Browse Source

Compatibility with qt 5.9.5

Adjustments to ensure compatibility with qt >= 5.9.5
harmonized naming of temporary qmessageboxes
Felix 4 years ago
parent
commit
fa35a347be

+ 6 - 6
mainwindow.cpp

@@ -98,9 +98,9 @@ MainWindow::~MainWindow()
 
 void MainWindow::nope()
 {
-    QMessageBox nope(this); //error box
-    nope.setText("This feature is not yet available!");
-    nope.exec();
+    QMessageBox message_box(this); //error box
+    message_box.setText("This feature is not yet available!");
+    message_box.exec();
 }
 
 
@@ -158,19 +158,19 @@ void MainWindow::on_actionAircraft_triggered()
 
 void MainWindow::on_actionNewFlight_triggered()
 {
-    NewFlightDialog nf = NewFlightDialog(this);
+    NewFlightDialog nf(this);
     nf.exec();
 
 }
 
 void MainWindow::on_actionNewAircraft_triggered()
 {
-    NewTailDialog nt = NewTailDialog(QString(), this);
+    NewTailDialog nt(QString(), this);
     nt.exec();
 }
 
 void MainWindow::on_actionNewPilot_triggered()
 {
-    NewPilotDialog np = NewPilotDialog(this);
+    NewPilotDialog np(this);
     np.exec();
 }

+ 2 - 2
openPilotLog.pro

@@ -2,7 +2,7 @@ QT       += core gui sql network
 
 greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
 
-CONFIG += c++17
+CONFIG += c++1z
 
 # The following define makes your compiler emit warnings if you use
 # any Qt feature that has been marked deprecated (the exact warnings
@@ -13,7 +13,7 @@ DEFINES += QT_DEPRECATED_WARNINGS
 # You can also make your code fail to compile if it uses deprecated APIs.
 # In order to do so, uncomment the following line.
 # You can also select to disable deprecated APIs only up to a certain version of Qt.
-#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
+DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
 
 # [G]: need to fix this. There must be a src/* command or smth
 SOURCES += \

+ 2 - 4
src/classes/asettings.cpp

@@ -147,7 +147,5 @@ QString ASettings::stringOfKey (const ASettings::Setup key)
 QString ASettings::stringOfKey (const ASettings::UserData key)
 { return  userDataMap[key]; }
 
-
-
-QSettings ASettings::settings()
-{ return QSettings(); }
+// [F]: removed because the function was unused and wouldn't compile with qt 5.9.5. Not sure why it did in the first place.
+// see https://doc.qt.io/archives/qt-5.9/qobject.html#no-copy-constructor-or-assignment-operator for info

+ 6 - 6
src/classes/astyle.cpp

@@ -5,11 +5,10 @@
 #include "src/testing/adebug.h"
 #include "src/classes/asettings.h"
 
-#ifdef __linux__
-const QString AStyle::defaultStyle = QStringLiteral("fusion");
-#elif defined(_WIN32) || defined(_WIN64)
-const QString AStyle::defaultStyle = QStringLiteral("Windows");
-#endif
+// this was throwing hundreds of warnings on 5.9.5, fusion is a good default for all platforms, let's
+// stick with that for now.
+const QString AStyle::defaultStyle = QStringLiteral("Fusion");
+
 const QString AStyle::defaultStyleSheet = QStringLiteral("");
 
 const QStringList AStyle::styles = QStyleFactory::keys();
