# HG changeset patch # User insilmaril # Date 1107871639 0 # Node ID 9db3eaa212376c4f1458dae2201e0c8464f1ba94 # Parent 9771028de303fc3c9aad444b277effca9d40aea1 added contextmenu to follow links diff -r 9771028de303 -r 9db3eaa21237 Makefile --- a/Makefile Mon Jan 31 09:47:43 2005 +0000 +++ b/Makefile Tue Feb 08 14:07:19 2005 +0000 @@ -1,6 +1,6 @@ ############################################################################# # Makefile for building: vym -# Generated by qmake (1.07a) (Qt 3.3.1) on: Mon Jan 31 00:05:28 2005 +# Generated by qmake (1.07a) (Qt 3.3.1) on: Mon Feb 7 11:52:57 2005 # Project: vym.pro # Template: app # Command: $(QMAKE) -o Makefile vym.pro @@ -12,14 +12,14 @@ CXX = g++ LEX = flex YACC = yacc -CFLAGS = -pipe -O2 -march=i586 -mcpu=i686 -fmessage-length=0 -Wall -fPIC -Wall -W -O2 -march=i586 -mcpu=i686 -fmessage-length=0 -Wall -fPIC -DQT_NO_DEBUG -DQT_SHARED -DQT_TABLET_SUPPORT -DQT_THREAD_SUPPORT -CXXFLAGS = -pipe -O2 -march=i586 -mcpu=i686 -fmessage-length=0 -Wall -fPIC -Wall -W -O2 -march=i586 -mcpu=i686 -fmessage-length=0 -Wall -fPIC -DQT_NO_DEBUG -DQT_SHARED -DQT_TABLET_SUPPORT -DQT_THREAD_SUPPORT +CFLAGS = -pipe -O2 -fmessage-length=0 -Wall -fPIC -Wall -W -O2 -fmessage-length=0 -Wall -fPIC -DQT_NO_DEBUG -DQT_SHARED -DQT_TABLET_SUPPORT -DQT_THREAD_SUPPORT +CXXFLAGS = -pipe -O2 -fmessage-length=0 -Wall -fPIC -Wall -W -O2 -fmessage-length=0 -Wall -fPIC -DQT_NO_DEBUG -DQT_SHARED -DQT_TABLET_SUPPORT -DQT_THREAD_SUPPORT LEXFLAGS = YACCFLAGS= -d INCPATH = -I/usr/lib/qt3/mkspecs/linux-g++ -I. -I/usr/include -I$(QTDIR)/include LINK = g++ LFLAGS = -LIBS = $(SUBLIBS) -L/usr/lib/ -L$(QTDIR)/lib/ -L/usr/X11R6/lib/ -lqt-mt -lXext -lX11 -lm +LIBS = $(SUBLIBS) -L/usr/lib64/ -L$(QTDIR)/lib64/ -L/usr/X11R6/lib64/ -lqt-mt -lXext -lX11 -lm AR = ar cqs RANLIB = MOC = $(QTDIR)/bin/moc @@ -199,7 +199,7 @@ $(MOC): ( cd $(QTDIR)/src/moc && $(MAKE) ) -Makefile: vym.pro /usr/lib/qt3/mkspecs/linux-g++/qmake.conf /usr/lib/qt3/lib/libqt-mt.prl +Makefile: vym.pro /usr/lib/qt3/mkspecs/linux-g++/qmake.conf /usr/lib/qt3/lib64/libqt-mt.prl $(QMAKE) -o Makefile vym.pro qmake: @$(QMAKE) -o Makefile vym.pro @@ -684,9 +684,10 @@ moc_texteditor.o: moc_texteditor.cpp texteditor.h -moc_exporthtmldialog.o: moc_exporthtmldialog.cpp exporthtmldialog.h +moc_exporthtmldialog.o: moc_exporthtmldialog.cpp exporthtmldialog.h showtextdialog.h -moc_exportxhtmldialog.o: moc_exportxhtmldialog.cpp exportxhtmldialog.h +moc_exportxhtmldialog.o: moc_exportxhtmldialog.cpp exportxhtmldialog.h process.h \ + showtextdialog.h moc_showtextdialog.o: moc_showtextdialog.cpp showtextdialog.h diff -r 9771028de303 -r 9db3eaa21237 branchobj.cpp --- a/branchobj.cpp Mon Jan 31 09:47:43 2005 +0000 +++ b/branchobj.cpp Tue Feb 08 14:07:19 2005 +0000 @@ -181,6 +181,11 @@ return floatimage.count(); } +int BranchObj::countLinks() +{ + return link.count(); +} + void BranchObj::setParObjTmp(LinkableMapObj* lmo, QPoint m, int off) { // Temporary link to lmo @@ -807,6 +812,14 @@ return link.count(); } +BranchObj* BranchObj::linkTargetAt (int i) +{ + if (link.at(i)) + return link.at(i)->otherBranch (this); + else + return NULL; +} + LinkableMapObj* BranchObj::addFloatImage () { FloatImageObj *newfi=new FloatImageObj (canvas,this); diff -r 9771028de303 -r 9db3eaa21237 branchobj.h --- a/branchobj.h Mon Jan 31 09:47:43 2005 +0000 +++ b/branchobj.h Tue Feb 08 14:07:19 2005 +0000 @@ -28,6 +28,7 @@ virtual int getFloatImageNum(FloatImageObj*); virtual int countBranches(); virtual int countFloatImages(); + virtual int countLinks(); virtual void setParObjTmp (LinkableMapObj*,QPoint,int);// Only for moving Obj around virtual void unsetParObjTmp(); // reuse original ParObj @@ -66,6 +67,7 @@ virtual void removeLink (LinkObj*); virtual void deleteLink (LinkObj*); virtual int countLink (); + virtual BranchObj* linkTargetAt (int); virtual LinkableMapObj* addFloatImage(); virtual LinkableMapObj* addFloatImage(FloatImageObj*); virtual void removeFloatImage(FloatImageObj*); diff -r 9771028de303 -r 9db3eaa21237 demos/todo.vym Binary file demos/todo.vym has changed diff -r 9771028de303 -r 9db3eaa21237 icons/icons.xcf Binary file icons/icons.xcf has changed diff -r 9771028de303 -r 9db3eaa21237 icons/modecolor.xpm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/icons/modecolor.xpm Tue Feb 08 14:07:19 2005 +0000 @@ -0,0 +1,48 @@ +/* XPM */ +static char * mode_color_xpm[] = { +"32 32 13 1", +" c None", +". c #FF0000", +"+ c #0026FF", +"@ c #5519AA", +"# c #BF0940", +"$ c #AA0D55", +"% c #C60839", +"& c #8E1171", +"* c #391EC6", +"= c #1C22E3", +"- c #71158E", +"; c #E3041C", +"> c #DB0524", +" ", +" ..... ", +" ... ", +" .. +++++++@. ", +" .......#$$%&+++*&%#..... ", +" .. +++=%-+*;@=+ ", +" .. +++++$+;*+++ ", +" +++++;$*++++ ", +" ++++$%@++++++ ", +" +++*;@%-+++++ ... ", +" +++@@++$;@@@%.. ", +" ++++%@+++*@%.... ", +" ..... @=+*$+++++++++ .. ", +" ...%$;*+++++++++ ", +" ..>*&%++++++++++++ ", +" -%=++++++++++++ ", +" ...+++++++++++++ ", +" ... +++++++++++ ", +" +++++++++++ ", +" ++++++++++ ", +" +++++++++++ ", +" +++++++++ ", +" ..... .... ...++.... ", +" . . . . . . +.+.++ ", +" . . . . . . +.+..+ ", +" . . . . . .++. ", +" . . .... ...++.... ", +" ", +" ", +" ", +" ", +" "}; diff -r 9771028de303 -r 9db3eaa21237 icons/modelink.xpm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/icons/modelink.xpm Tue Feb 08 14:07:19 2005 +0000 @@ -0,0 +1,48 @@ +/* XPM */ +static char * mode_link_xpm[] = { +"32 32 13 1", +" c None", +". c #FF0000", +"+ c #0026FF", +"@ c #5519AA", +"# c #BF0940", +"$ c #AA0D55", +"% c #C60839", +"& c #8E1171", +"* c #391EC6", +"= c #1C22E3", +"- c #71158E", +"; c #E3041C", +"> c #DB0524", +" ", +" ..... ", +" ... ", +" .. @. ", +" .......#$$%& *&%#..... ", +" .. =%- *;@= ", +" .. $ ;* ", +" ;$* ", +" $%@ ", +" *;@%- ... ", +" @@ $;@@@%.. ", +" %@ *@%.... ", +" ..... @= *$ .. ", +" ...%$;* ", +" ..>*&% ", +" -%= ", +" ... ", +" ... ", +" ", +" ", +" ", +" ", +" ..... .... ... .... ", +" . . . . . . . . ", +" . . . . . . . .. ", +" . . . . . . . ", +" . . .... ... .... ", +" ", +" ", +" ", +" ", +" "}; diff -r 9771028de303 -r 9db3eaa21237 linkobj.cpp --- a/linkobj.cpp Mon Jan 31 09:47:43 2005 +0000 +++ b/linkobj.cpp Tue Feb 08 14:07:19 2005 +0000 @@ -136,6 +136,16 @@ } } +BranchObj* LinkObj::otherBranch(BranchObj* thisBranch) +{ + if (!beginBranch && !endBranch) + return NULL; + if (thisBranch==beginBranch) + return endBranch; + else + return beginBranch; +} + void LinkObj::positionBBox() { } diff -r 9771028de303 -r 9db3eaa21237 linkobj.h --- a/linkobj.h Mon Jan 31 09:47:43 2005 +0000 +++ b/linkobj.h Tue Feb 08 14:07:19 2005 +0000 @@ -20,6 +20,7 @@ void deactivate(); // removes those pointers bool isUsed(); // true, if at least on branch uses it void updateLink(); + BranchObj* otherBranch (BranchObj*); void positionBBox(); void calcBBoxSize(); void setVisibility (bool); diff -r 9771028de303 -r 9db3eaa21237 main.cpp --- a/main.cpp Mon Jan 31 09:47:43 2005 +0000 +++ b/main.cpp Tue Feb 08 14:07:19 2005 +0000 @@ -50,6 +50,7 @@ QAction *actionEditSelectLast; QAction *actionEditLoadImage; QAction *actionEditToggleFloatExport; +QAction *actionEditNoLink; QAction *actionFormatColor; QAction *actionFormatPickColor; @@ -59,6 +60,10 @@ QAction *actionFormatLinkColorHint; QAction *actionFormatLinkColor; +QActionGroup *actionGroupModModes; +QAction *actionModModeColor; +QAction *actionModModeLink; + QActionGroup *actionGroupFormatFrameTypes; QAction *actionFormatFrameNone; QAction *actionFormatFrameRectangle; @@ -78,6 +83,7 @@ QAction *actionSettingsUseDelKey; QPopupMenu *branchContextMenu; +QPopupMenu *branchLinksContextMenu; QPopupMenu *floatimageContextMenu; QPopupMenu *saveImageFormatMenu; QPopupMenu *canvasContextMenu; diff -r 9771028de303 -r 9db3eaa21237 mainwindow.cpp --- a/mainwindow.cpp Mon Jan 31 09:47:43 2005 +0000 +++ b/mainwindow.cpp Tue Feb 08 14:07:19 2005 +0000 @@ -37,6 +37,8 @@ #include "icons/viewzoomreset.xpm" #include "icons/viewzoomin.xpm" #include "icons/viewzoomout.xpm" +#include "icons/modecolor.xpm" +#include "icons/modelink.xpm" #include "icons/vym-48x48.xpm" #include "icons/flag-note.xpm" #include "icons/flag-url.xpm" @@ -88,6 +90,7 @@ extern QAction *actionEditSelectLast; extern QAction *actionEditLoadImage; extern QAction *actionEditToggleFloatExport; +extern QAction *actionEditNoLink; extern QAction* actionFormatColor; extern QAction* actionFormatPickColor; @@ -97,6 +100,10 @@ extern QAction* actionFormatBackColor; extern QAction* actionFormatLinkColor; +extern QActionGroup* actionGroupModModes; +extern QAction* actionModModeColor; +extern QAction* actionModModeLink; + extern QActionGroup *actionGroupFormatFrameTypes; extern QAction *actionFormatFrameNone; extern QAction *actionFormatFrameRectangle; @@ -117,6 +124,7 @@ extern QAction* actionSettingsUseDelKey; extern QPopupMenu* branchContextMenu; +extern QPopupMenu* branchLinksContextMenu; extern QPopupMenu* floatimageContextMenu; extern QPopupMenu* saveImageFormatMenu; extern QPopupMenu* canvasContextMenu; @@ -189,6 +197,7 @@ setupEditActions(); setupFormatActions(); setupViewActions(); + setupModeActions(); setupFlagActions(); setupSettingsActions(); setupContextMenus(); @@ -476,7 +485,9 @@ actionEditHeading=a; a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Return, this, "editHeading" ); connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) ); - //a->addTo ( menu ); + actionEditHeading=a; + a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_F2, this, "editHeading" ); + connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) ); // Shortcut to delete selection a = new QAction( tr( "Delete Selection" ),tr( "Delete Selection" ), Key_Delete, this, "deleteBranch" ); @@ -554,6 +565,11 @@ a = new QAction( tr( "Add Image" ),tr( "Add Image" ), 0, this, "loadImage" ); connect( a, SIGNAL( activated() ), this, SLOT( editLoadImage() ) ); actionEditLoadImage=a; + + // inserted into branchLinksContextMenu, if no link is available. + a = new QAction( tr( "No link available" ),tr( "No link available" ), 0, this, "noLink" ); + a->setEnabled (false); + actionEditNoLink=a; } // Format Actions @@ -675,6 +691,29 @@ a->addTo( menu ); } +// Mode Actions +void Main::setupModeActions() +{ + //QPopupMenu *menu = new QPopupMenu( this ); + //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu ); + + QToolBar *tb = new QToolBar( this ); + tb->setLabel( "Modes (using modifiers)" ); + QAction *a; + actionGroupModModes=new QActionGroup ( this, "formatLinkStyles"); + actionGroupModModes->setExclusive (true); + a= new QAction( tr( "Use modifier to color branches" ), QPixmap(mode_color_xpm), tr( "Linkstyle Line" ), Key_C, actionGroupModModes, "modModeColor" ); + a->setToggleAction(true); + a->addTo (tb); + a->setOn(true); + actionModModeColor=a; + a= new QAction( tr( "Use modifier to draw links" ), QPixmap(mode_link_xpm), tr( "Linkstyle Line" ), Key_L, actionGroupModModes, "modModeLink" ); + + a->setToggleAction(true); + a->addTo (tb); + actionModModeLink=a; +} + // Flag Actions void Main::setupFlagActions() { @@ -799,6 +838,13 @@ branchContextMenu->insertSeparator(); actionGroupFormatFrameTypes->addTo( branchContextMenu ); + // Context Menu for links in a branch menu + // This will be populated "on demand" in MapEditor::updateActions + branchContextMenu->insertSeparator(); + branchLinksContextMenu =new QPopupMenu (this); + branchContextMenu->insertItem ("Goto Link",branchLinksContextMenu); + connect( branchLinksContextMenu, SIGNAL( activated(int) ), this, SLOT( editFollowLink(int ) ) ); + // Context menu for floatimage floatimageContextMenu =new QPopupMenu (this); saveImageFormatMenu=new QPopupMenu (this); @@ -1933,6 +1979,12 @@ currentMapEditor()->toggleFloatExport(); } +void Main::editFollowLink(int item) +{ + if (currentMapEditor()) + currentMapEditor()->followLink(branchLinksContextMenu->indexOf(item)); +} + void Main::formatSelectColor() { if (currentMapEditor()) @@ -2057,6 +2109,15 @@ currentMapEditor()->adjustCanvasSize(); } } + +void Main::modModeColor() +{ +} + +void Main::modModeLink() +{ +} + bool Main::settingsPDF() { // Default browser is set in constructor diff -r 9771028de303 -r 9db3eaa21237 mainwindow.h --- a/mainwindow.h Mon Jan 31 09:47:43 2005 +0000 +++ b/mainwindow.h Tue Feb 08 14:07:19 2005 +0000 @@ -38,6 +38,7 @@ void setupEditActions(); void setupFormatActions(); void setupViewActions(); + void setupModeActions(); void setupWindowActions(); void setupFlagActions(); void setupSettingsActions(); @@ -114,6 +115,7 @@ void editLoadImage(); void editSaveImage(int); void editToggleFloatExport(); + void editFollowLink (int); void formatSelectColor(); void formatPickColor(); @@ -134,6 +136,9 @@ void viewZoomIn(); void viewZoomOut(); + void modModeColor(); + void modModeLink(); + public slots: bool settingsPDF(); bool settingsURL(); diff -r 9771028de303 -r 9db3eaa21237 mapeditor.cpp --- a/mapeditor.cpp Mon Jan 31 09:47:43 2005 +0000 +++ b/mapeditor.cpp Tue Feb 08 14:07:19 2005 +0000 @@ -87,6 +87,7 @@ extern QAction *actionEditSelectLast; extern QAction *actionEditLoadImage; extern QAction *actionEditToggleFloatExport; +extern QAction *actionEditNoLink; extern QAction* actionFormatPickColor; extern QAction* actionFormatColorBranch; @@ -95,6 +96,10 @@ extern QAction *actionFormatBackColor; extern QAction *actionFormatLinkColor; +extern QActionGroup* actionGroupModModes; +extern QAction* actionModModeColor; +extern QAction* actionModModeLink; + extern QActionGroup *actionGroupFormatFrameTypes; extern QAction *actionFormatFrameNone; extern QAction *actionFormatFrameRectangle; @@ -113,6 +118,7 @@ extern QAction *actionSettingsPasteNewHeading; extern QPopupMenu *branchContextMenu; +extern QPopupMenu *branchLinksContextMenu; extern QPopupMenu *floatimageContextMenu; extern QPopupMenu *saveImageFormatMenu; extern QPopupMenu *exportImageFormatMenu; @@ -300,9 +306,6 @@ pickColorCursor=QCursor ( cursorcolorpicker_xpm, 5,27 ); #endif - modifierMode=pickColorMode; - //modifierMode=linkObjectsMode; // FIXME testing - pickingColor=false; editingBO=NULL; @@ -2229,9 +2232,34 @@ if ( (typeid(*selection) == typeid(BranchObj)) || (typeid(*selection) == typeid(MapCenterObj)) ) { + BranchObj *bo=(BranchObj*)(selection); + // Take care of links + if (bo->countLinks()==0) + { + branchLinksContextMenu->clear(); + branchLinksContextMenu->insertItem ("No link available"); + + } else + { + BranchObj *bot; + QString s; + branchLinksContextMenu->clear(); + for (int i=0; i<=bo->countLinks();i++) + { + bot=bo->linkTargetAt(i); + if (bot) + { + s=bot->getHeading(); + if (s.length()>25) + s=s.left(25)+"..."; + branchLinksContextMenu->insertItem (s); + } + } + } + standardFlagsDefault->setEnabled (true); - if ( ((BranchObj*)(selection))->getURL().isEmpty() ) + if ( bo->getURL().isEmpty() ) actionEditOpenURL->setEnabled (false); else actionEditOpenURL->setEnabled (true); @@ -2239,7 +2267,7 @@ actionEditHeading2URL->setEnabled (true); actionEditBugzilla2URL->setEnabled (true); - if ( ((BranchObj*)(selection))->getVymLink().isEmpty() ) + if ( bo->getVymLink().isEmpty() ) { actionEditOpenVymLink->setEnabled (false); actionEditDeleteVymLink->setEnabled (false); @@ -2643,13 +2671,24 @@ } } +void MapEditor::followLink(int i) +{ + cout << "ME::followLink "<linkTargetAt(i); + if (bo) + { + cout << "follow to "<getHeading()<unselect(); + selection=bo; + selection->select(); + ensureSelectionVisible(); + } +} + void MapEditor::testFunction() { cout << "MapEditor::testFunction() called\n"; - if (modifierMode==pickColorMode) - modifierMode=linkObjectsMode; - else - modifierMode=pickColorMode; + branchLinksContextMenu->setEnabled (false); } void MapEditor::ensureSelectionVisible() @@ -2728,7 +2767,7 @@ // Special case: CTRL is pressed if (e->state() & QMouseEvent::ControlButton) { - if (modifierMode==pickColorMode) + if (actionModModeColor->isOn()) { if (e->state() & QMouseEvent::ControlButton) { @@ -2737,21 +2776,21 @@ return; } } - if (modifierMode==linkObjectsMode) + if (actionModModeLink->isOn()) { - if (lmo && - (typeid(*lmo) == typeid(BranchObj)) || - (typeid(*lmo) == typeid(MapCenterObj)) ) + if (selection && + ((typeid(*selection) == typeid(BranchObj)) || + (typeid(*selection) == typeid(MapCenterObj))) ) { drawingLink=true; linkingObj_src=selection; tmpLink=new LinkObj (mapCanvas); - tmpLink->setBegin ( ((BranchObj*)(lmo)) ); + tmpLink->setBegin ( ((BranchObj*)(selection)) ); tmpLink->setEnd (p); tmpLink->updateLink(); tmpLink->setVisibility (true); return; - } + } } } @@ -2826,6 +2865,7 @@ // Move the selected MapObj if ( selection && movingObj) { + ensureVisible (p.x(),p.y()); // Now move the selection, but add relative position // (movingObj_start) where selection was chosen with @@ -2909,7 +2949,7 @@ } // reposition subbranch lmosel->reposition(); - ensureSelectionVisible(); + //ensureSelectionVisible(); if (lmo && (lmo!=selection) && (typeid(*lmo) == typeid(BranchObj) || diff -r 9771028de303 -r 9db3eaa21237 mapeditor.h --- a/mapeditor.h Mon Jan 31 09:47:43 2005 +0000 +++ b/mapeditor.h Tue Feb 08 14:07:19 2005 +0000 @@ -11,8 +11,6 @@ #include "mapcenterobj.h" #include "misc.h" -enum ModifierMode {pickColorMode,linkObjectsMode}; - class MapEditor : public QCanvasView , public xmlObj { Q_OBJECT @@ -130,6 +128,7 @@ void importDir(BranchObj *,QDir); public: void importDir(); + void followLink (int); void testFunction(); // FIXME just testing protected: @@ -154,8 +153,6 @@ LinkColorHint linkcolorhint;// use heading color or own color LinkStyle linkstyle; // default style for links - ModifierMode modifierMode; // pick color or link objects? - QCursor handOpenCursor; // cursor while moving canvas view QCursor pickColorCursor; // cursor while picking color bool pickingColor; diff -r 9771028de303 -r 9db3eaa21237 version.h --- a/version.h Mon Jan 31 09:47:43 2005 +0000 +++ b/version.h Tue Feb 08 14:07:19 2005 +0000 @@ -1,7 +1,7 @@ #ifndef VERSION_H #define VERSION_H -#define __VYM_VERSION__ "1.6.1" -#define __BUILD_DATE__ "January 31, 2005" +#define __VYM_VERSION__ "1.6.2" +#define __BUILD_DATE__ "February 8, 2005" #endif