totalswidget.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. *openPilotLog - A FOSS Pilot Logbook Application
  3. *Copyright (C) 2020-2021 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 "totalswidget.h"
  19. #include "ui_totalswidget.h"
  20. #include "src/testing/adebug.h"
  21. #include "src/database/adatabase.h"
  22. TotalsWidget::TotalsWidget(QWidget *parent) :
  23. QWidget(parent),
  24. ui(new Ui::TotalsWidget)
  25. {
  26. ui->setupUi(this);
  27. auto data = AStat::totals();
  28. DEB << "Filling Totals Line Edits...";
  29. for (const auto &field : data) {
  30. auto line_edit = parent->findChild<QLineEdit *>(field.first + "LineEdit");
  31. line_edit->setText(field.second);
  32. }
  33. QString salutation = tr("Welcome to openPilotLog");
  34. salutation.append(QStringLiteral(", ") + userName() + QLatin1Char('!'));
  35. ui->welcomeLabel->setText(salutation);
  36. }
  37. TotalsWidget::~TotalsWidget()
  38. {
  39. delete ui;
  40. }
  41. const QString TotalsWidget::userName()
  42. {
  43. auto namestring = aDB->getPilotEntry(1).name();
  44. auto names = namestring.split(',');
  45. if (!names.isEmpty())
  46. return names[0];
  47. return QString();
  48. }