@@ -73,7 +72,8 @@ void AStyle::setStyle(const QString style)
 
 void AStyle::setStyleSheet(const StyleSheet stylesheet)
 {
-    DEB << "Setting stylesheet to:" << defaultStyleSheets[stylesheet];
+    // [F]: qt 5.9.5 compatibility
+    DEB << "Setting stylesheet to:" << defaultStyleSheets[stylesheet].baseName();
     qApp->setStyleSheet(read_stylesheet(stylesheet));
     ASettings::write(ASettings::Main::StyleSheet, stylesheet);
     currentStyleSheet = defaultStyleSheets[stylesheet].fileName();

+ 2 - 2
src/functions/astat.cpp

@@ -123,9 +123,9 @@ QVector<QPair<QString, QString>> AStat::totals()
     for (const auto &column : columns) {
         value = query.value(columns.indexOf(column)).toString();
         if (!value.isEmpty()) {
-            output << QPair{column, value};
+            output.append(QPair<QString, QString>{column, value});
         } else {
-            output << QPair{column, QString("00:00")};
+            output.append(QPair<QString, QString>{column, QString("00:00")});
         }
     }
     return output;

+ 0 - 13
src/gui/dialogues/newflightdialog.cpp

@@ -26,15 +26,6 @@
 
 #include "src/testing/adebug.h"
 
-/////////////////////////////////////// DEBUG /////////////////////////////////////////////////////
-void NewFlightDialog::onInputRejected()
-{
-    auto sender_object = sender();
-    auto line_edit = this->findChild<QLineEdit*>(sender_object->objectName());
-    DEB << line_edit->objectName() << "Input Rejected - " << line_edit->text();
-}
-/////////////////////////////////////// DEBUG /////////////////////////////////////////////////////
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 ///                                         constants                                           ///
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -282,10 +273,6 @@ void NewFlightDialog::setupSignalsAndSlots()
     auto line_edits = this->findChildren<QLineEdit*>();
 
     for (const auto &line_edit : line_edits){
-        /////////////////////////////////////// DEBUG /////////////////////////////////////////////////////
-        QObject::connect(line_edit, &QLineEdit::inputRejected,
-                         this, &NewFlightDialog::onInputRejected);
-        /////////////////////////////////////// DEBUG /////////////////////////////////////////////////////
         line_edit->installEventFilter(this);
         if(line_edit->objectName().contains("Loc")){
             QObject::connect(line_edit, &QLineEdit::textChanged,

+ 0 - 4
src/gui/dialogues/newflightdialog.h

@@ -56,10 +56,6 @@ public:
 
 private slots:
 
-    /////// DEBUG
-        void onInputRejected();
-    /////// DEBUG
-
     void onToUpperTriggered_textChanged(const QString&);
     void onPilotNameLineEdit_editingFinished();
     void onLocationEditingFinished(QLineEdit*, QLabel*);

+ 3 - 3
src/gui/dialogues/newpilotdialog.cpp

@@ -118,9 +118,9 @@ void NewPilotDialog::setup()
 void NewPilotDialog::on_buttonBox_accepted()
 {
     if (ui->lastnameLineEdit->text().isEmpty() || ui->firstnameLineEdit->text().isEmpty()) {
-        auto mb = QMessageBox(this);
-        mb.setText("Last Name and First Name are required.");
-        mb.show();
+        QMessageBox message_box(this);
+        message_box.setText("Last Name and First Name are required.");
+        message_box.show();
     } else {
         submitForm();
     }

+ 4 - 4
src/gui/dialogues/newtaildialog.cpp

@@ -264,11 +264,11 @@ void NewTailDialog::on_buttonBox_accepted()
 
     if (!verify()) {
         if (!ASettings::read(ASettings::UserData::AcAllowIncomplete).toInt()) {
-            auto nope = QMessageBox(this);
-            nope.setIcon(QMessageBox::Warning);
-            nope.setText("Some or all recommended fields are empty.\nPlease go back and "
+            QMessageBox message_box(this);
+            message_box.setIcon(QMessageBox::Warning);
+            message_box.setText("Some or all recommended fields are empty.\nPlease go back and "
                          "complete the form.\n\nYou can allow logging incomplete tail entries on the settings page.");
-            nope.exec();
+            message_box.exec();
             return;
         } else {
             QMessageBox::StandardButton reply;

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

@@ -84,14 +84,14 @@ void AircraftWidget::setupModelAndView()
 void AircraftWidget::on_deleteButton_clicked()
 {
     if (selectedTails.length() == 0) {
-        auto mb = QMessageBox(this);
-        mb.setText(QStringLiteral("No Aircraft selected."));
-        mb.exec();
+        QMessageBox message_box(this);
+        message_box.setText(QStringLiteral("No Aircraft selected."));
+        message_box.exec();
 
     } else if (selectedTails.length() > 1) {
-        auto mb = QMessageBox(this);
-        mb.setText(QStringLiteral("Deleting multiple entries is currently not supported"));
-        mb.exec();
+        QMessageBox message_box(this);
+        message_box.setText(QStringLiteral("Deleting multiple entries is currently not supported"));
+        message_box.exec();
         /// [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
@@ -103,7 +103,7 @@ void AircraftWidget::on_deleteButton_clicked()
 
     } else if (selectedTails.length() == 1) {
         auto entry = aDB->getTailEntry(selectedTails.first());
-        auto message_box = QMessageBox(this);
+        QMessageBox message_box(this);
         QString message = "You are deleting the following aircraft:<br><br><b><tt>";
         message.append(entry.registration() + QStringLiteral(" - (") + entry.type() + ')');
         message.append(QStringLiteral("</b></tt><br><br>Are you sure?"));

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

@@ -25,14 +25,14 @@ DebugWidget::~DebugWidget()
 void DebugWidget::on_resetUserTablesPushButton_clicked()
 {
     ATimer timer(this);
-    QMessageBox result;
+    QMessageBox message_box(this);
     if (ADataBaseSetup::resetToDefault()){
-        result.setText("Database successfully reset");
-        result.exec();
+        message_box.setText("Database successfully reset");
+        message_box.exec();
         emit aDB->dataBaseUpdated();
     } else {
-        result.setText("Errors have occurred. Check console for Debug output. ");
-        result.exec();
+        message_box.setText("Errors have occurred. Check console for Debug output. ");
+        message_box.exec();
     }
 }
 
@@ -148,18 +148,18 @@ void DebugWidget::on_importCsvPushButton_clicked()
     if (file.exists() && file.isFile()) {
 
         if (ADataBaseSetup::commitData(aReadCsv(file.absoluteFilePath()), ui->tableComboBox->currentText())) {
-            auto mb = QMessageBox(this);
-            mb.setText("Data inserted successfully.");
-            mb.exec();
+            QMessageBox message_box(this);
+            message_box.setText("Data inserted successfully.");
+            message_box.exec();
         } else {
-            auto mb = QMessageBox(this);
-            mb.setText("Errors have ocurred. Check console for details.");
-            mb.exec();
+            QMessageBox message_box(this);
+            message_box.setText("Errors have ocurred. Check console for details.");
+            message_box.exec();
         }
     } else {
-        auto mb = QMessageBox(this);
-        mb.setText("Please select a valid file.");
-        mb.exec();
+        QMessageBox message_box(this);
+        message_box.setText("Please select a valid file.");
+        message_box.exec();
     }
 }
 

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

@@ -132,14 +132,14 @@ void PilotsWidget::on_newPilotButton_clicked()
 void PilotsWidget::on_deletePilotButton_clicked()
 {
     if (selectedPilots.length() == 0) {
-        auto mb = QMessageBox(this);
-        mb.setText("No Pilot selected.");
-        mb.exec();
+        QMessageBox message_box(this);
+        message_box.setText("No Pilot selected.");
+        message_box.exec();
 
     } else if (selectedPilots.length() > 1) {
-        auto mb = QMessageBox(this);
-        mb.setText("Deleting multiple entries is currently not supported");
-        mb.exec();
+        QMessageBox message_box(this);
+        message_box.setText("Deleting multiple entries is currently not supported");
+        message_box.exec();
         /// [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