From dc7cc269a4fffe43bdac2ae2dc6548fbd1e3bb5e Mon Sep 17 00:00:00 2001 From: Arno Date: Sat, 27 Oct 2012 13:02:16 +0200 Subject: Fix archiving pictures Well, what can I say. Lost in recursion and parent pointers. This commit actually boils down to using the proper database tables and inserting the right values. 'Nuff said... --- picfilesmodel.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'picfilesmodel.cpp') diff --git a/picfilesmodel.cpp b/picfilesmodel.cpp index cab7235..56d9522 100644 --- a/picfilesmodel.cpp +++ b/picfilesmodel.cpp @@ -135,16 +135,16 @@ void PicFilesModel::removeFiles(const QList &files){ } } -bool PicFilesModel::changeMappings(const QList &fileIds, const QList &mappingIds){ +bool PicFilesModel::changeMappings(const QList &fileIds, const QList &parentIds){ mDb.transaction(); foreach(int fid, fileIds){ mDeleteMappingsQ->bindValue(":id", fid); if(!mDeleteMappingsQ->exec()){ goto error; } - foreach(int mid, mappingIds){ + foreach(QVariant pid, parentIds){ mAddMappingsQ->bindValue(":pid", fid); - mAddMappingsQ->bindValue(":id", mid); + mAddMappingsQ->bindValue(":id", pid); if(!mAddMappingsQ->exec()){ goto error; } @@ -172,7 +172,9 @@ QList PicFilesModel::mappingDataFromFiles(const QList fileIds) foreach(int pId, parentIds){ QModelIndex curIdx = mMappingTreeModel->findRecursive(pId, MappingTreeModel::MyId, mMappingTreeModel->rootIndex()); MappingData curData; - curData.id = curIdx.data(MappingTreeModel::MyIdRole).toInt(); + //curData.id = curIdx.data(MappingTreeModel::MyIdRole).toInt(); + curData.mappingId = curIdx.data(MappingTreeModel::MappingIdRole).toInt(); + curData.parentId = curIdx.data(MappingTreeModel::ParentIdRole).toInt(); curData.name = curIdx.data(MappingTreeModel::NameRole).toString(); curData.path << mMappingTreeModel->path(curIdx); //.join("/"); retval << curData; -- cgit v1.2.3-70-g09d2