Browse Source

More documentation

Updated docs for Settingswidget, aircraftwidget, pilotswidget, backupwidget [WIP]
Felix Turo 4 years ago
parent
commit
da0b92ebcc

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

@@ -119,8 +119,8 @@ void AircraftWidget::tableView_selectionChanged()
         delete this->findChild<NewTailDialog*>();
 
     selectedTails.clear();
-
-    for (const auto& row : selection->selectedRows()) {
+    const auto selected_rows = selection->selectedRows();
+    for (const auto& row : selected_rows) {
         selectedTails << row.data().toInt();
         DEB << "Selected Tails(s) with ID: " << selectedTails;
     }
@@ -161,14 +161,10 @@ void AircraftWidget::tableView_headerClicked(int column)
 void AircraftWidget::on_deleteAircraftButton_clicked()
 {
     if (selectedTails.length() == 0) {
-        QMessageBox message_box(this);
-        message_box.setText(tr("No Aircraft selected."));
-        message_box.exec();
+        INFO(tr("No Aircraft selected."));
 
     } else if (selectedTails.length() > 1) {
-        QMessageBox message_box(this);
-        message_box.setText(tr("Deleting multiple entries is currently not supported"));
-        message_box.exec();
+        WARN(tr("Deleting multiple entries is currently not supported"));
         /// [F] to do: for (const auto& row_id : selectedPilots) { do batchDelete }
         /// I am not sure if enabling this functionality for this widget is a good idea.
         /// On the one hand, deleting many entries could be useful in a scenario where

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

@@ -44,6 +44,10 @@ class AircraftWidget;
  * in the QTableView, the NewTailDilog is displayed on the right side of the Widget, inside the QStackedWidget.
  * In order to avoid leaks from any previously made selections, existing Dialogs are deleted before a new one is created.
  * The NewTailDialog's `accepted` and `rejected` signals are connected to refresh the view as required.
+ *
+ * Note: The ATailEntry class is used to operate on individual aircraft, whereas the AAircraftEntry class is used to retreive
+ * templates of aircraft types. For example, 'D-ABCD' and 'N-XYZ' are different tails (Registrations), but they might be the same type of aircraft,
+ * for example 'Boeing 737-800'.
  */
 class AircraftWidget : public QWidget
 {

+ 1 - 0
src/gui/widgets/backupwidget.cpp

@@ -23,6 +23,7 @@ BackupWidget::BackupWidget(QWidget *parent) :
                                                  tr("Pilots"), tr("Last Flight"), tr("Total Time")});  // [G]: TODO make const but where?
     view = ui->tableView;
     refresh();
+    TODO << "Update Documentation";
 }
 
 BackupWidget::~BackupWidget()

+ 5 - 0
src/gui/widgets/backupwidget.h

@@ -40,6 +40,11 @@ public:
     }
 };
 
