1
0
Fork 0

Launcher aircraft list: show counts

This commit is contained in:
James Turner 2017-12-12 16:34:54 +00:00
parent 595b0d16da
commit f964728422
3 changed files with 29 additions and 1 deletions

View file

@ -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")

View file

@ -21,6 +21,7 @@ void AircraftProxyModel::setRatings(QList<int> 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)

View file

@ -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<int> ratings);
void setRatingFilterEnabled(bool e);
QString summaryText() const;
signals:
void ratingsChanged();
void ratingsFilterEnabledChanged();
void summaryTextChanged();
public slots: