forked from go-qamel/qamel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tablemodel.h
76 lines (61 loc) · 2.06 KB
/
tablemodel.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
64
65
66
67
68
69
70
71
72
73
74
75
76
#pragma once
#ifndef QAMEL_TABLEMODEL_H
#define QAMEL_TABLEMODEL_H
#ifdef __cplusplus
#include <QQmlEngine>
#include <QAbstractTableModel>
#include <QVariant>
#include <QHash>
#include <QByteArray>
#include <QString>
class QamelTableModel : public QAbstractTableModel
{
Q_OBJECT
Q_PROPERTY(int columns READ columns WRITE setColumns NOTIFY columnsChanged)
Q_PROPERTY(QVariantList contents READ contents WRITE setContents NOTIFY contentsChanged)
Q_PROPERTY(QVariantMap columnsName READ columnsName WRITE setColumnsName NOTIFY columnsNameChanged)
public:
int rowCount(const QModelIndex & = QModelIndex()) const override;
int columnCount(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;
int columns() const;
QVariantList contents() const;
QVariantMap columnsName() const;
public slots:
void setColumns(int);
void setContents(QVariantList);
void setColumnsName(QVariantMap columnsName);
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 columnsChanged();
void contentsChanged();
void columnsNameChanged();
private:
int _columns;
QVariantList _contents;
QVariantMap _columnsName;
QString getColumnName(int) const;
};
extern "C" {
#endif // __cplusplus
// Register QML
void QamelTableModel_RegisterQML(char* uri, int versionMajor, int versionMinor, char* qmlName);
#ifdef __cplusplus
}
#endif
#endif // QAMEL_TABLEMODEL_H