Quellcode durchsuchen

finished newtail dialog and added settings

fiffty-50 vor 4 Jahren
Ursprung
Commit
74c352302e

BIN
assets/database/logbook.db


+ 14 - 2
mainwindow.cpp

@@ -35,12 +35,14 @@ MainWindow::MainWindow(QWidget *parent)
     ui->actionNewFlight->setIcon(QIcon(":/icons/ionicon-icons/airplane-outline.png"));
     ui->actionAircraft->setIcon(QIcon(":/icons/ionicon-icons/airplane-outline.png"));
     ui->actionNewAircraft->setIcon(QIcon(":/icons/ionicon-icons/airplane-outline.png"));
+    ui->actionPilots->setIcon(QIcon(":/icons/ionicon-icons/settings-outline.png"));
+    ui->actionNewPilot->setIcon(QIcon(":/icons/ionicon-icons/settings-outline.png"));
 
-    // Adds space between toolbar items and actionSetting item
+    // Adds space between toolbar items
     auto *spacer = new QWidget();
     spacer->setMinimumWidth(10);
     spacer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
-    ui->toolBar->insertWidget(ui->actionSettings,spacer);
+    ui->toolBar->insertWidget(ui->actionNewFlight,spacer);
 
 
     // create and show homeWidget
@@ -120,3 +122,13 @@ void MainWindow::on_actionNewAircraft_triggered()
     auto nt = new NewTail(QString(), sql::createNew,this);
     nt->show();
 }
+
+void MainWindow::on_actionPilots_triggered()
+{
+    nope();
+}
+
+void MainWindow::on_actionNewPilot_triggered()
+{
+    nope();
+}

+ 4 - 0
mainwindow.h

@@ -62,6 +62,10 @@ private slots:
 
     void on_actionNewAircraft_triggered();
 
+    void on_actionPilots_triggered();
+
+    void on_actionNewPilot_triggered();
+
 private:
     Ui::MainWindow *ui;
 };

+ 21 - 0
mainwindow.ui

@@ -37,8 +37,10 @@
    <addaction name="actionHome"/>
    <addaction name="actionLogbook"/>
    <addaction name="actionAircraft"/>
+   <addaction name="actionPilots"/>
    <addaction name="actionNewFlight"/>
    <addaction name="actionNewAircraft"/>
+   <addaction name="actionNewPilot"/>
    <addaction name="actionSettings"/>
    <addaction name="actionQuit"/>
   </widget>
@@ -101,6 +103,25 @@
     <string>Add a new aircraft to the database</string>
    </property>
   </action>
+  <action name="actionPilots">
+   <property name="text">
+    <string>Pilots</string>
+   </property>
+   <property name="toolTip">
+    <string>Show or edit Pilots</string>
+   </property>
+   <property name="shortcut">
+    <string>Ctrl+P</string>
+   </property>
+  </action>
+  <action name="actionNewPilot">
+   <property name="text">
+    <string>NewPilot</string>
+   </property>
+   <property name="toolTip">
+    <string>Add a new Pilot to the database</string>
+   </property>
+  </action>
  </widget>
  <resources/>
  <connections/>

+ 23 - 13
src/gui/dialogues/newtail.cpp

@@ -58,6 +58,7 @@ NewTail::NewTail(db dbentry, sql::editRole edRole, QWidget *parent) :
     role = edRole;
     ui->searchLabel->hide();
     ui->searchLineEdit->hide();
+    ui->line->hide();
     formFiller(dbentry);
 }
 
