Browse Source

refactored entry

renamed entry files iaw guidelines. Refactored legacy entry as entry_deprecated to avoid conflicts and adjusted includes.
Felix Turo 4 years ago
parent
commit
6e0f3d17fb

+ 4 - 4
openPilotLog.pro

@@ -31,9 +31,9 @@ SOURCES += \
     src/database/db.cpp \
     src/database/dbinfo.cpp \
     src/database/dbsetup.cpp \
-    src/database/entry.cpp \
-    src/experimental/Entry.cpp \
+    src/database/entry_deprecated.cpp \
     src/experimental/adatabase.cpp \
+    src/experimental/entry.cpp \
     src/gui/dialogues/firstrundialog.cpp \
     src/gui/dialogues/newflightdialog.cpp \
     src/gui/dialogues/newpilotdialog.cpp \
@@ -62,11 +62,11 @@ HEADERS += \
     src/database/db.h \
     src/database/dbinfo.h \
     src/database/dbsetup.h \
-    src/database/entry.h \
+    src/database/entry_deprecated.h \
     src/experimental/Decl.h \
-    src/experimental/Entry.h \
     src/experimental/UserInput.h \
     src/experimental/adatabase.h \
+    src/experimental/entry.h \
     src/gui/dialogues/firstrundialog.h \
     src/gui/dialogues/newflightdialog.h \
     src/gui/dialogues/newpilotdialog.h \

+ 2 - 2
src/classes/aircraft.h

@@ -18,13 +18,13 @@
 #ifndef AIRCRAFT_H
 #define AIRCRAFT_H
 #include <QCoreApplication>
-#include "src/database/entry.h"
+#include "src/database/entry_deprecated.h"
 
 /*!
  * \brief The aircraft class
  *
  */
-class Aircraft : public Entry
+class Aircraft : public Entry_deprecated
 {
 //    using Entry::Entry;
 public:

+ 2 - 2
src/classes/flight.h

@@ -21,10 +21,10 @@
 #include <QCoreApplication>
 #include <QDateTime>
 #include <QDebug>
-#include "src/database/entry.h"
+#include "src/database/entry_deprecated.h"
 
 
-class Flight : public Entry
+class Flight : public Entry_deprecated
 {
 //    using Entry::Entry;
 public:

+ 2 - 2
src/classes/pilot.h

@@ -17,10 +17,10 @@
  */
 #ifndef PILOT_H
 #define PILOT_H
-#include "src/database/entry.h"
+#include "src/database/entry_deprecated.h"
 
 
-class Pilot : public Entry
+class Pilot : public Entry_deprecated
 {
 //    using Entry::Entry;
 public:

+ 12 - 12
src/database/entry.cpp → src/database/entry_deprecated.cpp

@@ -15,15 +15,15 @@
  *You should have received a copy of the GNU General Public License
  *along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
-#include "entry.h"
+#include "entry_deprecated.h"
 #include "debug.h"
 #include "db.h"
 
-Entry::Entry()
+Entry_deprecated::Entry_deprecated()
 {
 }
 
-Entry::Entry(QString table, int row)
+Entry_deprecated::Entry_deprecated(QString table, int row)
 {
     //retreive database layout
     const auto dbContent = DbInfo();
@@ -65,7 +65,7 @@ Entry::Entry(QString table, int row)
     }
 }
 
-Entry::Entry(QString table, QMap<QString, QString> newData)
+Entry_deprecated::Entry_deprecated(QString table, QMap<QString, QString> newData)
 {
     //retreive database layout
     const auto dbContent = DbInfo();
@@ -93,7 +93,7 @@ Entry::Entry(QString table, QMap<QString, QString> newData)
     data = newData;
 }
 
-void Entry::setData(QMap<QString, QString> &value)
+void Entry_deprecated::setData(QMap<QString, QString> &value)
 {
     //retreive database layout
     const auto dbContent = DbInfo();
@@ -114,7 +114,7 @@ void Entry::setData(QMap<QString, QString> &value)
     data = value;
 }
 
-bool Entry::commit()
+bool Entry_deprecated::commit()
 {
     if (exists()) {
         return update();
@@ -123,7 +123,7 @@ bool Entry::commit()
     }
 }
 
-bool Entry::remove()
+bool Entry_deprecated::remove()
 {
     if (exists()) {
         QString statement = "DELETE FROM " + position.first +
@@ -143,7 +143,7 @@ bool Entry::remove()
     }
 }
 
-bool Entry::exists()
+bool Entry_deprecated::exists()
 {
     //Check database for row id
     QString statement = "SELECT COUNT(*) FROM " + position.first +
@@ -160,7 +160,7 @@ bool Entry::exists()
     }
 }
 
-bool Entry::insert()
+bool Entry_deprecated::insert()
 {
     DEB("Inserting...");
     //check prerequisites
@@ -193,7 +193,7 @@ bool Entry::insert()
     }
 }
 
