Merge pull request #1681 from Joern-R/traindb

TrainDB -  fix //1 remove workout error
This commit is contained in:
Mark Liversedge
2015-11-19 21:04:20 +00:00
3 changed files with 25 additions and 14 deletions

View File

@@ -356,9 +356,7 @@ GcUpgrade::upgrade(const QDir &home)
if (last < VERSION33_BUILD) {
// cleanup/restore default entries in the trainDB
trainDB->updateDefaultEntries();
trainDB->upgradeDefaultEntriesWorkout();
}

View File

@@ -89,14 +89,6 @@ TrainDB::rebuildDB()
createVideoSyncTable();
}
bool
TrainDB::updateDefaultEntries() {
bool rc1 = createDefaultEntriesWorkout();
bool rc2 = createDefaultEntriesVideosync();
return rc1 && rc2;
}
bool TrainDB::createVideoTable()
{
@@ -507,6 +499,27 @@ bool TrainDB::createDefaultEntriesWorkout()
return rc;
}
bool TrainDB::upgradeDefaultEntriesWorkout()
{
// set texts starting with " " in upgrade - since due to same translation errors the " " was lost e.g. in German
QSqlQuery query(db->database(sessionid));
bool rc;
// adding a space at the front of string to make manual mode always
// appear first in a sorted list is a bit of a hack, but works ok
QString manualErg = QString("UPDATE workouts SET filename = \"%1\" WHERE filepath = \"//1\";")
.arg(" " + tr("Manual Erg Mode")); // keep the SPACE separate so that translation cannot remove it
rc = query.exec(manualErg);
QString manualCrs = QString("UPDATE workouts SET filename = \"%1\" WHERE filepath = \"//2\";")
.arg(" " + tr("Manual Slope Mode")); // keep the SPACE separate so that translation cannot remove it
rc = query.exec(manualCrs);
return rc;
}
bool TrainDB::createDefaultEntriesVideosync()
{
QSqlQuery query(db->database(sessionid));

View File

@@ -61,12 +61,12 @@ class TrainDB : public QObject
bool importVideoSync(QString pathname, VideoSyncFile *videosyncFile);
bool deleteVideoSync(QString pathname);
// for 3.3
bool upgradeDefaultEntriesWorkout();
// drop and recreate tables
void rebuildDB();
// update default entries in the tables
bool updateDefaultEntries();
signals:
void dataChanged();