f3a1c10b24
The HistoryPopup was caching its contents rather early, and we failed to tell the model when its underlying data updated. Connect that through so the history model refreshes also. https://sourceforge.net/p/flightgear/codetickets/2036/
44 lines
913 B
C++
44 lines
913 B
C++
#ifndef RECENTAIRCRAFTMODEL_HXX
|
|
#define RECENTAIRCRAFTMODEL_HXX
|
|
|
|
#include <QAbstractListModel>
|
|
#include <QUrl>
|
|
|
|
// forward decls
|
|
class AircraftItemModel;
|
|
|
|
class RecentAircraftModel : public QAbstractListModel
|
|
{
|
|
Q_OBJECT
|
|
|
|
Q_PROPERTY(bool isEmpty READ isEmpty NOTIFY isEmptyChanged)
|
|
public:
|
|
RecentAircraftModel(AircraftItemModel *acModel, QObject* pr = nullptr);
|
|
|
|
QVariant data(const QModelIndex &index, int role) const override;
|
|
|
|
int rowCount(const QModelIndex &parent) const override;
|
|
|
|
QHash<int, QByteArray> roleNames() const override;
|
|
|
|
QUrl mostRecent() const;
|
|
|
|
void insert(QUrl aircraftUrl);
|
|
|
|
void saveToSettings();
|
|
|
|
Q_INVOKABLE QUrl uriAt(int index) const;
|
|
|
|
bool isEmpty() const;
|
|
|
|
signals:
|
|
void isEmptyChanged();
|
|
|
|
private:
|
|
void onModelContentsChanged();
|
|
|
|
AircraftItemModel* m_aircraftModel;
|
|
QList<QUrl> m_data;
|
|
};
|
|
|
|
#endif // RECENTAIRCRAFTMODEL_HXX
|