diff -r 371945eb6d31 -r bef71af3f6ab xml-vym.cpp --- a/xml-vym.cpp Mon Jan 14 16:26:59 2008 +0000 +++ b/xml-vym.cpp Mon Jan 14 16:27:00 2008 +0000 @@ -68,6 +68,8 @@ if ( state == StateInit && (eName == "vymmap") ) { state = StateMap; + + // Check version if (!atts.value( "version").isEmpty() ) { if (!checkVersion(atts.value("version"))) @@ -79,55 +81,51 @@ ". If you run into problems after pressing " "the ok-button below, updating vym should help."); else - mc->setVersion(atts.value( "version" )); + model->setVersion(atts.value( "version" )); } - if (loadMode==NewMap || - (loadMode==ImportReplace && me->getSelection()==mc)) + + if (loadMode==NewMap ) { + // Create mapCenter + model->clear(); + lastBranch=model->first(); // avoid empty pointer + if (!atts.value( "author").isEmpty() ) - { - mc->setAuthor(atts.value( "author" ) ); - } + model->setAuthor(atts.value( "author" ) ); if (!atts.value( "comment").isEmpty() ) - { - mc->setComment (atts.value( "comment" ) ); - } + model->setComment (atts.value( "comment" ) ); if (!atts.value( "backgroundColor").isEmpty() ) { col.setNamedColor(atts.value("backgroundColor")); - mc->getScene()->setBackgroundBrush(col); + model->getScene()->setBackgroundBrush(col); } if (!atts.value( "selectionColor").isEmpty() ) { col.setNamedColor(atts.value("selectionColor")); - me->setSelectionColor(col); + model->getMapEditor()->setSelectionColor(col); } if (!atts.value( "linkColorHint").isEmpty() ) { if (atts.value("linkColorHint")=="HeadingColor") - me->setMapLinkColorHint(LinkableMapObj::HeadingColor); + model->getMapEditor()->setMapLinkColorHint(LinkableMapObj::HeadingColor); else - me->setMapLinkColorHint(LinkableMapObj::DefaultColor); + model->getMapEditor()->setMapLinkColorHint(LinkableMapObj::DefaultColor); } if (!atts.value( "linkStyle").isEmpty() ) - { - me->setMapLinkStyle(atts.value("linkStyle")); - } + model->getMapEditor()->setMapLinkStyle(atts.value("linkStyle")); if (!atts.value( "linkColor").isEmpty() ) { col.setNamedColor(atts.value("linkColor")); - me->setMapDefLinkColor(col); + model->getMapEditor()->setMapDefLinkColor(col); } if (!atts.value( "defXLinkColor").isEmpty() ) { col.setNamedColor(atts.value("defXLinkColor")); - me->setMapDefXLinkColor(col); + model->getMapEditor()->setMapDefXLinkColor(col); } if (!atts.value( "defXLinkWidth").isEmpty() ) - { - me->setMapDefXLinkWidth(atts.value("defXLinkWidth").toInt ()); - } + model->getMapEditor()->setMapDefXLinkWidth(atts.value("defXLinkWidth").toInt ()); } } else if ( eName == "select" && state == StateMap ) { @@ -143,12 +141,15 @@ if (loadMode==NewMap) { // Really use the found mapcenter as MCO in a new map - lastBranch=mc; // avoid empty pointer + + // FIXME not working for multiple mapCenters yet: + lastBranch=model->addMapCenter(); + //lastBranch=model->first(); // avoid empty pointer } else { // Treat the found mapcenter as a branch // in an existing map - LinkableMapObj* lmo=me->getSelection(); + LinkableMapObj* lmo=model->getSelection(); if (lmo && (typeid(*lmo) == typeid(BranchObj) ) || (typeid(*lmo) == typeid(MapCenterObj) ) ) { @@ -197,14 +198,14 @@ { // This is used in vymparts, which have no mapcenter! isVymPart=true; - LinkableMapObj* lmo=me->getSelection(); + LinkableMapObj* lmo=model->getSelection(); if (!lmo) { // If a vym part is _loaded_ (not imported), // selection==lmo==NULL // Treat it like ImportAdd then... loadMode=ImportAdd; - lmo=mc; + lmo=model->first(); // FIXME this used to be lmo=mc before } if (lmo && (typeid(*lmo) == typeid(BranchObj) ) || (typeid(*lmo) == typeid(MapCenterObj) ) ) @@ -320,7 +321,7 @@ case StateInit: break; case StateMap: break; case StateMapSelect: - me->select(ch_simplified); + model->select(ch_simplified); break; case StateMapSetting:break; case StateMapCenter: break; @@ -539,7 +540,7 @@ { lastFloat->setRelPos (QPointF (x,y) ); // make sure floats in mapcenter are repositioned to relative pos - if (mc==lastBranch) mc->positionContents(); + if (lastBranch->getDepth()==0) lastBranch->positionContents(); } else // Couldn't read relPos @@ -561,7 +562,7 @@ QColor col; bool okx; bool success=false; - XLinkObj *xlo=new XLinkObj (mc->getScene()); + XLinkObj *xlo=new XLinkObj (model->getScene()); if (!a.value( "color").isEmpty() ) { col.setNamedColor(a.value("color")); @@ -578,11 +579,11 @@ { if (!a.value( "endBranch").isEmpty() ) { - LinkableMapObj *lmo=mc->findObjBySelect (a.value( "beginBranch")); + LinkableMapObj *lmo=model->findObjBySelect (a.value( "beginBranch")); if (lmo && typeid (*lmo)==typeid (BranchObj)) { xlo->setBegin ((BranchObj*)lmo); - lmo=mc->findObjBySelect (a.value( "endBranch")); + lmo=model->findObjBySelect (a.value( "endBranch")); if (lmo && typeid (*lmo)==typeid (BranchObj)) { xlo->setEnd ((BranchObj*)(lmo)); @@ -598,11 +599,11 @@ { if (!a.value( "endID").isEmpty() ) { - LinkableMapObj *lmo=mc->findID (a.value( "beginID")); + LinkableMapObj *lmo=model->findID (a.value( "beginID")); if (lmo && typeid (*lmo)==typeid (BranchObj)) { xlo->setBegin ((BranchObj*)lmo); - lmo=mc->findID (a.value( "endID")); + lmo=model->findID (a.value( "endID")); if (lmo && typeid (*lmo)==typeid (BranchObj)) { xlo->setEnd ((BranchObj*)(lmo)); @@ -628,7 +629,7 @@ if (!a.value( "key").isEmpty() ) { if (!a.value( "value").isEmpty() ) - settings.setLocalEntry (me->getDestPath(), a.value ("key"), a.value ("value")); + settings.setLocalEntry (model->getMapEditor()->getDestPath(), a.value ("key"), a.value ("value")); else return false;