From f7d222d99ddb212606d439af3bea03643e215737 Mon Sep 17 00:00:00 2001 From: Joern Date: Thu, 19 Nov 2015 21:45:19 +0100 Subject: [PATCH] TrainDB - fix //1 remove workout error ... caused error in list-model since entries are added and "end-of" dbtable ... now only update of texts in upgrade to handle pre 3.3 translation problems --- src/GcUpgrade.cpp | 4 +--- src/TrainDB.cpp | 29 +++++++++++++++++++++-------- src/TrainDB.h | 6 +++--- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/GcUpgrade.cpp b/src/GcUpgrade.cpp index c7add0832..6064fe921 100644 --- a/src/GcUpgrade.cpp +++ b/src/GcUpgrade.cpp @@ -356,9 +356,7 @@ GcUpgrade::upgrade(const QDir &home) if (last < VERSION33_BUILD) { - // cleanup/restore default entries in the trainDB - trainDB->updateDefaultEntries(); - + trainDB->upgradeDefaultEntriesWorkout(); } diff --git a/src/TrainDB.cpp b/src/TrainDB.cpp index e0236b6e8..fb61e093f 100644 --- a/src/TrainDB.cpp +++ b/src/TrainDB.cpp @@ -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)); diff --git a/src/TrainDB.h b/src/TrainDB.h index dbaeb6123..be2f8e40d 100644 --- a/src/TrainDB.h +++ b/src/TrainDB.h @@ -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();