-bool Entry::update()
+bool Entry_deprecated::update()
 {
     //create query
     QString statement = "UPDATE " + position.first + " SET ";
@@ -224,7 +224,7 @@ bool Entry::update()
 }
 
 //Debug
-void Entry::print()
+void Entry_deprecated::print()
 {
     QString v = "Object status:\t\033[38;2;0;255;0;48;2;0;0;0m VALID \033[0m\n";
     QString nv = "Object status:\t\033[38;2;255;0;0;48;2;0;0;0m INVALID \033[0m\n";
@@ -240,7 +240,7 @@ void Entry::print()
     }
 }
 
-QString Entry::debug()
+QString Entry_deprecated::debug()
 {
     print();
     return QString();

+ 4 - 4
src/database/entry.h → src/database/entry_deprecated.h

@@ -26,12 +26,12 @@
  * It can be seen as a row in a table within the database.
  *
  */
-class Entry
+class Entry_deprecated
 {
 public:
-    Entry();
-    Entry(QString table, int row);
-    Entry(QString table, QMap<QString, QString> newData);
+    Entry_deprecated();
+    Entry_deprecated(QString table, int row);
+    Entry_deprecated(QString table, QMap<QString, QString> newData);
 
     QPair   <QString, int>       position = QPair<QString, int>();    // Position within the database, i.e. <table,row>
     QVector <QString>            columns  = QVector<QString>();       // The columns within the table

+ 1 - 1
src/experimental/adatabase.h

@@ -10,7 +10,7 @@
 #include "src/database/dbinfo.h"
 #include "debug.h"
 
-#include "Entry.h"
+#include "entry.h"
 
 namespace experimental {
 

+ 1 - 1
src/experimental/Entry.cpp → src/experimental/entry.cpp

@@ -1,4 +1,4 @@
-#include "Entry.h"
+#include "entry.h"
 
 namespace experimental {
 

+ 0 - 0
src/experimental/Entry.h → src/experimental/entry.h


+ 1 - 1
src/gui/dialogues/newpilotdialog.h

@@ -26,7 +26,7 @@
 #include "src/classes/pilot.h"
 
 #include "src/experimental/adatabase.h"
-#include "src/experimental/Entry.h"
+#include "src/experimental/entry.h"
 #include "src/experimental/Decl.h"
 
 namespace Ui {

+ 2 - 2
src/gui/dialogues/newtaildialog.cpp

@@ -112,7 +112,7 @@ void NewTailDialog::setupValidators()
  * information contained in an aircraft object.
  * \param db - entry retreived from database
  */
-void NewTailDialog::formFiller(Entry entry)
+void NewTailDialog::formFiller(Entry_deprecated entry)
 {
     DEB("Filling Form for a/c" << entry);
     //fill Line Edits
@@ -247,7 +247,7 @@ void NewTailDialog::on_searchLineEdit_textChanged(const QString &arg1)
 
         DEB("Template Selected. aircraft_id is: " << idMap.value(arg1));
         //call autofiller for dialog
-        formFiller(Entry("aircraft",idMap.value(arg1)));
+        formFiller(Entry_deprecated("aircraft",idMap.value(arg1)));
         ui->searchLineEdit->setStyleSheet("border: 1px solid green");
     } else {
         //for example, editing finished without selecting a result from Qcompleter

+ 2 - 2
src/gui/dialogues/newtaildialog.h

@@ -27,7 +27,7 @@
 #include "src/classes/aircraft.h"
 #include "src/classes/strictrxvalidator.h"
 #include "src/classes/acalc.h"
-#include "src/database/entry.h"
+#include "src/database/entry_deprecated.h"
 #include "src/experimental/adatabase.h"
 
 namespace Ui {
@@ -85,7 +85,7 @@ private:
 
     void setupValidators();
 
-    void formFiller(Entry);
+    void formFiller(Entry_deprecated);
 
     bool verify();
 };

+ 1 - 1
src/gui/widgets/homewidget.h

@@ -28,7 +28,7 @@
 #include "src/gui/dialogues/newtaildialog.h"
 #include "src/classes/aircraft.h"
 #include "src/gui/dialogues/newpilotdialog.h"
-#include "src/database/entry.h"
+#include "src/database/entry_deprecated.h"
 #include "src/gui/widgets/totalswidget.h"
 #include "src/gui/dialogues/firstrundialog.h"
 #include "src/gui/dialogues/newflightdialog.h"