浏览代码

code formatting

fiffty-50 4 年之前
父节点
当前提交
b3748290db

+ 3 - 4
main.cpp

@@ -28,10 +28,10 @@ int main(int argc, char *argv[])
     QCoreApplication::setApplicationName("openPilotLog");
     QCoreApplication::setApplicationName("openPilotLog");
 
 
 
 
-    if(!QDir("data").exists()){
+    if (!QDir("data").exists()) {
         QDir().mkdir("data");
         QDir().mkdir("data");
     }
     }
-    QSettings::setPath(QSettings::IniFormat,QSettings::UserScope,"data");
+    QSettings::setPath(QSettings::IniFormat, QSettings::UserScope, "data");
     QSettings::setDefaultFormat(QSettings::IniFormat);
     QSettings::setDefaultFormat(QSettings::IniFormat);
     QSettings settings;
     QSettings settings;
 
 
@@ -42,8 +42,7 @@ int main(int argc, char *argv[])
     QDir::setCurrent("/themes");
     QDir::setCurrent("/themes");
 
 
     switch (selectedtheme) {
     switch (selectedtheme) {
-    case 1:
-    {
+    case 1: {
         qDebug() << "main :: Loading light theme";
         qDebug() << "main :: Loading light theme";
         QFile file(":light.qss");
         QFile file(":light.qss");
         file.open(QFile::ReadOnly | QFile::Text);
         file.open(QFile::ReadOnly | QFile::Text);

+ 19 - 18
mainwindow.cpp

@@ -27,9 +27,9 @@ MainWindow::MainWindow(QWidget *parent)
 
 
     // Set up Toolbar
     // Set up Toolbar
     ui->toolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
     ui->toolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
-    ui->toolBar->setIconSize(QSize(64,64));
-    auto buttons = ui->toolBar->findChildren<QWidget*>();
-    for (const auto& button : buttons) {
+    ui->toolBar->setIconSize(QSize(64, 64));
+    auto buttons = ui->toolBar->findChildren<QWidget *>();
+    for (const auto &button : buttons) {
         button->setMinimumWidth(128);
         button->setMinimumWidth(128);
     }
     }
 
 
@@ -47,13 +47,13 @@ MainWindow::MainWindow(QWidget *parent)
     auto *spacer = new QWidget();
     auto *spacer = new QWidget();
     spacer->setMinimumWidth(10);
     spacer->setMinimumWidth(10);
     spacer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
     spacer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
-    ui->toolBar->insertWidget(ui->actionNewFlight,spacer);
+    ui->toolBar->insertWidget(ui->actionNewFlight, spacer);
 
 
 
 
     // create and show homeWidget
     // create and show homeWidget
     auto hw = new homeWidget(this);
     auto hw = new homeWidget(this);
     ui->stackedWidget->addWidget(hw);
     ui->stackedWidget->addWidget(hw);
-    ui->stackedWidget->setCurrentWidget(hw);  
+    ui->stackedWidget->setCurrentWidget(hw);
 
 
 }
 }
 
 
@@ -102,17 +102,18 @@ void MainWindow::on_actionSettings_triggered()
 }
 }
 
 
 void MainWindow::on_actionNewFlight_triggered()
 void MainWindow::on_actionNewFlight_triggered()
-{/*
-    QVector<QStringList> lineEdit_completionLists = {
-        QStringList(),//empty dummy list for TimeLineEdits
-        dbAirport::retreiveIataIcaoList(),
-        dbAircraft::retreiveRegistrationList(),
-        dbPilots::retreivePilotList()
-    };
-
-    NewFlight nf(this, lineEdit_completionLists);
-    nf.exec();
-    */
+{
+    /*
+       QVector<QStringList> lineEdit_completionLists = {
+           QStringList(),//empty dummy list for TimeLineEdits
+           dbAirport::retreiveIataIcaoList(),
+           dbAircraft::retreiveRegistrationList(),
+           dbPilots::retreivePilotList()
+       };
+
+       NewFlight nf(this, lineEdit_completionLists);
+       nf.exec();
+       */
 }
 }
 
 
 void MainWindow::on_actionAircraft_triggered()
 void MainWindow::on_actionAircraft_triggered()
@@ -124,7 +125,7 @@ void MainWindow::on_actionAircraft_triggered()
 
 
 void MainWindow::on_actionNewAircraft_triggered()
 void MainWindow::on_actionNewAircraft_triggered()
 {
 {
-    auto nt = new NewTail(QString(), db::createNew,this);
+    auto nt = new NewTail(QString(), db::createNew, this);
     nt->show();
     nt->show();
 }
 }
 
 
@@ -137,6 +138,6 @@ void MainWindow::on_actionPilots_triggered()
 
 
 void MainWindow::on_actionNewPilot_triggered()
 void MainWindow::on_actionNewPilot_triggered()
 {
 {
-    auto np = new NewPilot(db::createNew,this);
+    auto np = new NewPilot(db::createNew, this);
     np->show();
     np->show();
 }
 }

+ 3 - 1
mainwindow.h

@@ -36,7 +36,9 @@
 #include "src/gui/dialogues/newpilot.h"
 #include "src/gui/dialogues/newpilot.h"
 
 
 QT_BEGIN_NAMESPACE
 QT_BEGIN_NAMESPACE
-namespace Ui { class MainWindow; }
+namespace Ui {
+class MainWindow;
+}
 QT_END_NAMESPACE
 QT_END_NAMESPACE
 
 
 class MainWindow : public QMainWindow
 class MainWindow : public QMainWindow

+ 1 - 1
openPilotLog.pro.user

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE QtCreatorProject>
 <!DOCTYPE QtCreatorProject>
-<!-- Written by QtCreator 4.11.0, 2020-11-02T20:58:32. -->
+<!-- Written by QtCreator 4.11.0, 2020-11-06T11:26:14. -->
 <qtcreator>
 <qtcreator>
  <data>
  <data>
   <variable>EnvironmentId</variable>
   <variable>EnvironmentId</variable>

+ 1 - 1
src/classes/aircraft.h

@@ -26,7 +26,7 @@
  */
  */
 class aircraft : public entry
 class aircraft : public entry
 {
 {
-using entry::entry;
+    using entry::entry;
 };
 };
 
 
 #endif // AIRCRAFT_H
 #endif // AIRCRAFT_H

+ 91 - 86
src/classes/calc.cpp

@@ -25,17 +25,15 @@
  */
  */
 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
+    if (tonb > tofb) { // landing same day
+        QTime blocktimeout(0, 0); // initialise return value at midnight
         int blockseconds = tofb.secsTo(tonb); // returns seconds between 2 time objects
         int blockseconds = tofb.secsTo(tonb); // returns seconds between 2 time objects
         blocktimeout = blocktimeout.addSecs(blockseconds);
         blocktimeout = blocktimeout.addSecs(blockseconds);
         return blocktimeout;
         return blocktimeout;
 
 
-    } else // landing next day
-    {
-        QTime midnight(0,0);
-        QTime blocktimeout(0,0); // initialise return value at midnight
+    } else { // landing next day
+        QTime midnight(0, 0);
+        QTime blocktimeout(0, 0); // initialise return value at midnight
         int blockseconds = tofb.secsTo(midnight); // returns seconds passed until midnight
         int blockseconds = tofb.secsTo(midnight); // returns seconds passed until midnight
         blocktimeout = blocktimeout.addSecs(blockseconds);
         blocktimeout = blocktimeout.addSecs(blockseconds);
         blockseconds = midnight.secsTo(tonb); // returns seconds passed after midnight
         blockseconds = midnight.secsTo(tonb); // returns seconds passed after midnight
@@ -53,10 +51,14 @@ QTime calc::blocktime(QTime tofb, QTime tonb)
 QString calc::minutes_to_string(QString blockminutes)
 QString calc::minutes_to_string(QString blockminutes)
 {
 {
     int minutes = blockminutes.toInt();
     int minutes = blockminutes.toInt();
-    QString hour = QString::number(minutes/60);
-    if (hour.size() < 2) {hour.prepend("0");}
+    QString hour = QString::number(minutes / 60);
+    if (hour.size() < 2) {
+        hour.prepend("0");
+    }
     QString minute = QString::number(minutes % 60);
     QString minute = QString::number(minutes % 60);
-    if (minute.size() < 2) {minute.prepend("0");}
+    if (minute.size() < 2) {
+        minute.prepend("0");
+    }
     QString blocktime = hour + ":" + minute;
     QString blocktime = hour + ":" + minute;
     return blocktime;
     return blocktime;
 };
 };
@@ -165,8 +167,8 @@ double calc::greatCircleDistance(double lat1, double lon1, double lat2, double l
     double deltalat = lat2 - lat1;
     double deltalat = lat2 - lat1;
 
 
     double result = pow(sin(deltalat / 2), 2) +
     double result = pow(sin(deltalat / 2), 2) +
-            cos(lat1) * cos(lat2) * pow(sin(deltalon / 2), 2);
-    result = 2 * asin(sqrt(result));  
+                    cos(lat1) * cos(lat2) * pow(sin(deltalon / 2), 2);
+    result = 2 * asin(sqrt(result));
     return result;
     return result;
 }
 }
 
 
@@ -186,12 +188,13 @@ double calc::greatCircleDistanceBetweenAirports(QString dept, QString dest)
     }*/
     }*/
 
 
     QVector<QString> columns = {"lat", "long"};
     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()
-       )
-    {
+    if (deptCoordinates.isEmpty() || destCoordinates.isEmpty()
+       ) {
         qDebug() << "greatCircleDistance - invalid input. aborting.";
         qDebug() << "greatCircleDistance - invalid input. aborting.";
         return 0;
         return 0;
     }
     }
@@ -206,7 +209,7 @@ double calc::greatCircleDistanceBetweenAirports(QString dept, QString dest)
     double deltalat = lat2 - lat1;
     double deltalat = lat2 - lat1;
 
 
     double result = pow(sin(deltalat / 2), 2) +
     double result = pow(sin(deltalat / 2), 2) +
-            cos(lat1) * cos(lat2) * pow(sin(deltalon / 2), 2);
+                    cos(lat1) * cos(lat2) * pow(sin(deltalon / 2), 2);
     result = 2 * asin(sqrt(result));
     result = 2 * asin(sqrt(result));
     return radToNauticalMiles(result);
     return radToNauticalMiles(result);
 }
 }
@@ -221,7 +224,8 @@ double calc::greatCircleDistanceBetweenAirports(QString dept, QString dest)
  * \param tblk Total Blocktime in minutes
  * \param tblk Total Blocktime in minutes
  * \return coordinates {lat,lon} along the Great Circle Track
  * \return coordinates {lat,lon} along the Great Circle Track
  */
  */
-QVector<QVector<double>> calc::intermediatePointsOnGreatCircle(double lat1, double lon1, double lat2, double lon2, int tblk)
+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
     // Converting Latitude and Longitude to Radians
