2
0

homewidget.cpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 "homewidget.h"
  19. #include "ui_homewidget.h"
  20. #include "calc.h"
  21. #include "dbstat.h"
  22. #include "dbpilots.h"
  23. #include <QDebug>
  24. homeWidget::homeWidget(QWidget *parent) :
  25. QWidget(parent),
  26. ui(new Ui::homeWidget)
  27. {
  28. ui->setupUi(this);
  29. qDebug() << "homeWidget: Activated";
  30. /*
  31. * To Do: Functions to retreive values from DB
  32. */
  33. ui->totalTimeDisplayLabel->setText(calc::minutes_to_string(dbStat::retreiveTotalTime()));
  34. QString blockMinutesThisYear = dbStat::retreiveTotalTimeThisCalendarYear();
  35. ui->blockHoursCalDisplayLabel->setText(calc::minutes_to_string(blockMinutesThisYear));
  36. if (blockMinutesThisYear.toInt() > 900*60) {
  37. qDebug() << "More than 900 block hours this calendar year!";
  38. // set Text Red
  39. }
  40. QString blockMinutesRollingYear = dbStat::retreiveTotalTimeRollingYear();
  41. ui->blockHoursRolDisplayLabel->setText(calc::minutes_to_string(blockMinutesRollingYear));
  42. QVector<QString> currency = dbStat::retreiveCurrencyTakeoffLanding();
  43. ui->currencyDisplayLabel->setText(currency[0] + " Take Offs\n" + currency[1] + " Landings");
  44. if (currency[0].toInt() < 3 || currency[1].toInt() < 3){
  45. qDebug() << "Less than 3 TO/LDG in last 90 days!";
  46. //set Text Red
  47. }
  48. }
  49. homeWidget::~homeWidget()
  50. {
  51. delete ui;
  52. }
  53. void homeWidget::on_debugButton_clicked()
  54. {
  55. // ui->debugLineEdit->setText(dbAircraft::retreiveAircraftDetails("102")[1]);
  56. qDebug() << "Debug: ";
  57. dbPilots::retreivePilotList();
  58. }