Browse Source

code formatting

fiffty-50 4 years ago
parent
commit
b3748290db

+ 3 - 4
main.cpp

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

+ 19 - 18
mainwindow.cpp

@@ -27,9 +27,9 @@ MainWindow::MainWindow(QWidget *parent)
 
     // Set up Toolbar
     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);
     }
 
@@ -47,13 +47,13 @@ MainWindow::MainWindow(QWidget *parent)
     auto *spacer = new QWidget();
     spacer->setMinimumWidth(10);
     spacer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
-    ui->toolBar->insertWidget(ui->actionNewFlight,spacer);
+    ui->toolBar->insertWidget(ui->actionNewFlight, spacer);
 
 
     // create and show homeWidget
     auto hw = new homeWidget(this);
     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()
-{/*
-    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()
@@ -124,7 +125,7 @@ void MainWindow::on_actionAircraft_triggered()
 
 void MainWindow::on_actionNewAircraft_triggered()
 {
-    auto nt = new NewTail(QString(), db::createNew,this);
+    auto nt = new NewTail(QString(), db::createNew, this);
     nt->show();
 }
 
@@ -137,6 +138,6 @@ void MainWindow::on_actionPilots_triggered()
 
 void MainWindow::on_actionNewPilot_triggered()
 {
-    auto np = new NewPilot(db::createNew,this);
+    auto np = new NewPilot(db::createNew, this);
     np->show();
 }

+ 3 - 1
mainwindow.h

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

+ 1 - 1
openPilotLog.pro.user

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!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>
  <data>
   <variable>EnvironmentId</variable>

+ 1 - 1
src/classes/aircraft.h

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

+ 91 - 86
src/classes/calc.cpp

@@ -25,17 +25,15 @@
  */
 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
         blocktimeout = blocktimeout.addSecs(blockseconds);
         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
         blocktimeout = blocktimeout.addSecs(blockseconds);
         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)
 {
     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);
-    if (minute.size() < 2) {minute.prepend("0");}
+    if (minute.size() < 2) {
+        minute.prepend("0");
+    }
     QString blocktime = hour + ":" + minute;
     return blocktime;
 };
@@ -165,8 +167,8 @@ double calc::greatCircleDistance(double lat1, double lon1, double lat2, double l
     double deltalat = lat2 - lat1;
 
     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;
 }
 
@@ -186,12 +188,13 @@ double calc::greatCircleDistanceBetweenAirports(QString dept, QString dest)
     }*/
 
     QVector<QString> columns = {"lat", "long"};
-    QVector<QString> deptCoordinates = db::multiSelect(columns,"airports", "icao", dept, db::exactMatch);
-    QVector<QString> destCoordinates = db::multiSelect(columns,"airports", "icao", dest, db::exactMatch);
+    QVector<QString> deptCoordinates = db::multiSelect(columns, "airports", "icao", dept,
+                                                       db::exactMatch);
+    QVector<QString> destCoordinates = db::multiSelect(columns, "airports", "icao", dest,
+                                                       db::exactMatch);
 
-    if(deptCoordinates.isEmpty() || destCoordinates.isEmpty()
-       )
-    {
+    if (deptCoordinates.isEmpty() || destCoordinates.isEmpty()
+       ) {
         qDebug() << "greatCircleDistance - invalid input. aborting.";
         return 0;
     }
@@ -206,7 +209,7 @@ double calc::greatCircleDistanceBetweenAirports(QString dept, QString dest)
     double deltalat = lat2 - lat1;
 
     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));
     return radToNauticalMiles(result);
 }
@@ -221,7 +224,8 @@ double calc::greatCircleDistanceBetweenAirports(QString dept, QString dest)
  * \param tblk Total Blocktime in minutes
  * \return coordinates {lat,lon} along the Great Circle Track
  */
-QVector<QVector<double>> calc::intermediatePointsOnGreatCircle(double lat1, double lon1, 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)
     // 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
     // 0 is departure point, 1 is end point
     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
-        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 lon = atan2(y, x);
 
-        QVector<double> coordinate = {lat,lon};
+        QVector<double> coordinate = {lat, lon};
         coordinates.append(coordinate);
     }
     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 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