@@ -194,6 +195,7 @@ bool NewTail::verify()
 
     for(const auto le : recommended_line_edits){
         if(le->text() != ""){
+            DEB("Good: " << le);
             recommended_line_edits.removeOne(le);
             le->setStyleSheet("");
         }else{
@@ -363,19 +365,27 @@ void NewTail::on_buttonBox_accepted()
             submitForm(role);
             accept();
         }else{
-            QMessageBox::StandardButton reply;
-            reply = QMessageBox::question(this, "Warning",
-                                          "Some recommended fields are empty.\n\n"
-                                          "If you do not fill out the aircraft details, "
-                                          "it will be impossible to automatically determine Single/Multi Pilot Times or Single/Multi Engine Time."
-                                          "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)
-            {
-                submitForm(role);
-                accept();
+            QSettings setting;
+            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{
+                QMessageBox::StandardButton reply;
+                reply = QMessageBox::question(this, "Warning",
+                                              "Some recommended fields are empty.\n\n"
+                                              "If you do not fill out the aircraft details, "
+                                              "it will be impossible to automatically determine Single/Multi Pilot Times or Single/Multi Engine Time."
+                                              "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)
+                {
+                    submitForm(role);
+                    accept();
+                }
             }
         }
     }

+ 1 - 0
src/gui/dialogues/newtail.h

@@ -21,6 +21,7 @@
 #include <QDialog>
 #include <QCompleter>
 #include <QMessageBox>
+#include <QSettings>
 #include "src/classes/completionlist.h"
 #include "src/classes/aircraft.h"
 

+ 118 - 118
src/gui/dialogues/newtail.ui

@@ -14,75 +14,66 @@
    <string>Add New Aircraft</string>
   </property>
   <layout class="QGridLayout" name="gridLayout">
-   <item row="3" column="0">
-    <widget class="QLabel" name="registrationLabel">
+   <item row="11" column="0">
+    <widget class="QLabel" name="weightLabel">
      <property name="text">
-      <string>Registration</string>
+      <string>Weight Class</string>
      </property>
     </widget>
    </item>
-   <item row="3" column="1">
-    <widget class="QLineEdit" name="registrationLineEdit">
-     <property name="maxLength">
-      <number>20</number>
-     </property>
-     <property name="placeholderText">
-      <string>mandatory</string>
+   <item row="12" column="1">
+    <widget class="QDialogButtonBox" name="buttonBox">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
      </property>
-    </widget>
-   </item>
-   <item row="4" column="0">
-    <widget class="QLabel" name="companyLabel">
-     <property name="text">
-      <string>Company</string>
+     <property name="standardButtons">
+      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
      </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>
+   <item row="10" column="1">
+    <widget class="QComboBox" name="ppNumberComboBox">
+     <property name="currentText">
+      <string>&lt;Select&gt;</string>
      </property>
+     <item>
+      <property name="text">
+       <string>&lt;Select&gt;</string>
+      </property>
+     </item>
+     <item>
+      <property name="text">
+       <string>Single Engine</string>
+      </property>
+     </item>
+     <item>
+      <property name="text">
+       <string>Multi Engine</string>
+      </property>
+     </item>
     </widget>
    </item>
-   <item row="8" column="0">
-    <widget class="QLabel" name="operationLabel">
+   <item row="3" column="0">
+    <widget class="QLabel" name="registrationLabel">
      <property name="text">
-      <string>Operation</string>
+      <string>Registration</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">
+    <widget class="QLabel" name="editLabel">
      <property name="text">
-      <string>Power Plant</string>
+      <string>Edit Aircraft</string>
+     </property>
+     <property name="alignment">
+      <set>Qt::AlignCenter</set>
      </property>
     </widget>
    </item>
-   <item row="11" column="0">
-    <widget class="QLabel" name="weightLabel">
+   <item row="5" column="0">
+    <widget class="QLabel" name="makeLabel">
      <property name="text">
-      <string>Weight Class</string>
+      <string>Make</string>
      </property>
     </widget>
    </item>
@@ -93,8 +84,14 @@
      </property>
     </widget>
    </item>
-   <item row="11" column="1">
-    <widget class="QComboBox" name="weightComboBox">
+   <item row="8" column="1">
+    <widget class="QComboBox" name="operationComboBox">
+     <property name="editable">
+      <bool>false</bool>
+     </property>
+     <property name="currentText">
+      <string>&lt;Select&gt;</string>
+     </property>
      <item>
       <property name="text">
        <string>&lt;Select&gt;</string>
@@ -102,33 +99,20 @@
      </item>
      <item>
       <property name="text">
-       <string>Light</string>
-      </property>
-     </item>
-     <item>
-      <property name="text">
-       <string>Medium</string>
-      </property>
-     </item>
-     <item>
-      <property name="text">
-       <string>Heavy</string>
+       <string>Single Pilot</string>
       </property>
      </item>
      <item>
       <property name="text">
-       <string>Super</string>
+       <string>Multi Pilot</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>
+   <item row="8" column="0">
+    <widget class="QLabel" name="operationLabel">
+     <property name="text">
+      <string>Operation</string>
      </property>
     </widget>
    </item>
@@ -174,45 +158,23 @@
      </property>
     </widget>
    </item>
-   <item row="12" column="1">
-    <widget class="QDialogButtonBox" name="buttonBox">
-     <property name="orientation">
-      <enum>Qt::Horizontal</enum>
+   <item row="5" column="1">
+    <widget class="QLineEdit" name="makeLineEdit">
+     <property name="maxLength">
+      <number>20</number>
      </property>
-     <property name="standardButtons">
-      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+     <property name="placeholderText">
+      <string>e.g. Boeing</string>
      </property>
     </widget>
    </item>
-   <item row="8" column="1">
-    <widget class="QComboBox" name="operationComboBox">
-     <property name="editable">
-      <bool>false</bool>
-     </property>
-     <property name="currentText">
-      <string>&lt;Select&gt;</string>
+   <item row="7" column="1">
+    <widget class="QLineEdit" name="variantLineEdit">
+     <property name="maxLength">
+      <number>20</number>
      </property>
-     <item>
-      <property name="text">
-       <string>&lt;Select&gt;</string>
-      </property>
-     </item>
-     <item>
-      <property name="text">
-       <string>Single Pilot</string>
-      </property>
-     </item>
-     <item>
-      <property name="text">
-       <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 name="placeholderText">
+      <string>e.g. 800</string>
      </property>
     </widget>
    </item>
@@ -226,11 +188,8 @@
      </property>
     </widget>
    </item>
-   <item row="10" column="1">
-    <widget class="QComboBox" name="ppNumberComboBox">
-     <property name="currentText">
-      <string>&lt;Select&gt;</string>
-     </property>
+   <item row="11" column="1">
+    <widget class="QComboBox" name="weightComboBox">
      <item>
       <property name="text">
        <string>&lt;Select&gt;</string>
@@ -238,20 +197,50 @@
      </item>
      <item>
       <property name="text">
-       <string>Single Engine</string>
+       <string>Light</string>
       </property>
      </item>
      <item>
       <property name="text">
-       <string>Multi Engine</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="6" column="0">
-    <widget class="QLabel" name="modelLabel">
+   <item row="9" column="0">
+    <widget class="QLabel" name="powerPlantLabel">
      <property name="text">
-      <string>Model</string>
+      <string>Power Plant</string>
+     </property>
+    </widget>
+   </item>
+   <item row="3" column="1">
+    <widget class="QLineEdit" name="registrationLineEdit">
+     <property name="maxLength">
+      <number>20</number>
+     </property>
+     <property name="placeholderText">
+      <string>mandatory</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>
@@ -262,13 +251,24 @@
      </property>
     </widget>
    </item>
-   <item row="1" column="0" colspan="2">
-    <widget class="QLabel" name="editLabel">
+   <item row="4" column="0">
+    <widget class="QLabel" name="companyLabel">
      <property name="text">
-      <string>Edit Aircraft</string>
+      <string>Company</string>
      </property>
-     <property name="alignment">
-      <set>Qt::AlignCenter</set>
+    </widget>
+   </item>
+   <item row="6" column="0">
+    <widget class="QLabel" name="modelLabel">
+     <property name="text">
+      <string>Model</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>

+ 12 - 8
src/gui/widgets/aircraftwidget.cpp

@@ -32,18 +32,16 @@ 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,60);
-    view->setColumnWidth(3,60);
-    view->setColumnWidth(4,60);
-    view->setColumnWidth(5,60);
+    view->setColumnWidth(2,180);
     view->verticalHeader()->hide();
     view->setAlternatingRowColors(true);
-    for (int i = 6;i <= 17; i++) {
-        view->hideColumn(i);
-    }
     view->setSortingEnabled(true);
-    view->sortByColumn(0,Qt::AscendingOrder);
+    QSettings settings;
+
+    view->sortByColumn(settings.value("userdata/acSortColumn").toInt(),Qt::AscendingOrder);
+
     view->show();
 
     connect(ui->tableView->selectionModel(),
@@ -92,3 +90,9 @@ void aircraftWidget::on_deleteButton_clicked()
         mb->show();
     }
 }
+
+void aircraftWidget::on_newButton_clicked()
+{
+    auto nt = new NewTail(QString(), sql::createNew,this);
+    nt->show();
+}

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

@@ -6,6 +6,7 @@
 #include <QSqlTableModel>
 #include <QDebug>
 #include <QLabel>
+#include <QSettings>
 #include "src/gui/dialogues/newtail.h"
 #include "src/classes/aircraft.h"
 #include "src/database/db.h"
@@ -31,6 +32,8 @@ private slots:
 
     void on_deleteButton_clicked();
 
+    void on_newButton_clicked();
+
 private:
     Ui::aircraftWidget *ui;
 };

