Browse Source

Requested changes

requested changes as per comments
Felix 4 years ago
parent
commit
b866e7020d
4 changed files with 18 additions and 20 deletions
  1. 11 14
      mainwindow.cpp
  2. 4 4
      src/classes/aflightentry.cpp
  3. 2 2
      src/classes/aflightentry.h
  4. 1 0
      src/database/adatabase.cpp

+ 11 - 14
mainwindow.cpp

@@ -76,20 +76,17 @@ MainWindow::MainWindow(QWidget *parent)
     //// START DEBUG ////
     /// [F] I understand how it is annoying to not have the database
     /// working when something has changed. Hopefully this check
-    /// helps to avoid that in the future!
-    const int DATABASE_REVISION_NUMBER = 15;
-    QSqlQuery query;
-    query.prepare("SELECT COUNT (*) FROM changelog");
-    query.exec();
-    query.next();
-    if (query.value(0).toInt() != DATABASE_REVISION_NUMBER) {
-        DEB("##########################################");
-        DEB("Your database is out of date.");
-        DEB("Current Revision:  " << DATABASE_REVISION_NUMBER);
-        DEB("You have revision: " << query.value(0).toInt());
-        DEB("Use of DebugWidget to udpate recommended.");
-        DEB("##########################################");
-    }
+    /// helps to avoid that in the future! 
+    #if DATABASE < 15
+    DEB("Your database is up to date with the latest revision.");
+    #else
+    DEB("##########################################");
+    DEB("Your database is out of date.");
+    DEB("Current Revision:  " << DATABASE_REVISION_NUMBER);
+    DEB("You have revision: " << query.value(0).toInt());
+    DEB("Use of DebugWidget to udpate recommended.");
+    DEB("##########################################");
+    #endif
     //// END DEBUG ////
 
 }

+ 4 - 4
src/classes/aflightentry.cpp

@@ -51,19 +51,19 @@ const QString AFlightEntry::getRegistration()
     return acft.registration();
 }
 
-const QString AFlightEntry::getPilotName(pilot pilot_)
+const QString AFlightEntry::getPilotName(pilotPosition pilot_)
 {
     switch (pilot_) {
-    case pilot::pic: {
+    case pilotPosition::pic: {
         auto foreign_pilot = aDB()->resolveForeignPilot(tableData.value(DB_FLIGHTS_PIC).toInt());
         return foreign_pilot.name();
         break;
     }
-    case pilot::sic: {
+    case pilotPosition::secondPilot: {
         auto foreign_pilot = aDB()->resolveForeignPilot(tableData.value(DB_FLIGHTS_SECONDPILOT).toInt());
         return foreign_pilot.name();
     }
-    case pilot::thirdPilot: {
+    case pilotPosition::thirdPilot: {
         auto foreign_pilot = aDB()->resolveForeignPilot(tableData.value(DB_FLIGHTS_THIRDPILOT).toInt());
         return foreign_pilot.name();
         break;

+ 2 - 2
src/classes/aflightentry.h

@@ -29,7 +29,7 @@ public:
     AFlightEntry(int row_id);
     AFlightEntry(RowData table_data);
 
-    enum pilot { pic, sic, thirdPilot };
+    enum class pilotPosition { pic, secondPilot, thirdPilot };
 
     /*!
      * \brief Returs a summary of the flight data, if struct holds data
@@ -46,7 +46,7 @@ public:
      * \param pilot_number - 1=pic, 2=second Pilot, 3 = third Pilot
      * \return "Lastname, Firstname"
      */
-    const QString getPilotName(pilot);
+    const QString getPilotName(pilotPosition);
 };
 
 #endif // AFLIGHTENTRY_H

+ 1 - 0
src/database/adatabase.cpp

@@ -18,6 +18,7 @@
 #include "adatabase.h"
 #include "src/testing/adebug.h"
 
+#define DATABASE_VERSION 15
 const auto SQL_DRIVER = QStringLiteral("QSQLITE");
 
 ADatabaseError::ADatabaseError(QString msg_)