-    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)
     double w = 282.9404 + 4.70935e-5 * d; // (longitude of perihelion)
     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)
     // 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
-    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
-    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
     double solarlongitude = v + w;
     // 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;
     //rotate these coordinates to equitorial rectangular coordinates
     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:
-    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
-    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
     double GMST0 = fmod(L + 180, 360.0) / 15;
     double SIDTIME = GMST0 + UTH + lon / 15;
     // Replace RA with hour angle HA
-    double HA = (SIDTIME*15 - RA);
+    double HA = (SIDTIME * 15 - RA);
     // 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.
-    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
-    double elevation = asin(zhor)*(180 / M_PI);
+    double elevation = asin(zhor) * (180 / M_PI);
     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)
 {
     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.";
         return 0;
     }
@@ -351,11 +361,13 @@ int calc::calculateNightTime(QString dept, QString dest, QDateTime departureTime
     qDebug() << "calc::calculateNightTime destLat = " << destLat;
     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;
-    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 ++;
         }
     }
@@ -376,34 +388,27 @@ QString calc::formatTimeInput(QString userinput)
     QTime temptime; //empty time object is invalid by default
 
     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) {
     case completerTarget::pilots:
         query.append("SELECT piclastname||', '||picfirstname FROM pilots");
-        result = db::customQuery(query,1);
+        result = db::customQuery(query, 1);
         break;
     case completerTarget::airports:
         columns.append("icao");
@@ -49,7 +49,7 @@ completionList::completionList(completerTarget::targets type)
         break;
     case completerTarget::aircraft:
         query.append("SELECT make||' '||model||'-'||variant FROM aircraft");
-        result = db::customQuery(query,1);
+        result = db::customQuery(query, 1);
         break;
     }
 

+ 31 - 29
src/classes/stat.cpp

@@ -35,7 +35,7 @@ QString stat::totalTime(yearType yt)
         query = "SELECT SUM(tblk) FROM flights";
         break;
     case stat::calendarYear:
-        start.setDate(QDate::currentDate().year(),1,1);
+        start.setDate(QDate::currentDate().year(), 1, 1);
         startdate = start.toString(Qt::ISODate);
         startdate.append(QLatin1Char('\''));
         startdate.prepend(QLatin1Char('\''));
@@ -47,13 +47,14 @@ QString stat::totalTime(yearType yt)
         startdate.append(QLatin1Char('\''));
         startdate.prepend(QLatin1Char('\''));
         query = "SELECT SUM(tblk) FROM flights WHERE doft >= " + startdate;
-        break;}
+        break;
+    }
 
     QVector<QString> result = db::customQuery(query, 1);
 
-    if(!result.isEmpty()){
+    if (!result.isEmpty()) {
         return result[0];
-    }else{
+    } else {
         return QString();
     }
 }
@@ -78,9 +79,9 @@ QVector<QString> stat::currencyTakeOffLanding(int days)
                     "WHERE doft >= " + startdate;
     QVector<QString> result = db::customQuery(query, 2);
 
