-
Notifications
You must be signed in to change notification settings - Fork 19
/
listmodel.h
63 lines (49 loc) · 1.53 KB
/
listmodel.h
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#pragma once
#ifndef QAMEL_TABLEMODEL_H
#define QAMEL_TABLEMODEL_H
#ifdef __cplusplus
#include <QQmlEngine>
#include <QAbstractListModel>
#include <QVariant>
#include <QHash>
#include <QByteArray>
#include <QString>
class QamelListModel : public QAbstractListModel
{
Q_OBJECT
Q_PROPERTY(QVariantList contents READ contents WRITE setContents NOTIFY contentsChanged)
public:
int rowCount(const QModelIndex & = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role) const override;
QHash<int, QByteArray> roleNames() const override;
bool insertRows(int, int, const QModelIndex & = QModelIndex()) override;
bool removeRows(int, int, const QModelIndex & = QModelIndex()) override;
bool moveRows(const QModelIndex &, int, int, const QModelIndex &, int) override;
QVariantList contents() const;
public slots:
void setContents(QVariantList);
QVariant get(int);
int count();
void clear();
void insertRow(int, QVariant);
void insertRows(int, QVariantList);
void appendRow(QVariant);
void appendRows(QVariantList);
void deleteRows(int, int);
void setRow(int, QVariantMap);
void setRowProperty(int, QString, QVariant);
void swapRow(int, int);
void moveRows(int, int, int);
signals:
void contentsChanged();
private:
QVariantList _contents;
};
extern "C" {
#endif // __cplusplus
// Register QML
void QamelListModel_RegisterQML(char* uri, int versionMajor, int versionMinor, char* qmlName);
#ifdef __cplusplus
}
#endif
#endif // QAMEL_TABLEMODEL_H