diff options
author | Arno <am@disconnect.de> | 2012-09-22 07:11:55 +0200 |
---|---|---|
committer | Arno <am@disconnect.de> | 2012-09-22 07:11:55 +0200 |
commit | f2b80db9c4dd18e59f8b606e113d9f15cd891c5d (patch) | |
tree | b3eddefe7ae6dddc7821db30892a33f133a50325 /mappingtreemodel.h | |
parent | 7cab312d14f79136b8c40507e24523ca5b6dc1e7 (diff) | |
download | SheMov-f2b80db9c4dd18e59f8b606e113d9f15cd891c5d.tar.gz SheMov-f2b80db9c4dd18e59f8b606e113d9f15cd891c5d.tar.bz2 SheMov-f2b80db9c4dd18e59f8b606e113d9f15cd891c5d.zip |
MappingTreeModel Fix: repair parent <-> child relationship
Warning: this commit seems to work, but it doesn't!
Introduce two new tables: mappings_parents2 and pics_mappings2 to create
a real parent-child relationship. The pics_mappings need to reference a
unique mappings_parents_id so the same mapping can be a child of
different parents.
For now only the MappingTree references the new tables. Everything else
uses the old ones. Hence the warning!
Diffstat (limited to 'mappingtreemodel.h')
-rw-r--r-- | mappingtreemodel.h | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/mappingtreemodel.h b/mappingtreemodel.h index 396484a..ce64ba6 100644 --- a/mappingtreemodel.h +++ b/mappingtreemodel.h @@ -20,9 +20,9 @@ class SmTreeItem; class MappingTreeModel : public SmTreeModel { Q_OBJECT public: - enum Roles { NameRole = Qt::UserRole + 1, IdRole = Qt::UserRole + 2, AddedRole = Qt::UserRole + 3 }; - enum Fields { Name = 0, Id = 1, Added = 2 }; - enum { NumFields = 3 }; + enum Roles { NameRole = Qt::UserRole + 1, IdRole = Qt::UserRole + 2, AddedRole = Qt::UserRole + 3, ParentRole = Qt::UserRole + 4 }; + enum Fields { Name = 0, Id = 1, Added = 2, Parent = 3 }; + enum { NumFields = 4 }; MappingTreeModel(QStringList &headers, QObject *parent = 0); ~MappingTreeModel(); @@ -54,7 +54,7 @@ class MappingTreeModel : public SmTreeModel { public slots: void populate(); - void setType(int type) { mType = type; } + void setType(int type); // { mType = type; } signals: void mappingTypesChanged(); @@ -65,6 +65,8 @@ class MappingTreeModel : public SmTreeModel { QVariant id; QVariant name; }; + void getMappings(); + int addChild(const QString &name, int type); void getMappingTypes(); void getChildrenRecursive(SmTreeItem *item); QStringList getPathsRecursive(SmTreeItem *parent) const; @@ -74,7 +76,7 @@ class MappingTreeModel : public SmTreeModel { QList<MappingData> mappingData(SmTreeItem *item); QSqlDatabase mDb; QSqlQuery *mTypesQ; - QSqlQuery *mTypeParentsQ; + QString mSParentsQ; QSqlQuery *mUpdateTypeQ; QSqlQuery *mUpdateChildQ; QSqlQuery *mAddMappingTypeQ; @@ -86,9 +88,11 @@ class MappingTreeModel : public SmTreeModel { QSqlQuery *mUpdateParentQ; QSqlQuery *mDeleteMappingParentQ; QSqlQuery *mMappingsForFileIdQ; + QSqlQuery *mMappingsQ; QList<mappingType> mMappingTypes; QList<MappingData> mValidMappings; QList<SmTreeItem*> mSelectedMappings; + QMap<QString, int> mMappings; const QString mForbidden; int mType; }; |