1
0
Fork 0
flightgear/src/GUI/PathListModel.hxx
2020-03-10 10:28:56 +00:00

56 lines
1.2 KiB
C++

#ifndef PATHLISTMODEL_HXX
#define PATHLISTMODEL_HXX
#include <vector>
#include <QAbstractListModel>
const int PathRole = Qt::UserRole + 1;
const int PathEnabledRole = Qt::UserRole + 2;
class PathListModel : public QAbstractListModel
{
Q_OBJECT
Q_PROPERTY(int count READ count NOTIFY countChanged)
public:
PathListModel(QObject* pr);
~PathListModel() override;
void loadFromSettings(QString key);
void saveToSettings(QString key) const;
int rowCount(const QModelIndex& parent) const override;
QVariant data(const QModelIndex& index, int role) const override;
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
QHash<int, QByteArray> roleNames() const override;
static QStringList readEnabledPaths(QString settingsKey);
QStringList enabledPaths() const;
int count();
signals:
void enabledPathsChanged();
void countChanged();
public slots:
void removePath(int index);
void appendPath(QString path);
void swapIndices(int indexA, int indexB);
private:
struct PathEntry {
QString path;
bool enabled = true;
};
std::vector<PathEntry> mPaths;
};
#endif // PATHLISTMODEL_HXX