-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
toolbarmodel.h
74 lines (69 loc) · 2.08 KB
/
toolbarmodel.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
#ifndef TOOLBARMODEL_H
#define TOOLBARMODEL_H
#include <QAbstractListModel>
#include <QVector>
#include <QObject>
class ToolbarItems : public QObject
{
Q_OBJECT
public:
ToolbarItems();
//
void setVector(const QVector<int>& nv);
const QVector<int>& getToolbarElems() const { return toolbar_elems; }
const QVector<bool>& getAllElems() const { return elems; }
//
void swap(int pos0, int pos1);
void move(int pos0, int pos1);
void insert(int id, int pos);
void remove(int pos);
//
inline bool isUsed(int id) const { return elems[id]; }
signals:
void reset();
private:
QVector<int> toolbar_elems; // id's of elems
QVector<bool> elems;
};
class ItemModel : public QAbstractListModel
{
public:
ItemModel(ToolbarItems& t_items);
int rowCount(const QModelIndex & = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
Qt::ItemFlags flags(const QModelIndex &index) const;
//
QStringList mimeTypes() const;
QMimeData* mimeData(const QModelIndexList& indexes) const;
bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent);
#if QT_VERSION < 0x050000
Qt::DropActions supportedDragActions() const;
#endif
Qt::DropActions supportedDropActions() const;
private:
ToolbarItems& items;
const QVector<bool>& v;
};
class ItemToolbarModel : public QAbstractListModel
{
public:
ItemToolbarModel(ToolbarItems& t_items);
int rowCount(const QModelIndex& = QModelIndex()) const;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
Qt::ItemFlags flags(const QModelIndex &index) const;
//
QStringList mimeTypes() const;
QMimeData* mimeData(const QModelIndexList& indexes) const;
bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent);
#if QT_VERSION < 0x050000
Qt::DropActions supportedDragActions() const;
#endif
Qt::DropActions supportedDropActions() const;
//
QModelIndex up(const QModelIndex& index);
QModelIndex down(const QModelIndex& index);
private:
ToolbarItems& items;
const QVector<int>& v;
};
#endif // TOOLBARMODEL_H