# HG changeset patch # User insilmaril # Date 1177516974 0 # Node ID 8b9cfc26638ced69aaa86a3063f64f62035c15d3 # Parent 83a3be747ad9af52b6c937e7577442c3f4b3cdd9 started doxygen documentation diff -r 83a3be747ad9 -r 8b9cfc26638c linkablemapobj.cpp --- a/linkablemapobj.cpp Wed Apr 25 16:02:54 2007 +0000 +++ b/linkablemapobj.cpp Wed Apr 25 16:02:54 2007 +0000 @@ -35,16 +35,16 @@ { switch (style) { - case StyleLine: + case Line: delete (l); break; - case StyleParabel: + case Parabel: while (!segment.isEmpty()) delete segment.takeFirst(); break; - case StylePolyLine: + case PolyLine: delete (p); break; - case StylePolyParabel: + case PolyParabel: delete (p); break; default: @@ -63,11 +63,11 @@ childPos=QPointF(0,0); link2ParPos=false; l=NULL; - orientation=OrientUndef; + orientation=UndefinedOrientation; linkwidth=20; thickness_start=8; - style=StyleUndef; - linkpos=LinkBottom; + style=UndefinedStyle; + linkpos=Bottom; arcsegs=13; // TODO instead of linkcolor pen.color() could be used all around @@ -181,37 +181,37 @@ return rightPad; } -LinkStyle LinkableMapObj::getDefLinkStyle () +LinkableMapObj::Style LinkableMapObj::getDefLinkStyle () { - if (mapEditor==0) return StyleUndef; - LinkStyle ls=mapEditor->getMapLinkStyle(); + if (mapEditor==0) return UndefinedStyle; + Style ls=mapEditor->getMapLinkStyle(); switch (ls) { - case StyleLine: + case Line: return ls; break; - case StyleParabel: + case Parabel: return ls; break; - case StylePolyLine: + case PolyLine: if (depth>1) - return StyleLine; + return Line; else return ls; break; - case StylePolyParabel: + case PolyParabel: if (depth>1) - return StyleParabel; + return Parabel; else return ls; break; default: break; } - return StyleUndef; + return UndefinedStyle; } -void LinkableMapObj::setLinkStyle(LinkStyle newstyle) +void LinkableMapObj::setLinkStyle(Style newstyle) { //if (newstyle=style) return; delLink(); @@ -223,10 +223,10 @@ QGraphicsLineItem *cl; switch (style) { - case StyleUndef: + case UndefinedStyle: bottomline->hide(); break; - case StyleLine: + case Line: l = scene->addLine(QLineF(1,1,1,1),pen); l->setZValue(Z_LINK); if (visible) @@ -234,7 +234,7 @@ else l->hide(); break; - case StyleParabel: + case Parabel: for (int i=0;iaddLine(QLineF(i*5,0,i*10,100),pen); @@ -247,7 +247,7 @@ } pa0.resize (arcsegs+1); break; - case StylePolyLine: + case PolyLine: p =scene->addPolygon(QPolygonF(),pen,linkcolor); p->setZValue(Z_LINK); if (visible) @@ -256,7 +256,7 @@ p->hide(); pa0.resize (3); break; - case StylePolyParabel: + case PolyParabel: p = scene->addPolygon(QPolygonF(),pen,linkcolor); p->setZValue(Z_LINK); if (visible) @@ -273,7 +273,7 @@ } } -LinkStyle LinkableMapObj::getLinkStyle() +LinkableMapObj::Style LinkableMapObj::getLinkStyle() { return style; } @@ -290,12 +290,12 @@ return hideLinkUnselected; } -void LinkableMapObj::setLinkPos(LinkPos lp) +void LinkableMapObj::setLinkPos(Position lp) { linkpos=lp; } -LinkPos LinkableMapObj::getLinkPos() +LinkableMapObj::Position LinkableMapObj::getLinkPos() { return linkpos; } @@ -316,17 +316,17 @@ bottomline->setPen( pen ); switch (style) { - case StyleLine: + case Line: l->setPen( pen); break; - case StyleParabel: + case Parabel: for (int i=0; isetPen( pen); break; - case StylePolyLine: + case PolyLine: p->setBrush( QBrush(col)); break; - case StylePolyParabel: + case PolyParabel: p->setBrush( QBrush(col)); break; default: @@ -353,17 +353,17 @@ bottomline->show(); switch (style) { - case StyleLine: + case Line: if (l) l->show(); break; - case StyleParabel: + case Parabel: for (int i=0; ishow(); break; - case StylePolyLine: + case PolyLine: if (p) p->show(); break; - case StylePolyParabel: + case PolyParabel: if (p) p->show(); break; default: @@ -374,17 +374,17 @@ bottomline->hide(); switch (style) { - case StyleLine: + case Line: if (l) l->hide(); break; - case StyleParabel: + case Parabel: for (int i=0; ihide(); break; - case StylePolyLine: + case PolyLine: if (p) p->hide(); break; - case StylePolyParabel: + case PolyParabel: if (p) p->hide(); break; default: @@ -395,25 +395,25 @@ void LinkableMapObj::setOrientation() { - LinkOrient orientOld=orientation; + Orientation orientOld=orientation; if (!parObj) { - orientation=OrientUndef; + orientation=UndefinedOrientation; return; } // Set orientation, first look for orientation of parent - if (parObj->getOrientation() != OrientUndef ) + if (parObj->getOrientation() != UndefinedOrientation ) // use the orientation of the parent: orientation=parObj->getOrientation(); else { // calc orientation depending on position rel to parent if (absPos.x() < QPointF(parObj->getChildPos() ).x() ) - orientation=OrientLeftOfCenter; + orientation=LeftOfCenter; else - orientation=OrientRightOfCenter; + orientation=RightOfCenter; } if (orientOld!=orientation) requestReposition(); } @@ -434,14 +434,14 @@ // updateLink is called from move, but called from constructor we don't // have parents yet... - if (style==StyleUndef) return; + if (style==UndefinedStyle) return; switch (linkpos) { - case LinkMiddle: + case Middle: bottomlineY=bbox.top() + bbox.height()/2; // draw link to middle (of frame) break; - case LinkBottom: + case Bottom: bottomlineY=bbox.bottom()-1; // draw link to bottom of box break; } @@ -484,14 +484,14 @@ // Draw the link switch (style) { - case StyleLine: + case Line: //l->prepareGeometryChange(); l->setLine( QLine(qRound (parPos.x()), qRound(parPos.y()), qRound(p2x), qRound(p2y) )); break; - case StyleParabel: + case Parabel: parabel (pa0, p1x,p1y,p2x,p2y); for (int i=0; isetLine(QLineF( pa0.at(i).x(), pa0.at(i).y(),pa0.at(i+1).x(),pa0.at(i+1).y())); } break; - case StylePolyLine: + case PolyLine: pa0.clear(); pa0<prepareGeometryChange(); p->setPolygon(QPolygonF (pa0)); break; - case StylePolyParabel: + case PolyParabel: parabel (pa1, p1x,p1y,p2x+tp.x(),p2y+tp.y()); parabel (pa2, p1x,p1y,p2x-tp.x(),p2y-tp.y()); pa0.clear(); @@ -585,7 +585,7 @@ } } -LinkOrient LinkableMapObj::getOrientation() +LinkableMapObj::Orientation LinkableMapObj::getOrientation() { return orientation; } @@ -656,6 +656,8 @@ void LinkableMapObj::select() { + // select and unselect are still needed to + // handle hiding of links selected=true; setVisibility (visible); } @@ -705,3 +707,4 @@ return attribut ("hideLink","false"); } + diff -r 83a3be747ad9 -r 8b9cfc26638c linkablemapobj.h --- a/linkablemapobj.h Wed Apr 25 16:02:54 2007 +0000 +++ b/linkablemapobj.h Wed Apr 25 16:02:54 2007 +0000 @@ -1,6 +1,7 @@ #ifndef LINKABLEMAPOBJ_H #define LINKABLEMAPOBJ_H +#include "animpoint.h" #include "noteobj.h" #include "headingobj.h" #include "flagrowobj.h" @@ -8,20 +9,43 @@ #define MAX_DEPTH 999 -enum LinkOrient {OrientUndef,OrientLeftOfCenter, OrientRightOfCenter}; -enum LinkStyle { - StyleUndef, - StyleLine, - StyleParabel, - StylePolyLine, - StylePolyParabel -}; -enum LinkPos {LinkMiddle,LinkBottom}; -enum LinkColorHint {DefaultColor,HeadingColor}; + +/*! \brief This class adds links to MapObj + +The links are connecting the branches (BranchObj) and images (FloatImageObj) in the map. +*/ class LinkableMapObj:public QObject, public MapObj { Q_OBJECT public: + /*! Orientation of an object dependd on the position relative to the parent */ + enum Orientation { + UndefinedOrientation, //!< Undefined + LeftOfCenter, //!< Object is left of center + RightOfCenter //!< Object is right of center + }; + + /*! Various drawing styles for links */ + enum Style { + UndefinedStyle, //!< Undefined + Line, //!< Straight line + Parabel, //!< Parabel + PolyLine, //!< Polygon (thick line) + PolyParabel //!< Thick parabel + }; + + /*! Vertical position of link in object */ + enum Position { + Middle, //!< Link is drawn in the middle of object + Bottom //!< Link is drawn at bottom of object + }; + + /*! Hint if link should use the default link color or the color of heading */ + enum ColorHint { + DefaultColor, //!< Link uses the default color + HeadingColor //!< Link uses the color of heading + }; + LinkableMapObj (); LinkableMapObj (QGraphicsScene*); LinkableMapObj (LinkableMapObj*); @@ -45,13 +69,13 @@ virtual qreal getTopPad(); virtual qreal getLeftPad(); virtual qreal getRightPad(); - LinkStyle getDefLinkStyle(); - void setLinkStyle(LinkStyle); - LinkStyle getLinkStyle(); + Style getDefLinkStyle(); + void setLinkStyle(Style); + Style getLinkStyle(); void setHideLinkUnselected(bool); bool getHideLinkUnselected(); - void setLinkPos (LinkPos); - LinkPos getLinkPos (); + void setLinkPos (Position); + Position getLinkPos (); virtual void setLinkColor(); // sets color according to colorhint, overloaded virtual void setLinkColor(QColor); @@ -67,7 +91,7 @@ virtual void setDockPos()=0; // sets childPos and parPos QPointF getChildPos(); // returns pos where childs dock QPointF getParPos(); // returns pos where parents dock - LinkOrient getOrientation(); // get orientation + Orientation getOrientation(); // get orientation virtual int getDepth(); // return depth virtual void setMapEditor(MapEditor*); // set MapEditor (needed in LMO::updateNoteFlag) virtual MapEditor* getMapEditor(); // get MapEditor (usually from parent); @@ -99,7 +123,7 @@ MapEditor* mapEditor; // for and toggleScroll(), get default styles // and mapEditor->updateActions() // and mapEditor->updateSelection() - LinkOrient orientation; + Orientation orientation; qreal linkwidth; // width of a link int depth; // depth: undef=-1 mapCenter=0 branch=1..n QRectF bboxTotal; // bounding box including childs @@ -110,8 +134,8 @@ qreal bottomlineY; // vertical offset of dockpos to pos int thickness_start; // for StylePoly* - LinkStyle style; // Current style - LinkPos linkpos; // Link at bottom of object or middle of height + Style style; // Current style + Position linkpos; // Link at bottom of object or middle of height QColor linkcolor; // Link color QPen pen; QGraphicsLineItem* l; // line style @@ -129,7 +153,8 @@ qreal topPad, botPad, leftPad, rightPad; // padding within bbox - QPointF relPos; // position relative to childPos of parent + QPointF relPos; // position relative to childPos of parent + //AnimPoint relPos; // position relative to childPos of parent bool useRelPos; bool useOrientation; }; diff -r 83a3be747ad9 -r 8b9cfc26638c main.cpp --- a/main.cpp Wed Apr 25 16:02:54 2007 +0000 +++ b/main.cpp Wed Apr 25 16:02:54 2007 +0000 @@ -12,6 +12,7 @@ QString vymName; QString vymVersion; QString vymBuildDate; +QString vymCodeName; Main *mainWindow; // used in BranchObj::select() QString tmpVymDir; // All temp files go there, created in mainwindow @@ -22,6 +23,7 @@ QString iconPath; // Pointing to icons used for toolbars QString flagsPath; // Pointing to flags bool clipboardEmpty; +bool debug; // global debugging flag FlagRowObj *systemFlagsDefault; // used to copy from in LinkableMapObj FlagRowObj *standardFlagsDefault; @@ -42,15 +44,17 @@ vymName=__VYM_NAME; vymVersion=__VYM_VERSION; vymBuildDate=__VYM_BUILD_DATE; + vymCodeName=__VYM_CODENAME; // Reading and initializing options commandline options - options.add ("version", SwitchOption, "v","version"); - options.add ("local", SwitchOption, "l", "local"); - options.add ("help", SwitchOption, "h", "help"); - options.add ("quit", SwitchOption, "q", "quit"); - options.add ("run", StringOption, "r", "run"); - options.add ("test", StringOption, "t", "test"); + options.add ("debug", Option::Switch, "d", "debug"); + options.add ("version", Option::Switch, "v","version"); + options.add ("local", Option::Switch, "l", "local"); + options.add ("help", Option::Switch, "h", "help"); + options.add ("quit", Option::Switch, "q", "quit"); + options.add ("run", Option::String, "r", "run"); + options.add ("test", Option::String, "t", "test"); options.setHelpText ( "VYM - View Your Mind\n" "--------------------\n\n" @@ -64,11 +68,14 @@ return 1; } + debug=options.isOn ("debug"); + if (options.isOn ("version")) { - cout << "vym version "<<__VYM_VERSION - <<" (c) 2004-2006 Uwe Drechsel - " - <<__VYM_BUILD_DATE<move (20,20); + branchPropertyWindow->resize (settings.value( "/branchpropertywindow/geometry/size",QSize (150,100)).toSize()); + branchPropertyWindow->move (settings.value( "/branchpropertywindow/geometry/pos", QPoint(20,20)).toPoint()); + // Initialize script editor scriptEditor = new SimpleScriptEditor(); @@ -201,12 +204,12 @@ settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() ); settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() ); - //FIXME save branchPropWindow settings - //FIXME save scriptEditor settings + //TODO save scriptEditor settings // call the destructors delete textEditor; delete historyWindow; + delete branchPropertyWindow; // Remove temporary directory removeDir (QDir(tmpVymDir)); @@ -361,7 +364,7 @@ a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this); a->setStatusTip (tr( "Close Map" ) ); - a->setShortcut (Qt::ALT + Qt::Key_C ); //Close map + a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map fileMenu->addAction (a); connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) ); @@ -580,10 +583,10 @@ addAction (alt); actionListBranches.append(actionEditToggleScroll); - a = new QAction( tr( "Unscroll all scrolled branches","Edit menu" ), this); - a->setStatusTip (tr( "Unscroll all" )); + a = new QAction( tr( "Unscroll childs","Edit menu" ), this); + a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" )); editMenu->addAction (a); - connect( a, SIGNAL( triggered() ), this, SLOT( editUnScrollAll() ) ); + connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChilds() ) ); editMenu->addSeparator(); @@ -785,13 +788,13 @@ connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) ); actionEditLoadImage=a; - a = new QAction( tr( "Property Dialog","Dialog to edit properties of selection" )+QString ("..."), this); + a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this); a->setStatusTip (tr( "Set properties for selection" )); a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window a->setShortcutContext (Qt::WindowShortcut); addAction (a); - connect( a, SIGNAL( triggered() ), this, SLOT( showPropertyDialog() ) ); - actionTogglePropertyDialog=a; + connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) ); + actionTogglePropertyWindow=a; } // Format Actions @@ -869,18 +872,6 @@ formatMenu->addAction (a); actionFormatLinkStylePolyParabel=a; - a = new QAction( tr( "Include images vertically","Branch attribute" ), this); - a->setStatusTip ( tr ("Include top and bottom position of images into branch")); - a->setToggleAction(true); - connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesVer() ) ); - actionFormatIncludeImagesVer=a; - - a = new QAction( tr( "Include images horizontally","Branch attribute" ), this); - a->setStatusTip ( tr ("Include left and right position of images into branch")); - a->setToggleAction(true); - connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesHor() ) ); - actionFormatIncludeImagesHor=a; - a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this); a->setStatusTip (tr( "Hide link" )); a->setToggleAction(true); @@ -974,7 +965,7 @@ connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) ); actionViewToggleHistoryWindow=a; - viewMenu->addAction (actionTogglePropertyDialog ); + viewMenu->addAction (actionTogglePropertyWindow); a = new QAction(tr( "Antialiasing","View action" ),this ); a->setStatusTip ( tr( "Antialiasing" )); @@ -992,13 +983,13 @@ connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) ); actionViewToggleSmoothPixmapTransform=a; - a = new QAction(tr( "Next Window","View action" ), this); + a = new QAction(tr( "Next Map","View action" ), this); a->setStatusTip (a->text()); a->setShortcut (Qt::ALT + Qt::Key_N ); viewMenu->addAction (a); connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) ); - a = new QAction (tr( "Previous Window","View action" ), this ); + a = new QAction (tr( "Previous Map","View action" ), this ); a->setStatusTip (a->text()); a->setShortcut (Qt::ALT + Qt::Key_P ); viewMenu->addAction (a); @@ -1375,12 +1366,34 @@ connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) ); settingsMenu->addAction (a); - a = new QAction( tr( "Set path for macros","Settings action"), this); + a = new QAction( tr( "Set path for macros","Settings action")+"...", this); a->setStatusTip( tr( "Set path for macros")); connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) ); settingsMenu->addAction (a); + a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this); + a->setStatusTip( tr( "Set number of undo levels")); + connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) ); + settingsMenu->addAction (a); + settingsMenu->addSeparator(); + + a = new QAction( tr( "Autosave","Settings action"), this); + a->setStatusTip( tr( "Autosave")); + a->setToggleAction(true); + a->setOn ( settings.value ("/mapeditor/autosave/use",true).toBool()); + connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) ); + settingsMenu->addAction (a); + actionSettingsAutosaveToggle=a; + + a = new QAction( tr( "Autosave time","Settings action")+"...", this); + a->setStatusTip( tr( "Autosave time")); + connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) ); + settingsMenu->addAction (a); + actionSettingsAutosaveTime=a; + + settingsMenu->addSeparator(); + a = new QAction( tr( "Edit branch after adding it","Settings action" ), this ); a->setStatusTip( tr( "Edit branch after adding it" )); a->setToggleAction(true); @@ -1472,7 +1485,7 @@ // Context Menu for branch or mapcenter branchContextMenu =new QMenu (this); - branchContextMenu->addAction (actionTogglePropertyDialog); + branchContextMenu->addAction (actionTogglePropertyWindow); branchContextMenu->addSeparator(); // Submenu "Add" @@ -1498,14 +1511,12 @@ branchContextMenu->addSeparator(); branchContextMenu->addAction ( actionEditLoadImage); - branchContextMenu->addAction ( actionFormatIncludeImagesVer ); - branchContextMenu->addAction ( actionFormatIncludeImagesHor ); // Submenu for Links (URLs, vymLinks) branchLinksContextMenu =new QMenu (this); branchContextMenu->addSeparator(); - branchLinksContextMenu=branchContextMenu->addMenu(tr("URLs and vymLinks","Context menu name")); + branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name")); branchLinksContextMenu->addAction ( actionEditOpenURL ); branchLinksContextMenu->addAction ( actionEditOpenURLTab ); branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs ); @@ -1677,9 +1688,8 @@ { // Unselect all possibly selected objects // (Important to update note editor) - int i; MapEditor *me; - for (i=0;i<=tabWidget->count() -1;i++) + for (int i=0;i<=tabWidget->count() -1;i++) { me=(MapEditor*)tabWidget->page(i); @@ -1972,7 +1982,7 @@ setupRecentMapsMenu(); } -void Main::fileSave(const SaveMode &savemode) +void Main::fileSave(MapEditor *me, const SaveMode &savemode) { // tmp dir for zipping QString tmpMapDir; @@ -1982,13 +1992,12 @@ QString safeFilePath; - bool saveZipped=currentMapEditor()->saveZipped(); - - MapEditor * me=currentMapEditor(); + bool saveZipped=me->saveZipped(); + if (me) { QString fn=me->getFilePath(); - // filename=unnamed, filepath="" in constructor... + // filename=unnamed, filepath="" in constructor of mapEditor if ( !fn.isEmpty() ) { // We have a filepath, go on saving @@ -2067,6 +2076,8 @@ // We have no filepath yet, // call fileSaveAs() now, this will call fileSave() // again. + // First switch to editor + tabWidget->setCurrentWidget (me); fileSaveAs(savemode); } } @@ -2089,7 +2100,12 @@ void Main::fileSave() { - fileSave (CompleteMap); + fileSave (currentMapEditor(), CompleteMap); +} + +void Main::fileSave(MapEditor *me) +{ + fileSave (me,CompleteMap); } void Main::fileSaveAs(const SaveMode& savemode) @@ -2145,7 +2161,7 @@ // Save now currentMapEditor()->setFilePath(fn); - fileSave(savemode); + fileSave(currentMapEditor(), savemode); // Set name of tab if (savemode==CompleteMap) @@ -2415,7 +2431,7 @@ { case QMessageBox::Yes: // save and close - fileSave(CompleteMap); + fileSave(currentMapEditor(), CompleteMap); break; case QMessageBox::No: // close without saving @@ -2466,7 +2482,7 @@ switch( mb.exec() ) { case QMessageBox::Yes: // save (the changed editors) and exit - fileSave(CompleteMap); + fileSave(currentMapEditor(), CompleteMap); break; case QMessageBox::No: // exit without saving @@ -2846,7 +2862,7 @@ } } -void Main::editUnScrollAll() +void Main::editUnscrollChilds() { if (currentMapEditor()) currentMapEditor()->unscrollChilds(); @@ -3124,18 +3140,6 @@ } -void Main::formatIncludeImagesVer() -{ - if (currentMapEditor()) - currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn()); -} - -void Main::formatIncludeImagesHor() -{ - if (currentMapEditor()) - currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn()); -} - void Main::formatHideLinkUnselected() //FIXME get rid of this with imagepropertydialog { if (currentMapEditor()) @@ -3213,6 +3217,39 @@ settings.setValue ("/macros/macroDir",dir.path()); } +void Main::settingsUndoLevels() +{ + bool ok; + int i = QInputDialog::getInteger( + this, + tr("QInputDialog::getInteger()"), + tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok); + if (ok) + { + settings.setValue ("/mapeditor/stepsTotal",i); + QMessageBox::information( this, tr( "VYM -Information:" ), + tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i)); + } +} + +void Main::settingsAutosaveToggle() +{ + settings.setValue ("/mapeditor/autosave/used",actionSettingsAutosaveToggle->isOn() ); +} + +void Main::settingsAutosaveTime() +{ + bool ok; + int i = QInputDialog::getInteger( + this, + tr("QInputDialog::getInteger()"), + tr("Number of seconds before autosave:"), settings.value("/mapeditor/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok); + if (ok) + { + settings.setValue ("/mapeditor/autosave/ms",i * 1000); + } +} + void Main::settingsToggleDelKey() { if (actionSettingsUseDelKey->isOn()) @@ -3241,6 +3278,27 @@ } +void Main::windowToggleProperty() +{ + if (branchPropertyWindow->isVisible()) + branchPropertyWindow->hide(); + else + branchPropertyWindow->show(); + if(currentMapEditor()) + { + LinkableMapObj *sel=currentMapEditor()->getSelection(); + if (sel && (typeid(*sel) == typeid(BranchObj) || + typeid(*sel) == typeid(MapCenterObj))) + { + branchPropertyWindow->setMapEditor(currentMapEditor()); + branchPropertyWindow->setBranch((BranchObj*)sel); + return; + } + + } + branchPropertyWindow->setBranch(NULL); +} + void Main::windowToggleAntiAlias() { bool b=actionViewToggleAntiAlias->isOn(); @@ -3293,23 +3351,23 @@ actionViewToggleNoteEditor->setOn (textEditor->showWithMain()); actionViewToggleHistoryWindow->setOn (historyWindow->showWithMain()); - if (me->getMapLinkColorHint()==HeadingColor) + if (me->getMapLinkColorHint()==LinkableMapObj::HeadingColor) actionFormatLinkColorHint->setOn(true); else actionFormatLinkColorHint->setOn(false); switch (me->getMapLinkStyle()) { - case StyleLine: + case LinkableMapObj::Line: actionFormatLinkStyleLine->setOn(true); break; - case StyleParabel: + case LinkableMapObj::Parabel: actionFormatLinkStyleParabel->setOn(true); break; - case StylePolyLine: + case LinkableMapObj::PolyLine: actionFormatLinkStylePolyLine->setOn(true); break; - case StylePolyParabel: + case LinkableMapObj::PolyParabel: actionFormatLinkStylePolyParabel->setOn(true); break; default: @@ -3419,10 +3477,6 @@ for (int i=0; isetEnabled(true); actionEditDelete->setEnabled (true); - actionFormatIncludeImagesVer->setOn - ( ((BranchObj*)selection)->getIncludeImagesVer()); - actionFormatIncludeImagesHor->setOn - ( ((BranchObj*)selection)->getIncludeImagesHor()); actionFormatHideLinkUnselected->setOn (selection->getHideLinkUnselected()); } @@ -3469,7 +3523,7 @@ } } -ModMode Main::getModMode() +Main::ModMode Main::getModMode() { if (actionModModeColor->isOn()) return ModModeColor; if (actionModModeCopy->isOn()) return ModModeCopy; @@ -3517,24 +3571,6 @@ currentMapEditor()->runScript (script); } -void Main::showPropertyDialog() -{ - if(currentMapEditor()) - { - LinkableMapObj *sel=currentMapEditor()->getSelection(); - if (sel && (typeid(*sel) == typeid(BranchObj) || - typeid(*sel) == typeid(MapCenterObj))) - { - branchPropertyWindow->show(); - branchPropertyWindow->setMapEditor(currentMapEditor()); - branchPropertyWindow->setBranch((BranchObj*)sel); - return; - } - - } - branchPropertyWindow->setBranch(NULL); -} - void Main::windowNextEditor() { if (tabWidget->currentPageIndex() < tabWidget->count()) diff -r 83a3be747ad9 -r 8b9cfc26638c mainwindow.h --- a/mainwindow.h Wed Apr 25 16:02:54 2007 +0000 +++ b/mainwindow.h Wed Apr 25 16:02:54 2007 +0000 @@ -12,13 +12,19 @@ #include "texteditor.h" #include "xml.h" -enum ModMode {ModModeNone,ModModeColor,ModModeCopy,ModModeXLink}; - class Main : public QMainWindow { Q_OBJECT public: + /*! Modifier modes are used when CTRL together with a mouse button is pressed */ + enum ModMode { + ModModeNone, //!< Unused + ModModeColor, //!< Pick color from object + ModModeCopy, //!< Copy object + ModModeXLink //!< Create a XLink (XLinkObj) from selected object + }; + Main(QWidget* parent=0, const char* name=0, Qt::WFlags f=0); ~Main(); void loadCmdLine(); @@ -58,8 +64,11 @@ void fileLoad(); void fileLoadRecent(); void addRecentMap (const QString &); - void fileSave(const SaveMode & ); + void fileSave(MapEditor*, const SaveMode & ); void fileSave(); +public slots: + void fileSave(MapEditor *); // autosave from MapEditor +private slots: void fileSaveAs(const SaveMode &); void fileSaveAs(); void fileImportKDEBookmarks(); @@ -114,7 +123,7 @@ void editMoveUp(); void editMoveDown(); void editToggleScroll(); - void editUnScrollAll(); + void editUnscrollChilds(); void editNewBranch(); void editNewBranchBefore(); void editNewBranchAbove(); @@ -150,8 +159,6 @@ void formatSelectLinkColor(); void formatSelectSelectionColor(); void formatToggleLinkColorHint(); - void formatIncludeImagesVer(); - void formatIncludeImagesHor(); void formatHideLinkUnselected(); void viewZoomReset(); @@ -163,9 +170,13 @@ bool settingsURL(); void settingsMacroDir(); void settingsToggleDelKey(); + void settingsUndoLevels(); + void settingsAutosaveToggle(); + void settingsAutosaveTime(); void windowToggleNoteEditor(); void windowToggleHistory(); + void windowToggleProperty(); void updateHistory(SimpleSettings &); void windowToggleAntiAlias(); void windowToggleSmoothPixmap(); @@ -180,7 +191,6 @@ void runScript(const QString &); private slots: - void showPropertyDialog(); void windowNextEditor(); void windowPreviousEditor(); void windowShowNoteEditor(); @@ -196,6 +206,7 @@ void helpAboutQT(); void callMacro (); + private: QTabWidget *tabWidget; FindWindow *findWindow; @@ -269,8 +280,6 @@ QAction* actionFormatBackImage; QAction* actionFormatLinkColor; QAction* actionFormatSelectionColor; - QAction *actionFormatIncludeImagesVer; - QAction *actionFormatIncludeImagesHor; QActionGroup* actionGroupModModes; QAction* actionModModeColor; @@ -279,7 +288,7 @@ QActionGroup *actionGroupFormatFrameTypes; - QAction *actionTogglePropertyDialog; + QAction *actionTogglePropertyWindow; QActionGroup *actionGroupFormatLinkStyles; QAction *actionFormatLinkStyleLine; @@ -299,6 +308,8 @@ QAction* actionSettingsUseDelKey; QAction* actionSettingsUseFlagGroups; QAction* actionSettingsUseHideExport; + QAction* actionSettingsAutosaveToggle; + QAction* actionSettingsAutosaveTime; }; diff -r 83a3be747ad9 -r 8b9cfc26638c mapeditor.cpp --- a/mapeditor.cpp Wed Apr 25 16:02:54 2007 +0000 +++ b/mapeditor.cpp Wed Apr 25 16:02:54 2007 +0000 @@ -27,6 +27,7 @@ extern QString tmpVymDir; extern QString clipboardDir; extern bool clipboardEmpty; +extern bool debug; extern FlagRowObj *standardFlagsDefault; extern QMenu* branchContextMenu; @@ -55,7 +56,7 @@ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// MapEditor::MapEditor( QWidget* parent) : - QGraphicsView(parent) + QGraphicsView(parent) { //cout << "Constructor ME "<reposition(); // for positioning heading + // TODO animations + animObjList.clear(); + //timerId = startTimer(100); + + // autosave + autosaveTimer=new QTimer (this); + connect(autosaveTimer, SIGNAL(timeout()), this, SLOT(autosave())); } MapEditor::~MapEditor() { //cout <<"Destructor MapEditor\n"; + autosaveTimer->stop(); } MapCenterObj* MapEditor::getMapCenter() @@ -156,6 +165,11 @@ return blockReposition; } +void MapEditor::setSaveStateBlocked(bool b) +{ + blockSaveState=b; +} + QString MapEditor::getName (const LinkableMapObj *lmo) { QString s; @@ -197,13 +211,13 @@ QString ls; switch (linkstyle) { - case StyleLine: + case LinkableMapObj::Line: ls="StyleLine"; break; - case StyleParabel: + case LinkableMapObj::Parabel: ls="StyleParabel"; break; - case StylePolyLine: + case LinkableMapObj::PolyLine: ls="StylePolyLine"; break; default: @@ -213,7 +227,7 @@ QString s="\n"; QString colhint=""; - if (linkcolorhint==HeadingColor) + if (linkcolorhint==LinkableMapObj::HeadingColor) colhint=attribut("linkColorHint","HeadingColor"); QString mapAttr=attribut("version",vymVersion); @@ -349,7 +363,7 @@ /* TODO remove after testing */ - cout << "ME::saveState() "<updateHistory (undoSet); setChanged(); @@ -761,7 +777,7 @@ parser.setError (Aborted,"Type of selection is not a branch"); } else if (parser.checkParamCount(0)) { - if (!scrollBranch ()) + if (!scrollBranch (selb)) parser.setError (Aborted,"Could not scroll branch"); } } else if (com=="select") @@ -803,6 +819,17 @@ selectInt (fio); } + } else if (com=="setFrameType") + { + if ( xelection.type()!=Branch && xelection.type()!= MapCenter && xelection.type()!=FloatImage) + { + parser.setError (Aborted,"Type of selection does not allow setting frame type"); + } + else if (parser.checkParamCount(1)) + { + s=parser.parString(ok,0); + if (ok) setFrameType (s); + } } else if (com=="setMapAuthor") { if (parser.checkParamCount(1)) @@ -869,17 +896,16 @@ if (xelection.isEmpty() ) { parser.setError (Aborted,"Nothing selected"); - } else if (! selb) + } else if (xelection.type()!=Branch && xelection.type() != MapCenter &&xelection.type()!=FloatImage) { parser.setError (Aborted,"Type of selection is not a branch or floatimage"); - //FIXME selb is never a floatimage!! } else if (parser.checkParamCount(1)) { b=parser.parBool(ok,0); if (ok) setHideExport (b); } } else if (com=="setIncludeImagesHorizontally") - { + { if (xelection.isEmpty() ) { parser.setError (Aborted,"Nothing selected"); @@ -996,9 +1022,21 @@ parser.setError (Aborted,"Type of selection is not a branch"); } else if (parser.checkParamCount(0)) { - if (!unscrollBranch ()) + if (!unscrollBranch (selb)) parser.setError (Aborted,"Could not unscroll branch"); } + } else if (com=="unscrollChilds") + { + if (xelection.isEmpty() ) + { + parser.setError (Aborted,"Nothing selected"); + } else if (! selb ) + { + parser.setError (Aborted,"Type of selection is not a branch"); + } else if (parser.checkParamCount(0)) + { + unscrollChilds (); + } } else if (com=="unsetFlag") { if (xelection.isEmpty() ) @@ -1058,10 +1096,13 @@ void MapEditor::setChanged() { + if (!mapChanged) + autosaveTimer->start(settings.value("/mapeditor/autosave/ms/",300000).toInt()); mapChanged=true; mapDefault=false; mapUnsaved=true; findReset(); + } void MapEditor::closeMap() @@ -1168,7 +1209,9 @@ err=aborted; } else { + bool blockSaveStateOrg=blockSaveState; blockReposition=true; + blockSaveState=true; QXmlInputSource source( file); QXmlSimpleReader reader; reader.setContentHandler( &handler ); @@ -1177,10 +1220,9 @@ handler.setTmpDir (filePath.left(filePath.findRev("/",-1))); // needed to load files with rel. path handler.setInputFile (file.name()); handler.setLoadMode (lmode); - blockSaveState=true; bool ok = reader.parse( source ); blockReposition=false; - blockSaveState=false; + blockSaveState=blockSaveStateOrg; file.close(); if ( ok ) { @@ -1191,6 +1233,7 @@ mapDefault=false; mapChanged=false; mapUnsaved=false; + autosaveTimer->stop(); } } else { @@ -1224,7 +1267,8 @@ if (savemode==CompleteMap || xelection.isEmpty()) saveFile=saveToDir (fileDir,mapName+"-",true,QPointF(),NULL); else - saveFile=saveToDir (fileDir,mapName+"-",true,QPointF(),xelection.getBranch()); //FIXME check selected FIO + //save () FIXME check FIO + saveFile=saveToDir (fileDir,mapName+"-",true,QPointF(),xelection.getBranch()); if (!saveStringToDisk(fileDir+fname,saveFile)) return 1; @@ -1233,6 +1277,7 @@ { mapChanged=false; mapUnsaved=false; + autosaveTimer->stop(); updateActions(); } @@ -1373,7 +1418,7 @@ return pix; } -void MapEditor::setHideTmpMode (HideTmpMode mode) +void MapEditor::setHideTmpMode (BranchObj::HideTmpMode mode) { hidemode=mode; mapCenter->setHideTmp (hidemode); @@ -1381,7 +1426,7 @@ scene()->update(); } -HideTmpMode MapEditor::getHideTmpMode() +BranchObj::HideTmpMode MapEditor::getHideTmpMode() { return hidemode; } @@ -1399,9 +1444,9 @@ // should be called before and after exports // depending on the settings if (b && settings.value("/export/useHideExport","yes")=="yes") - setHideTmpMode (HideExport); + setHideTmpMode (BranchObj::HideExport); else - setHideTmpMode (HideNone); + setHideTmpMode (BranchObj::HideNone); } void MapEditor::exportImage(QString fn, QString format) @@ -1496,14 +1541,16 @@ void MapEditor::redo() { - blockSaveState=true; - // Restore variables int curStep=undoSet.readNumEntry (QString("/history/curStep")); int undosAvail=undoSet.readNumEntry (QString("/history/undosAvail")); int redosAvail=undoSet.readNumEntry (QString("/history/redosAvail")); // Can we undo at all? if (redosAvail<1) return; + + bool blockSaveStateOrg=blockSaveState; + blockSaveState=true; + redosAvail--; if (undosAvailreposition(); - blockSaveState=false; + blockSaveState=blockSaveStateOrg; undoSet.setEntry ("/history/undosAvail",QString::number(undosAvail)); undoSet.setEntry ("/history/redosAvail",QString::number(redosAvail)); @@ -1577,8 +1625,6 @@ void MapEditor::undo() { - blockSaveState=true; - // Restore variables int curStep=undoSet.readNumEntry (QString("/history/curStep")); int undosAvail=undoSet.readNumEntry (QString("/history/undosAvail")); @@ -1587,6 +1633,9 @@ // Can we undo at all? if (undosAvail<1) return; + bool blockSaveStateOrg=blockSaveState; + blockSaveState=true; + QString undoCommand= undoSet.readEntry (QString("/history/step-%1/undoCommand").arg(curStep)); QString undoSelection=undoSet.readEntry (QString("/history/step-%1/undoSelection").arg(curStep)); QString redoCommand= undoSet.readEntry (QString("/history/step-%1/redoCommand").arg(curStep)); @@ -1605,19 +1654,20 @@ if (!undoSelection.isEmpty()) select (undoSelection); -/* TODO testing -*/ - cout << "ME::undo() begin\n"; - cout << " undosAvail="<reposition(); @@ -1627,7 +1677,7 @@ redosAvail++; - blockSaveState=false; + blockSaveState=blockSaveStateOrg; /* TODO remove testing cout << "ME::undo() end\n"; cout << " undosAvail="<move(x,y); // FIXME xelection not moved automagically... + sel->move(x,y); mapCenter->reposition(); xelection.update(); } @@ -1841,11 +1891,8 @@ { if (!bo->canMoveBranchUp()) return; par=(BranchObj*)(bo->getParObj()); - xelection.unselect(); // FIXME needed? - bo=par->moveBranchUp (bo); // bo will be the one below selection - 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))); + 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(); scene()->update(); xelection.update(); @@ -1861,11 +1908,8 @@ { if (!bo->canMoveBranchDown()) return; par=(BranchObj*)(bo->getParObj()); - xelection.unselect(); // FIXME needed? - bo=par->moveBranchDown(bo); // bo will be the one above selection - 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))); + 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(); scene()->update(); xelection.update(); @@ -2209,7 +2253,7 @@ } else { // Special case, look at orientation - if (xelection.single()->getOrientation()==OrientRightOfCenter) + if (xelection.single()->getOrientation()==LinkableMapObj::RightOfCenter) num=QString ("%1").arg(num.toUInt()+1); else num=QString ("%1").arg(num.toUInt()-1); @@ -2291,7 +2335,7 @@ } else { // Special case, look at orientation - if (xelection.single()->getOrientation()==OrientRightOfCenter) + if (xelection.single()->getOrientation()==LinkableMapObj::RightOfCenter) num=QString ("%1").arg(num.toInt()-1); else num=QString ("%1").arg(num.toInt()+1); @@ -2325,7 +2369,7 @@ BranchObj *bo=xelection.getBranch(); if (bo && xelection.type()==Branch) { - if (bo->getOrientation()==OrientRightOfCenter) + if (bo->getOrientation()==LinkableMapObj::RightOfCenter) selectPrevBranchInt(); else if (bo->getDepth()==1) @@ -2339,7 +2383,7 @@ { BranchObj *bo=xelection.getBranch(); if (bo && xelection.type()==Branch) - if (bo->getOrientation()==OrientRightOfCenter) + if (bo->getOrientation()==LinkableMapObj::RightOfCenter) selectNextBranchInt(); else if (bo->getDepth()==1) @@ -2363,7 +2407,7 @@ if (bo) { // Workaround for reselecting on left and right side - if (bo->getOrientation()==OrientRightOfCenter) + if (bo->getOrientation()==LinkableMapObj::RightOfCenter) bo=par->getLastBranch(); if (bo) { @@ -2376,7 +2420,7 @@ } else { par=(BranchObj*)(sel->getParObj()); - if (sel->getOrientation()==OrientRightOfCenter) + if (sel->getOrientation()==LinkableMapObj::RightOfCenter) { if (xelection.type() == Branch || xelection.type() == FloatImage) @@ -2416,7 +2460,7 @@ if (bo) { // Workaround for reselecting on left and right side - if (bo->getOrientation()==OrientLeftOfCenter) + if (bo->getOrientation()==LinkableMapObj::LeftOfCenter) bo=par->getFirstBranch(); if (bo) { @@ -2428,7 +2472,7 @@ } else { par=(BranchObj*)(xelection.single()->getParObj()); - if (xelection.single()->getOrientation()==OrientLeftOfCenter) + if (xelection.single()->getOrientation()==LinkableMapObj::LeftOfCenter) { if (xelection.type() == Branch || xelection.type() == FloatImage) @@ -3025,13 +3069,13 @@ ); if (s=="StyleLine") - linkstyle=StyleLine; + linkstyle=LinkableMapObj::Line; else if (s=="StyleParabel") - linkstyle=StyleParabel; + linkstyle=LinkableMapObj::Parabel; else if (s=="StylePolyLine") - linkstyle=StylePolyLine; + linkstyle=LinkableMapObj::PolyLine; else - linkstyle=StylePolyParabel; + linkstyle=LinkableMapObj::PolyParabel; BranchObj *bo; bo=mapCenter->first(); @@ -3044,7 +3088,7 @@ mapCenter->reposition(); } -LinkStyle MapEditor::getMapLinkStyle () +LinkableMapObj::Style MapEditor::getMapLinkStyle () { return linkstyle; } @@ -3067,7 +3111,7 @@ } } -void MapEditor::setMapLinkColorHint(LinkColorHint lch) +void MapEditor::setMapLinkColorHint(LinkableMapObj::ColorHint lch) { linkcolorhint=lch; setMapLinkColorHintInt(); @@ -3075,10 +3119,10 @@ void MapEditor::toggleMapLinkColorHint() { - if (linkcolorhint==HeadingColor) - linkcolorhint=DefaultColor; + if (linkcolorhint==LinkableMapObj::HeadingColor) + linkcolorhint=LinkableMapObj::DefaultColor; else - linkcolorhint=HeadingColor; + linkcolorhint=LinkableMapObj::HeadingColor; BranchObj *bo; bo=mapCenter->first(); while (bo) @@ -3088,7 +3132,7 @@ } } -LinkColorHint MapEditor::getMapLinkColorHint() +LinkableMapObj::ColorHint MapEditor::getMapLinkColorHint() { return linkcolorhint; } @@ -3162,9 +3206,8 @@ return xelection.getColor(); } -bool MapEditor::scrollBranch() +bool MapEditor::scrollBranch(BranchObj *bo) { - BranchObj *bo=xelection.getBranch(); if (bo) { if (bo->isScrolled()) return false; @@ -3187,9 +3230,8 @@ return false; } -bool MapEditor::unscrollBranch() +bool MapEditor::unscrollBranch(BranchObj *bo) { - BranchObj *bo=xelection.getBranch(); if (bo) { if (!bo->isScrolled()) return false; @@ -3218,13 +3260,13 @@ if (xelection.type()==Branch ) { if (bo->isScrolled()) - unscrollBranch (); + unscrollBranch (bo); else - scrollBranch (); + scrollBranch (bo); } } -void MapEditor::unscrollChilds() // FIXME saveState missing +void MapEditor::unscrollChilds() { BranchObj *bo=xelection.getBranch(); if (bo) @@ -3232,7 +3274,7 @@ bo->first(); while (bo) { - if (bo->isScrolled()) bo->toggleScroll(); + if (bo->isScrolled()) unscrollBranch (bo); bo=bo->next(); } } @@ -3351,40 +3393,79 @@ } } -void MapEditor::setFrameType(const FrameType &t) // FIXME missing saveState +void MapEditor::setFrameType(const FrameObj::FrameType &t) { BranchObj *bo=xelection.getBranch(); if (bo) { + QString s=bo->getFrameTypeName(); 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(); bo->updateLink(); } } -void MapEditor::setFrameType(const QString &s) // FIXME missing saveState +void MapEditor::setFrameType(const QString &s) { BranchObj *bo=xelection.getBranch(); if (bo) { + 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(); bo->updateLink(); } } -void MapEditor::setFramePenColor(const QColor &c) // FIXME missing saveState +void MapEditor::setFramePenColor(const QColor &c) { BranchObj *bo=xelection.getBranch(); if (bo) + { + saveState (bo, QString("setFramePenColor (\"%1\")").arg(bo->getFramePenColor().name() ), + bo, QString ("setFramePenColor (\"%1\")").arg(c.name() ),QString ("set pen color of frame to %1").arg(c.name() )); bo->setFramePenColor (c); + } } -void MapEditor::setFrameBrushColor(const QColor &c) // FIXME missing saveState +void MapEditor::setFrameBrushColor(const QColor &c) { BranchObj *bo=xelection.getBranch(); if (bo) + { + saveState (bo, QString("setFrameBrushColor (\"%1\")").arg(bo->getFrameBrushColor().name() ), + bo, QString ("setFrameBrushColor (\"%1\")").arg(c.name() ),QString ("set brush color of frame to %1").arg(c.name() )); bo->setFrameBrushColor (c); + } +} + +void MapEditor::setFramePadding (const int &) +{ + BranchObj *bo=xelection.getBranch(); + /* + if (bo) + { + saveState (bo, QString("setFrameBrushColor (\"%1\")").arg(bo->getFrameBrushColor().name() ), + bo, QString ("setFrameBrushColor (\"%1\")").arg(c.name() ),QString ("set brush color of frame to %1").arg(c.name() )); + bo->setFrameBrushColor (c); + } + */ +} + +void MapEditor::setFrameBorderWidth(const int &) +{ + BranchObj *bo=xelection.getBranch(); + /* + if (bo) + { + saveState (bo, QString("setFrameBrushColor (\"%1\")").arg(bo->getFrameBrushColor().name() ), + bo, QString ("setFrameBrushColor (\"%1\")").arg(c.name() ),QString ("set brush color of frame to %1").arg(c.name() )); + bo->setFrameBrushColor (c); + } + */ } void MapEditor::setIncludeImagesVer(bool b) @@ -3550,6 +3631,8 @@ { // This is the playground + BranchObj *bo=xelection.getBranch(); + if (bo) animObjList.append( bo ); /* WarningDialog dia; @@ -3636,13 +3719,13 @@ { switch (mainWindow->getModMode()) { - case ModModeColor: + case Main::ModModeColor: setCursor (PickColorCursor); break; - case ModModeCopy: + case Main::ModModeCopy: setCursor (CopyCursor); break; - case ModModeXLink: + case Main::ModModeXLink: setCursor (XLinkCursor); break; default : @@ -3706,13 +3789,13 @@ // No system flag clicked, take care of modmodes (CTRL-Click) if (e->state() & Qt::ControlModifier) { - if (mainWindow->getModMode()==ModModeColor) + if (mainWindow->getModMode()==Main::ModModeColor) { pickingColor=true; setCursor (PickColorCursor); return; } - if (mainWindow->getModMode()==ModModeXLink) + if (mainWindow->getModMode()==Main::ModModeXLink) { BranchObj *bo_begin=NULL; if (lmo) @@ -3754,7 +3837,7 @@ // If modMode==copy, then we want to "move" the _new_ object around // then we need the offset from p to the _old_ selection, because of tmp - if (mainWindow->getModMode()==ModModeCopy && + if (mainWindow->getModMode()==Main::ModModeCopy && e->state() & Qt::ControlModifier) { if (xelection.type()==Branch) @@ -3801,7 +3884,7 @@ if ( lmosel && movingObj) { // reset cursor if we are moving and don't copy - if (mainWindow->getModMode()!=ModModeCopy) + if (mainWindow->getModMode()!=Main::ModModeCopy) setCursor (Qt::ArrowCursor); // To avoid jumping of the sceneView, only @@ -3878,7 +3961,7 @@ } else { // Move ordinary branch - if (lmosel->getOrientation() == OrientLeftOfCenter) + if (lmosel->getOrientation() == LinkableMapObj::LeftOfCenter) // Add width of bbox here, otherwise alignRelTo will cause jumping around lmosel->move(p.x() -movingObj_start.x()+lmosel->getBBox().width(), p.y()-movingObj_start.y() +lmosel->getTopPad() ); @@ -3958,7 +4041,7 @@ } // Have we been drawing a link? - if (drawingLink) + if (drawingLink) //FIXME savestate missing { drawingLink=false; // Check if we are over another branch @@ -3968,7 +4051,7 @@ tmpXLink->setEnd ( ((BranchObj*)(dst)) ); tmpXLink->updateXLink(); tmpXLink->activate(); - //saveStateComplete(QString("Activate xLink from %1 to %2").arg(getName(tmpXLink->getBegin())).arg(getName(tmpXLink->getEnd())) ); //FIXME undoCommand + //saveStateComplete(QString("Activate xLink from %1 to %2").arg(getName(tmpXLink->getBegin())).arg(getName(tmpXLink->getEnd())) ); } else { delete(tmpXLink); @@ -4187,8 +4270,28 @@ event->acceptProposedAction(); } -/* -void MapEditor::contentsDropEvent(QDropEvent *event) +void MapEditor::timerEvent(QTimerEvent *event) //FIXME testing +{ + Q_UNUSED(event); + + cout << "ME::timerEvent\n"; + + for (int i=0; ianimate(); + ((BranchObj*)animObjList.at(i))->move2RelPos (((BranchObj*)animObjList.at(i))->getRelPos() ); + } + mapCenter->reposition(); +} + +void MapEditor::autosave() +{ + if (mapUnsaved &&mapChanged && settings.value ("/mapeditor/autosave/used",true).toBool() ) + mainWindow->fileSave (this); +} + + +/*FIXME not needed? void MapEditor::contentsDropEvent(QDropEvent *event) { } else if (event->provides("application/x-moz-file-promise-url") && @@ -4256,12 +4359,9 @@ BranchObj *bo=xelection.getBranch(); if (bo) { - //FIXME XXX saveStateChangingPart(selection,QString("Add floatimage to %1").arg(getName(bo))); - //QString fn=fd->selectedFile(); - //lastImageDir=fn.left(fn.findRev ("/")); FloatImageObj *fio=bo->addFloatImage(); fio->load(img); - fio->setOriginalFilename("Image added by Drag and Drop"); + fio->setOriginalFilename("Image added by Drag and Drop"); // FIXME savestate mapCenter->reposition(); scene()->update(); } diff -r 83a3be747ad9 -r 8b9cfc26638c mapeditor.h --- a/mapeditor.h Wed Apr 25 16:02:54 2007 +0000 +++ b/mapeditor.h Wed Apr 25 16:02:54 2007 +0000 @@ -8,10 +8,13 @@ #include "file.h" #include "misc.h" #include "parser.h" +#include "ornamentedobj.h" #include "selection.h" #include "settings.h" +/*! \brief Main widget in vym to display and edit the map */ + class MapEditor : public QGraphicsView, public xmlObj { Q_OBJECT @@ -21,6 +24,8 @@ MapCenterObj* getMapCenter(); QGraphicsScene * getScene(); bool isRepositionBlocked(); // block while load or undo + bool isSaveStateBlocked(); // block while undo/redo or while running scripts + void setSaveStateBlocked(bool); private: QString getName(const LinkableMapObj*); // Get e.g. heading or filename @@ -59,8 +64,8 @@ void setSmoothPixmap(bool); private: QPixmap getPixmap(); - void setHideTmpMode (HideTmpMode); // temporary hide stuff - HideTmpMode getHideTmpMode(); // temporary hide stuff + void setHideTmpMode (BranchObj::HideTmpMode); // temporary hide stuff + BranchObj::HideTmpMode getHideTmpMode(); // temporary hide stuff public: void setExportMode (bool); // temporary hide stuff during export void exportImage (QString fn); // export as PNG @@ -152,11 +157,11 @@ void setMapAuthor (const QString &); void setMapComment(const QString &); void setMapLinkStyle (const QString &); // Set style of link - LinkStyle getMapLinkStyle (); // requested in LMO + LinkableMapObj::Style getMapLinkStyle (); // requested in LMO void setMapDefLinkColor(QColor); // default color of links void setMapLinkColorHintInt(); // color of links - void setMapLinkColorHint(LinkColorHint);// color of links - LinkColorHint getMapLinkColorHint(); + void setMapLinkColorHint(LinkableMapObj::ColorHint);// color of links + LinkableMapObj::ColorHint getMapLinkColorHint(); QColor getMapDefLinkColor(); void setMapDefXLinkColor(QColor); QColor getMapDefXLinkColor(); @@ -170,8 +175,8 @@ public: void setSelectionColor(QColor); QColor getSelectionColor(); - bool scrollBranch(); - bool unscrollBranch(); + bool scrollBranch(BranchObj*); + bool unscrollBranch(BranchObj*); void toggleScroll(); void unscrollChilds(); private: @@ -182,10 +187,12 @@ void saveFloatImageInt (FloatImageObj*, const QString &, const QString &); public: void saveFloatImage (); - void setFrameType(const FrameType &); + void setFrameType(const FrameObj::FrameType &); void setFrameType(const QString &); void setFramePenColor (const QColor &); void setFrameBrushColor (const QColor &); + void setFramePadding (const int &); + void setFrameBorderWidth (const int &); void setIncludeImagesVer(bool); void setIncludeImagesHor(bool); void setHideLinkUnselected (bool); @@ -204,18 +211,25 @@ virtual void keyPressEvent(QKeyEvent*); virtual void keyReleaseEvent(QKeyEvent*); virtual void mousePressEvent(QMouseEvent*); + virtual void mouseMoveEvent(QMouseEvent*); virtual void mouseReleaseEvent(QMouseEvent*); virtual void mouseDoubleClickEvent(QMouseEvent*); - virtual void mouseMoveEvent(QMouseEvent*); + virtual void resizeEvent( QResizeEvent * ); void dragEnterEvent (QDragEnterEvent *); void dragMoveEvent (QDragMoveEvent *); void dragLeaveEvent (QDragLeaveEvent *); void dropEvent (QDropEvent *); + void timerEvent(QTimerEvent *event); + +private slots: + void autosave (); + private: QGraphicsScene *mapScene; MapCenterObj* mapCenter; + QTimer *autosaveTimer; bool adjustCanvasRequested; // collect requests until end of user event BranchObj *editingBO; // entering Text into BO @@ -223,8 +237,8 @@ QColor defLinkColor; // default color for links QColor defXLinkColor; // default color for xlinks int defXLinkWidth; // default width for xlinks - LinkColorHint linkcolorhint;// use heading color or own color - LinkStyle linkstyle; // default style for links + LinkableMapObj::ColorHint linkcolorhint;// use heading color or own color + LinkableMapObj::Style linkstyle; // default style for links QCursor HandOpenCursor; // cursor while moving canvas view QCursor PickColorCursor; // cursor while picking color @@ -273,9 +287,10 @@ bool EOFind; // true, if search failed QPoint exportOffset; // set before export, used in save - HideTmpMode hidemode; // true while exporting to hide some stuff - - void resizeEvent( QResizeEvent * ); + BranchObj::HideTmpMode hidemode; // true while exporting to hide some stuff + + int timerId; // animation timer + QList animObjList;// list with animated objects }; #endif