-    if(!result.isEmpty()){
+    if (!result.isEmpty()) {
         return result;
-    }else{
+    } else {
         return QVector<QString>();
     }
 
@@ -89,35 +90,36 @@ QVector<QString> stat::currencyTakeOffLanding(int days)
 QVector<QPair<QString, QString>> stat::totals()
 {
     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);
     QVector<QPair<QString, QString>> output;
     QString value;
     q.next();
-    for(const auto& column : columns){
+    for (const auto &column : columns) {
         value = q.value(columns.indexOf(column)).toString();
-        if(!value.isEmpty()){
+        if (!value.isEmpty()) {
             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
 {
     auto validation = QRegularExpressionValidator::validate(txt, pos);
-    if(validation == QValidator::Intermediate) {
+    if (validation == QValidator::Intermediate) {
         return QValidator::Invalid;
     }
     return validation;

+ 3 - 2
src/classes/strictregularexpressionvalidator.h

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

+ 35 - 40
src/database/db.cpp

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

+ 1 - 1
src/database/dbinfo.h

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

+ 49 - 48
src/database/entry.cpp

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

+ 10 - 4
src/database/entry.h

@@ -33,9 +33,13 @@ public:
     entry(QString table, int row);
     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
-    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);
 
@@ -43,11 +47,13 @@ public:
     bool remove();
     bool exists();
 
-
     // Debug functionality
     void print();
     QString debug();
-    operator QString() { return debug(); } //overload for compatibility with qDebug()
+    operator QString()
+    {
+        return debug();    //overload for compatibility with qDebug()
+    }
 
 private:
 

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

@@ -48,10 +48,10 @@ NewPilot::~NewPilot()
 void NewPilot::on_buttonBox_accepted()
 {
     DEB("aseontuh");
-    if(ui->piclastnameLineEdit->text().isEmpty()){
+    if (ui->piclastnameLineEdit->text().isEmpty()) {
         auto mb = new QMessageBox(this);
         mb->setText("Last Name is required.");
-    }else{
+    } else {
         submitForm();
     }
 }
@@ -60,13 +60,13 @@ void NewPilot::formFiller()
 {
     DEB("Filling Form...");
     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();
         key.chop(8);//remove "LineEdit"
         QString value = oldEntry.data.value(key);
-        if(!value.isEmpty()){
+        if (!value.isEmpty()) {
             le->setText(value);
         }
     }
@@ -75,30 +75,31 @@ void NewPilot::formFiller()
 void NewPilot::submitForm()
 {
     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();
         key.chop(8);//remove "LineEdit"
         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
     switch (role) {
-    case db::createNew:{
-        auto newEntry = pilot("pilots",newData);;
+    case db::createNew: {
+        auto newEntry = pilot("pilots", newData);;
         DEB("New Object: ");
         newEntry.commit();
-        break;}
+        break;
+    }
     case db::editExisting:
         oldEntry.setData(newData);
-        DEB("updated entry: "<< oldEntry);
+        DEB("updated entry: " << oldEntry);
         oldEntry.commit();
         break;
     }

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

@@ -66,28 +66,30 @@ void NewTail::formFiller(aircraft entry)
 {
     DEB("Filling Form for a/c" << entry);
     //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();
         name.chop(8);//remove "LineEdit"
         QString value = entry.data.value(name);
-        if(!value.isEmpty()){
+        if (!value.isEmpty()) {
             le->setText(value);
         };
     }
     //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
@@ -99,11 +101,11 @@ void NewTail::formFiller(aircraft entry)
 void NewTail::setupCompleter()
 {
     auto query = QLatin1String("SELECT make||' '||model||'-'||variant, aircraft_id FROM aircraft");
-    auto vector = db::customQuery(query,2);
+    auto vector = db::customQuery(query, 2);
     QMap<QString, int> map;
-    for (int i = 0; i < vector.length()-2 ; i += 2){
-        if(vector[i] != QLatin1String("")){
-            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
@@ -112,7 +114,7 @@ void NewTail::setupCompleter()
     aircraftlist = cl->list;
     idMap = map;
 
-    QCompleter* completer = new QCompleter(aircraftlist,ui->searchLineEdit);
+    QCompleter *completer = new QCompleter(aircraftlist, ui->searchLineEdit);
     completer->setCaseSensitivity(Qt::CaseInsensitive);
     completer->setCompletionMode(QCompleter::PopupCompletion);
     completer->setFilterMode(Qt::MatchContains);
@@ -124,38 +126,38 @@ void NewTail::setupCompleter()
  */
 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);
             recommended_line_edits.removeOne(le);
             le->setStyleSheet("");
-        }else{
+        } else {
             le->setStyleSheet("border: 1px solid red");
             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);
             cb->setStyleSheet("");
-        }else{
+        } else {
             cb->setStyleSheet("background: orange");
             DEB("Not Good: " << cb);
         }
     }
 
-    if(recommended_line_edits.isEmpty() && recommended_combo_boxes.isEmpty()){
+    if (recommended_line_edits.isEmpty() && recommended_combo_boxes.isEmpty()) {
         return true;
-    }else{
+    } else {
         return false;
     }
 }
@@ -163,44 +165,47 @@ bool NewTail::verify()
 void NewTail::submitForm(db::editRole edRole)
 {
     DEB("Creating Database Object...");
-    QMap<QString,QString> newData;
+    QMap<QString, QString> newData;
     //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();
         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
-    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
     switch (edRole) {
-    case db::createNew:{
-        auto newEntry = new aircraft("tails",newData);;
+    case db::createNew: {
+        auto newEntry = new aircraft("tails", newData);;
         newEntry->commit();
-        break;}
+        break;
+    }
     case db::editExisting:
         oldEntry.setData(newData);
         oldEntry.commit();
@@ -212,13 +217,14 @@ void NewTail::submitForm(db::editRole edRole)
 
 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));
         //call autofiller for dialog
-        formFiller(aircraft("aircraft",idMap.value(arg1)));
+        formFiller(aircraft("aircraft", idMap.value(arg1)));
         ui->searchLineEdit->setStyleSheet("border: 1px solid green");
-    }else{
+    } else {
         //for example, editing finished without selecting a result from Qcompleter
         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)
 {
-    if(index != 0){
+    if (index != 0) {
         ui->operationComboBox->setStyleSheet("");
     }
 }
 
 void NewTail::on_ppTypeComboBox_currentIndexChanged(int index)
 {
-    if(index != 0){
+    if (index != 0) {
         ui->ppTypeComboBox->setStyleSheet("");
     }
 }
 
 void NewTail::on_ppNumberComboBox_currentIndexChanged(int index)
 {
-    if(index != 0){
+    if (index != 0) {
         ui->ppNumberComboBox->setStyleSheet("");
     }
 }
 
 void NewTail::on_weightComboBox_currentIndexChanged(int index)
 {
-    if(index != 0){
+    if (index != 0) {
         ui->weightComboBox->setStyleSheet("");
     }
 }
@@ -255,23 +261,23 @@ void NewTail::on_weightComboBox_currentIndexChanged(int index)
 void NewTail::on_buttonBox_accepted()
 {
     DEB("Button Box Accepted.");
-    if(ui->registrationLineEdit->text().isEmpty()){
+    if (ui->registrationLineEdit->text().isEmpty()) {
         auto nope = new QMessageBox(this);
         nope->setText("Registration cannot be empty.");
         nope->show();
-    }else{
-        if(verify()){
+    } else {
+        if (verify()) {
             DEB("Form verified");
             submitForm(role);
             accept();
-        }else{
+        } else {
             QSettings setting;
-            if(!setting.value("userdata/acAllowIncomplete").toInt()){
+            if (!setting.value("userdata/acAllowIncomplete").toInt()) {
                 auto nope = new QMessageBox(this);
                 nope->setText("Some or all fields are empty.\nPlease go back and "
                               "complete.\n\nYou can allow logging incomplete entries on the settings page.");
                 nope->show();
-            }else{
+            } else {
                 QMessageBox::StandardButton reply;
                 reply = QMessageBox::question(this, "Warning",
                                               "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"
                                               "It is highly recommended to fill in all the details.\n\n"
                                               "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);
                     accept();
                 }

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

@@ -50,21 +50,21 @@ aircraftWidget::aircraftWidget(QWidget *parent) :
     view->setSelectionMode(QAbstractItemView::SingleSelection);
     view->setEditTriggers(QAbstractItemView::NoEditTriggers);
     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->setAlternatingRowColors(true);
     view->setSortingEnabled(true);
     QSettings settings;
 
-    view->sortByColumn(settings.value("userdata/acSortColumn").toInt(),Qt::AscendingOrder);
+    view->sortByColumn(settings.value("userdata/acSortColumn").toInt(), Qt::AscendingOrder);
 
     view->show();
 
     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()
@@ -82,7 +82,7 @@ void aircraftWidget::tableView_selectionChanged(const QItemSelection &index, con
     setSelectedAircraft(index.indexes()[0].data().toInt());
     DEB("Selected aircraft with ID#: " << selectedAircraft);
 
-    auto nt = new NewTail(aircraft("tails",selectedAircraft),db::editExisting,this);
+    auto nt = new NewTail(aircraft("tails", selectedAircraft), db::editExisting, this);
     //auto nt = new NewTail(db(db::tails,selectedAircraft),this);
 
     nt->setWindowFlag(Qt::Widget);
@@ -92,9 +92,9 @@ void aircraftWidget::tableView_selectionChanged(const QItemSelection &index, con
 
 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();
 
 
@@ -103,12 +103,12 @@ void aircraftWidget::on_deleteButton_clicked()
         model->select();
         ui->tableView->setModel(model);
         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);
         mb->setText("No aircraft selected.");
         mb->show();
@@ -117,6 +117,6 @@ void aircraftWidget::on_deleteButton_clicked()
 
 void aircraftWidget::on_newButton_clicked()
 {
-    auto nt = new NewTail(QString(), db::createNew,this);
+    auto nt = new NewTail(QString(), db::createNew, this);
     nt->show();
 }

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

@@ -53,8 +53,8 @@ homeWidget::~homeWidget()
 
 void homeWidget::on_pushButton_clicked()
 {
-    auto pl = new pilot("pilots",498);
-    auto np = new NewPilot(*pl,db::editExisting,this);
+    auto pl = new pilot("pilots", 498);
+    auto np = new NewPilot(*pl, db::editExisting, this);
     np->show();
 }
 

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

@@ -41,16 +41,16 @@ logbookWidget::logbookWidget(QWidget *parent) :
     view->setSelectionBehavior(QAbstractItemView::SelectRows);
     view->setSelectionMode(QAbstractItemView::SingleSelection);
     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->verticalHeader()->hide();
     view->setAlternatingRowColors(true);
@@ -62,8 +62,8 @@ logbookWidget::logbookWidget(QWidget *parent) :
     DEB("Time taken for lookup and rendering: " << duration.count() << " microseconds");
 
     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()
@@ -76,7 +76,8 @@ void logbookWidget::setSelectedFlight(const qint32 &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());
     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()
 {
-    if(selectedFlight > 0)
-    {
+    if (selectedFlight > 0) {
         QVector<QString> columns = {
             "doft", "dept", "dest"
         };
-        QVector<QString> details = db::multiSelect(columns,"flights","id",QString::number(selectedFlight),db::exactMatch);
+        QVector<QString> details = db::multiSelect(columns, "flights", "id",
+                                                   QString::number(selectedFlight), db::exactMatch);
         QString detailsstring = "The following flight will be deleted:\n\n";
-        for(const auto& item : details)
-        {
+        for (const auto &item : details) {
             detailsstring.append(item);
             detailsstring.append(QLatin1Char(' '));
         }
@@ -120,11 +120,10 @@ void logbookWidget::on_deleteFlightPushButton_clicked()
 
         QMessageBox::StandardButton reply;
         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);
-            auto en = new flight("flights",selectedFlight);
+            auto en = new flight("flights", selectedFlight);
             en->remove();
 
             QSqlTableModel *ShowAllModel = new QSqlTableModel; //refresh view
@@ -132,11 +131,10 @@ void logbookWidget::on_deleteFlightPushButton_clicked()
             ShowAllModel->select();
             ui->tableView->setModel(ShowAllModel);
             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;
         NoFlight.setText("No flight selected.");
         NoFlight.exec();
@@ -149,7 +147,7 @@ void logbookWidget::on_filterFlightsByDateButton_clicked()
     QString startdate = date.toString("yyyy-MM-dd");
     date = ui->filterDateEdit_2->date();
     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;
     DateFilteredModel ->setTable("Logbook");

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

@@ -50,21 +50,21 @@ pilotsWidget::pilotsWidget(QWidget *parent) :
     view->setSelectionMode(QAbstractItemView::SingleSelection);
     view->setEditTriggers(QAbstractItemView::NoEditTriggers);
     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->setAlternatingRowColors(true);
     view->setSortingEnabled(true);
     QSettings settings;
 
-    view->sortByColumn(settings.value("userdata/pilSortColumn").toInt(),Qt::AscendingOrder);
+    view->sortByColumn(settings.value("userdata/pilSortColumn").toInt(), Qt::AscendingOrder);
 
     view->show();
 
     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()
@@ -77,7 +77,7 @@ void pilotsWidget::tableView_selectionChanged(const QItemSelection &index, const
     setSelectedPilot(index.indexes()[0].data().toInt());
     DEB("Selected Pilot with ID#: " << selectedPilot);
 
-    auto np = new NewPilot(pilot("pilots",selectedPilot), db::editExisting, this);
+    auto np = new NewPilot(pilot("pilots", selectedPilot), db::editExisting, this);
 
     np->setWindowFlag(Qt::Widget);
     ui->stackedWidget->addWidget(np);
@@ -91,15 +91,15 @@ void pilotsWidget::setSelectedPilot(const qint32 &value)
 
 void pilotsWidget::on_newButton_clicked()
 {
-    auto np = new NewPilot(db::createNew,this);
+    auto np = new NewPilot(db::createNew, this);
     np->show();
 }
 
 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();
 
 
@@ -108,12 +108,12 @@ void pilotsWidget::on_deletePushButton_clicked()
         model->select();
         ui->tableView->setModel(model);
         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);
         mb->setText("No Pilot selected.");
         mb->show();

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

@@ -39,13 +39,13 @@ settingsWidget::settingsWidget(QWidget *parent) :
 
 
     switch (settings.value("main/theme").toInt()) {
-      case 0:
+    case 0:
         ui->systemThemeCheckBox->setChecked(true);
         break;
-      case 1:
+    case 1:
         ui->lightThemeCheckBox->setChecked(true);
         break;
-      case 2:
+    case 2:
         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 = settings.value("userdata/flightnumberPrefix").toString();
-    if (storedPrefix.length() != 0){
+    if (storedPrefix.length() != 0) {
         ui->flightNumberPrefixLineEdit->setText(storedPrefix);
     }
 
@@ -79,24 +79,24 @@ settingsWidget::~settingsWidget()
 void settingsWidget::on_flightNumberPrefixLineEdit_textEdited(const QString &arg1)
 {
     QSettings settings;
-    settings.setValue("userdata/flightnumberPrefix",arg1);
+    settings.setValue("userdata/flightnumberPrefix", arg1);
 }
 
 void settingsWidget::themeGroup_toggled(int id)
 {
     QSettings settings;
-    settings.setValue("main/theme",id);
+    settings.setValue("main/theme", id);
 
 
     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();
         QProcess::startDetached(qApp->arguments()[0], qApp->arguments());
 
-    }else{
+    } else {
         QMessageBox *info = new QMessageBox(this);
         info->setText("Theme change will take effect the next time you start the application.");
         info->exec();
@@ -109,35 +109,35 @@ void settingsWidget::on_aboutPushButton_clicked()
     QString SQLITE_VERSION = dbInfo().version;
     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->open();
 }
@@ -145,14 +145,14 @@ void settingsWidget::on_aboutPushButton_clicked()
 void settingsWidget::on_acSortComboBox_currentIndexChanged(int index)
 {
     QSettings settings;
-    settings.setValue("userdata/acSortColumn",index);
+    settings.setValue("userdata/acSortColumn", index);
 }
 
 void settingsWidget::on_acAllowIncompleteComboBox_currentIndexChanged(int index)
 {
     QSettings settings;
-    settings.setValue("userdata/acAllowIncomplete",index);
-    if(index){
+    settings.setValue("userdata/acAllowIncomplete", index);
+    if (index) {
         QMessageBox::StandardButton reply;
         reply = QMessageBox::question(this, "Warning",
                                       "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"
                                       "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?",
-                                      QMessageBox::Yes|QMessageBox::No);
-        if (reply == QMessageBox::Yes){
+                                      QMessageBox::Yes | QMessageBox::No);
+        if (reply == QMessageBox::Yes) {
             QSettings settings;
-            settings.setValue("userdata/acAllowIncomplete",index);
-        }else{
+            settings.setValue("userdata/acAllowIncomplete", index);
+        } else {
             ui->acAllowIncompleteComboBox->setCurrentIndex(0);
         }
     }

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

@@ -11,8 +11,8 @@ totalsWidget::totalsWidget(QWidget *parent) :
     ui->setupUi(this);
     auto data = stat::totals();
     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);
     }
 }