+ 44 - 7
src/gui/widgets/aircraftwidget.ui

@@ -14,12 +14,6 @@
    <string>Form</string>
   </property>
   <layout class="QGridLayout" name="gridLayout">
-   <item row="0" column="1">
-    <widget class="QStackedWidget" name="stackedWidget">
-     <widget class="QWidget" name="page"/>
-     <widget class="QWidget" name="page_2"/>
-    </widget>
-   </item>
    <item row="0" column="0">
     <widget class="QTableView" name="tableView">
      <property name="sizePolicy">
@@ -30,10 +24,53 @@
      </property>
     </widget>
    </item>
+   <item row="0" column="1">
+    <layout class="QHBoxLayout" name="horizontalLayout">
+     <item>
+      <spacer name="horizontalSpacer">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <widget class="QStackedWidget" name="stackedWidget">
+       <widget class="QWidget" name="page"/>
+       <widget class="QWidget" name="page_2"/>
+      </widget>
+     </item>
+     <item>
+      <spacer name="horizontalSpacer_2">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+    </layout>
+   </item>
    <item row="1" column="0">
+    <widget class="QPushButton" name="newButton">
+     <property name="text">
+      <string>New Aircraft</string>
+     </property>
+    </widget>
+   </item>
+   <item row="2" column="0">
     <widget class="QPushButton" name="deleteButton">
      <property name="text">
