From f295cfb8672d97bb5c804499bdb311a9a0d8039b Mon Sep 17 00:00:00 2001 From: Arno Date: Sun, 29 Jun 2014 09:41:30 +0200 Subject: Major rework of MappingTreeResultView + Model Well, I hope this fixes the crashes for good. String comparison for looking up the parents really wasn't a prudent thing to do... Use the ParentIds instead. --- mappingtreemodel.h | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'mappingtreemodel.h') diff --git a/mappingtreemodel.h b/mappingtreemodel.h index efc4e2d..a730aaa 100644 --- a/mappingtreemodel.h +++ b/mappingtreemodel.h @@ -33,18 +33,14 @@ class MappingTreeModel : public SmTreeModel { //data QVariant data(const QModelIndex &index, int role) const; QList childList(const QVariant &value, int column = 0) const; - QStringList path(QModelIndex &idx) const; - QModelIndex indexFromPath(const QString &path, int column = 0) const; + QModelIndex indexFromParentPath(const QList &pPath, bool reverse) const; bool setData(const QModelIndex &idx, const QVariant &value, int role); - 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); bool renameChild(const QModelIndex &idx, const QString newName); bool deleteChild(const QModelIndex &idx); MappingData mappingDataFromIndex(QModelIndex &idx) const; - QStringList paths() const; - const QString &forbidden() const { return mForbidden; } const QSqlError &lastError() const { return mLastError; } public slots: @@ -65,7 +61,6 @@ class MappingTreeModel : public SmTreeModel { void getMappingTypes(); void getChildrenRecursive(SmTreeItem *item); bool updateChild(SmTreeItem *item, const QVariant &value); - QStringList getPathsRecursive(SmTreeItem *parent) const; QList getChildListRecursive(SmTreeItem *item, int column) const; QString basePath(SmTreeItem *item) const; int lowerBound(SmTreeItem *item, const QVariant &value, int column = 0) const; @@ -88,8 +83,8 @@ class MappingTreeResultModel : public SmTreeModel { //data + flags Qt::ItemFlags flags(const QModelIndex &index) const; - bool setData(const QModelIndex &index, const QVariant &value, int role); - QModelIndex insertChild(const QVariant &data, int mappingId, int parentId, int descId, SmTreeItem *parent); + virtual QVariant data(const QModelIndex &index, int role) const; + virtual bool setData(const QModelIndex &index, const QVariant &value, int role); QList columnValues(int column) const; void clearData(); @@ -105,12 +100,10 @@ struct MappingData { MappingData(); bool isValid(); int mappingId; - int parentId; int descId; QString name; - QList path; + QList parents; + QStringList path; }; -Q_DECLARE_METATYPE(QList) - #endif // MAPPINGTREEMODEL_H -- cgit v1.2.3-70-g09d2