Choice model settings was added
This commit is contained in:
47
viewmodels/settingsviewmodel.h
Normal file
47
viewmodels/settingsviewmodel.h
Normal file
@@ -0,0 +1,47 @@
|
||||
#ifndef SETTINGSVIEWMODEL_H
|
||||
#define SETTINGSVIEWMODEL_H
|
||||
|
||||
#include <QAbstractListModel>
|
||||
|
||||
#include "models/basemodel.h"
|
||||
|
||||
class SettingsViewModel : public QAbstractListModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SettingsViewModel(QObject *parent = nullptr);
|
||||
|
||||
int rowCount(const QModelIndex &parent) const override;
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
QHash<int, QByteArray> roleNames() const override;
|
||||
|
||||
private:
|
||||
enum Roles {
|
||||
Title = Qt::UserRole + 1,
|
||||
PropertyName,
|
||||
ControlType,
|
||||
Model
|
||||
};
|
||||
|
||||
struct SettingItem
|
||||
{
|
||||
QString title;
|
||||
QString propertyName;
|
||||
QString controlType;
|
||||
QString modelName;
|
||||
|
||||
SettingItem(const QString &title, const QString &propertyName, const QString &controlType, const QString &modelName = {}) :
|
||||
title(title),
|
||||
propertyName(propertyName),
|
||||
controlType(controlType),
|
||||
modelName(modelName) {}
|
||||
};
|
||||
|
||||
QVariant model(const QString &modelName) const;
|
||||
|
||||
QList<SettingItem> m_items;
|
||||
QMap<QString, BaseModel *> m_models;
|
||||
};
|
||||
|
||||
#endif // SETTINGSVIEWMODEL_H
|
||||
Reference in New Issue
Block a user