Browse Source

Cleanup and formatting

fiffty-50 4 years ago
parent
commit
b628041840

+ 3 - 6
openPilotLog.pro

@@ -28,8 +28,7 @@ SOURCES += \
     src/gui/dialogues/newtail.cpp \
     src/gui/widgets/homewidget.cpp \
     src/gui/widgets/logbookwidget.cpp \
-    src/gui/widgets/settingswidget.cpp \
-    src/gui/widgets/showaircraftlist.cpp
+    src/gui/widgets/settingswidget.cpp
 
 HEADERS += \
     mainwindow.h \
@@ -43,16 +42,14 @@ HEADERS += \
     src/gui/dialogues/newtail.h \
     src/gui/widgets/homewidget.h \
     src/gui/widgets/logbookwidget.h \
-    src/gui/widgets/settingswidget.h \
-    src/gui/widgets/showaircraftlist.h
+    src/gui/widgets/settingswidget.h
 
 FORMS += \
     mainwindow.ui \
     src/gui/dialogues/newtail.ui \
     src/gui/widgets/homewidget.ui \
     src/gui/widgets/logbookwidget.ui \
-    src/gui/widgets/settingswidget.ui \
-    src/gui/widgets/showaircraftlist.ui
+    src/gui/widgets/settingswidget.ui
 
 # Default rules for deployment.
 qnx: target.path = /tmp/$${TARGET}/bin

+ 5 - 1
src/classes/aircraft.cpp

@@ -17,6 +17,10 @@
  */
 #include "aircraft.h"
 
+// Debug Makro
+#define DEB(expr) \
+    qDebug() << "aircraft ::" << __func__ << "\t" << expr
+
 aircraft::aircraft()
 {
 
@@ -33,7 +37,7 @@ aircraft aircraft::fromTails(int tail_id)
     };
     auto tail = db::multiSelect(columns,"tails","tail_id",QString::number(tail_id),sql::exactMatch);
 
-    qDebug() << tail;
+    //DEB(tail);
     aircraft acft;
 
     acft.id = tail[0];

+ 1 - 6
src/database/db.cpp

@@ -86,7 +86,6 @@ bool db::exists(QString column, QString table, QString checkColumn, QString valu
         break;
     }
 
-    DEB("Executing SQL...");
     DEB(statement);
 
     QSqlQuery q(statement);
@@ -136,7 +135,6 @@ QString db::singleSelect(QString column, QString table, QString checkColumn, QSt
         break;
     }
 
-    DEB("Executing SQL...");
     DEB(statement);
 
     QSqlQuery q(statement);
@@ -189,7 +187,6 @@ QVector<QString> db::multiSelect(QVector<QString> columns, QString table, QStrin
         break;
     }
 
-    DEB("Executing SQL...");
     DEB(statement);
 
     QSqlQuery q(statement);
@@ -232,7 +229,6 @@ QVector<QString> db::multiSelect(QVector<QString> columns, QString table)
     }
     statement.append(" FROM " + table);
 
-    DEB("Executing SQL...");
     DEB(statement);
 
     QSqlQuery q(statement);
@@ -284,7 +280,6 @@ bool db::singleUpdate(QString table, QString column, QString value, QString chec
         break;
     }
 
-    DEB("Executing SQL...");
     DEB(statement);
 
     QSqlQuery q(statement);
@@ -328,7 +323,6 @@ bool db::deleteRow(QString table, QString column, QString value, sql::matchType
         break;
     }
 
-    DEB("Executing SQL...");
     DEB(statement);
 
     QSqlQuery q(statement);
@@ -355,6 +349,7 @@ bool db::deleteRow(QString table, QString column, QString value, sql::matchType
 QVector<QString> db::customQuery(QString query, int returnValues)
 {
     QSqlQuery q(query);
+    DEB(query);
     q.exec();
 
     if(!q.first()){

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

@@ -18,6 +18,11 @@
 #include "homewidget.h"
 #include "ui_homewidget.h"
 
+// Debug Makro
+#define DEB(expr) \
+    qDebug() << "homeWidget ::" << __func__ << "\t" << expr
+
+
 homeWidget::homeWidget(QWidget *parent) :
     QWidget(parent),
     ui(new Ui::homeWidget)
@@ -30,7 +35,13 @@ homeWidget::homeWidget(QWidget *parent) :
                 calc::minutes_to_string(
                 stat::totalTime(stat::rollingYear)));
     QVector<QString> toldg = stat::currencyTakeOffLanding(90);
-    QString ToLdg = toldg[0] + " / " + toldg[1];
+    QString ToLdg;// = toldg[0] + " / " + toldg[1];
+    for(const auto& item : toldg)
+    {
+        ToLdg += item;
+        if(toldg.indexOf(item) != toldg.length()-1) {ToLdg += QLatin1String(" / ");}
+    }
+
     ui->ToLdgDisplay->setText(ToLdg);
 }
 
@@ -44,5 +55,5 @@ void homeWidget::on_pushButton_clicked()
     //auto nt = new NewTail(this);
     //nt->show();
     auto ac = aircraft::fromTails(1);
-    qDebug() << ac;
+    DEB(ac);
 }

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

@@ -18,6 +18,10 @@
 #include "logbookwidget.h"
 #include "ui_logbookwidget.h"
 
+// Debug Makro
+#define DEB(expr) \
+    qDebug() << "logbookWidget ::" << __func__ << "\t" << expr
+
 logbookWidget::logbookWidget(QWidget *parent) :
     QWidget(parent),
     ui(new Ui::logbookWidget)
