-
Notifications
You must be signed in to change notification settings - Fork 0
/
basicmodel.h
73 lines (69 loc) · 3.37 KB
/
basicmodel.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
#ifndef BASICMODEL_H
#define BASICMODEL_H
#include "stdafx.h"
#include <QModelIndex>
#include <QAbstractItemModel>
#include <QObject>
#include "basicmodelitem.h"
#include "ddmimedata.h"
#include "imageitem.h"
struct DropPoint
{
int row;
int column;
QModelIndex parent;
};
class BasicModel : public QAbstractItemModel
{
Q_OBJECT
public:
explicit BasicModel(QObject *parent = 0);
explicit BasicModel(QList<QList<QVariant> > headers, QObject *parent = 0);
explicit BasicModel(QList<QList<QVariant> > _horisontalHeaders, QList<QList<QVariant> > _verticalHeaders, QObject *parent = 0);
void emptyHeaders(Qt::Orientation orientation);
~BasicModel();
QVariant data(const QModelIndex &index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const;
QModelIndex index(int row, int column,
const QModelIndex &parent = QModelIndex()) const;
QModelIndex parent(const QModelIndex &index) const;
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole );
bool setItemData(const QModelIndex &index, const QList<QList<QVariant> > &data);
BasicModelItem* getRootNode();
void setRootNode(BasicModelItem* item);
void setRootNodeData(QList<QList<QVariant> > data);
void AddItem(BasicModelItem* item, BasicModelItem* parent = 0);
virtual void AddBlankItem();
void removeItem(QModelIndex item);
BasicModelItem* getItem(const QModelIndex &index) const;
Qt::ItemFlags flags(const QModelIndex &index) const;
void empty();
// bool insertColumns(int position, int columns, const QModelIndex &parent = QModelIndex());
// bool removeColumns(int position, int columns, const QModelIndex &parent = QModelIndex());
bool insertRows(int position, int rows, const QModelIndex &parent = QModelIndex());
bool insertRows(int position, int rows, QList<QList<QVariant> >data, const QModelIndex &parent = QModelIndex());
bool insertRows(int position, int rows, BasicModelItem* item, const QModelIndex &parent);
bool removeRows(int position, int rows, const QModelIndex &parent = QModelIndex());
virtual QStringList mimeTypes() const;
virtual QMimeData* mimeData(const QModelIndexList &indexes) const;
virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);
Qt::DropActions supportedDropActions() const;
virtual bool canDropMimeData(const QMimeData * data,
Qt::DropAction action,
int row,
int column,
const QModelIndex & parent) const;
BasicModelItem* createItem(QString type, QList<QList<QVariant> >data);
QModelIndexList virtual parseDropData(QModelIndexList indexes);
QList<QList<QVariant> > verticalHeaders;
protected:
BasicModelItem* _root;
DropPoint findParentForDrop(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex parent);
signals:
public slots:
private:
};
#endif // BASICMODEL_H