diff -r 94ed4372ef08 -r 2d4cc445a86a vymmodel.cpp --- a/vymmodel.cpp Thu Mar 19 11:45:28 2009 +0000 +++ b/vymmodel.cpp Mon Mar 23 09:06:51 2009 +0000 @@ -73,7 +73,7 @@ delete mapCenters.takeFirst(); QModelIndex ri=index(rootItem); - removeRows (0, rowCount(ri),ri); + //removeRows (0, rowCount(ri),ri); // FIXME here should be at least a beginRemoveRows... } void VymModel::init () @@ -233,17 +233,17 @@ s+=xml.beginElement("vymmap",mapAttr); xml.incIndent(); - // Find the used flags while traversing the tree + // Find the used flags while traversing the tree // FIXME this can be done local to vymmodel maybe... standardFlagsDefault->resetUsedCounter(); // Reset the counters before saving // TODO constr. of FIO creates lots of objects, better do this in some other way... - FloatImageObj (mapScene).resetSaveCounter(); + FloatImageObj (mapScene).resetSaveCounter();// FIXME this can be done local to vymmodel maybe... // Build xml recursivly if (!saveSel || typeid (*saveSel) == typeid (MapCenterObj)) - // Save complete map, if saveSel not set - s+=saveToDir(tmpdir,prefix,writeflags,offset); + // Save all mapcenters as complete map, if saveSel not set + s+=saveTreeToDir(tmpdir,prefix,writeflags,offset); else { if ( typeid(*saveSel) == typeid(BranchObj) ) @@ -269,6 +269,15 @@ return s; } +QString VymModel::saveTreeToDir (const QString &tmpdir,const QString &prefix, int verbose, const QPointF &offset) +{ + QString s; + + for (int i=0; isaveToDir (tmpdir,prefix,verbose,offset); + return s; +} + void VymModel::setFilePath(QString fpath, QString destname) { if (fpath.isEmpty() || fpath=="") @@ -1409,15 +1418,6 @@ return NULL; } -QString VymModel::saveToDir (const QString &tmpdir,const QString &prefix, int verbose, const QPointF &offset) -{ - QString s; - - for (int i=0; isaveToDir (tmpdir,prefix,verbose,offset); - return s; -} - ////////////////////////////////////////////// // Interface ////////////////////////////////////////////// @@ -2032,6 +2032,14 @@ mapCenters.append(mapCenter); // Create TreeItem + QModelIndex parix=index(rootItem); + + int n=rootItem->branchCount(); + cout << "VM::addMapCenter n="< cData; cData << "VM:addMapCenter" << "undef"<<"undef"; TreeItem *ti=new TreeItem (cData,rootItem); @@ -2040,6 +2048,20 @@ mapCenter->setTreeItem (ti); rootItem->appendChild (ti); + endInsertRows(); + emit (newChildObject (parix)); + emit (layoutChanged() ); + + // Testing +/* + qWarning ("MW::insertRow a"); + if (!insertRow(0, parix)) + { + std::cout << " war nix...\n"; + } + qWarning ("MW::insertRow b"); +*/ + return mapCenter; } @@ -2084,12 +2106,22 @@ // Create TreeItem QList cData; - cData << "VM:createBranch" << "undef"<<"undef"; + cData << "new" << "undef"<<"undef"; + TreeItem *parti=bo->getTreeItem(); + QModelIndex parix=index(parti); + int n=parti->branchCount(); + + emit (layoutAboutToBeChanged() ); + beginInsertRows (parix,n,n+1); TreeItem *ti=new TreeItem (cData,parti); ti->setLMO (newbo); ti->setType (TreeItem::Branch); + parti->appendChild (ti); + endInsertRows (); + emit (newChildObject (parix)); + emit (layoutChanged() ); if (newbo) { @@ -2101,12 +2133,12 @@ { num=bo->getNum()+1; bo=(BranchObj*)bo->getParObj(); - if (bo) newbo=bo->insertBranch(num); + if (bo) newbo=bo->insertBranch(num); //FIXME VM still missing }else if (num==-3) { num=bo->getNum(); bo=(BranchObj*)bo->getParObj(); - if (bo) newbo=bo->insertBranch(num); + if (bo) newbo=bo->insertBranch(num); //FIXME VM still missing } } return newbo; @@ -2165,7 +2197,8 @@ BranchObj *parbo=(BranchObj*)(bo->getParObj()); // add below selection - newbo=parbo->insertBranch(bo->getNum()+1); + newbo=parbo->insertBranch(bo->getNum()+1); //FIXME VM still missing + if (newbo) { newbo->move2RelPos (p); @@ -2186,15 +2219,24 @@ void VymModel::deleteSelection() { - BranchObj *bo = getSelectedBranch(); + BranchObj *bo = getSelectedBranch(); // FIXME VM should not be necessary + if (!bo) return; + + QModelIndex ix=getSelectedIndex(); + if (!ix.isValid() ) return; + + QModelIndex parentIndex=parent(ix); + if (!parentIndex.isValid()) return; + TreeItem *ti=bo->getTreeItem(); - if (bo && selectionType()==TreeItem::MapCenter) + if (selectionType()==TreeItem::MapCenter) //FIXME VM still missing { // BranchObj* par=(BranchObj*)(bo->getParObj()); - selection.unselect(); - /* FIXME VM Note: does saveStateRemovingPart work for MCO? (No parent!) + //selection.unselect(); + /* FIXME VM Note: does saveStateRemovingPart work for MCO? (No parent!) saveStateRemovingPart (bo, QString ("Delete %1").arg(getObjectName(bo))); */ + /* bo=removeMapCenter ((MapCenterObj*)bo); if (bo) { @@ -2204,22 +2246,34 @@ } reposition(); return; + */ } - if (bo && selectionType()==TreeItem::Branch) + if (selectionType()==TreeItem::Branch) { - QModelIndex ix=getSelectedIndex(); + int n=ti->branchCount(); BranchObj* par=(BranchObj*)bo->getParObj(); unselect(); saveStateRemovingPart (bo, QString ("Delete %1").arg(getObjectName(bo))); + + emit (layoutAboutToBeChanged() ); + + cout << "VM::delete ti="<