Browse Source

fixed bug in tableview selection and currencyToLdg function

fiffty-50 4 năm trước cách đây
mục cha
commit
5d08b61d0f
3 tập tin đã thay đổi với 9 bổ sung23 xóa
  1. 2 3
      dbstat.cpp
  2. 6 15
      logbookwidget.cpp
  3. 1 5
      logbookwidget.h

+ 2 - 3
dbstat.cpp

@@ -94,9 +94,8 @@ QVector<QString> dbStat::retreiveCurrencyTakeoffLanding()
     QDate start = QDate::fromJulianDay(QDate::currentDate().toJulianDay() - 90);
 
     QSqlQuery query;
-    query.prepare("SELECT "
-                  "SUM(extras.TOday + extras.TOnight) AS 'TakeOFF', "
-                  "SUM(extras.LDGday + extras.LDGnight) AS 'Landing' "
+    query.prepare("SELECT SUM(extras.TOday) + SUM(extras.TOnight) AS 'TO', "
+                  "SUM(extras.LDGday) + SUM(extras.LDGnight) AS 'LDG' "
                   "FROM flights "
                   "INNER JOIN extras on flights.id = extras.extras_id "
                   "WHERE doft >= ?");

+ 6 - 15
logbookwidget.cpp

@@ -132,24 +132,15 @@ void logbookWidget::on_showAllButton_clicked()
     ui->tableView->setModel(ShowAllModel);
 }
 
-void logbookWidget::on_tableView_entered(const QModelIndex &index)
+/*void logbookWidget::on_tableView_pressed(const QModelIndex &index)
 {
     auto NewIndex = ui->tableView->model()->index(index.row(), 0);
     SelectedFlight = ui->tableView->model()->data(NewIndex).toInt();
-    qDebug() << "Selected Flight with ID#(entered): " << SelectedFlight;
-}
-
-void logbookWidget::on_tableView_pressed(const QModelIndex &index)
-{
-    auto NewIndex = ui->tableView->model()->index(index.row(), 0);
-    SelectedFlight = ui->tableView->model()->data(NewIndex).toInt();
-    qDebug() << "Selected Flight with ID#(entered): " << SelectedFlight;
-}
+    qDebug() << "Selected Flight with ID#(pressed): " << SelectedFlight;
+}*/
 
-void logbookWidget::on_tableView_changed(const QItemSelection &index, const QItemSelection &index2)// TO DO
+void logbookWidget::on_tableView_changed(const QItemSelection &index, const QItemSelection &)// TO DO
 {
-    //auto NewIndex = ui->tableView->model()->index(index.row(), 0);
-    //SelectedFlight = ui->tableView->model()->data(NewIndex).toInt();
-    qDebug() << "Selected Flight with ID#(signalslot): " << SelectedFlight;
-    qDebug() << "lol";// << index.value(1) << index.at(2);
+    SelectedFlight = index.indexes()[0].data().toInt();
+    qDebug() << "Selected Flight with ID#(selectionChanged): " << SelectedFlight;
 }

+ 1 - 5
logbookwidget.h

@@ -27,11 +27,7 @@ private slots:
 
     void on_showAllButton_clicked();
 
-    void on_tableView_entered(const QModelIndex &index);
-
-    void on_tableView_pressed(const QModelIndex &index);
-
-    void on_tableView_changed(const QItemSelection &index, const QItemSelection &index2);
+    void on_tableView_changed(const QItemSelection &index, const QItemSelection &);
 
 private:
     Ui::logbookWidget *ui;