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) ||