mainwindow.cpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. *openPilot Log - A FOSS Pilot Logbook Application
  3. *Copyright (C) 2020 Felix Turowsky
  4. *
  5. *This program is free software: you can redistribute it and/or modify
  6. *it under the terms of the GNU General Public License as published by
  7. *the Free Software Foundation, either version 3 of the License, or
  8. *(at your option) any later version.
  9. *
  10. *This program is distributed in the hope that it will be useful,
  11. *but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. *GNU General Public License for more details.
  14. *
  15. *You should have received a copy of the GNU General Public License
  16. *along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. #include "mainwindow.h"
  19. #include "ui_mainwindow.h"
  20. #include "newflight.h"
  21. #include "editflight.h"
  22. #include "newacft.h"
  23. #include "easaview.h"
  24. #include "dbman.cpp"
  25. #include "calc.h"
  26. #include "homewidget.h"
  27. #include "logbookwidget.h"
  28. #include <QTime>
  29. #include <QSqlDatabase>
  30. #include <QSqlDriver>
  31. #include <QSqlError>
  32. #include <QSqlQuery>
  33. #include <QSqlTableModel>
  34. #include <QTableView>
  35. #include <chrono>
  36. #include <QMessageBox>
  37. qlonglong SelectedFlightold = -1;
  38. MainWindow::MainWindow(QWidget *parent)
  39. : QMainWindow(parent)
  40. , ui(new Ui::MainWindow)
  41. {
  42. ui->setupUi(this);
  43. // Adds space between toolbar items and actionQuit item
  44. auto *spacer = new QWidget();
  45. spacer->setMinimumWidth(10);
  46. spacer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
  47. ui->toolBar->insertWidget(ui->actionQuit,spacer);
  48. // create and show homeWidget
  49. auto hw = new homeWidget(this);
  50. ui->stackedWidget->addWidget(hw);
  51. ui->stackedWidget->setCurrentWidget(hw);
  52. db::connect(); //connect to the database
  53. }
  54. MainWindow::~MainWindow()
  55. {
  56. delete ui;
  57. }
  58. /*
  59. * Functions
  60. */
  61. void MainWindow::nope()
  62. {
  63. QMessageBox nope; //error box
  64. nope.setText("This feature is not yet available!");
  65. nope.exec();
  66. }
  67. /*
  68. * Slots
  69. */
  70. void MainWindow::on_actionNew_Flight_triggered()
  71. {
  72. NewFlight nf(this);
  73. nf.exec();
  74. }
  75. void MainWindow::on_actionQuit_triggered()
  76. {
  77. QApplication::quit();
  78. }
  79. void MainWindow::on_quitButton_clicked()
  80. {
  81. QApplication::quit();
  82. }
  83. void MainWindow::on_actionHome_triggered()
  84. {
  85. auto hw = new homeWidget(this);
  86. ui->stackedWidget->addWidget(hw);
  87. ui->stackedWidget->setCurrentWidget(hw);
  88. }
  89. void MainWindow::on_actionLogbook_triggered()
  90. {
  91. auto lw = new logbookWidget(this);
  92. ui->stackedWidget->addWidget(lw);
  93. ui->stackedWidget->setCurrentWidget(lw);
  94. }