insilmaril@0: #include "mainwindow.h" insilmaril@0: insilmaril@0: #include insilmaril@0: #include insilmaril@0: #include insilmaril@0: #include insilmaril@0: #include insilmaril@0: #include insilmaril@0: #include insilmaril@0: #include insilmaril@0: #include insilmaril@0: #include insilmaril@0: #include insilmaril@0: #include insilmaril@175: //#include // for random seed insilmaril@0: insilmaril@0: insilmaril@0: #include insilmaril@95: #include insilmaril@0: #include insilmaril@0: insilmaril@205: #include "aboutdialog.h" insilmaril@205: #include "exportoofiledialog.h" insilmaril@228: #include "exports.h" insilmaril@205: #include "exportxhtmldialog.h" insilmaril@205: #include "file.h" insilmaril@0: #include "flagrowobj.h" insilmaril@205: #include "imports.h" insilmaril@0: #include "mapeditor.h" insilmaril@205: #include "misc.h" insilmaril@205: #include "options.h" insilmaril@0: #include "process.h" insilmaril@0: #include "settings.h" insilmaril@205: #include "showtextdialog.h" insilmaril@205: #include "texteditor.h" insilmaril@205: #include "version.h" insilmaril@0: insilmaril@0: extern TextEditor *textEditor; insilmaril@0: extern Main *mainWindow; insilmaril@164: extern QString tmpVymDir; insilmaril@166: extern QString clipboardDir; insilmaril@166: extern bool clipboardEmpty; insilmaril@0: extern int statusbarTime; insilmaril@0: extern FlagRowObj* standardFlagsDefault; insilmaril@166: extern FlagRowObj* systemFlagsDefault; insilmaril@0: insilmaril@98: extern QPtrList actionListBranches; insilmaril@98: insilmaril@0: extern QAction* actionFileSave; insilmaril@0: extern QAction* actionFilePrint; insilmaril@0: extern QAction* actionEditUndo; insilmaril@163: extern QAction* actionEditRedo; insilmaril@0: extern QAction *actionEditCopy; insilmaril@0: extern QAction *actionEditCut; insilmaril@0: extern QAction *actionEditPaste; insilmaril@0: extern QAction *actionEditMoveUp; insilmaril@0: extern QAction *actionEditMoveDown; insilmaril@0: extern QAction *actionEditToggleScroll; insilmaril@0: extern QAction* actionEditOpenURL; insilmaril@266: extern QAction* actionEditOpenURLTab; insilmaril@0: extern QAction* actionEditURL; insilmaril@0: extern QAction* actionEditHeading2URL; insilmaril@0: extern QAction* actionEditBugzilla2URL; insilmaril@175: extern QAction* actionEditFATE2URL; insilmaril@0: extern QAction *actionEditOpenVymLink; insilmaril@0: extern QAction *actionEditVymLink; insilmaril@0: extern QAction *actionEditDeleteVymLink; insilmaril@243: extern QAction *actionEditToggleHideExport; insilmaril@0: extern QAction *actionEditMapInfo; insilmaril@0: extern QAction *actionEditHeading; insilmaril@0: extern QAction *actionEditDelete; insilmaril@0: extern QAction *actionEditAddBranch; insilmaril@98: extern QAction *actionEditAddBranchHere; insilmaril@0: extern QAction *actionEditAddBranchAbove; insilmaril@0: extern QAction *actionEditAddBranchBelow; insilmaril@294: extern QAction *actionEditRemoveBranchKeepChilds; insilmaril@98: extern QAction *actionEditRemoveChilds; insilmaril@0: extern QAction *actionEditImportAdd; insilmaril@0: extern QAction *actionEditImportReplace; insilmaril@0: extern QAction *actionEditSaveBranch; insilmaril@0: extern QAction *actionEditSelectFirst; insilmaril@0: extern QAction *actionEditSelectLast; insilmaril@0: extern QAction *actionEditLoadImage; insilmaril@0: insilmaril@0: extern QAction* actionFormatColor; insilmaril@0: extern QAction* actionFormatPickColor; insilmaril@0: extern QAction* actionFormatColorBranch; insilmaril@0: extern QAction* actionFormatColorSubtree; insilmaril@0: extern QAction* actionFormatLinkColorHint; insilmaril@0: extern QAction* actionFormatBackColor; insilmaril@0: extern QAction* actionFormatLinkColor; insilmaril@175: extern QAction *actionFormatIncludeImagesVer; insilmaril@175: extern QAction *actionFormatIncludeImagesHor; insilmaril@0: insilmaril@89: extern QActionGroup* actionGroupModModes; insilmaril@89: extern QAction* actionModModeColor; insilmaril@89: extern QAction* actionModModeLink; insilmaril@93: extern QAction* actionModModeCopy; insilmaril@89: insilmaril@0: extern QActionGroup *actionGroupFormatFrameTypes; insilmaril@0: extern QAction *actionFormatFrameNone; insilmaril@0: extern QAction *actionFormatFrameRectangle; insilmaril@0: insilmaril@0: extern QActionGroup *actionGroupFormatLinkStyles; insilmaril@0: extern QAction *actionFormatLinkStyleLine; insilmaril@0: extern QAction *actionFormatLinkStyleParabel; insilmaril@0: extern QAction *actionFormatLinkStylePolyLine; insilmaril@0: extern QAction *actionFormatLinkStylePolyParabel; insilmaril@160: extern QAction *actionFormatHideLinkUnselected; insilmaril@0: insilmaril@0: extern QAction *actionViewToggleNoteEditor; insilmaril@294: extern QAction *actionViewToggleHistoryWindow; insilmaril@0: insilmaril@0: extern QAction* actionSettingsAutoedit; insilmaril@0: extern QAction* actionSettingsAutoselectHeading; insilmaril@0: extern QAction* actionSettingsAutoselectHeading; insilmaril@0: extern QAction* actionSettingsAutoselectText; insilmaril@0: extern QAction* actionSettingsPasteNewHeading; insilmaril@0: extern QAction* actionSettingsUseDelKey; insilmaril@103: extern QAction* actionSettingsUseFlagGroups; insilmaril@260: extern QAction* actionSettingsUseHideExport; insilmaril@0: insilmaril@0: extern QPopupMenu* branchContextMenu; insilmaril@98: extern QPopupMenu* branchAddContextMenu; insilmaril@98: extern QPopupMenu* branchRemoveContextMenu; insilmaril@89: extern QPopupMenu* branchLinksContextMenu; insilmaril@94: extern QPopupMenu* branchLinksContextMenuDup; insilmaril@0: extern QPopupMenu* floatimageContextMenu; insilmaril@0: extern QPopupMenu* saveImageFormatMenu; insilmaril@0: extern QPopupMenu* canvasContextMenu; insilmaril@0: extern QPopupMenu* lastMapsMenu; insilmaril@205: extern QPopupMenu* importMenu; insilmaril@0: extern QPopupMenu* exportMenu; insilmaril@0: extern QPopupMenu* exportImageFormatMenu; insilmaril@0: insilmaril@0: insilmaril@0: extern Settings settings; insilmaril@0: extern Options options; insilmaril@269: extern QDir vymBaseDir; insilmaril@269: extern QString iconPath; insilmaril@269: extern QString flagsPath; insilmaril@0: insilmaril@0: #if defined(Q_OS_LINUX) insilmaril@0: extern void qt_wait_for_window_manager( QWidget* w ); insilmaril@0: #endif insilmaril@0: insilmaril@0: Main::Main(QWidget* parent, const char* name, WFlags f) : insilmaril@0: QMainWindow(parent,name,f) insilmaril@0: { insilmaril@0: mainWindow=this; insilmaril@0: insilmaril@0: setCaption ("VYM - View Your Mind"); insilmaril@0: insilmaril@0: // Load window settings insilmaril@0: resize (settings.readNumEntry( "/vym/mainwindow/geometry/width", 800), insilmaril@0: settings.readNumEntry( "/vym/mainwindow/geometry/height",600)); insilmaril@0: move (settings.readNumEntry( "/vym/mainwindow/geometry/posX", 100), insilmaril@0: settings.readNumEntry( "/vym/mainwindow/geometry/posY", 100)); insilmaril@0: insilmaril@0: insilmaril@164: // Create unique temporary directory insilmaril@164: tmpVymDir=makeUniqueDir ("/tmp/vym-XXXXXX"); insilmaril@164: insilmaril@166: // Create direcctory for clipboard insilmaril@166: clipboardDir=tmpVymDir+"/clipboard"; insilmaril@166: QDir d(clipboardDir); insilmaril@166: d.mkdir (clipboardDir,true); insilmaril@166: makeSubDirs (clipboardDir); insilmaril@166: clipboardEmpty=true; insilmaril@164: insilmaril@266: procBrowser=NULL; insilmaril@266: insilmaril@166: // FIXME not used currently insilmaril@93: // Set random seed (random used for object IDs) insilmaril@166: // QTime t = QTime::currentTime(); // set random seed insilmaril@166: // srand( t.hour()*12+t.minute()*60+t.second()*60 ); insilmaril@93: insilmaril@93: insilmaril@0: // Initialize some settings, which are platform dependant insilmaril@0: QString p,s; insilmaril@0: insilmaril@0: // application to open URLs insilmaril@0: p="/vym/mainwindow/readerURL"; insilmaril@0: #if defined(Q_OS_LINUX) insilmaril@0: s=settings.readEntry (p,"konqueror"); insilmaril@0: #else insilmaril@0: #if defined(Q_OS_MACX) insilmaril@104: s=settings.readEntry (p,"/usr/bin/open"); insilmaril@0: #else insilmaril@0: s=settings.readEntry (p,"mozilla"); insilmaril@0: #endif insilmaril@0: #endif insilmaril@0: settings.writeEntry( p,s); insilmaril@0: insilmaril@0: // application to open PDFs insilmaril@0: p="/vym/mainwindow/readerPDF"; insilmaril@0: #if defined(Q_OS_LINUX) insilmaril@0: s=settings.readEntry (p,"acroread"); insilmaril@0: #else insilmaril@0: #if defined(Q_OS_MACX) insilmaril@104: s=settings.readEntry (p,"/usr/bin/open"); insilmaril@0: #else insilmaril@0: s=settings.readEntry (p,"acroread"); insilmaril@0: #endif insilmaril@0: #endif insilmaril@0: settings.writeEntry( p,s); insilmaril@0: insilmaril@0: insilmaril@0: maxLastMaps=9; insilmaril@0: insilmaril@0: // Create tab widget which holds the maps insilmaril@0: tabWidget= new QTabWidget (this); insilmaril@0: connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ), insilmaril@0: this, SLOT( editorChanged( QWidget * ) ) ); insilmaril@0: insilmaril@0: setCentralWidget(tabWidget); insilmaril@0: insilmaril@0: setupFileActions(); insilmaril@0: setupEditActions(); insilmaril@0: setupFormatActions(); insilmaril@0: setupViewActions(); insilmaril@89: setupModeActions(); insilmaril@0: setupFlagActions(); insilmaril@0: setupSettingsActions(); insilmaril@0: setupContextMenus(); insilmaril@0: if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) setupTestActions(); insilmaril@0: setupHelpActions(); insilmaril@0: insilmaril@0: // After menu is created, we can enable some actions insilmaril@0: actionFilePrint->setEnabled (true); insilmaril@0: insilmaril@0: statusBar(); insilmaril@0: insilmaril@0: insilmaril@0: // Initialize Find window insilmaril@0: findWindow=new FindWindow(NULL,"findwindow"); insilmaril@0: connect (findWindow, SIGNAL( findButton(QString) ), insilmaril@0: this, SLOT(editFind(QString) ) ); insilmaril@0: connect (findWindow, SIGNAL( somethingChanged() ), insilmaril@0: this, SLOT(editFindChanged() ) ); insilmaril@0: insilmaril@160: // Connect TextEditor, so that we can update flags if text changes insilmaril@160: connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag())); insilmaril@160: insilmaril@0: updateGeometry(); insilmaril@0: } insilmaril@0: insilmaril@0: Main::~Main() insilmaril@0: { insilmaril@0: // Save Settings insilmaril@0: settings.writeEntry( "/vym/mainwindow/geometry/width", width() ); insilmaril@0: settings.writeEntry( "/vym/mainwindow/geometry/height", height() ); insilmaril@0: settings.writeEntry( "/vym/mainwindow/geometry/posX", pos().x() ); insilmaril@0: settings.writeEntry( "/vym/mainwindow/geometry/posY", pos().y() ); insilmaril@0: insilmaril@185: settings.writeEntry( "/vym/version/version", __VYM_VERSION ); insilmaril@185: settings.writeEntry( "/vym/version/builddate", __BUILD_DATE ); insilmaril@0: insilmaril@0: settings.writeEntry( "/vym/mapeditor/editmode/autoselectheading",actionSettingsAutoselectHeading->isOn() ); insilmaril@0: settings.writeEntry( "/vym/mapeditor/editmode/autoselecttext",actionSettingsAutoselectText->isOn() ); insilmaril@0: settings.writeEntry( "/vym/mapeditor/editmode/pastenewheading",actionSettingsPasteNewHeading->isOn() ); insilmaril@0: settings.writeEntry( "/vym/mapeditor/editmode/autoedit",actionSettingsAutoedit->isOn() ); insilmaril@0: settings.writeEntry( "/vym/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() ); insilmaril@103: settings.writeEntry( "/vym/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() ); insilmaril@260: settings.writeEntry( "/vym/export/useHideExport",actionSettingsUseHideExport->isOn() ); insilmaril@0: insilmaril@0: QString s; insilmaril@0: int maps=lastMaps.count(); insilmaril@0: settings.writeEntry( "/vym/lastMaps/number",maps ); insilmaril@0: for (int i=1;i<=maps;i++) insilmaril@0: { insilmaril@0: QStringList::Iterator it = lastMaps.at(i-1); insilmaril@0: s=QString("/vym/lastMaps/map-%1").arg(i); insilmaril@0: if (!s.isEmpty() && i<=maxLastMaps) insilmaril@0: settings.writeEntry (s, *it); insilmaril@0: } insilmaril@0: insilmaril@0: insilmaril@0: // To make the texteditor save its settings, call the destructor insilmaril@0: delete (textEditor); insilmaril@164: insilmaril@164: // Remove temporary directory insilmaril@164: removeDir (QDir(tmpVymDir)); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::loadCmdLine() insilmaril@0: { insilmaril@0: /* TODO draw some kind of splashscreen while loading... insilmaril@0: if (qApp->argc()>1) insilmaril@0: { insilmaril@0: } insilmaril@0: */ insilmaril@0: insilmaril@0: QStringList flist=options.getFileList(); insilmaril@0: QStringList::Iterator it=flist.begin(); insilmaril@0: insilmaril@0: while (it !=flist.end() ) insilmaril@0: { insilmaril@0: fileLoad (*it, NewMap); insilmaril@0: *it++; insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@0: insilmaril@0: void Main::statusMessage(const QString &s) insilmaril@0: { insilmaril@0: statusBar()->message (s); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::closeEvent (QCloseEvent* ) insilmaril@0: { insilmaril@0: fileExitVYM(); insilmaril@0: } insilmaril@0: insilmaril@0: // File Actions insilmaril@0: void Main::setupFileActions() insilmaril@0: { insilmaril@0: QToolBar *tb = new QToolBar( this ); insilmaril@0: tb->setLabel( "File Actions" ); insilmaril@0: QPopupMenu *menu = new QPopupMenu( this ); insilmaril@0: menuBar()->insertItem( tr( "&File" ), menu ); insilmaril@0: insilmaril@0: // Keycodes: /usr/lib64/qt3/include/qnamespace.h insilmaril@0: insilmaril@0: QAction *a; insilmaril@269: a = new QAction( tr( "New map","File menu" ), QPixmap( iconPath+"filenew.png"), tr( "&New..." ), CTRL + Key_N, this, "fileNew" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); insilmaril@0: a->addTo( tb ); insilmaril@0: a->addTo( menu ); insilmaril@0: insilmaril@269: a = new QAction( tr( "Open","File menu" ), QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ), CTRL + Key_O, this, "fileOpen" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( fileLoad() ) ); insilmaril@0: a->addTo( tb ); insilmaril@0: a->addTo( menu ); insilmaril@0: insilmaril@0: lastMapsMenu = new QPopupMenu (this); insilmaril@0: insilmaril@0: menu->insertItem (tr("Open Recent"),lastMapsMenu ); insilmaril@0: menu->insertSeparator(); insilmaril@0: insilmaril@269: a = new QAction( tr( "Save" ), QPixmap( iconPath+"filesave.png"), tr( "&Save..." ), CTRL + Key_S, this, "fileSave" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( fileSave() ) ); insilmaril@0: a->addTo( tb ); insilmaril@0: a->addTo( menu ); insilmaril@0: actionFileSave=a; insilmaril@0: insilmaril@269: a = new QAction( tr( "Save &As" ), QPixmap(iconPath+"filesaveas.png"), tr( "Save &As..." ), 0, this, "fileSaveAs" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( fileSaveAs() ) ); insilmaril@0: a->addTo( menu ); insilmaril@0: insilmaril@0: menu->insertSeparator(); insilmaril@0: insilmaril@205: importMenu = new QPopupMenu (this); insilmaril@205: menu->insertItem (tr("Import"),importMenu ); insilmaril@205: insilmaril@205: a = new QAction( tr( "Import")+" "+tr("KDE Bookmarks" ), QPixmap(), tr("KDE Bookmarks"), 0, this, "importKDEBookmarks" ); insilmaril@205: connect( a, SIGNAL( activated() ), this, SLOT( fileImportKDEBookmarks() ) ); insilmaril@205: a->addTo (importMenu); insilmaril@205: insilmaril@314: a = new QAction( tr( "Import")+" "+tr("Firefox Bookmarks" ), QPixmap(), tr("Firefox Bookmarks"), 0, this, "importFirefoxBookmarks" ); insilmaril@314: connect( a, SIGNAL( activated() ), this, SLOT( fileImportFirefoxBookmarks() ) ); insilmaril@314: a->addTo (importMenu); insilmaril@314: insilmaril@243: a = new QAction( tr( "Import")+" Mind Manager" , QPixmap(), "Mind Manager...", 0, this, "importMM" ); insilmaril@215: connect( a, SIGNAL( activated() ), this, SLOT( fileImportMM() ) ); insilmaril@215: a->addTo (importMenu); insilmaril@215: insilmaril@151: a = new QAction( tr( "Import directory structure (experimental)" ), QPixmap(), tr( "Import Dir"+QString("...") ), 0, this, "export" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( fileImportDir() ) ); insilmaril@205: a->addTo( importMenu); insilmaril@0: insilmaril@0: exportMenu = new QPopupMenu (this); insilmaril@0: menu->insertItem (tr("Export"),exportMenu ); insilmaril@0: insilmaril@0: menu->insertSeparator(); insilmaril@0: insilmaril@0: insilmaril@269: a = new QAction( tr( "Print" ), QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), CTRL + Key_P, this, "filePrint" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( filePrint() ) ); insilmaril@0: a->addTo( tb ); insilmaril@0: a->addTo( menu ); insilmaril@0: actionFilePrint=a; insilmaril@0: insilmaril@269: a = new QAction( tr( "Close Map" ), QPixmap(iconPath+"fileclose.png"), tr( "&Close Map" ), ALT + Key_C, this, "fileCloseMap" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( fileCloseMap() ) ); insilmaril@0: a->addTo( menu ); insilmaril@0: insilmaril@269: a = new QAction( tr( "Exit")+" "+__VYM, QPixmap(iconPath+"exit.png"), tr( "E&xit")+" "+__VYM, CTRL + Key_Q, this, "fileExitVYM" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( fileExitVYM() ) ); insilmaril@0: a->addTo( menu ); insilmaril@0: } insilmaril@0: insilmaril@0: insilmaril@0: //Edit Actions insilmaril@0: void Main::setupEditActions() insilmaril@0: { insilmaril@0: QToolBar *tb = new QToolBar( this ); insilmaril@0: tb->setLabel( "Edit Actions" ); insilmaril@0: QPopupMenu *menu = new QPopupMenu( this ); insilmaril@0: menuBar()->insertItem( tr( "&Edit" ), menu ); insilmaril@0: insilmaril@0: QAction *a; insilmaril@102: QAction *alt; insilmaril@269: a = new QAction( tr( "Undo" ), QPixmap( iconPath+"undo.png"), tr( "&Undo" ), CTRL + Key_Z, this, "editUndo" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( editUndo() ) ); insilmaril@0: a->setEnabled (false); insilmaril@0: a->addTo( tb ); insilmaril@0: a->addTo( menu ); insilmaril@0: actionEditUndo=a; insilmaril@163: insilmaril@163: if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) insilmaril@163: { insilmaril@269: a = new QAction( tr( "Redo" ), QPixmap( iconPath+"redo.png"), tr( "&Redo" ), CTRL + Key_Y, this, "editRedo" ); insilmaril@163: connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) ); insilmaril@163: a->addTo( tb ); insilmaril@163: a->addTo( menu ); insilmaril@163: } insilmaril@163: insilmaril@0: menu->insertSeparator(); insilmaril@269: a = new QAction( tr( "Copy" ), QPixmap( iconPath+"editcopy.png"), tr( "&Copy" ), CTRL + Key_C, this, "editCopy" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); insilmaril@0: a->setEnabled (false); insilmaril@0: a->addTo( tb ); insilmaril@0: a->addTo( menu ); insilmaril@0: actionEditCopy=a; insilmaril@269: a = new QAction( tr( "Cut" ), QPixmap( iconPath+"editcut.png" ), tr( "Cu&t" ), CTRL + Key_X, this, "editCut" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); insilmaril@0: a->setEnabled (false); insilmaril@0: a->addTo( tb ); insilmaril@0: a->addTo( menu ); insilmaril@0: actionEditCut=a; insilmaril@269: a = new QAction( tr( "Paste" ), QPixmap( iconPath+"editpaste.png"), tr( "&Paste" ), CTRL + Key_V, this, "editPaste" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); insilmaril@0: a->setEnabled (false); insilmaril@0: a->addTo( tb ); insilmaril@0: a->addTo( menu ); insilmaril@0: actionEditPaste=a; insilmaril@98: insilmaril@269: a = new QAction( tr( "Move branch up" ), QPixmap(iconPath+"up.png" ), tr( "Move up" ), Key_PageUp, this, "editMoveUp" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( editMoveUp() ) ); insilmaril@0: a->setEnabled (false); insilmaril@0: a->addTo( tb ); insilmaril@0: a->addTo( menu ); insilmaril@0: actionEditMoveUp=a; insilmaril@98: insilmaril@269: a = new QAction( tr( "Move branch down" ), QPixmap( iconPath+"down.png"), tr( "Move down" ), Key_PageDown, this, "editMoveDown" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( editMoveDown() ) ); insilmaril@0: a->setEnabled (false); insilmaril@0: a->addTo( tb ); insilmaril@0: a->addTo( menu ); insilmaril@0: actionEditMoveDown=a; insilmaril@98: insilmaril@0: insilmaril@269: a = new QAction( tr( "Scroll branch" ), QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ), Key_ScrollLock, this, "scroll" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) ); insilmaril@269: alt = new QAction( tr( "Scroll branch" ), QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ), Key_S, this, "scroll" ); insilmaril@102: connect( alt, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) ); insilmaril@102: #if defined(Q_OS_MACX) insilmaril@102: actionEditToggleScroll=alt; insilmaril@102: #else insilmaril@102: actionEditToggleScroll=a; insilmaril@102: #endif insilmaril@102: actionEditToggleScroll->setEnabled (false); insilmaril@250: actionEditToggleScroll->setToggleAction(true); insilmaril@102: actionEditToggleScroll->addTo( tb ); insilmaril@102: actionEditToggleScroll->addTo( menu ); insilmaril@102: actionListBranches.append(actionEditToggleScroll); insilmaril@0: insilmaril@0: a = new QAction( tr( "Unscroll all" ), QPixmap(), tr( "Unscroll all scrolled branches" ), 0, this, "scroll" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( editUnScrollAll() ) ); insilmaril@0: a->addTo( menu ); insilmaril@0: insilmaril@0: menu->insertSeparator(); insilmaril@0: insilmaril@269: a = new QAction( tr( "Find" ), QPixmap(iconPath+"find.png"), tr( "Find"+QString("...") ), CTRL + Key_F, this, "find" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( editOpenFindWindow() ) ); insilmaril@0: a->addTo( menu ); insilmaril@0: insilmaril@0: menu->insertSeparator(); insilmaril@0: insilmaril@269: a = new QAction( tr( "Open URL" ), QPixmap(flagsPath+"flag-url.png"), tr( "Open URL" ), CTRL + Key_U, this, "url" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( editOpenURL() ) ); insilmaril@0: a->addTo( tb ); insilmaril@0: a->setEnabled (false); insilmaril@0: actionEditOpenURL=a; insilmaril@0: insilmaril@267: a = new QAction( tr( "Open URL in new tab" ), QPixmap(), tr( "Open URL in new tab" ), CTRL + Key_U, this, "urltab" ); insilmaril@266: connect( a, SIGNAL( activated() ), this, SLOT( editOpenURLTab() ) ); insilmaril@266: a->setEnabled (false); insilmaril@266: actionEditOpenURLTab=a; insilmaril@266: insilmaril@151: a = new QAction( tr( "Edit URL" ), QPixmap(), tr( "Edit URL"+QString("...") ), SHIFT + CTRL + Key_U, this, "url" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( editURL() ) ); insilmaril@0: a->setEnabled (false); insilmaril@98: actionListBranches.append(a); insilmaril@0: actionEditURL=a; insilmaril@0: insilmaril@0: a = new QAction( tr( "Use heading of selected branch as URL" ), QPixmap(), tr( "Use heading for URL" ), 0, this, "heading2url" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( editHeading2URL() ) ); insilmaril@0: a->setEnabled (false); insilmaril@98: actionListBranches.append(a); insilmaril@0: actionEditHeading2URL=a; insilmaril@0: insilmaril@0: a = new QAction( tr( "Create URL to Bugzilla" ), QPixmap(), tr( "Create URL to Bugzilla" ), 0, this, "bugzilla2url" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( editBugzilla2URL() ) ); insilmaril@0: a->setEnabled (false); insilmaril@98: actionListBranches.append(a); insilmaril@0: actionEditBugzilla2URL=a; insilmaril@0: insilmaril@175: a = new QAction( tr( "Create URL to FATE" ), QPixmap(), tr( "Create URL to FATE" ), 0, this, "FATE2url" ); insilmaril@175: connect( a, SIGNAL( activated() ), this, SLOT( editFATE2URL() ) ); insilmaril@175: a->setEnabled (false); insilmaril@175: actionListBranches.append(a); insilmaril@175: actionEditFATE2URL=a; insilmaril@0: insilmaril@269: a = new QAction( tr( "Jump to another vym map, if needed load it first" ), QPixmap(flagsPath+"flag-vymlink.png"), tr( "Jump to map" ), 0, this, "jumpMap" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( editOpenVymLink() ) ); insilmaril@0: a->addTo( tb ); insilmaril@0: a->setEnabled (false); insilmaril@0: actionEditOpenVymLink=a; insilmaril@0: insilmaril@151: a = new QAction( tr( "Edit link to another vym map" ), QPixmap(), tr( "Edit vym link"+QString("...") ), 0, this, "editLinkMap" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( editVymLink() ) ); insilmaril@0: a->setEnabled (false); insilmaril@98: actionListBranches.append(a); insilmaril@0: actionEditVymLink=a; insilmaril@0: insilmaril@0: a = new QAction( tr( "Delete link to another vym map" ), QPixmap(), tr( "Delete vym link" ), 0, this, "deleteLinkMap" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( editDeleteVymLink() ) ); insilmaril@0: a->setEnabled (false); insilmaril@0: actionEditDeleteVymLink=a; insilmaril@0: insilmaril@269: a = new QAction( tr( "Hide object in exports" ), QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports" ), Key_H, this, "hideExport" ); insilmaril@243: connect( a, SIGNAL( activated() ), this, SLOT( editToggleHideExport() ) ); insilmaril@243: a->setToggleAction(true); insilmaril@243: a->addTo( tb ); insilmaril@243: a->setEnabled (false); insilmaril@243: actionEditToggleHideExport=a; insilmaril@243: insilmaril@151: a = new QAction( tr( "Edit Map Info" ), QPixmap(), tr( "Edit Map Info"+QString("...") ), 0, this, "editMapInfo" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( editMapInfo() ) ); insilmaril@0: a->setEnabled (true); insilmaril@0: actionEditMapInfo=a; insilmaril@0: insilmaril@0: menu->insertSeparator(); insilmaril@0: insilmaril@0: // Shortcuts to modify heading: insilmaril@0: a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Enter, this, "editHeading" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) ); insilmaril@98: actionListBranches.append(a); insilmaril@0: a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Return, this, "editHeading" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) ); insilmaril@98: actionListBranches.append(a); insilmaril@89: actionEditHeading=a; insilmaril@89: a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_F2, this, "editHeading" ); insilmaril@89: connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) ); insilmaril@102: a->setEnabled (false); insilmaril@102: actionEditHeading=a; insilmaril@98: actionListBranches.append(a); insilmaril@0: insilmaril@0: // Shortcut to delete selection insilmaril@0: a = new QAction( tr( "Delete Selection" ),tr( "Delete Selection" ), Key_Delete, this, "deleteBranch" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( editDeleteSelection() ) ); insilmaril@0: a->setEnabled (false); insilmaril@0: actionEditDelete=a; insilmaril@0: insilmaril@0: // Shortcut to add branch insilmaril@102: alt = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), Key_A, this, "newBranch" ); insilmaril@102: connect( alt, SIGNAL( activated() ), this, SLOT( editNewBranch() ) ); insilmaril@0: a = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), Key_Insert, this, "newBranch" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( editNewBranch() ) ); insilmaril@0: a->setEnabled (false); insilmaril@98: actionListBranches.append(a); insilmaril@102: #if defined (Q_OS_MACX) insilmaril@175: // In OSX show different shortcut in menues, the keys work independtly always insilmaril@102: actionEditAddBranch=alt; insilmaril@102: #else insilmaril@102: actionEditAddBranch=a; insilmaril@102: #endif insilmaril@0: insilmaril@98: // Add branch by inserting it at selection insilmaril@98: a = new QAction( tr( "Add a branch by inserting and making selection its child" ),tr( "Add branch (insert)" ), ALT + Key_Insert, this, "newBranchHere" ); insilmaril@98: connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) ); insilmaril@98: a->setEnabled (false); insilmaril@98: actionListBranches.append(a); insilmaril@98: actionEditAddBranchHere=a; insilmaril@175: a = new QAction( tr( "Add a branch by inserting and making selection its child" ),tr( "Add branch (insert)" ), ALT + Key_A, this, "newBranchHere" ); insilmaril@175: connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) ); insilmaril@175: actionListBranches.append(a); insilmaril@98: insilmaril@0: // Add branch above insilmaril@0: a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_Insert, this, "newBranch" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) ); insilmaril@0: a->setEnabled (false); insilmaril@98: actionListBranches.append(a); insilmaril@0: actionEditAddBranchAbove=a; insilmaril@175: a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_A, this, "newBranch" ); insilmaril@175: connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) ); insilmaril@175: actionListBranches.append(a); insilmaril@0: insilmaril@0: // Add branch below insilmaril@0: a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_Insert, this, "newBranch" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) ); insilmaril@0: a->setEnabled (false); insilmaril@98: actionListBranches.append(a); insilmaril@0: actionEditAddBranchBelow=a; insilmaril@175: a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_A, this, "newBranch" ); insilmaril@175: connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) ); insilmaril@175: actionListBranches.append(a); insilmaril@0: insilmaril@0: // Import at selection (adding to selection) insilmaril@228: a = new QAction( tr( "Add map at selection" ),tr( "Add map (insert)" ), 0, this, "importAdd" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( editImportAdd() ) ); insilmaril@0: a->setEnabled (false); insilmaril@98: actionListBranches.append(a); insilmaril@0: actionEditImportAdd=a; insilmaril@0: insilmaril@0: // Import at selection (replacing selection) insilmaril@228: a = new QAction( tr( "Replace selection with map" ),tr( "Add map (replace)" ), 0, this, "importReplace" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( editImportReplace() ) ); insilmaril@0: a->setEnabled (false); insilmaril@98: actionListBranches.append(a); insilmaril@0: actionEditImportReplace=a; insilmaril@0: insilmaril@0: // Save selection insilmaril@98: a = new QAction( tr( "Save selection" ),tr( "Save selection" ), 0, this, "saveSelection" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( editSaveBranch() ) ); insilmaril@0: a->setEnabled (false); insilmaril@98: actionListBranches.append(a); insilmaril@0: actionEditSaveBranch=a; insilmaril@0: insilmaril@98: // Only remove branch, not its childs insilmaril@98: a = new QAction( tr( "Remove only branch and keep its childs" ),tr( "Remove only branch " ), ALT + Key_Delete, this, "removeBranchHere" ); insilmaril@294: connect( a, SIGNAL( activated() ), this, SLOT( editRemoveBranchKeepChilds() ) ); insilmaril@98: a->setEnabled (false); insilmaril@98: actionListBranches.append(a); insilmaril@294: actionEditRemoveBranchKeepChilds=a; insilmaril@98: insilmaril@98: // Only remove childs of a branch insilmaril@98: a = new QAction( tr( "Remove childs of branch" ),tr( "Remove childs" ), SHIFT + Key_Delete, this, "removeBranchChilds" ); insilmaril@98: connect( a, SIGNAL( activated() ), this, SLOT( editRemoveChilds() ) ); insilmaril@98: a->setEnabled (false); insilmaril@98: actionListBranches.append(a); insilmaril@98: actionEditRemoveChilds=a; insilmaril@98: insilmaril@0: // Shortcuts for navigating with cursor: insilmaril@0: a = new QAction( tr( "Select upper branch" ),tr( "Select upper branch" ), Key_Up, this, "upperBranch" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( editUpperBranch() ) ); insilmaril@0: a = new QAction( tr( "Select lower branch" ),tr( "Select lower branch" ), Key_Down, this, "lowerBranch" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( editLowerBranch() ) ); insilmaril@0: a = new QAction( tr( "Select left branch" ),tr( "Select left branch" ), Key_Left, this, "upperBranch" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( editLeftBranch() ) ); insilmaril@0: a = new QAction( tr( "Select right branch" ),tr( "Select child branch" ), Key_Right, this, "rightBranch" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( editRightBranch() ) ); insilmaril@0: a = new QAction( tr( "Select first branch" ),tr( "Select first branch" ), Key_Home, this, "firstBranch" ); insilmaril@0: a->setEnabled (false); insilmaril@0: a->addTo ( menu ); insilmaril@98: actionListBranches.append(a); insilmaril@0: actionEditSelectFirst=a; insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( editFirstBranch() ) ); insilmaril@0: a = new QAction( tr( "Select last branch" ),tr( "Select last branch" ), Key_End, this, "lastBranch" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( editLastBranch() ) ); insilmaril@0: a->setEnabled (false); insilmaril@0: a->addTo ( menu ); insilmaril@98: actionListBranches.append(a); insilmaril@0: actionEditSelectLast=a; insilmaril@0: insilmaril@151: a = new QAction( tr( "Add Image" ),tr( "Add Image" )+QString("..."), 0, this, "loadImage" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( editLoadImage() ) ); insilmaril@0: actionEditLoadImage=a; insilmaril@89: insilmaril@0: } insilmaril@0: insilmaril@0: // Format Actions insilmaril@0: void Main::setupFormatActions() insilmaril@0: { insilmaril@0: QPopupMenu *menu = new QPopupMenu( this ); insilmaril@314: menuBar()->insertItem( tr( "F&ormat" ), menu ); insilmaril@0: insilmaril@0: QToolBar *tb = new QToolBar( this ); insilmaril@0: QAction *a; insilmaril@0: QPixmap pix( 16,16); insilmaril@0: pix.fill (black); insilmaril@151: actionFormatColor= new QAction( tr( "Set Color" ), pix, tr( "Set &Color" )+QString("..."), 0, this, "formatColor" ); insilmaril@0: connect( actionFormatColor, SIGNAL( activated() ), this, SLOT( formatSelectColor() ) ); insilmaril@0: actionFormatColor->addTo( tb ); insilmaril@0: actionFormatColor->addTo( menu ); insilmaril@269: a= new QAction( tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ), QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color" ), CTRL + Key_K, this, "pickColor" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( formatPickColor() ) ); insilmaril@0: a->setEnabled (false); insilmaril@0: a->addTo( tb ); insilmaril@0: a->addTo( menu ); insilmaril@98: actionListBranches.append(a); insilmaril@0: actionFormatPickColor=a; insilmaril@269: a= new QAction( tr( "Color branch" ), QPixmap(iconPath+"formatcoloritem.png"), tr( "Color &branch" ), CTRL + Key_I, this, "colorItem" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( formatColorItem() ) ); insilmaril@0: a->setEnabled (false); insilmaril@0: a->addTo( tb ); insilmaril@0: a->addTo( menu ); insilmaril@98: actionListBranches.append(a); insilmaril@0: actionFormatColorBranch=a; insilmaril@269: a= new QAction( tr( "Color Subtree" ), QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color sub&tree" ), CTRL + Key_T, this, "colorBranch" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( formatColorBranch() ) ); insilmaril@0: a->setEnabled (false); insilmaril@0: a->addTo( menu ); insilmaril@0: a->addTo( tb ); insilmaril@98: actionListBranches.append(a); insilmaril@0: actionFormatColorSubtree=a; insilmaril@0: insilmaril@0: menu->insertSeparator(); insilmaril@0: actionGroupFormatLinkStyles=new QActionGroup ( this, "formatLinkStyles"); insilmaril@0: actionGroupFormatLinkStyles->setExclusive (true); insilmaril@0: a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" ); insilmaril@0: a->setToggleAction(true); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleLine() ) ); insilmaril@0: actionFormatLinkStyleLine=a; insilmaril@0: a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" ); insilmaril@0: a->setToggleAction(true); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleParabel() ) ); insilmaril@0: actionFormatLinkStyleParabel=a; insilmaril@0: a= new QAction( tr( "PolyLine" ), QPixmap(), tr( "Linkstyle Thick Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" ); insilmaril@0: a->setToggleAction(true); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyLine() ) ); insilmaril@0: actionFormatLinkStylePolyLine=a; insilmaril@0: a= new QAction( tr( "PolyParabel" ), QPixmap(), tr( "Linkstyle Thick Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStylePolyParabel" ); insilmaril@0: a->setToggleAction(true); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyParabel() ) ); insilmaril@0: actionFormatLinkStylePolyParabel=a; insilmaril@0: actionGroupFormatLinkStyles->addTo (menu); insilmaril@0: insilmaril@0: actionGroupFormatFrameTypes=new QActionGroup ( this, "formatFrameTypes"); insilmaril@0: actionGroupFormatFrameTypes->setExclusive (true); insilmaril@0: a = new QAction( tr( "No Frame" ),tr( "No Frame" ), 0, actionGroupFormatFrameTypes, "frameNone" ); insilmaril@0: a->setToggleAction(true); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( formatFrameNone() ) ); insilmaril@0: actionFormatFrameNone=a; insilmaril@0: a = new QAction( tr( "Rectangle" ),tr( "Rectangle" ), 0, actionGroupFormatFrameTypes, "frameRectangle" ); insilmaril@0: a->setToggleAction(true); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( formatFrameRectangle() ) ); insilmaril@0: actionFormatFrameRectangle=a; insilmaril@0: insilmaril@175: a = new QAction( tr ("Include top and bottom position of images into branch"), tr( "Include images vertically" ), 0, actionFormatIncludeImagesVer, "includeImagesVer" ); insilmaril@175: a->setToggleAction(true); insilmaril@175: connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesVer() ) ); insilmaril@175: actionFormatIncludeImagesVer=a; insilmaril@175: insilmaril@175: a = new QAction( tr ("Include left and right position of images into branch"), tr( "Include images horizontally" ), 0, actionFormatIncludeImagesHor, "includeImagesHor" ); insilmaril@175: a->setToggleAction(true); insilmaril@175: connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesHor() ) ); insilmaril@175: actionFormatIncludeImagesHor=a; insilmaril@175: insilmaril@160: a = new QAction( tr( "Hide link" ),tr( "Hide link if object is not selected" ), 0, actionFormatHideLinkUnselected, "hideLinkUnselected" ); insilmaril@160: a->setToggleAction(true); insilmaril@160: connect( a, SIGNAL( activated() ), this, SLOT( formatHideLinkUnselected() ) ); insilmaril@160: actionFormatHideLinkUnselected=a; insilmaril@160: insilmaril@0: menu->insertSeparator(); insilmaril@0: a= new QAction( tr( "Use same color for links and headings" ), QPixmap(), tr( "&Use color of heading for link" ), 0, this, "formatLinkColorHint" ); insilmaril@0: a->setToggleAction(true); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( formatToggleLinkColorHint() ) ); insilmaril@0: a->addTo( menu ); insilmaril@0: actionFormatLinkColorHint=a; insilmaril@0: pix.fill (white); insilmaril@151: actionFormatLinkColor= new QAction( tr( "Set Link Color" ), pix, tr( "Set &Link Color"+QString("...") ), 0, this, "formatLinkColor" ); insilmaril@0: connect( actionFormatLinkColor, SIGNAL( activated() ), this, SLOT( formatSelectLinkColor() ) ); insilmaril@0: actionFormatLinkColor->addTo( menu ); insilmaril@151: actionFormatBackColor= new QAction( tr( "Set Background Color" ), pix, tr( "Set &Background Color" )+QString("..."), 0, this, "formatBackColor" ); insilmaril@0: connect( actionFormatBackColor, SIGNAL( activated() ), this, SLOT( formatSelectBackColor() ) ); insilmaril@0: actionFormatBackColor->addTo( menu ); insilmaril@0: } insilmaril@0: insilmaril@0: // View Actions insilmaril@0: void Main::setupViewActions() insilmaril@0: { insilmaril@0: QToolBar *tb = new QToolBar( this ); insilmaril@0: tb->setLabel( "View Actions" ); insilmaril@0: QPopupMenu *menu = new QPopupMenu( this ); insilmaril@0: menuBar()->insertItem( tr( "&View" ), menu ); insilmaril@0: insilmaril@0: QAction *a; insilmaril@269: a = new QAction( tr( "Zoom reset" ), QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom" ), CTRL + Key_0, this, "zoomReset" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT(viewZoomReset() ) ); insilmaril@0: a->addTo( tb ); insilmaril@0: a->addTo( menu ); insilmaril@269: a = new QAction( tr( "Zoom in" ), QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in" ), CTRL + Key_Plus, this, "zoomIn" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT(viewZoomIn() ) ); insilmaril@0: a->addTo( tb ); insilmaril@0: a->addTo( menu ); insilmaril@269: a = new QAction( tr( "Zoom out" ), QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out" ), CTRL + Key_Minus, this, "zoomOut" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( viewZoomOut() ) ); insilmaril@0: a->addTo( tb ); insilmaril@0: a->addTo( menu ); insilmaril@294: insilmaril@294: insilmaril@314: a = new QAction( tr( "Show Note Editor" ), QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor" ), CTRL + Key_E , this, "noteEditor" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT(windowToggleNoteEditor() ) ); insilmaril@0: a->setToggleAction(true); insilmaril@0: if (textEditor->showWithMain()) insilmaril@0: a->setOn(true); insilmaril@0: else insilmaril@0: a->setOn(false); insilmaril@0: a->addTo( tb ); insilmaril@0: a->addTo( menu ); insilmaril@0: actionViewToggleNoteEditor=a; insilmaril@294: insilmaril@314: a = new QAction( tr( "Show history window" ), QPixmap(), tr( "Show history window" ), CTRL + Key_H , this, "historyWindow" ); insilmaril@294: connect( a, SIGNAL( activated() ), this, SLOT(windowToggleHistory() ) ); insilmaril@294: a->setToggleAction(false); insilmaril@294: a->addTo( menu ); insilmaril@294: actionViewToggleHistoryWindow=a; insilmaril@294: insilmaril@0: a = new QAction( tr( "&Next Window" ), QPixmap(), tr( "Next Window" ), ALT + Key_N , this, "nextWindow" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT(windowNextEditor() ) ); insilmaril@0: a->addTo( menu ); insilmaril@0: a = new QAction( tr( "&Previous Window" ), QPixmap(), tr( "Previous Window" ), ALT + Key_P , this, "previousWindow" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT(windowPreviousEditor() ) ); insilmaril@0: a->addTo( menu ); insilmaril@0: } insilmaril@0: insilmaril@89: // Mode Actions insilmaril@89: void Main::setupModeActions() insilmaril@89: { insilmaril@89: //QPopupMenu *menu = new QPopupMenu( this ); insilmaril@89: //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu ); insilmaril@89: insilmaril@89: QToolBar *tb = new QToolBar( this ); insilmaril@91: tb->setLabel( tr ("Modes when using modifiers") ); insilmaril@89: QAction *a; insilmaril@89: actionGroupModModes=new QActionGroup ( this, "formatLinkStyles"); insilmaril@89: actionGroupModModes->setExclusive (true); insilmaril@269: a= new QAction( tr( "Use modifier to color branches" ), QPixmap(iconPath+"modecolor.png"), 0, Key_J, actionGroupModModes, "modModeColor" ); insilmaril@89: a->setToggleAction(true); insilmaril@89: a->addTo (tb); insilmaril@89: a->setOn(true); insilmaril@89: actionModModeColor=a; insilmaril@104: insilmaril@269: a= new QAction( tr( "Use modifier to copy" ), QPixmap(iconPath+"modecopy.png"), 0, Key_K, actionGroupModModes, "modModeCopy" ); insilmaril@104: a->setToggleAction(true); insilmaril@104: a->addTo (tb); insilmaril@104: actionModModeCopy=a; insilmaril@104: insilmaril@269: a= new QAction( tr( "Use modifier to draw xLinks" ), QPixmap(iconPath+"modelink.png"), 0, Key_L, actionGroupModModes, "modModeLink" ); insilmaril@89: a->setToggleAction(true); insilmaril@89: a->addTo (tb); insilmaril@89: actionModModeLink=a; insilmaril@89: } insilmaril@89: insilmaril@0: // Flag Actions insilmaril@0: void Main::setupFlagActions() insilmaril@0: { insilmaril@166: // Create System Flags insilmaril@166: systemFlagsDefault = new FlagRowObj (); insilmaril@166: systemFlagsDefault->setVisibility (false); insilmaril@166: systemFlagsDefault->setName ("systemFlagsDef"); insilmaril@166: insilmaril@166: FlagObj *fo = new FlagObj (); insilmaril@269: fo->load(QPixmap(flagsPath+"flag-note.png")); insilmaril@166: fo->setName("note"); insilmaril@166: fo->setToolTip(tr("Note","Systemflag")); insilmaril@166: systemFlagsDefault->addFlag (fo); // makes deep copy insilmaril@166: insilmaril@269: fo->load(QPixmap(flagsPath+"flag-url.png")); insilmaril@166: fo->setName("url"); insilmaril@166: fo->setToolTip(tr("WWW Document (external)","Systemflag")); insilmaril@166: systemFlagsDefault->addFlag (fo); insilmaril@166: insilmaril@269: fo->load(QPixmap(flagsPath+"flag-vymlink.png")); insilmaril@166: fo->setName("vymLink"); insilmaril@166: fo->setToolTip(tr("Link to another vym map","Systemflag")); insilmaril@166: systemFlagsDefault->addFlag (fo); insilmaril@166: insilmaril@269: fo->load(QPixmap(flagsPath+"flag-scrolled-right.png")); insilmaril@166: fo->setName("scrolledright"); insilmaril@166: fo->setToolTip(tr("subtree is scrolled","Systemflag")); insilmaril@166: systemFlagsDefault->addFlag (fo); insilmaril@166: insilmaril@269: fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png")); insilmaril@166: fo->setName("tmpUnscrolledright"); insilmaril@166: fo->setToolTip(tr("subtree is temporary scrolled","Systemflag")); insilmaril@166: systemFlagsDefault->addFlag (fo); insilmaril@166: insilmaril@269: fo->load(QPixmap(flagsPath+"flag-hideexport.png")); insilmaril@243: fo->setName("hideInExport"); insilmaril@243: fo->setToolTip(tr("Hide object in exported maps","Systemflag")); insilmaril@243: systemFlagsDefault->addFlag (fo); insilmaril@243: insilmaril@166: // Create Standard Flags insilmaril@166: standardFlagsDefault = new FlagRowObj (); insilmaril@166: standardFlagsDefault->setVisibility (false); insilmaril@166: standardFlagsDefault->setName ("standardFlagsDef"); insilmaril@166: insilmaril@269: fo->load(QPixmap(flagsPath+"flag-exclamationmark.png")); insilmaril@166: fo->setName ("exclamationmark"); insilmaril@166: fo->setGroup("standard-mark"); insilmaril@166: fo->setToolTip(tr("Take care!","Standardflag")); insilmaril@166: standardFlagsDefault->addFlag (fo); // makes deep copy insilmaril@166: insilmaril@269: fo->load(QPixmap(flagsPath+"flag-questionmark.png")); insilmaril@166: fo->setName("questionmark"); insilmaril@166: fo->setGroup("standard-mark"); insilmaril@166: fo->setToolTip(tr("Really?","Standardflag")); insilmaril@166: standardFlagsDefault->addFlag (fo); insilmaril@166: insilmaril@269: fo->load(QPixmap(flagsPath+"flag-hook-green.png")); insilmaril@166: fo->setName("hook-green"); insilmaril@166: fo->setGroup("standard-hook"); insilmaril@166: fo->setToolTip(tr("ok!","Standardflag")); insilmaril@166: standardFlagsDefault->addFlag (fo); insilmaril@166: insilmaril@269: fo->load(QPixmap(flagsPath+"flag-cross-red.png")); insilmaril@166: fo->setName("cross-red"); insilmaril@166: fo->setGroup("standard-hook"); insilmaril@166: fo->setToolTip(tr("Not ok!","Standardflag")); insilmaril@166: standardFlagsDefault->addFlag (fo); insilmaril@166: insilmaril@269: fo->load(QPixmap(flagsPath+"flag-stopsign.png")); insilmaril@166: fo->setName("stopsign"); insilmaril@166: fo->setToolTip(tr("This won't work!","Standardflag")); insilmaril@166: standardFlagsDefault->addFlag (fo); insilmaril@166: insilmaril@269: fo->load(QPixmap(flagsPath+"flag-smiley-good.png")); insilmaril@166: fo->setName("smiley-good"); insilmaril@166: fo->setGroup("standard-smiley"); insilmaril@166: fo->setToolTip(tr("Good","Standardflag")); insilmaril@166: standardFlagsDefault->addFlag (fo); insilmaril@166: insilmaril@269: fo->load(QPixmap(flagsPath+"flag-smiley-sad.png")); insilmaril@166: fo->setName("smiley-sad"); insilmaril@166: fo->setGroup("standard-smiley"); insilmaril@166: fo->setToolTip(tr("Bad","Standardflag")); insilmaril@166: standardFlagsDefault->addFlag (fo); insilmaril@166: insilmaril@269: fo->load(QPixmap(flagsPath+"flag-smiley-omg.png")); insilmaril@269: // Original omg.png (in KDE emoticons) insilmaril@269: fo->setName("smiley-omg"); insilmaril@269: fo->setGroup("standard-smiley"); insilmaril@269: fo->setToolTip(tr("Oh no!","Standardflag")); insilmaril@269: standardFlagsDefault->addFlag (fo); insilmaril@269: insilmaril@269: fo->load(QPixmap(flagsPath+"flag-kalarm.png")); insilmaril@166: fo->setName("clock"); insilmaril@166: fo->setToolTip(tr("Time critical","Standardflag")); insilmaril@166: standardFlagsDefault->addFlag (fo); insilmaril@166: insilmaril@269: fo->load(QPixmap(flagsPath+"flag-phone.png")); insilmaril@269: fo->setName("phone"); insilmaril@269: fo->setToolTip(tr("Call...","Standardflag")); insilmaril@269: standardFlagsDefault->addFlag (fo); insilmaril@269: insilmaril@269: fo->load(QPixmap(flagsPath+"flag-lamp.png")); insilmaril@166: fo->setName("lamp"); insilmaril@166: fo->setToolTip(tr("Idea!","Standardflag")); insilmaril@166: standardFlagsDefault->addFlag (fo); insilmaril@166: insilmaril@269: fo->load(QPixmap(flagsPath+"flag-arrow-up.png")); insilmaril@166: fo->setName("arrow-up"); insilmaril@166: fo->setGroup("standard-arrow"); insilmaril@166: fo->setToolTip(tr("Important","Standardflag")); insilmaril@166: standardFlagsDefault->addFlag (fo); insilmaril@166: insilmaril@269: fo->load(QPixmap(flagsPath+"flag-arrow-down.png")); insilmaril@166: fo->setName("arrow-down"); insilmaril@166: fo->setGroup("standard-arrow"); insilmaril@166: fo->setToolTip(tr("Unimportant","Standardflag")); insilmaril@166: standardFlagsDefault->addFlag (fo); insilmaril@166: insilmaril@269: fo->load(QPixmap(flagsPath+"flag-arrow-2up.png")); insilmaril@269: fo->setName("2arrow-up"); insilmaril@269: fo->setGroup("standard-arrow"); insilmaril@269: fo->setToolTip(tr("Very important!","Standardflag")); insilmaril@269: standardFlagsDefault->addFlag (fo); insilmaril@269: insilmaril@269: fo->load(QPixmap(flagsPath+"flag-arrow-2down.png")); insilmaril@269: fo->setName("2arrow-down"); insilmaril@269: fo->setGroup("standard-arrow"); insilmaril@269: fo->setToolTip(tr("Very unimportant!","Standardflag")); insilmaril@269: standardFlagsDefault->addFlag (fo); insilmaril@269: insilmaril@269: fo->load(QPixmap(flagsPath+"flag-thumb-up.png")); insilmaril@166: fo->setName("thumb-up"); insilmaril@166: fo->setGroup("standard-thumb"); insilmaril@166: fo->setToolTip(tr("I like this","Standardflag")); insilmaril@166: standardFlagsDefault->addFlag (fo); insilmaril@166: insilmaril@269: fo->load(QPixmap(flagsPath+"flag-thumb-down.png")); insilmaril@166: fo->setName("thumb-down"); insilmaril@166: fo->setGroup("standard-thumb"); insilmaril@166: fo->setToolTip(tr("I like this","Standardflag")); insilmaril@166: fo->setToolTip(tr("I do not like this","Standardflag")); insilmaril@166: standardFlagsDefault->addFlag (fo); insilmaril@166: insilmaril@269: fo->load(QPixmap(flagsPath+"flag-rose.png")); insilmaril@269: fo->setName("rose"); insilmaril@269: fo->setToolTip(tr("Rose","Standardflag")); insilmaril@269: standardFlagsDefault->addFlag (fo); insilmaril@269: insilmaril@269: fo->load(QPixmap(flagsPath+"flag-heart.png")); insilmaril@166: fo->setName("heart"); insilmaril@166: fo->setToolTip(tr("I just love... ","Standardflag")); insilmaril@166: standardFlagsDefault->addFlag (fo); insilmaril@166: insilmaril@269: fo->load(QPixmap(flagsPath+"flag-present.png")); insilmaril@269: fo->setName("present"); insilmaril@269: fo->setToolTip(tr("Surprise!","Standardflag")); insilmaril@269: standardFlagsDefault->addFlag (fo); insilmaril@269: insilmaril@269: fo->load(QPixmap(flagsPath+"flag-flash.png")); insilmaril@166: fo->setName("flash"); insilmaril@166: fo->setToolTip(tr("Dangerous","Standardflag")); insilmaril@166: standardFlagsDefault->addFlag (fo); insilmaril@166: insilmaril@269: fo->load(QPixmap(flagsPath+"flag-info.png")); insilmaril@269: // Original: xsldbg_output.png insilmaril@269: fo->setName("info"); insilmaril@269: fo->setToolTip(tr("Info","Standardflag")); insilmaril@269: standardFlagsDefault->addFlag (fo); insilmaril@269: insilmaril@269: fo->load(QPixmap(flagsPath+"flag-lifebelt.png")); insilmaril@269: // Original khelpcenter.png insilmaril@166: fo->setName("lifebelt"); insilmaril@166: fo->setToolTip(tr("This will help","Standardflag")); insilmaril@166: standardFlagsDefault->addFlag (fo); insilmaril@243: insilmaril@166: delete (fo); insilmaril@166: insilmaril@0: standardFlagsDefault->makeToolbar(this, "Standard Flags"); insilmaril@0: } insilmaril@0: insilmaril@0: // Settings Actions insilmaril@0: void Main::setupSettingsActions() insilmaril@0: { insilmaril@0: QPopupMenu *menu = new QPopupMenu( this ); insilmaril@0: menuBar()->insertItem( tr( "&Settings" ), menu ); insilmaril@0: insilmaril@0: QAction *a; insilmaril@0: insilmaril@0: insilmaril@159: a = new QAction( tr( "Set application to open pdf files"), QPixmap(), tr( "Set application to open pdf files ...") , 0, this, "setPDF" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( settingsPDF() ) ); insilmaril@0: a->addTo( menu ); insilmaril@0: insilmaril@159: a = new QAction( tr( "Set application to open external links"), QPixmap(), tr( "Set application to open external links..."), 0, this, "setURL" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( settingsURL() ) ); insilmaril@0: a->addTo( menu ); insilmaril@0: insilmaril@0: menu->insertSeparator(); insilmaril@0: a = new QAction( tr( "Edit branch after adding it" ), QPixmap(), tr( "Edit branch after adding it" ), 0, this, "autoedit" ); insilmaril@0: a->setToggleAction(true); insilmaril@0: a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoedit",true) ); insilmaril@0: a->addTo( menu ); insilmaril@0: actionSettingsAutoedit=a; insilmaril@0: insilmaril@0: a= new QAction( tr( "Select branch after adding it" ), QPixmap(), tr( "Select branch after adding it" ), 0, this, "autoselectheading" ); insilmaril@0: a->setToggleAction(true); insilmaril@0: a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselect",false) ); insilmaril@0: a->addTo( menu ); insilmaril@0: actionSettingsAutoselectHeading=a; insilmaril@0: insilmaril@0: a= new QAction( tr( "Select heading before editing" ), QPixmap(), tr( "Select existing heading" ), 0, this, "autoselectexistingtext" ); insilmaril@0: a->setToggleAction(true); insilmaril@0: a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselectexistingtext",true) ); insilmaril@0: a->addTo( menu ); insilmaril@0: actionSettingsAutoselectText=a; insilmaril@0: insilmaril@151: a= new QAction( tr( "Pasting into new branch" ), QPixmap(), tr( "pasting into new branch" ), 0, this, "pastenewheading" ); insilmaril@0: a->setToggleAction(true); insilmaril@0: a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/newheadingisempty",true) ); insilmaril@0: a->addTo( menu ); insilmaril@0: actionSettingsPasteNewHeading=a; insilmaril@0: insilmaril@151: a= new QAction( tr( "Delete key for deleting branches" ), QPixmap(), tr( "Delete key" ), 0, this, "delkey" ); insilmaril@0: a->setToggleAction(true); insilmaril@0: a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useDelKey",false) ); insilmaril@0: a->addTo( menu ); insilmaril@0: actionSettingsUseDelKey=a; insilmaril@103: insilmaril@151: a= new QAction( tr( "Use exclusive flags in flag toolbars" ), QPixmap(), tr( "Exclusive flags" ), 0, this, "flaggroups" ); insilmaril@103: a->setToggleAction(true); insilmaril@103: a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useFlagGroups",true) ); insilmaril@103: a->addTo( menu ); insilmaril@103: actionSettingsUseFlagGroups=a; insilmaril@260: insilmaril@260: a= new QAction( tr( "Use hide flag during exports " ), QPixmap(), tr( "Use hide flags" ), 0, this, "hideexport" ); insilmaril@260: a->setToggleAction(true); insilmaril@260: a->setOn ( settings.readBoolEntry ("/vym/export/useHideExport",true) ); insilmaril@260: a->addTo( menu ); insilmaril@260: actionSettingsUseHideExport=a; insilmaril@0: } insilmaril@0: insilmaril@0: // Test Actions insilmaril@0: void Main::setupTestActions() insilmaril@0: { insilmaril@0: QPopupMenu *menu = new QPopupMenu( this ); insilmaril@0: menuBar()->insertItem( tr( "&Test" ), menu ); insilmaril@0: insilmaril@0: QAction *a; insilmaril@175: a = new QAction( tr( "Call test function" ), QPixmap(), tr( "test flag" ), 0, this, "flag" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( testFunction() ) ); insilmaril@0: a->addTo( menu ); insilmaril@0: } insilmaril@0: insilmaril@0: // Help Actions insilmaril@0: void Main::setupHelpActions() insilmaril@0: { insilmaril@0: QPopupMenu *menu = new QPopupMenu( this ); insilmaril@0: menuBar()->insertItem( tr( "&Help" ), menu ); insilmaril@0: insilmaril@0: QAction *a; insilmaril@0: a = new QAction( tr( "Open VYM Documentation (pdf)" ), QPixmap(), tr( "Open VYM Documentation (pdf) " ), 0, this, "about" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( helpDoc() ) ); insilmaril@0: a->addTo( menu ); insilmaril@0: insilmaril@205: a = new QAction( tr( "About VYM")+" "__VYM, QPixmap(), tr( "About VYM" ), 0, this, "about" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( helpAbout() ) ); insilmaril@0: a->addTo( menu ); insilmaril@0: insilmaril@0: a = new QAction( tr( "Information about QT toolkit" ), QPixmap(), tr( "About QT" ), 0, this, "about" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( helpAboutQT() ) ); insilmaril@0: a->addTo( menu ); insilmaril@0: } insilmaril@0: insilmaril@0: // Context Menus insilmaril@0: void Main::setupContextMenus() insilmaril@0: { insilmaril@0: QAction*a; insilmaril@0: insilmaril@0: // Context Menu for branch or mapcenter insilmaril@0: branchContextMenu =new QPopupMenu (this); insilmaril@98: insilmaril@98: // Submenu "Add" insilmaril@98: branchAddContextMenu =new QPopupMenu (this); insilmaril@98: actionEditPaste->addTo ( branchAddContextMenu ); insilmaril@98: actionEditAddBranch->addTo ( branchAddContextMenu ); insilmaril@98: actionEditAddBranchHere->addTo ( branchAddContextMenu ); insilmaril@98: actionEditAddBranchAbove->addTo ( branchAddContextMenu ); insilmaril@98: actionEditAddBranchBelow->addTo ( branchAddContextMenu ); insilmaril@98: branchAddContextMenu->insertSeparator(); insilmaril@98: actionEditLoadImage->addTo( branchAddContextMenu ); insilmaril@98: branchAddContextMenu->insertSeparator(); insilmaril@98: actionEditImportAdd->addTo ( branchAddContextMenu ); insilmaril@98: actionEditImportReplace->addTo ( branchAddContextMenu ); insilmaril@98: insilmaril@98: // Submenu "Remove" insilmaril@98: branchRemoveContextMenu =new QPopupMenu (this); insilmaril@98: actionEditCut->addTo ( branchRemoveContextMenu ); insilmaril@98: actionEditDelete->addTo ( branchRemoveContextMenu ); insilmaril@294: actionEditRemoveBranchKeepChilds->addTo( branchRemoveContextMenu ); insilmaril@98: actionEditRemoveChilds->addTo( branchRemoveContextMenu ); insilmaril@98: insilmaril@98: branchContextMenu->insertItem (tr("Add"),branchAddContextMenu); insilmaril@98: branchContextMenu->insertItem (tr("Remove"),branchRemoveContextMenu); insilmaril@98: insilmaril@0: actionEditSaveBranch->addTo( branchContextMenu ); insilmaril@98: insilmaril@0: branchContextMenu->insertSeparator(); insilmaril@0: actionEditOpenURL->addTo ( branchContextMenu ); insilmaril@266: actionEditOpenURLTab->addTo ( branchContextMenu ); insilmaril@0: actionEditURL->addTo ( branchContextMenu ); insilmaril@0: actionEditHeading2URL->addTo ( branchContextMenu ); insilmaril@0: if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) insilmaril@175: { insilmaril@0: actionEditBugzilla2URL->addTo( branchContextMenu ); insilmaril@175: actionEditFATE2URL->addTo( branchContextMenu ); insilmaril@175: } insilmaril@0: branchContextMenu->insertSeparator(); insilmaril@0: actionEditOpenVymLink->addTo ( branchContextMenu ); insilmaril@0: actionEditVymLink->addTo ( branchContextMenu ); insilmaril@0: actionEditDeleteVymLink->addTo ( branchContextMenu ); insilmaril@98: insilmaril@0: branchContextMenu->insertSeparator(); insilmaril@0: actionGroupFormatFrameTypes->addTo( branchContextMenu ); insilmaril@0: insilmaril@160: branchContextMenu->insertSeparator(); insilmaril@175: actionFormatIncludeImagesVer->addTo( branchContextMenu ); insilmaril@227: actionFormatIncludeImagesHor->addTo( branchContextMenu ); insilmaril@160: actionFormatHideLinkUnselected->addTo( branchContextMenu ); insilmaril@160: insilmaril@89: // Context Menu for links in a branch menu insilmaril@89: // This will be populated "on demand" in MapEditor::updateActions insilmaril@89: branchContextMenu->insertSeparator(); insilmaril@89: branchLinksContextMenu =new QPopupMenu (this); insilmaril@94: branchLinksContextMenuDup =new QPopupMenu (this); insilmaril@95: branchContextMenu->insertItem (tr("Edit XLink"),branchLinksContextMenuDup); insilmaril@95: connect( branchLinksContextMenuDup, SIGNAL( activated(int) ), this, SLOT( editEditXLink(int ) ) ); insilmaril@89: insilmaril@105: branchContextMenu->insertItem (tr("Goto XLink"),branchLinksContextMenu); insilmaril@105: connect( branchLinksContextMenu, SIGNAL( activated(int) ), this, SLOT( editFollowXLink(int ) ) ); insilmaril@105: insilmaril@0: // Context menu for floatimage insilmaril@0: floatimageContextMenu =new QPopupMenu (this); insilmaril@0: saveImageFormatMenu=new QPopupMenu (this); insilmaril@0: exportImageFormatMenu=new QPopupMenu (this); insilmaril@0: insilmaril@0: QStrList fmt = QImage::outputFormats(); insilmaril@0: for (const char* f = fmt.first(); f; f = fmt.next()) insilmaril@0: { insilmaril@0: saveImageFormatMenu->insertItem( f ); insilmaril@0: exportImageFormatMenu->insertItem( f ); insilmaril@0: } insilmaril@0: connect( saveImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( editSaveImage(int ) ) ); insilmaril@0: connect( exportImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( fileExportImage(int ) ) ); insilmaril@0: floatimageContextMenu->insertItem( tr("Save image"),saveImageFormatMenu ); insilmaril@0: insilmaril@0: floatimageContextMenu->insertSeparator(); insilmaril@0: actionEditCopy->addTo( floatimageContextMenu ); insilmaril@0: actionEditCut->addTo( floatimageContextMenu ); insilmaril@0: insilmaril@250: /* FIXME not needed any longer insilmaril@0: floatimageContextMenu->insertSeparator(); insilmaril@0: a = new QAction( tr( "Use for Export" ), QPixmap(), tr( "Use for Export"), 0, this, "useForExport" ); insilmaril@0: a->setToggleAction(true); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( editToggleFloatExport() ) ); insilmaril@0: a->addTo( floatimageContextMenu); insilmaril@0: actionEditToggleFloatExport=a; insilmaril@250: */ insilmaril@0: insilmaril@160: floatimageContextMenu->insertSeparator(); insilmaril@160: actionFormatHideLinkUnselected->addTo( floatimageContextMenu ); insilmaril@0: insilmaril@243: exportMenu->insertItem ( tr("Export as")+" Image",exportImageFormatMenu); insilmaril@228: insilmaril@205: a = new QAction( tr( "Export in Open Document Format used e.g. in Open Office " ), QPixmap(), "Open Office"+QString("..."), 0, this, "exportOOPresentation" ); insilmaril@185: connect( a, SIGNAL( activated() ), this, SLOT( fileExportOOPresentation() ) ); insilmaril@185: a->addTo (exportMenu); insilmaril@0: insilmaril@243: a = new QAction( tr( "Export as")+" webpage (XHTML)" , QPixmap(), "Webpage (XHTML)...", ALT + Key_X, this, "exportXHTML" ); insilmaril@228: connect( a, SIGNAL( activated() ), this, SLOT( fileExportXHTML() ) ); insilmaril@228: a->addTo( exportMenu ); insilmaril@185: insilmaril@243: a = new QAction( tr( "Export as")+" ASCII"+" "+tr("(still experimental)" ), QPixmap(), "Text (ASCII)...", 0, this, "exportASCII" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( fileExportASCII() ) ); insilmaril@143: a->addTo( exportMenu ); insilmaril@0: insilmaril@243: a = new QAction( tr( "Export as")+" "+tr("KDE Bookmarks" ), QPixmap(), tr("KDE Bookmarks"), 0, this, "importKDEBookmarks" ); insilmaril@243: connect( a, SIGNAL( activated() ), this, SLOT( fileExportKDEBookmarks() ) ); insilmaril@314: a->addTo (exportMenu); insilmaril@243: insilmaril@243: a = new QAction( tr( "Export as")+" Taskjuggler"+" "+tr("(still experimental)" ), QPixmap(), "Taskjuggler...", 0, this, "exportTJ" ); insilmaril@228: connect( a, SIGNAL( activated() ), this, SLOT( fileExportTaskjuggler() ) ); insilmaril@228: a->addTo( exportMenu ); insilmaril@228: insilmaril@243: a = new QAction( tr( "Export as")+" LaTeX"+" "+tr("(still experimental)" ), QPixmap(), "LaTeX...", 0, this, "exportLaTeX" ); insilmaril@163: connect( a, SIGNAL( activated() ), this, SLOT( fileExportLaTeX() ) ); insilmaril@163: a->addTo( exportMenu ); insilmaril@163: insilmaril@243: a = new QAction( tr( "Export as")+" XML" , QPixmap(), "XML...", 0, this, "exportXML" ); insilmaril@0: connect( a, SIGNAL( activated() ), this, SLOT( fileExportXML() ) ); insilmaril@0: a->addTo( exportMenu ); insilmaril@0: insilmaril@0: // Context menu for canvas insilmaril@0: canvasContextMenu =new QPopupMenu (this); insilmaril@0: actionEditMapInfo->addTo( canvasContextMenu ); insilmaril@0: canvasContextMenu->insertSeparator(); insilmaril@0: actionGroupFormatLinkStyles->addTo( canvasContextMenu ); insilmaril@0: canvasContextMenu->insertSeparator(); insilmaril@0: actionFormatLinkColorHint->addTo( canvasContextMenu ); insilmaril@0: actionFormatLinkColor->addTo( canvasContextMenu ); insilmaril@0: actionFormatBackColor->addTo( canvasContextMenu ); insilmaril@0: insilmaril@0: // Menu for last opened files insilmaril@0: // Read settings initially insilmaril@0: QString s; insilmaril@0: int j=settings.readNumEntry( "/vym/lastMaps/number",0); insilmaril@0: for (int i=1;i<=j;i++) insilmaril@0: { insilmaril@0: s=settings.readEntry(QString("/vym/lastMaps/map-%1").arg(i),""); insilmaril@0: if (!s.isEmpty() && j<=maxLastMaps) insilmaril@0: lastMaps.append(s); insilmaril@0: } insilmaril@0: setupLastMapsMenu(); insilmaril@0: connect( lastMapsMenu, SIGNAL( activated(int) ), this, SLOT( fileLoadLast(int ) ) ); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::setupLastMapsMenu() insilmaril@0: { insilmaril@0: // Remove double entries insilmaril@0: QStringList::Iterator it=lastMaps.begin(); insilmaril@0: QStringList::Iterator jt; insilmaril@0: while (it!=lastMaps.end() ) insilmaril@0: { insilmaril@0: jt=it; insilmaril@0: ++jt; insilmaril@0: while (jt!=lastMaps.end() ) insilmaril@0: { insilmaril@0: if (*it == *jt) insilmaril@0: jt=lastMaps.remove(jt); insilmaril@0: else insilmaril@0: jt++; insilmaril@0: } insilmaril@0: it++; insilmaril@0: } insilmaril@0: insilmaril@0: // Limit length of list to maxLastMaps insilmaril@0: while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back(); insilmaril@0: insilmaril@0: // build Menu from lastMaps string list insilmaril@0: lastMapsMenu->clear(); insilmaril@0: for (it = lastMaps.begin(); it != lastMaps.end(); ++it ) insilmaril@0: lastMapsMenu->insertItem (*it ); insilmaril@0: insilmaril@0: } insilmaril@0: insilmaril@0: void Main::hideEvent (QHideEvent * ) insilmaril@0: { insilmaril@0: if (!textEditor->isMinimized() ) textEditor->hide(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::showEvent (QShowEvent * ) insilmaril@0: { insilmaril@117: if (textEditor->showWithMain()) textEditor->showNormal(); insilmaril@0: } insilmaril@0: insilmaril@0: bool Main::reallyWriteDirectory(const QString &dir) insilmaril@0: { insilmaril@0: QStringList eList = QDir(dir).entryList(); insilmaril@0: if (eList.first() ==".") eList.pop_front(); // remove "." insilmaril@0: if (eList.first() =="..") eList.pop_front(); // remove "." insilmaril@0: if (!eList.isEmpty()) insilmaril@0: { insilmaril@185: QMessageBox mb( __VYM, insilmaril@159: tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?").arg(dir), insilmaril@0: QMessageBox::Warning, insilmaril@0: QMessageBox::Yes , insilmaril@0: QMessageBox::Cancel | QMessageBox::Default, insilmaril@0: QMessageBox::QMessageBox::NoButton ); insilmaril@0: insilmaril@0: mb.setButtonText( QMessageBox::Yes, tr("Overwrite") ); insilmaril@0: mb.setButtonText( QMessageBox::No, tr("Cancel")); insilmaril@0: switch( mb.exec() ) insilmaril@0: { insilmaril@0: case QMessageBox::Yes: insilmaril@0: // save insilmaril@0: return true; insilmaril@0: case QMessageBox::Cancel: insilmaril@0: // do nothing insilmaril@0: return false; insilmaril@0: } insilmaril@0: } insilmaril@0: return true; insilmaril@0: } insilmaril@0: insilmaril@0: QString Main::browseDirectory (const QString &caption) insilmaril@0: { insilmaril@0: QFileDialog fd(this,caption); insilmaril@0: fd.setMode (QFileDialog::DirectoryOnly); insilmaril@185: fd.setCaption(__VYM " - "+caption); insilmaril@0: fd.show(); insilmaril@0: insilmaril@0: if ( fd.exec() == QDialog::Accepted ) insilmaril@0: return fd.selectedFile(); insilmaril@0: else insilmaril@0: return ""; insilmaril@0: } insilmaril@0: insilmaril@0: MapEditor* Main::currentMapEditor() const insilmaril@0: { insilmaril@0: if ( tabWidget->currentPage() && insilmaril@0: tabWidget->currentPage()->inherits( "MapEditor" ) ) insilmaril@0: return (MapEditor*)tabWidget->currentPage(); insilmaril@0: return NULL; insilmaril@0: } insilmaril@0: insilmaril@0: //TODO not used now, maybe use this for overview window later insilmaril@0: void Main::newView() insilmaril@0: { insilmaril@0: // Open a new view... have it delete when closed. insilmaril@0: Main *m = new Main(0, 0, WDestructiveClose); insilmaril@0: qApp->setMainWidget(m); insilmaril@0: m->show(); insilmaril@0: qApp->setMainWidget(0); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editorChanged(QWidget *) insilmaril@0: { insilmaril@0: // Unselect all possibly selected objects insilmaril@0: // (Important to update note editor) insilmaril@0: int i; insilmaril@0: MapEditor *me; insilmaril@0: for (i=0;i<=tabWidget->count() -1;i++) insilmaril@0: { insilmaril@0: insilmaril@0: me=(MapEditor*)tabWidget->page(i); insilmaril@0: me->unselect(); insilmaril@0: } insilmaril@0: currentMapEditor()->reselect(); insilmaril@0: insilmaril@0: // Update actions to in menus and toolbars according to editor insilmaril@0: currentMapEditor()->updateActions(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::fileNew() insilmaril@0: { insilmaril@0: QString fn="unnamed"; insilmaril@0: MapEditor* medit = new MapEditor (tabWidget, true); insilmaril@0: tabWidget->addTab (medit,fn); insilmaril@0: tabWidget->showPage(medit); insilmaril@0: medit->viewport()->setFocus(); insilmaril@166: // For the very first map we do not have flagrows yet... insilmaril@166: medit->select("mc:"); insilmaril@0: } insilmaril@0: insilmaril@205: ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode) insilmaril@0: { insilmaril@205: ErrorCode err=success; insilmaril@0: insilmaril@0: // fn is usually the archive, mapfile the file after uncompressing insilmaril@0: QString mapfile; insilmaril@0: insilmaril@0: // Make fn absolute (needed for unzip) insilmaril@0: fn=QDir (fn).absPath(); insilmaril@0: insilmaril@0: MapEditor *me; insilmaril@0: insilmaril@0: if (lmode==NewMap) insilmaril@0: { insilmaril@0: // Check, if map is already loaded insilmaril@0: int i=0; insilmaril@0: while (i<=tabWidget->count() -1) insilmaril@0: { insilmaril@0: me=(MapEditor*)tabWidget->page(i); insilmaril@0: if (me->getFilePath() == fn) insilmaril@0: { insilmaril@0: // Already there, ask for confirmation insilmaril@185: QMessageBox mb( __VYM, insilmaril@159: tr("The map %1\nis already opened." insilmaril@0: "Opening the same map in multiple editors may lead \n" insilmaril@0: "to confusion when finishing working with vym." insilmaril@159: "Do you want to").arg(fn), insilmaril@0: QMessageBox::Warning, insilmaril@0: QMessageBox::Yes | QMessageBox::Default, insilmaril@0: QMessageBox::Cancel | QMessageBox::Escape, insilmaril@0: QMessageBox::QMessageBox::NoButton); insilmaril@0: mb.setButtonText( QMessageBox::Yes, tr("Open anyway") ); insilmaril@0: mb.setButtonText( QMessageBox::Cancel, tr("Cancel")); insilmaril@0: switch( mb.exec() ) insilmaril@0: { insilmaril@0: case QMessageBox::Yes: insilmaril@0: // load anyway insilmaril@0: i=tabWidget->count(); insilmaril@0: break; insilmaril@0: case QMessageBox::Cancel: insilmaril@0: // do nothing insilmaril@205: return aborted; insilmaril@0: break; insilmaril@0: } insilmaril@0: } insilmaril@0: i++; insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@0: insilmaril@0: // Try to load map insilmaril@0: if ( !fn.isEmpty() ) insilmaril@0: { insilmaril@0: me = currentMapEditor(); insilmaril@0: int tabIndex=tabWidget->currentPageIndex(); insilmaril@0: // Check first, if mapeditor exists insilmaril@0: // If it is not default AND we want a new map, insilmaril@0: // create a new mapeditor in a new tab insilmaril@0: if ( lmode==NewMap && (!me || !me->isDefault() ) ) insilmaril@0: { insilmaril@0: me = new MapEditor (tabWidget,true); insilmaril@0: tabWidget->addTab (me,fn); insilmaril@0: tabIndex=tabWidget->indexOf (me); insilmaril@0: tabWidget->setCurrentPage (tabIndex); insilmaril@0: } insilmaril@0: insilmaril@0: // Check, if file exists (important for creating new files insilmaril@0: // from command line insilmaril@0: if (!QFile(fn).exists() ) insilmaril@0: { insilmaril@185: QMessageBox mb( __VYM, insilmaril@159: tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn), insilmaril@0: QMessageBox::Question, insilmaril@0: QMessageBox::Yes , insilmaril@0: QMessageBox::Cancel | QMessageBox::Default, insilmaril@0: QMessageBox::QMessageBox::NoButton ); insilmaril@0: insilmaril@0: mb.setButtonText( QMessageBox::Yes, tr("Create")); insilmaril@0: mb.setButtonText( QMessageBox::No, tr("Cancel")); insilmaril@0: switch( mb.exec() ) insilmaril@0: { insilmaril@0: case QMessageBox::Yes: insilmaril@0: // Create new map insilmaril@0: currentMapEditor()->setFilePath(fn); insilmaril@0: tabWidget->setTabLabel (currentMapEditor(), insilmaril@0: currentMapEditor()->getFileName() ); insilmaril@0: statusBar()->message( "Created " + fn , statusbarTime ); insilmaril@205: return success; insilmaril@0: insilmaril@0: case QMessageBox::Cancel: insilmaril@0: // don't create new map insilmaril@0: statusBar()->message( "Loading " + fn + " failed!", statusbarTime ); insilmaril@0: fileCloseMap(); insilmaril@205: return aborted; insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@0: insilmaril@0: //tabWidget->currentPage() won't be NULL here, because of above... insilmaril@0: tabWidget->showPage(me); insilmaril@0: me->viewport()->setFocus(); insilmaril@0: insilmaril@0: // Create temporary directory for packing insilmaril@0: char tmpdir1[]="/tmp/vym-XXXXXX"; insilmaril@0: QString tmpMapDir=mkdtemp(tmpdir1); insilmaril@0: insilmaril@0: // Try to unzip file insilmaril@185: err=unzipDir (tmpMapDir,fn); insilmaril@185: if (err==nozip) insilmaril@0: { insilmaril@185: mapfile=fn; insilmaril@185: me->setZipped(false); insilmaril@0: } else insilmaril@0: { insilmaril@185: me->setZipped(true); insilmaril@185: insilmaril@185: // Look for mapname.xml insilmaril@185: mapfile= fn.left(fn.findRev(".",-1,true)); insilmaril@185: mapfile=mapfile.section( '/', -1 ); insilmaril@185: QFile file( tmpMapDir + "/" + mapfile + ".xml"); insilmaril@185: if (!file.exists() ) insilmaril@0: { insilmaril@185: // mapname.xml does not exist, well, insilmaril@185: // maybe some renamed the mapname.vym file... insilmaril@185: // Try to find any .xml in the toplevel insilmaril@185: // directory of the .vym file insilmaril@185: QStringList flist=QDir (tmpMapDir).entryList("*.xml"); insilmaril@185: if (flist.count()==1) insilmaril@0: { insilmaril@185: // Only one entry, take this one insilmaril@185: mapfile=tmpMapDir + "/"+flist.first(); insilmaril@0: } else insilmaril@185: { insilmaril@185: for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it ) insilmaril@185: *it=tmpMapDir + "/" + *it; insilmaril@185: // TODO Multiple entries, load all (but only the first one into this ME) insilmaril@185: //mainWindow->fileLoadFromTmp (flist); insilmaril@185: //returnCode=1; // Silently forget this attempt to load insilmaril@185: qWarning ("MainWindow::load (fn) multimap found..."); insilmaril@185: } insilmaril@0: insilmaril@185: if (flist.isEmpty() ) insilmaril@185: { insilmaril@185: QMessageBox::critical( 0, tr( "Critical Load Error" ), insilmaril@185: tr("Couldn't find a map (*.xml) in .vym archive.\n")); insilmaril@185: err=aborted; insilmaril@185: } insilmaril@185: } //file doesn't exist insilmaril@185: else insilmaril@185: mapfile=file.name(); insilmaril@0: } insilmaril@0: insilmaril@185: if (err!=aborted) insilmaril@185: { insilmaril@185: // Save existing filename in case we import insilmaril@185: QString fn_org=me->getFilePath(); insilmaril@106: insilmaril@185: // Finally load map into mapEditor insilmaril@185: me->setFilePath (mapfile,fn); insilmaril@205: err=me->load(mapfile,lmode); insilmaril@106: insilmaril@185: // Restore old (maybe empty) filepath, if this is an import insilmaril@185: if (lmode!=NewMap) insilmaril@185: me->setFilePath (fn_org); insilmaril@185: } insilmaril@0: insilmaril@185: // Finally check for errors and go home insilmaril@185: if (err==aborted) insilmaril@185: { insilmaril@185: if (lmode==NewMap) fileCloseMap(); insilmaril@185: statusBar()->message( "Could not load " + fn, statusbarTime ); insilmaril@185: } else insilmaril@0: { insilmaril@0: if (lmode==NewMap) insilmaril@0: { insilmaril@0: me->setFilePath (fn); insilmaril@0: tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName()); insilmaril@205: if (fn.left(9)!="/tmp/vym-") insilmaril@205: { insilmaril@205: // Only append to lastMaps if not loaded from a tmpDir insilmaril@205: // e.g. imported bookmarks are in a tmpDir insilmaril@205: lastMaps.prepend(me->getFilePath() ); insilmaril@205: setupLastMapsMenu(); insilmaril@205: } insilmaril@0: actionFilePrint->setEnabled (true); insilmaril@0: } insilmaril@0: statusBar()->message( "Loaded " + fn, statusbarTime ); insilmaril@0: } insilmaril@0: insilmaril@185: // Delete tmpDir insilmaril@185: removeDir (QDir(tmpMapDir)); insilmaril@0: } insilmaril@205: return err; insilmaril@0: } insilmaril@0: insilmaril@0: insilmaril@0: void Main::fileLoad(const LoadMode &lmode) insilmaril@0: { insilmaril@0: QFileDialog *fd=new QFileDialog( this); insilmaril@0: if (!lastFileDir.isEmpty()) insilmaril@0: fd->setDir (lastFileDir); insilmaril@185: fd->setMode (QFileDialog::ExistingFiles); insilmaril@0: fd->addFilter ("XML (*.xml)"); insilmaril@0: fd->addFilter ("VYM map (*.vym *.vyp)"); insilmaril@0: switch (lmode) insilmaril@0: { insilmaril@0: case NewMap: insilmaril@0: fd->setCaption(tr("Load vym map")); insilmaril@0: break; insilmaril@0: case ImportAdd: insilmaril@0: fd->setCaption(tr("Import: Add vym map to selection")); insilmaril@0: break; insilmaril@0: case ImportReplace: insilmaril@0: fd->setCaption(tr("Import: Replace selection with vym map")); insilmaril@0: break; insilmaril@0: } insilmaril@0: fd->show(); insilmaril@0: insilmaril@0: QString fn; insilmaril@0: if ( fd->exec() == QDialog::Accepted ) insilmaril@0: { insilmaril@0: lastFileDir=fd->dirPath(); insilmaril@185: QStringList flist = fd->selectedFiles(); insilmaril@185: QStringList::Iterator it = flist.begin(); insilmaril@185: while( it != flist.end() ) insilmaril@185: { insilmaril@185: fn = *it; insilmaril@185: fileLoad(*it, lmode); insilmaril@185: ++it; insilmaril@185: } insilmaril@0: } insilmaril@185: delete (fd); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::fileLoad() insilmaril@0: { insilmaril@0: fileLoad (NewMap); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::fileLoadLast(int i) insilmaril@0: { insilmaril@0: fileLoad(*lastMaps.at(lastMapsMenu->indexOf (i) ),NewMap); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::fileSave(const SaveMode &savemode) insilmaril@0: { insilmaril@0: // tmp dir for zipping insilmaril@0: QString tmpMapDir; insilmaril@0: insilmaril@0: // Error codes insilmaril@205: ErrorCode err=success; insilmaril@0: insilmaril@0: QString safeFilePath; insilmaril@0: insilmaril@0: bool saveZipped=currentMapEditor()->saveZipped(); insilmaril@0: insilmaril@151: MapEditor * me=currentMapEditor(); insilmaril@151: if (me) insilmaril@0: { insilmaril@151: QString fn=me->getFilePath(); insilmaril@0: // filename=unnamed, filepath="" in constructor... insilmaril@0: if ( !fn.isEmpty() ) insilmaril@0: { insilmaril@0: // We have a filepath, go on saving insilmaril@0: // First remove existing file, we insilmaril@0: // don't want to add to old zip archives insilmaril@0: QFile f(fn); insilmaril@0: if (f.exists() ) insilmaril@0: if (!f.remove()) insilmaril@0: QMessageBox::warning( 0, tr( "Save Error" ), insilmaril@0: fn+ tr("\ncould not be removed before saving")); insilmaril@0: insilmaril@0: // Look, if we should zip the data: insilmaril@0: if (!saveZipped) insilmaril@0: { insilmaril@185: QMessageBox mb( __VYM, insilmaril@159: tr("The map %1\ndid not use the compressed " insilmaril@0: "vym file format.\nWriting it uncompressed will also write images \n" insilmaril@0: "and flags and thus may overwrite files in the " insilmaril@159: "given directory\n\nDo you want to write the map").arg(fn), insilmaril@0: QMessageBox::Warning, insilmaril@0: QMessageBox::Yes | QMessageBox::Default, insilmaril@0: QMessageBox::No , insilmaril@0: QMessageBox::Cancel | QMessageBox::Escape); insilmaril@0: mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") ); insilmaril@0: mb.setButtonText( QMessageBox::No, tr("uncompressed") ); insilmaril@0: mb.setButtonText( QMessageBox::Cancel, tr("Cancel")); insilmaril@0: switch( mb.exec() ) insilmaril@0: { insilmaril@0: case QMessageBox::Yes: insilmaril@0: // save compressed (default file format) insilmaril@0: saveZipped=true; insilmaril@0: break; insilmaril@0: case QMessageBox::No: insilmaril@0: // save uncompressed insilmaril@0: saveZipped=false; insilmaril@0: break; insilmaril@0: case QMessageBox::Cancel: insilmaril@0: // do nothing insilmaril@0: return; insilmaril@0: break; insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@0: if (saveZipped) insilmaril@0: { insilmaril@0: char tmpdir1[]="/tmp/vym-XXXXXX"; insilmaril@0: tmpMapDir=mkdtemp(tmpdir1); insilmaril@0: insilmaril@151: safeFilePath=me->getFilePath(); insilmaril@151: me->setFilePath (tmpMapDir+"/"+ insilmaril@151: me->getMapName()+ ".xml", insilmaril@0: safeFilePath); insilmaril@151: me->save (savemode); insilmaril@151: me->setFilePath (safeFilePath); insilmaril@0: insilmaril@175: zipDir (tmpMapDir,fn); insilmaril@0: } // save zipped insilmaril@0: else insilmaril@0: { insilmaril@0: // Save unzipped. insilmaril@151: safeFilePath=me->getFilePath(); insilmaril@151: me->setFilePath (fn, safeFilePath); insilmaril@151: me->save (savemode); insilmaril@151: me->setFilePath (safeFilePath); insilmaril@0: } // save zipped insilmaril@0: } // filepath available insilmaril@0: else insilmaril@0: { insilmaril@0: // We have no filepath yet, insilmaril@0: // call fileSaveAs() now, this will call fileSave() insilmaril@0: // again. insilmaril@0: fileSaveAs(savemode); insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@250: if (saveZipped && !tmpMapDir.isEmpty()) insilmaril@0: // Delete tmpDir insilmaril@175: removeDir (QDir(tmpMapDir)); insilmaril@0: insilmaril@0: if (err==success) insilmaril@151: { insilmaril@0: statusBar()->message( insilmaril@159: tr("Saved %1").arg(me->getFilePath()), insilmaril@0: statusbarTime ); insilmaril@151: lastMaps.prepend(me->getFilePath() ); insilmaril@151: setupLastMapsMenu(); insilmaril@151: } else insilmaril@0: statusBar()->message( insilmaril@159: tr("Couldn't save ").arg(me->getFilePath()), insilmaril@0: statusbarTime ); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::fileSave() insilmaril@0: { insilmaril@0: fileSave (CompleteMap); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::fileSaveAs(const SaveMode& savemode) insilmaril@0: { insilmaril@0: QString fn; insilmaril@0: insilmaril@0: if (currentMapEditor()) insilmaril@0: { insilmaril@0: if (savemode==CompleteMap) insilmaril@0: fn = QFileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this ); insilmaril@0: else insilmaril@0: fn = QFileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this ); insilmaril@0: if ( !fn.isEmpty() ) insilmaril@0: { insilmaril@0: // Check for existing file insilmaril@0: if (QFile (fn).exists()) insilmaril@0: { insilmaril@185: QMessageBox mb( __VYM, insilmaril@159: tr("The file %1\nexists already. Do you want to").arg(fn), insilmaril@0: QMessageBox::Warning, insilmaril@0: QMessageBox::Yes | QMessageBox::Default, insilmaril@0: QMessageBox::Cancel | QMessageBox::Escape, insilmaril@0: QMessageBox::QMessageBox::NoButton); insilmaril@0: mb.setButtonText( QMessageBox::Yes, tr("Overwrite") ); insilmaril@0: mb.setButtonText( QMessageBox::Cancel, tr("Cancel")); insilmaril@0: switch( mb.exec() ) insilmaril@0: { insilmaril@0: case QMessageBox::Yes: insilmaril@0: // save insilmaril@0: break; insilmaril@0: case QMessageBox::Cancel: insilmaril@0: // do nothing insilmaril@0: return; insilmaril@0: break; insilmaril@0: } insilmaril@0: } else insilmaril@0: { insilmaril@0: // New file, add extension to filename, if missing insilmaril@0: // This is always .vym or .vyp, depending on savemode insilmaril@0: if (savemode==CompleteMap) insilmaril@0: { insilmaril@0: if (!fn.contains (".vym") && !fn.contains (".xml")) insilmaril@0: fn +=".vym"; insilmaril@0: } else insilmaril@0: { insilmaril@0: if (!fn.contains (".vyp") && !fn.contains (".xml")) insilmaril@0: fn +=".vyp"; insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@0: insilmaril@0: insilmaril@0: insilmaril@0: // Save now insilmaril@0: currentMapEditor()->setFilePath(fn); insilmaril@0: fileSave(savemode); insilmaril@0: insilmaril@0: // Set name of tab insilmaril@94: if (savemode==CompleteMap) insilmaril@94: tabWidget->setTabLabel (currentMapEditor(), insilmaril@94: currentMapEditor()->getFileName() ); insilmaril@0: return; insilmaril@0: } insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@0: void Main::fileSaveAs() insilmaril@0: { insilmaril@0: fileSaveAs (CompleteMap); insilmaril@0: } insilmaril@0: insilmaril@205: void Main::fileImportKDEBookmarks() insilmaril@205: { insilmaril@205: ImportKDEBookmarks im; insilmaril@205: im.transform(); insilmaril@205: if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() ) insilmaril@205: currentMapEditor()->setFilePath (""); insilmaril@205: } insilmaril@205: insilmaril@314: void Main::fileImportFirefoxBookmarks() insilmaril@314: { insilmaril@314: ImportFirefoxBookmarks im; insilmaril@314: im.transform(); insilmaril@314: if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() ) insilmaril@314: currentMapEditor()->setFilePath (""); insilmaril@314: } insilmaril@314: insilmaril@215: void Main::fileImportMM() insilmaril@215: { insilmaril@215: ImportMM im; insilmaril@215: insilmaril@215: QFileDialog *fd=new QFileDialog( this); insilmaril@215: if (!lastFileDir.isEmpty()) insilmaril@215: fd->setDir (lastFileDir); insilmaril@215: fd->setMode (QFileDialog::ExistingFiles); insilmaril@215: fd->addFilter ("Mind Manager (*.mmap)"); insilmaril@215: fd->setCaption(tr("Import")+" "+"Mind Manager"); insilmaril@215: fd->show(); insilmaril@215: insilmaril@215: if ( fd->exec() == QDialog::Accepted ) insilmaril@215: { insilmaril@215: lastFileDir=fd->dirPath(); insilmaril@215: QStringList flist = fd->selectedFiles(); insilmaril@215: QStringList::Iterator it = flist.begin(); insilmaril@215: while( it != flist.end() ) insilmaril@215: { insilmaril@215: im.setFile (*it); insilmaril@215: if (im.transform() && insilmaril@215: success==fileLoad (im.getTransformedFile(),NewMap) && insilmaril@215: currentMapEditor() ) insilmaril@215: currentMapEditor()->setFilePath (""); insilmaril@215: insilmaril@215: ++it; insilmaril@215: } insilmaril@215: } insilmaril@215: delete (fd); insilmaril@215: insilmaril@215: } insilmaril@215: insilmaril@215: void Main::fileImportDir() insilmaril@215: { insilmaril@215: if (currentMapEditor()) insilmaril@215: currentMapEditor()->importDir(); insilmaril@215: } insilmaril@215: insilmaril@0: void Main::fileExportXML() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: { insilmaril@0: QString dir=browseDirectory(tr("Export XML to directory")); insilmaril@0: if (dir !="" && reallyWriteDirectory(dir) ) insilmaril@0: currentMapEditor()->exportXML(dir); insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@0: insilmaril@0: void Main::fileExportXHTML() insilmaril@0: { insilmaril@260: MapEditor *me=currentMapEditor(); insilmaril@0: QString dir; insilmaril@260: if (me) insilmaril@0: { insilmaril@0: ExportXHTMLDialog dia(this); insilmaril@260: dia.setFilePath (me->getFilePath() ); insilmaril@260: dia.setMapName (me->getMapName() ); insilmaril@0: dia.readSettings(); insilmaril@0: insilmaril@0: if (dia.exec()==QDialog::Accepted) insilmaril@0: { insilmaril@0: QString dir=dia.getDir(); insilmaril@0: // Check, if warnings should be used before overwriting insilmaril@0: // the output directory insilmaril@0: bool ok; insilmaril@0: if (dia.warnings()) insilmaril@0: ok=reallyWriteDirectory(dir); insilmaril@0: else insilmaril@0: ok=true; insilmaril@0: insilmaril@0: if (ok) insilmaril@0: { insilmaril@260: me->exportXML (dia.getDir() ); insilmaril@260: dia.doExport(me->getMapName() ); insilmaril@0: if (dia.hasChanged()) insilmaril@260: me->setChanged(); insilmaril@0: } insilmaril@0: } insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@0: void Main::fileExportImage(int item) insilmaril@0: { insilmaril@260: MapEditor *me=currentMapEditor(); insilmaril@260: if (me) insilmaril@0: { insilmaril@0: QString fn = QFileDialog::getSaveFileName( QString::null, "Image (*.bmp *.jpg *.pbm *.pgm *.png *.ppm *xbm *.xpm)", insilmaril@0: this ); insilmaril@0: if ( !fn.isEmpty() ) insilmaril@260: me->exportImage(fn,item); insilmaril@194: else insilmaril@159: statusBar()->message( tr("Couldn't save %1").arg(fn), statusbarTime ); insilmaril@194: insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@0: void Main::fileExportASCII() insilmaril@0: { insilmaril@260: MapEditor *me=currentMapEditor(); insilmaril@260: if (me) insilmaril@228: { insilmaril@228: ExportASCII ex; insilmaril@260: ex.setMapCenter(me->getMapCenter()); insilmaril@228: ex.addFilter ("TXT (*.txt)"); insilmaril@228: ex.setCaption(__VYM " -" +tr("Export as ASCII")+" "+tr("(still experimental)")); insilmaril@260: if (ex.execDialog() ) insilmaril@260: { insilmaril@260: me->setExportMode(true); insilmaril@260: ex.doExport(); insilmaril@260: me->setExportMode(false); insilmaril@260: } insilmaril@228: } insilmaril@0: } insilmaril@0: insilmaril@163: void Main::fileExportLaTeX() insilmaril@163: { insilmaril@260: MapEditor *me=currentMapEditor(); insilmaril@260: if (me) insilmaril@228: { insilmaril@228: ExportLaTeX ex; insilmaril@260: ex.setMapCenter(me->getMapCenter()); insilmaril@228: ex.addFilter ("Tex (*.tex)"); insilmaril@228: ex.setCaption(__VYM " -" +tr("Export as LaTeX")+" "+tr("(still experimental)")); insilmaril@260: if (ex.execDialog() ) insilmaril@260: { insilmaril@260: me->setExportMode(true); insilmaril@260: ex.doExport(); insilmaril@260: me->setExportMode(false); insilmaril@260: } insilmaril@228: } insilmaril@228: } insilmaril@228: insilmaril@243: void Main::fileExportKDEBookmarks() insilmaril@243: { insilmaril@243: ExportKDEBookmarks ex; insilmaril@260: MapEditor *me=currentMapEditor(); insilmaril@260: if (me) insilmaril@243: { insilmaril@260: ex.setMapCenter (me->getMapCenter() ); insilmaril@243: ex.doExport(); insilmaril@243: } insilmaril@243: } insilmaril@243: insilmaril@228: void Main::fileExportTaskjuggler() insilmaril@228: { insilmaril@228: ExportTaskjuggler ex; insilmaril@260: MapEditor *me=currentMapEditor(); insilmaril@260: if (me) insilmaril@228: { insilmaril@260: ex.setMapCenter (me->getMapCenter() ); insilmaril@228: ex.setCaption ( __VYM " - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)")); insilmaril@243: ex.addFilter ("Taskjuggler (*.tjp)"); insilmaril@260: if (ex.execDialog() ) insilmaril@260: { insilmaril@260: me->setExportMode(true); insilmaril@260: ex.doExport(); insilmaril@260: me->setExportMode(false); insilmaril@260: } insilmaril@228: } insilmaril@163: } insilmaril@163: insilmaril@163: void Main::fileExportOOPresentation() insilmaril@163: { insilmaril@228: ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to")+" Open Office"); insilmaril@185: // FIXME add extra info in dialog insilmaril@185: //ImagePreview *p =new ImagePreview (fd); insilmaril@185: //fd->setContentsPreviewEnabled( TRUE ); insilmaril@185: //fd->setContentsPreview( p, p ); insilmaril@185: //fd->setPreviewMode( QFileDialog::Contents ); insilmaril@228: fd->setCaption(__VYM " - " +tr("Export to")+" Open Office"); insilmaril@185: //fd->setDir (lastImageDir); insilmaril@185: fd->show(); insilmaril@185: insilmaril@185: if ( fd->exec() == QDialog::Accepted ) insilmaril@185: { insilmaril@185: QString fn=fd->selectedFile(); insilmaril@185: //lastImageDir=fn.left(fn.findRev ("/")); insilmaril@185: if (currentMapEditor()) insilmaril@185: currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig()); insilmaril@185: } insilmaril@163: } insilmaril@163: insilmaril@0: void Main::fileCloseMap() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: { insilmaril@0: if (currentMapEditor()->hasChanged()) insilmaril@0: { insilmaril@185: QMessageBox mb( __VYM, insilmaril@159: tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()), insilmaril@0: QMessageBox::Warning, insilmaril@0: QMessageBox::Yes | QMessageBox::Default, insilmaril@0: QMessageBox::No, insilmaril@0: QMessageBox::Cancel | QMessageBox::Escape ); insilmaril@0: mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") ); insilmaril@0: mb.setButtonText( QMessageBox::No, tr("Discard changes")); insilmaril@0: switch( mb.exec() ) insilmaril@0: { insilmaril@0: case QMessageBox::Yes: insilmaril@0: // save and close insilmaril@0: fileSave(CompleteMap); insilmaril@0: break; insilmaril@0: case QMessageBox::No: insilmaril@0: // close without saving insilmaril@0: break; insilmaril@0: case QMessageBox::Cancel: insilmaril@0: // do nothing insilmaril@0: return; insilmaril@0: } insilmaril@0: } insilmaril@0: currentMapEditor()->closeMap(); insilmaril@0: tabWidget->removePage(currentMapEditor()); insilmaril@0: if (tabWidget->count()==0) insilmaril@0: actionFilePrint->setEnabled (false); insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@0: void Main::filePrint() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->print(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::fileExitVYM() insilmaril@0: { insilmaril@0: // Check if one or more editors have changed insilmaril@0: MapEditor *me; insilmaril@0: int i; insilmaril@0: for (i=0;i<=tabWidget->count() -1;i++) insilmaril@0: { insilmaril@0: insilmaril@0: me=(MapEditor*)tabWidget->page(i); insilmaril@0: insilmaril@0: // If something changed, ask what to do insilmaril@0: if (me->isUnsaved()) insilmaril@0: { insilmaril@0: tabWidget->setCurrentPage(i); insilmaril@185: QMessageBox mb( __VYM, insilmaril@0: tr("This map is not saved yet. Do you want to"), insilmaril@0: QMessageBox::Warning, insilmaril@0: QMessageBox::Yes | QMessageBox::Default, insilmaril@0: QMessageBox::No, insilmaril@0: QMessageBox::Cancel | QMessageBox::Escape ); insilmaril@0: mb.setButtonText( QMessageBox::Yes, tr("Save map") ); insilmaril@0: mb.setButtonText( QMessageBox::No, tr("Discard changes") ); insilmaril@0: mb.show(); insilmaril@0: // Call undocumented function: setActiveWindow is only insilmaril@0: // possible, if widget is visible. This depends on insilmaril@0: // windowmanager... insilmaril@0: #if defined(Q_OS_LINUX) insilmaril@0: qt_wait_for_window_manager( this); insilmaril@0: #endif insilmaril@0: mb.setActiveWindow(); insilmaril@0: switch( mb.exec() ) { insilmaril@0: case QMessageBox::Yes: insilmaril@0: // save (the changed editors) and exit insilmaril@0: fileSave(CompleteMap); insilmaril@0: break; insilmaril@0: case QMessageBox::No: insilmaril@0: // exit without saving insilmaril@0: break; insilmaril@0: case QMessageBox::Cancel: insilmaril@0: // don't save and don't exit insilmaril@0: return; insilmaril@0: } insilmaril@0: } insilmaril@0: } // loop over all MEs insilmaril@0: qApp->quit(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editUndo() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->undo(); insilmaril@0: } insilmaril@0: insilmaril@163: void Main::editRedo() insilmaril@0: { insilmaril@163: if (currentMapEditor()) insilmaril@163: currentMapEditor()->redo(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editCopy() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->copy(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editPaste() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->paste(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editCut() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->cut(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editOpenFindWindow() insilmaril@0: { insilmaril@0: findWindow->popup(); insilmaril@0: findWindow->raise(); insilmaril@0: insilmaril@0: // Call undocumented function: setActiveWindow is only insilmaril@0: // possible, if widget is visible. This depends on insilmaril@0: // windowmanager... insilmaril@0: #if defined(Q_OS_LINUX) insilmaril@0: qt_wait_for_window_manager( this); insilmaril@0: #endif insilmaril@0: findWindow->setActiveWindow(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editFind(QString s) insilmaril@0: { insilmaril@0: bool cs=false; insilmaril@0: BranchObj *bo=currentMapEditor()->findText(s, cs); insilmaril@0: if (bo) insilmaril@0: { insilmaril@0: statusBar()->message( "Found: " + bo->getHeading(), statusbarTime ); insilmaril@0: } else insilmaril@0: { insilmaril@0: QMessageBox::information( findWindow, tr( "VYM -Information:" ), insilmaril@159: tr("No matches found for %1").arg(s)); insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editFindChanged() insilmaril@0: { // Notify editor, to abort the current find process insilmaril@0: currentMapEditor()->findReset(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editOpenURL() insilmaril@0: { insilmaril@266: // Open new browser insilmaril@0: if (currentMapEditor()) insilmaril@266: { insilmaril@266: QString url=currentMapEditor()->getURL(); insilmaril@266: if (url=="") return; insilmaril@266: QString browser=settings.readEntry("/vym/mainwindow/readerURL" ); insilmaril@266: procBrowser = new QProcess( this ); insilmaril@266: insilmaril@266: procBrowser->addArgument( browser); insilmaril@266: procBrowser->addArgument( url); insilmaril@266: insilmaril@266: if ( !procBrowser->start() ) insilmaril@266: { insilmaril@266: // try to set path to browser insilmaril@266: QMessageBox::warning(0, insilmaril@266: tr("Warning"), insilmaril@266: tr("Couldn't find a viewer to open %1.\n").arg(url)+ insilmaril@266: tr("Please use Settings->")+tr("Set application to open an URL")); insilmaril@266: settingsURL() ; insilmaril@266: } insilmaril@266: } insilmaril@266: } insilmaril@266: void Main::editOpenURLTab() insilmaril@266: { insilmaril@266: if (currentMapEditor()) insilmaril@266: { insilmaril@266: QString url=currentMapEditor()->getURL(); insilmaril@266: if (url=="") return; insilmaril@266: QString browser=settings.readEntry("/vym/mainwindow/readerURL" ); insilmaril@266: if (browser.contains("konqueror") && procBrowser && procBrowser->isRunning()) insilmaril@266: { insilmaril@266: // Try to open new tab in existing browser insilmaril@266: QProcess *p=new QProcess (this); insilmaril@266: p->addArgument ("dcop"); insilmaril@266: p->addArgument (QString("konqueror-%1").arg(procBrowser->processIdentifier())); insilmaril@266: p->addArgument ("konqueror-mainwindow#1"); insilmaril@266: p->addArgument ("newTab"); insilmaril@266: p->addArgument (url); insilmaril@266: if ( !p->start() ) insilmaril@266: // try to set browser insilmaril@266: QMessageBox::warning(0, insilmaril@266: tr("Warning"), insilmaril@266: tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror")); insilmaril@266: } else insilmaril@266: // Open new browser insilmaril@266: editOpenURL(); insilmaril@266: } insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editURL() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->editURL(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editHeading2URL() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->editHeading2URL(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editBugzilla2URL() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->editBugzilla2URL(); insilmaril@0: } insilmaril@0: insilmaril@175: void Main::editFATE2URL() insilmaril@175: { insilmaril@175: if (currentMapEditor()) insilmaril@175: currentMapEditor()->editFATE2URL(); insilmaril@175: } insilmaril@175: insilmaril@0: void Main::editOpenVymLink() insilmaril@0: { insilmaril@0: // Get current path to map insilmaril@0: QString currentVymLink; insilmaril@0: if (currentMapEditor()) insilmaril@0: { insilmaril@0: currentVymLink=currentMapEditor()->getVymLink(); insilmaril@0: // compare path with already loaded maps insilmaril@0: int index=-1; insilmaril@0: int i; insilmaril@0: MapEditor *me; insilmaril@0: for (i=0;i<=tabWidget->count() -1;i++) insilmaril@0: { insilmaril@0: me=(MapEditor*)tabWidget->page(i); insilmaril@0: if (currentVymLink==me->getFilePath() ) insilmaril@0: { insilmaril@0: index=i; insilmaril@0: break; insilmaril@0: } insilmaril@0: } insilmaril@0: if (index<0) insilmaril@0: // Load map insilmaril@0: { insilmaril@0: if (!QFile(currentVymLink).exists() ) insilmaril@0: QMessageBox::critical( 0, tr( "Critical Error" ), insilmaril@159: tr("Couldn't open map %1").arg(currentVymLink)); insilmaril@0: else insilmaril@0: { insilmaril@0: fileLoad (currentVymLink, NewMap); insilmaril@0: tabWidget->setCurrentPage (tabWidget->count()-1); insilmaril@0: } insilmaril@0: } else insilmaril@0: // Go to tab containing the map insilmaril@0: tabWidget->setCurrentPage (index); insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editVymLink() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->editVymLink(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editDeleteVymLink() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->deleteVymLink(); insilmaril@0: } insilmaril@0: insilmaril@243: void Main::editToggleHideExport() insilmaril@243: { insilmaril@243: if (currentMapEditor()) insilmaril@294: currentMapEditor()->toggleHideExport(); insilmaril@243: } insilmaril@243: insilmaril@0: void Main::editMapInfo() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->editMapInfo(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editMoveUp() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->moveBranchUp(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editMoveDown() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->moveBranchDown(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editToggleScroll() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: { insilmaril@0: currentMapEditor()->toggleScroll(); insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editUnScrollAll() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: { insilmaril@0: currentMapEditor()->unScrollAll(); insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editHeading() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->editHeading(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editNewBranch() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->addNewBranch(0); insilmaril@0: } insilmaril@0: insilmaril@98: void Main::editNewBranchHere() insilmaril@98: { insilmaril@98: if (currentMapEditor()) insilmaril@98: currentMapEditor()->addNewBranchHere(); insilmaril@98: } insilmaril@98: insilmaril@0: void Main::editNewBranchAbove() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->addNewBranch(-1); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editNewBranchBelow() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->addNewBranch(1); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editImportAdd() insilmaril@0: { insilmaril@0: fileLoad (ImportAdd); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editImportReplace() insilmaril@0: { insilmaril@0: fileLoad (ImportReplace); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editSaveBranch() insilmaril@0: { insilmaril@0: fileSaveAs (PartOfMap); insilmaril@0: } insilmaril@0: insilmaril@294: void Main::editRemoveBranchKeepChilds() insilmaril@98: { insilmaril@98: if (currentMapEditor()) insilmaril@294: currentMapEditor()->removeBranchKeepChilds(); insilmaril@98: } insilmaril@98: insilmaril@98: void Main::editRemoveChilds() insilmaril@98: { insilmaril@98: if (currentMapEditor()) insilmaril@98: currentMapEditor()->removeChilds(); insilmaril@98: } insilmaril@98: insilmaril@0: void Main::editDeleteSelection() insilmaril@0: { insilmaril@151: if (currentMapEditor() && actionSettingsUseDelKey->isOn()) insilmaril@0: currentMapEditor()->deleteSelection(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editUpperBranch() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->selectUpperBranch(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editLowerBranch() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->selectLowerBranch(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editLeftBranch() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->selectLeftBranch(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editRightBranch() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->selectRightBranch(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editFirstBranch() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->selectFirstBranch(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editLastBranch() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->selectLastBranch(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editLoadImage() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->loadFloatImage(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editSaveImage(int item) insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->saveFloatImage(item); insilmaril@0: } insilmaril@0: insilmaril@95: void Main::editFollowXLink(int item) insilmaril@89: { insilmaril@89: if (currentMapEditor()) insilmaril@95: currentMapEditor()->followXLink(branchLinksContextMenu->indexOf(item)); insilmaril@89: } insilmaril@89: insilmaril@95: void Main::editEditXLink(int item) insilmaril@94: { insilmaril@94: if (currentMapEditor()) insilmaril@95: currentMapEditor()->editXLink(branchLinksContextMenuDup->indexOf(item)); insilmaril@94: } insilmaril@94: insilmaril@0: void Main::formatSelectColor() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: { insilmaril@0: QColor col = QColorDialog::getColor( currentMapEditor()->color(), this ); insilmaril@0: if ( !col.isValid() ) return; insilmaril@0: currentMapEditor()->setColor( col ); insilmaril@0: colorChanged( col ); insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@0: void Main::formatPickColor() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: colorChanged( currentMapEditor()->pickColor() ); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::colorChanged(QColor c) insilmaril@0: { insilmaril@0: QPixmap pix( 16, 16 ); insilmaril@0: pix.fill( c ); insilmaril@0: actionFormatColor->setIconSet( pix ); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::formatColorItem() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->colorItem(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::formatColorBranch() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->colorBranch(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::formatLinkStyleLine() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->setLinkStyle(StyleLine); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::formatLinkStyleParabel() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->setLinkStyle(StyleParabel); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::formatLinkStylePolyLine() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->setLinkStyle(StylePolyLine); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::formatLinkStylePolyParabel() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->setLinkStyle(StylePolyParabel); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::formatSelectBackColor() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->selectBackgroundColor(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::formatSelectLinkColor() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->selectLinkColor(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::formatToggleLinkColorHint() insilmaril@0: { insilmaril@0: currentMapEditor()->toggleLinkColorHint(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::formatFrameNone() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->setFrame(NoFrame); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::formatFrameRectangle() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->setFrame(Rectangle); insilmaril@0: } insilmaril@0: insilmaril@175: void Main::formatIncludeImagesVer() insilmaril@175: { insilmaril@175: if (currentMapEditor()) insilmaril@175: currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn()); insilmaril@175: } insilmaril@175: insilmaril@175: void Main::formatIncludeImagesHor() insilmaril@175: { insilmaril@175: if (currentMapEditor()) insilmaril@175: currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn()); insilmaril@175: } insilmaril@175: insilmaril@160: void Main::formatHideLinkUnselected() insilmaril@160: { insilmaril@160: if (currentMapEditor()) insilmaril@160: currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn()); insilmaril@160: } insilmaril@160: insilmaril@0: void Main::viewZoomReset() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: { insilmaril@0: QWMatrix m; insilmaril@0: m.reset(); insilmaril@0: currentMapEditor()->setWorldMatrix( m ); insilmaril@0: currentMapEditor()->setViewCenter(); insilmaril@0: currentMapEditor()->adjustCanvasSize(); insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@0: void Main::viewZoomIn() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: { insilmaril@0: QWMatrix m = currentMapEditor()->worldMatrix(); insilmaril@0: m.scale( 1.25, 1.25 ); insilmaril@0: currentMapEditor()->setWorldMatrix( m ); insilmaril@0: currentMapEditor()->setViewCenter(); insilmaril@0: currentMapEditor()->adjustCanvasSize(); insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@0: void Main::viewZoomOut() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: { insilmaril@0: QWMatrix m = currentMapEditor()->worldMatrix(); insilmaril@0: m.scale( 0.8, 0.8 ); insilmaril@0: currentMapEditor()->setWorldMatrix( m ); insilmaril@0: currentMapEditor()->setViewCenter(); insilmaril@0: currentMapEditor()->adjustCanvasSize(); insilmaril@0: } insilmaril@0: } insilmaril@89: insilmaril@89: void Main::modModeColor() insilmaril@89: { insilmaril@89: } insilmaril@89: insilmaril@89: void Main::modModeLink() insilmaril@89: { insilmaril@89: } insilmaril@89: insilmaril@0: bool Main::settingsPDF() insilmaril@0: { insilmaril@0: // Default browser is set in constructor insilmaril@0: bool ok; insilmaril@0: QString text = QInputDialog::getText( insilmaril@266: "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal, insilmaril@0: settings.readEntry("/vym/mainwindow/readerPDF"), &ok, this ); insilmaril@0: if (ok) insilmaril@0: settings.writeEntry ("/vym/mainwindow/readerPDF",text); insilmaril@0: return ok; insilmaril@0: } insilmaril@0: insilmaril@0: insilmaril@0: bool Main::settingsURL() insilmaril@0: { insilmaril@0: // Default browser is set in constructor insilmaril@0: bool ok; insilmaril@0: QString text = QInputDialog::getText( insilmaril@266: "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal, insilmaril@0: settings.readEntry("/vym/mainwindow/readerURL") insilmaril@0: , &ok, this ); insilmaril@0: if (ok) insilmaril@0: settings.writeEntry ("/vym/mainwindow/readerURL",text); insilmaril@0: return ok; insilmaril@0: } insilmaril@0: insilmaril@0: void Main::windowToggleNoteEditor() insilmaril@0: { insilmaril@0: if (textEditor->showWithMain() ) insilmaril@0: windowHideNoteEditor(); insilmaril@0: else insilmaril@0: windowShowNoteEditor(); insilmaril@0: } insilmaril@0: insilmaril@294: void Main::windowToggleHistory() insilmaril@294: { insilmaril@294: if (currentMapEditor()) insilmaril@294: currentMapEditor()->toggleHistoryWindow(); insilmaril@294: } insilmaril@294: insilmaril@160: void Main::updateNoteFlag() insilmaril@160: { insilmaril@160: if (currentMapEditor()) insilmaril@160: currentMapEditor()->updateNoteFlag(); insilmaril@160: } insilmaril@160: insilmaril@0: void Main::windowShowNoteEditor() insilmaril@0: { insilmaril@0: textEditor->setShowWithMain(true); insilmaril@0: textEditor->show(); insilmaril@0: actionViewToggleNoteEditor->setOn (true); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::windowHideNoteEditor() insilmaril@0: { insilmaril@0: textEditor->setShowWithMain(false); insilmaril@0: textEditor->hide(); insilmaril@0: actionViewToggleNoteEditor->setOn (false); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::windowNextEditor() insilmaril@0: { insilmaril@0: if (tabWidget->currentPageIndex() < tabWidget->count()) insilmaril@0: tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::windowPreviousEditor() insilmaril@0: { insilmaril@0: if (tabWidget->currentPageIndex() >0) insilmaril@0: tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::standardFlagChanged() insilmaril@0: { insilmaril@0: currentMapEditor()->toggleStandardFlag(sender()->name()); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::testFunction() insilmaril@0: { insilmaril@205: currentMapEditor()->testFunction(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::helpDoc() insilmaril@0: { insilmaril@0: QString docpath; insilmaril@103: #if defined(Q_OS_MACX) insilmaril@103: docpath="./vym.app/Contents/vym.pdf"; insilmaril@103: #else insilmaril@103: // default path in SUSE LINUX insilmaril@103: docpath="/usr/share/doc/packages/vym/doc/vym.pdf"; insilmaril@103: #endif insilmaril@0: insilmaril@0: if (!QFile (docpath).exists() ) insilmaril@0: { insilmaril@0: // relative path for easy testing in tarball insilmaril@0: docpath="doc/vym.pdf"; insilmaril@0: if (!QFile (docpath).exists() ) insilmaril@0: { insilmaril@0: // relative path for testing while still writing vym.tex insilmaril@0: docpath="doc/tex/vym.pdf"; insilmaril@0: if (!QFile (docpath).exists() ) insilmaril@0: { insilmaril@175: // Try yet another one for Knoppix insilmaril@175: docpath="/usr/share/doc/packages/vym/vym.pdf"; insilmaril@175: if (!QFile (docpath).exists() ) insilmaril@175: { insilmaril@175: QMessageBox::critical(0, insilmaril@175: tr("Critcal error"), insilmaril@175: tr("Couldn't find the documentation\n" insilmaril@175: "vym.pdf in various places.")); insilmaril@175: return; insilmaril@175: } insilmaril@0: } insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@0: Process *pdfProc = new Process(); insilmaril@0: pdfProc->clearArguments(); insilmaril@0: pdfProc->addArgument( settings.readEntry("/vym/mainwindow/readerPDF")); insilmaril@0: pdfProc->addArgument( docpath); insilmaril@0: insilmaril@0: if ( !pdfProc->start() ) insilmaril@0: { insilmaril@0: // error handling insilmaril@266: QMessageBox::warning(0, insilmaril@266: tr("Warning"), insilmaril@266: tr("Couldn't find a viewer to open %1.\n").arg("vym.pdf")+ insilmaril@266: tr("Please use Settings->")+tr("Set application to open PDF files")); insilmaril@266: settingsPDF(); insilmaril@0: return; insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@0: insilmaril@0: void Main::helpAbout() insilmaril@0: { insilmaril@148: AboutDialog ad; insilmaril@150: ad.setName ("aboutwindow"); insilmaril@148: ad.setMinimumSize(500,500); insilmaril@148: ad.resize (QSize (500,500)); insilmaril@148: ad.exec(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::helpAboutQT() insilmaril@0: { insilmaril@0: QMessageBox::aboutQt( this, "Qt Application Example" ); insilmaril@0: } insilmaril@0: