From f2b80db9c4dd18e59f8b606e113d9f15cd891c5d Mon Sep 17 00:00:00 2001 From: Arno Date: Sat, 22 Sep 2012 07:11:55 +0200 Subject: 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! --- mappingtreemodel.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'mappingtreemodel.h') 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(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 mMappingTypes; QList mValidMappings; QList mSelectedMappings; + QMap mMappings; const QString mForbidden; int mType; }; -- cgit v1.2.3-70-g09d2