From e2d4843586d84da62e325d1cb0025a795b162c1c Mon Sep 17 00:00:00 2001 From: Arno Date: Sat, 6 Oct 2012 11:02:42 +0200 Subject: More fixes to MappingTreeModel Fix move, addChild and such. Rename Fields and Roles to more speaking names, but that revealed a much deeper bug: the ParentID isn't really the parent_id, but the mapping_id. That could explain a lot. Nevertheless, it's still faster to repopulate the model after moving oder adding children instead of calling removeRows and insertRows. Another non-working commit... :( --- mappingtreemodel.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'mappingtreemodel.h') diff --git a/mappingtreemodel.h b/mappingtreemodel.h index b2fa9eb..beb7d7f 100644 --- a/mappingtreemodel.h +++ b/mappingtreemodel.h @@ -21,8 +21,8 @@ class SmTreeItem; class MappingTreeModel : public SmTreeModel { Q_OBJECT public: - enum Roles { NameRole = Qt::UserRole + 1, IdRole = Qt::UserRole + 2, AddedRole = Qt::UserRole + 3, MapParentIdRole = Qt::UserRole + 4 }; - enum Fields { Name = 0, Id = 1, Added = 2, MapParentId = 3 }; + enum Roles { NameRole = Qt::UserRole + 1, ParentIdRole = Qt::UserRole + 2, AddedRole = Qt::UserRole + 3, MyIdRole = Qt::UserRole + 4 }; + enum Fields { Name = 0, ParentId = 1, Added = 2, MyId = 3 }; enum { NumFields = 4 }; MappingTreeModel(QStringList &headers, QObject *parent = 0); ~MappingTreeModel(); @@ -41,7 +41,7 @@ class MappingTreeModel : public SmTreeModel { QStringList path(QModelIndex &idx) const; QModelIndex indexFromPath(const QString &path, int column = 0) const; bool setData(const QModelIndex &index, const QVariant &value, int role); - void move(const QModelIndex &source, const QModelIndex &dest); + bool move(const QModelIndex &source, const QModelIndex &dest); bool addMappingType(const QString &type); bool deleteMappingType(int typeId); bool addChild(const QVariant &name, const QModelIndex &parent); -- cgit v1.2.3-70-g09d2