@@ -233,18 +237,18 @@ QVector<QVector<double>> calc::intermediatePointsOnGreatCircle(double lat1, doub
     //loop for creating one minute steps along the Great Circle
     //loop for creating one minute steps along the Great Circle
     // 0 is departure point, 1 is end point
     // 0 is departure point, 1 is end point
     QVector<QVector<double>> coordinates;
     QVector<QVector<double>> coordinates;
-    double fraction = 1.0/tblk;
-    for(int i = 0; i <= tblk; i++) {
+    double fraction = 1.0 / tblk;
+    for (int i = 0; i <= tblk; i++) {
         // Calculating intermediate point for fraction of distance
         // Calculating intermediate point for fraction of distance
-        double A=sin((1-fraction * i) * d)/sin(d);
-        double B=sin(fraction * i * d)/sin(d);
-        double x = A*cos(lat1) * cos(lon1) + B * cos(lat2) * cos(lon2);
-        double y = A*cos(lat1) * sin(lon1) + B * cos(lat2) * sin(lon2);
-        double z = A*sin(lat1) + B * sin(lat2);
+        double A = sin((1 - fraction * i) * d) / sin(d);
+        double B = sin(fraction * i * d) / sin(d);
+        double x = A * cos(lat1) * cos(lon1) + B * cos(lat2) * cos(lon2);
+        double y = A * cos(lat1) * sin(lon1) + B * cos(lat2) * sin(lon2);
+        double z = A * sin(lat1) + B * sin(lat2);
         double lat = atan2(z, sqrt( pow(x, 2) + pow(y, 2) ));
         double lat = atan2(z, sqrt( pow(x, 2) + pow(y, 2) ));
         double lon = atan2(y, x);
         double lon = atan2(y, x);
 
 
-        QVector<double> coordinate = {lat,lon};
+        QVector<double> coordinate = {lat, lon};
         coordinates.append(coordinate);
         coordinates.append(coordinate);
     }
     }
     return coordinates;
     return coordinates;
@@ -268,55 +272,60 @@ QVector<QVector<double>> calc::intermediatePointsOnGreatCircle(double lat1, doub
  */
  */
 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.
+    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;
+    double d = utc_time_point.date().toJulianDay() - 2451544 + utc_time_point.time().hour() / 24.0 +
+               utc_time_point.time().minute() / 1440.0;
 
 
     // Orbital Elements (in degress)
     // Orbital Elements (in degress)
     double w = 282.9404 + 4.70935e-5 * d; // (longitude of perihelion)
     double w = 282.9404 + 4.70935e-5 * d; // (longitude of perihelion)
     double e = 0.016709 - 1.151e-9 * d; // (eccentricity)
     double e = 0.016709 - 1.151e-9 * d; // (eccentricity)
-    double M = fmod(356.0470 + 0.9856002585 * d, 360.0); // (mean anomaly, needs to be between 0 and 360 degrees)
-    double oblecl = 23.4393 - 3.563e-7*d; // (Sun's obliquity of the ecliptic)
+    double M = fmod(356.0470 + 0.9856002585 * d,
+                    360.0); // (mean anomaly, needs to be between 0 and 360 degrees)
+    double oblecl = 23.4393 - 3.563e-7 * d; // (Sun's obliquity of the ecliptic)
     double L = w + M; // (Sun's mean longitude)
     double L = w + M; // (Sun's mean longitude)
     // auxiliary angle
     // auxiliary angle
-    double  E = M + (180 / M_PI)*e*sin(M*(M_PI / 180))*(1 + e*cos(M*(M_PI / 180)));
+    double  E = M + (180 / M_PI) * e * sin(M * (M_PI / 180)) * (1 + e * cos(M * (M_PI / 180)));
     // The Sun's rectangular coordinates in the plane of the ecliptic
     // The Sun's rectangular coordinates in the plane of the ecliptic
-    double x = cos(E*(M_PI / 180)) - e;
-    double y = sin(E*(M_PI / 180))*sqrt(1 - pow(e, 2));
+    double x = cos(E * (M_PI / 180)) - e;
+    double y = sin(E * (M_PI / 180)) * sqrt(1 - pow(e, 2));
     // find the distance and true anomaly
     // find the distance and true anomaly
-    double r = sqrt(pow(x,2) + pow(y,2));
-    double v = atan2(y, x)*(180 / M_PI);
+    double r = sqrt(pow(x, 2) + pow(y, 2));
+    double v = atan2(y, x) * (180 / M_PI);
     // find the longitude of the sun
     // find the longitude of the sun
     double solarlongitude = v + w;
     double solarlongitude = v + w;
     // compute the ecliptic rectangular coordinates
     // compute the ecliptic rectangular coordinates
-    double xeclip = r*cos(solarlongitude*(M_PI / 180));
-    double yeclip = r*sin(solarlongitude*(M_PI / 180));
+    double xeclip = r * cos(solarlongitude * (M_PI / 180));
+    double yeclip = r * sin(solarlongitude * (M_PI / 180));
     double zeclip = 0.0;
     double zeclip = 0.0;
     //rotate these coordinates to equitorial rectangular coordinates
     //rotate these coordinates to equitorial rectangular coordinates
     double xequat = xeclip;
     double xequat = xeclip;
-    double yequat = yeclip*cos(oblecl*(M_PI / 180)) + zeclip * sin(oblecl*(M_PI / 180));
-    double zequat = yeclip*sin(23.4406*(M_PI / 180)) + zeclip * cos(oblecl*(M_PI / 180));
+    double yequat = yeclip * cos(oblecl * (M_PI / 180)) + zeclip * sin(oblecl * (M_PI / 180));
+    double zequat = yeclip * sin(23.4406 * (M_PI / 180)) + zeclip * cos(oblecl * (M_PI / 180));
     // convert equatorial rectangular coordinates to RA and Decl:
     // convert equatorial rectangular coordinates to RA and Decl:
-    r = sqrt(pow(xequat, 2) + pow(yequat, 2) + pow(zequat, 2)) - (Alt / 149598000); //roll up the altitude correction
-    double RA = atan2(yequat, xequat)*(180 / M_PI);
-    double delta = asin(zequat / r)*(180 / M_PI);
+    r = sqrt(pow(xequat, 2) + pow(yequat, 2) + pow(zequat,
+                                                   2)) - (Alt / 149598000); //roll up the altitude correction
+    double RA = atan2(yequat, xequat) * (180 / M_PI);
+    double delta = asin(zequat / r) * (180 / M_PI);
 
 
     // GET UTH time
     // GET UTH time
-    double UTH = utc_time_point.time().hour() + utc_time_point.time().minute()/60.0 + utc_time_point.time().second()/3600.0;
+    double UTH = utc_time_point.time().hour() + utc_time_point.time().minute() / 60.0 +
+                 utc_time_point.time().second() / 3600.0;
     // Calculate local siderial time
     // Calculate local siderial time
     double GMST0 = fmod(L + 180, 360.0) / 15;
     double GMST0 = fmod(L + 180, 360.0) / 15;
     double SIDTIME = GMST0 + UTH + lon / 15;
     double SIDTIME = GMST0 + UTH + lon / 15;
     // Replace RA with hour angle HA
     // Replace RA with hour angle HA
-    double HA = (SIDTIME*15 - RA);
+    double HA = (SIDTIME * 15 - RA);
     // convert to rectangular coordinate system
     // convert to rectangular coordinate system
-    x = cos(HA*(M_PI / 180))*cos(delta*(M_PI / 180));
-    y = sin(HA*(M_PI / 180))*cos(delta*(M_PI / 180));
-    double z = sin(delta*(M_PI / 180));
+    x = cos(HA * (M_PI / 180)) * cos(delta * (M_PI / 180));
+    y = sin(HA * (M_PI / 180)) * cos(delta * (M_PI / 180));
+    double z = sin(delta * (M_PI / 180));
     // rotate this along an axis going east - west.
     // rotate this along an axis going east - west.
-    double zhor = x*sin((90 - lat)*(M_PI / 180)) + z*cos((90 - lat)*(M_PI / 180));
+    double zhor = x * sin((90 - lat) * (M_PI / 180)) + z * cos((90 - lat) * (M_PI / 180));
 
 
     // Find the Elevation
     // Find the Elevation
-    double elevation = asin(zhor)*(180 / M_PI);
+    double elevation = asin(zhor) * (180 / M_PI);
     return elevation;
     return elevation;
 }
 }
 
 
@@ -331,12 +340,13 @@ double calc::solarElevation(QDateTime utc_time_point, double lat, double lon)
 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> 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()
-       )
-    {
+    if (deptCoordinates.isEmpty() || destCoordinates.isEmpty()
+       ) {
         qDebug() << "calc::calculateNightTime - invalid input. aborting.";
         qDebug() << "calc::calculateNightTime - invalid input. aborting.";
         return 0;
         return 0;
     }
     }
@@ -351,11 +361,13 @@ int calc::calculateNightTime(QString dept, QString dest, QDateTime departureTime
     qDebug() << "calc::calculateNightTime destLat = " << destLat;
     qDebug() << "calc::calculateNightTime destLat = " << destLat;
     qDebug() << "calc::calculateNightTime destLon = " << destLon;
     qDebug() << "calc::calculateNightTime destLon = " << destLon;
 
 
-    QVector<QVector<double>> route = intermediatePointsOnGreatCircle(deptLat, deptLon, destLat, destLon, tblk);
+    QVector<QVector<double>> route = intermediatePointsOnGreatCircle(deptLat, deptLon, destLat, destLon,
+                                                                     tblk);
 
 
     int nightTime = 0;
     int nightTime = 0;
-    for(int i = 0; i < tblk ; i++) {
-        if(solarElevation(departureTime.addSecs(60*i),radToDeg(route[i][0]),radToDeg(route[i][1])) < -0.6) {
+    for (int i = 0; i < tblk ; i++) {
+        if (solarElevation(departureTime.addSecs(60 * i), radToDeg(route[i][0]),
+                           radToDeg(route[i][1])) < -0.6) {
             nightTime ++;
             nightTime ++;
         }
         }
     }
     }
@@ -376,34 +388,27 @@ QString calc::formatTimeInput(QString userinput)
     QTime temptime; //empty time object is invalid by default
     QTime temptime; //empty time object is invalid by default
 
 
     bool containsSeperator = userinput.contains(":");
     bool containsSeperator = userinput.contains(":");
-        if(userinput.length() == 4 && !containsSeperator)
-        {
-            temptime = QTime::fromString(userinput,"hhmm");
-        }else if(userinput.length() == 3 && !containsSeperator)
-        {
-            if(userinput.toInt() < 240) //Qtime is invalid if time is between 000 and 240 for this case
-            {
-                QString tempstring = userinput.prepend("0");
-                temptime = QTime::fromString(tempstring,"hhmm");
-            }else
-            {
-                temptime = QTime::fromString(userinput,"Hmm");
-            }
-        }else if(userinput.length() == 4 && containsSeperator)
-        {
-            temptime = QTime::fromString(userinput,"h:mm");
-        }else if(userinput.length() == 5 && containsSeperator)
-        {
-            temptime = QTime::fromString(userinput,"hh:mm");
+    if (userinput.length() == 4 && !containsSeperator) {
+        temptime = QTime::fromString(userinput, "hhmm");
+    } else if (userinput.length() == 3 && !containsSeperator) {
+        if (userinput.toInt() < 240) { //Qtime is invalid if time is between 000 and 240 for this case
+            QString tempstring = userinput.prepend("0");
+            temptime = QTime::fromString(tempstring, "hhmm");
+        } else {
+            temptime = QTime::fromString(userinput, "Hmm");
         }
         }
+    } else if (userinput.length() == 4 && containsSeperator) {
+        temptime = QTime::fromString(userinput, "h:mm");
+    } else if (userinput.length() == 5 && containsSeperator) {
+        temptime = QTime::fromString(userinput, "hh:mm");
+    }
 
 
-        output = temptime.toString("hh:mm");
-        if(output.isEmpty())
-        {
-            /*QMessageBox timeformat(this);
-            timeformat.setText("Please enter a valid time. Any of these formats is valid:\n845 0845 8:45 08:45");
-            timeformat.exec();*/
-            qDebug() << "Time input is invalid.";
-        }
-        return output;
+    output = temptime.toString("hh:mm");
+    if (output.isEmpty()) {
+        /*QMessageBox timeformat(this);
+        timeformat.setText("Please enter a valid time. Any of these formats is valid:\n845 0845 8:45 08:45");
+        timeformat.exec();*/
+        qDebug() << "Time input is invalid.";
+    }
+    return output;
 }
 }

+ 2 - 2
src/classes/completionlist.cpp

@@ -36,7 +36,7 @@ completionList::completionList(completerTarget::targets type)
     switch (type) {
     switch (type) {
     case completerTarget::pilots:
     case completerTarget::pilots:
         query.append("SELECT piclastname||', '||picfirstname FROM pilots");
         query.append("SELECT piclastname||', '||picfirstname FROM pilots");
-        result = db::customQuery(query,1);
+        result = db::customQuery(query, 1);
         break;
         break;
     case completerTarget::airports:
     case completerTarget::airports:
         columns.append("icao");
         columns.append("icao");
@@ -49,7 +49,7 @@ completionList::completionList(completerTarget::targets type)
         break;
         break;
     case completerTarget::aircraft:
     case completerTarget::aircraft:
         query.append("SELECT make||' '||model||'-'||variant FROM aircraft");
         query.append("SELECT make||' '||model||'-'||variant FROM aircraft");
-        result = db::customQuery(query,1);
+        result = db::customQuery(query, 1);
         break;
         break;
     }
     }
 
 

+ 31 - 29
src/classes/stat.cpp

@@ -35,7 +35,7 @@ QString stat::totalTime(yearType yt)
         query = "SELECT SUM(tblk) FROM flights";
         query = "SELECT SUM(tblk) FROM flights";
         break;
         break;
     case stat::calendarYear:
     case stat::calendarYear:
