| 1 |
#ifndef QMLVARIANTLISTMODEL_H |
| 2 |
#define QMLVARIANTLISTMODEL_H |
| 3 |
|
| 4 |
#include <QObject> |
| 5 |
#include <QAbstractListModel> |
| 6 |
#include <QList> |
| 7 |
#include <QVariant> |
| 8 |
|
| 9 |
class QmlVariantListModel : public QAbstractListModel |
| 10 |
{ |
| 11 |
Q_OBJECT |
| 12 |
Q_PROPERTY(int count READ count NOTIFY countChanged) |
| 13 |
public: |
| 14 |
explicit QmlVariantListModel(QObject *parent = 0); |
| 15 |
|
| 16 |
QHash<int, QByteArray> rolenames() const; |
| 17 |
QVariant data(const QModelIndex &index, int role) const; |
| 18 |
bool setData(const QModelIndex &index, const QVariant &value, int role); |
| 19 |
int rowCount(const QModelIndex &parent = QModelIndex()) const; |
| 20 |
|
| 21 |
signals: |
| 22 |
void countChanged(); |
| 23 |
|
| 24 |
public slots: |
| 25 |
void append(const QVariant &value); |
| 26 |
void appendList(const QVariantList &values); |
| 27 |
int count() const; |
| 28 |
void clear(); |
| 29 |
QVariant get(int index); |
| 30 |
bool isEmpty() const; |
| 31 |
void insert(int index, const QVariant &value); |
| 32 |
void insertList(int index, const QVariantList &values); |
| 33 |
QVariantList list() const; |
| 34 |
void move(int index, int to); |
| 35 |
void prepend(const QVariant &value); |
| 36 |
void prependList(const QVariantList &values); |
| 37 |
void replace(int index, const QVariant &value); |
| 38 |
void remove(int index); |
| 39 |
|
| 40 |
private: |
| 41 |
void countPossiblyChanged(); |
| 42 |
|
| 43 |
QVariantList m_values; |
| 44 |
int m_count; |
| 45 |
}; |
| 46 |
|
| 47 |
#endif |