+/*!
+ * \brief The BackupWidget is the interface for the user to create and restore backups of the
+ * database.
+ * \details To Do...
+ */
 class BackupWidget : public QWidget
 {
     Q_OBJECT

+ 11 - 20
src/gui/widgets/pilotswidget.cpp

@@ -145,14 +145,9 @@ void PilotsWidget::on_newPilotButton_clicked()
 void PilotsWidget::on_deletePilotButton_clicked()
 {
     if (selectedPilots.length() == 0) {
-        QMessageBox message_box(this);
-        message_box.setText(tr("No Pilot selected."));
-        message_box.exec();
-
+        INFO(tr("No Pilot selected."));
     } else if (selectedPilots.length() > 1) {
-        QMessageBox message_box(this);
-        message_box.setText(tr("Deleting multiple entries is currently not supported"));
-        message_box.exec();
+        WARN(tr("Deleting multiple entries is currently not supported"));
         /// [F] to do: for (const auto& row_id : selectedPilots) { do batchDelete }
         /// I am not sure if enabling this functionality for this widget is a good idea.
         /// On the one hand, deleting many entries could be useful in a scenario where
@@ -164,15 +159,15 @@ void PilotsWidget::on_deletePilotButton_clicked()
 
     } else if (selectedPilots.length() == 1) {
         auto entry = aDB->getPilotEntry(selectedPilots.first());
-        QMessageBox message_box(this);
-        message_box.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
-        message_box.setDefaultButton(QMessageBox::No);
-        message_box.setIcon(QMessageBox::Question);
-        message_box.setWindowTitle(tr("Delete Pilot"));
+        QMessageBox confirm(this);
+        confirm.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
+        confirm.setDefaultButton(QMessageBox::No);
+        confirm.setIcon(QMessageBox::Question);
+        confirm.setWindowTitle(tr("Delete Pilot"));
 
-        message_box.setText(tr("You are deleting the following pilot:<br><br><b><tt>"
+        confirm.setText(tr("You are deleting the following pilot:<br><br><b><tt>"
                                "%1</b></tt><br><br>Are you sure?").arg(entry.name()));
-        if (message_box.exec() == QMessageBox::Yes) {
+        if (confirm.exec() == QMessageBox::Yes) {
             if(!aDB->remove(entry))
                 onDeleteUnsuccessful();
         }
@@ -198,11 +193,9 @@ void PilotsWidget::onDeleteUnsuccessful()
         constrained_flights.append(aDB->getFlightEntry(row_id));
     }
 
-    QMessageBox message_box(this);
     if (constrained_flights.isEmpty()) {
-        message_box.setText(tr("<br>Unable to delete.<br><br>The following error has ocurred:<br>%1"
+        WARN(tr("<br>Unable to delete.<br><br>The following error has ocurred:<br>%1"
                                ).arg(aDB->lastError.text()));
-        message_box.exec();
         return;
     } else {
         QString constrained_flights_string;
@@ -213,7 +206,7 @@ void PilotsWidget::onDeleteUnsuccessful()
                 break;
             }
         }
-        message_box.setText(tr("Unable to delete.<br><br>"
+        WARN(tr("Unable to delete.<br><br>"
                                "This is most likely the case because a flight exists with the Pilot "
                                "you are trying to delete as PIC.<br><br>"
                                "%1 flight(s) with this pilot have been found:<br><br><br><b><tt>"
@@ -222,8 +215,6 @@ void PilotsWidget::onDeleteUnsuccessful()
                                "before removing this pilot from the database.<br><br>"
                                ).arg(QString::number(constrained_flights.length()),
                                      constrained_flights_string));
-        message_box.setIcon(QMessageBox::Critical);
-        message_box.exec();
     }
 }
 

+ 20 - 14
src/gui/widgets/settingswidget.cpp

@@ -86,6 +86,7 @@ void SettingsWidget::setupComboBoxes(){
     }
 }
 
+
 void SettingsWidget::setupDateEdits()
 {
     // Read Display Format Setting
@@ -97,7 +98,8 @@ void SettingsWidget::setupDateEdits()
     for (const auto &date_format : ADate::getDisplayNames())
         ui->dateFormatComboBox->addItem(date_format);
     ui->dateFormatComboBox->setCurrentIndex(date_format_index);
-    for (const auto & date_edit : this->findChildren<QDateEdit*>()) {
+    const auto date_edits = this->findChildren<QDateEdit*>();
+    for (const auto &date_edit : date_edits) {
         date_edit->setDisplayFormat(date_format_string);
     }
     // Fill currencies
@@ -123,6 +125,9 @@ void SettingsWidget::setupDateEdits()
     }
 }
 
+/*!
+ * \brief SettingsWidget::readSettings Reads settings from ASettings and sets up the UI accordingly
+ */
 void SettingsWidget::readSettings()
 {
     /*
@@ -204,6 +209,9 @@ void SettingsWidget::setupValidators()
     }
 }
 
+/*!
+ * \brief SettingsWidget::updatePersonalDetails Updates the database with the users personal details.
+ */
 void SettingsWidget::updatePersonalDetails()
 {
     RowData_T user_data;
@@ -371,7 +379,9 @@ void SettingsWidget::on_acAllowIncompleteComboBox_currentIndexChanged(int index)
  * About Tab
  */
 
-
+/*!
+ * \brief SettingsWidget::on_aboutPushButton_clicked Displays Application Version and Licensing information
+ */
 void SettingsWidget::on_aboutPushButton_clicked()
 {
     QMessageBox message_box(this);
@@ -458,11 +468,9 @@ void SettingsWidget::on_fontSpinBox_valueChanged(int arg1)
 void SettingsWidget::on_fontCheckBox_stateChanged(int arg1)
 {
     if (usingStylesheet() && arg1 == Qt::Unchecked) {
-        QMessageBox message_box(this);
-        message_box.setText(tr("The style you have currently selected may not be fully compatible "
-                               "with changing to a custom font while the application is running.<br><br>"
-                               "Applying your changes may require restarting the application.<br>"));
-        message_box.exec();
+        WARN(tr("The style you have currently selected may not be fully compatible "
+                "with changing to a custom font while the application is running.<br><br>"
+                "Applying your changes may require restarting the application.<br>"));
     }
     switch (arg1) {
     case Qt::Unchecked:
@@ -473,7 +481,7 @@ void SettingsWidget::on_fontCheckBox_stateChanged(int arg1)
         QFont font(ui->fontComboBox->currentFont());
         font.setPointSize(ui->fontSpinBox->value());
         qApp->setFont(font);
-        DEB << "Setting Font:" << font.toString();
+        LOG << "Setting Font:" << font.toString();
         break;
     }
     case Qt::Checked:
@@ -481,9 +489,7 @@ void SettingsWidget::on_fontCheckBox_stateChanged(int arg1)
         ui->fontComboBox->setEnabled(false);
         ui->fontSpinBox->setEnabled(false);
         ASettings::write(ASettings::Main::UseSystemFont, true);
-        QMessageBox message_box(this);
-        message_box.setText(tr("The application will be restarted for this change to take effect."));
-        message_box.exec();
+        INFO(tr("The application will be restarted for this change to take effect."));
         qApp->quit();
         QProcess::startDetached(qApp->arguments()[0], qApp->arguments());
     }
@@ -507,7 +513,7 @@ bool SettingsWidget::usingStylesheet()
 
 void SettingsWidget::on_resetStylePushButton_clicked()
 {
-    DEB << "Resetting style to default...";
+    LOG << "Resetting style to default...";
     ui->styleComboBox->setCurrentText(AStyle::defaultStyle);
     ui->fontCheckBox->setChecked(true);
 }
@@ -693,8 +699,8 @@ void SettingsWidget::on_currCustom2LineEdit_editingFinished()
 void SettingsWidget::on_dateFormatComboBox_currentIndexChanged(int index)
 {
     ASettings::write(ASettings::Main::DateFormat, index);
-
-    for (const auto & date_edit : this->findChildren<QDateEdit*>()) {
+    const auto date_edits = this->findChildren<QDateEdit*>();
+    for (const auto & date_edit : date_edits) {
         date_edit->setDisplayFormat(
                     ADate::getFormatString(
                         static_cast<Opl::Date::ADateFormat>(ASettings::read(ASettings::Main::DateFormat).toInt())));

+ 11 - 7
src/gui/widgets/settingswidget.h

@@ -21,7 +21,6 @@
 #include <QWidget>
 #include <QButtonGroup>
 #include <QValidator>
-#include <QMessageBox>
 #include <QProcess>
 #include <QDebug>
 #include <QFontDialog>
@@ -30,6 +29,14 @@ namespace Ui {
 class SettingsWidget;
 }
 
+/*!
+ * \brief The SettingsWidget is used to to display and alter Settings.
+ *
+ * \details Most Inputs are collected and processed in various slots and
+ * written to the settings file via the ASettings class. In the `Personal` Settings
+ * tab, the user can edit his personal details, which are then written to the Database
+ * (The Logbook owner is registered in the Pilots Database with `pilot_id = 1`).
+ */
 class SettingsWidget : public QWidget
 {
     Q_OBJECT
@@ -39,13 +46,12 @@ public:
     ~SettingsWidget();
 
     /*!
-     * \brief Widgets that need to receive a signal when a setting is updated.
+     * \brief enumerates Widgets that need to receive a signal when a setting is updated.
      */
     enum SettingSignal {LogbookWidget, HomeWidget, AircraftWidget, PilotsWidget};
 
 private slots:
 
-//    void onThemeGroup_buttonClicked(int theme_id);
     void on_aboutPushButton_clicked();
     void on_acftSortComboBox_currentIndexChanged(int index);
     void on_acAllowIncompleteComboBox_currentIndexChanged(int index);
@@ -65,8 +71,6 @@ private slots:
     void on_companyLineEdit_editingFinished();
     void on_styleComboBox_currentTextChanged(const QString& new_style_setting);
 
-    //void on_fontPushButton_clicked();
-
     void on_fontComboBox_currentFontChanged(const QFont &f);
 
     void on_fontSpinBox_valueChanged(int arg1);
@@ -129,8 +133,8 @@ private:
 signals:
 
     /*!
-     * \brief settingChanged is emitted when a setting change shall trigger
-     * an update to another widget.
+     * \brief settingChanged is emitted when a setting change occurs that needs to trigger
+     * an update (repaint) to another widget.
      */
     void settingChanged(SettingSignal widget);
 };

+ 1 - 1
src/gui/widgets/settingswidget.ui

@@ -17,7 +17,7 @@
    <item row="0" column="0">
     <widget class="QTabWidget" name="tabWidget">
      <property name="currentIndex">
-      <number>1</number>
+      <number>0</number>
      </property>
      <widget class="QWidget" name="personalTab">
       <attribute name="title">