-      <string>Delete</string>
+      <string>Delete Aircraft</string>
      </property>
     </widget>
    </item>

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

@@ -60,6 +60,10 @@ settingsWidget::settingsWidget(QWidget *parent) :
     QRegExp flightNumberPrefix_rx("[a-zA-Z0-9]?[a-zA-Z0-9]?[a-zA-Z0-9]"); // allow max 3 letters (upper and lower) and numbers
     QValidator *flightNumberPrefixValidator = new QRegExpValidator(flightNumberPrefix_rx, this);
     ui->flightNumberPrefixLineEdit->setValidator(flightNumberPrefixValidator);
+    /*
+     * Aircraft Tab
+     */
+    ui->acSortComboBox->setCurrentIndex(settings.value("userdata/acSortColumn").toInt());
 
 }
 
@@ -137,3 +141,32 @@ void settingsWidget::on_aboutPushButton_clicked()
     mb->setText(text);
     mb->open();
 }
+
+void settingsWidget::on_acSortComboBox_currentIndexChanged(int index)
+{
+    QSettings settings;
+    settings.setValue("userdata/acSortColumn",index);
+}
+
+void settingsWidget::on_acAllowIncompleteComboBox_currentIndexChanged(int index)
+{
+    QSettings settings;
+    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"
+                                      "If you do not fill out the aircraft details, "
+                                      "it will be impossible to automatically determine Single/Multi Pilot Times or Single/Multi Engine Time."
+                                      "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){
+            QSettings settings;
+            settings.setValue("userdata/acAllowIncomplete",index);
+        }else{
+            ui->acAllowIncompleteComboBox->setCurrentIndex(0);
+        }
+    }
+}

