# HG changeset patch # User insilmaril # Date 1170073753 0 # Node ID d886c77ac0fec26a1a7fda74fda32e51857eb2ec # Parent 7019762f8701dcb095c6a8f845457accfcd2f8b7 minor fixes diff -r 7019762f8701 -r d886c77ac0fe demos/todo.vym Binary file demos/todo.vym has changed diff -r 7019762f8701 -r d886c77ac0fe exports.cpp --- a/exports.cpp Tue Jan 23 11:50:56 2007 +0000 +++ b/exports.cpp Mon Jan 29 12:29:13 2007 +0000 @@ -26,9 +26,9 @@ removeDir (tmpDir); } -void ExportBase::setDir(const QString &p) +void ExportBase::setDir(const QDir &d) { - outputDir=p; + outDir=d; } void ExportBase::setFile (const QString &p) @@ -59,6 +59,7 @@ fd->setFilter (filter); fd->setCaption(caption); fd->setMode( QFileDialog::AnyFile ); + fd->setDir (outDir); fd->show(); if ( fd->exec() == QDialog::Accepted ) diff -r 7019762f8701 -r d886c77ac0fe exports.h --- a/exports.h Tue Jan 23 11:50:56 2007 +0000 +++ b/exports.h Mon Jan 29 12:29:13 2007 +0000 @@ -15,7 +15,7 @@ public: ExportBase(); virtual ~ExportBase(); - virtual void setDir(const QString &); + virtual void setDir(const QDir&); virtual void setFile(const QString &); virtual void setMapCenter (MapCenterObj*); virtual void setCaption(const QString &); @@ -25,7 +25,7 @@ virtual QString getSectionString (BranchObj*); QDir tmpDir; - QString outputDir; + QDir outDir; QString outputFile; MapCenterObj *mapCenter; QString indentPerDepth; diff -r 7019762f8701 -r d886c77ac0fe mainwindow.cpp --- a/mainwindow.cpp Tue Jan 23 11:50:56 2007 +0000 +++ b/mainwindow.cpp Mon Jan 29 12:29:13 2007 +0000 @@ -2249,6 +2249,7 @@ ExportASCII ex; ex.setMapCenter(me->getMapCenter()); ex.addFilter ("TXT (*.txt)"); + ex.setDir(lastImageDir); ex.setCaption(vymName+ " -" +tr("Export as ASCII")+" "+tr("(still experimental)")); if (ex.execDialog() ) { @@ -2267,6 +2268,7 @@ ExportLaTeX ex; ex.setMapCenter(me->getMapCenter()); ex.addFilter ("Tex (*.tex)"); + ex.setDir(lastImageDir); ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)")); if (ex.execDialog() ) { @@ -2296,6 +2298,7 @@ { ex.setMapCenter (me->getMapCenter() ); ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)")); + ex.setDir(lastImageDir); ex.addFilter ("Taskjuggler (*.tjp)"); if (ex.execDialog() ) { diff -r 7019762f8701 -r d886c77ac0fe mapeditor.cpp --- a/mapeditor.cpp Tue Jan 23 11:50:56 2007 +0000 +++ b/mapeditor.cpp Mon Jan 29 12:29:13 2007 +0000 @@ -95,12 +95,10 @@ copyingObj=false; editingBO=NULL; - selection=NULL; - selectionLast=NULL; movingObj=NULL; xelection.setMapCenter (mapCenter); - xelection.clear(); + xelection.unselect(); defXLinkWidth=1; defXLinkColor=QColor (230,230,230); @@ -257,8 +255,8 @@ s+=settings.getXMLData (destPath); // Save selection - if (selection && !saveSel ) - s+=valueElement("select",selection->getSelectString()); + if (!xelection.isEmpty() && !saveSel ) + s+=valueElement("select",xelection.getSelectString()); decIndent(); s+=endElement("vymmap"); @@ -428,6 +426,7 @@ void MapEditor::parseAtom(const QString &atom) { + BranchObj *selb=xelection.getBranch(); API api; QString s,t; int x,y; @@ -440,11 +439,10 @@ // External commands if (com=="addBranch") { - if (!selection) + if (xelection.isEmpty()) { api.setError (Aborted,"Nothing selected"); - } else if ( (typeid(*selection) != typeid(BranchObj) && - typeid(*selection) != typeid(MapCenterObj)) ) + } else if (! selb ) { api.setError (Aborted,"Type of selection is not a branch"); } else @@ -464,11 +462,10 @@ } } else if (com=="addBranchBefore") { - if (!selection) + if (xelection.isEmpty()) { api.setError (Aborted,"Nothing selected"); - } else if ( (typeid(*selection) != typeid(BranchObj) && - typeid(*selection) != typeid(MapCenterObj)) ) + } else if (! selb ) { api.setError (Aborted,"Type of selection is not a branch"); } else @@ -480,11 +477,10 @@ } } else if (com==QString("addMapReplace")) { - if (!selection) + if (xelection.isEmpty()) { api.setError (Aborted,"Nothing selected"); - } else if ( (typeid(*selection) != typeid(BranchObj) && - typeid(*selection) != typeid(MapCenterObj)) ) + } else if (! selb ) { api.setError (Aborted,"Type of selection is not a branch"); } else if (api.checkParamCount(1)) @@ -492,15 +488,14 @@ //s=api.parString (ok,0); // selection t=api.parString (ok,0); // path to map if (QDir::isRelativePath(t)) t=QDir::convertSeparators (tmpMapDir + "/"+t); - addMapReplaceInt(selection->getSelectString(),t); + addMapReplaceInt(selb->getSelectString(),t); } } else if (com==QString("addMapInsert")) { - if (!selection) + if (xelection.isEmpty()) { api.setError (Aborted,"Nothing selected"); - } else if ( (typeid(*selection) != typeid(BranchObj) && - typeid(*selection) != typeid(MapCenterObj)) ) + } else if (! selb ) { api.setError (Aborted,"Type of selection is not a branch"); } else @@ -515,11 +510,10 @@ } } else if (com=="colorBranch") { - if (!selection) + if (xelection.isEmpty()) { api.setError (Aborted,"Nothing selected"); - } else if ( typeid(*selection) != typeid(BranchObj) && - typeid(*selection) != typeid(MapCenterObj)) + } else if (! selb ) { api.setError (Aborted,"Type of selection is not a branch"); } else if (api.checkParamCount(1)) @@ -529,11 +523,10 @@ } } else if (com=="colorSubtree") { - if (!selection) + if (xelection.isEmpty()) { api.setError (Aborted,"Nothing selected"); - } else if ( typeid(*selection) != typeid(BranchObj) && - typeid(*selection) != typeid(MapCenterObj)) + } else if (! selb ) { api.setError (Aborted,"Type of selection is not a branch"); } else if (api.checkParamCount(1)) @@ -543,12 +536,12 @@ } } else if (com=="cut") { - if (!selection) + if (xelection.isEmpty()) { api.setError (Aborted,"Nothing selected"); - } else if ( typeid(*selection) != typeid(BranchObj) && - typeid(*selection) != typeid(MapCenterObj) && - typeid(*selection) != typeid(FloatImageObj) ) + } else if ( xelection.type()!=Branch && + xelection.type()!=MapCenter && + xelection.type()!=FloatImage ) { api.setError (Aborted,"Type of selection is not a branch or floatimage"); } else if (api.checkParamCount(0)) @@ -557,12 +550,11 @@ } } else if (com=="delete") { - if (!selection) + if (xelection.isEmpty()) { api.setError (Aborted,"Nothing selected"); - } else if ( (typeid(*selection) != typeid(BranchObj) && - typeid(*selection) != typeid(MapCenterObj)) ) - { + } else if (! selb ) + { api.setError (Aborted,"Type of selection is not a branch"); } else if (api.checkParamCount(0)) { @@ -570,12 +562,11 @@ } } else if (com=="deleteKeepChilds") { - if (!selection) + if (xelection.isEmpty()) { api.setError (Aborted,"Nothing selected"); - } else if ( (typeid(*selection) != typeid(BranchObj) && - typeid(*selection) != typeid(MapCenterObj)) ) - { + } else if (! selb ) + { api.setError (Aborted,"Type of selection is not a branch"); } else if (api.checkParamCount(0)) { @@ -583,12 +574,11 @@ } } else if (com=="deleteChilds") { - if (!selection) + if (xelection.isEmpty()) { api.setError (Aborted,"Nothing selected"); - } else if ( (typeid(*selection) != typeid(BranchObj) && - typeid(*selection) != typeid(MapCenterObj)) ) - { + } else if (! selb) + { api.setError (Aborted,"Type of selection is not a branch"); } else if (api.checkParamCount(0)) { @@ -596,11 +586,10 @@ } } else if (com=="linkTo") { - if (!selection) + if (xelection.isEmpty()) { api.setError (Aborted,"Nothing selected"); - } else if ( (typeid(*selection) == typeid(BranchObj) || - typeid(*selection) == typeid(MapCenterObj)) ) + } else if ( selb) { if (api.checkParamCount(4)) { @@ -616,21 +605,21 @@ // Get number in parent x=api.parInt (ok,1); if (ok) - ((BranchObj*)selection)->linkTo ((BranchObj*)(dst),x); + selb->linkTo ((BranchObj*)(dst),x); } else if (typeid(*dst) == typeid(MapCenterObj) ) { - ((BranchObj*)selection)->linkTo ((BranchObj*)(dst),-1); + selb->linkTo ((BranchObj*)(dst),-1); // Get coordinates of mainbranch x=api.parInt (ok,2); if (ok) { y=api.parInt (ok,3); - if (ok) ((BranchObj*)selection)->move (x,y); + if (ok) selb->move (x,y); } } } } - } else if ( typeid(*selection) != typeid(FloatImageObj)) + } else if ( xelection.type() == FloatImage) { if (api.checkParamCount(1)) { @@ -649,11 +638,10 @@ api.setError (Aborted,"Type of selection is not a floatimage or branch"); } else if (com=="moveBranchUp") { - if (!selection) + if (xelection.isEmpty() ) { api.setError (Aborted,"Nothing selected"); - } else if ( (typeid(*selection) != typeid(BranchObj) && - typeid(*selection) != typeid(MapCenterObj)) ) + } else if (! selb ) { api.setError (Aborted,"Type of selection is not a branch"); } else if (api.checkParamCount(0)) @@ -662,11 +650,10 @@ } } else if (com=="moveBranchDown") { - if (!selection) + if (xelection.isEmpty() ) { api.setError (Aborted,"Nothing selected"); - } else if ( (typeid(*selection) != typeid(BranchObj) && - typeid(*selection) != typeid(MapCenterObj)) ) + } else if (! selb ) { api.setError (Aborted,"Type of selection is not a branch"); } else if (api.checkParamCount(0)) @@ -675,12 +662,12 @@ } } else if (com=="move") { - if (!selection) + if (xelection.isEmpty() ) { api.setError (Aborted,"Nothing selected"); - } else if ( typeid(*selection) != typeid(BranchObj) && - typeid(*selection) != typeid(MapCenterObj) && - typeid(*selection) != typeid(FloatImageObj) ) + } else if ( xelection.type()!=Branch && + xelection.type()!=MapCenter && + xelection.type()!=FloatImage ) { api.setError (Aborted,"Type of selection is not a branch or floatimage"); } else if (api.checkParamCount(2)) @@ -694,12 +681,12 @@ } } else if (com=="moveRel") { - if (!selection) + if (xelection.isEmpty() ) { api.setError (Aborted,"Nothing selected"); - } else if ( typeid(*selection) != typeid(BranchObj) && - typeid(*selection) != typeid(MapCenterObj) && - typeid(*selection) != typeid(FloatImageObj) ) + } else if ( xelection.type()!=Branch && + xelection.type()!=MapCenter && + xelection.type()!=FloatImage ) { api.setError (Aborted,"Type of selection is not a branch or floatimage"); } else if (api.checkParamCount(2)) @@ -713,11 +700,10 @@ } } else if (com=="paste") { - if (!selection) + if (xelection.isEmpty() ) { api.setError (Aborted,"Nothing selected"); - } else if ( typeid(*selection) != typeid(BranchObj) && - typeid(*selection) != typeid(MapCenterObj) ) + } else if (! selb ) { api.setError (Aborted,"Type of selection is not a branch"); } else if (api.checkParamCount(0)) @@ -747,11 +733,10 @@ } } else if (com=="setMapBackgroundColor") { - if (!selection) + if (xelection.isEmpty() ) { api.setError (Aborted,"Nothing selected"); - } else if ( (typeid(*selection) != typeid(BranchObj) && - typeid(*selection) != typeid(MapCenterObj)) ) + } else if (! xelection.getBranch() ) { api.setError (Aborted,"Type of selection is not a branch"); } else if (api.checkParamCount(1)) @@ -761,11 +746,10 @@ } } else if (com=="setMapDefLinkColor") { - if (!selection) + if (xelection.isEmpty() ) { api.setError (Aborted,"Nothing selected"); - } else if ( (typeid(*selection) != typeid(BranchObj) && - typeid(*selection) != typeid(MapCenterObj)) ) + } else if (! selb ) { api.setError (Aborted,"Type of selection is not a branch"); } else if (api.checkParamCount(1)) @@ -782,11 +766,10 @@ } } else if (com=="setHeading") { - if (!selection) + if (xelection.isEmpty() ) { api.setError (Aborted,"Nothing selected"); - } else if ( (typeid(*selection) != typeid(BranchObj) && - typeid(*selection) != typeid(MapCenterObj)) ) + } else if (! selb ) { api.setError (Aborted,"Type of selection is not a branch"); } else if (api.checkParamCount(1)) @@ -797,11 +780,10 @@ } } else if (com=="setHideExport") { - if (!selection) + if (xelection.isEmpty() ) { api.setError (Aborted,"Nothing selected"); - } else if ( typeid(*selection) != typeid(BranchObj) && - typeid(*selection) != typeid(FloatImageObj) ) + } else if (! selb) { api.setError (Aborted,"Type of selection is not a branch or floatimage"); } else if (api.checkParamCount(1)) @@ -811,11 +793,10 @@ } } else if (com=="setURL") { - if (!selection) + if (xelection.isEmpty() ) { api.setError (Aborted,"Nothing selected"); - } else if ( (typeid(*selection) != typeid(BranchObj) && - typeid(*selection) != typeid(MapCenterObj)) ) + } else if (! selb ) { api.setError (Aborted,"Type of selection is not a branch"); } else if (api.checkParamCount(1)) @@ -825,11 +806,10 @@ } } else if (com=="setVymLink") { - if (!selection) + if (xelection.isEmpty() ) { api.setError (Aborted,"Nothing selected"); - } else if ( (typeid(*selection) != typeid(BranchObj) && - typeid(*selection) != typeid(MapCenterObj)) ) + } else if (! selb ) { api.setError (Aborted,"Type of selection is not a branch"); } else if (api.checkParamCount(1)) @@ -840,11 +820,10 @@ } else if (com=="setFlag") { - if (!selection) + if (xelection.isEmpty() ) { api.setError (Aborted,"Nothing selected"); - } else if ( (typeid(*selection) != typeid(BranchObj) && - typeid(*selection) != typeid(MapCenterObj)) ) + } else if (! selb ) { api.setError (Aborted,"Type of selection is not a branch"); } else if (api.checkParamCount(1)) @@ -852,19 +831,17 @@ s=api.parString(ok,0); if (ok) { - BranchObj* bo=(BranchObj*)selection; - bo->activateStandardFlag(s); - bo->updateFlagsToolbar(); + selb->activateStandardFlag(s); + selb->updateFlagsToolbar(); } } } else if (com=="unsetFlag") { - if (!selection) + if (xelection.isEmpty() ) { api.setError (Aborted,"Nothing selected"); - } else if ( (typeid(*selection) != typeid(BranchObj) && - typeid(*selection) != typeid(MapCenterObj)) ) + } else if (! selb ) { api.setError (Aborted,"Type of selection is not a branch"); } else if (api.checkParamCount(1)) @@ -872,9 +849,8 @@ s=api.parString(ok,0); if (ok) { - BranchObj* bo=(BranchObj*)selection; - bo->deactivateStandardFlag(s); - bo->updateFlagsToolbar(); + selb->deactivateStandardFlag(s); + selb->updateFlagsToolbar(); } } } else @@ -918,8 +894,8 @@ void MapEditor::closeMap() { // Unselect before disabling the toolbar actions - if (selection) selection->unselect(); - selection=NULL; + if (!xelection.isEmpty() ) xelection.unselect(); + xelection.clear(); updateActions(); clear(); @@ -983,27 +959,25 @@ if (lmode==NewMap) { - if (selection) selection->unselect(); - selection=NULL; + if (xelection.isEmpty() ) xelection.unselect(); + xelection.clear(); mapCenter->clear(); mapCenter->setMapEditor(this); // (map state is set later at end of load...) } else { - if (!selection || (typeid(*selection) != typeid(BranchObj) && - typeid(*selection) != typeid (MapCenterObj))) - return aborted; - BranchObj *bo=(BranchObj*)selection; + BranchObj *bo=xelection.getBranch(); + if (!bo) return aborted; if (lmode==ImportAdd) saveStateChangingPart( - selection, - selection, + bo, + bo, QString("addMapInsert (%1)").arg(fname), QString("Add map %1 to %2").arg(fname).arg(getName(bo))); else saveStateChangingPart( - selection, - selection, + bo, + bo, QString("addMapReplace(%1)").arg(fname), QString("Add map %1 to %2").arg(fname).arg(getName(bo))); } @@ -1073,10 +1047,10 @@ QString saveFile; - if (savemode==CompleteMap || selection==NULL) + if (savemode==CompleteMap || xelection.isEmpty()) saveFile=saveToDir (fileDir,mapName+"-",true,QPointF(),NULL); else - saveFile=saveToDir (fileDir,mapName+"-",true,QPointF(),selection); + saveFile=saveToDir (fileDir,mapName+"-",true,QPointF(),xelection.getBranch()); //FIXME check selected FIO if (!saveStringToDisk(fileDir+fname,saveFile)) return 1; @@ -1136,12 +1110,7 @@ pp.setRenderHint(QPainter::Antialiasing,true); // Don't print the visualisation of selection - LinkableMapObj *oldselection=NULL; - if (selection) - { - oldselection=selection; - selection->unselect(); - } + xelection.unselect(); QRectF mapRect=totalBBox; QGraphicsRectItem *frame=NULL; @@ -1192,11 +1161,7 @@ if (frame) delete (frame); // Restore selection - if (oldselection) - { - selection=oldselection; - selection->select(); - } + xelection.reselect(); // Save settings in vymrc settings.writeEntry("/mainwindow/printerName",printer->printerName()); @@ -1225,12 +1190,7 @@ pp.setRenderHints(renderHints()); // Don't print the visualisation of selection - LinkableMapObj *oldselection=NULL; - if (selection) - { - oldselection=selection; - selection->unselect(); - } + xelection.unselect(); mapScene->render ( &pp, QRectF(0,0,mapRect.width(),mapRect.height()), @@ -1241,11 +1201,7 @@ // Restore selection - if (oldselection) - { - selection=oldselection; - selection->select(); - } + xelection.reselect(); return pix; } @@ -1338,22 +1294,18 @@ void MapEditor::clear() { - if (selection) - { - selection->unselect(); - selection=NULL; - } - + xelection.unselect(); mapCenter->clear(); } void MapEditor::copy() { - if (selection) + LinkableMapObj *sel=xelection.single(); + if (sel) { // write to directory QString clipfile="part"; - QString saveFile=saveToDir (fileDir,clipfile+"-",true,QPointF(),selection); + QString saveFile=saveToDir (fileDir,clipfile+"-",true,QPointF(),sel ); // FIXME check FIO QFile file; file.setName ( clipboardDir + "/"+clipfile+".xml"); @@ -1597,8 +1549,8 @@ void MapEditor::addMapInsertInt (const QString &path, int pos) { - if (selection && (typeid(*selection) == typeid(BranchObj) || - typeid(*selection) == typeid(MapCenterObj))) + BranchObj *sel=xelection.getBranch(); + if (sel); { QString pathDir=path.left(path.findRev("/")); QDir d(pathDir); @@ -1624,8 +1576,8 @@ QMessageBox::critical( 0, tr( "Critical Parse Error while reading %1").arg(path), handler.errorProtocol()); } - if (selection!=mapCenter) - ((BranchObj*)selection)->getLastBranch()->linkTo ((BranchObj*)(selection),pos); + if (sel!=mapCenter) + sel->getLastBranch()->linkTo (sel,pos); } else QMessageBox::critical( 0, tr( "Critical Error" ), tr("Could not read %1").arg(path)); } @@ -1642,17 +1594,17 @@ deleteSelection(); } -void MapEditor::paste() +void MapEditor::paste() // FIXME no pasting of FIO ??? { - if (selection && (typeid(*selection) == typeid(BranchObj) || - typeid(*selection) == typeid(MapCenterObj))) + BranchObj *sel=xelection.getBranch(); + if (sel) { pasteNoSave(); saveStateChangingPart( - selection, - selection, + sel, + sel, "paste ()", - QString("Paste to %1").arg( getName(selection)) + QString("Paste to %1").arg( getName(sel)) ); mapCenter->reposition(); } @@ -1660,28 +1612,35 @@ void MapEditor::cut() { - saveStateChangingPart( - selection->getParObj(), - selection, - "cut ()", - QString("Cut %1").arg(getName(selection)) - ); - copy(); - cutNoSave(); - mapCenter->reposition(); + LinkableMapObj *sel=xelection.single(); + if ( sel && (xelection.type() == Branch || + xelection.type()==MapCenter || + xelection.type()==FloatImage)) + { + saveStateChangingPart( + sel->getParObj(), + sel, + "cut ()", + QString("Cut %1").arg(getName(sel )) + ); + copy(); + cutNoSave(); + mapCenter->reposition(); + } } void MapEditor::move(const int &x, const int &y) { - if (selection) + LinkableMapObj *sel=xelection.single(); + if (sel) { - QString ps=qpointfToString (selection->getAbsPos()); - QString s=selection->getSelectString(); + QString ps=qpointfToString (sel->getAbsPos()); + QString s=xelection.single()->getSelectString(); saveState( s, "move "+ps, s, "move "+qpointfToString (QPointF (x,y)), - QString("Move %1 to %2").arg(getName(selection)).arg(ps)); - selection->move(x,y); + QString("Move %1 to %2").arg(getName(sel)).arg(ps)); + sel->move(x,y); // FIXME xelection not moved automagically... mapCenter->reposition(); } @@ -1689,35 +1648,34 @@ void MapEditor::moveRel (const int &x, const int &y) { - if (selection && (typeid(*selection) == typeid(BranchObj) || - typeid(*selection) == typeid(MapCenterObj) || - typeid(*selection) == typeid (FloatImageObj))) + LinkableMapObj *sel=xelection.single(); + if (sel) { - QString ps=qpointfToString (selection->getRelPos()); - QString s=selection->getSelectString(); + QString ps=qpointfToString (sel->getRelPos()); + QString s=sel->getSelectString(); saveState( s, "moveRel "+ps, s, "moveRel "+qpointfToString (QPointF (x,y)), - QString("Move %1 to relativ position %2").arg(getName(selection)).arg(ps)); - ((OrnamentedObj*)selection)->move2RelPos (x,y); + QString("Move %1 to relativ position %2").arg(getName(sel)).arg(ps)); + ((OrnamentedObj*)sel)->move2RelPos (x,y); mapCenter->reposition(); - selection->updateLink(); + sel->updateLink(); } } void MapEditor::moveBranchUp() { - BranchObj* bo; + BranchObj* bo=xelection.getBranch(); BranchObj* par; - if (typeid(*selection) == typeid(BranchObj) ) + if (bo) { - bo=(BranchObj*)selection; if (!bo->canMoveBranchUp()) return; par=(BranchObj*)(bo->getParObj()); - selection->unselect(); + xelection.unselect(); // FIXME needed? bo=par->moveBranchUp (bo); // bo will be the one below selection - selection->select(); - saveState (selection,"moveBranchDown ()",bo,"moveBranchUp ()",QString("Move up %1").arg(getName(bo))); + xelection.reselect(); + //saveState (selection,"moveBranchDown ()",bo,"moveBranchUp ()",QString("Move up %1").arg(getName(bo))); + saveState (bo,"moveBranchDown ()",bo,"moveBranchUp ()",QString("Move up %1").arg(getName(bo))); mapCenter->reposition(); scene()->update(); ensureSelectionVisible(); @@ -1726,63 +1684,61 @@ void MapEditor::moveBranchDown() { - BranchObj* bo; + BranchObj* bo=xelection.getBranch(); BranchObj* par; - if (typeid(*selection) == typeid(BranchObj) ) + if (bo) { - bo=(BranchObj*)selection; if (!bo->canMoveBranchDown()) return; par=(BranchObj*)(bo->getParObj()); - selection->unselect(); + xelection.unselect(); // FIXME needed? bo=par->moveBranchDown(bo); // bo will be the one above selection - selection->select(); - saveState(selection,"moveBranchUp ()",bo,"moveBranchDown ()",QString("Move down %1").arg(getName(bo))); + xelection.reselect(); + //saveState(selection,"moveBranchUp ()",bo,"moveBranchDown ()",QString("Move down %1").arg(getName(bo))); + saveState(bo,"moveBranchUp ()",bo,"moveBranchDown ()",QString("Move down %1").arg(getName(bo))); mapCenter->reposition(); scene()->update(); ensureSelectionVisible(); } } -void MapEditor::linkTo(const QString &dstString) +void MapEditor::linkTo(const QString &dstString) // FIXME needed? only for FIO ?? { - BranchObj *dst=(BranchObj*)(mapCenter->findObjBySelect(dstString)); - if (dst && (typeid(*dst)==typeid (BranchObj) || - typeid(*dst)==typeid (MapCenterObj))) - { - LinkableMapObj *dstPar=dst->getParObj(); - QString parString=dstPar->getSelectString(); - if (typeid(*selection)==typeid(FloatImageObj)) - { - FloatImageObj *fio=(FloatImageObj*)selection; + FloatImageObj *fio=xelection.getFloatImage(); + if (fio) + { + BranchObj *dst=(BranchObj*)(mapCenter->findObjBySelect(dstString)); + if (dst && (typeid(*dst)==typeid (BranchObj) || + typeid(*dst)==typeid (MapCenterObj))) + { + LinkableMapObj *dstPar=dst->getParObj(); + QString parString=dstPar->getSelectString(); QString fioPreSelectString=fio->getSelectString(); QString fioPreParentSelectString=fio->getParObj()->getSelectString(); ((BranchObj*)(dst))->addFloatImage (fio); - fio->unselect(); + xelection.unselect(); ((BranchObj*)(fio->getParObj()))->removeFloatImage (fio); fio=((BranchObj*)(dst))->getLastFloatImage(); fio->setRelPos(); fio->reposition(); - selection=(LinkableMapObj*)fio; - selection->select(); + xelection.select(fio); saveState( fio->getSelectString(), QString("linkTo (\"%1\")").arg(fioPreParentSelectString), fioPreSelectString, QString ("linkTo (\"%1\")").arg(dstString), QString ("Link floatimage to %1").arg(getName(dst))); - } + } } } QString MapEditor::getHeading(bool &ok, QPoint &p) { - if (selection && - (typeid(*selection) == typeid(BranchObj) || - typeid(*selection) == typeid(MapCenterObj) ) ) + BranchObj *bo=xelection.getBranch(); + if (bo) { ok=true; - p=mapFromScene(selection->getAbsPos()); - return ((BranchObj*)selection)->getHeading(); + p=mapFromScene(bo->getAbsPos()); + return bo->getHeading(); } ok=false; return QString(); @@ -1790,19 +1746,16 @@ void MapEditor::setHeading(const QString &s) { - if (selection && - (typeid(*selection) == typeid(BranchObj) || - typeid(*selection) == typeid(MapCenterObj) ) ) + BranchObj *sel=xelection.getBranch(); + if (sel) { - editingBO=(BranchObj*)selection; saveState( - selection, - "setHeading (\""+editingBO->getHeading()+"\")", - selection, + sel, + "setHeading (\""+sel->getHeading()+"\")", + sel, "setHeading (\""+s+"\")", - QString("Set heading of %1 to \"%2\"").arg(getName(editingBO)).arg(s) ); - editingBO->setHeading(s ); - editingBO=NULL; + QString("Set heading of %1 to \"%2\"").arg(getName(sel)).arg(s) ); + sel->setHeading(s ); mapCenter->reposition(); ensureSelectionVisible(); } @@ -1811,11 +1764,10 @@ void MapEditor::setURLInt (const QString &s) { // Internal function, no saveState needed - if (selection && - (typeid(*selection) == typeid(BranchObj) || - typeid(*selection) == typeid(MapCenterObj) ) ) + BranchObj *bo=xelection.getBranch(); + if (bo) { - ((BranchObj*)selection)->setURL(s); + bo->setURL(s); mapCenter->reposition(); ensureSelectionVisible(); } @@ -1823,11 +1775,10 @@ void MapEditor::setHeadingInt(const QString &s) { - if (selection && - (typeid(*selection) == typeid(BranchObj) || - typeid(*selection) == typeid(MapCenterObj) ) ) + BranchObj *bo=xelection.getBranch(); + if (bo) { - ((BranchObj*)selection)->setHeading(s); + bo->setHeading(s); mapCenter->reposition(); ensureSelectionVisible(); } @@ -1836,11 +1787,10 @@ void MapEditor::setVymLinkInt (const QString &s) { // Internal function, no saveState needed - if (selection && - (typeid(*selection) == typeid(BranchObj) || - typeid(*selection) == typeid(MapCenterObj) ) ) + BranchObj *bo=xelection.getBranch(); + if (bo) { - ((BranchObj*)selection)->setVymLink(s); + bo->setVymLink(s); mapCenter->reposition(); ensureSelectionVisible(); } @@ -1854,11 +1804,9 @@ // -1 insert in childs of parent below selection // 0..n insert in childs of parent at pos BranchObj *newbo=NULL; - if (selection && - (typeid(*selection) == typeid(BranchObj) || - typeid(*selection) == typeid(MapCenterObj) ) ) + BranchObj *bo=xelection.getBranch(); + if (bo) { - BranchObj* bo = (BranchObj*) selection; if (num==-2) { // save scroll state. If scrolled, automatically select @@ -1886,12 +1834,10 @@ // -1 add above // 0 add as child // +1 add below - BranchObj *bo = (BranchObj*) selection; + BranchObj *bo = xelection.getBranch(); BranchObj *newbo=NULL; - if (selection && - (typeid(*selection) == typeid(BranchObj) || - typeid(*selection) == typeid(MapCenterObj) ) ) + if (bo) { setCursor (Qt::ArrowCursor); @@ -1902,7 +1848,7 @@ saveState( newbo, "delete ()", - selection, + bo, QString ("addBranch (%1)").arg(pos-2), QString ("Add new branch to %1").arg(getName(bo))); @@ -1916,15 +1862,14 @@ BranchObj* MapEditor::addNewBranchBefore() { BranchObj *newbo=NULL; - if (selection && - (typeid(*selection) == typeid(BranchObj) ) ) + BranchObj *bo = xelection.getBranch(); + if (bo && xelection.type()==Branch) // We accept no MapCenterObj here, so we _have_ a parent { - BranchObj* bo = (BranchObj*) selection; QPointF p=bo->getRelPos(); - BranchObj *parbo=(BranchObj*)(selection->getParObj()); + BranchObj *parbo=(BranchObj*)(bo->getParObj()); // add below selection newbo=parbo->insertBranch(bo->getNum()+1); @@ -1933,7 +1878,7 @@ newbo->move2RelPos (p); // Move selection to new branch - ((BranchObj*)selection)->linkTo (newbo,-1); + bo->linkTo (newbo,-1); saveState (newbo, "deleteKeepChilds ()", newbo, "addBranchBefore ()", QString ("Add branch before %1").arg(getName(bo))); @@ -1946,22 +1891,22 @@ void MapEditor::deleteSelection() { - if (selection && typeid(*selection) ==typeid(BranchObj) ) + BranchObj *bo = xelection.getBranch(); + if (bo && xelection.type()==Branch) { - BranchObj* bo=(BranchObj*)selection; BranchObj* par=(BranchObj*)(bo->getParObj()); - bo->unselect(); + xelection.unselect(); saveStateRemovingPart (bo, QString ("Delete %1").arg(getName(bo))); - selection=NULL; par->removeBranch(bo); - selection=par; - selection->select(); + xelection.select (par); ensureSelectionVisible(); mapCenter->reposition(); + mapScene->update(); + return; } - if (selection && typeid(*selection) ==typeid(FloatImageObj) ) + FloatImageObj *fio=xelection.getFloatImage(); + if (fio) { - FloatImageObj* fio=(FloatImageObj*)selection; BranchObj* par=(BranchObj*)(fio->getParObj()); saveStateChangingPart( par, @@ -1969,40 +1914,29 @@ "delete ()", QString("Delete %1").arg(getName(fio)) ); - fio->unselect(); - selection=NULL; + xelection.unselect(); par->removeFloatImage(fio); - selection=par; - selection->select(); + xelection.select (par); ensureSelectionVisible(); mapCenter->reposition(); + mapScene->update(); + return; } - mapScene->update(); } LinkableMapObj* MapEditor::getSelection() { - return selection; + return xelection.single(); } void MapEditor::unselect() { - if (selection) - { - selectionLast=selection; - selection->unselect(); - selection=NULL; - } + xelection.unselect(); } void MapEditor::reselect() { - if (selectionLast) - { - selection=selectionLast; - selection->select(); - selectionLast=NULL; - } + xelection.reselect(); } bool MapEditor::select (const QString &s) @@ -2012,9 +1946,8 @@ // Finally select the found object if (lmo) { - if (selection) unselect(); - selection=lmo; - selection->select(); + xelection.unselect(); + xelection.select(lmo); ensureSelectionVisible(); return true; } @@ -2023,27 +1956,22 @@ QString MapEditor::getSelectString() { - if (selection) return selection->getSelectString(); - return QString(); + return xelection.getSelectString(); } void MapEditor::selectInt (LinkableMapObj *lmo) { - if (lmo && selection != lmo) - { - // select the MapObj - if (selection) selection->unselect(); - selection=lmo; - selection->select(); - } + if (lmo && xelection.single()!= lmo) + xelection.select(lmo); } void MapEditor::selectNextBranchInt() { // Increase number of branch - if (selection) + LinkableMapObj *sel=xelection.single(); + if (sel) { - QString s=selection->getSelectString(); + QString s=sel->getSelectString(); QString part; QString typ; QString num; @@ -2067,7 +1995,7 @@ // try to increase the parental number in order to // find a successor with same depth - int d=selection->getDepth(); + int d=xelection.single()->getDepth(); int oldDepth=d; int i; bool found=false; @@ -2088,7 +2016,7 @@ } else { // Special case, look at orientation - if (selection->getOrientation()==OrientRightOfCenter) + if (xelection.single()->getOrientation()==OrientRightOfCenter) num=QString ("%1").arg(num.toUInt()+1); else num=QString ("%1").arg(num.toUInt()-1); @@ -2102,7 +2030,7 @@ b=select (s); if (b) { - if ( ((BranchObj*)selection)->countBranches()>0) + if ( xelection.getBranch()->countBranches()>0) s+=",bo:0"; else break; @@ -2121,9 +2049,10 @@ void MapEditor::selectPrevBranchInt() { // Decrease number of branch - if (selection) + BranchObj *bo=xelection.getBranch(); + if (bo) { - QString s=selection->getSelectString(); + QString s=bo->getSelectString(); QString part; QString typ; QString num; @@ -2148,7 +2077,7 @@ // try to decrease the parental number in order to // find a precessor with same depth - int d=selection->getDepth(); + int d=xelection.single()->getDepth(); int oldDepth=d; int i; bool found=false; @@ -2169,7 +2098,7 @@ } else { // Special case, look at orientation - if (selection->getOrientation()==OrientRightOfCenter) + if (xelection.single()->getOrientation()==OrientRightOfCenter) num=QString ("%1").arg(num.toInt()-1); else num=QString ("%1").arg(num.toInt()+1); @@ -2182,8 +2111,8 @@ { b=select (s); if (b) - if ( ((BranchObj*)selection)->countBranches()>0) - s+=",bo:"+ QString ("%1").arg( ((BranchObj*)selection)->countBranches()-1 ); + if ( xelection.getBranch()->countBranches()>0) + s+=",bo:"+ QString ("%1").arg( xelection.getBranch()->countBranches()-1 ); else break; else @@ -2200,36 +2129,30 @@ void MapEditor::selectUpperBranch() { - if (selection) + BranchObj *bo=xelection.getBranch(); + if (bo && xelection.type()==Branch) { - if (typeid(*selection) == typeid(BranchObj)) - { - if (selection->getOrientation()==OrientRightOfCenter) + if (bo->getOrientation()==OrientRightOfCenter) + selectPrevBranchInt(); + else + if (bo->getDepth()==1) + selectNextBranchInt(); + else + selectPrevBranchInt(); + } +} + +void MapEditor::selectLowerBranch() +{ + BranchObj *bo=xelection.getBranch(); + if (bo && xelection.type()==Branch) + if (bo->getOrientation()==OrientRightOfCenter) + selectNextBranchInt(); + else + if (bo->getDepth()==1) selectPrevBranchInt(); else - if (selection->getDepth()==1) - selectNextBranchInt(); - else - selectPrevBranchInt(); - } - } -} - -void MapEditor::selectLowerBranch() -{ - if (selection) - { - if (typeid(*selection) == typeid(BranchObj)) - { - if (selection->getOrientation()==OrientRightOfCenter) selectNextBranchInt(); - else - if (selection->getDepth()==1) - selectPrevBranchInt(); - else - selectNextBranchInt(); - } - } } @@ -2237,50 +2160,44 @@ { BranchObj* bo; BranchObj* par; - if (selection) + LinkableMapObj *sel=xelection.single(); + if (sel) { - if (typeid(*selection) == typeid(MapCenterObj)) + if (xelection.type()== MapCenter) { - par= (BranchObj*) selection; + par=xelection.getBranch(); bo=par->getLastSelectedBranch(); if (bo) { // Workaround for reselecting on left and right side if (bo->getOrientation()==OrientRightOfCenter) + bo=par->getLastBranch(); + if (bo) { bo=par->getLastBranch(); - } - if (bo) - { - par->unselect(); - selection=bo; - selection->select(); + xelection.select(bo); ensureSelectionVisible(); } } } else { - par=(BranchObj*)(selection->getParObj()); - if (selection->getOrientation()==OrientRightOfCenter) + par=(BranchObj*)(sel->getParObj()); + if (sel->getOrientation()==OrientRightOfCenter) { - if (typeid(*selection) == typeid(BranchObj) || - typeid(*selection) == typeid(FloatImageObj)) + if (xelection.type() == Branch || + xelection.type() == FloatImage) { - selection->unselect(); - selection=par; - selection->select(); + xelection.select(par); ensureSelectionVisible(); } } else { - if (typeid(*selection) == typeid(BranchObj) ) + if (xelection.type() == Branch ) { - bo=((BranchObj*)selection)->getLastSelectedBranch(); + bo=xelection.getBranch()->getLastSelectedBranch(); if (bo) { - selection->unselect(); - selection=bo; - selection->select(); + xelection.select(bo); ensureSelectionVisible(); } } @@ -2293,12 +2210,12 @@ { BranchObj* bo; BranchObj* par; - - if (selection) + LinkableMapObj *sel=xelection.single(); + if (sel) { - if (typeid(*selection) == typeid(MapCenterObj)) + if (xelection.type()==MapCenter) { - par= (BranchObj*) selection; + par=xelection.getBranch(); bo=par->getLastSelectedBranch(); if (bo) { @@ -2307,35 +2224,29 @@ bo=par->getFirstBranch(); if (bo) { - par->unselect(); - selection=bo; - selection->select(); + xelection.select(bo); ensureSelectionVisible(); } } } else { - par=(BranchObj*)(selection->getParObj()); - if (selection->getOrientation()==OrientLeftOfCenter) + par=(BranchObj*)(xelection.single()->getParObj()); + if (xelection.single()->getOrientation()==OrientLeftOfCenter) { - if (typeid(*selection) == typeid(BranchObj) || - typeid(*selection) == typeid(FloatImageObj)) + if (xelection.type() == Branch || + xelection.type() == FloatImage) { - selection->unselect(); - selection=par; - selection->select(); + xelection.select(par); ensureSelectionVisible(); } } else { - if (typeid(*selection) == typeid(BranchObj) ) + if (xelection.type() == Branch) { - bo=((BranchObj*)selection)->getLastSelectedBranch(); + bo=xelection.getBranch()->getLastSelectedBranch(); if (bo) { - selection->unselect(); - selection=bo; - selection->select(); + xelection.select(bo); ensureSelectionVisible(); } } @@ -2346,44 +2257,35 @@ void MapEditor::selectFirstBranch() { - BranchObj *bo1; + BranchObj *bo1=xelection.getBranch(); BranchObj *bo2; BranchObj* par; - if (selection) { - if (typeid(*selection) == typeid(BranchObj)) - { - bo1= (BranchObj*) selection; - par=(BranchObj*)(bo1->getParObj()); - bo2=par->getFirstBranch(); - if (bo2) { - bo1->unselect(); - selection=bo2; - selection->select(); - ensureSelectionVisible(); - } - } - } + if (bo1) + { + par=(BranchObj*)(bo1->getParObj()); + bo2=par->getFirstBranch(); + if (bo2) { + xelection.select(bo2); + ensureSelectionVisible(); + } + } } void MapEditor::selectLastBranch() { - BranchObj *bo1; + BranchObj *bo1=xelection.getBranch(); BranchObj *bo2; BranchObj* par; - if (selection) { - if (typeid(*selection) == typeid(BranchObj)) + if (bo1) + { + par=(BranchObj*)(bo1->getParObj()); + bo2=par->getLastBranch(); + if (bo2) { - bo1= (BranchObj*) selection; - par=(BranchObj*)(bo1->getParObj()); - bo2=par->getLastBranch(); - if (bo2) { - bo1->unselect(); - selection=bo2; - selection->select(); - ensureSelectionVisible(); - } - } - } + xelection.select(bo2); + ensureSelectionVisible(); + } + } } void MapEditor::selectMapBackgroundImage () @@ -2418,7 +2320,7 @@ QString ("setMapBackgroundImage (%1)").arg(col.name()), QString("Set background color of map to %1").arg(col.name())); */ - cout << "Trying to load "<setBackgroundBrush(brush); @@ -2436,9 +2338,9 @@ { QColor oldcol=mapScene->backgroundBrush().color(); saveState( - selection, + mapCenter, QString ("setMapBackgroundColor (%1)").arg(oldcol.name()), - selection, + mapCenter, QString ("setMapBackgroundColor (%1)").arg(col.name()), QString("Set background color of map to %1").arg(col.name())); mapScene->setBackgroundBrush(col); @@ -2451,15 +2353,8 @@ QColor MapEditor::getCurrentHeadingColor() { - if (selection) - { - if (typeid(*selection) == typeid(BranchObj) || - typeid(*selection) == typeid(MapCenterObj)) - { - BranchObj *bo=(BranchObj*)selection; - return bo->getColor(); - } - } + BranchObj *bo=xelection.getBranch(); + if (bo) return bo->getColor(); QMessageBox::warning(0,tr("Warning"),tr("Can't get color of heading,\nthere's no branch selected")); return Qt::black; @@ -2467,72 +2362,60 @@ void MapEditor::colorBranch (QColor c) { - if (selection) + BranchObj *bo=xelection.getBranch(); + if (bo) { - if (typeid(*selection) == typeid(BranchObj) || - typeid(*selection) == typeid(MapCenterObj)) - { - BranchObj *bo=(BranchObj*)selection; - saveState( - selection, - QString ("colorBranch (%1)").arg(bo->getColor().name()), - selection, - QString ("colorBranch (%1)").arg(c.name()), - QString("Set color of %1 to %2").arg(getName(bo)).arg(c.name()) - ); - bo->setColor(c); // color branch - } + saveState( + bo, + QString ("colorBranch (%1)").arg(bo->getColor().name()), + bo, + QString ("colorBranch (%1)").arg(c.name()), + QString("Set color of %1 to %2").arg(getName(bo)).arg(c.name()) + ); + bo->setColor(c); // color branch } } void MapEditor::colorSubtree (QColor c) { - if (selection) + BranchObj *bo=xelection.getBranch(); + if (bo) { - if (typeid(*selection) == typeid(BranchObj) || - typeid(*selection) == typeid(MapCenterObj)) - { - BranchObj *bo=(BranchObj*)selection; - saveStateChangingPart( - selection, - selection, - QString ("colorSubtree (%1)").arg(c.name()), - QString ("Set color of %1 and childs to %2").arg(getName(bo)).arg(c.name()) - ); - bo->setColorSubtree (c); // color links, color childs - } + saveStateChangingPart( + bo, + bo, + QString ("colorSubtree (%1)").arg(c.name()), + QString ("Set color of %1 and childs to %2").arg(getName(bo)).arg(c.name()) + ); + bo->setColorSubtree (c); // color links, color childs } } void MapEditor::toggleStandardFlag(QString f) { - if (selection) + BranchObj *bo=xelection.getBranch(); + if (bo) { - if (typeid(*selection) == typeid(BranchObj) || - typeid(*selection) == typeid(MapCenterObj)) + QString u,r; + if (bo->isSetStandardFlag(f)) { - BranchObj *bo=(BranchObj*)selection; - QString u,r; - if (bo->isSetStandardFlag(f)) - { - r="unsetFlag"; - u="setFlag"; - } - else - { - u="unsetFlag"; - r="setFlag"; - } - saveState( - selection, - QString("%1 (\"%2\")").arg(u).arg(f), - selection, - QString("%1 (\"%2\")").arg(r).arg(f), - QString("Toggling standard flag \"%1\" of %2").arg(f).arg(getName(bo))); - bo->toggleStandardFlag (f,mainWindow->useFlagGroups()); - } - } + r="unsetFlag"; + u="setFlag"; + } + else + { + u="unsetFlag"; + r="setFlag"; + } + saveState( + bo, + QString("%1 (\"%2\")").arg(u).arg(f), + bo, + QString("%1 (\"%2\")").arg(r).arg(f), + QString("Toggling standard flag \"%1\" of %2").arg(f).arg(getName(bo))); + bo->toggleStandardFlag (f,mainWindow->useFlagGroups()); + } } @@ -2557,11 +2440,9 @@ // Searching in Note if (itFind->getNote().contains(s,cs)) { - if (selection!=itFind) + if (xelection.single()!=itFind) { - if (selection) ((BranchObj*)selection)->unselect(); - selection=itFind; - selection->select(); + xelection.select(itFind); ensureSelectionVisible(); } if (textEditor->findText(s,flags)) @@ -2573,9 +2454,7 @@ // Searching in Heading if (searching && itFind->getHeading().contains (s,cs) ) { - if (selection) ((BranchObj*)selection)->unselect(); - selection=itFind; - selection->select(); + xelection.select(itFind); ensureSelectionVisible(); searching=false; } @@ -2587,9 +2466,8 @@ } } if (!searching) - { - return (BranchObj*)selection; - } else + return xelection.getBranch(); + else return NULL; } @@ -2600,16 +2478,15 @@ } void MapEditor::setURL(const QString &url) { - if (selection && (typeid(*selection) == typeid(BranchObj) || - typeid(*selection) == typeid(MapCenterObj)) ) - { - BranchObj *bo=(BranchObj*)selection; + BranchObj *bo=xelection.getBranch(); + if (bo) + { QString oldurl=bo->getURL(); bo->setURL (url); saveState ( - selection, + bo, QString ("setURL (\"%1\")").arg(oldurl), - selection, + bo, QString ("setURL (\"%1\")").arg(url), QString ("set URL of %1 to %2").arg(getName(bo)).arg(url) ); @@ -2619,11 +2496,10 @@ void MapEditor::editURL() { - if (selection && (typeid(*selection) == typeid(BranchObj) || - typeid(*selection) == typeid(MapCenterObj)) ) + BranchObj *bo=xelection.getBranch(); + if (bo) { bool ok; - BranchObj *bo=(BranchObj*)selection; QString text = QInputDialog::getText( "VYM", tr("Enter URL:"), QLineEdit::Normal, bo->getURL(), &ok, this ); @@ -2635,9 +2511,9 @@ QString MapEditor::getURL() { - if (selection && (typeid(*selection) == typeid(BranchObj) || - typeid(*selection) == typeid(MapCenterObj)) ) - return ((BranchObj*)selection)->getURL(); + BranchObj *bo=xelection.getBranch(); + if (bo) + return bo->getURL(); else return ""; } @@ -2645,10 +2521,9 @@ QStringList MapEditor::getURLs() { QStringList urls; - if (selection && (typeid(*selection) == typeid(BranchObj) || - typeid(*selection) == typeid(MapCenterObj)) ) + BranchObj *bo=xelection.getBranch(); + if (bo) { - BranchObj *bo=(BranchObj*)selection; bo=bo->first(); while (bo) { @@ -2662,17 +2537,16 @@ void MapEditor::editHeading2URL() { - if (selection && (typeid(*selection) == typeid(BranchObj) || - typeid(*selection) == typeid(MapCenterObj)) ) - setURL (((BranchObj*)selection)->getHeading()); + BranchObj *bo=xelection.getBranch(); + if (bo) + setURL (bo->getHeading()); } void MapEditor::editBugzilla2URL() { - if (selection && (typeid(*selection) == typeid(BranchObj) || - typeid(*selection) == typeid(MapCenterObj)) ) + BranchObj *bo=xelection.getBranch(); + if (bo) { - BranchObj *bo=(BranchObj*)selection; QString url= "https://bugzilla.novell.com/show_bug.cgi?id="+bo->getHeading(); setURL (url); } @@ -2680,15 +2554,14 @@ void MapEditor::editFATE2URL() { - if (selection && (typeid(*selection) == typeid(BranchObj) || - typeid(*selection) == typeid(MapCenterObj)) ) + BranchObj *bo=xelection.getBranch(); + if (bo) { - BranchObj *bo=(BranchObj*)selection; QString url= "http://keeper.suse.de:8080/webfate/match/id?value=ID"+bo->getHeading(); saveState( - selection, + bo, "setURL (\""+bo->getURL()+"\")", - selection, + bo, "setURL (\""+url+"\")", QString("Use heading of %1 as link to FATE").arg(getName(bo)) ); @@ -2699,10 +2572,9 @@ void MapEditor::editVymLink() { - if (selection && (typeid(*selection) == typeid(BranchObj) || - typeid(*selection) == typeid(MapCenterObj)) ) + BranchObj *bo=xelection.getBranch(); + if (bo) { - BranchObj *bo=(BranchObj*)selection; QStringList filters; filters <<"VYM map (*.vym)"; QFileDialog *fd=new QFileDialog( this,vymName+" - " +tr("Link to another map")); @@ -2716,9 +2588,9 @@ if ( fd->exec() == QDialog::Accepted ) { saveState( - selection, + bo, "setVymLink (\""+bo->getVymLink()+"\")", - selection, + bo, "setVymLink (\""+fd->selectedFile()+"\")", QString("Set vymlink of %1 to %2").arg(getName(bo)).arg(fd->selectedFile()) ); @@ -2732,14 +2604,13 @@ void MapEditor::deleteVymLink() { - if (selection && (typeid(*selection) == typeid(BranchObj) || - typeid(*selection) == typeid(MapCenterObj)) ) + BranchObj *bo=xelection.getBranch(); + if (bo) { - BranchObj *bo=(BranchObj*)selection; saveState( - selection, + bo, "setVymLink (\""+bo->getVymLink()+"\")", - selection, + bo, "setVymLink (\"\")", QString("Unset vymlink of %1").arg(getName(bo)) ); @@ -2752,20 +2623,19 @@ void MapEditor::setHideExport(bool b) { - if (selection && (typeid(*selection) == typeid(BranchObj) || - typeid(*selection)==typeid(FloatImageObj))) + BranchObj *bo=xelection.getBranch(); + if (bo) { - OrnamentedObj *oo=(OrnamentedObj*)selection; - oo->setHideInExport (b); + bo->setHideInExport (b); QString u= b ? "false" : "true"; QString r=!b ? "false" : "true"; saveState( - selection, + bo, QString ("setHideExport (%1)").arg(u), - selection, + bo, QString ("setHideExport (%1)").arg(r), - QString ("Set HideExport flag of %1 to %2").arg(getName(oo)).arg (r) + QString ("Set HideExport flag of %1 to %2").arg(getName(bo)).arg (r) ); updateActions(); mapCenter->reposition(); @@ -2775,29 +2645,27 @@ void MapEditor::toggleHideExport() { - if (selection && (typeid(*selection) == typeid(BranchObj) || - typeid(*selection)==typeid(FloatImageObj))) - setHideExport ( !((OrnamentedObj*)selection)->hideInExport() ); + BranchObj *bo=xelection.getBranch(); + if (bo) + setHideExport ( !bo->hideInExport() ); } QString MapEditor::getVymLink() { - if (selection && (typeid(*selection) == typeid(BranchObj) || - typeid(*selection) == typeid(MapCenterObj)) ) - { - return ((BranchObj*)selection)->getVymLink(); - } - return ""; + BranchObj *bo=xelection.getBranch(); + if (bo) + return bo->getVymLink(); + else + return ""; } QStringList MapEditor::getVymLinks() { QStringList links; - if (selection && (typeid(*selection) == typeid(BranchObj) || - typeid(*selection) == typeid(MapCenterObj)) ) + BranchObj *bo=xelection.getBranch(); + if (bo) { - BranchObj *bo=(BranchObj*)selection; bo=bo->first(); while (bo) { @@ -2811,40 +2679,41 @@ void MapEditor::deleteKeepChilds() { - if (selection && (typeid(*selection) == typeid(BranchObj) )) - { - BranchObj* bo=(BranchObj*)selection; - BranchObj* par=(BranchObj*)(bo->getParObj()); + BranchObj *bo=xelection.getBranch(); + BranchObj *par; + if (bo) + { + par=(BranchObj*)(bo->getParObj()); QPointF p=bo->getRelPos(); saveStateChangingPart( - selection->getParObj(), - selection, + bo->getParObj(), + bo, "deleteKeepChilds ()", QString("Remove %1 and keep its childs").arg(getName(bo)) ); - QString sel=selection->getSelectString(); + QString sel=bo->getSelectString(); unselect(); par->removeBranchHere(bo); mapCenter->reposition(); select (sel); - ((BranchObj*)selection)->move2RelPos (p); + xelection.getBranch()->move2RelPos (p); mapCenter->reposition(); } } void MapEditor::deleteChilds() { - if (selection && (typeid(*selection) == typeid(BranchObj) || - typeid(*selection)==typeid(MapCenterObj))) + BranchObj *bo=xelection.getBranch(); + if (bo) { saveStateChangingPart( - selection->getParObj(), - selection, + bo->getParObj(), + bo, "deleteChilds ()", - QString( "Remove childs of branch %1").arg(getName(selection)) + QString( "Remove childs of branch %1").arg(getName(bo)) ); - ((BranchObj*)selection)->removeChilds(); + bo->removeChilds(); mapCenter->reposition(); } } @@ -2896,18 +2765,16 @@ void MapEditor::updateNoteFlag() { - if (selection) - if ( (typeid(*selection) == typeid(BranchObj)) || - (typeid(*selection) == typeid(MapCenterObj)) ) - ((BranchObj*)selection)->updateNoteFlag(); + BranchObj *bo=xelection.getBranch(); + if (bo) bo->updateNoteFlag(); } void MapEditor::setMapAuthor (const QString &s) { saveState ( - selection, + mapCenter, QString ("setMapAuthor (\"%1\")").arg(mapCenter->getAuthor()), - selection, + mapCenter, QString ("setMapAuthor (\"%1\")").arg(s), QString ("Set author of map to \"%1\"").arg(s) ); @@ -2917,9 +2784,9 @@ void MapEditor::setMapComment (const QString &s) { saveState ( - selection, + mapCenter, QString ("setMapComment (\"%1\")").arg(mapCenter->getComment()), - selection, + mapCenter, QString ("setMapComment (\"%1\")").arg(s), QString ("Set comment of map") ); @@ -3034,9 +2901,9 @@ QColor col = QColorDialog::getColor( defLinkColor, this ); if ( !col.isValid() ) return; saveState ( - selection, + mapCenter, QString("setMapDefLinkColor (\"%1\")").arg(getMapDefLinkColor().name()), - selection, + mapCenter, QString("setMapDefLinkColor (\"%1\")").arg(col.name()), QString("Set link color to %1").arg(col.name()) ); @@ -3046,9 +2913,9 @@ void MapEditor::toggleScroll() { - if (selection && (typeid(*selection) == typeid(BranchObj)) ) + BranchObj *bo=xelection.getBranch(); + if (xelection.type()==Branch ) { - BranchObj *bo=((BranchObj*)selection); if (bo->countBranches()==0) return; if (bo->getDepth()==0) return; QString u,r; @@ -3063,9 +2930,9 @@ r="unscroll"; } saveState( - selection, + bo, QString ("%1 ()").arg(u), - selection, + bo, QString ("%1 ()").arg(r), QString ("%1 %2").arg(r).arg(getName(bo)) ); @@ -3087,11 +2954,9 @@ void MapEditor::loadFloatImage () { - if (selection && - (typeid(*selection) == typeid(BranchObj)) || - (typeid(*selection) == typeid(MapCenterObj)) ) + BranchObj *bo=xelection.getBranch(); + if (bo) { - BranchObj *bo=((BranchObj*)selection); Q3FileDialog *fd=new Q3FileDialog( this); fd->setMode (Q3FileDialog::ExistingFiles); @@ -3122,9 +2987,9 @@ saveState( (LinkableMapObj*)fio, "delete ()", - selection, + bo, QString ("loadFloatImage (%1)").arg(*it), - QString("Add floatimage %1 to %2").arg(*it).arg(getName(selection)) + QString("Add floatimage %1 to %2").arg(*it).arg(getName(bo)) ); bo->getLastFloatImage()->setOriginalFilename(fn); ++it; @@ -3140,10 +3005,9 @@ void MapEditor::saveFloatImage () { - if (selection && - (typeid(*selection) == typeid(FloatImageObj)) ) + FloatImageObj *fio=xelection.getFloatImage(); + if (fio) { - FloatImageObj *fio=((FloatImageObj*)selection); QFileDialog *fd=new QFileDialog( this); fd->setFilters (imageIO.getFilters()); fd->setCaption(vymName+" - " +tr("Save image")); @@ -3187,51 +3051,50 @@ void MapEditor::setFrame(const FrameType &t) // FIXME missing saveState { - if (selection && - (typeid(*selection) == typeid(BranchObj)) || - (typeid(*selection) == typeid(MapCenterObj)) ) + BranchObj *bo=xelection.getBranch(); + if (bo) { - selection->setFrameType (t); + bo->setFrameType (t); mapCenter->reposition(); - selection->updateLink(); + bo->updateLink(); } } void MapEditor::setIncludeImagesVer(bool b) // FIXME missing saveState { - if (selection && - (typeid(*selection) == typeid(BranchObj)) || - (typeid(*selection) == typeid(MapCenterObj)) ) - ((BranchObj*)selection)->setIncludeImagesVer(b); + BranchObj *bo=xelection.getBranch(); + if (bo) + { + bo->setIncludeImagesVer(b); mapCenter->reposition(); + } } void MapEditor::setIncludeImagesHor(bool b) // FIXME missing saveState { - if (selection && - (typeid(*selection) == typeid(BranchObj)) || - (typeid(*selection) == typeid(MapCenterObj)) ) - ((BranchObj*)selection)->setIncludeImagesHor(b); + BranchObj *bo=xelection.getBranch(); + if (bo) + { + bo->setIncludeImagesHor(b); mapCenter->reposition(); + } } void MapEditor::setHideLinkUnselected (bool b) // FIXME missing saveState { - if (selection && - (typeid(*selection) == typeid(BranchObj)) || - (typeid(*selection) == typeid(MapCenterObj)) || - (typeid(*selection) == typeid(FloatImageObj)) ) - selection->setHideLinkUnselected(b); + LinkableMapObj *sel=xelection.single(); + if (sel && + (xelection.type() == Branch || + xelection.type() == MapCenter || + xelection.type() == FloatImage )) + sel->setHideLinkUnselected(b); } void MapEditor::importDirInt(BranchObj *dst, QDir d) // FIXME missing saveState { - if (selection && - (typeid(*selection) == typeid(BranchObj)) || - (typeid(*selection) == typeid(MapCenterObj)) ) + BranchObj *bo=xelection.getBranch(); + if (bo) { - BranchObj *bo; - // Traverse directories d.setFilter( QDir::Dirs| QDir::Hidden | QDir::NoSymLinks ); QFileInfoList list = d.entryInfoList(); @@ -3276,9 +3139,8 @@ void MapEditor::importDir() { - if (selection && - (typeid(*selection) == typeid(BranchObj)) || - (typeid(*selection) == typeid(MapCenterObj)) ) + BranchObj *bo=xelection.getBranch(); + if (bo) { QStringList filters; filters <<"VYM map (*.vym)"; @@ -3291,7 +3153,6 @@ QString fn; if ( fd->exec() == QDialog::Accepted ) { - BranchObj *bo=((BranchObj*)selection); importDirInt (bo,QDir(fd->selectedFile()) ); mapCenter->reposition(); scene()->update(); @@ -3301,16 +3162,13 @@ void MapEditor::followXLink(int i) { - if (selection && - (typeid(*selection) == typeid(BranchObj)) || - (typeid(*selection) == typeid(MapCenterObj)) ) + BranchObj *bo=xelection.getBranch(); + if (bo) { - BranchObj *bo=((BranchObj*)selection)->XLinkTargetAt(i); + bo=bo->XLinkTargetAt(i); if (bo) { - selection->unselect(); - selection=bo; - selection->select(); + xelection.select(bo); ensureSelectionVisible(); } } @@ -3318,16 +3176,15 @@ void MapEditor::editXLink(int i) // FIXME missing saveState { - if (selection && - (typeid(*selection) == typeid(BranchObj)) || - (typeid(*selection) == typeid(MapCenterObj)) ) + BranchObj *bo=xelection.getBranch(); + if (bo) { - XLinkObj *xlo=((BranchObj*)selection)->XLinkAt(i); + XLinkObj *xlo=bo->XLinkAt(i); if (xlo) { EditXLinkDialog dia; dia.setXLink (xlo); - dia.setSelection(selection); + dia.setSelection(bo); if (dia.exec() == QDialog::Accepted) { if (dia.useSettingsGlobal() ) @@ -3336,7 +3193,7 @@ setMapDefXLinkWidth (xlo->getWidth() ); } if (dia.deleteXLink()) - ((BranchObj*)selection)->deleteXLinkAt(i); + bo->deleteXLinkAt(i); } } } @@ -3388,12 +3245,8 @@ void MapEditor::ensureSelectionVisible() { - if (selection) - { - LinkableMapObj* lmo= dynamic_cast (selection); - ensureVisible (lmo->getBBox()); - } - + LinkableMapObj *lmo=xelection.single(); + if (lmo) ensureVisible (lmo->getBBox() ); } void MapEditor::contextMenuEvent ( QContextMenuEvent * e ) @@ -3406,24 +3259,20 @@ if (lmo) { // MapObj was found - if (selection != lmo) + if (xelection.single() != lmo) { // select the MapObj - if (selection) selection->unselect(); - selection=lmo; - selection->select(); + xelection.select(lmo); } // Context Menu - if (selection) + if (xelection.getBranch() ) { - if (typeid(*selection)==typeid(BranchObj) || - typeid(*selection)==typeid(MapCenterObj) ) - { - // Context Menu on branch or mapcenter - updateActions(); - branchContextMenu->popup(e->globalPos() ); - } - if (typeid(*selection)==typeid(FloatImageObj)) + // Context Menu on branch or mapcenter + updateActions(); + branchContextMenu->popup(e->globalPos() ); + } else + { + if (xelection.getFloatImage() ) { // Context Menu on floatimage updateActions(); @@ -3527,10 +3376,8 @@ if (lmo) bo_begin=(BranchObj*)(lmo); else - if (selection && - ((typeid(*selection) == typeid(BranchObj)) || - (typeid(*selection) == typeid(MapCenterObj))) ) - bo_begin=(BranchObj*)selection; + if (xelection.getBranch() ) + bo_begin=xelection.getBranch(); if (bo_begin) { drawingLink=true; @@ -3552,8 +3399,10 @@ // Left Button Move Branches if (e->button() == Qt::LeftButton ) { - movingObj_start.setX( p.x() - selection->x() ); - movingObj_start.setY( p.y() - selection->y() ); + //movingObj_start.setX( p.x() - selection->x() );// TODO replaced selection->lmo here + //movingObj_start.setY( p.y() - selection->y() ); + movingObj_start.setX( p.x() - lmo->x() ); + movingObj_start.setY( p.y() - lmo->y() ); movingObj_orgPos.setX (lmo->x() ); movingObj_orgPos.setY (lmo->y() ); movingObj_orgRelPos=lmo->getRelPos(); @@ -3563,18 +3412,17 @@ if (mainWindow->getModMode()==ModModeCopy && e->state() & Qt::ControlModifier) { - if (typeid(*selection)==typeid(BranchObj) ) + if (xelection.type()==Branch) { copyingObj=true; - mapCenter->addBranch ((BranchObj*)selection); + mapCenter->addBranch ((BranchObj*)xelection.single()); unselect(); - selection=mapCenter->getLastBranch(); - selection->select(); + xelection.select(mapCenter->getLastBranch()); mapCenter->reposition(); } } - movingObj=selection; + movingObj=xelection.single(); } else // Middle Button Toggle Scroll // (On Mac OS X this won't work, but we still have @@ -3601,9 +3449,10 @@ void MapEditor::mouseMoveEvent(QMouseEvent* e) { QPointF p = mapToScene(e->pos()); + LinkableMapObj *lmosel=xelection.single(); // Move the selected MapObj - if ( selection && movingObj) + if ( lmosel && movingObj) { // reset cursor if we are moving and don't copy if (mainWindow->getModMode()!=ModModeCopy) @@ -3611,7 +3460,7 @@ // To avoid jumping of the sceneView, only // ensureSelectionVisible, if not tmp linked - if (!selection->hasParObjTmp()) + if (!lmosel->hasParObjTmp()) ensureSelectionVisible (); // Now move the selection, but add relative position @@ -3619,51 +3468,47 @@ // mousepointer. (This avoids flickering resp. jumping // of selection back to absPos) - LinkableMapObj *lmosel; - lmosel = dynamic_cast (selection); - // Check if we could link LinkableMapObj* lmo=mapCenter->findMapObj(p, lmosel); - if (typeid(*selection) == typeid(FloatImageObj)) + FloatObj *fio=xelection.getFloatImage(); + if (fio) { - FloatObj *fo=(FloatObj*)selection; - fo->move (p.x() -movingObj_start.x(), p.y()-movingObj_start.y() ); - fo->setRelPos(); - fo->updateLink(); //no need for reposition, if we update link here + fio->move (p.x() -movingObj_start.x(), p.y()-movingObj_start.y() ); + fio->setRelPos(); + fio->updateLink(); //no need for reposition, if we update link here // Relink float to new mapcenter or branch, if shift is pressed // Only relink, if selection really has a new parent if ( (e->modifiers()==Qt::ShiftModifier) && lmo && ( (typeid(*lmo)==typeid(BranchObj)) || (typeid(*lmo)==typeid(MapCenterObj)) ) && - ( lmo != fo->getParObj()) + ( lmo != fio->getParObj()) ) { - if (typeid(*fo) == typeid(FloatImageObj) && + if (typeid(*fio) == typeid(FloatImageObj) && ( (typeid(*lmo)==typeid(BranchObj) || typeid(*lmo)==typeid(MapCenterObj)) )) { // Also save the move which was done so far - FloatImageObj *fio=(FloatImageObj*)selection; QString pold=qpointfToString(movingObj_orgRelPos); QString pnow=qpointfToString(fio->getRelPos()); saveState( - selection, + fio, "moveRel "+pold, - selection, + fio, "moveRel "+pnow, - QString("Move %1 to relativ position %2").arg(getName(selection)).arg(pnow)); + QString("Move %1 to relativ position %2").arg(getName(fio)).arg(pnow)); fio->getParObj()->requestReposition(); mapCenter->reposition(); - cout << "current relPos="<getRelPos(); + movingObj=lmosel; + movingObj_orgRelPos=lmosel->getRelPos(); cout <<"ok 0\n"; mapCenter->reposition(); @@ -3699,10 +3544,7 @@ // reposition subbranch lmosel->reposition(); - if (lmo && (lmo!=selection) && - (typeid(*lmo) == typeid(BranchObj) || - (typeid(*lmo) == typeid(MapCenterObj) ) - ) ) + if (lmo && (lmo!=lmosel) && xelection.getBranch() ) { if (e->modifiers()==Qt::ControlModifier) { @@ -3748,6 +3590,7 @@ { QPointF p = mapToScene(e->pos()); LinkableMapObj *dst; + LinkableMapObj *lmosel=xelection.single(); // Have we been picking color? if (pickingColor) { @@ -3755,7 +3598,7 @@ setCursor (Qt::ArrowCursor); // Check if we are over another branch dst=mapCenter->findMapObj(p, NULL); - if (dst && selection) + if (dst && lmosel) { if (e->state() & Qt::ShiftModifier) colorBranch (((BranchObj*)(dst))->getColor()); @@ -3771,7 +3614,7 @@ drawingLink=false; // Check if we are over another branch dst=mapCenter->findMapObj(p, NULL); - if (dst && selection) + if (dst && lmosel) { tmpXLink->setEnd ( ((BranchObj*)(dst)) ); tmpXLink->updateXLink(); @@ -3786,53 +3629,52 @@ } // Have we been moving something? - if ( selection && movingObj ) + if ( lmosel && movingObj ) { - if(typeid(*selection)==typeid (FloatImageObj)) + FloatImageObj *fo=xelection.getFloatImage(); + if(fo) { // Moved FloatObj. Maybe we need to reposition - FloatImageObj *fo=(FloatImageObj*)selection; QString pold=qpointfToString(movingObj_orgRelPos); QString pnow=qpointfToString(fo->getRelPos()); saveState( - selection, + fo, "moveRel "+pold, - selection, + fo, "moveRel "+pnow, - QString("Move %1 to relativ position %2").arg(getName(selection)).arg(pnow)); - - selection->getParObj()->requestReposition(); + QString("Move %1 to relativ position %2").arg(getName(fo)).arg(pnow)); + + fo->getParObj()->requestReposition(); mapCenter->reposition(); } // Check if we are over another branch, but ignore // any found LMOs, which are FloatObjs - dst=mapCenter->findMapObj(mapToScene(e->pos() ), - ((LinkableMapObj*)selection) ); + dst=mapCenter->findMapObj(mapToScene(e->pos() ), lmosel); if (dst && (typeid(*dst)!=typeid(BranchObj) && typeid(*dst)!=typeid(MapCenterObj))) dst=NULL; - if (typeid(*selection) == typeid(MapCenterObj) ) + if (xelection.type() == MapCenter ) { // FIXME The MapCenter was moved, no savestate yet } - if (typeid(*selection) == typeid(BranchObj) ) + if (xelection.type() == Branch ) { // A branch was moved // save the position in case we link to mapcenter - QPointF savePos=QPointF (selection->x(),selection->y() ); + QPointF savePos=QPointF (lmosel->getAbsPos() ); // Reset the temporary drawn link to the original one - ((LinkableMapObj*)selection)->unsetParObjTmp(); + lmosel->unsetParObjTmp(); // For Redo we may need to save original selection - QString preSelStr=selection->getSelectString(); + QString preSelStr=lmosel->getSelectString(); copyingObj=false; if (dst ) { - BranchObj* bsel=(BranchObj*)selection; + BranchObj* bsel=xelection.getBranch(); BranchObj* bdst=(BranchObj*)dst; QString preParStr=(bsel->getParObj())->getSelectString(); @@ -3855,7 +3697,7 @@ bsel->linkTo (bdst,-1); if (dst->getDepth()==0) bsel->move (savePos); } - QString postSelStr=selection->getSelectString(); + QString postSelStr=lmosel->getSelectString(); QString postNum=QString::number (bsel->getNum(),10); QString undoCom="linkTo (\""+ @@ -3871,17 +3713,17 @@ preSelStr, redoCom, QString("Relink %1 to %2").arg(getName(bsel)).arg(getName(dst)) ); } else - if (selection->getDepth()==1) + if (lmosel->getDepth()==1) { // The select string might be different _after_ moving around. // Therefor reposition and then use string of old selection, too mapCenter->reposition(); - QString ps=qpointfToString ( ((BranchObj*)selection)->getRelPos() ); + QString ps=qpointfToString ( lmosel->getRelPos() ); saveState( - selection->getSelectString(), "moveRel "+qpointfToString(movingObj_orgRelPos), + lmosel->getSelectString(), "moveRel "+qpointfToString(movingObj_orgRelPos), preSelStr, "moveRel "+ps, - QString("Move %1 to relative position %2").arg(getName(selection)).arg(ps)); + QString("Move %1 to relative position %2").arg(getName(lmosel)).arg(ps)); } // Draw the original link, before selection was moved around @@ -3907,9 +3749,7 @@ LinkableMapObj *lmo=mapCenter->findMapObj(p, NULL); if (lmo) { // MapObj was found // First select the MapObj than edit heading - if (selection) selection->unselect(); - selection=lmo; - selection->select(); + xelection.select(lmo); mainWindow->editHeading(); } } @@ -3943,9 +3783,8 @@ void MapEditor::dropEvent(QDropEvent *event) { - if (selection && - (typeid(*selection) == typeid(BranchObj)) || - (typeid(*selection) == typeid(MapCenterObj))) + BranchObj *sel=xelection.getBranch(); + if (sel) { QList uris; if (event->mimeData()->hasImage()) @@ -3964,7 +3803,7 @@ BranchObj *bo; for (int i=0; iaddBranch(); + bo=sel->addBranch(); if (bo) { s=uris.at(i).toLocalFile(); @@ -4060,11 +3899,9 @@ void MapEditor::addFloatImageInt (const QPixmap &img) { - if (selection && - (typeid(*selection) == typeid(BranchObj)) || - (typeid(*selection) == typeid(MapCenterObj)) ) + BranchObj *bo=xelection.getBranch(); + if (bo) { - BranchObj *bo=((BranchObj*)selection); //FIXME XXX saveStateChangingPart(selection,QString("Add floatimage to %1").arg(getName(bo))); //QString fn=fd->selectedFile(); //lastImageDir=fn.left(fn.findRev ("/")); diff -r 7019762f8701 -r d886c77ac0fe mapeditor.h --- a/mapeditor.h Tue Jan 23 11:50:56 2007 +0000 +++ b/mapeditor.h Mon Jan 29 12:29:13 2007 +0000 @@ -213,9 +213,7 @@ bool copyingObj; // true while creating a link XLinkObj* tmpXLink; - Selection xelection; // FIXME not used (yet) - LinkableMapObj* selection; // select a LinkableMapObj - LinkableMapObj* selectionLast; // last selection + Selection xelection; MapObj* movingObj; // moving a MapObj MapObj* linkingObj_src; // part of a link QPointF movingObj_orgPos; // org. pos of mouse before move diff -r 7019762f8701 -r d886c77ac0fe selection.cpp --- a/selection.cpp Tue Jan 23 11:50:56 2007 +0000 +++ b/selection.cpp Mon Jan 29 12:29:13 2007 +0000 @@ -23,15 +23,16 @@ void Selection::clear() { - selectList.clear(); + unselect(); lastSelectList.clear(); } bool Selection::select(LinkableMapObj *lmo) // TODO no multiselections yet { - clear(); + if (!selectList.isEmpty()) unselect(); selectList.append (lmo); - return false; + lmo->select(); + return true; } bool Selection::select (const QString &s) // TODO no multiselections yet @@ -41,7 +42,7 @@ // Finally select the found object if (lmo) { - clear(); + unselect(); select (lmo); return true; } @@ -62,8 +63,13 @@ void Selection::unselect() { - lastSelectList=selectList; - selectList.clear(); + if (!selectList.isEmpty() ) + { + for (int i=0; i< selectList.count(); ++i) + selectList.at(i)->unselect(); + lastSelectList=selectList; + selectList.clear(); + } } bool Selection::isEmpty() @@ -88,6 +94,45 @@ return Undefined; } +LinkableMapObj* Selection::first() +{ + if (!selectList.isEmpty()) + return selectList.first(); + else + return NULL; +} + +LinkableMapObj* Selection::single() +{ + if (selectList.count() == 1) + return selectList.first(); + else + return NULL; +} + +BranchObj* Selection::getBranch() +{ + if (!selectList.isEmpty()) + { + LinkableMapObj *sel=selectList.first(); + if (typeid (*sel)==typeid (BranchObj) || + typeid (*sel)==typeid (MapCenterObj)) + return (BranchObj*)sel; + } + return NULL; +} + +FloatImageObj* Selection::getFloatImage() +{ + if (!selectList.isEmpty()) + { + LinkableMapObj *sel=selectList.first(); + if (typeid (*sel)==typeid (FloatImageObj)) + return (FloatImageObj*)sel; + } + return NULL; +} + QString Selection::getSelectString()// TODO no multiselections yet { if (selectList.count()==1) diff -r 7019762f8701 -r d886c77ac0fe selection.h --- a/selection.h Tue Jan 23 11:50:56 2007 +0000 +++ b/selection.h Mon Jan 29 12:29:13 2007 +0000 @@ -22,6 +22,10 @@ bool isEmpty(); uint count(); SelectionType type(); + LinkableMapObj * first(); // first in selection list + LinkableMapObj * single(); // NULL, if multiple selected + BranchObj* getBranch(); + FloatImageObj* getFloatImage(); QString getSelectString(); diff -r 7019762f8701 -r d886c77ac0fe tex/vym.changelog --- a/tex/vym.changelog Tue Jan 23 11:50:56 2007 +0000 +++ b/tex/vym.changelog Mon Jan 29 12:29:13 2007 +0000 @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Wed Jan 29 17:27:31 CET 2007 - uwedr + +- Version: 1.8.66 +- Feature: Using a new class to select objects +- Bugfix: Remember last directory before ASCII/LaTeX export + ------------------------------------------------------------------- Fri Jan 19 22:53:27 CET 2007 - uwe diff -r 7019762f8701 -r d886c77ac0fe version.h --- a/version.h Tue Jan 23 11:50:56 2007 +0000 +++ b/version.h Mon Jan 29 12:29:13 2007 +0000 @@ -4,8 +4,8 @@ #include #define __VYM_NAME "VYM" -#define __VYM_VERSION "1.8.65" -#define __VYM_BUILD_DATE "January 22, 2007" +#define __VYM_VERSION "1.8.66" +#define __VYM_BUILD_DATE "January 29, 2007" bool checkVersion(const QString &);