diff options
Diffstat (limited to 'common/modelresult.h')
-rw-r--r-- | common/modelresult.h | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/common/modelresult.h b/common/modelresult.h index 062517f..0f0c06a 100644 --- a/common/modelresult.h +++ b/common/modelresult.h | |||
@@ -28,11 +28,12 @@ | |||
28 | #include "query.h" | 28 | #include "query.h" |
29 | #include "resultprovider.h" | 29 | #include "resultprovider.h" |
30 | 30 | ||
31 | template<class T, class Ptr> | 31 | template <class T, class Ptr> |
32 | class ModelResult : public QAbstractItemModel | 32 | class ModelResult : public QAbstractItemModel |
33 | { | 33 | { |
34 | public: | 34 | public: |
35 | enum Roles { | 35 | enum Roles |
36 | { | ||
36 | DomainObjectRole = Qt::UserRole + 1, | 37 | DomainObjectRole = Qt::UserRole + 1, |
37 | ChildrenFetchedRole, | 38 | ChildrenFetchedRole, |
38 | DomainObjectBaseRole | 39 | DomainObjectBaseRole |
@@ -46,7 +47,7 @@ public: | |||
46 | int columnCount(const QModelIndex &parent = QModelIndex()) const; | 47 | int columnCount(const QModelIndex &parent = QModelIndex()) const; |
47 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; | 48 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; |
48 | QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; | 49 | QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; |
49 | QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const; | 50 | QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; |
50 | QModelIndex parent(const QModelIndex &index) const; | 51 | QModelIndex parent(const QModelIndex &index) const; |
51 | bool hasChildren(const QModelIndex &parent = QModelIndex()) const; | 52 | bool hasChildren(const QModelIndex &parent = QModelIndex()) const; |
52 | 53 | ||
@@ -66,7 +67,7 @@ private: | |||
66 | QModelIndex createIndexFromId(const qint64 &id) const; | 67 | QModelIndex createIndexFromId(const qint64 &id) const; |
67 | void fetchEntities(const QModelIndex &parent); | 68 | void fetchEntities(const QModelIndex &parent); |
68 | 69 | ||
69 | //TODO we should be able to directly use T as index, with an appropriate hash function, and thus have a QMap<T, T> and QList<T> | 70 | // TODO we should be able to directly use T as index, with an appropriate hash function, and thus have a QMap<T, T> and QList<T> |
70 | QMap<qint64 /* entity id */, Ptr> mEntities; | 71 | QMap<qint64 /* entity id */, Ptr> mEntities; |
71 | QMap<qint64 /* parent entity id */, QList<qint64> /* child entity id*/> mTree; | 72 | QMap<qint64 /* parent entity id */, QList<qint64> /* child entity id*/> mTree; |
72 | QMap<qint64 /* child entity id */, qint64 /* parent entity id*/> mParents; | 73 | QMap<qint64 /* child entity id */, qint64 /* parent entity id*/> mParents; |
@@ -77,4 +78,3 @@ private: | |||
77 | std::function<void(const Ptr &)> loadEntities; | 78 | std::function<void(const Ptr &)> loadEntities; |
78 | typename Sink::ResultEmitter<Ptr>::Ptr mEmitter; | 79 | typename Sink::ResultEmitter<Ptr>::Ptr mEmitter; |
79 | }; | 80 | }; |
80 | |||