-        start.setDate(QDate::currentDate().year(),1,1);
+        start.setDate(QDate::currentDate().year(), 1, 1);
         startdate = start.toString(Qt::ISODate);
         startdate = start.toString(Qt::ISODate);
         startdate.append(QLatin1Char('\''));
         startdate.append(QLatin1Char('\''));
         startdate.prepend(QLatin1Char('\''));
         startdate.prepend(QLatin1Char('\''));
@@ -47,13 +47,14 @@ QString stat::totalTime(yearType yt)
         startdate.append(QLatin1Char('\''));
         startdate.append(QLatin1Char('\''));
         startdate.prepend(QLatin1Char('\''));
         startdate.prepend(QLatin1Char('\''));
         query = "SELECT SUM(tblk) FROM flights WHERE doft >= " + startdate;
         query = "SELECT SUM(tblk) FROM flights WHERE doft >= " + startdate;
-        break;}
+        break;
+    }
 
 
     QVector<QString> result = db::customQuery(query, 1);
     QVector<QString> result = db::customQuery(query, 1);
 
 
-    if(!result.isEmpty()){
+    if (!result.isEmpty()) {
         return result[0];
         return result[0];
-    }else{
+    } else {
         return QString();
         return QString();
     }
     }
 }
 }
@@ -78,9 +79,9 @@ QVector<QString> stat::currencyTakeOffLanding(int days)
                     "WHERE doft >= " + startdate;
                     "WHERE doft >= " + startdate;
     QVector<QString> result = db::customQuery(query, 2);
     QVector<QString> result = db::customQuery(query, 2);
 
 
-    if(!result.isEmpty()){
+    if (!result.isEmpty()) {
         return result;
         return result;
-    }else{
+    } else {
         return QVector<QString>();
         return QVector<QString>();
     }
     }
 
 
@@ -89,35 +90,36 @@ QVector<QString> stat::currencyTakeOffLanding(int days)
 QVector<QPair<QString, QString>> stat::totals()
 QVector<QPair<QString, QString>> stat::totals()
 {
 {
     QString statement = "SELECT"
     QString statement = "SELECT"
-            " printf(SUM(tblk)/60)||':'||printf('%02d',SUM(tblk)%60),"
-            " printf(SUM(tSPSE)/60)||':'||printf('%02d',SUM(tSPSE)%60),"
-            " printf(SUM(tSPME)/60)||':'||printf('%02d',SUM(tSPME)%60),"
-            " printf(SUM(tNIGHT)/60)||':'||printf('%02d',SUM(tNIGHT)%60),"
-            " printf(SUM(tIFR)/60)||':'||printf('%02d',SUM(tIFR)%60),"
-            " printf(SUM(tPIC)/60)||':'||printf('%02d',SUM(tPIC)%60),"
-            " printf(SUM(tPICUS)/60)||':'||printf('%02d',SUM(tPICUS)%60),"
-            " printf(SUM(tSIC)/60)||':'||printf('%02d',SUM(tSIC)%60),"
-            " printf(SUM(tDual)/60)||':'||printf('%02d',SUM(tDual)%60),"
-            " printf(SUM(tFI)/60)||':'||printf('%02d',SUM(tFI)%60),"
-            " printf(SUM(tSIM)/60)||':'||printf('%02d',SUM(tSIM)%60),"
-            " printf(SUM(tMP)/60)||':'||printf('%02d',SUM(tMP)%60),"
-            " SUM(toDay) AS 'TO Day', SUM(toNight),"
-            " SUM(ldgDay) AS 'LDG Day', SUM(ldgNight)"
-            " FROM flights";
-    QVector<QString> columns = {"total","spse","spme" , "night", "ifr",
-                                "pic" , "picus", "sic", "dual", "fi", "sim","multipilot",
-                                "today", "tonight", "ldgday", "ldgnight"};
+                        " printf(SUM(tblk)/60)||':'||printf('%02d',SUM(tblk)%60),"
+                        " printf(SUM(tSPSE)/60)||':'||printf('%02d',SUM(tSPSE)%60),"
+                        " printf(SUM(tSPME)/60)||':'||printf('%02d',SUM(tSPME)%60),"
+                        " printf(SUM(tNIGHT)/60)||':'||printf('%02d',SUM(tNIGHT)%60),"
+                        " printf(SUM(tIFR)/60)||':'||printf('%02d',SUM(tIFR)%60),"
+                        " printf(SUM(tPIC)/60)||':'||printf('%02d',SUM(tPIC)%60),"
+                        " printf(SUM(tPICUS)/60)||':'||printf('%02d',SUM(tPICUS)%60),"
+                        " printf(SUM(tSIC)/60)||':'||printf('%02d',SUM(tSIC)%60),"
+                        " printf(SUM(tDual)/60)||':'||printf('%02d',SUM(tDual)%60),"
+                        " printf(SUM(tFI)/60)||':'||printf('%02d',SUM(tFI)%60),"
+                        " printf(SUM(tSIM)/60)||':'||printf('%02d',SUM(tSIM)%60),"
+                        " printf(SUM(tMP)/60)||':'||printf('%02d',SUM(tMP)%60),"
+                        " SUM(toDay) AS 'TO Day', SUM(toNight),"
+                        " SUM(ldgDay) AS 'LDG Day', SUM(ldgNight)"
+                        " FROM flights";
+    QVector<QString> columns = {"total", "spse", "spme", "night", "ifr",
+                                "pic", "picus", "sic", "dual", "fi", "sim", "multipilot",
+                                "today", "tonight", "ldgday", "ldgnight"
+                               };
     QSqlQuery q(statement);
     QSqlQuery q(statement);
     QVector<QPair<QString, QString>> output;
     QVector<QPair<QString, QString>> output;
     QString value;
     QString value;
     q.next();
     q.next();
-    for(const auto& column : columns){
+    for (const auto &column : columns) {
         value = q.value(columns.indexOf(column)).toString();
         value = q.value(columns.indexOf(column)).toString();
-        if(!value.isEmpty()){
+        if (!value.isEmpty()) {
             output << QPair{column, value};
             output << QPair{column, value};
-        }else{
-            output << QPair{column,QString("00:00")};
+        } else {
+            output << QPair{column, QString("00:00")};
         }
         }
     }
     }
-return output;
+    return output;
 }
 }

+ 1 - 1
src/classes/strictregularexpressionvalidator.cpp

