summaryrefslogtreecommitdiffstats
path: root/archivemodel.cpp
diff options
context:
space:
mode:
authorArno <am@disconnect.de>2013-09-28 08:55:45 +0200
committerArno <am@disconnect.de>2013-09-28 08:55:45 +0200
commit697541ea2c50ba97fc4b4e31e9e7c4d82be51899 (patch)
tree1f8e724c653a1f69fe0ece21dcb5409300af87e3 /archivemodel.cpp
parent09df993cd04065196279ce2c8c375df0d9080f78 (diff)
downloadSheMov-697541ea2c50ba97fc4b4e31e9e7c4d82be51899.tar.gz
SheMov-697541ea2c50ba97fc4b4e31e9e7c4d82be51899.tar.bz2
SheMov-697541ea2c50ba97fc4b4e31e9e7c4d82be51899.zip
Fix copy constructor of SmTreeItem
Seems the copy constructor of SmTreeItem was botched. After copying a rootItem, some children wouldn't show up. I guess it has something to do with the QHash of the parents. Replace it with an explictit deep copy function where needed.
Diffstat (limited to 'archivemodel.cpp')
-rw-r--r--archivemodel.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/archivemodel.cpp b/archivemodel.cpp
index 75f6509..b4a1e2b 100644
--- a/archivemodel.cpp
+++ b/archivemodel.cpp
@@ -976,11 +976,25 @@ ArchiveCollector::ArchiveCollector(int numFields, int order, QObject *parent) :
SmTreeItem *ArchiveCollector::rootItem(){
mAccessMx.lock();
- SmTreeItem *retval = new SmTreeItem(*mRootItem);
+ SmTreeItem *retval = copyRecursive(mRootItem, 0);
mAccessMx.unlock();
return retval;
}
+SmTreeItem *ArchiveCollector::copyRecursive(SmTreeItem *item, SmTreeItem *parent){
+ SmTreeItem *newItem = new SmTreeItem(*item);
+ newItem->setParent(parent);
+ if(parent){
+ parent->appendChild(newItem);
+ }
+ if(item->childCount()){
+ for(int i = 0; i < item->childCount(); ++i){
+ copyRecursive(item->child(i), newItem);
+ }
+ }
+ return newItem;
+}
+
void ArchiveCollector::setCancelled(bool cancel){
QMutexLocker l(&mCancelledMx);
mCancelled = cancel;