@@ -54,7 +58,7 @@ logbookWidget::logbookWidget(QWidget *parent) :
 
     auto stop = std::chrono::high_resolution_clock::now();
     auto duration = std::chrono::duration_cast<std::chrono::microseconds>(stop - start);
-    qDebug() << "logbookWidget: Time taken for lookup and rendering: " << duration.count() << " microseconds";
+    DEB("Time taken for lookup and rendering: " << duration.count() << " microseconds");
 
     connect(ui->tableView->selectionModel(),
     SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
@@ -74,7 +78,7 @@ void logbookWidget::setSelectedFlight(const qint32 &value)
 void logbookWidget::tableView_selectionChanged(const QItemSelection &index, const QItemSelection &)// TO DO
 {
     setSelectedFlight(index.indexes()[0].data().toInt());
-    qDebug() << "New selected Flight with ID#(selectionChanged): " << selectedFlight;
+    DEB("Selected flight with ID#: " << selectedFlight);
 }
 
 
@@ -118,7 +122,7 @@ void logbookWidget::on_deleteFlightPushButton_clicked()
                                       QMessageBox::Yes|QMessageBox::No);
         if (reply == QMessageBox::Yes)
         {
-            qDebug() << "Deleting Flight with ID# " << selectedFlight;
+            DEB("Deleting flight with ID# " << selectedFlight);
             db::deleteRow("flights","id",QString::number(selectedFlight),sql::exactMatch);
 
             QSqlTableModel *ShowAllModel = new QSqlTableModel; //refresh view

+ 0 - 5
src/gui/widgets/settingswidget.cpp

@@ -20,8 +20,6 @@
 
 
 
-
-
 settingsWidget::settingsWidget(QWidget *parent) :
     QWidget(parent),
     ui(new Ui::settingsWidget)
@@ -41,15 +39,12 @@ settingsWidget::settingsWidget(QWidget *parent) :
 
     switch (settings.value("main/theme").toInt()) {
       case 0:
-        qDebug() << "System Theme";
         ui->systemThemeCheckBox->setChecked(true);
         break;
       case 1:
-        qDebug() << "Light Theme";
         ui->lightThemeCheckBox->setChecked(true);
         break;
       case 2:
-        qDebug() << "Dark Theme";
         ui->darkThemeCheckBox->setChecked(true);
     }
     /*

+ 0 - 52
src/gui/widgets/showaircraftlist.cpp

@@ -1,52 +0,0 @@
-/*
- *openPilot Log - A FOSS Pilot Logbook Application
- *Copyright (C) 2020  Felix Turowsky
- *
- *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.
- *
- *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.
- *
- *You should have received a copy of the GNU General Public License
- *along with this program.  If not, see <https://www.gnu.org/licenses/>.
- */
-#include "showaircraftlist.h"
-#include "ui_showaircraftlist.h"
-
-
-ShowAircraftList::ShowAircraftList(QWidget *parent) :
-    QDialog(parent),
-    ui(new Ui::ShowAircraftList)
-{
-    ui->setupUi(this);
-
-    QSqlTableModel *model = new QSqlTableModel;
-    model->setTable("AircraftListView");
-    model->select();
-
-
-    QTableView *view = ui->tableView;
-    view->setModel(model);
-    view->setSelectionBehavior(QAbstractItemView::SelectRows);
-    view->setSelectionMode(QAbstractItemView::SingleSelection);
-    view->setEditTriggers(QAbstractItemView::NoEditTriggers);
-    view->verticalHeader()->hide();
-    view->setAlternatingRowColors(true);
-    //view->hideColumn(0); // don't show the ID
-    view->show();
-}
-
-ShowAircraftList::~ShowAircraftList()
-{
-    delete ui;
-}
-
-void ShowAircraftList::on_closeButton_clicked()
-{
-    QDialog::close();
-}

+ 0 - 47
src/gui/widgets/showaircraftlist.h

@@ -1,47 +0,0 @@
-/*
- *openPilot Log - A FOSS Pilot Logbook Application
- *Copyright (C) 2020  Felix Turowsky
- *
- *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.
- *
- *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.
- *
- *You should have received a copy of the GNU General Public License
- *along with this program.  If not, see <https://www.gnu.org/licenses/>.
- */
-#ifndef SHOWAIRCRAFTLIST_H
-#define SHOWAIRCRAFTLIST_H
-
-#include <QDialog>
-#include <QStringListModel>
-#include <QDebug>
-#include <QMessageBox>
-#include <QSqlQueryModel>
-#include <QSqlTableModel>
-
-namespace Ui {
-class ShowAircraftList;
-}
-
-class ShowAircraftList : public QDialog
-{
-    Q_OBJECT
-
-public:
-    explicit ShowAircraftList(QWidget *parent = nullptr);
-    ~ShowAircraftList();
-
-private slots:
-    void on_closeButton_clicked();
-
-private:
-    Ui::ShowAircraftList *ui;
-};
-
-#endif // SHOWAIRCRAFTLIST_H

+ 0 - 31
src/gui/widgets/showaircraftlist.ui

@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>ShowAircraftList</class>
- <widget class="QDialog" name="ShowAircraftList">
-  <property name="geometry">
-   <rect>
-    <x>0</x>
-    <y>0</y>
-    <width>343</width>
-    <height>387</height>
-   </rect>
-  </property>
-  <property name="windowTitle">
-   <string>Dialog</string>
-  </property>
-  <layout class="QGridLayout" name="gridLayout">
-   <item row="0" column="0">
-    <widget class="QTableView" name="tableView"/>
-   </item>
-   <item row="1" column="0">
-    <widget class="QPushButton" name="closeButton">
-     <property name="text">
-      <string>Close</string>
-     </property>
-    </widget>
-   </item>
-  </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>