@@ -20,7 +20,7 @@
 QValidator::State StrictRegularExpressionValidator::validate(QString &txt, int &pos) const
 QValidator::State StrictRegularExpressionValidator::validate(QString &txt, int &pos) const
 {
 {
     auto validation = QRegularExpressionValidator::validate(txt, pos);
     auto validation = QRegularExpressionValidator::validate(txt, pos);
-    if(validation == QValidator::Intermediate) {
+    if (validation == QValidator::Intermediate) {
         return QValidator::Invalid;
         return QValidator::Invalid;
     }
     }
     return validation;
     return validation;

+ 3 - 2
src/classes/strictregularexpressionvalidator.h

@@ -24,9 +24,10 @@
 /*!
 /*!
  * \brief The StrictRegularExpressionValidator class only returns Invalid or Acceptable
  * \brief The StrictRegularExpressionValidator class only returns Invalid or Acceptable
  */
  */
-class StrictRegularExpressionValidator : public QRegularExpressionValidator {
+class StrictRegularExpressionValidator : public QRegularExpressionValidator
+{
 public:
 public:
-    QValidator::State validate(QString& txt, int& pos) const;
+    QValidator::State validate(QString &txt, int &pos) const;
 };
 };
 
 
 #endif // STRICTREGULAREXPRESSIONVALIDATOR_H
 #endif // STRICTREGULAREXPRESSIONVALIDATOR_H

+ 35 - 40
src/database/db.cpp

@@ -26,19 +26,19 @@ void db::connect()
 {
 {
     const QString driver("QSQLITE");
     const QString driver("QSQLITE");
 
 
-    if(QSqlDatabase::isDriverAvailable(driver)){
+    if (QSqlDatabase::isDriverAvailable(driver)) {
 
 
         QDir directory("data");
         QDir directory("data");
         QString databaseLocation = directory.filePath("logbook.db");
         QString databaseLocation = directory.filePath("logbook.db");
         QSqlDatabase db = QSqlDatabase::addDatabase(driver);
         QSqlDatabase db = QSqlDatabase::addDatabase(driver);
         db.setDatabaseName(databaseLocation);
         db.setDatabaseName(databaseLocation);
 
 
-        if(!db.open()){
+        if (!db.open()) {
             DEB("DatabaseConnect - ERROR: " << db.lastError().text());
             DEB("DatabaseConnect - ERROR: " << db.lastError().text());
-        }else{
+        } else {
             DEB("Database connection established.");
             DEB("Database connection established.");
         }
         }
-    }else{
+    } else {
         DEB("DatabaseConnect - ERROR: no driver " << driver << " available");
         DEB("DatabaseConnect - ERROR: no driver " << driver << " available");
     }
     }
 }
 }
@@ -49,7 +49,8 @@ void db::connect()
  * \param value - The value to be checked
  * \param value - The value to be checked
  * \return
  * \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;
     bool output = false;
     QString statement = "SELECT " + column + " FROM " + table + " WHERE " + checkColumn;
     QString statement = "SELECT " + column + " FROM " + table + " WHERE " + checkColumn;
@@ -70,21 +71,21 @@ bool db::exists(QString column, QString table, QString checkColumn, QString valu
     QSqlQuery q(statement);
     QSqlQuery q(statement);
     q.exec();
     q.exec();
 
 
-    if(!q.first()){
+    if (!q.first()) {
         DEB("No result found. Check Query and Error.");
         DEB("No result found. Check Query and Error.");
         DEB("Error: " << q.lastError().text());
         DEB("Error: " << q.lastError().text());
-    }else{
+    } else {
         DEB("Success. Found a result.");
         DEB("Success. Found a result.");
         output = true;
         output = true;
-        if(q.next()){
+        if (q.next()) {
             DEB("More than one result in Database for your query");
             DEB("More than one result in Database for your query");
         }
         }
     }
     }
 // Debug:
 // Debug:
     q.first();
     q.first();
     q.previous();
     q.previous();
-    while(q.next()){
-            DEB("Query result: " << q.value(0).toString());
+    while (q.next()) {
+        DEB("Query result: " << q.value(0).toString());
     }
     }
 // end of Debug
 // end of Debug
     return output;
     return output;
@@ -98,7 +99,8 @@ bool db::exists(QString column, QString table, QString checkColumn, QString valu
  * \param match - enum db::exactMatch or db::partialMatch
  * \param match - enum db::exactMatch or db::partialMatch
  * \return QString
  * \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 statement = "SELECT " + column + " FROM " + table + " WHERE " + checkColumn;
     QString result;
     QString result;
@@ -119,14 +121,14 @@ QString db::singleSelect(QString column, QString table, QString checkColumn, QSt
     QSqlQuery q(statement);
     QSqlQuery q(statement);
     q.exec();
     q.exec();
 
 
-    if(!q.first()){
+    if (!q.first()) {
         DEB("No result found. Check Query and Error.");
         DEB("No result found. Check Query and Error.");
         DEB("Error: " << q.lastError().text());
         DEB("Error: " << q.lastError().text());
         return QString();
         return QString();
-    }else{
+    } else {
         DEB("Success. Found a result.");
         DEB("Success. Found a result.");
         result.append(q.value(0).toString());
         result.append(q.value(0).toString());
-        if(q.next()){
+        if (q.next()) {
             DEB("More than one result in Database for your query");
             DEB("More than one result in Database for your query");
         }
         }
         return result;
         return result;
@@ -142,14 +144,13 @@ QString db::singleSelect(QString column, QString table, QString checkColumn, QSt
  * \param match - enum db::exactMatch or db::partialMatch
  * \param match - enum db::exactMatch or db::partialMatch
  * \return QVector<QString>
  * \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 ";
     QString statement = "SELECT ";
-    for(const auto& column : columns)
-    {
+    for (const auto &column : columns) {
         statement.append(column);
         statement.append(column);
-        if(column != columns.last())
-        {
+        if (column != columns.last()) {
             statement.append(QLatin1String(", "));
             statement.append(QLatin1String(", "));
         }
         }
     }
     }
@@ -171,17 +172,16 @@ QVector<QString> db::multiSelect(QVector<QString> columns, QString table, QStrin
     QSqlQuery q(statement);
     QSqlQuery q(statement);
     q.exec();
     q.exec();
 
 
-    if(!q.first()){
+    if (!q.first()) {
         DEB("No result found. Check Query and Error.");
         DEB("No result found. Check Query and Error.");
         DEB("Error: " << q.lastError().text());
         DEB("Error: " << q.lastError().text());
         return QVector<QString>();
         return QVector<QString>();
-    }else{
+    } else {
         q.first();
         q.first();
         q.previous();
         q.previous();
         QVector<QString> result;
         QVector<QString> result;
         while (q.next()) {
         while (q.next()) {
-            for(int i = 0; i < columns.size() ; i++)
-            {
+            for (int i = 0; i < columns.size() ; i++) {
                 result.append(q.value(i).toString());
                 result.append(q.value(i).toString());
             }
             }
         }
         }
@@ -197,11 +197,9 @@ QVector<QString> db::multiSelect(QVector<QString> columns, QString table, QStrin
 QVector<QString> db::multiSelect(QVector<QString> columns, QString table)
 QVector<QString> db::multiSelect(QVector<QString> columns, QString table)
 {
 {
     QString statement = "SELECT ";
     QString statement = "SELECT ";
-    for(const auto& column : columns)
-    {
+    for (const auto &column : columns) {
         statement.append(column);
         statement.append(column);
-        if(column != columns.last())
-        {
+        if (column != columns.last()) {
             statement.append(QLatin1String(", "));
             statement.append(QLatin1String(", "));
         }
         }
     }
     }
@@ -212,17 +210,16 @@ QVector<QString> db::multiSelect(QVector<QString> columns, QString table)
     QSqlQuery q(statement);
     QSqlQuery q(statement);
     q.exec();
     q.exec();
 
 
-    if(!q.first()){
+    if (!q.first()) {
         DEB("No result found. Check Query and Error.");
         DEB("No result found. Check Query and Error.");
         DEB("Error: " << q.lastError().text());
         DEB("Error: " << q.lastError().text());
         return QVector<QString>();
         return QVector<QString>();
-    }else{
+    } else {
         q.first();
         q.first();
         q.previous();
         q.previous();
         QVector<QString> result;
         QVector<QString> result;
         while (q.next()) {
         while (q.next()) {
-            for(int i = 0; i < columns.size() ; i++)
-            {
+            for (int i = 0; i < columns.size() ; i++) {
                 result.append(q.value(i).toString());
                 result.append(q.value(i).toString());
             }
             }
         }
         }
@@ -241,7 +238,8 @@ QVector<QString> db::multiSelect(QVector<QString> columns, QString table)
  * \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
  * \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;
     QString statement = "UPDATE " + table;
     statement.append(QLatin1String(" SET ") + column + QLatin1String(" = '") + value);
     statement.append(QLatin1String(" SET ") + column + QLatin1String(" = '") + value);
@@ -264,12 +262,10 @@ bool db::singleUpdate(QString table, QString column, QString value, QString chec
     q.exec();
     q.exec();
     QString error = q.lastError().text();
     QString error = q.lastError().text();
 
 
-    if(error.length() > 1)
-    {
+    if (error.length() > 1) {
         DEB("Errors have occured: " << error);
         DEB("Errors have occured: " << error);
         return false;
         return false;
-    }else
-    {
+    } else {
         DEB("Success!");
         DEB("Success!");
         return true;
         return true;
     }
     }
@@ -286,17 +282,16 @@ QVector<QString> db::customQuery(QString query, int returnValues)
     DEB(query);
     DEB(query);
     q.exec();
     q.exec();
 
 
-    if(!q.first()){
+    if (!q.first()) {
         DEB("No result found. Check Query and Error.");
         DEB("No result found. Check Query and Error.");
         DEB("Error: " << q.lastError().text());
         DEB("Error: " << q.lastError().text());
         return QVector<QString>();
         return QVector<QString>();
-    }else{
+    } else {
         q.first();
         q.first();
         q.previous();
         q.previous();
         QVector<QString> result;
         QVector<QString> result;
         while (q.next()) {
         while (q.next()) {
-            for(int i = 0; i < returnValues ; i++)
-            {
+            for (int i = 0; i < returnValues ; i++) {
                 result.append(q.value(i).toString());
                 result.append(q.value(i).toString());
             }
             }
         }
         }

+ 3 - 3
src/database/dbinfo.cpp

@@ -35,12 +35,12 @@ void dbInfo::getColumnNames()
 {
 {
     QSqlDatabase db = QSqlDatabase::database("qt_sql_default_connection");
     QSqlDatabase db = QSqlDatabase::database("qt_sql_default_connection");
     QVector<QString> columnNames;
     QVector<QString> columnNames;
-    for(const auto& table : tables){
+    for (const auto &table : tables) {
         columnNames.clear();
         columnNames.clear();
         QSqlRecord fields = db.record(table);
         QSqlRecord fields = db.record(table);
-        for(int i = 0; i < fields.count(); i++){
+        for (int i = 0; i < fields.count(); i++) {
             columnNames << fields.field(i).name();
             columnNames << fields.field(i).name();
-            format.insert(table,columnNames);
+            format.insert(table, columnNames);
         }
         }
     }
     }
 }
 }

+ 1 - 1
src/database/dbinfo.h

@@ -29,7 +29,7 @@ public:
 
 
     QString version = QString();
     QString version = QString();
 
 
-    QMap<QString,QVector<QString>> format;
+    QMap<QString, QVector<QString>> format;
 
 
     QVector<QString> tables;
     QVector<QString> tables;
 
 

+ 49 - 48
src/database/entry.cpp

@@ -30,39 +30,40 @@ entry::entry(QString table, int row)
     //retreive database layout
     //retreive database layout
     const auto dbContent = dbInfo();
     const auto dbContent = dbInfo();
 
 
-    if(dbContent.tables.contains(table)){
+    if (dbContent.tables.contains(table)) {
         position.first = table;
         position.first = table;
         columns = dbContent.format.value(table);
         columns = dbContent.format.value(table);
-    }else{
+    } 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();}
+        position.first = QString();
+    }
 
 
     //Check database for row id
     //Check database for row id
-    QString statement = "SELECT COUNT(*) FROM " + table + " WHERE _rowid_="+QString::number(row);
+    QString statement = "SELECT COUNT(*) FROM " + table + " WHERE _rowid_=" + QString::number(row);
     QSqlQuery q(statement);
     QSqlQuery q(statement);
     q.next();
     q.next();
     int rows = q.value(0).toInt();
     int rows = q.value(0).toInt();
-    if(rows==0){
+    if (rows == 0) {
         DEB("No entry found for row id: " << row );
         DEB("No entry found for row id: " << row );
         position.second = 0;
         position.second = 0;
-    }else{
+    } else {
         DEB("Retreiving data for row id: " << row);
         DEB("Retreiving data for row id: " << row);
-        QString statement = "SELECT * FROM " + table + " WHERE _rowid_="+QString::number(row);
+        QString statement = "SELECT * FROM " + table + " WHERE _rowid_=" + QString::number(row);
         DEB("Executing SQL...");
         DEB("Executing SQL...");
         DEB(statement);
         DEB(statement);
 
 
         QSqlQuery q(statement);
         QSqlQuery q(statement);
         q.exec();
         q.exec();
         q.next();
         q.next();
-        for(int i=0; i < dbContent.format.value(table).length(); i++){
-            data.insert(dbContent.format.value(table)[i],q.value(i).toString());
+        for (int i = 0; i < dbContent.format.value(table).length(); i++) {
+            data.insert(dbContent.format.value(table)[i], q.value(i).toString());
         }
         }
 
 
         QString error = q.lastError().text();
         QString error = q.lastError().text();
-        if(error.length() > 2){
+        if (error.length() > 2) {
             DEB("Error: " << q.lastError().text());
             DEB("Error: " << q.lastError().text());
             position.second = 0;
             position.second = 0;
-        }else{
+        } else {
             position.second = row;
             position.second = row;
         }
         }
     }
     }
@@ -73,24 +74,24 @@ entry::entry(QString table, QMap<QString, QString> newData)
     //retreive database layout
     //retreive database layout
     const auto dbContent = dbInfo();
     const auto dbContent = dbInfo();
 
 
-    if(dbContent.tables.contains(table)){
+    if (dbContent.tables.contains(table)) {
         position.first = table;
         position.first = table;
         position.second = 0;
         position.second = 0;
         columns = dbContent.format.value(table);
         columns = dbContent.format.value(table);
-    }else{
+    } 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();
         position.first = QString();
     }
     }
     //Check validity of newData
     //Check validity of newData
     QVector<QString> badkeys;
     QVector<QString> badkeys;
-    QMap<QString,QString>::iterator i;
-    for (i = newData.begin(); i != newData.end(); ++i){
-        if(!columns.contains(i.key())){
-            DEB(i.key() << "Not in column list for table " << table <<". Discarding.");
+    QMap<QString, QString>::iterator i;
+    for (i = newData.begin(); i != newData.end(); ++i) {
+        if (!columns.contains(i.key())) {
+            DEB(i.key() << "Not in column list for table " << table << ". Discarding.");
             badkeys << i.key();
             badkeys << i.key();
         }
         }
     }
     }
-    for(const auto& var : badkeys){
+    for (const auto &var : badkeys) {
         newData.remove(var);
         newData.remove(var);
     }
     }
     data = newData;
     data = newData;
@@ -103,31 +104,29 @@ void entry::setData(const QMap<QString, QString> &value)
 
 
 bool entry::commit()
 bool entry::commit()
 {
 {
-    if(exists()){
+    if (exists()) {
         return update();
         return update();
-    }else{
+    } else {
         return insert();
         return insert();
     }
     }
 }
 }
 
 
 bool entry::remove()
 bool entry::remove()
 {
 {
-    if(exists()){
+    if (exists()) {
         QString statement = "DELETE FROM " + position.first +
         QString statement = "DELETE FROM " + position.first +
-                           " WHERE _rowid_=" + QString::number(position.second);
+                            " WHERE _rowid_=" + QString::number(position.second);
         QSqlQuery q(statement);
         QSqlQuery q(statement);
         QString error = q.lastError().text();
         QString error = q.lastError().text();
 
 
-        if(error.length() > 1)
-        {
+        if (error.length() > 1) {
             DEB("Errors have occured: " << error);
             DEB("Errors have occured: " << error);
             return false;
             return false;
-        }else
-        {
+        } else {
             DEB("Entry removed.");
             DEB("Entry removed.");
             return true;
             return true;
         }
         }
-    }else{
+    } else {
         return false;
         return false;
     }
     }
 }
 }
@@ -136,15 +135,15 @@ bool entry::exists()
 {
 {
     //Check database for row id
     //Check database for row id
     QString statement = "SELECT COUNT(*) FROM " + position.first +
     QString statement = "SELECT COUNT(*) FROM " + position.first +
-                       " WHERE _rowid_="+QString::number(position.second);
+                        " WHERE _rowid_=" + QString::number(position.second);
     QSqlQuery q(statement);
     QSqlQuery q(statement);
     q.next();
     q.next();
     int rows = q.value(0).toInt();
     int rows = q.value(0).toInt();
-    if(rows){
-        DEB("Entry exists. "<<rows);
+    if (rows) {
+        DEB("Entry exists. " << rows);
         return true;
         return true;
-    }else{
-        DEB("Entry does not exist. "<<rows);
+    } else {
+        DEB("Entry does not exist. " << rows);
         return false;
         return false;
     }
     }
 }
 }
@@ -154,18 +153,18 @@ bool entry::insert()
     DEB("Inserting...");
     DEB("Inserting...");
     //check prerequisites
     //check prerequisites
 
 
-    if(data.isEmpty()){
+    if (data.isEmpty()) {
         DEB("Object Contains no data. Aborting.");
         DEB("Object Contains no data. Aborting.");
         return false;
         return false;
     }
     }
     QString statement = "INSERT INTO " + position.first + QLatin1String(" (");
     QString statement = "INSERT INTO " + position.first + QLatin1String(" (");
-    QMap<QString,QString>::iterator i;
-    for (i = data.begin(); i != data.end(); ++i){
+    QMap<QString, QString>::iterator i;
+    for (i = data.begin(); i != data.end(); ++i) {
         statement += i.key() + QLatin1String(", ");
         statement += i.key() + QLatin1String(", ");
     }
     }
     statement.chop(2);
     statement.chop(2);
     statement += QLatin1String(") VALUES (");
     statement += QLatin1String(") VALUES (");
-    for (i = data.begin(); i != data.end(); ++i){
+    for (i = data.begin(); i != data.end(); ++i) {
         statement += QLatin1String("'") + i.value() + QLatin1String("', ");
         statement += QLatin1String("'") + i.value() + QLatin1String("', ");
     }
     }
     statement.chop(2);
     statement.chop(2);
@@ -173,10 +172,10 @@ bool entry::insert()
 
 
     QSqlQuery q(statement);
     QSqlQuery q(statement);
     QString error = q.lastError().text();
     QString error = q.lastError().text();
-    if(error.length() < 2){
+    if (error.length() < 2) {
         DEB("Entry successfully committed.");
         DEB("Entry successfully committed.");
         return true;
         return true;
-    }else{
+    } else {
         DEB("Unable to commit. Query Error: " << q.lastError().text());
         DEB("Unable to commit. Query Error: " << q.lastError().text());
         return false;
         return false;
     }
     }
@@ -187,23 +186,25 @@ bool entry::update()
     //create query
     //create query
     QString statement = "UPDATE " + position.first + " SET ";
     QString statement = "UPDATE " + position.first + " SET ";
 
 
-    QMap<QString,QString>::const_iterator i;
-    for (i = data.constBegin(); i != data.constEnd(); ++i){
-        if(i.key()!=QString()){
-            statement += i.key()+QLatin1String("='")+i.value()+QLatin1String("', ");
-        }else{DEB(i.key() << "is empty key. skipping.");}
+    QMap<QString, QString>::const_iterator i;
+    for (i = data.constBegin(); i != data.constEnd(); ++i) {
+        if (i.key() != QString()) {
+            statement += i.key() + QLatin1String("='") + i.value() + QLatin1String("', ");
+        } else {
+            DEB(i.key() << "is empty key. skipping.");
+        }
     }
     }
     statement.chop(2); // Remove last comma
     statement.chop(2); // Remove last comma
-    statement.append(QLatin1String(" WHERE _rowid_=")+QString::number(position.second));
+    statement.append(QLatin1String(" WHERE _rowid_=") + QString::number(position.second));
 
 
     //execute query
     //execute query
     QSqlQuery q(statement);
     QSqlQuery q(statement);
     //check result. Upon success, error should be " "
     //check result. Upon success, error should be " "
     QString error = q.lastError().text();
     QString error = q.lastError().text();
-    if(error.length() < 2){
+    if (error.length() < 2) {
         DEB("Object successfully updated.");
         DEB("Object successfully updated.");
         return true;
         return true;
-    }else{
+    } else {
         DEB("Query Error: " << q.lastError().text());
         DEB("Query Error: " << q.lastError().text());
         return false;
         return false;
     }
     }
@@ -220,8 +221,8 @@ void entry::print()
     //if(isValid){cout << v;}else{cout << nv;}
     //if(isValid){cout << v;}else{cout << nv;}
     cout << "Record from table: " << position.first << ", row: " << position.second << "\n";
     cout << "Record from table: " << position.first << ", row: " << position.second << "\n";
     cout << "=================================\n";
     cout << "=================================\n";
-    QMap<QString,QString>::const_iterator i;
-    for (i = data.constBegin(); i != data.constEnd(); ++i){
+    QMap<QString, QString>::const_iterator i;
+    for (i = data.constBegin(); i != data.constEnd(); ++i) {
         cout << i.key() << ":\t" << i.value() << "\n";
         cout << i.key() << ":\t" << i.value() << "\n";
     }
     }
 }
 }

+ 10 - 4
src/database/entry.h

@@ -33,9 +33,13 @@ public:
     entry(QString table, int row);
     entry(QString table, int row);
     entry(QString table, QMap<QString, QString> newData);
     entry(QString table, QMap<QString, QString> newData);
 
 
-    QPair   <QString,int>       position = QPair<QString,int>();     // Position within the database, i.e. <table,row>
+
+
+    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
     QVector <QString>           columns  = QVector<QString>();       // The columns within the table
-    QMap    <QString,QString>   data     = QMap<QString,QString>();  // Tha data to fill that table, <column,value>
+    QMap    <QString, QString>   data     =
+        QMap<QString, QString>(); // Tha data to fill that table, <column,value>
 
 
     void setData(const QMap<QString, QString> &value);
     void setData(const QMap<QString, QString> &value);
 
 
@@ -43,11 +47,13 @@ public:
     bool remove();
     bool remove();
     bool exists();
     bool exists();
 
 
-
     // Debug functionality
     // Debug functionality
     void print();
     void print();
     QString debug();
     QString debug();
-    operator QString() { return debug(); } //overload for compatibility with qDebug()
+    operator QString()
+    {
+        return debug();    //overload for compatibility with qDebug()
+    }
 
 
 private:
 private:
 
 

+ 17 - 16
src/gui/dialogues/newpilot.cpp

@@ -48,10 +48,10 @@ NewPilot::~NewPilot()
 void NewPilot::on_buttonBox_accepted()
 void NewPilot::on_buttonBox_accepted()
 {
 {
     DEB("aseontuh");
     DEB("aseontuh");
-    if(ui->piclastnameLineEdit->text().isEmpty()){
+    if (ui->piclastnameLineEdit->text().isEmpty()) {
         auto mb = new QMessageBox(this);
         auto mb = new QMessageBox(this);
         mb->setText("Last Name is required.");
         mb->setText("Last Name is required.");
-    }else{
+    } else {
         submitForm();
         submitForm();
     }
     }
 }
 }
@@ -60,13 +60,13 @@ void NewPilot::formFiller()
 {
 {
     DEB("Filling Form...");
     DEB("Filling Form...");
     DEB(oldEntry);
     DEB(oldEntry);
-    auto line_edits = parent()->findChildren<QLineEdit*>();
+    auto line_edits = parent()->findChildren<QLineEdit *>();
 
 
-    for (const auto& le : line_edits) {
+    for (const auto &le : line_edits) {
         QString key = le->objectName();
         QString key = le->objectName();
         key.chop(8);//remove "LineEdit"
         key.chop(8);//remove "LineEdit"
         QString value = oldEntry.data.value(key);
         QString value = oldEntry.data.value(key);
-        if(!value.isEmpty()){
+        if (!value.isEmpty()) {
             le->setText(value);
             le->setText(value);
         }
         }
     }
     }
@@ -75,30 +75,31 @@ void NewPilot::formFiller()
 void NewPilot::submitForm()
 void NewPilot::submitForm()
 {
 {
     DEB("Creating Database Object...");
     DEB("Creating Database Object...");
-    QMap<QString,QString> newData;
+    QMap<QString, QString> newData;
 
 
-    auto line_edits = parent()->findChildren<QLineEdit*>();
+    auto line_edits = parent()->findChildren<QLineEdit *>();
 
 
-    for (const auto& le : line_edits) {
+    for (const auto &le : line_edits) {
         QString key = le->objectName();
         QString key = le->objectName();
         key.chop(8);//remove "LineEdit"
         key.chop(8);//remove "LineEdit"
         QString value = le->text();
         QString value = le->text();
-        if(!key.isEmpty()){
-            newData.insert(key,value);
+        if (!key.isEmpty()) {
+            newData.insert(key, value);
         }
         }
     }
     }
-    DEB("New Data: "<<newData);
-    DEB("Role: "<<role);
+    DEB("New Data: " << newData);
+    DEB("Role: " << role);
     //create db object
     //create db object
     switch (role) {
     switch (role) {
-    case db::createNew:{
-        auto newEntry = pilot("pilots",newData);;
+    case db::createNew: {
+        auto newEntry = pilot("pilots", newData);;
         DEB("New Object: ");
         DEB("New Object: ");
         newEntry.commit();
         newEntry.commit();
-        break;}
+        break;
+    }
     case db::editExisting:
     case db::editExisting:
         oldEntry.setData(newData);
         oldEntry.setData(newData);
-        DEB("updated entry: "<< oldEntry);
+        DEB("updated entry: " << oldEntry);
         oldEntry.commit();
         oldEntry.commit();
         break;
         break;
     }
     }

+ 75 - 70
src/gui/dialogues/newtail.cpp

@@ -66,28 +66,30 @@ void NewTail::formFiller(aircraft entry)
 {
 {
     DEB("Filling Form for a/c" << entry);
     DEB("Filling Form for a/c" << entry);
     //fill Line Edits
     //fill Line Edits
-    auto line_edits = parent()->findChildren<QLineEdit*>();
-    for (const auto& le : line_edits) {
+    auto line_edits = parent()->findChildren<QLineEdit *>();
+    for (const auto &le : line_edits) {
         QString name = le->objectName();
         QString name = le->objectName();
         name.chop(8);//remove "LineEdit"
         name.chop(8);//remove "LineEdit"
         QString value = entry.data.value(name);
         QString value = entry.data.value(name);
-        if(!value.isEmpty()){
+        if (!value.isEmpty()) {
             le->setText(value);
             le->setText(value);
         };
         };
     }
     }
     //select comboboxes
     //select comboboxes
-    QVector<QString> operation = {entry.data.value("singleengine"),entry.data.value("multiengine")};
-    QVector<QString> ppNumber =  {entry.data.value("singlepilot"),entry.data.value("multipilot")};
-    QVector<QString> ppType =    {entry.data.value("unpowered"),entry.data.value("piston"),
-                                  entry.data.value("turboprop"),entry.data.value("jet")};
-    QVector<QString> weight =    {entry.data.value("light"),entry.data.value("medium"),
-                                  entry.data.value("heavy"),entry.data.value("super")};
+    QVector<QString> operation = {entry.data.value("singleengine"), entry.data.value("multiengine")};
+    QVector<QString> ppNumber =  {entry.data.value("singlepilot"), entry.data.value("multipilot")};
+    QVector<QString> ppType =    {entry.data.value("unpowered"), entry.data.value("piston"),
+                                  entry.data.value("turboprop"), entry.data.value("jet")
+                                 };
+    QVector<QString> weight =    {entry.data.value("light"), entry.data.value("medium"),
+                                  entry.data.value("heavy"), entry.data.value("super")
+                                 };
 
 
 
 
-    ui->operationComboBox->setCurrentIndex(operation.indexOf("1")+1);
-    ui->ppNumberComboBox->setCurrentIndex(ppNumber.indexOf("1")+1);
-    ui->ppTypeComboBox->setCurrentIndex(ppType.indexOf("1")+1);
-    ui->weightComboBox->setCurrentIndex(weight.indexOf("1")+1);
+    ui->operationComboBox->setCurrentIndex(operation.indexOf("1") + 1);
+    ui->ppNumberComboBox->setCurrentIndex(ppNumber.indexOf("1") + 1);
+    ui->ppTypeComboBox->setCurrentIndex(ppType.indexOf("1") + 1);
+    ui->weightComboBox->setCurrentIndex(weight.indexOf("1") + 1);
 }
 }
 
 
 /// Functions
 /// Functions
@@ -99,11 +101,11 @@ void NewTail::formFiller(aircraft entry)
 void NewTail::setupCompleter()
 void NewTail::setupCompleter()
 {
 {
     auto query = QLatin1String("SELECT make||' '||model||'-'||variant, aircraft_id FROM aircraft");
     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;
     QMap<QString, int> map;
-    for (int i = 0; i < vector.length()-2 ; i += 2){
-        if(vector[i] != QLatin1String("")){
-            map.insert(vector[i],vector[i+1].toInt());
+    for (int i = 0; i < vector.length() - 2 ; i += 2) {
+        if (vector[i] != QLatin1String("")) {
+            map.insert(vector[i], vector[i + 1].toInt());
         }
         }
     }
     }
     //creating QStringlist for QCompleter
     //creating QStringlist for QCompleter
@@ -112,7 +114,7 @@ void NewTail::setupCompleter()
     aircraftlist = cl->list;
     aircraftlist = cl->list;
     idMap = map;
     idMap = map;
 
 
-    QCompleter* completer = new QCompleter(aircraftlist,ui->searchLineEdit);
+    QCompleter *completer = new QCompleter(aircraftlist, ui->searchLineEdit);
     completer->setCaseSensitivity(Qt::CaseInsensitive);
     completer->setCaseSensitivity(Qt::CaseInsensitive);
     completer->setCompletionMode(QCompleter::PopupCompletion);
     completer->setCompletionMode(QCompleter::PopupCompletion);
     completer->setFilterMode(Qt::MatchContains);
     completer->setFilterMode(Qt::MatchContains);
@@ -124,38 +126,38 @@ void NewTail::setupCompleter()
  */
  */
 bool NewTail::verify()
 bool NewTail::verify()
 {
 {
-    auto recommended_line_edits = parent()->findChildren<QLineEdit*>("registrationLineEdit");
-    recommended_line_edits.append(parent()->findChild<QLineEdit*>("makeLineEdit"));
-    recommended_line_edits.append(parent()->findChild<QLineEdit*>("modelLineEdit"));
+    auto recommended_line_edits = parent()->findChildren<QLineEdit *>("registrationLineEdit");
+    recommended_line_edits.append(parent()->findChild<QLineEdit *>("makeLineEdit"));
+    recommended_line_edits.append(parent()->findChild<QLineEdit *>("modelLineEdit"));
 
 
-    auto recommended_combo_boxes = parent()->findChildren<QComboBox*>("operationComboBox");
-    recommended_combo_boxes.append(parent()->findChild<QComboBox*>("ppNumberComboBox"));
-    recommended_combo_boxes.append(parent()->findChild<QComboBox*>("ppTypeComboBox"));
+    auto recommended_combo_boxes = parent()->findChildren<QComboBox *>("operationComboBox");
+    recommended_combo_boxes.append(parent()->findChild<QComboBox *>("ppNumberComboBox"));
+    recommended_combo_boxes.append(parent()->findChild<QComboBox *>("ppTypeComboBox"));
 
 
-    for(const auto le : recommended_line_edits){
-        if(le->text() != ""){
+    for (const auto le : recommended_line_edits) {
+        if (le->text() != "") {
             DEB("Good: " << le);
             DEB("Good: " << le);
             recommended_line_edits.removeOne(le);
             recommended_line_edits.removeOne(le);
             le->setStyleSheet("");
             le->setStyleSheet("");
-        }else{
+        } else {
             le->setStyleSheet("border: 1px solid red");
             le->setStyleSheet("border: 1px solid red");
             DEB("Not Good: " << le);
             DEB("Not Good: " << le);
         }
         }
     }
     }
-    for(const auto cb : recommended_combo_boxes){
-        if(cb->currentIndex() != 0){
+    for (const auto cb : recommended_combo_boxes) {
+        if (cb->currentIndex() != 0) {
 
 
             recommended_combo_boxes.removeOne(cb);
             recommended_combo_boxes.removeOne(cb);
             cb->setStyleSheet("");
             cb->setStyleSheet("");
-        }else{
+        } else {
             cb->setStyleSheet("background: orange");
             cb->setStyleSheet("background: orange");
             DEB("Not Good: " << cb);
             DEB("Not Good: " << cb);
         }
         }
     }
     }
 
 
-    if(recommended_line_edits.isEmpty() && recommended_combo_boxes.isEmpty()){
+    if (recommended_line_edits.isEmpty() && recommended_combo_boxes.isEmpty()) {
         return true;
         return true;
-    }else{
+    } else {
         return false;
         return false;
     }
     }
 }
 }
@@ -163,44 +165,47 @@ bool NewTail::verify()
 void NewTail::submitForm(db::editRole edRole)
 void NewTail::submitForm(db::editRole edRole)
 {
 {
     DEB("Creating Database Object...");
     DEB("Creating Database Object...");
-    QMap<QString,QString> newData;
+    QMap<QString, QString> newData;
     //retreive Line Edits
     //retreive Line Edits
-    auto line_edits = parent()->findChildren<QLineEdit*>();
+    auto line_edits = parent()->findChildren<QLineEdit *>();
 
 
-    for (const auto& le : line_edits) {
+    for (const auto &le : line_edits) {
         QString name = le->objectName();
         QString name = le->objectName();
         name.chop(8);//remove "LineEdit"
         name.chop(8);//remove "LineEdit"
-        if(!le->text().isEmpty()){
-            newData.insert(name,le->text());
+        if (!le->text().isEmpty()) {
+            newData.insert(name, le->text());
         }
         }
     }
     }
 
 
     //prepare comboboxes
     //prepare comboboxes
-    QVector<QString> operation = {"singlepilot","multipilot"};
-    QVector<QString> ppNumber  = {"singleengine","multiengine"};
-    QVector<QString> ppType    = {"unpowered","piston",
-                                  "turboprop","jet"};
-    QVector<QString> weight    = {"light","medium",
-                                  "heavy","super"};
+    QVector<QString> operation = {"singlepilot", "multipilot"};
+    QVector<QString> ppNumber  = {"singleengine", "multiengine"};
+    QVector<QString> ppType    = {"unpowered", "piston",
+                                  "turboprop", "jet"
+                                 };
+    QVector<QString> weight    = {"light", "medium",
+                                  "heavy", "super"
+                                 };
 
 
-    if(ui->operationComboBox->currentIndex()!=0){
-        newData.insert(operation[ui->operationComboBox->currentIndex()-1],QLatin1String("1"));
+    if (ui->operationComboBox->currentIndex() != 0) {
+        newData.insert(operation[ui->operationComboBox->currentIndex() - 1], QLatin1String("1"));
     }
     }
-    if(ui->ppNumberComboBox->currentIndex()!=0){
-        newData.insert(ppNumber[ui->ppNumberComboBox->currentIndex()-1],QLatin1String("1"));
+    if (ui->ppNumberComboBox->currentIndex() != 0) {
+        newData.insert(ppNumber[ui->ppNumberComboBox->currentIndex() - 1], QLatin1String("1"));
     }
     }
-    if(ui->ppTypeComboBox->currentIndex()!=0){
-        newData.insert(ppType[ui->ppTypeComboBox->currentIndex()-1],QLatin1String("1"));
+    if (ui->ppTypeComboBox->currentIndex() != 0) {
+        newData.insert(ppType[ui->ppTypeComboBox->currentIndex() - 1], QLatin1String("1"));
     }
     }
-    if(ui->weightComboBox->currentIndex()!=0){
-        newData.insert(weight[ui->weightComboBox->currentIndex()-1],QLatin1String("1"));
+    if (ui->weightComboBox->currentIndex() != 0) {
+        newData.insert(weight[ui->weightComboBox->currentIndex() - 1], QLatin1String("1"));
     }
     }
     //create db object
     //create db object
     switch (edRole) {
     switch (edRole) {
-    case db::createNew:{
-        auto newEntry = new aircraft("tails",newData);;
+    case db::createNew: {
+        auto newEntry = new aircraft("tails", newData);;
         newEntry->commit();
         newEntry->commit();
-        break;}
+        break;
+    }
     case db::editExisting:
     case db::editExisting:
         oldEntry.setData(newData);
         oldEntry.setData(newData);
         oldEntry.commit();
         oldEntry.commit();
@@ -212,13 +217,14 @@ void NewTail::submitForm(db::editRole edRole)
 
 
 void NewTail::on_searchLineEdit_textChanged(const QString &arg1)
 void NewTail::on_searchLineEdit_textChanged(const QString &arg1)
 {
 {
-    if(aircraftlist.contains(arg1)){//equivalent to editing finished for this purpose. todo: consider connecing qcompleter activated signal with editing finished slot.
+    if (aircraftlist.contains(
+                arg1)) { //equivalent to editing finished for this purpose. todo: consider connecing qcompleter activated signal with editing finished slot.
 
 
         DEB("Template Selected. aircraft_id is: " << idMap.value(arg1));
         DEB("Template Selected. aircraft_id is: " << idMap.value(arg1));
         //call autofiller for dialog
         //call autofiller for dialog
-        formFiller(aircraft("aircraft",idMap.value(arg1)));
+        formFiller(aircraft("aircraft", idMap.value(arg1)));
         ui->searchLineEdit->setStyleSheet("border: 1px solid green");
         ui->searchLineEdit->setStyleSheet("border: 1px solid green");
-    }else{
+    } else {
         //for example, editing finished without selecting a result from Qcompleter
         //for example, editing finished without selecting a result from Qcompleter
         ui->searchLineEdit->setStyleSheet("border: 1px solid orange");
         ui->searchLineEdit->setStyleSheet("border: 1px solid orange");
     }
     }
@@ -226,28 +232,28 @@ void NewTail::on_searchLineEdit_textChanged(const QString &arg1)
 
 
 void NewTail::on_operationComboBox_currentIndexChanged(int index)
 void NewTail::on_operationComboBox_currentIndexChanged(int index)
 {
 {
-    if(index != 0){
+    if (index != 0) {
         ui->operationComboBox->setStyleSheet("");
         ui->operationComboBox->setStyleSheet("");
     }
     }
 }
 }
 
 
 void NewTail::on_ppTypeComboBox_currentIndexChanged(int index)
 void NewTail::on_ppTypeComboBox_currentIndexChanged(int index)
 {
 {
-    if(index != 0){
+    if (index != 0) {
         ui->ppTypeComboBox->setStyleSheet("");
         ui->ppTypeComboBox->setStyleSheet("");
     }
     }
 }
 }
 
 
 void NewTail::on_ppNumberComboBox_currentIndexChanged(int index)
 void NewTail::on_ppNumberComboBox_currentIndexChanged(int index)
 {
 {
-    if(index != 0){
+    if (index != 0) {
         ui->ppNumberComboBox->setStyleSheet("");
         ui->ppNumberComboBox->setStyleSheet("");
     }
     }
 }
 }
 
 
 void NewTail::on_weightComboBox_currentIndexChanged(int index)
 void NewTail::on_weightComboBox_currentIndexChanged(int index)
 {
 {
-    if(index != 0){
+    if (index != 0) {
         ui->weightComboBox->setStyleSheet("");
         ui->weightComboBox->setStyleSheet("");
     }
     }
 }
 }
@@ -255,23 +261,23 @@ void NewTail::on_weightComboBox_currentIndexChanged(int index)
 void NewTail::on_buttonBox_accepted()
 void NewTail::on_buttonBox_accepted()
 {
 {
     DEB("Button Box Accepted.");
     DEB("Button Box Accepted.");
-    if(ui->registrationLineEdit->text().isEmpty()){
+    if (ui->registrationLineEdit->text().isEmpty()) {
         auto nope = new QMessageBox(this);
         auto nope = new QMessageBox(this);
         nope->setText("Registration cannot be empty.");
         nope->setText("Registration cannot be empty.");
         nope->show();
         nope->show();
-    }else{
-        if(verify()){
+    } else {
+        if (verify()) {
             DEB("Form verified");
             DEB("Form verified");
             submitForm(role);
             submitForm(role);
             accept();
             accept();
-        }else{
+        } else {
             QSettings setting;
             QSettings setting;
-            if(!setting.value("userdata/acAllowIncomplete").toInt()){
+            if (!setting.value("userdata/acAllowIncomplete").toInt()) {
                 auto nope = new QMessageBox(this);
                 auto nope = new QMessageBox(this);
                 nope->setText("Some or all fields are empty.\nPlease go back and "
                 nope->setText("Some or all fields are empty.\nPlease go back and "
                               "complete.\n\nYou can allow logging incomplete entries on the settings page.");
                               "complete.\n\nYou can allow logging incomplete entries on the settings page.");
                 nope->show();
                 nope->show();
-            }else{
+            } else {
                 QMessageBox::StandardButton reply;
                 QMessageBox::StandardButton reply;
                 reply = QMessageBox::question(this, "Warning",
                 reply = QMessageBox::question(this, "Warning",
                                               "Some recommended fields are empty.\n\n"
                                               "Some recommended fields are empty.\n\n"
@@ -280,9 +286,8 @@ void NewTail::on_buttonBox_accepted()
                                               "This will also impact statistics and auto-logging capabilites.\n\n"
                                               "This will also impact statistics and auto-logging capabilites.\n\n"
                                               "It is highly recommended to fill in all the details.\n\n"
                                               "It is highly recommended to fill in all the details.\n\n"
                                               "Are you sure you want to proceed?",
                                               "Are you sure you want to proceed?",
-                                              QMessageBox::Yes|QMessageBox::No);
-                if (reply == QMessageBox::Yes)
-                {
+                                              QMessageBox::Yes | QMessageBox::No);
+                if (reply == QMessageBox::Yes) {
                     submitForm(role);
                     submitForm(role);
                     accept();
                     accept();
                 }
                 }

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

@@ -50,21 +50,21 @@ aircraftWidget::aircraftWidget(QWidget *parent) :
     view->setSelectionMode(QAbstractItemView::SingleSelection);
     view->setSelectionMode(QAbstractItemView::SingleSelection);
     view->setEditTriggers(QAbstractItemView::NoEditTriggers);
     view->setEditTriggers(QAbstractItemView::NoEditTriggers);
     view->horizontalHeader()->setStretchLastSection(QHeaderView::Stretch);
     view->horizontalHeader()->setStretchLastSection(QHeaderView::Stretch);
-    view->setColumnWidth(0,60);
-    view->setColumnWidth(1,120);
-    view->setColumnWidth(2,180);
+    view->setColumnWidth(0, 60);
+    view->setColumnWidth(1, 120);
+    view->setColumnWidth(2, 180);
     view->verticalHeader()->hide();
     view->verticalHeader()->hide();
     view->setAlternatingRowColors(true);
     view->setAlternatingRowColors(true);
     view->setSortingEnabled(true);
     view->setSortingEnabled(true);
     QSettings settings;
     QSettings settings;
 
 
-    view->sortByColumn(settings.value("userdata/acSortColumn").toInt(),Qt::AscendingOrder);
+    view->sortByColumn(settings.value("userdata/acSortColumn").toInt(), Qt::AscendingOrder);
 
 
     view->show();
     view->show();
 
 
     connect(ui->tableView->selectionModel(),
     connect(ui->tableView->selectionModel(),
-    SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
-    SLOT(tableView_selectionChanged(const QItemSelection &, const QItemSelection &)));
+            SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
+            SLOT(tableView_selectionChanged(const QItemSelection &, const QItemSelection &)));
 }
 }
 
 
 aircraftWidget::~aircraftWidget()
 aircraftWidget::~aircraftWidget()
@@ -82,7 +82,7 @@ void aircraftWidget::tableView_selectionChanged(const QItemSelection &index, con
     setSelectedAircraft(index.indexes()[0].data().toInt());
     setSelectedAircraft(index.indexes()[0].data().toInt());
     DEB("Selected aircraft with ID#: " << selectedAircraft);
     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);
     //auto nt = new NewTail(db(db::tails,selectedAircraft),this);
 
 
     nt->setWindowFlag(Qt::Widget);
     nt->setWindowFlag(Qt::Widget);
@@ -92,9 +92,9 @@ void aircraftWidget::tableView_selectionChanged(const QItemSelection &index, con
 
 
 void aircraftWidget::on_deleteButton_clicked()
 void aircraftWidget::on_deleteButton_clicked()
 {
 {
-    if(selectedAircraft > 0){
+    if (selectedAircraft > 0) {
 
 
-        auto ac = new aircraft("tails",selectedAircraft);
+        auto ac = new aircraft("tails", selectedAircraft);
         ac->remove();
         ac->remove();
 
 
 
 
@@ -103,12 +103,12 @@ void aircraftWidget::on_deleteButton_clicked()
         model->select();
         model->select();
         ui->tableView->setModel(model);
         ui->tableView->setModel(model);
         connect(ui->tableView->selectionModel(),
         connect(ui->tableView->selectionModel(),
-        SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
-        SLOT(tableView_selectionChanged(const QItemSelection &, const QItemSelection &)));
+                SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
+                SLOT(tableView_selectionChanged(const QItemSelection &, const QItemSelection &)));
 
 
-        ui->stackedWidget->setCurrentWidget(parent()->findChild<QWidget*>("welcomeAC"));
+        ui->stackedWidget->setCurrentWidget(parent()->findChild<QWidget *>("welcomeAC"));
 
 
-    }else{
+    } else {
         auto mb = new QMessageBox(this);
         auto mb = new QMessageBox(this);
         mb->setText("No aircraft selected.");
         mb->setText("No aircraft selected.");
         mb->show();
         mb->show();
@@ -117,6 +117,6 @@ void aircraftWidget::on_deleteButton_clicked()
 
 
 void aircraftWidget::on_newButton_clicked()
 void aircraftWidget::on_newButton_clicked()
 {
 {
-    auto nt = new NewTail(QString(), db::createNew,this);
+    auto nt = new NewTail(QString(), db::createNew, this);
     nt->show();
     nt->show();
 }
 }

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

@@ -53,8 +53,8 @@ homeWidget::~homeWidget()
 
 
 void homeWidget::on_pushButton_clicked()
 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();
     np->show();
 }
 }
 
 

+ 25 - 27
src/gui/widgets/logbookwidget.cpp

@@ -41,16 +41,16 @@ logbookWidget::logbookWidget(QWidget *parent) :
     view->setSelectionBehavior(QAbstractItemView::SelectRows);
     view->setSelectionBehavior(QAbstractItemView::SelectRows);
     view->setSelectionMode(QAbstractItemView::SingleSelection);
     view->setSelectionMode(QAbstractItemView::SingleSelection);
     view->setEditTriggers(QAbstractItemView::NoEditTriggers);
     view->setEditTriggers(QAbstractItemView::NoEditTriggers);
-    view->setColumnWidth(1,120);
-    view->setColumnWidth(2,60);
-    view->setColumnWidth(3,60);
-    view->setColumnWidth(4,60);
-    view->setColumnWidth(5,60);
-    view->setColumnWidth(6,60);
-    view->setColumnWidth(7,120);
-    view->setColumnWidth(8,180);
-    view->setColumnWidth(9,120);
-    view->setColumnWidth(10,90);
+    view->setColumnWidth(1, 120);
+    view->setColumnWidth(2, 60);
+    view->setColumnWidth(3, 60);
+    view->setColumnWidth(4, 60);
+    view->setColumnWidth(5, 60);
+    view->setColumnWidth(6, 60);
+    view->setColumnWidth(7, 120);
+    view->setColumnWidth(8, 180);
+    view->setColumnWidth(9, 120);
+    view->setColumnWidth(10, 90);
     view->horizontalHeader()->setStretchLastSection(QHeaderView::Stretch);
     view->horizontalHeader()->setStretchLastSection(QHeaderView::Stretch);
     view->verticalHeader()->hide();
     view->verticalHeader()->hide();
     view->setAlternatingRowColors(true);
     view->setAlternatingRowColors(true);
@@ -62,8 +62,8 @@ logbookWidget::logbookWidget(QWidget *parent) :
     DEB("Time taken for lookup and rendering: " << duration.count() << " microseconds");
     DEB("Time taken for lookup and rendering: " << duration.count() << " microseconds");
 
 
     connect(ui->tableView->selectionModel(),
     connect(ui->tableView->selectionModel(),
-    SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
-    SLOT(tableView_selectionChanged(const QItemSelection &, const QItemSelection &)));
+            SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
+            SLOT(tableView_selectionChanged(const QItemSelection &, const QItemSelection &)));
 }
 }
 
 
 logbookWidget::~logbookWidget()
 logbookWidget::~logbookWidget()
@@ -76,7 +76,8 @@ void logbookWidget::setSelectedFlight(const qint32 &value)
     selectedFlight = value;
     selectedFlight = value;
 }
 }
 
 
-void logbookWidget::tableView_selectionChanged(const QItemSelection &index, const QItemSelection &)// TO DO
+void logbookWidget::tableView_selectionChanged(const QItemSelection &index,
+                                               const QItemSelection &)// TO DO
 {
 {
     setSelectedFlight(index.indexes()[0].data().toInt());
     setSelectedFlight(index.indexes()[0].data().toInt());
     DEB("Selected flight with ID#: " << selectedFlight);
     DEB("Selected flight with ID#: " << selectedFlight);
@@ -104,15 +105,14 @@ void logbookWidget::on_editFlightButton_clicked() // To Do: Fix! - use new fligh
 
 
 void logbookWidget::on_deleteFlightPushButton_clicked()
 void logbookWidget::on_deleteFlightPushButton_clicked()
 {
 {
-    if(selectedFlight > 0)
-    {
+    if (selectedFlight > 0) {
         QVector<QString> columns = {
         QVector<QString> columns = {
             "doft", "dept", "dest"
             "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";
         QString detailsstring = "The following flight will be deleted:\n\n";
-        for(const auto& item : details)
-        {
+        for (const auto &item : details) {
             detailsstring.append(item);
             detailsstring.append(item);
             detailsstring.append(QLatin1Char(' '));
             detailsstring.append(QLatin1Char(' '));
         }
         }
@@ -120,11 +120,10 @@ void logbookWidget::on_deleteFlightPushButton_clicked()
 
 
         QMessageBox::StandardButton reply;
         QMessageBox::StandardButton reply;
         reply = QMessageBox::question(this, "Delete Flight", detailsstring,
         reply = QMessageBox::question(this, "Delete Flight", detailsstring,
-                                      QMessageBox::Yes|QMessageBox::No);
-        if (reply == QMessageBox::Yes)
-        {
+                                      QMessageBox::Yes | QMessageBox::No);
+        if (reply == QMessageBox::Yes) {
             DEB("Deleting flight with ID# " << selectedFlight);
             DEB("Deleting flight with ID# " << selectedFlight);
-            auto en = new flight("flights",selectedFlight);
+            auto en = new flight("flights", selectedFlight);
             en->remove();
             en->remove();
 
 
             QSqlTableModel *ShowAllModel = new QSqlTableModel; //refresh view
             QSqlTableModel *ShowAllModel = new QSqlTableModel; //refresh view
@@ -132,11 +131,10 @@ void logbookWidget::on_deleteFlightPushButton_clicked()
             ShowAllModel->select();
             ShowAllModel->select();
             ui->tableView->setModel(ShowAllModel);
             ui->tableView->setModel(ShowAllModel);
             connect(ui->tableView->selectionModel(),
             connect(ui->tableView->selectionModel(),
-            SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
-            SLOT(tableView_selectionChanged(const QItemSelection &, const QItemSelection &)));
+                    SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
+                    SLOT(tableView_selectionChanged(const QItemSelection &, const QItemSelection &)));
         }
         }
-    }else
-    {
+    } else {
         QMessageBox NoFlight;
         QMessageBox NoFlight;
         NoFlight.setText("No flight selected.");
         NoFlight.setText("No flight selected.");
         NoFlight.exec();
         NoFlight.exec();
@@ -149,7 +147,7 @@ void logbookWidget::on_filterFlightsByDateButton_clicked()
     QString startdate = date.toString("yyyy-MM-dd");
     QString startdate = date.toString("yyyy-MM-dd");
     date = ui->filterDateEdit_2->date();
     date = ui->filterDateEdit_2->date();
     QString enddate = date.toString("yyyy-MM-dd");
     QString enddate = date.toString("yyyy-MM-dd");
-    QString datefilter = "Date BETWEEN '" + startdate +"' AND '" + enddate + QLatin1Char('\'');
+    QString datefilter = "Date BETWEEN '" + startdate + "' AND '" + enddate + QLatin1Char('\'');
 
 
     QSqlTableModel *DateFilteredModel = new QSqlTableModel;
     QSqlTableModel *DateFilteredModel = new QSqlTableModel;
     DateFilteredModel ->setTable("Logbook");
     DateFilteredModel ->setTable("Logbook");

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

@@ -50,21 +50,21 @@ pilotsWidget::pilotsWidget(QWidget *parent) :
     view->setSelectionMode(QAbstractItemView::SingleSelection);
     view->setSelectionMode(QAbstractItemView::SingleSelection);
     view->setEditTriggers(QAbstractItemView::NoEditTriggers);
     view->setEditTriggers(QAbstractItemView::NoEditTriggers);
     view->horizontalHeader()->setStretchLastSection(QHeaderView::Stretch);
     view->horizontalHeader()->setStretchLastSection(QHeaderView::Stretch);
-    view->setColumnWidth(0,60);
-    view->setColumnWidth(1,240);
-    view->setColumnWidth(2,180);
+    view->setColumnWidth(0, 60);
+    view->setColumnWidth(1, 240);
+    view->setColumnWidth(2, 180);
     view->verticalHeader()->hide();
     view->verticalHeader()->hide();
     view->setAlternatingRowColors(true);
     view->setAlternatingRowColors(true);
     view->setSortingEnabled(true);
     view->setSortingEnabled(true);
     QSettings settings;
     QSettings settings;
 
 
-    view->sortByColumn(settings.value("userdata/pilSortColumn").toInt(),Qt::AscendingOrder);
+    view->sortByColumn(settings.value("userdata/pilSortColumn").toInt(), Qt::AscendingOrder);
 
 
     view->show();
     view->show();
 
 
     connect(ui->tableView->selectionModel(),
     connect(ui->tableView->selectionModel(),
-    SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
-    SLOT(tableView_selectionChanged(const QItemSelection &, const QItemSelection &)));
+            SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
+            SLOT(tableView_selectionChanged(const QItemSelection &, const QItemSelection &)));
 }
 }
 
 
 pilotsWidget::~pilotsWidget()
 pilotsWidget::~pilotsWidget()
@@ -77,7 +77,7 @@ void pilotsWidget::tableView_selectionChanged(const QItemSelection &index, const
     setSelectedPilot(index.indexes()[0].data().toInt());
     setSelectedPilot(index.indexes()[0].data().toInt());
     DEB("Selected Pilot with ID#: " << selectedPilot);
     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);
     np->setWindowFlag(Qt::Widget);
     ui->stackedWidget->addWidget(np);
     ui->stackedWidget->addWidget(np);
@@ -91,15 +91,15 @@ void pilotsWidget::setSelectedPilot(const qint32 &value)
 
 
 void pilotsWidget::on_newButton_clicked()
 void pilotsWidget::on_newButton_clicked()
 {
 {
-    auto np = new NewPilot(db::createNew,this);
+    auto np = new NewPilot(db::createNew, this);
     np->show();
     np->show();
 }
 }
 
 
 void pilotsWidget::on_deletePushButton_clicked()
 void pilotsWidget::on_deletePushButton_clicked()
 {
 {
-    if(selectedPilot > 0){
+    if (selectedPilot > 0) {
 
 
-        auto pil = new pilot("pilots",selectedPilot);
+        auto pil = new pilot("pilots", selectedPilot);
         pil->remove();
         pil->remove();
 
 
 
 
@@ -108,12 +108,12 @@ void pilotsWidget::on_deletePushButton_clicked()
         model->select();
         model->select();
         ui->tableView->setModel(model);
         ui->tableView->setModel(model);
         connect(ui->tableView->selectionModel(),
         connect(ui->tableView->selectionModel(),
-        SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
-        SLOT(tableView_selectionChanged(const QItemSelection &, const QItemSelection &)));
+                SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
+                SLOT(tableView_selectionChanged(const QItemSelection &, const QItemSelection &)));
 
 
-        ui->stackedWidget->setCurrentWidget(parent()->findChild<QWidget*>("welcomePL"));
+        ui->stackedWidget->setCurrentWidget(parent()->findChild<QWidget *>("welcomePL"));
 
 
-    }else{
+    } else {
         auto mb = new QMessageBox(this);
         auto mb = new QMessageBox(this);
         mb->setText("No Pilot selected.");
         mb->setText("No Pilot selected.");
         mb->show();
         mb->show();

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

@@ -39,13 +39,13 @@ settingsWidget::settingsWidget(QWidget *parent) :
 
 
 
 
     switch (settings.value("main/theme").toInt()) {
     switch (settings.value("main/theme").toInt()) {
-      case 0:
+    case 0:
         ui->systemThemeCheckBox->setChecked(true);
         ui->systemThemeCheckBox->setChecked(true);
         break;
         break;
-      case 1:
+    case 1:
         ui->lightThemeCheckBox->setChecked(true);
         ui->lightThemeCheckBox->setChecked(true);
         break;
         break;
-      case 2:
+    case 2:
         ui->darkThemeCheckBox->setChecked(true);
         ui->darkThemeCheckBox->setChecked(true);
     }
     }
     /*
     /*
@@ -53,7 +53,7 @@ settingsWidget::settingsWidget(QWidget *parent) :
      */
      */
     //QString storedPrefix = db::singleSelect("setting","settings","setting_id","50",sql::exactMatch);
     //QString storedPrefix = db::singleSelect("setting","settings","setting_id","50",sql::exactMatch);
     QString storedPrefix = settings.value("userdata/flightnumberPrefix").toString();
     QString storedPrefix = settings.value("userdata/flightnumberPrefix").toString();
-    if (storedPrefix.length() != 0){
+    if (storedPrefix.length() != 0) {
         ui->flightNumberPrefixLineEdit->setText(storedPrefix);
         ui->flightNumberPrefixLineEdit->setText(storedPrefix);
     }
     }
 
 
@@ -79,24 +79,24 @@ settingsWidget::~settingsWidget()
 void settingsWidget::on_flightNumberPrefixLineEdit_textEdited(const QString &arg1)
 void settingsWidget::on_flightNumberPrefixLineEdit_textEdited(const QString &arg1)
 {
 {
     QSettings settings;
     QSettings settings;
-    settings.setValue("userdata/flightnumberPrefix",arg1);
+    settings.setValue("userdata/flightnumberPrefix", arg1);
 }
 }
 
 
 void settingsWidget::themeGroup_toggled(int id)
 void settingsWidget::themeGroup_toggled(int id)
 {
 {
     QSettings settings;
     QSettings settings;
-    settings.setValue("main/theme",id);
+    settings.setValue("main/theme", id);
 
 
 
 
     QMessageBox::StandardButton reply;
     QMessageBox::StandardButton reply;
-    reply = QMessageBox::question(this, "Changing Themes", "Changing the theme requires restarting the Application.\n\nWould you like to restart now?",
-                                  QMessageBox::Yes|QMessageBox::No);
-    if (reply == QMessageBox::Yes)
-    {
+    reply = QMessageBox::question(this, "Changing Themes",
+                                  "Changing the theme requires restarting the Application.\n\nWould you like to restart now?",
+                                  QMessageBox::Yes | QMessageBox::No);
+    if (reply == QMessageBox::Yes) {
         qApp->quit();
         qApp->quit();
         QProcess::startDetached(qApp->arguments()[0], qApp->arguments());
         QProcess::startDetached(qApp->arguments()[0], qApp->arguments());
 
 
-    }else{
+    } else {
         QMessageBox *info = new QMessageBox(this);
         QMessageBox *info = new QMessageBox(this);
         info->setText("Theme change will take effect the next time you start the application.");
         info->setText("Theme change will take effect the next time you start the application.");
         info->exec();
         info->exec();
@@ -109,35 +109,35 @@ void settingsWidget::on_aboutPushButton_clicked()
     QString SQLITE_VERSION = dbInfo().version;
     QString SQLITE_VERSION = dbInfo().version;
     QString text = QMessageBox::tr(
     QString text = QMessageBox::tr(
 
 
-                "<h3><center>About openPilotLog</center></h3>"
-                "<br>"
-                "(c) 2020 Felix Turowsky"
-                "<br>"
-                "<p>This is a collaboratively developed Free and Open Source Application. "
-                "Visit us <a href=\"https://%1/\">here</a> for more information.</p>"
-
-                "<p>This program is free software: you can redistribute it and/or modify "
-                "it under the terms of the GNU General Public License as published by "
-                "the Free Software Foundation, either version 3 of the License, or "
-                "(at your option) any later version.</p>"
-
-                "<p>This program is distributed in the hope that it will be useful, "
-                "but WITHOUT ANY WARRANTY; without even the implied warranty of "
-                "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the "
-                "GNU General Public License for more details.</p> "
-
-                "<p>You should have received a copy of the GNU General Public License "
-                "along with this program.  If not, "
-                "please click <a href=\"https://www.gnu.org/licenses/\">here</a>.</p>"
-
-                "<br>"
-
-                "<p>This program uses <a href=\"http://%2/\">Qt</a> version %3 and "
-                "<a href=\"https://sqlite.org/about.html/\">SQLite</a> version %4</p>"
-                ).arg(QLatin1String("github.com/fiffty-50/openpilotlog"),
-                      QLatin1String("qt.io"),
-                      QLatin1String(QT_VERSION_STR),
-                      QString(SQLITE_VERSION));
+                       "<h3><center>About openPilotLog</center></h3>"
+                       "<br>"
+                       "(c) 2020 Felix Turowsky"
+                       "<br>"
+                       "<p>This is a collaboratively developed Free and Open Source Application. "
+                       "Visit us <a href=\"https://%1/\">here</a> for more information.</p>"
+
+                       "<p>This program is free software: you can redistribute it and/or modify "
+                       "it under the terms of the GNU General Public License as published by "
+                       "the Free Software Foundation, either version 3 of the License, or "
+                       "(at your option) any later version.</p>"
+
+                       "<p>This program is distributed in the hope that it will be useful, "
+                       "but WITHOUT ANY WARRANTY; without even the implied warranty of "
+                       "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the "
+                       "GNU General Public License for more details.</p> "
+
+                       "<p>You should have received a copy of the GNU General Public License "
+                       "along with this program.  If not, "
+                       "please click <a href=\"https://www.gnu.org/licenses/\">here</a>.</p>"
+
+                       "<br>"
+
+                       "<p>This program uses <a href=\"http://%2/\">Qt</a> version %3 and "
+                       "<a href=\"https://sqlite.org/about.html\">SQLite</a> version %4</p>"
+                   ).arg(QLatin1String("github.com/fiffty-50/openpilotlog"),
+                         QLatin1String("qt.io"),
+                         QLatin1String(QT_VERSION_STR),
+                         QString(SQLITE_VERSION));
     mb->setText(text);
     mb->setText(text);
     mb->open();
     mb->open();
 }
 }
@@ -145,14 +145,14 @@ void settingsWidget::on_aboutPushButton_clicked()
 void settingsWidget::on_acSortComboBox_currentIndexChanged(int index)
 void settingsWidget::on_acSortComboBox_currentIndexChanged(int index)
 {
 {
     QSettings settings;
     QSettings settings;
-    settings.setValue("userdata/acSortColumn",index);
+    settings.setValue("userdata/acSortColumn", index);
 }
 }
 
 
 void settingsWidget::on_acAllowIncompleteComboBox_currentIndexChanged(int index)
 void settingsWidget::on_acAllowIncompleteComboBox_currentIndexChanged(int index)
 {
 {
     QSettings settings;
     QSettings settings;
-    settings.setValue("userdata/acAllowIncomplete",index);
-    if(index){
+    settings.setValue("userdata/acAllowIncomplete", index);
+    if (index) {
         QMessageBox::StandardButton reply;
         QMessageBox::StandardButton reply;
         reply = QMessageBox::question(this, "Warning",
         reply = QMessageBox::question(this, "Warning",
                                       "Warning: Enabling incomplete logging will enable you to add aircraft with incomplete data.\n\n"
                                       "Warning: Enabling incomplete logging will enable you to add aircraft with incomplete data.\n\n"
@@ -161,11 +161,11 @@ void settingsWidget::on_acAllowIncompleteComboBox_currentIndexChanged(int index)
                                       "This will also impact statistics and auto-logging capabilites.\n\n"
                                       "This will also impact statistics and auto-logging capabilites.\n\n"
                                       "It is highly recommended to keep this option off unless you have a specific reason not to.\n\n"
                                       "It is highly recommended to keep this option off unless you have a specific reason not to.\n\n"
                                       "Are you sure you want to proceed?",
                                       "Are you sure you want to proceed?",
-                                      QMessageBox::Yes|QMessageBox::No);
-        if (reply == QMessageBox::Yes){
+                                      QMessageBox::Yes | QMessageBox::No);
+        if (reply == QMessageBox::Yes) {
             QSettings settings;
             QSettings settings;
-            settings.setValue("userdata/acAllowIncomplete",index);
-        }else{
+            settings.setValue("userdata/acAllowIncomplete", index);
+        } else {
             ui->acAllowIncompleteComboBox->setCurrentIndex(0);
             ui->acAllowIncompleteComboBox->setCurrentIndex(0);
         }
         }
     }
     }

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

@@ -11,8 +11,8 @@ totalsWidget::totalsWidget(QWidget *parent) :
     ui->setupUi(this);
     ui->setupUi(this);
     auto data = stat::totals();
     auto data = stat::totals();
     DEB("Filling Totals Line Edits...");
     DEB("Filling Totals Line Edits...");
-    for(const auto& field : data){
-        auto line_edit = parent->findChild<QLineEdit*>(field.first+"LineEdit");
+    for (const auto &field : data) {
+        auto line_edit = parent->findChild<QLineEdit *>(field.first + "LineEdit");
         line_edit->setText(field.second);
         line_edit->setText(field.second);
     }
     }
 }
 }