+ 4 - 0
src/gui/widgets/settingswidget.h

@@ -47,6 +47,10 @@ private slots:
 
     void on_aboutPushButton_clicked();
 
+    void on_acSortComboBox_currentIndexChanged(int index);
+
+    void on_acAllowIncompleteComboBox_currentIndexChanged(int index);
+
 private:
     Ui::settingsWidget *ui;
 

+ 84 - 27
src/gui/widgets/settingswidget.ui

@@ -17,7 +17,7 @@
    <item row="0" column="0">
     <widget class="QTabWidget" name="tabWidget">
      <property name="currentIndex">
-      <number>0</number>
+      <number>2</number>
      </property>
      <widget class="QWidget" name="generalTab">
       <attribute name="title">
@@ -58,32 +58,89 @@
       <attribute name="title">
        <string>Flight Logging</string>
       </attribute>
-      <widget class="QLabel" name="flightNumberPrefixLabel">
-       <property name="geometry">
-        <rect>
-         <x>10</x>
-         <y>20</y>
-         <width>161</width>
-         <height>19</height>
-        </rect>
-       </property>
-       <property name="text">
-        <string>Flight Number Prefix</string>
-       </property>
-      </widget>
-      <widget class="QLineEdit" name="flightNumberPrefixLineEdit">
-       <property name="geometry">
-        <rect>
-         <x>200</x>
-         <y>20</y>
-         <width>113</width>
-         <height>27</height>
-        </rect>
-       </property>
-       <property name="placeholderText">
-        <string>optional</string>
-       </property>
-      </widget>
+      <layout class="QGridLayout" name="gridLayout_7">
+       <item row="0" column="0">
+        <layout class="QGridLayout" name="gridLayout_4">
+         <item row="0" column="0">
+          <widget class="QLabel" name="flightNumberPrefixLabel">
+           <property name="text">
+            <string>Flight Number Prefix</string>
+           </property>
+          </widget>
+         </item>
+         <item row="0" column="1">
+          <widget class="QLineEdit" name="flightNumberPrefixLineEdit">
+           <property name="placeholderText">
+            <string>optional</string>
+           </property>
+          </widget>
+         </item>
+        </layout>
+       </item>
+      </layout>
+     </widget>
+     <widget class="QWidget" name="aircraftTab">
+      <attribute name="title">
+       <string>Aircraft</string>
+      </attribute>
+      <layout class="QGridLayout" name="gridLayout_6">
+       <item row="0" column="0">
+        <layout class="QGridLayout" name="gridLayout_5">
+         <item row="0" column="0">
+          <widget class="QLabel" name="acSortLabel">
+           <property name="text">
+            <string>Sort by</string>
+           </property>
+          </widget>
+         </item>
+         <item row="0" column="1">
+          <widget class="QComboBox" name="acSortComboBox">
+           <item>
+            <property name="text">
+             <string>ID</string>
+            </property>
+           </item>
+           <item>
+            <property name="text">
+             <string>Registration</string>
+            </property>
+           </item>
+           <item>
+            <property name="text">
+             <string>Type</string>
+            </property>
+           </item>
+           <item>
+            <property name="text">
+             <string>Company</string>
+            </property>
+           </item>
+          </widget>
+         </item>
+         <item row="1" column="0">
+          <widget class="QLabel" name="acAllowIncompleteLabel">
+           <property name="text">
+            <string>Allow incomplete</string>
+           </property>
+          </widget>
+         </item>
+         <item row="1" column="1">
+          <widget class="QComboBox" name="acAllowIncompleteComboBox">
+           <item>
+            <property name="text">
+             <string>No</string>
+            </property>
+           </item>
+           <item>
+            <property name="text">
+             <string>Yes</string>
+            </property>
+           </item>
+          </widget>
+         </item>
+        </layout>
+       </item>
+      </layout>
      </widget>
      <widget class="QWidget" name="aboutTab">
       <attribute name="title">