From f964728422cc9f21447cd4cda1b415f5dcf50ca6 Mon Sep 17 00:00:00 2001 From: James Turner Date: Tue, 12 Dec 2017 16:34:54 +0000 Subject: [PATCH] Launcher aircraft list: show counts --- src/GUI/AircraftRatingsPanel.qml | 13 ++++++++++++- src/GUI/AircraftSearchFilterModel.cxx | 12 ++++++++++++ src/GUI/AircraftSearchFilterModel.hxx | 5 +++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/GUI/AircraftRatingsPanel.qml b/src/GUI/AircraftRatingsPanel.qml index ce7087ef9..ca001232f 100644 --- a/src/GUI/AircraftRatingsPanel.qml +++ b/src/GUI/AircraftRatingsPanel.qml @@ -14,11 +14,22 @@ ListHeaderBox _launcher.browseAircraftModel.ratingsFilterEnabled = checked } - label: qsTr("Filter aircraft based on rating") + label: qsTr("Filter using ratings") anchors.verticalCenter: parent.verticalCenter }, + Text { + anchors { + verticalCenter: parent.verticalCenter + leftMargin: Style.margin + left: doFilterCheck.right + right: adjustRatingsText.left + } + text: _launcher.browseAircraftModel.summaryText + }, + ClickableText { + id: adjustRatingsText anchors.right: parent.right anchors.rightMargin: Style.margin text: qsTr("Adjust minimum ratings") diff --git a/src/GUI/AircraftSearchFilterModel.cxx b/src/GUI/AircraftSearchFilterModel.cxx index a95246d69..7e90e027c 100644 --- a/src/GUI/AircraftSearchFilterModel.cxx +++ b/src/GUI/AircraftSearchFilterModel.cxx @@ -21,6 +21,7 @@ void AircraftProxyModel::setRatings(QList ratings) m_ratings = ratings; invalidate(); emit ratingsChanged(); + emit summaryTextChanged(); } void AircraftProxyModel::setAircraftFilterString(QString s) @@ -61,6 +62,17 @@ void AircraftProxyModel::setRatingFilterEnabled(bool e) m_ratingsFilter = e; invalidate(); emit ratingsFilterEnabledChanged(); + emit summaryTextChanged(); +} + +QString AircraftProxyModel::summaryText() const +{ + const int unfilteredCount = sourceModel()->rowCount(); + if (m_ratingsFilter) { + return tr("(%1 of %2 aircraft)").arg(rowCount()).arg(unfilteredCount); + } + + return tr("(%1 aircraft)").arg(unfilteredCount); } void AircraftProxyModel::setInstalledFilterEnabled(bool e) diff --git a/src/GUI/AircraftSearchFilterModel.hxx b/src/GUI/AircraftSearchFilterModel.hxx index 8ad073729..43ddf2fb5 100644 --- a/src/GUI/AircraftSearchFilterModel.hxx +++ b/src/GUI/AircraftSearchFilterModel.hxx @@ -15,6 +15,8 @@ public: Q_PROPERTY(bool ratingsFilterEnabled READ ratingsFilterEnabled WRITE setRatingFilterEnabled NOTIFY ratingsFilterEnabledChanged) + Q_PROPERTY(QString summaryText READ summaryText NOTIFY summaryTextChanged) + Q_INVOKABLE void setAircraftFilterString(QString s); /** @@ -37,9 +39,12 @@ public: void setRatings(QList ratings); void setRatingFilterEnabled(bool e); + + QString summaryText() const; signals: void ratingsChanged(); void ratingsFilterEnabledChanged(); + void summaryTextChanged(); public slots: