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... :( --- picfilesmodel.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'picfilesmodel.cpp') diff --git a/picfilesmodel.cpp b/picfilesmodel.cpp index 651ce32..cab7235 100644 --- a/picfilesmodel.cpp +++ b/picfilesmodel.cpp @@ -40,7 +40,7 @@ PicFilesModel::~PicFilesModel(){ } void PicFilesModel::setMapping(int pMapId){ - QList ids = mMappingTreeModel->childList(pMapId, MappingTreeModel::MapParentId); + QList ids = mMappingTreeModel->childList(pMapId, MappingTreeModel::MyId); mMappingIds.clear(); foreach(QVariant i, ids){ mMappingIds << i.toInt(); @@ -170,9 +170,9 @@ QList PicFilesModel::mappingDataFromFiles(const QList fileIds) } QList retval; foreach(int pId, parentIds){ - QModelIndex curIdx = mMappingTreeModel->findRecursive(pId, MappingTreeModel::MapParentId, mMappingTreeModel->rootIndex()); + QModelIndex curIdx = mMappingTreeModel->findRecursive(pId, MappingTreeModel::MyId, mMappingTreeModel->rootIndex()); MappingData curData; - curData.id = curIdx.data(MappingTreeModel::MapParentIdRole).toInt(); + curData.id = curIdx.data(MappingTreeModel::MyIdRole).toInt(); curData.name = curIdx.data(MappingTreeModel::NameRole).toString(); curData.path << mMappingTreeModel->path(curIdx); //.join("/"); retval << curData; -- cgit v1.2.3-70-g09d2