|
@@ -2,8 +2,11 @@
|
|
#include "QtSql/qsqltablemodel.h"
|
|
#include "QtSql/qsqltablemodel.h"
|
|
#include "QtWidgets/qgridlayout.h"
|
|
#include "QtWidgets/qgridlayout.h"
|
|
#include "QtWidgets/qheaderview.h"
|
|
#include "QtWidgets/qheaderview.h"
|
|
|
|
+#include "src/classes/easaftl.h"
|
|
|
|
+#include "src/classes/time.h"
|
|
#include "src/database/database.h"
|
|
#include "src/database/database.h"
|
|
#include "src/functions/statistics.h"
|
|
#include "src/functions/statistics.h"
|
|
|
|
+#include "src/classes/settings.h"
|
|
#include <QCalendarWidget>
|
|
#include <QCalendarWidget>
|
|
#include <QInputDialog>
|
|
#include <QInputDialog>
|
|
#include <QLabel>
|
|
#include <QLabel>
|
|
@@ -113,35 +116,52 @@ void CurrencyWidget::setupUI()
|
|
|
|
|
|
void CurrencyWidget::fillTakeOffAndLandingCurrencies()
|
|
void CurrencyWidget::fillTakeOffAndLandingCurrencies()
|
|
{
|
|
{
|
|
- const auto takeoff_landings = OPL::Statistics::countTakeOffLanding();
|
|
|
|
- if(takeoff_landings.isEmpty() || takeoff_landings.size() != 2)
|
|
|
|
- return;
|
|
|
|
-
|
|
|
|
- QList<QLabel*> displayLabels = {
|
|
|
|
- takeOffCountDisplayLabel,
|
|
|
|
- landingCountDisplayLabel
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- for(int i = 0; i < 2; i++) {
|
|
|
|
- int count = takeoff_landings[i].toInt();
|
|
|
|
- if(count < 3)
|
|
|
|
- setLabelColour(displayLabels[i], Colour::Red);
|
|
|
|
- displayLabels[i]->setText(displayLabels[i]->text().arg(count));
|
|
|
|
- }
|
|
|
|
- QDate expiration_date = OPL::Statistics::currencyTakeOffLandingExpiry();
|
|
|
|
- if (expiration_date <= QDate::currentDate())
|
|
|
|
- setLabelColour(takeOffLandingExpiryDisplayLabel, Colour::Red);
|
|
|
|
- takeOffLandingExpiryDisplayLabel->setText(expiration_date.toString(Qt::TextDate));
|
|
|
|
|
|
+ const auto takeoff_landings = OPL::Statistics::countTakeOffLanding();
|
|
|
|
+ if(takeoff_landings.isEmpty() || takeoff_landings.size() != 2)
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ QList<QLabel*> displayLabels = {
|
|
|
|
+ takeOffCountDisplayLabel,
|
|
|
|
+ landingCountDisplayLabel
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ for(int i = 0; i < 2; i++) {
|
|
|
|
+ int count = takeoff_landings[i].toInt();
|
|
|
|
+ if(count < 3)
|
|
|
|
+ setLabelColour(displayLabels[i], Colour::Red);
|
|
|
|
+ displayLabels[i]->setText(displayLabels[i]->text().arg(count));
|
|
|
|
+ }
|
|
|
|
+ QDate expiration_date = OPL::Statistics::currencyTakeOffLandingExpiry();
|
|
|
|
+ if (expiration_date <= QDate::currentDate())
|
|
|
|
+ setLabelColour(takeOffLandingExpiryDisplayLabel, Colour::Red);
|
|
|
|
+ takeOffLandingExpiryDisplayLabel->setText(expiration_date.toString(Qt::TextDate));
|
|
}
|
|
}
|
|
|
|
|
|
void CurrencyWidget::fillFlightTimeLimitations()
|
|
void CurrencyWidget::fillFlightTimeLimitations()
|
|
{
|
|
{
|
|
- TODO << "Fill flight time limitations";
|
|
|
|
|
|
+ const QList<QPair<QLabel *, OPL::Statistics::TimeFrame>> limits =
|
|
|
|
+ {
|
|
|
|
+ { flightTime28DaysDisplayLabel, OPL::Statistics::TimeFrame::Rolling28Days },
|
|
|
|
+ { flightTime365DaysDisplayLabel, OPL::Statistics::TimeFrame::Rolling12Months },
|
|
|
|
+ { flightTimeCalendarYearDisplayLabel, OPL::Statistics::TimeFrame::CalendarYear },
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ double ftlWarningThreshold = Settings::getFtlWarningThreshold();
|
|
|
|
+ for (const auto &pair : limits) {
|
|
|
|
+ int accruedMinutes = OPL::Statistics::totalTime(pair.second);
|
|
|
|
+ int limitMinutes = EasaFTL::getLimit(pair.second);
|
|
|
|
+ pair.first->setText(OPL::Time(accruedMinutes).toString());
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if (accruedMinutes >= limitMinutes)
|
|
|
|
+ setLabelColour(pair.first, Colour::Red);
|
|
|
|
+ else if (accruedMinutes >= limitMinutes * ftlWarningThreshold)
|
|
|
|
+ setLabelColour(pair.first, Colour::Orange);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
void CurrencyWidget::editRequested(const QModelIndex &index)
|
|
void CurrencyWidget::editRequested(const QModelIndex &index)
|
|
{
|
|
{
|
|
- LOG << "Edit requested at: " << index.data();
|
|
|
|
lastSelection = index;
|
|
lastSelection = index;
|
|
const QString selection = index.data().toString();
|
|
const QString selection = index.data().toString();
|
|
const QDate selectedDate = QDate::fromString(selection, dateFormat);
|
|
const QDate selectedDate = QDate::fromString(selection, dateFormat);
|
|
@@ -152,7 +172,6 @@ void CurrencyWidget::editRequested(const QModelIndex &index)
|
|
calendar->show();
|
|
calendar->show();
|
|
} else {
|
|
} else {
|
|
// the displayName column has been selected for editing
|
|
// the displayName column has been selected for editing
|
|
- LOG << "Other edit requested";
|
|
|
|
displayNameEditRequested(index);
|
|
displayNameEditRequested(index);
|
|
}
|
|
}
|
|
}
|
|
}
|