fiffty-50 пре 4 година
родитељ
комит
ffc1e74521

BIN
assets/database/logbook.db


+ 6 - 0
mainwindow.cpp

@@ -46,6 +46,12 @@ MainWindow::MainWindow(QWidget *parent)
     ui->stackedWidget->addWidget(hw);
     ui->stackedWidget->setCurrentWidget(hw);
 
+    // currently working on aircraftWidget
+
+    auto aw = new aircraftWidget(this);
+    ui->stackedWidget->addWidget(aw);
+    ui->stackedWidget->setCurrentWidget(aw);
+
 }
 
 MainWindow::~MainWindow()

+ 1 - 0
mainwindow.h

@@ -30,6 +30,7 @@
 #include "src/gui/widgets/homewidget.h"
 #include "src/gui/widgets/settingswidget.h"
 #include "src/gui/widgets/logbookwidget.h"
+#include "src/gui/widgets/aircraftwidget.h"
 
 QT_BEGIN_NAMESPACE
 namespace Ui { class MainWindow; }

+ 5 - 0
openPilotLog.pro

@@ -25,7 +25,9 @@ SOURCES += \
     src/classes/stat.cpp \
     src/classes/strictregularexpressionvalidator.cpp \
     src/database/db.cpp \
+    src/database/dbinfo.cpp \
     src/gui/dialogues/newtail.cpp \
+    src/gui/widgets/aircraftwidget.cpp \
     src/gui/widgets/homewidget.cpp \
     src/gui/widgets/logbookwidget.cpp \
     src/gui/widgets/settingswidget.cpp
@@ -39,7 +41,9 @@ HEADERS += \
     src/classes/stat.h \
     src/classes/strictregularexpressionvalidator.h \
     src/database/db.h \
+    src/database/dbinfo.h \
     src/gui/dialogues/newtail.h \
+    src/gui/widgets/aircraftwidget.h \
     src/gui/widgets/homewidget.h \
     src/gui/widgets/logbookwidget.h \
     src/gui/widgets/settingswidget.h
@@ -47,6 +51,7 @@ HEADERS += \
 FORMS += \
     mainwindow.ui \
     src/gui/dialogues/newtail.ui \
+    src/gui/widgets/aircraftwidget.ui \
     src/gui/widgets/homewidget.ui \
     src/gui/widgets/logbookwidget.ui \
     src/gui/widgets/settingswidget.ui

+ 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-10-28T18:21:35. -->
+<!-- Written by QtCreator 4.11.0, 2020-10-31T11:04:51. -->
 <qtcreator>
  <data>
   <variable>EnvironmentId</variable>

+ 12 - 9
src/classes/aircraft.cpp

@@ -31,39 +31,39 @@ aircraft::aircraft()
  * \param database_id primary key in database
  * \param db either database::tails or database::acft
  */
