diff -r bb94eec7c8f3 -r 0e1aeb21cb78 mainwindow.cpp --- a/mainwindow.cpp Thu Sep 21 13:48:05 2006 +0000 +++ b/mainwindow.cpp Mon Oct 16 12:42:54 2006 +0000 @@ -1,24 +1,10 @@ #include "mainwindow.h" #include -#include -#include -#include + #include -#include -#include -#include -#include -//Added by qt3to4: #include -#include -#include -#include -#include -#include -#include #include -//#include // for random seed #include #include @@ -49,94 +35,17 @@ extern FlagRowObj* standardFlagsDefault; extern FlagRowObj* systemFlagsDefault; -extern Q3PtrList actionListBranches; - -extern QAction* actionFileSave; -extern QAction* actionFilePrint; -extern QAction* actionEditUndo; -extern QAction* actionEditRedo; -extern QAction *actionEditCopy; -extern QAction *actionEditCut; -extern QAction *actionEditPaste; -extern QAction *actionEditMoveUp; -extern QAction *actionEditMoveDown; -extern QAction *actionEditToggleScroll; -extern QAction* actionEditOpenURL; -extern QAction* actionEditOpenURLTab; -extern QAction* actionEditOpenMultipleURLTabs; -extern QAction* actionEditURL; -extern QAction* actionEditHeading2URL; -extern QAction* actionEditBugzilla2URL; -extern QAction* actionEditFATE2URL; -extern QAction *actionEditOpenVymLink; -extern QAction *actionEditOpenMultipleVymLinks; -extern QAction *actionEditVymLink; -extern QAction *actionEditDeleteVymLink; -extern QAction *actionEditToggleHideExport; -extern QAction *actionEditMapInfo; -extern QAction *actionEditHeading; -extern QAction *actionEditDelete; -extern QAction *actionEditAddBranch; -extern QAction *actionEditAddBranchHere; -extern QAction *actionEditAddBranchAbove; -extern QAction *actionEditAddBranchBelow; -extern QAction *actionEditRemoveBranchKeepChilds; -extern QAction *actionEditRemoveChilds; -extern QAction *actionEditImportAdd; -extern QAction *actionEditImportReplace; -extern QAction *actionEditSaveBranch; -extern QAction *actionEditSelectFirst; -extern QAction *actionEditSelectLast; -extern QAction *actionEditLoadImage; - -extern QAction* actionFormatColor; -extern QAction* actionFormatPickColor; -extern QAction* actionFormatColorBranch; -extern QAction* actionFormatColorSubtree; -extern QAction* actionFormatLinkColorHint; -extern QAction* actionFormatBackColor; -extern QAction* actionFormatLinkColor; -extern QAction *actionFormatIncludeImagesVer; -extern QAction *actionFormatIncludeImagesHor; - -extern QActionGroup* actionGroupModModes; -extern QAction* actionModModeColor; -extern QAction* actionModModeLink; -extern QAction* actionModModeCopy; - -extern QActionGroup *actionGroupFormatFrameTypes; -extern QAction *actionFormatFrameNone; -extern QAction *actionFormatFrameRectangle; - -extern QActionGroup *actionGroupFormatLinkStyles; -extern QAction *actionFormatLinkStyleLine; -extern QAction *actionFormatLinkStyleParabel; -extern QAction *actionFormatLinkStylePolyLine; -extern QAction *actionFormatLinkStylePolyParabel; -extern QAction *actionFormatHideLinkUnselected; - -extern QAction *actionViewToggleNoteEditor; -extern QAction *actionViewToggleHistoryWindow; - -extern QAction* actionSettingsAutoedit; -extern QAction* actionSettingsAutoselectHeading; -extern QAction* actionSettingsAutoselectHeading; -extern QAction* actionSettingsAutoselectText; -extern QAction* actionSettingsUseDelKey; -extern QAction* actionSettingsUseFlagGroups; -extern QAction* actionSettingsUseHideExport; - -extern QMenu* branchContextMenu; -extern QMenu* branchAddContextMenu; -extern QMenu* branchRemoveContextMenu; -extern QMenu* branchLinksContextMenu; -extern QMenu* branchXLinksContextMenuEdit; -extern QMenu* branchXLinksContextMenuFollow; -extern QMenu* floatimageContextMenu; -extern QMenu* canvasContextMenu; -extern QMenu* fileLastMapsMenu; -extern QMenu* fileImportMenu; -extern QMenu* fileExportMenu; +QMenu* branchContextMenu; +QMenu* branchAddContextMenu; +QMenu* branchRemoveContextMenu; +QMenu* branchLinksContextMenu; +QMenu* branchXLinksContextMenuEdit; +QMenu* branchXLinksContextMenuFollow; +QMenu* floatimageContextMenu; +QMenu* canvasContextMenu; +QMenu* fileLastMapsMenu; +QMenu* fileImportMenu; +QMenu* fileExportMenu; extern Settings settings; @@ -252,6 +161,7 @@ // Connect TextEditor, so that we can update flags if text changes connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag())); + connect (textEditor, SIGNAL (textClosed() ), this, SLOT (updateActions())); updateGeometry(); } @@ -267,9 +177,9 @@ settings.setValue( "/version/version", __VYM_VERSION ); settings.setValue( "/version/builddate", __BUILD_DATE ); - settings.setValue( "/mapeditor/editmode/autoSelectHeading",actionSettingsAutoselectHeading->isOn() ); - settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoselectText->isOn() ); - settings.setValue( "/mapeditor/editmode/autoEdit",actionSettingsAutoedit->isOn() ); + settings.setValue( "/mapeditor/editmode/autoSelectHeading",actionSettingsAutoSelectHeading->isOn() ); + settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() ); + settings.setValue( "/mapeditor/editmode/autoEdit",actionSettingsAutoEdit->isOn() ); settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() ); settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() ); settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() ); @@ -957,19 +867,19 @@ connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameRectangle() ) ); actionFormatFrameRectangle=a; - a = new QAction( tr( "Include images vertically" ), actionFormatIncludeImagesVer); + a = new QAction( tr( "Include images vertically" ), 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" ), actionFormatIncludeImagesHor ); + a = new QAction( tr( "Include images horizontally" ), 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" ), actionFormatHideLinkUnselected); + a = new QAction( tr( "Hide link if object is not selected" ), this); a->setStatusTip (tr( "Hide link" )); a->setToggleAction(true); connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) ); @@ -1093,7 +1003,7 @@ a->setStatusTip( tr( "Use modifier to draw xLinks" )); a->setToggleAction(true); a->addTo (tb); - actionModModeLink=a; + actionModModeXLink=a; } // Flag Actions @@ -1438,21 +1348,21 @@ a->setToggleAction(true); a->setOn ( settings.value ("/mapeditor/editmode/autoEdit",true).toBool()); settingsMenu->addAction (a); - actionSettingsAutoedit=a; + actionSettingsAutoEdit=a; a= new QAction( tr( "Select branch after adding it" ), this ); a->setStatusTip( tr( "Select branch after adding it" )); a->setToggleAction(true); a->setOn ( settings.value ("/mapeditor/editmode/autoSelectHeading",false).toBool() ); settingsMenu->addAction (a); - actionSettingsAutoselectHeading=a; + actionSettingsAutoSelectHeading=a; a= new QAction(tr( "Select existing heading" ), this); a->setStatusTip( tr( "Select heading before editing" )); a->setToggleAction(true); a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() ); settingsMenu->addAction (a); - actionSettingsAutoselectText=a; + actionSettingsAutoSelectText=a; a= new QAction( tr( "Delete key" ), this); a->setStatusTip( tr( "Delete key for deleting branches" )); @@ -1739,7 +1649,7 @@ void Main::fileNew() { QString fn="unnamed"; - MapEditor* medit = new MapEditor ( NULL,true); + MapEditor* medit = new MapEditor ( NULL); tabWidget->addTab (medit,fn); tabWidget->showPage(medit); medit->viewport()->setFocus(); @@ -1807,7 +1717,7 @@ // create a new mapeditor in a new tab if ( lmode==NewMap && (!me || !me->isDefault() ) ) { - me= new MapEditor ( NULL,true); + me= new MapEditor ( NULL); tabWidget->addTab (me,fn); tabIndex=tabWidget->indexOf (me); tabWidget->setCurrentPage (tabIndex); @@ -2978,7 +2888,7 @@ { if (currentMapEditor()) { - QColor col = QColorDialog::getColor( currentMapEditor()->color(), this ); + QColor col = QColorDialog::getColor( currentMapEditor()->getColor(), this ); if ( !col.isValid() ) return; currentMapEditor()->setColor( col ); colorChanged( col ); @@ -3117,14 +3027,6 @@ } } -void Main::modModeColor() -{ -} - -void Main::modModeLink() -{ -} - bool Main::settingsPDF() { // Default browser is set in constructor @@ -3182,6 +3084,222 @@ currentMapEditor()->updateNoteFlag(); } +void Main::updateActions() +{ + MapEditor *me=currentMapEditor(); + if (!me) return; + + // updateActions is also called when NoteEditor is closed + actionViewToggleNoteEditor->setOn (textEditor->isVisible()); + + QAction *a; + if (me->getLinkColorHint()==HeadingColor) + actionFormatLinkColorHint->setOn(true); + else + actionFormatLinkColorHint->setOn(false); + + switch (me->getLinkStyle()) + { + case StyleLine: + actionFormatLinkStyleLine->setOn(true); + break; + case StyleParabel: + actionFormatLinkStyleParabel->setOn(true); + break; + case StylePolyLine: + actionFormatLinkStylePolyLine->setOn(true); + break; + case StylePolyParabel: + actionFormatLinkStylePolyParabel->setOn(true); + break; + default: + break; + } + + QPixmap pix( 16, 16 ); + pix.fill( me->getBackgroundColor() ); + actionFormatBackColor->setIconSet( pix ); + pix.fill( me->getDefLinkColor() ); + actionFormatLinkColor->setIconSet( pix ); + + actionFileSave->setEnabled( me->isUnsaved() ); + if (me->isUndoAvailable()) + actionEditUndo->setEnabled( true); + else + actionEditUndo->setEnabled( false); + + if (me->isRedoAvailable()) + actionEditRedo->setEnabled( true); + else + actionEditRedo->setEnabled( false); + + LinkableMapObj *selection=me->getSelection(); + if (selection) + { + if ( (typeid(*selection) == typeid(BranchObj)) || + (typeid(*selection) == typeid(MapCenterObj)) ) + { + BranchObj *bo=(BranchObj*)selection; + // Take care of links + if (bo->countXLinks()==0) + { + branchXLinksContextMenuEdit->clear(); + branchXLinksContextMenuFollow->clear(); + } else + { + BranchObj *bot; + QString s; + branchXLinksContextMenuEdit->clear(); + branchXLinksContextMenuFollow->clear(); + for (int i=0; i<=bo->countXLinks();i++) + { + bot=bo->XLinkTargetAt(i); + if (bot) + { + s=bot->getHeading(); + if (s.length()>25) + s=s.left(25)+"..."; + branchXLinksContextMenuFollow->addAction (s); + branchXLinksContextMenuEdit->addAction (s); + } + } + } + + standardFlagsDefault->setEnabled (true); + + actionEditToggleScroll->setEnabled (true); + if ( bo->isScrolled() ) + actionEditToggleScroll->setOn(true); + else + actionEditToggleScroll->setOn(false); + + if ( bo->getURL().isEmpty() ) + { + actionEditOpenURL->setEnabled (false); + actionEditOpenURLTab->setEnabled (false); + } + else + { + actionEditOpenURL->setEnabled (true); + actionEditOpenURLTab->setEnabled (true); + } + if ( bo->getVymLink().isEmpty() ) + { + actionEditOpenVymLink->setEnabled (false); + actionEditDeleteVymLink->setEnabled (false); + } else + { + actionEditOpenVymLink->setEnabled (true); + actionEditDeleteVymLink->setEnabled (true); + } + + if (bo->canMoveBranchUp()) + actionEditMoveUp->setEnabled (true); + else + actionEditMoveUp->setEnabled (false); + if (bo->canMoveBranchDown()) + actionEditMoveDown->setEnabled (true); + else + actionEditMoveDown->setEnabled (false); + + + actionEditToggleHideExport->setEnabled (true); + actionEditToggleHideExport->setOn (bo->hideInExport() ); + + actionEditCopy->setEnabled (true); + actionEditCut->setEnabled (true); + if (!clipboardEmpty) + actionEditPaste->setEnabled (true); + else + actionEditPaste->setEnabled (false); + for (a=actionListBranches.first();a;a=actionListBranches.next()) + a->setEnabled(true); + actionEditDelete->setEnabled (true); + switch (selection->getFrameType()) + { + case NoFrame: + actionFormatFrameNone->setOn(true); + break; + case Rectangle: + actionFormatFrameRectangle->setOn(true); + break; + default: + break; + } + actionFormatIncludeImagesVer->setOn + ( ((BranchObj*)selection)->getIncludeImagesVer()); + actionFormatIncludeImagesHor->setOn + ( ((BranchObj*)selection)->getIncludeImagesHor()); + actionFormatHideLinkUnselected->setOn + (selection->getHideLinkUnselected()); + } + if ( (typeid(*selection) == typeid(FloatImageObj)) ) + { + FloatObj *fo=(FloatImageObj*)selection; +//FIXME do this in mainwindow standardFlagsDefault->setEnabled (false); + + actionEditOpenURL->setEnabled (false); + actionEditOpenVymLink->setEnabled (false); + actionEditDeleteVymLink->setEnabled (false); + actionEditToggleHideExport->setEnabled (true); + actionEditToggleHideExport->setOn (fo->hideInExport() ); + + + actionEditCopy->setEnabled (true); + actionEditCut->setEnabled (true); + actionEditPaste->setEnabled (false); + for (a=actionListBranches.first();a;a=actionListBranches.next()) + a->setEnabled(false); + actionEditDelete->setEnabled (true); + actionFormatHideLinkUnselected->setOn + ( selection->getHideLinkUnselected()); + actionEditMoveUp->setEnabled (false); + actionEditMoveDown->setEnabled (false); + } + + } else + { + actionEditCopy->setEnabled (false); + actionEditCut->setEnabled (false); + actionEditPaste->setEnabled (false); + for (a=actionListBranches.first();a;a=actionListBranches.next()) + a->setEnabled(false); + + actionEditToggleScroll->setEnabled (false); + actionEditOpenURL->setEnabled (false); + actionEditOpenVymLink->setEnabled (false); + actionEditDeleteVymLink->setEnabled (false); + actionEditHeading2URL->setEnabled (false); + actionEditDelete->setEnabled (false); + actionEditMoveUp->setEnabled (false); + actionEditMoveDown->setEnabled (false); + actionEditToggleHideExport->setEnabled (false); + } +} + +ModMode Main::getModMode() +{ + if (actionModModeColor->isOn()) return ModModeColor; + if (actionModModeCopy->isOn()) return ModModeCopy; + if (actionModModeXLink->isOn()) return ModModeXLink; + return ModModeNone; +} + +bool Main::autoEdit() +{ + return actionSettingsAutoEdit->isOn(); +} + +bool Main::autoSelectHeading() +{ + return actionSettingsAutoSelectHeading->isOn(); +} + +bool Main::useFlagGroups() +{ + return actionSettingsUseFlagGroups->isOn(); +} + void Main::windowShowNoteEditor() { textEditor->setShowWithMain(true);