Aircraft update list gets its own tab
This commit is contained in:
parent
2212e9342f
commit
7a0483281d
8 changed files with 85 additions and 50 deletions
|
@ -247,8 +247,6 @@ void AircraftItemModel::refreshPackages()
|
|||
}
|
||||
|
||||
emit dataChanged(index(firstRow), index(firstRow + newSize - 1));
|
||||
m_cachedUpdateCount = m_packageRoot->packagesNeedingUpdate().size();
|
||||
emit aircraftNeedingUpdatedChanged();
|
||||
}
|
||||
|
||||
int AircraftItemModel::rowCount(const QModelIndex& parent) const
|
||||
|
@ -701,22 +699,4 @@ bool AircraftItemModel::isIndexRunnable(const QModelIndex& index) const
|
|||
return !ex->isDownloading();
|
||||
}
|
||||
|
||||
int AircraftItemModel::aircraftNeedingUpdated() const
|
||||
{
|
||||
return m_cachedUpdateCount;
|
||||
}
|
||||
|
||||
bool AircraftItemModel::showUpdateAll() const
|
||||
{
|
||||
return (m_cachedUpdateCount > 0) && m_showUpdateAll;
|
||||
}
|
||||
|
||||
void AircraftItemModel::setShowUpdateAll(bool showUpdateAll)
|
||||
{
|
||||
if (m_showUpdateAll == showUpdateAll)
|
||||
return;
|
||||
|
||||
m_showUpdateAll = showUpdateAll;
|
||||
emit aircraftNeedingUpdatedChanged();
|
||||
}
|
||||
|
||||
|
|
|
@ -66,9 +66,6 @@ class AircraftItemModel : public QAbstractListModel
|
|||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(int aircraftNeedingUpdated READ aircraftNeedingUpdated NOTIFY aircraftNeedingUpdatedChanged)
|
||||
Q_PROPERTY(bool showUpdateAll READ showUpdateAll WRITE setShowUpdateAll NOTIFY aircraftNeedingUpdatedChanged)
|
||||
|
||||
public:
|
||||
|
||||
AircraftItemModel(QObject* pr);
|
||||
|
@ -110,20 +107,12 @@ public:
|
|||
*/
|
||||
QString nameForAircraftURI(QUrl uri) const;
|
||||
|
||||
int aircraftNeedingUpdated() const;
|
||||
|
||||
bool showUpdateAll() const;
|
||||
|
||||
signals:
|
||||
void aircraftInstallFailed(QModelIndex index, QString errorMessage);
|
||||
|
||||
void aircraftInstallCompleted(QModelIndex index);
|
||||
|
||||
void aircraftNeedingUpdatedChanged();
|
||||
|
||||
void catalogsRefreshed();
|
||||
public slots:
|
||||
void setShowUpdateAll(bool showUpdateAll);
|
||||
|
||||
private slots:
|
||||
void onScanStarted();
|
||||
|
@ -165,9 +154,7 @@ private:
|
|||
simgear::pkg::PackageList m_packages;
|
||||
|
||||
mutable QHash<QString, QPixmap> m_downloadedPixmapCache;
|
||||
int m_cachedUpdateCount = 0;
|
||||
int m_cachedLocalAircraftCount = 0;
|
||||
bool m_showUpdateAll = true;
|
||||
};
|
||||
|
||||
#endif // of FG_GUI_AIRCRAFT_MODEL
|
||||
|
|
|
@ -15,6 +15,10 @@ AircraftProxyModel::AircraftProxyModel(QObject *pr, QAbstractItemModel * source)
|
|||
|
||||
// kick off initial sort
|
||||
sort(0);
|
||||
|
||||
connect(this, &QAbstractItemModel::rowsInserted, this, &AircraftProxyModel::countChanged);
|
||||
connect(this, &QAbstractItemModel::rowsRemoved, this, &AircraftProxyModel::countChanged);
|
||||
connect(this, &QAbstractItemModel::modelReset, this, &AircraftProxyModel::countChanged);
|
||||
}
|
||||
|
||||
void AircraftProxyModel::setRatings(QList<int> ratings)
|
||||
|
@ -78,6 +82,11 @@ QString AircraftProxyModel::summaryText() const
|
|||
return tr("(%1 aircraft)").arg(unfilteredCount);
|
||||
}
|
||||
|
||||
int AircraftProxyModel::count() const
|
||||
{
|
||||
return rowCount();
|
||||
}
|
||||
|
||||
void AircraftProxyModel::setInstalledFilterEnabled(bool e)
|
||||
{
|
||||
if (e == m_onlyShowInstalled) {
|
||||
|
@ -88,6 +97,15 @@ void AircraftProxyModel::setInstalledFilterEnabled(bool e)
|
|||
invalidate();
|
||||
}
|
||||
|
||||
void AircraftProxyModel::setHaveUpdateFilterEnabled(bool e)
|
||||
{
|
||||
if (e == m_onlyShowWithUpdate)
|
||||
return;
|
||||
|
||||
m_onlyShowWithUpdate = e;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
bool AircraftProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
|
||||
{
|
||||
QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
|
||||
|
@ -105,6 +123,21 @@ bool AircraftProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sour
|
|||
}
|
||||
}
|
||||
|
||||
if (m_onlyShowWithUpdate) {
|
||||
QVariant v = index.data(AircraftPackageStatusRole);
|
||||
const auto status = static_cast<LocalAircraftCache::PackageStatus>(v.toInt());
|
||||
switch (status) {
|
||||
case LocalAircraftCache::PackageNotInstalled:
|
||||
case LocalAircraftCache::PackageInstalled:
|
||||
case LocalAircraftCache::NotPackaged:
|
||||
return false; // no updated need / possible
|
||||
|
||||
// otherwise, show in the update list
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// if there is no search active, i.e we are browsing, we might apply the
|
||||
// ratings filter.
|
||||
if (m_filterString.isEmpty() && !m_onlyShowInstalled && m_ratingsFilter) {
|
||||
|
|
|
@ -19,6 +19,8 @@ public:
|
|||
|
||||
Q_INVOKABLE void setAircraftFilterString(QString s);
|
||||
|
||||
Q_PROPERTY(int count READ count NOTIFY countChanged)
|
||||
|
||||
/**
|
||||
* Compute the row (index in QML / ListView speak) based on an aircraft URI.
|
||||
* Return -1 if the UIR is not present in the (filtered) model
|
||||
|
@ -41,15 +43,19 @@ public:
|
|||
void setRatingFilterEnabled(bool e);
|
||||
|
||||
QString summaryText() const;
|
||||
|
||||
int count() const;
|
||||
signals:
|
||||
void ratingsChanged();
|
||||
void ratingsFilterEnabledChanged();
|
||||
void summaryTextChanged();
|
||||
void countChanged();
|
||||
|
||||
public slots:
|
||||
|
||||
void setInstalledFilterEnabled(bool e);
|
||||
|
||||
void setHaveUpdateFilterEnabled(bool e);
|
||||
protected:
|
||||
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
|
||||
|
||||
|
@ -58,6 +64,8 @@ private:
|
|||
|
||||
bool m_ratingsFilter = true;
|
||||
bool m_onlyShowInstalled = false;
|
||||
bool m_onlyShowWithUpdate = false;
|
||||
|
||||
QList<int> m_ratings;
|
||||
QString m_filterString;
|
||||
SGPropertyNode_ptr m_filterProps;
|
||||
|
|
|
@ -75,6 +75,10 @@ LauncherController::LauncherController(QObject *parent, QWindow* window) :
|
|||
m_installedAircraftModel = new AircraftProxyModel(this, m_aircraftModel);
|
||||
m_installedAircraftModel->setInstalledFilterEnabled(true);
|
||||
|
||||
m_aircraftWithUpdatesModel = new AircraftProxyModel(this, m_aircraftModel);
|
||||
m_aircraftWithUpdatesModel->setInstalledFilterEnabled(true);
|
||||
m_aircraftWithUpdatesModel->setHaveUpdateFilterEnabled(true);
|
||||
|
||||
m_browseAircraftModel = new AircraftProxyModel(this, m_aircraftModel);
|
||||
m_browseAircraftModel->setRatingFilterEnabled(true);
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@ class LauncherController : public QObject
|
|||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(AircraftProxyModel* installedAircraftModel MEMBER m_installedAircraftModel CONSTANT)
|
||||
Q_PROPERTY(AircraftProxyModel* aircraftWithUpdatesModel MEMBER m_aircraftWithUpdatesModel CONSTANT)
|
||||
Q_PROPERTY(AircraftProxyModel* browseAircraftModel MEMBER m_browseAircraftModel CONSTANT)
|
||||
Q_PROPERTY(AircraftProxyModel* searchAircraftModel MEMBER m_aircraftSearchModel CONSTANT)
|
||||
|
||||
|
@ -230,6 +231,7 @@ private:
|
|||
AircraftItemModel* m_aircraftModel;
|
||||
AircraftProxyModel* m_aircraftSearchModel;
|
||||
AircraftProxyModel* m_browseAircraftModel;
|
||||
AircraftProxyModel* m_aircraftWithUpdatesModel;
|
||||
MPServersModel* m_serversModel = nullptr;
|
||||
LocationController* m_location = nullptr;
|
||||
|
||||
|
|
|
@ -39,6 +39,17 @@ Item
|
|||
}
|
||||
active: root.state == "browse"
|
||||
}
|
||||
|
||||
TabButton {
|
||||
id: updatesButton
|
||||
// visible: _launcher.baseAircraftModel.showUpdateAll
|
||||
text: qsTr("Updates")
|
||||
onClicked: {
|
||||
root.state = "updates"
|
||||
aircraftList.updateSelectionFromLauncher();
|
||||
}
|
||||
active: root.state == "updates"
|
||||
}
|
||||
} // of header row
|
||||
|
||||
SearchButton {
|
||||
|
@ -154,6 +165,21 @@ Item
|
|||
}
|
||||
}
|
||||
|
||||
StyledText {
|
||||
id: noUpdatesMessage
|
||||
anchors {
|
||||
left: parent.left
|
||||
top: tabBar.bottom
|
||||
bottom: parent.bottom
|
||||
right: scrollbar.left
|
||||
}
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
font.pixelSize: Style.headingFontPixelSize
|
||||
text: qsTr("No aircraft updates available right now")
|
||||
visible: (root.state == "updates") && (_launcher.aircraftWithUpdatesModel.count == 0)
|
||||
}
|
||||
|
||||
Scrollbar {
|
||||
id: scrollbar
|
||||
anchors.right: parent.right
|
||||
|
@ -170,7 +196,6 @@ Item
|
|||
PropertyChanges {
|
||||
target: aircraftList
|
||||
model: _launcher.installedAircraftModel
|
||||
header: _launcher.baseAircraftModel.showUpdateAll ? updateAllHeader : null
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -190,6 +215,15 @@ Item
|
|||
model: _launcher.browseAircraftModel
|
||||
header: _addOns.showNoOfficialHangar ? noDefaultCatalogHeader : ratingsHeader
|
||||
}
|
||||
},
|
||||
|
||||
State {
|
||||
name: "updates"
|
||||
PropertyChanges {
|
||||
target: aircraftList
|
||||
model: _launcher.aircraftWithUpdatesModel
|
||||
header: (_launcher.aircraftWithUpdatesModel.count > 0) ? updateAllHeader : null
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ ListHeaderBox {
|
|||
}
|
||||
|
||||
text: qsTr("%1 aircraft have updates available - download and install them now?").
|
||||
arg( _launcher.baseAircraftModel.aircraftNeedingUpdated);
|
||||
arg(_launcher.aircraftWithUpdatesModel.count)
|
||||
wrapMode: Text.WordWrap
|
||||
},
|
||||
|
||||
|
@ -24,24 +24,11 @@ ListHeaderBox {
|
|||
id: updateAllButton
|
||||
text: qsTr("Update all")
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.right: notNowButton.left
|
||||
anchors.rightMargin: Style.margin
|
||||
|
||||
onClicked: {
|
||||
_launcher.requestUpdateAllAircraft();
|
||||
_launcher.baseAircraftModel.showUpdateAll = false
|
||||
}
|
||||
},
|
||||
|
||||
Button {
|
||||
id: notNowButton
|
||||
text: qsTr("Not now")
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: Style.margin
|
||||
|
||||
onClicked: {
|
||||
_launcher.baseAircraftModel.showUpdateAll = false
|
||||
_launcher.requestUpdateAllAircraft();
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
Loading…
Add table
Reference in a new issue