-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDataModel.h
More file actions
46 lines (37 loc) · 1.22 KB
/
DataModel.h
File metadata and controls
46 lines (37 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef DATAMODEL_H
#define DATAMODEL_H
#include <QAbstractListModel>
class DataModel : public QAbstractListModel
{
Q_OBJECT
public:
DataModel(const QString& flag);
typedef struct ProgramInfo {
QString name;
QString iconUrl;
QString execCmd;
QString cmdPara;
} ProgramInfo;
enum Role {
NameRole = Qt::UserRole + 1,
IconRole,
ExecRole,
ParaRole
};
// QAbstractListModel overrides
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
QHash<int, QByteArray> roleNames() const override;
Q_INVOKABLE void execProgram(int index,const QList<QString>& parameters);
Q_INVOKABLE QStringList getItem(int index) const;
Q_INVOKABLE void setItem(int index, QStringList content);
Q_INVOKABLE void exchangeItem(int index1, int index2);
Q_INVOKABLE void addItem(QStringList content);
Q_INVOKABLE void deleteItem(int index);
Q_INVOKABLE void readFromFile();
Q_INVOKABLE void writeToFile();
private:
QList<ProgramInfo> m_programList;
QString m_recordFileUrl = "./programRecord.ini";;
};
#endif // DATAMODEL_H