/
birdmodel.h
executable file
·64 lines (55 loc) · 1.75 KB
/
birdmodel.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
#ifndef BIRDMODEL_H
#define BIRDMODEL_H
#include <QAbstractListModel>
#include "bird.h"
class BirdModel : public QAbstractListModel
{
Q_OBJECT
public:
explicit BirdModel(QObject *parent = 0);
enum Roles
{
FilterRole = Qt::UserRole + 1, // 33
IndexRole,
IdRole,
FinNameRole, // 36
SweNameRole,
AbbrevRole,
LatinNameRole,
FinGroupRole, // 40
SweGroupRole,
LatinGroupRole,
CategoryRole, // 43
EngNameRole,
EngGroupRole, // 45
SweNameOnlyRole,
SweGroupOnlyRole,
EngNameOnlyRole,
EngGroupOnlyRole, // 49
SectionRole,
EmptyRole1,
EmptyRole2,
EmptyRole3,
IsCustomRole, // 54
LocalizedNameRole,
LocalizedGroupRole,
SortingNameRole = Qt::UserRole + 100
};
signals:
public slots:
Q_INVOKABLE QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
Q_INVOKABLE int rowCount(const QModelIndex &parent = QModelIndex()) const;
Q_INVOKABLE void clear();
Q_INVOKABLE void addItem(const Bird &item);
Q_INVOKABLE bool removeRow (int row, const QModelIndex & parent = QModelIndex());
Q_INVOKABLE bool removeRows (int row, int count, const QModelIndex & parent = QModelIndex());
Q_INVOKABLE Bird getItem(int index) const;
Q_INVOKABLE bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole);
Q_INVOKABLE void replaceItem(int row, const Bird &item);
void setContent(const QList<Bird> &newItems);
QList<Bird> content() const;
private:
QList<Bird> items;
QHash<int, QByteArray> roles;
};
#endif // BIRDMODEL_H