# HG changeset patch # User insilmaril # Date 1200328019 0 # Node ID 2abfdb7e85f48f8a470952135af43a8a5ca7826b # Parent 954221e01e4e355137ab8038910cd49e129934e9 Added french manual by Claude diff -r 954221e01e4e -r 2abfdb7e85f4 mainwindow.cpp --- a/mainwindow.cpp Mon Jan 14 16:26:59 2008 +0000 +++ b/mainwindow.cpp Mon Jan 14 16:26:59 2008 +0000 @@ -2343,7 +2343,7 @@ if (me) { ExportCSV ex; - ex.setMapCenter(me->getMapCenter()); + ex.setModel (me->getModel()); ex.addFilter ("CSV (*.csv)"); ex.setDir(lastImageDir); ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)")); @@ -2362,7 +2362,7 @@ if (me) { ExportLaTeX ex; - ex.setMapCenter(me->getMapCenter()); + ex.setModel (me->getModel()); ex.addFilter ("Tex (*.tex)"); ex.setDir(lastImageDir); ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)")); @@ -2381,7 +2381,7 @@ MapEditor *me=currentMapEditor(); if (me) { - ex.setMapCenter (me->getMapCenter() ); + ex.setModel (me->getModel()); ex.doExport(); } } @@ -2392,7 +2392,7 @@ MapEditor *me=currentMapEditor(); if (me) { - ex.setMapCenter (me->getMapCenter() ); + ex.setModel (me->getModel()); ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)")); ex.setDir(lastImageDir); ex.addFilter ("Taskjuggler (*.tjp)"); diff -r 954221e01e4e -r 2abfdb7e85f4 mapeditor.cpp --- a/mapeditor.cpp Mon Jan 14 16:26:59 2008 +0000 +++ b/mapeditor.cpp Mon Jan 14 16:26:59 2008 +0000 @@ -6,8 +6,6 @@ #include #include -#include "version.h" - #include "parser.h" #include "editxlinkdialog.h" #include "exports.h" @@ -69,15 +67,11 @@ //mapScene= new QGraphicsScene(QRectF(0,0,width(),height()), parent); mapScene->setBackgroundBrush (QBrush(Qt::white, Qt::SolidPattern)); + model=new VymModel(); + model->setScene (mapScene); + model->setMapEditor (this); setScene (mapScene); - - mapCenter = new MapCenterObj(mapScene); - mapCenter->setVisibility (true); - mapCenter->setMapEditor (this); - mapCenter->setHeading (tr("New Map","Heading of mapcenter in new map")); - //mapCenter->move(mapScene->width()/2-mapCenter->width()/2,mapScene->height()/2-mapCenter->height()/2); - mapCenter->move(0,0); printer=NULL; @@ -101,7 +95,7 @@ editingBO=NULL; movingObj=NULL; - xelection.setMapEditor (this); + xelection.setModel (model); xelection.unselect(); defXLinkWidth=1; @@ -141,7 +135,7 @@ setAcceptDrops (true); - mapCenter->reposition(); // for positioning heading + model->reposition(); // TODO animations animObjList.clear(); @@ -195,11 +189,12 @@ // tmpMapDir is in tmpVymDir, so it gets removed automagically when vym closes //removeDir(QDir(tmpMapDir)); + delete (model); } -MapCenterObj* MapEditor::getMapCenter() +VymModel* MapEditor::getModel() { - return mapCenter; + return model; } QGraphicsScene * MapEditor::getScene() @@ -299,10 +294,10 @@ colhint=attribut("linkColorHint","HeadingColor"); QString mapAttr=attribut("version",vymVersion); - if (!saveSel || saveSel==mapCenter) - mapAttr+= attribut("author",mapCenter->getAuthor()) + - attribut("comment",mapCenter->getComment()) + - attribut("date",mapCenter->getDate()) + + if (!saveSel) + mapAttr+= attribut("author",model->getAuthor()) + + attribut("comment",model->getComment()) + + attribut("date",model->getDate()) + attribut("backgroundColor", mapScene->backgroundBrush().color().name() ) + attribut("selectionColor", xelection.getColor().name() ) + attribut("linkStyle", ls ) + @@ -323,7 +318,7 @@ // Build xml recursivly if (!saveSel || typeid (*saveSel) == typeid (MapCenterObj)) // Save complete map, if saveSel not set - s+=mapCenter->saveToDir(tmpdir,prefix,writeflags,offset); + s+=model->saveToDir(tmpdir,prefix,writeflags,offset); else { if ( typeid(*saveSel) == typeid(BranchObj) ) @@ -512,6 +507,17 @@ NULL); } +void MapEditor::saveState(const QString &uc, const QString &rc, const QString &comment) +{ + // "Normal" savestate applied to model (no selection needed): + // save commands and comment + saveState (UndoCommand, + NULL, uc, + NULL, rc, + comment, + NULL); +} + void MapEditor::parseAtom(const QString &atom) { @@ -803,7 +809,7 @@ // 1 num in parent (for branches) // 2,3 x,y of mainbranch or mapcenter s=parser.parString(ok,0); - LinkableMapObj *dst=mapCenter->findObjBySelect (s); + LinkableMapObj *dst=model->findObjBySelect (s); if (dst) { if (typeid(*dst) == typeid(BranchObj) ) @@ -838,7 +844,7 @@ { // 0 selectstring of parent s=parser.parString(ok,0); - LinkableMapObj *dst=mapCenter->findObjBySelect (s); + LinkableMapObj *dst=model->findObjBySelect (s); if (dst) { if (typeid(*dst) == typeid(BranchObj) || @@ -1431,7 +1437,7 @@ if (parser.errorLevel()==NoError) { // setChanged(); FIXME should not be called e.g. for export?! - mapCenter->reposition(); + model->reposition(); } else { @@ -1550,8 +1556,8 @@ { if (xelection.isEmpty() ) xelection.unselect(); xelection.clear(); - mapCenter->clear(); - mapCenter->setMapEditor(this); + model->clear(); + model->setMapEditor(this); // (map state is set later at end of load...) } else { @@ -1589,7 +1595,7 @@ QXmlSimpleReader reader; reader.setContentHandler( handler ); reader.setErrorHandler( handler ); - handler->setMapEditor( this ); + handler->setModel ( model); // We need to set the tmpDir in order to load files with rel. path @@ -1603,7 +1609,7 @@ file.close(); if ( ok ) { - mapCenter->reposition(); + model->reposition(); xelection.update(); if (lmode==NewMap) { @@ -1685,7 +1691,7 @@ printer->setOutputFileName(settings.value("/mainwindow/printerFileName",printer->outputFileName()).toString()); } - QRectF totalBBox=mapCenter->getTotalBBox(); + QRectF totalBBox=model->getTotalBBox(); // Try to set orientation automagically // Note: Interpretation of generated postscript is amibiguous, if @@ -1779,7 +1785,7 @@ QPixmap MapEditor::getPixmap() { - QRectF mapRect=mapCenter->getTotalBBox(); + QRectF mapRect=model->getTotalBBox(); QPixmap pix((int)mapRect.width()+2,(int)mapRect.height()+1); QPainter pp (&pix); @@ -1801,8 +1807,8 @@ void MapEditor::setHideTmpMode (HideTmpMode mode) { hidemode=mode; - mapCenter->setHideTmp (hidemode); - mapCenter->reposition(); + model->setHideTmp (hidemode); + model->reposition(); scene()->update(); } @@ -1824,7 +1830,7 @@ void MapEditor::exportASCII(QString fname,bool askName) { ExportASCII ex; - ex.setMapCenter(mapCenter); + ex.setModel (model); if (fname=="") ex.setFile (mapName+".txt"); else @@ -1879,7 +1885,7 @@ { ExportOO ex; ex.setFile (fn); - ex.setMapCenter(mapCenter); + ex.setModel (model); if (ex.setConfigFile(cf)) { setExportMode (true); @@ -1946,7 +1952,7 @@ makeSubDirs (dir); // write to directory - QString saveFile=saveToDir (dir,mapName+"-",true,mapCenter->getTotalBBox().topLeft() ,NULL); + QString saveFile=saveToDir (dir,mapName+"-",true,model->getTotalBBox().topLeft() ,NULL); QFile file; file.setName ( dir + "/"+mapName+".xml"); @@ -1972,7 +1978,7 @@ void MapEditor::clear() { xelection.unselect(); - mapCenter->clear(); + model->clear(); } void MapEditor::copy() @@ -2018,10 +2024,11 @@ QString comment=undoSet.readEntry (QString("/history/step-%1/comment").arg(curStep)); QString version=undoSet.readEntry ("/history/version"); + /* TODO Maybe check for version, if we save the history if (!checkVersion(version)) QMessageBox::warning(0,tr("Warning"), tr("Version %1 of saved undo/redo data\ndoes not match current vym version %2.").arg(version).arg(vymVersion)); - + */ // Find out current undo directory QString bakMapDir(QString(tmpMapDir+"/undo-%1").arg(curStep)); @@ -2047,7 +2054,7 @@ parseAtom (redoCommand); - mapCenter->reposition(); + model->reposition(); blockSaveState=blockSaveStateOrg; @@ -2095,9 +2102,11 @@ QString comment=undoSet.readEntry (QString("/history/step-%1/comment").arg(curStep)); QString version=undoSet.readEntry ("/history/version"); + /* TODO Maybe check for version, if we save the history if (!checkVersion(version)) QMessageBox::warning(0,tr("Warning"), tr("Version %1 of saved undo/redo data\ndoes not match current vym version %2.").arg(version).arg(vymVersion)); + */ // Find out current undo directory QString bakMapDir(QString(tmpMapDir+"/undo-%1").arg(curStep)); @@ -2121,7 +2130,7 @@ cout << " ---------------------------"<reposition(); + model->reposition(); undosAvail--; curStep--; @@ -2196,12 +2205,12 @@ QXmlSimpleReader reader; reader.setContentHandler( &handler ); reader.setErrorHandler( &handler ); - handler.setMapEditor( this ); + handler.setModel ( model); handler.setTmpDir ( pathDir ); // needed to load files with rel. path if (undoSel.isEmpty()) { unselect(); - mapCenter->clear(); + model->clear(); handler.setLoadMode (NewMap); } else { @@ -2238,7 +2247,7 @@ QXmlSimpleReader reader; reader.setContentHandler( &handler ); reader.setErrorHandler( &handler ); - handler.setMapEditor( this ); + handler.setModel (model); handler.setTmpDir ( pathDir ); // needed to load files with rel. path handler.setLoadMode (ImportAdd); blockReposition=true; @@ -2250,7 +2259,7 @@ QMessageBox::critical( 0, tr( "Critical Parse Error while reading %1").arg(path), handler.errorProtocol()); } - if (sel!=mapCenter) + if (sel->getDepth()>0) sel->getLastBranch()->linkTo (sel,pos); } else QMessageBox::critical( 0, tr( "Critical Error" ), tr("Could not read %1").arg(path)); @@ -2285,7 +2294,7 @@ QString("Paste to %1").arg( getName(sel)) ); pasteNoSave(0); - mapCenter->reposition(); + model->reposition(); } } @@ -2306,7 +2315,7 @@ */ copy(); deleteSelection(); - mapCenter->reposition(); + model->reposition(); } } @@ -2326,7 +2335,7 @@ s, "move "+qpointfToString(to), QString("Move %1 to %2").arg(getName(sel)).arg(ps)); sel->move(x,y); - mapCenter->reposition(); + model->reposition(); xelection.update(); } } @@ -2348,7 +2357,7 @@ s, "moveRel "+qpointfToString(to), QString("Move %1 to relative position %2").arg(getName(sel)).arg(ps)); ((OrnamentedObj*)sel)->move2RelPos (x,y); - mapCenter->reposition(); + model->reposition(); sel->updateLink(); xelection.update(); } @@ -2365,7 +2374,7 @@ par=(BranchObj*)(bo->getParObj()); BranchObj *obo=par->moveBranchUp (bo); // bo will be the one below selection saveState (bo->getSelectString(),"moveBranchDown ()",obo->getSelectString(),"moveBranchUp ()",QString("Move up %1").arg(getName(bo))); - mapCenter->reposition(); + model->reposition(); scene()->update(); xelection.update(); ensureSelectionVisible(); @@ -2382,7 +2391,7 @@ par=(BranchObj*)(bo->getParObj()); BranchObj *obo=par->moveBranchDown(bo); // bo will be the one above selection saveState(bo->getSelectString(),"moveBranchUp ()",obo->getSelectString(),"moveBranchDown ()",QString("Move down %1").arg(getName(bo))); - mapCenter->reposition(); + model->reposition(); scene()->update(); xelection.update(); ensureSelectionVisible(); @@ -2398,7 +2407,7 @@ { saveStateChangingPart(bo,bo, "sortChildren ()",QString("Sort children of %1").arg(getName(bo))); bo->sortChildren(); - mapCenter->reposition(); + model->reposition(); ensureSelectionVisible(); } } @@ -2409,7 +2418,7 @@ FloatImageObj *fio=xelection.getFloatImage(); if (fio) { - BranchObj *dst=(BranchObj*)(mapCenter->findObjBySelect(dstString)); + BranchObj *dst=(BranchObj*)(model->findObjBySelect(dstString)); if (dst && (typeid(*dst)==typeid (BranchObj) || typeid(*dst)==typeid (MapCenterObj))) { @@ -2459,7 +2468,7 @@ "setHeading (\""+s+"\")", QString("Set heading of %1 to \"%2\"").arg(getName(sel)).arg(s) ); sel->setHeading(s ); - mapCenter->reposition(); + model->reposition(); xelection.update(); ensureSelectionVisible(); } @@ -2471,7 +2480,7 @@ if (bo) { bo->setHeading(s); - mapCenter->reposition(); + model->reposition(); xelection.update(); ensureSelectionVisible(); } @@ -2484,7 +2493,7 @@ if (bo) { bo->setVymLink(s); - mapCenter->reposition(); + model->reposition(); updateActions(); xelection.update(); ensureSelectionVisible(); @@ -2548,7 +2557,7 @@ QString ("addBranch (%1)").arg(pos), QString ("Add new branch to %1").arg(getName(bo))); - mapCenter->reposition(); + model->reposition(); xelection.update(); latestSelection=newbo->getSelectString(); // In Network mode, the client needs to know where the new branch is, @@ -2588,7 +2597,7 @@ saveState (newbo, "deleteKeepChilds ()", newbo, "addBranchBefore ()", QString ("Add branch before %1").arg(getName(bo))); - mapCenter->reposition(); + model->reposition(); xelection.update(); } } @@ -2599,6 +2608,23 @@ void MapEditor::deleteSelection() { BranchObj *bo = xelection.getBranch(); + if (bo && xelection.type()==Selection::MapCenter) + { + // BranchObj* par=(BranchObj*)(bo->getParObj()); + xelection.unselect(); + /* FIXME Note: does saveStateRemovingPart work for MCO? (No parent!) + saveStateRemovingPart (bo, QString ("Delete %1").arg(getName(bo))); + */ + bo=model->removeMapCenter ((MapCenterObj*)bo); + if (bo) + { + xelection.select (bo); + ensureSelectionVisible(); + xelection.update(); + } + model->reposition(); + return; + } if (bo && xelection.type()==Selection::Branch) { BranchObj* par=(BranchObj*)(bo->getParObj()); @@ -2607,7 +2633,7 @@ par->removeBranch(bo); xelection.select (par); ensureSelectionVisible(); - mapCenter->reposition(); + model->reposition(); xelection.update(); xelection.update(); return; @@ -2625,7 +2651,7 @@ xelection.unselect(); par->removeFloatImage(fio); xelection.select (par); - mapCenter->reposition(); + model->reposition(); xelection.update(); ensureSelectionVisible(); return; @@ -2659,7 +2685,7 @@ bool MapEditor::select (const QString &s) { - LinkableMapObj *lmo=mapCenter->findObjBySelect(s); + LinkableMapObj *lmo=model->findObjBySelect(s); // Finally select the found object if (lmo) @@ -3085,9 +3111,7 @@ { QColor oldcol=mapScene->backgroundBrush().color(); saveState( - mapCenter, QString ("setMapBackgroundColor (\"%1\")").arg(oldcol.name()), - mapCenter, QString ("setMapBackgroundColor (\"%1\")").arg(col.name()), QString("Set background color of map to %1").arg(col.name())); mapScene->setBackgroundBrush(col); @@ -3177,7 +3201,7 @@ if (EOFind) // nothing found, start again EOFind=false; - itFind=mapCenter->first(); + itFind=model->first(); } bool searching=true; bool foundNote=false; @@ -3209,7 +3233,7 @@ } if (!foundNote) { - itFind=itFind->next(); + itFind=model->next(itFind); if (!itFind) EOFind=true; } } @@ -3239,7 +3263,7 @@ QString ("set URL of %1 to %2").arg(getName(bo)).arg(url) ); updateActions(); - mapCenter->reposition(); + model->reposition(); xelection.update(); ensureSelectionVisible(); } @@ -3393,7 +3417,7 @@ ); bo->setVymLink ("" ); updateActions(); - mapCenter->reposition(); + model->reposition(); scene()->update(); } } @@ -3415,7 +3439,7 @@ QString ("Set HideExport flag of %1 to %2").arg(getName(bo)).arg (r) ); updateActions(); - mapCenter->reposition(); + model->reposition(); xelection.update(); scene()->update(); } @@ -3473,10 +3497,10 @@ QString sel=bo->getSelectString(); unselect(); par->removeBranchHere(bo); - mapCenter->reposition(); + model->reposition(); select (sel); xelection.getBranch()->move2RelPos (p); - mapCenter->reposition(); + model->reposition(); } } @@ -3492,7 +3516,7 @@ QString( "Remove childs of branch %1").arg(getName(bo)) ); bo->removeChilds(); - mapCenter->reposition(); + model->reposition(); } } @@ -3500,8 +3524,8 @@ { ExtraInfoDialog dia; dia.setMapName (getFileName() ); - dia.setAuthor (mapCenter->getAuthor() ); - dia.setComment(mapCenter->getComment() ); + dia.setAuthor (model->getAuthor() ); + dia.setComment(model->getComment() ); // Calc some stats QString stats; @@ -3512,14 +3536,14 @@ uint n=0; uint xl=0; BranchObj *bo; - bo=mapCenter->first(); + bo=model->first(); while (bo) { if (!bo->getNote().isEmpty() ) n++; f+= bo->countFloatImages(); b++; xl+=bo->countXLinks(); - bo=bo->next(); + bo=model->next(bo); } stats+=QString ("%1 branches\n").arg (b-1,6); stats+=QString ("%1 xLinks \n").arg (xl,6); @@ -3569,33 +3593,38 @@ void MapEditor::setMapAuthor (const QString &s) { saveState ( - mapCenter, - QString ("setMapAuthor (\"%1\")").arg(mapCenter->getAuthor()), - mapCenter, + QString ("setMapAuthor (\"%1\")").arg(model->getAuthor()), QString ("setMapAuthor (\"%1\")").arg(s), QString ("Set author of map to \"%1\"").arg(s) ); - mapCenter->setAuthor (s); + model->setAuthor (s); } void MapEditor::setMapComment (const QString &s) { saveState ( - mapCenter, - QString ("setMapComment (\"%1\")").arg(mapCenter->getComment()), - mapCenter, + QString ("setMapComment (\"%1\")").arg(model->getComment()), QString ("setMapComment (\"%1\")").arg(s), QString ("Set comment of map") ); - mapCenter->setComment (s); + model->setComment (s); } void MapEditor::setMapLinkStyle (const QString & s) { - saveStateChangingPart ( - mapCenter, - mapCenter, + QString snow; + if (linkstyle==LinkableMapObj::Line) + snow="StyleLine"; + else if (linkstyle==LinkableMapObj::Parabel) + snow="StyleParabel"; + else if (linkstyle==LinkableMapObj::PolyLine) + snow="StylePolyLine"; + else if (linkstyle==LinkableMapObj::PolyParabel) + snow="StyleParabel"; + + saveState ( QString("setMapLinkStyle (\"%1\")").arg(s), + QString("setMapLinkStyle (\"%1\")").arg(snow), QString("Set map link style (\"%1\")").arg(s) ); @@ -3609,14 +3638,14 @@ linkstyle=LinkableMapObj::PolyParabel; BranchObj *bo; - bo=mapCenter->first(); - bo=bo->next(); + bo=model->first(); + bo=model->next(bo); while (bo) { bo->setLinkStyle(bo->getDefLinkStyle()); - bo=bo->next(); + bo=model->next(bo); } - mapCenter->reposition(); + model->reposition(); } LinkableMapObj::Style MapEditor::getMapLinkStyle () @@ -3628,11 +3657,11 @@ { defLinkColor=c; BranchObj *bo; - bo=mapCenter->first(); + bo=model->first(); while (bo) { bo->setLinkColor(); - bo=bo->next(); + bo=model->next(bo); } updateActions(); } @@ -3641,11 +3670,11 @@ { // called from setMapLinkColorHint(lch) or at end of parse BranchObj *bo; - bo=mapCenter->first(); + bo=model->first(); while (bo) { bo->setLinkColor(); - bo=bo->next(); + bo=model->next(bo); } } @@ -3662,11 +3691,11 @@ else linkcolorhint=LinkableMapObj::HeadingColor; BranchObj *bo; - bo=mapCenter->first(); + bo=model->first(); while (bo) { bo->setLinkColor(); - bo=bo->next(); + bo=model->next(bo); } } @@ -3705,9 +3734,7 @@ QColor col = QColorDialog::getColor( defLinkColor, this ); if ( !col.isValid() ) return; saveState ( - mapCenter, QString("setMapDefLinkColor (\"%1\")").arg(getMapDefLinkColor().name()), - mapCenter, QString("setMapDefLinkColor (\"%1\")").arg(col.name()), QString("Set map link color to %1").arg(col.name()) ); @@ -3730,9 +3757,7 @@ { if ( !col.isValid() ) return; saveState ( - mapCenter, QString("setSelectionColor (%1)").arg(xelection.getColor().name()), - mapCenter, QString("setSelectionColor (%1)").arg(col.name()), QString("Set color of selection box to %1").arg(col.name()) ); @@ -3829,7 +3854,7 @@ bo->addFloatImage(); fio=bo->getLastFloatImage(); fio->load(fn); - mapCenter->reposition(); + model->reposition(); scene()->update(); return fio; } @@ -3942,7 +3967,7 @@ bo->setFrameType (t); saveState (bo, QString("setFrameType (\"%1\")").arg(s), bo, QString ("setFrameType (\"%1\")").arg(bo->getFrameTypeName()),QString ("set type of frame to %1").arg(s)); - mapCenter->reposition(); + model->reposition(); bo->updateLink(); } } @@ -3955,7 +3980,7 @@ saveState (bo, QString("setFrameType (\"%1\")").arg(bo->getFrameTypeName()), bo, QString ("setFrameType (\"%1\")").arg(s),QString ("set type of frame to %1").arg(s)); bo->setFrameType (s); - mapCenter->reposition(); + model->reposition(); bo->updateLink(); } } @@ -3990,7 +4015,7 @@ saveState (bo, QString("setFramePadding (\"%1\")").arg(bo->getFramePadding() ), bo, QString ("setFramePadding (\"%1\")").arg(i),QString ("set brush color of frame to %1").arg(i)); bo->setFramePadding (i); - mapCenter->reposition(); + model->reposition(); bo->updateLink(); } } @@ -4003,7 +4028,7 @@ saveState (bo, QString("setFrameBorderWidth (\"%1\")").arg(bo->getFrameBorderWidth() ), bo, QString ("setFrameBorderWidth (\"%1\")").arg(i),QString ("set border width of frame to %1").arg(i)); bo->setFrameBorderWidth (i); - mapCenter->reposition(); + model->reposition(); bo->updateLink(); } } @@ -4024,7 +4049,7 @@ QString("Include images vertically in %1").arg(getName(bo)) ); bo->setIncludeImagesVer(b); - mapCenter->reposition(); + model->reposition(); } } @@ -4044,7 +4069,7 @@ QString("Include images horizontally in %1").arg(getName(bo)) ); bo->setIncludeImagesHor(b); - mapCenter->reposition(); + model->reposition(); } } @@ -4146,7 +4171,7 @@ if ( fd->exec() == QDialog::Accepted ) { importDirInt (fd->selectedFile() ); - mapCenter->reposition(); + model->reposition(); scene()->update(); } } @@ -4232,8 +4257,9 @@ void MapEditor::testFunction2() { - mapCenter->reposition(); - scene()->update(); + + cout << "Selection: "<addMapCenter(); /* // Toggle hidemode @@ -4258,7 +4284,7 @@ // mouseEvent, we don't need to close here. QPointF p = mapToScene(e->pos()); - LinkableMapObj* lmo=mapCenter->findMapObj(p, NULL); + LinkableMapObj* lmo=model->findMapObj(p, NULL); if (lmo) { // MapObj was found @@ -4336,7 +4362,7 @@ } QPointF p = mapToScene(e->pos()); - LinkableMapObj* lmo=mapCenter->findMapObj(p, NULL); + LinkableMapObj* lmo=model->findMapObj(p, NULL); e->accept(); @@ -4425,13 +4451,14 @@ if (mainWindow->getModMode()==Main::ModModeCopy && e->state() & Qt::ControlModifier) { - if (xelection.type()==Selection::Branch) + BranchObj *bo=xelection.getBranch(); + if (bo) { copyingObj=true; - mapCenter->addBranch ((BranchObj*)xelection.single()); + bo->addBranch ((BranchObj*)xelection.single()); unselect(); - xelection.select(mapCenter->getLastBranch()); - mapCenter->reposition(); + xelection.select(bo->getLastBranch()); + model->reposition(); } } @@ -4483,7 +4510,7 @@ // of selection back to absPos) // Check if we could link - LinkableMapObj* lmo=mapCenter->findMapObj(p, lmosel); + LinkableMapObj* lmo=model->findMapObj(p, lmosel); FloatObj *fio=xelection.getFloatImage(); @@ -4517,13 +4544,13 @@ "moveRel "+pnow, QString("Move %1 to relative position %2").arg(getName(fio)).arg(pnow)); fio->getParObj()->requestReposition(); - mapCenter->reposition(); + model->reposition(); linkTo (lmo->getSelectString()); //movingObj=lmosel; //movingObj_orgRelPos=lmosel->getRelPos(); - mapCenter->reposition(); + model->reposition(); } } } else @@ -4532,10 +4559,10 @@ { // Move MapCenter if (e->buttons()== Qt::LeftButton && e->modifiers()==Qt::ShiftModifier) - mapCenter->moveAll(p.x() -movingObj_start.x(), p.y()-movingObj_start.y() ); + ((MapCenterObj*)lmosel)->moveAll(p.x() -movingObj_start.x(), p.y()-movingObj_start.y() ); else - mapCenter->move (p.x() -movingObj_start.x(), p.y()-movingObj_start.y() ); - mapCenter->updateRelPositions(); + lmosel->move (p.x() -movingObj_start.x(), p.y()-movingObj_start.y() ); + model->updateRelPositions(); } else { if (lmosel->getDepth()==1) @@ -4614,7 +4641,7 @@ pickingColor=false; setCursor (Qt::ArrowCursor); // Check if we are over another branch - dst=mapCenter->findMapObj(p, NULL); + dst=model->findMapObj(p, NULL); if (dst && lmosel) { if (e->state() & Qt::ShiftModifier) @@ -4630,7 +4657,7 @@ { drawingLink=false; // Check if we are over another branch - dst=mapCenter->findMapObj(p, NULL); + dst=model->findMapObj(p, NULL); if (dst && lmosel) { tmpXLink->setEnd ( ((BranchObj*)(dst)) ); @@ -4662,33 +4689,32 @@ QString("Move %1 to relative position %2").arg(getName(fo)).arg(pnow)); fo->getParObj()->requestReposition(); - mapCenter->reposition(); + model->reposition(); } // Check if we are over another branch, but ignore // any found LMOs, which are FloatObjs - dst=mapCenter->findMapObj(mapToScene(e->pos() ), lmosel); + dst=model->findMapObj(mapToScene(e->pos() ), lmosel); if (dst && (typeid(*dst)!=typeid(BranchObj) && typeid(*dst)!=typeid(MapCenterObj))) dst=NULL; - if (xelection.type() == Selection::MapCenter ) + BranchObj *bo=xelection.getBranch(); + if (bo && bo->getDepth()==0) { - // TODO: Check for problems if graphicsview is resized for - // undo/redo... - if (movingObj_orgPos != mapCenter->getAbsPos()) + if (movingObj_orgPos != bo->getAbsPos()) { QString pold=qpointfToString(movingObj_orgPos); - QString pnow=qpointfToString(mapCenter->getAbsPos()); + QString pnow=qpointfToString(bo->getAbsPos()); saveState( fo, "move "+pold, fo, "move "+pnow, - QString("Move mapcenter %1 to position %2").arg(getName(mapCenter)).arg(pnow)); + QString("Move mapcenter %1 to position %2").arg(getName(bo)).arg(pnow)); } } - + if (xelection.type() == Selection::Branch ) { // A branch was moved @@ -4747,7 +4773,7 @@ { // The select string might be different _after_ moving around. // Therefor reposition and then use string of old selection, too - mapCenter->reposition(); + model->reposition(); QPointF rp(lmosel->getRelPos()); if (rp != movingObj_orgRelPos) @@ -4760,7 +4786,7 @@ } } // Draw the original link, before selection was moved around - mapCenter->reposition(); + model->reposition(); } xelection.update(); // Finally resize scene, if needed @@ -4786,7 +4812,7 @@ if (e->button() == Qt::LeftButton ) { QPointF p = mapToScene(e->pos()); - LinkableMapObj *lmo=mapCenter->findMapObj(p, NULL); + LinkableMapObj *lmo=model->findMapObj(p, NULL); if (lmo) { // MapObj was found // First select the MapObj than edit heading xelection.select(lmo); @@ -4876,7 +4902,7 @@ } } } - mapCenter->reposition(); + model->reposition(); } } event->acceptProposedAction(); @@ -4893,7 +4919,7 @@ animObjList.at(i)->animate(); ((BranchObj*)animObjList.at(i))->move2RelPos (((BranchObj*)animObjList.at(i))->getRelPos() ); } - mapCenter->reposition(); + model->reposition(); } @@ -5011,19 +5037,19 @@ case QAbstractSocket::RemoteHostClosedError: break; case QAbstractSocket::HostNotFoundError: - QMessageBox::information(this, __VYM_NAME " Network client", + QMessageBox::information(this, vymName +" Network client", "The host was not found. Please check the " "host name and port settings."); break; case QAbstractSocket::ConnectionRefusedError: - QMessageBox::information(this, __VYM_NAME " Network client", + QMessageBox::information(this, vymName + " Network client", "The connection was refused by the peer. " "Make sure the fortune server is running, " "and check that the host name and port " "settings are correct."); break; default: - QMessageBox::information(this, __VYM_NAME " Network client", + QMessageBox::information(this, vymName + " Network client", QString("The following error occurred: %1.") .arg(clientSocket->errorString())); } @@ -5115,7 +5141,7 @@ QString s=bo->getSelectString(); saveState (PartOfMap, s, "nop ()", s, "copy ()","Copy dropped image to clipboard",fio ); saveState (fio,"delete ()", bo,QString("paste(%1)").arg(curStep),"Pasting dropped image"); - mapCenter->reposition(); + model->reposition(); scene()->update(); } } diff -r 954221e01e4e -r 2abfdb7e85f4 mapeditor.h --- a/mapeditor.h Mon Jan 14 16:26:59 2008 +0000 +++ b/mapeditor.h Mon Jan 14 16:26:59 2008 +0000 @@ -6,13 +6,15 @@ #include "attribute.h" #include "file.h" -#include "mapcenterobj.h" #include "misc.h" #include "parser.h" #include "ornamentedobj.h" #include "selection.h" #include "settings.h" +#include "vymmodel.h" +class VymModel; +class Selection; /*! \brief Main widget in vym to display and edit a map */ @@ -41,7 +43,7 @@ }; MapEditor(QWidget* parent=0); ~MapEditor(); - MapCenterObj* getMapCenter(); //!< Return center of map + VymModel* getModel(); QGraphicsScene * getScene(); State getState(); //!< Return State of MapEditor void setStateEditHeading (bool); //!< If set to true, State will change to EditHeading @@ -83,15 +85,42 @@ Additionally a comment is logged. */ - void saveState(const SaveMode& savemode, const QString &undoSelection, const QString &undoCommand, const QString &redoSelection, const QString &redoCommand, const QString &comment, LinkableMapObj *saveSelection); + void saveState( + const SaveMode& savemode, + const QString &undoSelection, + const QString &undoCommand, + const QString &redoSelection, + const QString &redoCommand, + const QString &comment, + LinkableMapObj *saveSelection); /*! Overloaded for convenience */ - void saveStateChangingPart(LinkableMapObj *undoSelection, LinkableMapObj* redoSelection, const QString &redoCommand, const QString &comment); + void saveStateChangingPart( + LinkableMapObj *undoSelection, + LinkableMapObj* redoSelection, + const QString &redoCommand, + const QString &comment); /*! Overloaded for convenience */ - void saveStateRemovingPart(LinkableMapObj *redoSelection, const QString &comment); + void saveStateRemovingPart( + LinkableMapObj *redoSelection, + const QString &comment); /*! Overloaded for convenience */ - void saveState(LinkableMapObj *undoSelection, const QString &undoCommand, LinkableMapObj *redoSelection, const QString &redoCommand, const QString &comment); + void saveState( + LinkableMapObj *undoSelection, + const QString &undoCommand, + LinkableMapObj *redoSelection, + const QString &redoCommand, + const QString &comment); /*! Overloaded for convenience */ - void saveState(const QString &undoSelection, const QString &undoCommand, const QString &redoSelection, const QString &redoCommand, const QString &comment) ; + void saveState( + const QString &undoSelection, + const QString &undoCommand, + const QString &redoSelection, + const QString &redoCommand, + const QString &comment) ; + void saveState( + const QString &undoCommand, + const QString &redoCommand, + const QString &comment) ; public: @@ -361,7 +390,7 @@ private: State state; // State of MapEditor QGraphicsScene *mapScene; - MapCenterObj* mapCenter; + VymModel *model; // Vym Map, includding several mapCenters QTimer *autosaveTimer; bool adjustCanvasRequested; // collect requests until end of user event diff -r 954221e01e4e -r 2abfdb7e85f4 mapobj.cpp --- a/mapobj.cpp Mon Jan 14 16:26:59 2008 +0000 +++ b/mapobj.cpp Mon Jan 14 16:26:59 2008 +0000 @@ -102,49 +102,16 @@ clickBox.moveTo (clickBox.x()+x,clickBox.y()+y); } -bool MapObj::inBox(const QPointF &p) -{ - if (p.x() >= clickBox.left() && p.x() <= clickBox.right() - && p.y() <= clickBox.bottom() && p.y() >= clickBox.top() ) - return true; - return false; -} - QRectF MapObj::getBBox() { return bbox; } -QRectF MapObj::addBBox(QRectF r1, QRectF r2) -{ - // Find smallest QRectF containing given rectangles +QRectF MapObj::getClickBox() +{ + return clickBox; +} - QRectF n; - // Set left border - if (r1.left() <= r2.left() ) - n.setLeft(r1.left() ); - else - n.setLeft(r2.left() ); - - // Set top border - if (r1.top() <= r2.top() ) - n.setTop(r1.top() ); - else - n.setTop(r2.top() ); - - // Set right border - if (r1.right() <= r2.right() ) - n.setRight(r2.right() ); - else - n.setRight(r1.right() ); - - // Set bottom - if (r1.bottom() <= r2.bottom() ) - n.setBottom(r2.bottom() ); - else - n.setBottom(r1.bottom() ); - return n; -} QSizeF MapObj::getSize() { diff -r 954221e01e4e -r 2abfdb7e85f4 mapobj.h --- a/mapobj.h Mon Jan 14 16:26:59 2008 +0000 +++ b/mapobj.h Mon Jan 14 16:26:59 2008 +0000 @@ -3,12 +3,9 @@ #include #include -#include #include "xmlobj.h" -using namespace std; - #define Z_BBOX 0 #define Z_XLINK 10 #define Z_LINK 20 @@ -39,9 +36,8 @@ virtual void move (double x,double y); // move to absolute Position virtual void move (QPointF p); virtual void moveBy (double x,double y); // move to relative Position - virtual bool inBox(const QPointF&); // Check if Point is within clickbox virtual QRectF getBBox(); // returns bounding box - virtual QRectF addBBox(QRectF,QRectF); // returns bbox which includes both boxes + virtual QRectF getClickBox(); // returns box to click virtual QSizeF getSize(); // returns size of bounding box virtual bool isVisibleObj(); virtual void setVisibility(bool); diff -r 954221e01e4e -r 2abfdb7e85f4 noteobj.cpp --- a/noteobj.cpp Mon Jan 14 16:26:59 2008 +0000 +++ b/noteobj.cpp Mon Jan 14 16:26:59 2008 +0000 @@ -84,10 +84,9 @@ rx.setPattern ("""); r.replace (rx,"\""); -/* FIXME +/* FIXME wrap text at width if (fonthint !="fixed") { - // wrap text at width } */ return r; diff -r 954221e01e4e -r 2abfdb7e85f4 texteditor.cpp --- a/texteditor.cpp Mon Jan 14 16:26:59 2008 +0000 +++ b/texteditor.cpp Mon Jan 14 16:26:59 2008 +0000 @@ -6,7 +6,6 @@ #include "noteobj.h" #include "settings.h" -#include "version.h" extern int statusbarTime; extern Settings settings; diff -r 954221e01e4e -r 2abfdb7e85f4 version.h --- a/version.h Mon Jan 14 16:26:59 2008 +0000 +++ b/version.h Mon Jan 14 16:26:59 2008 +0000 @@ -4,10 +4,10 @@ #include #define __VYM_NAME "VYM" -#define __VYM_VERSION "1.11.4" +#define __VYM_VERSION "1.11.5" //#define __VYM_CODENAME "Codename: 1.10.0-RC-3" #define __VYM_CODENAME "Codename: development version" -#define __VYM_BUILD_DATE "2008-01-02" +#define __VYM_BUILD_DATE "2008-01-14" bool checkVersion(const QString &); diff -r 954221e01e4e -r 2abfdb7e85f4 vym.pro --- a/vym.pro Mon Jan 14 16:26:59 2008 +0000 +++ b/vym.pro Mon Jan 14 16:26:59 2008 +0000 @@ -35,6 +35,7 @@ floatimageobj.h \ floatobj.h \ frameobj.h \ + geometry.h \ headingobj.h \ highlighter.h \ historywindow.h \ @@ -56,6 +57,7 @@ simplescripteditor.h\ texteditor.h \ version.h \ + vymmodel.h \ xlinkobj.h \ xml-base.h \ xml-vym.h \ @@ -85,6 +87,7 @@ floatimageobj.cpp \ floatobj.cpp \ frameobj.cpp \ + geometry.cpp \ headingobj.cpp \ highlighter.cpp \ historywindow.cpp \ @@ -107,6 +110,7 @@ simplescripteditor.cpp \ texteditor.cpp \ version.cpp \ + vymmodel.cpp \ xlinkobj.cpp \ xml-base.cpp \ xml-vym.cpp \