-aircraft::aircraft(int database_id, aircraft::database db)
+aircraft::aircraft(int database_id, aircraft::database table)
 {
     QVector<QString> columns = {
         "tail_id", "registration", "company",
         "make", "model", "variant",
         "singlepilot", "multipilot", "singleengine", "multiengine",
         "unpowered", "piston", "turboprop",
-        "jet", "light", "medium", "heavy"
+        "jet", "light", "medium", "heavy", "super"
     };
     QString checkColumn;
-    QString table;
+    QString tableName;
 
-    switch (db) {
+    switch (table) {
     case database::tail:
         //DEB("tails:" << columns);
-        table.append("tails");
+        tableName.append("tails");
         checkColumn.append("tail_id");
         break;
     case database::acft:
         columns.replace(0,"aircraft_id");
         columns.remove(1,2);
         //DEB("acft:" << columns;)
-        table.append("aircraft");
+        tableName.append("aircraft");
         checkColumn.append("aircraft_id");
         break;
     }
 
-    auto vector = db::multiSelect(columns,table,checkColumn,QString::number(database_id),sql::exactMatch);
+    auto vector = db::multiSelect(columns,tableName,checkColumn,QString::number(database_id),sql::exactMatch);
 
     if(vector.length() < 2){
         id = "invalid";
     }else{
-        switch (db) {
+        switch (table) {
         case database::tail:
             id = vector[0];
             registration = vector[1];
@@ -83,6 +83,7 @@ aircraft::aircraft(int database_id, aircraft::database db)
             light = vector[14].toInt();
             medium = vector[15].toInt();
             heavy = vector[16].toInt();
+            super = vector[17].toInt();
             break;
         case database::acft:
             id = vector[0];
@@ -101,6 +102,7 @@ aircraft::aircraft(int database_id, aircraft::database db)
             light = vector[12].toInt();
             medium = vector[13].toInt();
             heavy = vector[14].toInt();
+            super = vector[15].toInt();
             break;
         }
     }
@@ -122,7 +124,8 @@ void aircraft::print()
          << "SE:\t" << singleengine << "\tME:\t" << multiengine << "\n";
     cout << "UNP:\t\t" << unpowered << "\tPIS:\t" << piston << "\t"
          << "TPR:\t" << turboprop << "\tJET:\t" << jet << "\n";
-    cout << "Light:\t" << light << "\tMedium:\t" << medium << "\tHeavy:\t" << heavy << "\n";
+    cout << "Light:\t" << light << "\tMedium:\t" << medium;
+    cout << "Heavy:\t" << heavy << "\tSuper:\t" << super << "\n";
 
 }
 

+ 2 - 1
src/classes/aircraft.h

@@ -31,7 +31,7 @@ public:
     enum database {tail, acft};
 
     aircraft();
-    aircraft(int database_id, database);
+    aircraft(int database_id, database table);
     aircraft(QString registration);
 
     QString id;
@@ -51,6 +51,7 @@ public:
     bool light          = false;
     bool medium         = false;
     bool heavy          = false;
+    bool super          = false;
 
     // Functions
     static QVector<QString> toVector(aircraft);

+ 122 - 10
src/database/db.cpp

@@ -16,11 +16,47 @@
  *along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 #include "db.h"
+#include "dbinfo.h"
 
 // Debug Makro
 #define DEB(expr) \
     qDebug() << "db ::" << __func__ << "\t" << expr
 
+db::db(sql::tableName tn, int row_ID)
+{
+    switch (tn) {
+    case sql::flights:
+        table = "flights";
+        break;
+    case sql::pilots:
+        table = "pilots";
+        break;
+    case sql::aircraft:
+        table = "aircraft";
+        break;
+    case sql::tails:
+        table = "tails";
+        break;
+    case sql::airports:
+        table = "airports";
+        break;
+    }
+    row_id = row_ID;
+
+
+    QString statement = "SELECT COUNT(*) FROM " + table + " WHERE _rowid_="+QString::number(row_id);
+    QSqlQuery q(statement);
+    q.exec();
+    q.next();
+    int rows = q.value(0).toInt();
+    if(rows==0){
+        DEB("No entry found for row id: " << row_ID );
+    }else{
+        DEB("Retreiving data for row id: " << row_id);
+        isValid = retreiveData();
+    }
+}
+
 /*!
  * \brief db::connect connects to the database via the default connection.
  * Can then be accessed globally with QSqlDatabase::database("qt_sql_default_connection")
@@ -47,19 +83,30 @@ void db::connect()
 }
 
 /*!
- * \brief db::sqliteversion queries database version.
+ * \brief db::retreiveData retreives data from the database.
+ * \return
  */
-QString db::sqliteversion()
+bool db::retreiveData()
 {
-    QSqlQuery version;
-    version.prepare("SELECT sqlite_version()");
-    version.exec();
-    QString result;
+    const auto info = dbInfo();
 
-    while (version.next()) {
-        result.append(version.value(0).toString());
+    QString statement = "SELECT * FROM " + table + " WHERE _rowid_="+QString::number(row_id);
+    DEB("Executing SQL...");
+    DEB(statement);
+
+    QSqlQuery q(statement);
+    q.exec();
+    q.next();
+    for(int i=0; i < info.format.value(table).length(); i++){
+        data.insert(info.format.value(table)[i],q.value(i).toString());
     }
-    return result;
+
+
+    QString error = q.lastError().text();
+    if(error.length() > 2){
+        DEB("Error: " << q.lastError().text());
+        return false;
+    }else{return true;}
 }
 
 
@@ -373,7 +420,7 @@ QVector<QString> db::customQuery(QString query, int returnValues)
 /*!
  * \brief db::getColumnNames Looks up column names of a given table
  * \param table name of the table in the database
- */
+
 QVector<QString> db::getColumnNames(QString table)
 {
     QSqlDatabase db = QSqlDatabase::database("qt_sql_default_connection");
@@ -384,4 +431,69 @@ QVector<QString> db::getColumnNames(QString table)
         columnNames << fields.field(i).name();
     }
     return columnNames;
+}*/
+
+/*!
+ * \brief db::update updates the database with the values contained in the object.
+ * \return True on Success
+ */
+bool db::update()
+{
+    //check prerequisites
+    if(row_id == 0){
+        DEB("Invalid Row ID: " << row_id);
+        return false;
+    }
+    if(data.isEmpty()){
+        DEB("Object Contains no data. Aborting.");
+        return false;
+    }
+    //create query
+    QString statement = "UPDATE " + table + " SET ";
+
+    QMap<QString,QString>::const_iterator i;
+    for (i = data.constBegin(); i != data.constEnd(); ++i){
+        if(i.value()!=QString()){
+            statement += i.key()+QLatin1String("='")+i.value()+QLatin1String("', ");
+        }else{DEB(i.key() << "is empty. skipping.");}
+    }
+    statement.chop(2); // Remove last comma
+    statement.append(QLatin1String(" WHERE _rowid_=")+QString::number(row_id));
+
+    //execute query
+    QSqlQuery q(statement);
+    DEB(statement);
+    q.exec();
+    //check result. Upon success, error should be " "
+    QString error = q.lastError().text();
+    if(error.length() < 2){
+        return true;
+    }else{
+        DEB("Query Error: " << q.lastError().text());
+        return false;
+    }
+}
+
+
+//Debug
+void db::print()
+{
+    QString v = "Object status:\t\033[38;2;0;255;0;48;2;0;0;0m VALID \033[0m\n";
+    QString nv = "Object status:\t\033[38;2;255;0;0;48;2;0;0;0m INVALID \033[0m\n";
+    QTextStream cout(stdout, QIODevice::WriteOnly);
+
+    cout << "=========Database Object=========\n";
+    if(isValid){cout << v;}else{cout << nv;}
+    cout << "Record from table: " << table << ", row: " << row_id << "\n";
+    cout << "=================================\n";
+    QMap<QString,QString>::const_iterator i;
+    for (i = data.constBegin(); i != data.constEnd(); ++i){
+        cout << i.key() << ": " << i.value() << "\n";
+    }
+}
+
+QString db::debug()
+{
+    print();
+    return QString();
 }

+ 28 - 4
src/database/db.h

@@ -28,10 +28,11 @@
 #include <QDir>
 #include <QDebug>
 
+
 class sql
 {
 public:
-    enum tableName {flights, pilots, settings };
+    enum tableName {flights, pilots, tails, aircraft, airports };
     enum queryType {select, update };
     enum matchType {exactMatch, partialMatch};
 };
@@ -39,14 +40,32 @@ public:
 
 class db
 {
+private:
+    QString table = QString();
+
+    int row_id = 0;
+
+    bool retreiveData();
+
+    QMap<QString, QString> data;
+
 public:
 
-    static void connect();
+    db(sql::tableName, int row_ID);
 
-    static QString sqliteversion();
+    bool isValid = false;
 
-    static QVector<QString> getColumnNames(QString table);
+    void setData(const QMap<QString, QString> &value);
 
+    QMap<QString, QString> getData() const;
+
+    //Functions
+
+    bool update();
+
+    static void connect();
+
+    static QVector<QString> getColumnNames(QString table);
 
     static bool exists(QString column, QString table, QString checkColumn, QString value, sql::matchType match);
 
@@ -62,6 +81,11 @@ public:
 
     static QVector<QString> customQuery(QString query, int returnValues);
 
+    // Debug functionality
+    void print();
+    QString debug();
+    operator QString() { return debug(); } //overload for compatibility with qDebug()
+
 };
 
 #endif // DB_H

+ 58 - 0
src/database/dbinfo.cpp

@@ -0,0 +1,58 @@
+/*
+ *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 "dbinfo.h"
+// Debug Makro
+#define DEB(expr) \
+    qDebug() << "dbInfo ::" << __func__ << "\t" << expr
+dbInfo::dbInfo()
+{
+    QSqlDatabase db = QSqlDatabase::database("qt_sql_default_connection");
+    tables = db.tables().toVector();
+    getColumnNames();
+    sqliteversion();
+}
+
+/*!
+ * \brief dbInfo::getColumnNames Looks up column names for all tables
+ * in the database.
+ */
+void dbInfo::getColumnNames()
+{
+    QSqlDatabase db = QSqlDatabase::database("qt_sql_default_connection");
+    QVector<QString> columnNames;
+    for(const auto& table : tables){
+        columnNames.clear();
+        QSqlRecord fields = db.record(table);
+        for(int i = 0; i < fields.count(); i++){
+            columnNames << fields.field(i).name();
+            format.insert(table,columnNames);
+        }
+    }
+}
+
+/*!
+ * \brief db::sqliteversion queries database version.
+ */
+void dbInfo::sqliteversion()
+{
+    QSqlQuery q;
+    q.prepare("SELECT sqlite_version()");
+    q.exec();
+    q.next();
+    version = q.value(0).toString();
+}

+ 41 - 0
src/database/dbinfo.h

@@ -0,0 +1,41 @@
+/*
+ *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 DBINFO_H
+#define DBINFO_H
+
+#include <QCoreApplication>
+#include <QDebug>
+#include "db.h"
+
+class dbInfo
+{
+public:
+    dbInfo();
+
+    QString version = QString();
+
+    QMap<QString,QVector<QString>> format;
+
+    QVector<QString> tables;
+
+    void getColumnNames();
+
+    void sqliteversion();
+};
+
+#endif // DBINFO_H

+ 3 - 0
src/gui/dialogues/newtail.cpp

@@ -39,6 +39,7 @@ NewTail::NewTail(QString newreg, QWidget *parent) :
     ui(new Ui::NewTail)
 {
     ui->setupUi(this);
+    ui->editLabel->hide();
     ui->registrationLineEdit->setText(newreg);
 
     //creating a QMap<id,searchstring>
@@ -196,6 +197,8 @@ void NewTail::formFiller(aircraft ac)
         ui->weightComboBox->setCurrentIndex(2);
     }else if(ac.heavy){
         ui->weightComboBox->setCurrentIndex(3);
+    }else if (ac.super) {
+        ui->weightComboBox->setCurrentIndex(4);
     }
 }
 

+ 131 - 116
src/gui/dialogues/newtail.ui

@@ -14,7 +14,14 @@
    <string>Add New Aircraft</string>
   </property>
   <layout class="QGridLayout" name="gridLayout">
-   <item row="2" column="1">
+   <item row="3" column="0">
+    <widget class="QLabel" name="registrationLabel">
+     <property name="text">
+      <string>Registration</string>
+     </property>
+    </widget>
+   </item>
+   <item row="3" column="1">
     <widget class="QLineEdit" name="registrationLineEdit">
      <property name="maxLength">
       <number>20</number>
@@ -24,38 +31,70 @@
      </property>
     </widget>
    </item>
-   <item row="5" column="0">
-    <widget class="QLabel" name="modelLabel">
+   <item row="4" column="0">
+    <widget class="QLabel" name="companyLabel">
      <property name="text">
-      <string>Model</string>
+      <string>Company</string>
      </property>
     </widget>
    </item>
-   <item row="4" column="1">
-    <widget class="QLineEdit" name="makeLineEdit">
+   <item row="0" column="1">
+    <widget class="QLineEdit" name="searchLineEdit">
      <property name="maxLength">
       <number>20</number>
      </property>
      <property name="placeholderText">
-      <string>e.g. Boeing</string>
+      <string>start typing to search for aircraft types</string>
      </property>
     </widget>
    </item>
    <item row="8" column="0">
+    <widget class="QLabel" name="operationLabel">
+     <property name="text">
+      <string>Operation</string>
+     </property>
+    </widget>
+   </item>
+   <item row="2" column="0" colspan="2">
+    <widget class="Line" name="line">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+    </widget>
+   </item>
+   <item row="7" column="1">
+    <widget class="QLineEdit" name="variantLineEdit">
+     <property name="maxLength">
+      <number>20</number>
+     </property>
+     <property name="placeholderText">
+      <string>e.g. 800</string>
+     </property>
+    </widget>
+   </item>
+   <item row="9" column="0">
     <widget class="QLabel" name="powerPlantLabel">
      <property name="text">
       <string>Power Plant</string>
      </property>
     </widget>
    </item>
-   <item row="7" column="1">
-    <widget class="QComboBox" name="operationComboBox">
-     <property name="editable">
-      <bool>false</bool>
+   <item row="11" column="0">
+    <widget class="QLabel" name="weightLabel">
+     <property name="text">
+      <string>Weight Class</string>
      </property>
-     <property name="currentText">
-      <string>&lt;Select&gt;</string>
+    </widget>
+   </item>
+   <item row="7" column="0">
+    <widget class="QLabel" name="variantLabel">
+     <property name="text">
+      <string>Variant</string>
      </property>
+    </widget>
+   </item>
+   <item row="11" column="1">
+    <widget class="QComboBox" name="weightComboBox">
      <item>
       <property name="text">
        <string>&lt;Select&gt;</string>
@@ -63,18 +102,38 @@
      </item>
      <item>
       <property name="text">
-       <string>Single Pilot</string>
+       <string>Light</string>
       </property>
      </item>
      <item>
       <property name="text">
-       <string>Multi Pilot</string>
+       <string>Medium</string>
+      </property>
+     </item>
+     <item>
+      <property name="text">
+       <string>Heavy</string>
+      </property>
+     </item>
+     <item>
+      <property name="text">
+       <string>Super</string>
       </property>
      </item>
     </widget>
    </item>
+   <item row="5" column="1">
+    <widget class="QLineEdit" name="makeLineEdit">
+     <property name="maxLength">
+      <number>20</number>
+     </property>
+     <property name="placeholderText">
+      <string>e.g. Boeing</string>
+     </property>
+    </widget>
+   </item>
    <item row="9" column="1">
-    <widget class="QComboBox" name="ppNumberComboBox">
+    <widget class="QComboBox" name="ppTypeComboBox">
      <property name="currentText">
       <string>&lt;Select&gt;</string>
      </property>
@@ -85,17 +144,27 @@
      </item>
      <item>
       <property name="text">
-       <string>Single Engine</string>
+       <string>Unpowered</string>
       </property>
      </item>
      <item>
       <property name="text">
-       <string>Multi Engine</string>
+       <string>Piston</string>
+      </property>
+     </item>
+     <item>
+      <property name="text">
+       <string>Turboprop</string>
+      </property>
+     </item>
+     <item>
+      <property name="text">
+       <string>Jet</string>
       </property>
      </item>
     </widget>
    </item>
-   <item row="3" column="1">
+   <item row="4" column="1">
     <widget class="QLineEdit" name="companyLineEdit">
      <property name="maxLength">
       <number>20</number>
@@ -105,69 +174,7 @@
      </property>
     </widget>
    </item>
-   <item row="6" column="0">
-    <widget class="QLabel" name="variantLabel">
-     <property name="text">
-      <string>Variant</string>
-     </property>
-    </widget>
-   </item>
-   <item row="5" column="1">
-    <widget class="QLineEdit" name="modelLineEdit">
-     <property name="maxLength">
-      <number>20</number>
-     </property>
-     <property name="placeholderText">
-      <string>e.g. 737</string>
-     </property>
-    </widget>
-   </item>
-   <item row="0" column="0">
-    <widget class="QLabel" name="searchLabel">
-     <property name="text">
-      <string>Search</string>
-     </property>
-    </widget>
-   </item>
-   <item row="7" column="0">
-    <widget class="QLabel" name="operationLabel">
-     <property name="text">
-      <string>Operation</string>
-     </property>
-    </widget>
-   </item>
-   <item row="0" column="1">
-    <widget class="QLineEdit" name="searchLineEdit">
-     <property name="maxLength">
-      <number>20</number>
-     </property>
-     <property name="placeholderText">
-      <string>start typing to search for aircraft types</string>
-     </property>
-    </widget>
-   </item>
-   <item row="4" column="0">
-    <widget class="QLabel" name="makeLabel">
-     <property name="text">
-      <string>Make</string>
-     </property>
-    </widget>
-   </item>
-   <item row="2" column="0">
-    <widget class="QLabel" name="registrationLabel">
-     <property name="text">
-      <string>Registration</string>
-     </property>
-    </widget>
-   </item>
-   <item row="1" column="0" colspan="2">
-    <widget class="Line" name="line">
-     <property name="orientation">
-      <enum>Qt::Horizontal</enum>
-     </property>
-    </widget>
-   </item>
-   <item row="11" column="1">
+   <item row="12" column="1">
     <widget class="QDialogButtonBox" name="buttonBox">
      <property name="orientation">
       <enum>Qt::Horizontal</enum>
@@ -178,7 +185,10 @@
     </widget>
    </item>
    <item row="8" column="1">
-    <widget class="QComboBox" name="ppTypeComboBox">
+    <widget class="QComboBox" name="operationComboBox">
+     <property name="editable">
+      <bool>false</bool>
+     </property>
      <property name="currentText">
       <string>&lt;Select&gt;</string>
      </property>
@@ -189,28 +199,38 @@
      </item>
      <item>
       <property name="text">
-       <string>Unpowered</string>
-      </property>
-     </item>
-     <item>
-      <property name="text">
-       <string>Piston</string>
-      </property>
-     </item>
-     <item>
-      <property name="text">
-       <string>Turboprop</string>
+       <string>Single Pilot</string>
       </property>
      </item>
      <item>
       <property name="text">
-       <string>Jet</string>
+       <string>Multi Pilot</string>
       </property>
      </item>
     </widget>
    </item>
+   <item row="5" column="0">
+    <widget class="QLabel" name="makeLabel">
+     <property name="text">
+      <string>Make</string>
+     </property>
+    </widget>
+   </item>
+   <item row="6" column="1">
+    <widget class="QLineEdit" name="modelLineEdit">
+     <property name="maxLength">
+      <number>20</number>
+     </property>
+     <property name="placeholderText">
+      <string>e.g. 737</string>
+     </property>
+    </widget>
+   </item>
    <item row="10" column="1">
-    <widget class="QComboBox" name="weightComboBox">
+    <widget class="QComboBox" name="ppNumberComboBox">
+     <property name="currentText">
+      <string>&lt;Select&gt;</string>
+     </property>
      <item>
       <property name="text">
        <string>&lt;Select&gt;</string>
@@ -218,42 +238,37 @@
      </item>
      <item>
       <property name="text">
-       <string>Light</string>
-      </property>
-     </item>
-     <item>
-      <property name="text">
-       <string>Medium</string>
+       <string>Single Engine</string>
       </property>
      </item>
      <item>
       <property name="text">
-       <string>Heavy</string>
+       <string>Multi Engine</string>
       </property>
      </item>
     </widget>
    </item>
-   <item row="10" column="0">
-    <widget class="QLabel" name="weightLabel">
+   <item row="6" column="0">
+    <widget class="QLabel" name="modelLabel">
      <property name="text">
-      <string>Weight Class</string>
+      <string>Model</string>
      </property>
     </widget>
    </item>
-   <item row="6" column="1">
-    <widget class="QLineEdit" name="variantLineEdit">
-     <property name="maxLength">
-      <number>20</number>
-     </property>
-     <property name="placeholderText">
-      <string>e.g. 800</string>
+   <item row="0" column="0">
+    <widget class="QLabel" name="searchLabel">
+     <property name="text">
+      <string>Search</string>
      </property>
     </widget>
    </item>
-   <item row="3" column="0">
-    <widget class="QLabel" name="companyLabel">
+   <item row="1" column="0" colspan="2">
+    <widget class="QLabel" name="editLabel">
      <property name="text">
-      <string>Company</string>
+      <string>Edit Aircraft</string>
+     </property>
+     <property name="alignment">
+      <set>Qt::AlignCenter</set>
      </property>
     </widget>
    </item>

+ 72 - 0
src/gui/widgets/aircraftwidget.cpp

@@ -0,0 +1,72 @@
+#include "aircraftwidget.h"
+#include "ui_aircraftwidget.h"
+
+// Debug Makro
+#define DEB(expr) \
+    qDebug() << "aircraftWidget ::" << __func__ << "\t" << expr
+
+aircraftWidget::aircraftWidget(QWidget *parent) :
+    QWidget(parent),
+    ui(new Ui::aircraftWidget)
+{
+    ui->setupUi(this);
+
+    QString welcomeMessage = "Select an Aircraft to show or edit details.";
+    QWidget *start = new QWidget();
+    QLabel *label = new QLabel(welcomeMessage);
+    label->setAlignment(Qt::AlignCenter);
+    QHBoxLayout *layout = new QHBoxLayout();
+    layout->addWidget(label);
+    start->setLayout(layout);
+    ui->stackedWidget->addWidget(start);
+    ui->stackedWidget->setCurrentWidget(start);
+
+
+    QSqlTableModel *model = new QSqlTableModel;
+    model->setTable("viewTails");
+    model->select();
+
+    QTableView *view = ui->tableView;
+    view->setModel(model);
+    view->setSelectionBehavior(QAbstractItemView::SelectRows);
+    view->setSelectionMode(QAbstractItemView::SingleSelection);
+    view->setEditTriggers(QAbstractItemView::NoEditTriggers);
+    view->horizontalHeader()->setStretchLastSection(QHeaderView::Stretch);
+    view->setColumnWidth(1,120);
+    view->setColumnWidth(2,60);
+    view->setColumnWidth(3,60);
+    view->setColumnWidth(4,60);
+    view->setColumnWidth(5,60);
+    view->verticalHeader()->hide();
+    view->setAlternatingRowColors(true);
+    for (int i = 6;i <= 17; i++) {
+        view->hideColumn(i);
+    }
+    view->setSortingEnabled(true);
+    view->show();
+
+    connect(ui->tableView->selectionModel(),
+    SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
+    SLOT(tableView_selectionChanged(const QItemSelection &, const QItemSelection &)));
+}
+
+aircraftWidget::~aircraftWidget()
+{
+    delete ui;
+}
+
+void aircraftWidget::setSelectedAircraft(const qint32 &value)
+{
+    selectedAircraft = value;
+}
+
+void aircraftWidget::tableView_selectionChanged(const QItemSelection &index, const QItemSelection &)
+{
+    setSelectedAircraft(index.indexes()[0].data().toInt());
+    DEB("Selected aircraft with ID#: " << selectedAircraft);
+
+    auto nt = new NewTail(aircraft(selectedAircraft,aircraft::tail),this);
+    nt->setWindowFlag(Qt::Widget);
+    ui->stackedWidget->addWidget(nt);
+    ui->stackedWidget->setCurrentWidget(nt);
+}

+ 35 - 0
src/gui/widgets/aircraftwidget.h

@@ -0,0 +1,35 @@
+#ifndef AIRCRAFTWIDGET_H
+#define AIRCRAFTWIDGET_H
+
+#include <QWidget>
+#include <QItemSelection>
+#include <QSqlTableModel>
+#include <QDebug>
+#include <QLabel>
+#include "src/gui/dialogues/newtail.h"
+#include "src/classes/aircraft.h"
+
+namespace Ui {
+class aircraftWidget;
+}
+
+class aircraftWidget : public QWidget
+{
+    Q_OBJECT
+
+public:
+    explicit aircraftWidget(QWidget *parent = nullptr);
+    ~aircraftWidget();
+
+    qint32 selectedAircraft = 0;
+
+    void setSelectedAircraft(const qint32 &value);
+
+private slots:
+    void tableView_selectionChanged(const QItemSelection &index, const QItemSelection &);
+
+private:
+    Ui::aircraftWidget *ui;
+};
+
+#endif // AIRCRAFTWIDGET_H

+ 37 - 0
src/gui/widgets/aircraftwidget.ui

@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>aircraftWidget</class>
+ <widget class="QWidget" name="aircraftWidget">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>911</width>
+    <height>370</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <layout class="QGridLayout" name="gridLayout">
+   <item row="0" column="0">
+    <widget class="QTableView" name="tableView">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="1">
+    <widget class="QStackedWidget" name="stackedWidget">
+     <widget class="QWidget" name="page"/>
+     <widget class="QWidget" name="page_2"/>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

+ 6 - 4
src/gui/widgets/homewidget.cpp

@@ -52,12 +52,14 @@ homeWidget::~homeWidget()
 
 void homeWidget::on_pushButton_clicked()
 {
-    aircraft ac(203,aircraft::tail);
+    //aircraft ac(203,aircraft::tail);
 
-    auto nt = new NewTail("SE-NEU",this);
-    nt->show();
+    //auto nt = new NewTail("SE-NEU",this);
+    //nt->show();
     //aircraft ac2(114,aircraft::acft);
     //aircraft ac3(0,aircraft::acft);
-    //DEB(ac << ac2 << ac3);
+
+    auto ob = db(sql::flights,1);
+    DEB(ob);
 
 }

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

@@ -17,6 +17,7 @@
  */
 #include "settingswidget.h"
 #include "ui_settingswidget.h"
+#include "src/database/dbinfo.h"
 
 
 
@@ -101,7 +102,7 @@ void settingsWidget::themeGroup_toggled(int id)
 void settingsWidget::on_aboutPushButton_clicked()
 {
     auto mb = new QMessageBox(this);
-    QString SQLITE_VERSION = db::sqliteversion();
+    QString SQLITE_VERSION = dbInfo().version;
     QString text = QMessageBox::tr(
 
                 "<h3><center>About openPilotLog</center></h3>"