diff -r 3a58c9ef4a18 -r 0e1aeb21cb78 mapeditor.cpp --- a/mapeditor.cpp Thu Sep 14 11:38:18 2006 +0000 +++ b/mapeditor.cpp Mon Oct 16 12:42:54 2006 +0000 @@ -1,23 +1,5 @@ #include "mapeditor.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include #include #include #include @@ -49,76 +31,8 @@ extern QString tmpVymDir; extern QString clipboardDir; extern bool clipboardEmpty; -extern FlagRowObj *systemFlagsDefault; extern FlagRowObj *standardFlagsDefault; -extern Q3PtrList actionListBranches; - -extern QAction *actionFileSave; -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 *actionEditURL; -extern QAction *actionEditHeading2URL; -extern QAction *actionEditBugzilla2URL; -extern QAction *actionEditFATE2URL; -extern QAction *actionEditOpenVymLink; -extern QAction *actionEditVymLink; -extern QAction *actionEditDeleteVymLink; -extern QAction *actionEditToggleHideExport; -extern QAction *actionEditHeading; -extern QAction *actionEditDelete; -extern QAction *actionEditAddBranch; -extern QAction *actionEditAddBranchAbove; -extern QAction *actionEditAddBranchBelow; -extern QAction *actionEditRemoveBranchHere; -extern QAction *actionEditRemoveChilds; -extern QAction *actionEditImportAdd; -extern QAction *actionEditImportReplace; -extern QAction *actionEditSaveBranch; -extern QAction *actionEditSelectFirst; -extern QAction *actionEditSelectLast; -extern QAction *actionEditLoadImage; - -extern QAction* actionFormatPickColor; -extern QAction* actionFormatColorBranch; -extern QAction* actionFormatColorSubtree; -extern QAction *actionFormatLinkColorHint; -extern QAction *actionFormatBackColor; -extern QAction *actionFormatLinkColor; - -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 *actionFormatIncludeImagesVer; -extern QAction *actionFormatIncludeImagesHor; -extern QAction *actionFormatHideLinkUnselected; -extern QAction *actionFormatLinkStyleLine; -extern QAction *actionFormatLinkStyleParabel; -extern QAction *actionFormatLinkStylePolyLine; -extern QAction *actionFormatLinkStylePolyParabel; - -extern QAction *actionViewToggleNoteEditor; - -extern QAction *actionSettingsAutoedit; -extern QAction *actionSettingsAutoselectHeading; -extern QAction *actionSettingsAutoselectText; -extern QAction *actionSettingsUseFlagGroups; - extern QMenu* branchContextMenu; extern QMenu* branchAddContextMenu; extern QMenu* branchRemoveContextMenu; @@ -145,7 +59,7 @@ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// MapEditor::MapEditor( - QWidget* parent, bool interactive, const char* name, Qt::WFlags f) : + QWidget* parent, const char* name, Qt::WFlags f) : Q3CanvasView(parent,name,f), urlOperator(0), imageBuffer(0) { //cout << "Constructor ME "<backgroundColor(); } @@ -493,6 +401,7 @@ NULL); } +/* FIXME not used void MapEditor::saveStateComData(LinkableMapObj *undoSel, const QString &uc, LinkableMapObj *redoSel, const QString &rc, const QString &comment, LinkableMapObj *saveSel) { QString redoSelection=""; @@ -506,6 +415,7 @@ comment, saveSel); } +*/ void MapEditor::saveState(LinkableMapObj *undoSel, const QString &uc, LinkableMapObj *redoSel, const QString &rc, const QString &comment) { @@ -833,8 +743,6 @@ mapChanged=true; mapDefault=false; mapUnsaved=true; - actionEditUndo->setEnabled (true); - actionFileSave->setEnabled (true); findReset(); } @@ -1000,7 +908,7 @@ { mapChanged=false; mapUnsaved=false; - actionFileSave->setEnabled(false); + updateActions(); } return returnCode; @@ -1369,6 +1277,14 @@ } +bool MapEditor::isRedoAvailable() +{ + if (undoSet.readNumEntry("/history/undosAvail",0)>0) + return true; + else + return false; +} + void MapEditor::undo() { blockSaveState=true; @@ -1434,6 +1350,14 @@ updateActions(); } +bool MapEditor::isUndoAvailable() +{ + if (undoSet.readNumEntry("/history/undosAvail",0)>0) + return true; + else + return false; +} + void MapEditor::gotoStep (int i) { // Restore variables @@ -1744,15 +1668,15 @@ adjustCanvasSize(); - if (actionSettingsAutoedit->isOn() || - actionSettingsAutoselectHeading->isOn() ) + if (mainWindow->autoEdit() || + mainWindow->autoSelectHeading() ) { selection->unselect(); selection=newbo; selection->select(); - if (actionSettingsAutoedit->isOn() ) + if (mainWindow->autoEdit() ) mainWindow->editHeading(); - if (!actionSettingsAutoselectHeading->isOn() + if (!mainWindow->autoSelectHeading() )//&& !wasScrolled) //FIXME wasScrolled was moved to addNewBranchInt { selection->unselect(); @@ -1787,15 +1711,15 @@ mapCenter->reposition(); adjustCanvasSize(); - if (actionSettingsAutoedit->isOn() || - actionSettingsAutoselectHeading->isOn() ) + if (mainWindow->autoEdit() || + mainWindow->autoSelectHeading() ) { selection->unselect(); selection=newbo; selection->select(); - if (actionSettingsAutoedit->isOn() ) + if (mainWindow->autoEdit() ) mainWindow->editHeading(); - if (!actionSettingsAutoselectHeading->isOn() + if (!mainWindow->autoSelectHeading() && !wasScrolled) { selection->unselect(); @@ -2345,7 +2269,7 @@ saveStateConstSelection(QString("%1 (\"%2\")").arg(u).arg(f), QString("%1 (\"%2\")").arg(r).arg(f), QString("Toggling standard flag \"%1\" of %2").arg(f).arg(getName(bo))); - bo->toggleStandardFlag (f,actionSettingsUseFlagGroups->isOn()); + bo->toggleStandardFlag (f,mainWindow->useFlagGroups()); adjustCanvasSize(); } } @@ -2571,7 +2495,6 @@ s="Set"; } saveStateComplete(QString ("%1 hide export flag of %2").arg(s).arg(getName(selection))); //TODO undoCommand - actionEditToggleHideExport->setOn (oo->hideInExport()); updateActions(); mapCenter->reposition(); adjustCanvasSize(); @@ -2683,190 +2606,8 @@ void MapEditor::updateActions() { - QAction *a; - if (getLinkColorHint()==HeadingColor) - actionFormatLinkColorHint->setOn(true); - else - actionFormatLinkColorHint->setOn(false); - - switch (linkstyle) - { - 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( mapCanvas->backgroundColor() ); - actionFormatBackColor->setIconSet( pix ); - pix.fill( defLinkColor ); - actionFormatLinkColor->setIconSet( pix ); - - actionFileSave->setEnabled( mapUnsaved ); - if (undoSet.readNumEntry("/history/undosAvail",0)>0) - actionEditUndo->setEnabled( true); - else - actionEditUndo->setEnabled( false); - - if (undoSet.readNumEntry("/history/redosAvail",0)>0) - actionEditRedo->setEnabled( true); - else - actionEditRedo->setEnabled( false); - - 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 - { -//FIXME do this in mainwindow standardFlagsDefault->setEnabled (false); - - 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); - } + mainWindow->updateActions(); + // FIXME maybe don't update if blockReposition is set } void MapEditor::updateNoteFlag() @@ -3417,13 +3158,13 @@ // Special case: CTRL is pressed if (e->state() & Qt::ControlModifier) { - if (actionModModeColor->isOn()) + if (mainWindow->getModMode()==ModModeColor) { pickingColor=true; setCursor (pickColorCursor); return; } - if (actionModModeLink->isOn()) + if (mainWindow->getModMode()==ModModeXLink) { BranchObj *bo_begin=NULL; if (lmo) @@ -3462,7 +3203,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 (actionModModeCopy->isOn() && + if (mainWindow->getModMode()==ModModeCopy && e->state() & Qt::ControlModifier) { if (typeid(*selection)==typeid(BranchObj) )