Browse Source

code formatting

fiffty-50 4 years ago
parent
commit
6e3a980820

+ 3 - 3
mainwindow.cpp

@@ -23,7 +23,7 @@ MainWindow::MainWindow(QWidget *parent)
     , ui(new Ui::MainWindow)
 {
     ui->setupUi(this);
-    db::connect();
+    Db::connect();
 
     // Set up Toolbar
     ui->toolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
@@ -125,7 +125,7 @@ void MainWindow::on_actionAircraft_triggered()
 
 void MainWindow::on_actionNewAircraft_triggered()
 {
-    auto nt = new NewTail(QString(), db::createNew, this);
+    auto nt = new NewTail(QString(), Db::createNew, this);
     nt->show();
 }
 
@@ -138,6 +138,6 @@ void MainWindow::on_actionPilots_triggered()
 
 void MainWindow::on_actionNewPilot_triggered()
 {
-    auto np = new NewPilot(db::createNew, this);
+    auto np = new NewPilot(Db::createNew, this);
     np->show();
 }

+ 2 - 2
openPilotLog.pro

@@ -24,7 +24,7 @@ SOURCES += \
     src/classes/flight.cpp \
     src/classes/pilot.cpp \
     src/classes/stat.cpp \
-    src/classes/strictregularexpressionvalidator.cpp \
+    src/classes/strictrxvalidator.cpp \
     src/database/db.cpp \
     src/database/dbinfo.cpp \
     src/database/entry.cpp \
@@ -45,7 +45,7 @@ HEADERS += \
     src/classes/flight.h \
     src/classes/pilot.h \
     src/classes/stat.h \
-    src/classes/strictregularexpressionvalidator.h \
+    src/classes/strictrxvalidator.h \
     src/database/db.h \
     src/database/dbinfo.h \
     src/database/entry.h \

+ 2 - 2
src/classes/aircraft.h

@@ -24,9 +24,9 @@
  * \brief The aircraft class
  *
  */
-class aircraft : public entry
+class Aircraft : public Entry
 {
-    using entry::entry;
+    using Entry::Entry;
 };
 
 #endif // AIRCRAFT_H

+ 39 - 39
src/classes/calc.cpp

@@ -18,12 +18,12 @@
 #include "calc.h"
 //#include "dbman.cpp"
 /*!
- * \brief calc::blocktime Calculates Block Time for a given departure and arrival time
+ * \brief Calc::blocktime Calculates Block Time for a given departure and arrival time
  * \param tofb QTime Time Off Blocks
  * \param tonb QTime Time On Blocks
  * \return Block Time in minutes
  */
-QTime calc::blocktime(QTime tofb, QTime tonb)
+QTime Calc::blocktime(QTime tofb, QTime tonb)
 {
     if (tonb > tofb) { // landing same day
         QTime blocktimeout(0, 0); // initialise return value at midnight
@@ -44,11 +44,11 @@ QTime calc::blocktime(QTime tofb, QTime tonb)
 
 
 /*!
- * \brief calc::minutes_to_string Converts database time to String Time
+ * \brief Calc::minutes_to_string Converts database time to String Time
  * \param blockminutes int from database
  * \return String hh:mm
  */
-QString calc::minutes_to_string(QString blockminutes)
+QString Calc::minutes_to_string(QString blockminutes)
 {
     int minutes = blockminutes.toInt();
     QString hour = QString::number(minutes / 60);
@@ -64,11 +64,11 @@ QString calc::minutes_to_string(QString blockminutes)
 };
 
 /*!
- * \brief calc::time_to_minutes converts QTime to int minutes
+ * \brief Calc::time_to_minutes converts QTime to int minutes
  * \param time QTime
  * \return int time as number of minutes
  */
-int calc::time_to_minutes(QTime time)
+int Calc::time_to_minutes(QTime time)
 {
     QString timestring = time.toString("hh:mm");
     int minutes = (timestring.left(2).toInt()) * 60;
@@ -77,11 +77,11 @@ int calc::time_to_minutes(QTime time)
 }
 
 /*!
- * \brief calc::string_to_minutes Converts String Time to String Number of Minutes
+ * \brief Calc::string_to_minutes Converts String Time to String Number of Minutes
  * \param timestring "hh:mm"
  * \return String number of minutes
  */
-int calc::string_to_minutes(QString timestring)
+int Calc::string_to_minutes(QString timestring)
 {
     int minutes = (timestring.left(2).toInt()) * 60;
     minutes += timestring.right(2).toInt();
@@ -90,7 +90,7 @@ int calc::string_to_minutes(QString timestring)
 }
 
 /*!
- * The purpose of the following functions is to provide functionality enabling the calculation of
+ * The purpose of the following functions is to provide functionality enabling the Calculation of
  * night flying time. EASA defines night as follows:
  *
  * ‘Night’  means  the  period  between  the  end  of  evening  civil  twilight  and  the  beginning  of
@@ -99,14 +99,14 @@ int calc::string_to_minutes(QString timestring)
  *
  *
  *
- * This is the proccess of calculating night time in this program:
+ * This is the proccess of Calculating night time in this program:
  *
  * 1) A flight from A to B follows the Great Circle Track along these two points
  *    at an average cruising height of 11km. (~FL 360)
  *
  * 2) Any time the Elevation of the Sun at the current position is less
  *    than -6 degrees, night conditions are present.
- * 3) The calculation is performed for every minute of flight time.
+ * 3) The Calculation is performed for every minute of flight time.
  *
  * In general, input and output for most functions is decimal degrees, like coordinates
  * are stowed in the airports table. Calculations are normally done using
@@ -118,7 +118,7 @@ int calc::string_to_minutes(QString timestring)
  * \param rad
  * \return degrees
  */
-double calc::radToDeg(double rad)
+double Calc::radToDeg(double rad)
 {
     double deg = rad * (180 / M_PI);
     return deg;
@@ -129,7 +129,7 @@ double calc::radToDeg(double rad)
  * \param deg
  * \return radians
  */
-double calc::degToRad(double deg)
+double Calc::degToRad(double deg)
 {
     double rad = deg * (M_PI / 180);
     return rad;
@@ -140,7 +140,7 @@ double calc::degToRad(double deg)
  * \param rad
  * \return nautical miles
  */
-double calc::radToNauticalMiles(double rad)
+double Calc::radToNauticalMiles(double rad)
 {
     double nm = rad * 3440.06479482;
     return nm;
@@ -154,7 +154,7 @@ double calc::radToNauticalMiles(double rad)
  * \param lon2 Location Longitude in degrees -180:180 W(-) E(+)
  * \return
  */
-double calc::greatCircleDistance(double lat1, double lon1, double lat2, double lon2)
+double Calc::greatCircleDistance(double lat1, double lon1, double lat2, double lon2)
 {
     // Converting Latitude and Longitude to Radians
     lat1 = degToRad(lat1);
@@ -173,13 +173,13 @@ double calc::greatCircleDistance(double lat1, double lon1, double lat2, double l
 }
 
 /*!
- * \brief calc::greatCircleDistanceBetweenAirports Calculates Great
+ * \brief Calc::greatCircleDistanceBetweenAirports Calculates Great
  * Circle distance between two coordinates, return in nautical miles.
  * \param dept ICAO 4-letter Airport Identifier
  * \param dest ICAO 4-letter Airport Identifier
  * \return Nautical Miles From Departure to Destination
  */
-double calc::greatCircleDistanceBetweenAirports(QString dept, QString dest)
+double Calc::greatCircleDistanceBetweenAirports(QString dept, QString dest)
 {
     //db::multiSelect("airports", columns, "EDDF", "icao", db::exactMatch);
     /*if(dbAirport::retreiveIcaoCoordinates(dept).isEmpty() || dbAirport::retreiveIcaoCoordinates(dest).isEmpty()){
@@ -188,10 +188,10 @@ double calc::greatCircleDistanceBetweenAirports(QString dept, QString dest)
     }*/
 
     QVector<QString> columns = {"lat", "long"};
-    QVector<QString> deptCoordinates = db::multiSelect(columns, "airports", "icao", dept,
-                                                       db::exactMatch);
-    QVector<QString> destCoordinates = db::multiSelect(columns, "airports", "icao", dest,
-                                                       db::exactMatch);
+    QVector<QString> deptCoordinates = Db::multiSelect(columns, "airports", "icao", dept,
+                                                       Db::exactMatch);
+    QVector<QString> destCoordinates = Db::multiSelect(columns, "airports", "icao", dest,
+                                                       Db::exactMatch);
 
     if (deptCoordinates.isEmpty() || destCoordinates.isEmpty()
        ) {
@@ -224,10 +224,10 @@ double calc::greatCircleDistanceBetweenAirports(QString dept, QString dest)
  * \param tblk Total Blocktime in minutes
  * \return coordinates {lat,lon} along the Great Circle Track
  */
-QVector<QVector<double>> calc::intermediatePointsOnGreatCircle(double lat1, double lon1,
+QVector<QVector<double>> Calc::intermediatePointsOnGreatCircle(double lat1, double lon1,
                                                                double lat2, double lon2, int tblk)
 {
-    double d = greatCircleDistance(lat1, lon1, lat2, lon2); //calculate distance (radians)
+    double d = greatCircleDistance(lat1, lon1, lat2, lon2); //Calculate distance (radians)
     // Converting Latitude and Longitude to Radians
     lat1 = degToRad(lat1);
     lon1 = degToRad(lon1);
@@ -265,16 +265,16 @@ QVector<QVector<double>> calc::intermediatePointsOnGreatCircle(double lat1, doub
  * Darin C. Koblock: https://www.mathworks.com/matlabcentral/profile/authors/1284781
  * Kevin Godden: https://www.ridgesolutions.ie/index.php/about-us/
  *
- * \param utc_time_point - QDateTime (UTC) for which the elevation is calculated
+ * \param utc_time_point - QDateTime (UTC) for which the elevation is Calculated
  * \param lat - Location Latitude in degrees -90:90 ;S(-) N(+)
  * \param lon - Location Longitude in degrees -180:180 W(-) E(+)
  * \return elevation - double of solar elevation in degrees.
  */
-double calc::solarElevation(QDateTime utc_time_point, double lat, double lon)
+double Calc::solarElevation(QDateTime utc_time_point, double lat, double lon)
 {
     double Alt =
         11; // I am taking 11 kilometers as an average cruising height for a commercial passenger airplane.
-    // convert current DateTime Object to a J2000 value used in the calculation
+    // convert current DateTime Object to a J2000 value used in the Calculation
     double d = utc_time_point.date().toJulianDay() - 2451544 + utc_time_point.time().hour() / 24.0 +
                utc_time_point.time().minute() / 1440.0;
 
@@ -337,17 +337,17 @@ double calc::solarElevation(QDateTime utc_time_point, double lat, double lon)
  * \param tblk - Total block time in minutes
  * \return Total number of minutes under night flying conditions
  */
-int calc::calculateNightTime(QString dept, QString dest, QDateTime departureTime, int tblk)
+int Calc::calculateNightTime(QString dept, QString dest, QDateTime departureTime, int tblk)
 {
     QVector<QString> columns = {"lat", "long"};
-    QVector<QString> deptCoordinates = db::multiSelect(columns, "airports", "icao", dept,
-                                                       db::exactMatch);
-    QVector<QString> destCoordinates = db::multiSelect(columns, "airports", "icao", dest,
-                                                       db::exactMatch);
+    QVector<QString> deptCoordinates = Db::multiSelect(columns, "airports", "icao", dept,
+                                                       Db::exactMatch);
+    QVector<QString> destCoordinates = Db::multiSelect(columns, "airports", "icao", dest,
+                                                       Db::exactMatch);
 
     if (deptCoordinates.isEmpty() || destCoordinates.isEmpty()
        ) {
-        qDebug() << "calc::calculateNightTime - invalid input. aborting.";
+        qDebug() << "Calc::CalculateNightTime - invalid input. aborting.";
         return 0;
     }
 
@@ -356,10 +356,10 @@ int calc::calculateNightTime(QString dept, QString dest, QDateTime departureTime
     double destLat = degToRad(destCoordinates[0].toDouble());
     double destLon = degToRad(destCoordinates[1].toDouble());
 
-    qDebug() << "calc::calculateNightTime deptLat = " << deptLat;
-    qDebug() << "calc::calculateNightTime deptLon = " << deptLon;
-    qDebug() << "calc::calculateNightTime destLat = " << destLat;
-    qDebug() << "calc::calculateNightTime destLon = " << destLon;
+    qDebug() << "Calc::CalculateNightTime deptLat = " << deptLat;
+    qDebug() << "Calc::CalculateNightTime deptLon = " << deptLon;
+    qDebug() << "Calc::CalculateNightTime destLat = " << destLat;
+    qDebug() << "Calc::CalculateNightTime destLon = " << destLon;
 
     QVector<QVector<double>> route = intermediatePointsOnGreatCircle(deptLat, deptLon, destLat, destLon,
                                                                      tblk);
@@ -371,18 +371,18 @@ int calc::calculateNightTime(QString dept, QString dest, QDateTime departureTime
             nightTime ++;
         }
     }
-    qDebug() << "calc::calculateNightTime result: " << nightTime << " minutes night flying time.";
+    qDebug() << "Calc::CalculateNightTime result: " << nightTime << " minutes night flying time.";
     return nightTime;
 }
 
 /*!
- * \brief calc::formatTimeInput verifies user input and formats to hh:mm
+ * \brief Calc::formatTimeInput verifies user input and formats to hh:mm
  * if the output is not a valid time, an empty string is returned. Accepts
  * input as hh:mm, h:mm, hhmm or hmm.
  * \param userinput from a QLineEdit
  * \return formatted QString "hh:mm" or Empty String
  */
-QString calc::formatTimeInput(QString userinput)
+QString Calc::formatTimeInput(QString userinput)
 {
     QString output; //
     QTime temptime; //empty time object is invalid by default

+ 1 - 1
src/classes/calc.h

@@ -28,7 +28,7 @@
  * outside of the database. This includes tasks like converting different units and formats,
  * or functions calculating block time or night time.
  */
-class calc
+class Calc
 {
 public:
 

+ 12 - 12
src/classes/completionlist.cpp

@@ -17,7 +17,7 @@
  */
 #include "completionlist.h"
 
-completionList::completionList()
+CompletionList::CompletionList()
 {
 
 }
@@ -27,32 +27,32 @@ completionList::completionList()
  * Access object->list for the list.
  * \param type see enum completerTarget::targets
  */
-completionList::completionList(completerTarget::targets type)
+CompletionList::CompletionList(CompleterTarget::targets type)
 {
     QString query;
     QVector<QString> columns;
     QVector<QString> result;
 
     switch (type) {
-    case completerTarget::pilots:
+    case CompleterTarget::pilots:
         query.append("SELECT piclastname||', '||picfirstname FROM pilots");
-        result = db::customQuery(query, 1);
+        result = Db::customQuery(query, 1);
         break;
-    case completerTarget::airports:
+    case CompleterTarget::airports:
         columns.append("icao");
         columns.append("iata");
-        result = db::multiSelect(columns, "airports");
+        result = Db::multiSelect(columns, "airports");
         break;
-    case completerTarget::registrations:
+    case CompleterTarget::registrations:
         columns.append("registration");
-        result = db::multiSelect(columns, "tails");
+        result = Db::multiSelect(columns, "tails");
         break;
-    case completerTarget::aircraft:
+    case CompleterTarget::aircraft:
         query.append("SELECT make||' '||model||'-'||variant FROM aircraft");
-        result = db::customQuery(query, 1);
+        result = Db::customQuery(query, 1);
         break;
     }
 
-    completionList::list = result.toList();
-    completionList::list.removeAll(QString(""));
+    CompletionList::list = result.toList();
+    CompletionList::list.removeAll(QString(""));
 }

+ 4 - 7
src/classes/completionlist.h

@@ -21,7 +21,7 @@
 #include <QCoreApplication>
 #include "src/database/db.h"
 
-class completerTarget
+class CompleterTarget
 {
 public:
     enum targets {airports, pilots, registrations, aircraft};
@@ -31,17 +31,14 @@ public:
 /*!
  * \brief The completionList class provides QStringLists to be used by a QCompleter
  */
-class completionList
+class CompletionList
 {
 public:
-
-
-
     QStringList list;
 
-    completionList();
+    CompletionList();
 
-    completionList(completerTarget::targets);
+    CompletionList(CompleterTarget::targets);
 };
 
 #endif // COMPLETIONLIST_H

+ 2 - 2
src/classes/flight.h

@@ -24,9 +24,9 @@
 #include "src/database/entry.h"
 
 
-class flight : public entry
+class Flight : public Entry
 {
-    using entry::entry;
+    using Entry::Entry;
 };
 
 #endif // FLIGHT_H

+ 2 - 2
src/classes/pilot.h

@@ -20,9 +20,9 @@
 #include "src/database/entry.h"
 
 
-class pilot : public entry
+class Pilot : public Entry
 {
-    using entry::entry;
+    using Entry::Entry;
 };
 
 #endif // PILOT_H

+ 10 - 10
src/classes/stat.cpp

@@ -19,29 +19,29 @@
 
 
 /*!
- * \brief stat::totalTime Looks up Total Blocktime in the flights database
+ * \brief Stat::totalTime Looks up Total Blocktime in the flights database
  * \param yearType - Whether the calculation is based on total time, last
  * calendar year or the last rolling year
  * \return Amount of Total Block Time in minutes
  */
-QString stat::totalTime(yearType yt)
+QString Stat::totalTime(yearType yt)
 {
     QString query;
     QDate start;
     QString startdate;
 
     switch (yt) {
-    case stat::allYears:
+    case Stat::allYears:
         query = "SELECT SUM(tblk) FROM flights";
         break;
-    case stat::calendarYear:
+    case Stat::calendarYear:
         start.setDate(QDate::currentDate().year(), 1, 1);
         startdate = start.toString(Qt::ISODate);
         startdate.append(QLatin1Char('\''));
         startdate.prepend(QLatin1Char('\''));
         query = "SELECT SUM(tblk) FROM flights WHERE doft >= " + startdate;
         break;
-    case stat::rollingYear:
+    case Stat::rollingYear:
         start = QDate::fromJulianDay(QDate::currentDate().toJulianDay() - 365);
         startdate = start.toString(Qt::ISODate);
         startdate.append(QLatin1Char('\''));
@@ -50,7 +50,7 @@ QString stat::totalTime(yearType yt)
         break;
     }
 
-    QVector<QString> result = db::customQuery(query, 1);
+    QVector<QString> result = Db::customQuery(query, 1);
 
     if (!result.isEmpty()) {
         return result[0];
@@ -60,12 +60,12 @@ QString stat::totalTime(yearType yt)
 }
 
 /*!
- * \brief stat::currencyTakeOffLanding Returns the amount of Take Offs and
+ * \brief Stat::currencyTakeOffLanding Returns the amount of Take Offs and
  * Landings performed in the last x days. Normally, 90 would be used. (EASA)
  * \param days Number of days to check
  * \return {TO,LDG}
  */
-QVector<QString> stat::currencyTakeOffLanding(int days)
+QVector<QString> Stat::currencyTakeOffLanding(int days)
 {
     QDate start = QDate::fromJulianDay(QDate::currentDate().toJulianDay() - days);
     QString startdate = start.toString(Qt::ISODate);
@@ -77,7 +77,7 @@ QVector<QString> stat::currencyTakeOffLanding(int days)
                     "SUM(flights.LDGday) + SUM(flights.LDGnight) AS 'LDG' "
                     "FROM flights "
                     "WHERE doft >= " + startdate;
-    QVector<QString> result = db::customQuery(query, 2);
+    QVector<QString> result = Db::customQuery(query, 2);
 
     if (!result.isEmpty()) {
         return result;
@@ -87,7 +87,7 @@ QVector<QString> stat::currencyTakeOffLanding(int days)
 
 }
 
-QVector<QPair<QString, QString>> stat::totals()
+QVector<QPair<QString, QString>> Stat::totals()
 {
     QString statement = "SELECT"
                         " printf(SUM(tblk)/60)||':'||printf('%02d',SUM(tblk)%60),"

+ 1 - 1
src/classes/stat.h

@@ -26,7 +26,7 @@
  * from the database, such as total times or recency. In general, most values are
  * provided as either QString or QVector<QString>.
  */
-class stat
+class Stat
 {
 public:
 

+ 2 - 2
src/classes/strictregularexpressionvalidator.cpp → src/classes/strictrxvalidator.cpp

@@ -15,9 +15,9 @@
  *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 "strictregularexpressionvalidator.h"
+#include "strictrxvalidator.h"
 
-QValidator::State StrictRegularExpressionValidator::validate(QString &txt, int &pos) const
+QValidator::State StrictRxValidator::validate(QString &txt, int &pos) const
 {
     auto validation = QRegularExpressionValidator::validate(txt, pos);
     if (validation == QValidator::Intermediate) {

+ 4 - 17
src/classes/strictregularexpressionvalidator.h → src/classes/strictrxvalidator.h

@@ -15,8 +15,8 @@
  *You should have received a copy of the GNU General Public License
  *along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
-#ifndef STRICTREGULAREXPRESSIONVALIDATOR_H
-#define STRICTREGULAREXPRESSIONVALIDATOR_H
+#ifndef STRICTRXVALIDATOR_H
+#define STRICTRXVALIDATOR_H
 
 #include <QRegularExpression>
 #include <QValidator>
@@ -24,23 +24,10 @@
 /*!
  * \brief The StrictRegularExpressionValidator class only returns Invalid or Acceptable
  */
-class StrictRegularExpressionValidator : public QRegularExpressionValidator
+class StrictRxValidator : public QRegularExpressionValidator
 {
 public:
     QValidator::State validate(QString &txt, int &pos) const;
 };
 
-#endif // STRICTREGULAREXPRESSIONVALIDATOR_H
-
-/*class StrictRegularExpressionValidator : public QRegularExpressionValidator {
-public:
-    QValidator::State validate(QString& txt, int& pos) const {
-        {
-            auto validation = QRegularExpressionValidator::validate(txt, pos);
-            if(validation == QValidator::Intermediate) {
-                return QValidator::Invalid;
-            }
-            return validation;
-        }
-    }
-};*/
+#endif

+ 27 - 27
src/database/db.cpp

@@ -22,7 +22,7 @@
 #define DEB(expr) \
     qDebug() << __PRETTY_FUNCTION__ << "\t" << expr
 
-void db::connect()
+void Db::connect()
 {
     const QString driver("QSQLITE");
 
@@ -43,23 +43,23 @@ void db::connect()
     }
 }
 /*!
- * \brief db::exists checks if a certain value exists in the database with a sqlite WHERE statement
+ * \brief Db::exists checks if a certain value exists in the database with a sqlite WHERE statement
  * \param table - Name of the table
  * \param column - Name of the column
  * \param value - The value to be checked
  * \return
  */
-bool db::exists(QString column, QString table, QString checkColumn, QString value,
-                db::matchType match)
+bool Db::exists(QString column, QString table, QString checkColumn, QString value,
+                Db::matchType match)
 {
     bool output = false;
     QString statement = "SELECT " + column + " FROM " + table + " WHERE " + checkColumn;
 
     switch (match) {
-    case db::exactMatch:
+    case Db::exactMatch:
         statement += " = '" + value + QLatin1Char('\'');
         break;
-    case db::partialMatch:
+    case Db::partialMatch:
         value.append(QLatin1Char('%'));
         value.prepend(QLatin1Char('%'));
         statement.append(" LIKE '" + value + QLatin1Char('\''));
@@ -96,20 +96,20 @@ bool db::exists(QString column, QString table, QString checkColumn, QString valu
  * \param table - Name of the table
  * \param column - Name of the column
  * \param value - Identifier for WHERE statement
- * \param match - enum db::exactMatch or db::partialMatch
+ * \param match - enum Db::exactMatch or Db::partialMatch
  * \return QString
  */
-QString db::singleSelect(QString column, QString table, QString checkColumn, QString value,
-                         db::matchType match)
+QString Db::singleSelect(QString column, QString table, QString checkColumn, QString value,
+                         Db::matchType match)
 {
     QString statement = "SELECT " + column + " FROM " + table + " WHERE " + checkColumn;
     QString result;
 
     switch (match) {
-    case db::exactMatch:
+    case Db::exactMatch:
         statement += " = '" + value + QLatin1Char('\'');
         break;
-    case db::partialMatch:
+    case Db::partialMatch:
         value.append(QLatin1Char('%'));
         value.prepend(QLatin1Char('%'));
         statement.append(" LIKE '" + value + QLatin1Char('\''));
@@ -136,16 +136,16 @@ QString db::singleSelect(QString column, QString table, QString checkColumn, QSt
 }
 
 /*!
- * \brief db::multiSelect Returns multiple values from the database with a sqlite WHERE statement
+ * \brief Db::multiSelect Returns multiple values from the database with a sqlite WHERE statement
  * \param table - Name of the table
  * \param columns - QVector<QString> Names of the columns to be queried
  * \param value - Identifier for WHERE statement
  * \param checkColumn - column to match value to
- * \param match - enum db::exactMatch or db::partialMatch
+ * \param match - enum Db::exactMatch or Db::partialMatch
  * \return QVector<QString>
  */
-QVector<QString> db::multiSelect(QVector<QString> columns, QString table, QString checkColumn,
-                                 QString value, db::matchType match)
+QVector<QString> Db::multiSelect(QVector<QString> columns, QString table, QString checkColumn,
+                                 QString value, Db::matchType match)
 {
     QString statement = "SELECT ";
     for (const auto &column : columns) {
@@ -157,10 +157,10 @@ QVector<QString> db::multiSelect(QVector<QString> columns, QString table, QStrin
     statement.append(" FROM " + table + " WHERE " + checkColumn);
 
     switch (match) {
-    case db::exactMatch:
+    case Db::exactMatch:
         statement += " = '" + value + QLatin1Char('\'');
         break;
-    case db::partialMatch:
+    case Db::partialMatch:
         value.append(QLatin1Char('%'));
         value.prepend(QLatin1Char('%'));
         statement.append(" LIKE '" + value + QLatin1Char('\''));
@@ -189,12 +189,12 @@ QVector<QString> db::multiSelect(QVector<QString> columns, QString table, QStrin
     }
 }
 /*!
- * \brief db::multiSelect Returns a complete column(s) for a given table.
+ * \brief Db::multiSelect Returns a complete column(s) for a given table.
  * \param column
  * \param table
  * \return
  */
-QVector<QString> db::multiSelect(QVector<QString> columns, QString table)
+QVector<QString> Db::multiSelect(QVector<QString> columns, QString table)
 {
     QString statement = "SELECT ";
     for (const auto &column : columns) {
@@ -228,28 +228,28 @@ QVector<QString> db::multiSelect(QVector<QString> columns, QString table)
 }
 
 /*!
- * \brief db::singleUpdate Updates a single value in the database.
+ * \brief Db::singleUpdate Updates a single value in the database.
  * Query format: UPDATE table SET column = value WHERE checkcolumn =/LIKE checkvalue
  * \param table Name of the table to be updated
  * \param column Name of the column to be updated
  * \param checkColumn Name of the column for WHERE statement
  * \param value The value to be set
  * \param checkvalue The value for the WHERE statement
- * \param match enum db::exactMatch or db::partialMatch
+ * \param match enum Db::exactMatch or Db::partialMatch
  * \return true on success, otherwise error messages in debug out
  */
-bool db::singleUpdate(QString table, QString column, QString value, QString checkColumn,
-                      QString checkvalue, db::matchType match)
+bool Db::singleUpdate(QString table, QString column, QString value, QString checkColumn,
+                      QString checkvalue, Db::matchType match)
 {
     QString statement = "UPDATE " + table;
     statement.append(QLatin1String(" SET ") + column + QLatin1String(" = '") + value);
     statement.append(QLatin1String("' WHERE "));
 
     switch (match) {
-    case db::exactMatch:
+    case Db::exactMatch:
         statement.append(checkColumn + " = '" + checkvalue + QLatin1Char('\''));
         break;
-    case db::partialMatch:
+    case Db::partialMatch:
         value.append(QLatin1Char('%'));
         value.prepend(QLatin1Char('%'));
         statement.append(checkColumn + " LIKE '" + checkvalue + QLatin1Char('\''));
@@ -271,12 +271,12 @@ bool db::singleUpdate(QString table, QString column, QString value, QString chec
     }
 }
 /*!
- * \brief db::customQuery Can be used to send a complex query to the database.
+ * \brief Db::customQuery Can be used to send a complex query to the database.
  * \param query - the full sql query statement
  * \param returnValues - the number of expected return values
  * \return QVector<QString> of results
  */
-QVector<QString> db::customQuery(QString query, int returnValues)
+QVector<QString> Db::customQuery(QString query, int returnValues)
 {
     QSqlQuery q(query);
     DEB(query);

+ 6 - 6
src/database/db.h

@@ -29,13 +29,13 @@
 #include <QDebug>
 
 /*!
- * \brief The db class provides a basic API for accessing the database programatically.
+ * \brief The Db class provides a basic API for accessing the database programatically.
  * It is used to set up the initial connection and various basic queries can be
  * executed using a set of static functions. When interfacing with the database
  * for the purpose of adding, deleting or updating entries, the use of the entry class
  * and its subclasses is recommended.
  */
-class db
+class Db
 {
 public:
     /*!
@@ -52,13 +52,13 @@ public:
 
     static void             connect();
     static bool             exists(QString column, QString table, QString checkColumn,
-                                   QString value, db::matchType match);
+                                   QString value, Db::matchType match);
     static bool             singleUpdate(QString table, QString column, QString value,
-                                         QString checkColumn, QString checkvalue, db::matchType match);
+                                         QString checkColumn, QString checkvalue, Db::matchType match);
     static QString          singleSelect(QString column, QString table, QString checkColumn,
-                                         QString value, db::matchType match);
+                                         QString value, Db::matchType match);
     static QVector<QString> multiSelect(QVector<QString> columns, QString table,
-                                        QString checkColumn, QString value, db::matchType match);
+                                        QString checkColumn, QString value, Db::matchType match);
     static QVector<QString> multiSelect(QVector<QString> columns, QString table);
     static QVector<QString> customQuery(QString query, int returnValues);
 

+ 5 - 5
src/database/dbinfo.cpp

@@ -18,8 +18,8 @@
 #include "dbinfo.h"
 // Debug Makro
 #define DEB(expr) \
-    qDebug() << "dbInfo ::" << __PRETTY_FUNCTION__ << "\t" << expr
-dbInfo::dbInfo()
+    qDebug() << __PRETTY_FUNCTION__ << "\t" << expr
+DbInfo::DbInfo()
 {
     QSqlDatabase db = QSqlDatabase::database("qt_sql_default_connection");
     tables = db.tables().toVector();
@@ -28,10 +28,10 @@ dbInfo::dbInfo()
 }
 
 /*!
- * \brief dbInfo::getColumnNames Looks up column names for all tables
+ * \brief DbInfo::getColumnNames Looks up column names for all tables
  * in the database.
  */
-void dbInfo::getColumnNames()
+void DbInfo::getColumnNames()
 {
     QSqlDatabase db = QSqlDatabase::database("qt_sql_default_connection");
     QVector<QString> columnNames;
@@ -48,7 +48,7 @@ void dbInfo::getColumnNames()
 /*!
  * \brief db::sqliteversion queries database version.
  */
-void dbInfo::sqliteversion()
+void DbInfo::sqliteversion()
 {
     QSqlQuery q;
     q.prepare("SELECT sqlite_version()");

+ 2 - 2
src/database/dbinfo.h

@@ -22,10 +22,10 @@
 #include <QDebug>
 #include "db.h"
 
-class dbInfo
+class DbInfo
 {
 public:
-    dbInfo();
+    DbInfo();
 
     QString version = QString();
 

+ 16 - 16
src/database/entry.cpp

@@ -20,21 +20,21 @@
 #define DEB(expr) \
     qDebug() << __PRETTY_FUNCTION__ << "\t" << expr
 
-entry::entry()
+Entry::Entry()
 {
 
 }
 
-entry::entry(QString table, int row)
+Entry::Entry(QString table, int row)
 {
     //retreive database layout
-    const auto dbContent = dbInfo();
+    const auto dbContent = DbInfo();
 
     if (dbContent.tables.contains(table)) {
         position.first = table;
         columns = dbContent.format.value(table);
     } else {
-        DEB(table << " not a table in database. Unable to create entry object.");
+        DEB(table << " not a table in database. Unable to create Entry object.");
         position.first = QString();
     }
 
@@ -44,7 +44,7 @@ entry::entry(QString table, int row)
     q.next();
     int rows = q.value(0).toInt();
     if (rows == 0) {
-        DEB("No entry found for row id: " << row );
+        DEB("No Entry found for row id: " << row );
         position.second = 0;
     } else {
         DEB("Retreiving data for row id: " << row);
@@ -69,17 +69,17 @@ entry::entry(QString table, int row)
     }
 }
 
-entry::entry(QString table, QMap<QString, QString> newData)
+Entry::Entry(QString table, QMap<QString, QString> newData)
 {
     //retreive database layout
-    const auto dbContent = dbInfo();
+    const auto dbContent = DbInfo();
 
     if (dbContent.tables.contains(table)) {
         position.first = table;
         position.second = 0;
         columns = dbContent.format.value(table);
     } else {
-        DEB(table << " not a table in database. Unable to create entry object.");
+        DEB(table << " not a table in database. Unable to create Entry object.");
         position.first = QString();
     }
     //Check validity of newData
@@ -97,12 +97,12 @@ entry::entry(QString table, QMap<QString, QString> newData)
     data = newData;
 }
 
-void entry::setData(const QMap<QString, QString> &value)
+void Entry::setData(const QMap<QString, QString> &value)
 {
     data = value;
 }
 
-bool entry::commit()
+bool Entry::commit()
 {
     if (exists()) {
         return update();
@@ -111,7 +111,7 @@ bool entry::commit()
     }
 }
 
-bool entry::remove()
+bool Entry::remove()
 {
     if (exists()) {
         QString statement = "DELETE FROM " + position.first +
@@ -131,7 +131,7 @@ bool entry::remove()
     }
 }
 
-bool entry::exists()
+bool Entry::exists()
 {
     //Check database for row id
     QString statement = "SELECT COUNT(*) FROM " + position.first +
@@ -148,7 +148,7 @@ bool entry::exists()
     }
 }
 
-bool entry::insert()
+bool Entry::insert()
 {
     DEB("Inserting...");
     //check prerequisites
@@ -181,7 +181,7 @@ bool entry::insert()
     }
 }
 
-bool entry::update()
+bool Entry::update()
 {
     //create query
     QString statement = "UPDATE " + position.first + " SET ";
@@ -211,7 +211,7 @@ bool entry::update()
 }
 
 //Debug
-void entry::print()
+void Entry::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";
@@ -227,7 +227,7 @@ void entry::print()
     }
 }
 
-QString entry::debug()
+QString Entry::debug()
 {
     print();
     return QString();

+ 5 - 5
src/database/entry.h

@@ -22,16 +22,16 @@
 #include "src/database/db.h"
 #include "src/database/dbinfo.h"
 /*!
- * \brief The entry class is the base class for database entries.
+ * \brief The Entry class is the base class for database entries.
  * It can be seen as a row in a table within the database.
  *
  */
-class entry
+class Entry
 {
 public:
-    entry();
-    entry(QString table, int row);
-    entry(QString table, QMap<QString, QString> newData);
+    Entry();
+    Entry(QString table, int row);
+    Entry(QString table, QMap<QString, QString> newData);
 
 
 

+ 5 - 5
src/gui/dialogues/newpilot.cpp

@@ -21,7 +21,7 @@
 #define DEB(expr) \
     qDebug() << __PRETTY_FUNCTION__ << "\t" << expr
 
-NewPilot::NewPilot(db::editRole edRole, QWidget *parent) :
+NewPilot::NewPilot(Db::editRole edRole, QWidget *parent) :
     QDialog(parent),
     ui(new Ui::NewPilot)
 {
@@ -29,7 +29,7 @@ NewPilot::NewPilot(db::editRole edRole, QWidget *parent) :
     ui->setupUi(this);
 }
 
-NewPilot::NewPilot(pilot existingEntry, db::editRole edRole, QWidget *parent) :
+NewPilot::NewPilot(Pilot existingEntry, Db::editRole edRole, QWidget *parent) :
     QDialog(parent),
     ui(new Ui::NewPilot)
 {
@@ -91,13 +91,13 @@ void NewPilot::submitForm()
     DEB("Role: " << role);
     //create db object
     switch (role) {
-    case db::createNew: {
-        auto newEntry = pilot("pilots", newData);;
+    case Db::createNew: {
+        auto newEntry = Pilot("pilots", newData);;
         DEB("New Object: ");
         newEntry.commit();
         break;
     }
-    case db::editExisting:
+    case Db::editExisting:
         oldEntry.setData(newData);
         DEB("updated entry: " << oldEntry);
         oldEntry.commit();

+ 4 - 4
src/gui/dialogues/newpilot.h

@@ -31,8 +31,8 @@ class NewPilot : public QDialog
     Q_OBJECT
 
 public:
-    explicit NewPilot(db::editRole, QWidget *parent = nullptr);
-    explicit NewPilot(pilot, db::editRole, QWidget *parent = nullptr);
+    explicit NewPilot(Db::editRole, QWidget *parent = nullptr);
+    explicit NewPilot(Pilot, Db::editRole, QWidget *parent = nullptr);
     ~NewPilot();
 
 private slots:
@@ -41,9 +41,9 @@ private slots:
 private:
     Ui::NewPilot *ui;
 
-    db::editRole role;
+    Db::editRole role;
 
-    pilot oldEntry;
+    Pilot oldEntry;
 
     void formFiller();
 

+ 10 - 10
src/gui/dialogues/newtail.cpp

@@ -24,7 +24,7 @@
 
 
 //Dialog to be used to create a new tail
-NewTail::NewTail(QString newreg, db::editRole edRole, QWidget *parent) :
+NewTail::NewTail(QString newreg, Db::editRole edRole, QWidget *parent) :
     QDialog(parent),
     ui(new Ui::NewTail)
 {
@@ -39,7 +39,7 @@ NewTail::NewTail(QString newreg, db::editRole edRole, QWidget *parent) :
 }
 
 //Dialog to be used to edit an existing tail
-NewTail::NewTail(aircraft dbentry, db::editRole edRole, QWidget *parent) :
+NewTail::NewTail(Aircraft dbentry, Db::editRole edRole, QWidget *parent) :
     QDialog(parent),
     ui(new Ui::NewTail)
 {
@@ -62,7 +62,7 @@ NewTail::~NewTail()
  * information contained in an aircraft object.
  * \param db - entry retreived from database
  */
-void NewTail::formFiller(aircraft entry)
+void NewTail::formFiller(Aircraft entry)
 {
     DEB("Filling Form for a/c" << entry);
     //fill Line Edits
@@ -101,7 +101,7 @@ void NewTail::formFiller(aircraft entry)
 void NewTail::setupCompleter()
 {
     auto query = QLatin1String("SELECT make||' '||model||'-'||variant, aircraft_id FROM aircraft");
-    auto vector = db::customQuery(query, 2);
+    auto vector = Db::customQuery(query, 2);
     QMap<QString, int> map;
     for (int i = 0; i < vector.length() - 2 ; i += 2) {
         if (vector[i] != QLatin1String("")) {
@@ -109,7 +109,7 @@ void NewTail::setupCompleter()
         }
     }
     //creating QStringlist for QCompleter
-    auto cl = new completionList(completerTarget::aircraft);
+    auto cl = new CompletionList(CompleterTarget::aircraft);
 
     aircraftlist = cl->list;
     idMap = map;
@@ -162,7 +162,7 @@ bool NewTail::verify()
     }
 }
 
-void NewTail::submitForm(db::editRole edRole)
+void NewTail::submitForm(Db::editRole edRole)
 {
     DEB("Creating Database Object...");
     QMap<QString, QString> newData;
@@ -201,12 +201,12 @@ void NewTail::submitForm(db::editRole edRole)
     }
     //create db object
     switch (edRole) {
-    case db::createNew: {
-        auto newEntry = new aircraft("tails", newData);;
+    case Db::createNew: {
+        auto newEntry = new Aircraft("tails", newData);;
         newEntry->commit();
         break;
     }
-    case db::editExisting:
+    case Db::editExisting:
         oldEntry.setData(newData);
         oldEntry.commit();
         break;
@@ -222,7 +222,7 @@ void NewTail::on_searchLineEdit_textChanged(const QString &arg1)
 
         DEB("Template Selected. aircraft_id is: " << idMap.value(arg1));
         //call autofiller for dialog
-        formFiller(aircraft("aircraft", idMap.value(arg1)));
+        formFiller(Aircraft("aircraft", idMap.value(arg1)));
         ui->searchLineEdit->setStyleSheet("border: 1px solid green");
     } else {
         //for example, editing finished without selecting a result from Qcompleter

+ 6 - 6
src/gui/dialogues/newtail.h

@@ -43,9 +43,9 @@ public:
 
     //explicit NewTail(aircraft acft, QWidget *parent = nullptr);
     //to create new tail from scratch
-    explicit NewTail(QString reg, db::editRole edRole, QWidget *parent = nullptr);
+    explicit NewTail(QString reg, Db::editRole edRole, QWidget *parent = nullptr);
     //to edit existing tail
-    explicit NewTail(aircraft dbentry, db::editRole edRole, QWidget *parent = nullptr);
+    explicit NewTail(Aircraft dbentry, Db::editRole edRole, QWidget *parent = nullptr);
 
     ~NewTail();
 
@@ -68,17 +68,17 @@ private:
 
     Ui::NewTail *ui;
 
-    db::editRole role;
+    Db::editRole role;
 
-    aircraft oldEntry;
+    Aircraft oldEntry;
 
-    void submitForm(db::editRole edRole);
+    void submitForm(Db::editRole edRole);
 
     void setupCompleter();
 
     //void formFiller(aircraft);
 
-    void formFiller(aircraft);
+    void formFiller(Aircraft);
 
     bool verify();
 

+ 3 - 3
src/gui/widgets/aircraftwidget.cpp

@@ -82,7 +82,7 @@ void aircraftWidget::tableView_selectionChanged(const QItemSelection &index, con
     setSelectedAircraft(index.indexes()[0].data().toInt());
     DEB("Selected aircraft with ID#: " << selectedAircraft);
 
-    auto nt = new NewTail(aircraft("tails", selectedAircraft), db::editExisting, this);
+    auto nt = new NewTail(Aircraft("tails", selectedAircraft), Db::editExisting, this);
     //auto nt = new NewTail(db(db::tails,selectedAircraft),this);
 
     nt->setWindowFlag(Qt::Widget);
@@ -94,7 +94,7 @@ void aircraftWidget::on_deleteButton_clicked()
 {
     if (selectedAircraft > 0) {
 
-        auto ac = new aircraft("tails", selectedAircraft);
+        auto ac = new Aircraft("tails", selectedAircraft);
         ac->remove();
 
 
@@ -117,6 +117,6 @@ void aircraftWidget::on_deleteButton_clicked()
 
 void aircraftWidget::on_newButton_clicked()
 {
-    auto nt = new NewTail(QString(), db::createNew, this);
+    auto nt = new NewTail(QString(), Db::createNew, this);
     nt->show();
 }

+ 2 - 17
src/gui/widgets/homewidget.cpp

@@ -29,21 +29,6 @@ homeWidget::homeWidget(QWidget *parent) :
 {
     ui->setupUi(this);
     showTotals();
-    /*ui->totalTimeThisYearDisplay->setText(
-                calc::minutes_to_string(
-                stat::totalTime(stat::calendarYear)));
-    ui->totalTime365DaysDisplay->setText(
-                calc::minutes_to_string(
-                stat::totalTime(stat::rollingYear)));
-    QVector<QString> toldg = stat::currencyTakeOffLanding(90);
-    QString ToLdg;// = toldg[0] + " / " + toldg[1];
-    for(const auto& item : toldg)
-    {
-        ToLdg += item;
-        if(toldg.indexOf(item) != toldg.length()-1) {ToLdg += QLatin1String(" / ");}
-    }*/
-
-    //ui->ToLdgDisplay->setText(ToLdg);
 }
 
 homeWidget::~homeWidget()
@@ -53,8 +38,8 @@ homeWidget::~homeWidget()
 
 void homeWidget::on_pushButton_clicked()
 {
-    auto pl = new pilot("pilots", 498);
-    auto np = new NewPilot(*pl, db::editExisting, this);
+    auto pl = new Pilot("pilots", 498);
+    auto np = new NewPilot(*pl, Db::editExisting, this);
     np->show();
 }
 

+ 3 - 3
src/gui/widgets/logbookwidget.cpp

@@ -109,8 +109,8 @@ void logbookWidget::on_deleteFlightPushButton_clicked()
         QVector<QString> columns = {
             "doft", "dept", "dest"
         };
-        QVector<QString> details = db::multiSelect(columns, "flights", "id",
-                                                   QString::number(selectedFlight), db::exactMatch);
+        QVector<QString> details = Db::multiSelect(columns, "flights", "id",
+                                                   QString::number(selectedFlight), Db::exactMatch);
         QString detailsstring = "The following flight will be deleted:\n\n";
         for (const auto &item : details) {
             detailsstring.append(item);
@@ -123,7 +123,7 @@ void logbookWidget::on_deleteFlightPushButton_clicked()
                                       QMessageBox::Yes | QMessageBox::No);
         if (reply == QMessageBox::Yes) {
             DEB("Deleting flight with ID# " << selectedFlight);
-            auto en = new flight("flights", selectedFlight);
+            auto en = new Flight("flights", selectedFlight);
             en->remove();
 
             QSqlTableModel *ShowAllModel = new QSqlTableModel; //refresh view

+ 3 - 3
src/gui/widgets/pilotswidget.cpp

@@ -77,7 +77,7 @@ void pilotsWidget::tableView_selectionChanged(const QItemSelection &index, const
     setSelectedPilot(index.indexes()[0].data().toInt());
     DEB("Selected Pilot with ID#: " << selectedPilot);
 
-    auto np = new NewPilot(pilot("pilots", selectedPilot), db::editExisting, this);
+    auto np = new NewPilot(Pilot("pilots", selectedPilot), Db::editExisting, this);
 
     np->setWindowFlag(Qt::Widget);
     ui->stackedWidget->addWidget(np);
@@ -91,7 +91,7 @@ void pilotsWidget::setSelectedPilot(const qint32 &value)
 
 void pilotsWidget::on_newButton_clicked()
 {
-    auto np = new NewPilot(db::createNew, this);
+    auto np = new NewPilot(Db::createNew, this);
     np->show();
 }
 
@@ -99,7 +99,7 @@ void pilotsWidget::on_deletePushButton_clicked()
 {
     if (selectedPilot > 0) {
 
-        auto pil = new pilot("pilots", selectedPilot);
+        auto pil = new Pilot("pilots", selectedPilot);
         pil->remove();
 
 

+ 1 - 1
src/gui/widgets/settingswidget.cpp

@@ -106,7 +106,7 @@ void settingsWidget::themeGroup_toggled(int id)
 void settingsWidget::on_aboutPushButton_clicked()
 {
     auto mb = new QMessageBox(this);
-    QString SQLITE_VERSION = dbInfo().version;
+    QString SQLITE_VERSION = DbInfo().version;
     QString text = QMessageBox::tr(
 
                        "<h3><center>About openPilotLog</center></h3>"

+ 1 - 1
src/gui/widgets/totalswidget.cpp

@@ -9,7 +9,7 @@ totalsWidget::totalsWidget(QWidget *parent) :
     ui(new Ui::totalsWidget)
 {
     ui->setupUi(this);
-    auto data = stat::totals();
+    auto data = Stat::totals();
     DEB("Filling Totals Line Edits...");
     for (const auto &field : data) {
         auto line_edit = parent->findChild<QLineEdit *>(field.first + "LineEdit");