insilmaril@9: #include "mainwindow.h" insilmaril@9: insilmaril@3: #include insilmaril@9: #include insilmaril@9: #include insilmaril@9: #include insilmaril@2: #include insilmaril@9: #include insilmaril@9: #include insilmaril@9: #include insilmaril@9: #include insilmaril@2: //Added by qt3to4: insilmaril@2: #include insilmaril@2: #include insilmaril@2: #include insilmaril@2: #include insilmaril@2: #include insilmaril@2: #include insilmaril@3: #include insilmaril@2: #include insilmaril@2: //#include // for random seed insilmaril@0: insilmaril@0: #include insilmaril@2: #include insilmaril@0: #include insilmaril@0: insilmaril@2: #include "aboutdialog.h" insilmaril@2: #include "exportoofiledialog.h" insilmaril@2: #include "exports.h" insilmaril@2: #include "exportxhtmldialog.h" insilmaril@2: #include "file.h" insilmaril@0: #include "flagrowobj.h" insilmaril@2: #include "imports.h" insilmaril@0: #include "mapeditor.h" insilmaril@2: #include "misc.h" insilmaril@2: #include "options.h" insilmaril@0: #include "process.h" insilmaril@0: #include "settings.h" insilmaril@2: #include "showtextdialog.h" insilmaril@2: #include "texteditor.h" insilmaril@2: #include "version.h" insilmaril@0: insilmaril@0: extern TextEditor *textEditor; insilmaril@0: extern Main *mainWindow; insilmaril@2: extern QString tmpVymDir; insilmaril@2: extern QString clipboardDir; insilmaril@2: extern bool clipboardEmpty; insilmaril@0: extern int statusbarTime; insilmaril@0: extern FlagRowObj* standardFlagsDefault; insilmaril@2: extern FlagRowObj* systemFlagsDefault; insilmaril@2: insilmaril@2: extern Q3PtrList actionListBranches; insilmaril@0: insilmaril@0: extern QAction* actionFileSave; insilmaril@0: extern QAction* actionFilePrint; insilmaril@0: extern QAction* actionEditUndo; insilmaril@2: 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@2: extern QAction* actionEditOpenURLTab; insilmaril@16: extern QAction* actionEditOpenMultipleURLTabs; insilmaril@0: extern QAction* actionEditURL; insilmaril@0: extern QAction* actionEditHeading2URL; insilmaril@0: extern QAction* actionEditBugzilla2URL; insilmaril@2: extern QAction* actionEditFATE2URL; insilmaril@0: extern QAction *actionEditOpenVymLink; insilmaril@17: extern QAction *actionEditOpenMultipleVymLinks; insilmaril@0: extern QAction *actionEditVymLink; insilmaril@0: extern QAction *actionEditDeleteVymLink; insilmaril@2: extern QAction *actionEditToggleHideExport; insilmaril@0: extern QAction *actionEditMapInfo; insilmaril@0: extern QAction *actionEditHeading; insilmaril@0: extern QAction *actionEditDelete; insilmaril@0: extern QAction *actionEditAddBranch; insilmaril@2: extern QAction *actionEditAddBranchHere; insilmaril@0: extern QAction *actionEditAddBranchAbove; insilmaril@0: extern QAction *actionEditAddBranchBelow; insilmaril@2: extern QAction *actionEditRemoveBranchKeepChilds; insilmaril@2: 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@2: extern QAction *actionFormatIncludeImagesVer; insilmaril@2: extern QAction *actionFormatIncludeImagesHor; insilmaril@0: insilmaril@3: extern QActionGroup* actionGroupModModes; insilmaril@2: extern QAction* actionModModeColor; insilmaril@2: extern QAction* actionModModeLink; insilmaril@2: extern QAction* actionModModeCopy; insilmaril@2: insilmaril@3: extern QActionGroup *actionGroupFormatFrameTypes; insilmaril@0: extern QAction *actionFormatFrameNone; insilmaril@0: extern QAction *actionFormatFrameRectangle; insilmaril@0: insilmaril@3: extern QActionGroup *actionGroupFormatLinkStyles; insilmaril@0: extern QAction *actionFormatLinkStyleLine; insilmaril@0: extern QAction *actionFormatLinkStyleParabel; insilmaril@0: extern QAction *actionFormatLinkStylePolyLine; insilmaril@0: extern QAction *actionFormatLinkStylePolyParabel; insilmaril@2: extern QAction *actionFormatHideLinkUnselected; insilmaril@0: insilmaril@0: extern QAction *actionViewToggleNoteEditor; insilmaril@2: 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* actionSettingsUseDelKey; insilmaril@2: extern QAction* actionSettingsUseFlagGroups; insilmaril@2: extern QAction* actionSettingsUseHideExport; insilmaril@0: insilmaril@4: extern QMenu* branchContextMenu; insilmaril@4: extern QMenu* branchAddContextMenu; insilmaril@4: extern QMenu* branchRemoveContextMenu; insilmaril@17: extern QMenu* branchLinksContextMenu; insilmaril@17: extern QMenu* branchXLinksContextMenuEdit; insilmaril@17: extern QMenu* branchXLinksContextMenuFollow; insilmaril@4: extern QMenu* floatimageContextMenu; insilmaril@4: extern QMenu* canvasContextMenu; insilmaril@4: extern QMenu* fileLastMapsMenu; insilmaril@4: extern QMenu* fileImportMenu; insilmaril@4: extern QMenu* fileExportMenu; insilmaril@0: insilmaril@0: insilmaril@0: extern Settings settings; insilmaril@0: extern Options options; insilmaril@4: extern ImageIO imageIO; insilmaril@4: insilmaril@2: extern QDir vymBaseDir; insilmaril@4: extern QDir lastImageDir; insilmaril@11: extern QDir lastFileDir; insilmaril@2: extern QString iconPath; insilmaril@2: extern QString flagsPath; insilmaril@0: insilmaril@2: Main::Main(QWidget* parent, const char* name, Qt::WFlags f) : insilmaril@3: 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@13: resize (settings.value( "/mainwindow/geometry/size",QSize (800,600)).toSize()); insilmaril@13: move (settings.value( "/mainwindow/geometry/pos", QPoint(300,100)).toPoint()); insilmaril@0: insilmaril@0: insilmaril@2: // Create unique temporary directory insilmaril@2: tmpVymDir=makeUniqueDir ("/tmp/vym-XXXXXX"); insilmaril@2: insilmaril@2: // Create direcctory for clipboard insilmaril@2: clipboardDir=tmpVymDir+"/clipboard"; insilmaril@2: QDir d(clipboardDir); insilmaril@2: d.mkdir (clipboardDir,true); insilmaril@2: makeSubDirs (clipboardDir); insilmaril@2: clipboardEmpty=true; insilmaril@2: insilmaril@2: procBrowser=NULL; insilmaril@2: insilmaril@2: // FIXME not used currently insilmaril@2: // Set random seed (random used for object IDs) insilmaril@2: // QTime t = QTime::currentTime(); // set random seed insilmaril@2: // srand( t.hour()*12+t.minute()*60+t.second()*60 ); insilmaril@2: insilmaril@2: insilmaril@0: // Initialize some settings, which are platform dependant insilmaril@0: QString p,s; insilmaril@0: insilmaril@0: // application to open URLs insilmaril@13: p="/mainwindow/readerURL"; insilmaril@0: #if defined(Q_OS_LINUX) insilmaril@13: s=settings.value (p,"konqueror").toString(); insilmaril@0: #else insilmaril@0: #if defined(Q_OS_MACX) insilmaril@13: s=settings.value (p,"/usr/bin/open").toString(); insilmaril@0: #else insilmaril@13: s=settings.value (p,"mozilla"); insilmaril@0: #endif insilmaril@0: #endif insilmaril@13: settings.setValue( p,s); insilmaril@0: insilmaril@0: // application to open PDFs insilmaril@13: p="/mainwindow/readerPDF"; insilmaril@0: #if defined(Q_OS_LINUX) insilmaril@13: s=settings.value (p,"acroread").toString(); insilmaril@0: #else insilmaril@0: #if defined(Q_OS_MACX) insilmaril@13: s=settings.value (p,"/usr/bin/open").toString(); insilmaril@0: #else insilmaril@13: s=settings.value (p,"acroread").toString(); insilmaril@0: #endif insilmaril@0: #endif insilmaril@13: settings.setValue( 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@16: lineedit=new QLineEdit (this); insilmaril@16: lineedit->hide(); insilmaril@16: insilmaril@0: setCentralWidget(tabWidget); insilmaril@0: insilmaril@0: setupFileActions(); insilmaril@0: setupEditActions(); insilmaril@0: setupFormatActions(); insilmaril@0: setupViewActions(); insilmaril@2: setupModeActions(); insilmaril@0: setupFlagActions(); insilmaril@0: setupSettingsActions(); insilmaril@0: setupContextMenus(); insilmaril@13: if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions(); insilmaril@0: setupHelpActions(); insilmaril@0: insilmaril@0: statusBar(); insilmaril@0: insilmaril@13: restoreState (settings.value("/mainwindow/state",0).toByteArray()); 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@2: // Connect TextEditor, so that we can update flags if text changes insilmaril@2: connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag())); insilmaril@2: insilmaril@0: updateGeometry(); insilmaril@0: } insilmaril@0: insilmaril@0: Main::~Main() insilmaril@0: { insilmaril@0: // Save Settings insilmaril@13: settings.setValue ( "/mainwindow/geometry/size", size() ); insilmaril@13: settings.setValue ( "/mainwindow/geometry/pos", pos() ); insilmaril@13: insilmaril@13: settings.setValue ("/mainwindow/state",saveState(0)); insilmaril@13: insilmaril@13: settings.setValue( "/version/version", __VYM_VERSION ); insilmaril@13: settings.setValue( "/version/builddate", __BUILD_DATE ); insilmaril@13: insilmaril@17: settings.setValue( "/mapeditor/editmode/autoSelectHeading",actionSettingsAutoselectHeading->isOn() ); insilmaril@17: settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoselectText->isOn() ); insilmaril@17: settings.setValue( "/mapeditor/editmode/autoEdit",actionSettingsAutoedit->isOn() ); insilmaril@13: settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() ); insilmaril@13: settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() ); insilmaril@13: settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() ); insilmaril@0: insilmaril@0: QString s; insilmaril@0: int maps=lastMaps.count(); insilmaril@13: settings.setValue( "/lastMaps/number",maps ); insilmaril@0: for (int i=1;i<=maps;i++) insilmaril@0: { insilmaril@13: s=QString("/lastMaps/map-%1").arg(i); insilmaril@0: if (!s.isEmpty() && i<=maxLastMaps) insilmaril@13: settings.setValue (s, lastMaps.at(i-1)); insilmaril@0: } insilmaril@0: insilmaril@0: insilmaril@0: // To make the texteditor save its settings, call the destructor insilmaril@0: delete (textEditor); insilmaril@2: insilmaril@2: // Remove temporary directory insilmaril@2: 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@13: QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") ); insilmaril@13: QToolBar *tb = addToolBar( tr ("&Map") ); insilmaril@18: tb->setObjectName ("mapTB"); insilmaril@0: insilmaril@0: QAction *a; insilmaril@2: a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New..." ),this); insilmaril@2: a->setStatusTip ( tr( "New map","File menu" ) ); insilmaril@2: a->setShortcut ( Qt::CTRL + Qt::Key_N ); insilmaril@0: a->addTo( tb ); insilmaril@4: fileMenu->addAction (a); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) ); insilmaril@0: insilmaril@2: a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ),this); insilmaril@2: a->setStatusTip (tr( "Open","File menu" ) ); insilmaril@2: a->setShortcut ( Qt::CTRL + Qt::Key_O ); insilmaril@0: a->addTo( tb ); insilmaril@4: fileMenu->addAction (a); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) ); insilmaril@0: insilmaril@4: fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent")); insilmaril@4: fileMenu->addSeparator(); insilmaril@0: insilmaril@2: a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save..." ), this); insilmaril@2: a->setStatusTip ( tr( "Save" )); insilmaril@2: a->setShortcut (Qt::CTRL + Qt::Key_S ); insilmaril@0: a->addTo( tb ); insilmaril@4: fileMenu->addAction (a); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) ); insilmaril@0: actionFileSave=a; insilmaril@0: insilmaril@2: a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As..." ), this); insilmaril@2: a->setStatusTip (tr( "Save &As" ) ); insilmaril@4: fileMenu->addAction (a); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) ); insilmaril@0: insilmaril@4: fileMenu->addSeparator(); insilmaril@4: insilmaril@4: fileImportMenu = fileMenu->addMenu (tr("Import")); insilmaril@2: insilmaril@2: a = new QAction(tr("KDE Bookmarks"), this); insilmaril@2: a->setStatusTip ( tr( "Import")+" "+tr("KDE Bookmarks" )); insilmaril@4: a->addTo (fileImportMenu); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) ); insilmaril@13: insilmaril@13: if (settings.value( "/mainwindow/showTestMenu",false).toBool()) insilmaril@2: { insilmaril@2: a = new QAction( QPixmap(), tr("Firefox Bookmarks"),this); insilmaril@2: a->setStatusTip (tr( "Import")+" "+tr("Firefox Bookmarks" ) ); insilmaril@4: a->addTo (fileImportMenu); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) ); insilmaril@2: } insilmaril@2: insilmaril@2: a = new QAction("Mind Manager...",this); insilmaril@2: a->setStatusTip ( tr( "Import")+" Mind Manager" ); insilmaril@4: fileImportMenu->addAction (a); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) ); insilmaril@2: insilmaril@2: a = new QAction( tr( "Import Dir"+QString("...") ), this); insilmaril@2: a->setStatusTip (tr( "Import directory structure (experimental)" ) ); insilmaril@4: fileImportMenu->addAction (a); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) ); insilmaril@0: insilmaril@4: fileExportMenu = fileMenu->addMenu (tr("Export")); insilmaril@4: insilmaril@4: a = new QAction( tr("Image")+QString("..."), this); insilmaril@4: a->setStatusTip( tr( "Export map as image" )); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) ); insilmaril@4: fileExportMenu->addAction (a); insilmaril@4: insilmaril@4: a = new QAction( "Open Office"+QString("..."), this); insilmaril@4: a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office " )); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) ); insilmaril@4: fileExportMenu->addAction (a); insilmaril@4: insilmaril@4: a = new QAction( "Webpage (XHTML)...",this ); insilmaril@4: a->setShortcut (Qt::ALT + Qt::Key_X); insilmaril@4: a->setStatusTip ( tr( "Export as")+" webpage (XHTML)"); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) ); insilmaril@4: fileExportMenu->addAction (a); insilmaril@4: insilmaril@4: a = new QAction( "Text (ASCII)...", this); insilmaril@4: a->setStatusTip ( tr( "Export as")+" ASCII"+" "+tr("(still experimental)" )); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) ); insilmaril@4: fileExportMenu->addAction (a); insilmaril@4: insilmaril@4: a = new QAction( tr("KDE Bookmarks"), this); insilmaril@4: a->setStatusTip( tr( "Export as")+" "+tr("KDE Bookmarks" )); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) ); insilmaril@4: fileExportMenu->addAction (a); insilmaril@4: insilmaril@4: a = new QAction( "Taskjuggler...", this ); insilmaril@4: a->setStatusTip( tr( "Export as")+" Taskjuggler"+" "+tr("(still experimental)" )); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) ); insilmaril@4: fileExportMenu->addAction (a); insilmaril@4: insilmaril@4: a = new QAction( "LaTeX...", this); insilmaril@4: a->setStatusTip( tr( "Export as")+" LaTeX"+" "+tr("(still experimental)" )); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) ); insilmaril@4: fileExportMenu->addAction (a); insilmaril@4: insilmaril@4: a = new QAction( "XML..." , this ); insilmaril@4: a->setStatusTip (tr( "Export as")+" XML"); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) ); insilmaril@4: fileExportMenu->addAction (a); insilmaril@4: insilmaril@4: fileMenu->addSeparator(); insilmaril@0: insilmaril@2: a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this); insilmaril@2: a->setStatusTip ( tr( "Print" ) ); insilmaril@2: a->setShortcut (Qt::CTRL + Qt::Key_P ); insilmaril@0: a->addTo( tb ); insilmaril@4: fileMenu->addAction (a); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) ); insilmaril@0: actionFilePrint=a; insilmaril@0: insilmaril@2: a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map" ), this); insilmaril@2: a->setStatusTip (tr( "Close Map" ) ); insilmaril@2: a->setShortcut (Qt::ALT + Qt::Key_C ); insilmaril@4: fileMenu->addAction (a); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) ); insilmaril@2: insilmaril@2: a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit")+" "+__VYM, this); insilmaril@2: a->setStatusTip ( tr( "Exit")+" "+__VYM ); insilmaril@2: a->setShortcut (Qt::CTRL + Qt::Key_Q ); insilmaril@4: fileMenu->addAction (a); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) ); insilmaril@0: } insilmaril@0: insilmaril@0: insilmaril@0: //Edit Actions insilmaril@0: void Main::setupEditActions() insilmaril@0: { insilmaril@13: QToolBar *tb = addToolBar( tr ("&Actions") ); insilmaril@0: tb->setLabel( "Edit Actions" ); insilmaril@18: tb->setObjectName ("actionsTB"); insilmaril@5: QMenu *editMenu = menuBar()->addMenu( tr("&Edit") ); insilmaril@0: insilmaril@0: QAction *a; insilmaril@2: QAction *alt; insilmaril@2: a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo" ),this); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) ); insilmaril@2: a->setStatusTip (tr( "Undo" ) ); insilmaril@2: a->setShortcut ( Qt::CTRL + Qt::Key_Z ); insilmaril@0: a->setEnabled (false); insilmaril@5: tb->addAction (a); insilmaril@5: editMenu->addAction (a); insilmaril@0: actionEditUndo=a; insilmaril@2: insilmaril@16: a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo" ), this); insilmaril@16: a->setStatusTip (tr( "Redo" )); insilmaril@16: a->setShortcut (Qt::CTRL + Qt::Key_Y ); insilmaril@16: tb->addAction (a); insilmaril@16: editMenu->addAction (a); insilmaril@16: connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) ); insilmaril@16: actionEditRedo=a; insilmaril@2: insilmaril@5: editMenu->addSeparator(); insilmaril@2: a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy" ), this); insilmaril@2: a->setStatusTip ( tr( "Copy" ) ); insilmaril@2: a->setShortcut (Qt::CTRL + Qt::Key_C ); insilmaril@0: a->setEnabled (false); insilmaril@5: tb->addAction (a); insilmaril@5: editMenu->addAction (a); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) ); insilmaril@0: actionEditCopy=a; insilmaril@2: insilmaril@2: a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t" ), this); insilmaril@2: a->setStatusTip ( tr( "Cut" ) ); insilmaril@2: a->setShortcut (Qt::CTRL + Qt::Key_X ); insilmaril@0: a->setEnabled (false); insilmaril@5: tb->addAction (a); insilmaril@5: editMenu->addAction (a); insilmaril@0: actionEditCut=a; insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) ); insilmaril@2: insilmaril@2: a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste" ),this); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) ); insilmaril@2: a->setStatusTip ( tr( "Paste" ) ); insilmaril@2: a->setShortcut ( Qt::CTRL + Qt::Key_V ); insilmaril@0: a->setEnabled (false); insilmaril@5: tb->addAction (a); insilmaril@5: editMenu->addAction (a); insilmaril@0: actionEditPaste=a; insilmaril@2: insilmaril@5: // Shortcuts to modify heading: insilmaril@5: a = new QAction(tr( "Edit heading" ),this); insilmaril@5: a->setStatusTip ( tr( "edit Heading" )); insilmaril@5: a->setShortcut ( Qt::Key_Enter); insilmaril@16: // a->setShortcutContext (Qt::WindowShortcut); insilmaril@6: addAction (a); insilmaril@5: connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) ); insilmaril@5: actionListBranches.append(a); insilmaril@5: a = new QAction( tr( "Edit heading" ), this); insilmaril@5: a->setStatusTip (tr( "edit Heading" )); insilmaril@5: a->setShortcut (Qt::Key_Return ); insilmaril@16: //a->setShortcutContext (Qt::WindowShortcut); insilmaril@7: addAction (a); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) ); insilmaril@6: actionListBranches.append(a); insilmaril@5: editMenu->addAction (a); insilmaril@5: actionEditHeading=a; insilmaril@6: a = new QAction( tr( "Edit heading" ), this); insilmaril@5: a->setStatusTip (tr( "edit Heading" )); insilmaril@5: a->setShortcut ( Qt::Key_F2 ); insilmaril@7: a->setShortcutContext (Qt::WindowShortcut); insilmaril@6: addAction (a); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) ); insilmaril@5: actionListBranches.append(a); insilmaril@5: insilmaril@5: // Shortcut to delete selection insilmaril@5: a = new QAction( tr( "Delete Selection" ),this); insilmaril@5: a->setStatusTip (tr( "Delete Selection" )); insilmaril@5: a->setShortcut ( Qt::Key_Delete); insilmaril@7: a->setShortcutContext (Qt::WindowShortcut); insilmaril@7: addAction (a); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) ); insilmaril@5: actionEditDelete=a; insilmaril@5: insilmaril@5: // Shortcut to add branch insilmaril@5: alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child" ), this); insilmaril@5: alt->setStatusTip ( tr( "Add a branch as child of selection" )); insilmaril@5: alt->setShortcut (Qt::Key_A); insilmaril@7: alt->setShortcutContext (Qt::WindowShortcut); insilmaril@7: addAction (alt); insilmaril@13: connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) ); insilmaril@5: a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child" ), this); insilmaril@5: a->setStatusTip ( tr( "Add a branch as child of selection" )); insilmaril@5: a->setShortcut (Qt::Key_Insert); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) ); insilmaril@5: actionListBranches.append(a); insilmaril@5: #if defined (Q_OS_MACX) insilmaril@5: // In OSX show different shortcut in menues, the keys work indepently always insilmaril@5: actionEditAddBranch=alt; insilmaril@5: #else insilmaril@5: actionEditAddBranch=a; insilmaril@5: #endif insilmaril@5: editMenu->addAction (actionEditAddBranch); insilmaril@5: tb->addAction (actionEditAddBranch); insilmaril@5: insilmaril@5: insilmaril@5: // Add branch by inserting it at selection insilmaril@5: a = new QAction(tr( "Add branch (insert)" ), this); insilmaril@5: a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" )); insilmaril@5: a->setShortcut (Qt::ALT + Qt::Key_Insert ); insilmaril@7: a->setShortcutContext (Qt::WindowShortcut); insilmaril@7: addAction (a); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchHere() ) ); insilmaril@5: a->setEnabled (false); insilmaril@5: actionListBranches.append(a); insilmaril@5: actionEditAddBranchHere=a; insilmaril@5: a = new QAction(tr( "Add branch (insert)" ),this); insilmaril@5: a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" )); insilmaril@5: a->setShortcut ( Qt::ALT + Qt::Key_A ); insilmaril@7: a->setShortcutContext (Qt::WindowShortcut); insilmaril@7: addAction (a); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchHere() ) ); insilmaril@5: actionListBranches.append(a); insilmaril@5: insilmaril@5: // Add branch above insilmaril@5: a = new QAction(tr( "Add branch above" ), this); insilmaril@5: a->setStatusTip ( tr( "Add a branch above selection" )); insilmaril@5: a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); insilmaril@7: a->setShortcutContext (Qt::WindowShortcut); insilmaril@7: addAction (a); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) ); insilmaril@5: a->setEnabled (false); insilmaril@5: actionListBranches.append(a); insilmaril@5: actionEditAddBranchAbove=a; insilmaril@5: a = new QAction(tr( "Add branch above" ), this); insilmaril@5: a->setStatusTip ( tr( "Add a branch above selection" )); insilmaril@5: a->setShortcut (Qt::SHIFT+Qt::Key_A ); insilmaril@7: a->setShortcutContext (Qt::WindowShortcut); insilmaril@7: addAction (a); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) ); insilmaril@5: actionListBranches.append(a); insilmaril@5: insilmaril@5: // Add branch below insilmaril@5: a = new QAction(tr( "Add branch below" ), this); insilmaril@5: a->setStatusTip ( tr( "Add a branch below selection" )); insilmaril@5: a->setShortcut (Qt::CTRL +Qt::Key_Insert ); insilmaril@7: a->setShortcutContext (Qt::WindowShortcut); insilmaril@7: addAction (a); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) ); insilmaril@5: a->setEnabled (false); insilmaril@5: actionListBranches.append(a); insilmaril@5: actionEditAddBranchBelow=a; insilmaril@5: a = new QAction(tr( "Add branch below" ), this); insilmaril@5: a->setStatusTip ( tr( "Add a branch below selection" )); insilmaril@5: a->setShortcut (Qt::CTRL +Qt::Key_A ); insilmaril@7: a->setShortcutContext (Qt::WindowShortcut); insilmaril@7: addAction (a); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) ); insilmaril@5: actionListBranches.append(a); insilmaril@5: insilmaril@2: a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up" ), this); insilmaril@2: a->setStatusTip ( tr( "Move branch up" ) ); insilmaril@2: a->setShortcut (Qt::Key_PageUp ); insilmaril@0: a->setEnabled (false); insilmaril@5: tb->addAction (a); insilmaril@5: editMenu->addAction (a); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) ); insilmaril@0: actionEditMoveUp=a; insilmaril@2: insilmaril@2: a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down" ),this); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) ); insilmaril@2: a->setStatusTip (tr( "Move branch down" ) ); insilmaril@2: a->setShortcut ( Qt::Key_PageDown ); insilmaril@0: a->setEnabled (false); insilmaril@5: tb->addAction (a); insilmaril@5: editMenu->addAction (a); insilmaril@0: actionEditMoveDown=a; insilmaril@2: insilmaril@0: insilmaril@2: a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ),this); insilmaril@2: a->setShortcut ( Qt::Key_ScrollLock ); insilmaril@2: a->setStatusTip (tr( "Scroll branch" ) ); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) ); insilmaril@2: alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ), this); insilmaril@2: alt->setShortcut ( Qt::Key_S ); insilmaril@2: alt->setStatusTip (tr( "Scroll branch" )); insilmaril@13: connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) ); insilmaril@2: #if defined(Q_OS_MACX) insilmaril@2: actionEditToggleScroll=alt; insilmaril@2: #else insilmaril@2: actionEditToggleScroll=a; insilmaril@2: #endif insilmaril@2: actionEditToggleScroll->setEnabled (false); insilmaril@2: actionEditToggleScroll->setToggleAction(true); insilmaril@5: tb->addAction (actionEditToggleScroll); insilmaril@5: editMenu->addAction ( actionEditToggleScroll); insilmaril@5: editMenu->addAction (actionEditToggleScroll); insilmaril@2: actionListBranches.append(actionEditToggleScroll); insilmaril@2: insilmaril@2: a = new QAction( tr( "Unscroll all scrolled branches" ), this); insilmaril@2: a->setStatusTip (tr( "Unscroll all" )); insilmaril@5: editMenu->addAction (a); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( editUnScrollAll() ) ); insilmaril@0: insilmaril@5: editMenu->addSeparator(); insilmaril@0: insilmaril@2: a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find"+QString("...") ), this); insilmaril@2: a->setStatusTip (tr( "Find" ) ); insilmaril@2: a->setShortcut (Qt::CTRL + Qt::Key_F ); insilmaril@5: editMenu->addAction (a); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) ); insilmaril@0: insilmaril@5: editMenu->addSeparator(); insilmaril@0: insilmaril@2: a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL" ), this); insilmaril@2: a->setShortcut (Qt::CTRL + Qt::Key_U ); insilmaril@2: a->setShortcut (tr( "Open URL" )); insilmaril@5: tb->addAction (a); insilmaril@10: addAction(a); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) ); insilmaril@0: actionEditOpenURL=a; insilmaril@0: insilmaril@2: a = new QAction( tr( "Open URL in new tab" ), this); insilmaril@2: a->setStatusTip (tr( "Open URL in new tab" )); insilmaril@2: a->setShortcut (Qt::CTRL+Qt::Key_U ); insilmaril@10: addAction(a); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) ); insilmaril@2: actionEditOpenURLTab=a; insilmaril@2: insilmaril@16: a = new QAction( tr( "Open all URLs in subtree" ), this); insilmaril@16: a->setStatusTip (tr( "Open all URLs in subtree" )); insilmaril@16: addAction(a); insilmaril@17: actionListBranches.append(a); insilmaril@16: connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) ); insilmaril@16: actionEditOpenMultipleURLTabs=a; insilmaril@16: insilmaril@2: a = new QAction(QPixmap(), tr( "Edit URL"+QString("...") ), this); insilmaril@2: a->setStatusTip ( tr( "Edit URL" ) ); insilmaril@10: a->setShortcut (Qt::SHIFT + Qt::CTRL + Qt::Key_U ); insilmaril@10: //a->setShortcut ( Qt::Key_U ); insilmaril@8: a->setShortcutContext (Qt::WindowShortcut); insilmaril@2: actionListBranches.append(a); insilmaril@10: addAction(a); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) ); insilmaril@0: actionEditURL=a; insilmaril@0: insilmaril@2: a = new QAction( tr( "Use heading for URL" ), this); insilmaril@2: a->setStatusTip ( tr( "Use heading of selected branch as URL" )); insilmaril@2: a->setEnabled (false); insilmaril@2: actionListBranches.append(a); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) ); insilmaril@0: actionEditHeading2URL=a; insilmaril@0: insilmaril@2: a = new QAction(tr( "Create URL to Bugzilla" ), this); insilmaril@2: a->setStatusTip ( tr( "Create URL to Bugzilla" )); insilmaril@2: a->setEnabled (false); insilmaril@2: actionListBranches.append(a); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) ); insilmaril@0: actionEditBugzilla2URL=a; insilmaril@0: insilmaril@2: a = new QAction(tr( "Create URL to FATE" ), this); insilmaril@2: a->setStatusTip ( tr( "Create URL to FATE" )); insilmaril@2: a->setEnabled (false); insilmaril@2: actionListBranches.append(a); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) ); insilmaril@2: actionEditFATE2URL=a; insilmaril@0: insilmaril@17: a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open xlinked map" ), this); insilmaril@2: a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" )); insilmaril@5: tb->addAction (a); insilmaril@0: a->setEnabled (false); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) ); insilmaril@0: actionEditOpenVymLink=a; insilmaril@0: insilmaril@17: a = new QAction(QPixmap(), tr( "Open all vym links in subtree" ), this); insilmaril@17: a->setStatusTip ( tr( "Open all vym links in subtree" )); insilmaril@17: a->setEnabled (false); insilmaril@17: actionListBranches.append(a); insilmaril@17: connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) ); insilmaril@17: actionEditOpenMultipleVymLinks=a; insilmaril@17: insilmaril@17: insilmaril@2: a = new QAction(tr( "Edit vym link"+QString("...") ), this); insilmaril@2: a->setEnabled (false); insilmaril@2: a->setStatusTip ( tr( "Edit link to another vym map" )); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) ); insilmaril@2: actionListBranches.append(a); insilmaril@0: actionEditVymLink=a; insilmaril@0: insilmaril@2: a = new QAction(tr( "Delete vym link" ),this); insilmaril@2: a->setStatusTip ( tr( "Delete link to another vym map" )); insilmaril@2: a->setEnabled (false); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) ); insilmaril@0: actionEditDeleteVymLink=a; insilmaril@0: insilmaril@2: a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports" ), this); insilmaril@2: a->setStatusTip ( tr( "Hide object in exports" ) ); insilmaril@2: a->setShortcut (Qt::Key_H ); insilmaril@2: a->setToggleAction(true); insilmaril@5: tb->addAction (a); insilmaril@2: a->setEnabled (false); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) ); insilmaril@2: actionEditToggleHideExport=a; insilmaril@0: insilmaril@2: a = new QAction(tr( "Edit Map Info"+QString("...") ),this); insilmaril@2: a->setStatusTip ( tr( "Edit Map Info" )); insilmaril@2: a->setEnabled (true); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) ); insilmaril@0: actionEditMapInfo=a; insilmaril@0: insilmaril@5: editMenu->addSeparator(); insilmaril@0: insilmaril@0: // Import at selection (adding to selection) insilmaril@2: a = new QAction( tr( "Add map (insert)" ),this); insilmaril@2: a->setStatusTip (tr( "Add map at selection" )); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) ); insilmaril@0: a->setEnabled (false); insilmaril@2: actionListBranches.append(a); insilmaril@0: actionEditImportAdd=a; insilmaril@0: insilmaril@0: // Import at selection (replacing selection) insilmaril@2: a = new QAction( tr( "Add map (replace)" ), this); insilmaril@2: a->setStatusTip (tr( "Replace selection with map" )); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) ); insilmaril@0: a->setEnabled (false); insilmaril@2: actionListBranches.append(a); insilmaril@0: actionEditImportReplace=a; insilmaril@0: insilmaril@0: // Save selection insilmaril@2: a = new QAction( tr( "Save selection" ), this); insilmaril@2: a->setStatusTip (tr( "Save selection" )); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) ); insilmaril@0: a->setEnabled (false); insilmaril@2: actionListBranches.append(a); insilmaril@0: actionEditSaveBranch=a; insilmaril@0: insilmaril@2: // Only remove branch, not its childs insilmaril@2: a = new QAction(tr( "Remove only branch " ), this); insilmaril@2: a->setStatusTip ( tr( "Remove only branch and keep its childs" )); insilmaril@2: a->setShortcut (Qt::ALT + Qt::Key_Delete ); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( editRemoveBranchKeepChilds() ) ); insilmaril@2: a->setEnabled (false); insilmaril@2: actionListBranches.append(a); insilmaril@2: actionEditRemoveBranchKeepChilds=a; insilmaril@2: insilmaril@2: // Only remove childs of a branch insilmaril@2: a = new QAction( tr( "Remove childs" ), this); insilmaril@2: a->setStatusTip (tr( "Remove childs of branch" )); insilmaril@2: a->setShortcut (Qt::SHIFT + Qt::Key_Delete ); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( editRemoveChilds() ) ); insilmaril@2: a->setEnabled (false); insilmaril@2: actionListBranches.append(a); insilmaril@2: actionEditRemoveChilds=a; insilmaril@2: insilmaril@0: // Shortcuts for navigating with cursor: insilmaril@2: a = new QAction(tr( "Select upper branch" ), this); insilmaril@2: a->setStatusTip ( tr( "Select upper branch" )); insilmaril@2: a->setShortcut (Qt::Key_Up ); insilmaril@7: a->setShortcutContext (Qt::WindowShortcut); insilmaril@7: addAction (a); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) ); insilmaril@2: a = new QAction( tr( "Select lower branch" ),this); insilmaril@2: a->setStatusTip (tr( "Select lower branch" )); insilmaril@2: a->setShortcut ( Qt::Key_Down ); insilmaril@7: a->setShortcutContext (Qt::WindowShortcut); insilmaril@7: addAction (a); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) ); insilmaril@2: a = new QAction(tr( "Select left branch" ), this); insilmaril@2: a->setStatusTip ( tr( "Select left branch" )); insilmaril@2: a->setShortcut (Qt::Key_Left ); insilmaril@7: a->setShortcutContext (Qt::WindowShortcut); insilmaril@7: addAction (a); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) ); insilmaril@2: a = new QAction( tr( "Select child branch" ), this); insilmaril@2: a->setStatusTip (tr( "Select right branch" )); insilmaril@2: a->setShortcut (Qt::Key_Right); insilmaril@7: a->setShortcutContext (Qt::WindowShortcut); insilmaril@7: addAction (a); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) ); insilmaril@2: a = new QAction( tr( "Select first branch" ), this); insilmaril@2: a->setStatusTip (tr( "Select first branch" )); insilmaril@2: a->setShortcut (Qt::Key_Home ); insilmaril@7: a->setShortcutContext (Qt::WindowShortcut); insilmaril@7: addAction (a); insilmaril@0: a->setEnabled (false); insilmaril@5: editMenu->addAction (a); insilmaril@2: actionListBranches.append(a); insilmaril@0: actionEditSelectFirst=a; insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) ); insilmaril@2: a = new QAction( tr( "Select last branch" ),this); insilmaril@2: a->setStatusTip (tr( "Select last branch" )); insilmaril@2: a->setShortcut ( Qt::Key_End ); insilmaril@7: a->setShortcutContext (Qt::WindowShortcut); insilmaril@7: addAction (a); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) ); insilmaril@0: a->setEnabled (false); insilmaril@5: editMenu->addAction (a); insilmaril@2: actionListBranches.append(a); insilmaril@0: actionEditSelectLast=a; insilmaril@0: insilmaril@2: a = new QAction( tr( "Add Image" )+QString("..."), this); insilmaril@2: a->setStatusTip (tr( "Add Image" )); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) ); insilmaril@0: actionEditLoadImage=a; insilmaril@2: insilmaril@0: } insilmaril@0: insilmaril@0: // Format Actions insilmaril@0: void Main::setupFormatActions() insilmaril@0: { insilmaril@5: QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat")); insilmaril@0: insilmaril@3: QToolBar *tb = addToolBar( tr("Format Actions","Toolbars")); insilmaril@18: tb->setObjectName ("formatTB"); insilmaril@0: QAction *a; insilmaril@0: QPixmap pix( 16,16); insilmaril@2: pix.fill (Qt::black); insilmaril@2: a= new QAction(pix, tr( "Set &Color" )+QString("..."), this); insilmaril@2: a->setStatusTip ( tr( "Set Color" )); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) ); insilmaril@2: a->addTo( tb ); insilmaril@5: formatMenu->addAction (a); insilmaril@2: actionFormatColor=a; insilmaril@2: a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color" ), this); insilmaril@2: a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) ); insilmaril@2: a->setShortcut (Qt::CTRL + Qt::Key_K ); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) ); insilmaril@0: a->setEnabled (false); insilmaril@0: a->addTo( tb ); insilmaril@5: formatMenu->addAction (a); insilmaril@2: actionListBranches.append(a); insilmaril@0: actionFormatPickColor=a; insilmaril@2: insilmaril@2: a= new QAction(QPixmap(iconPath+"formatcoloritem.png"), tr( "Color &branch" ), this); insilmaril@2: a->setStatusTip ( tr( "Color branch" ) ); insilmaril@2: a->setShortcut (Qt::CTRL + Qt::Key_I); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( formatColorItem() ) ); insilmaril@0: a->setEnabled (false); insilmaril@0: a->addTo( tb ); insilmaril@5: formatMenu->addAction (a); insilmaril@2: actionListBranches.append(a); insilmaril@0: actionFormatColorBranch=a; insilmaril@2: insilmaril@2: a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color sub&tree" ), this); insilmaril@2: a->setStatusTip ( tr( "Color Subtree" )); insilmaril@2: a->setShortcut (Qt::CTRL + Qt::Key_T); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) ); insilmaril@0: a->setEnabled (false); insilmaril@5: formatMenu->addAction (a); insilmaril@0: a->addTo( tb ); insilmaril@2: actionListBranches.append(a); insilmaril@0: actionFormatColorSubtree=a; insilmaril@0: insilmaril@5: formatMenu->addSeparator(); insilmaril@3: actionGroupFormatLinkStyles=new QActionGroup ( this); insilmaril@0: actionGroupFormatLinkStyles->setExclusive (true); insilmaril@2: a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles); insilmaril@2: a->setStatusTip (tr( "Line" )); insilmaril@0: a->setToggleAction(true); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) ); insilmaril@5: formatMenu->addAction (a); insilmaril@0: actionFormatLinkStyleLine=a; insilmaril@2: a= new QAction( tr( "Linkstyle Parabel" ), actionGroupFormatLinkStyles); insilmaril@2: a->setStatusTip (tr( "Line" )); insilmaril@0: a->setToggleAction(true); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) ); insilmaril@5: formatMenu->addAction (a); insilmaril@0: actionFormatLinkStyleParabel=a; insilmaril@2: a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles ); insilmaril@2: a->setStatusTip (tr( "PolyLine" )); insilmaril@0: a->setToggleAction(true); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) ); insilmaril@5: formatMenu->addAction (a); insilmaril@0: actionFormatLinkStylePolyLine=a; insilmaril@2: a= new QAction( tr( "Linkstyle Thick Parabel" ), actionGroupFormatLinkStyles); insilmaril@2: a->setStatusTip (tr( "PolyParabel" ) ); insilmaril@0: a->setToggleAction(true); insilmaril@5: a->setChecked (true); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) ); insilmaril@5: formatMenu->addAction (a); insilmaril@0: actionFormatLinkStylePolyParabel=a; insilmaril@0: insilmaril@3: actionGroupFormatFrameTypes=new QActionGroup ( this); insilmaril@0: actionGroupFormatFrameTypes->setExclusive (true); insilmaril@2: a = new QAction( tr( "No Frame" ), actionGroupFormatFrameTypes ); insilmaril@2: a->setStatusTip (tr("No Frame")); insilmaril@0: a->setToggleAction(true); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameNone() ) ); insilmaril@0: actionFormatFrameNone=a; insilmaril@2: a = new QAction( tr( "Rectangle" ), actionGroupFormatFrameTypes); insilmaril@2: a->setStatusTip (tr( "Rectangle" )); insilmaril@0: a->setToggleAction(true); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameRectangle() ) ); insilmaril@0: actionFormatFrameRectangle=a; insilmaril@0: insilmaril@2: a = new QAction( tr( "Include images vertically" ), actionFormatIncludeImagesVer); insilmaril@2: a->setStatusTip ( tr ("Include top and bottom position of images into branch")); insilmaril@2: a->setToggleAction(true); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesVer() ) ); insilmaril@2: actionFormatIncludeImagesVer=a; insilmaril@2: insilmaril@2: a = new QAction( tr( "Include images horizontally" ), actionFormatIncludeImagesHor ); insilmaril@2: a->setStatusTip ( tr ("Include left and right position of images into branch")); insilmaril@2: a->setToggleAction(true); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesHor() ) ); insilmaril@2: actionFormatIncludeImagesHor=a; insilmaril@2: insilmaril@2: a = new QAction( tr( "Hide link if object is not selected" ), actionFormatHideLinkUnselected); insilmaril@2: a->setStatusTip (tr( "Hide link" )); insilmaril@2: a->setToggleAction(true); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) ); insilmaril@2: actionFormatHideLinkUnselected=a; insilmaril@2: insilmaril@5: formatMenu->addSeparator(); insilmaril@2: a= new QAction( tr( "&Use color of heading for link" ), this); insilmaril@2: a->setStatusTip (tr( "Use same color for links and headings" )); insilmaril@0: a->setToggleAction(true); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) ); insilmaril@5: formatMenu->addAction (a); insilmaril@0: actionFormatLinkColorHint=a; insilmaril@2: insilmaril@2: pix.fill (Qt::white); insilmaril@2: a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this ); insilmaril@2: a->setStatusTip (tr( "Set Link Color" )); insilmaril@5: formatMenu->addAction (a); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) ); insilmaril@2: actionFormatLinkColor=a; insilmaril@2: insilmaril@2: a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this ); insilmaril@2: a->setStatusTip (tr( "Set Background Color" )); insilmaril@5: formatMenu->addAction (a); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) ); insilmaril@2: actionFormatBackColor=a; insilmaril@0: } insilmaril@0: insilmaril@0: // View Actions insilmaril@0: void Main::setupViewActions() insilmaril@0: { insilmaril@3: QToolBar *tb = addToolBar( tr("View Actions","Toolbars") ); insilmaril@0: tb->setLabel( "View Actions" ); insilmaril@18: tb->setObjectName ("viewTB"); insilmaril@5: QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" )); insilmaril@0: insilmaril@0: QAction *a; insilmaril@2: a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom" ), this); insilmaril@2: a->setStatusTip ( tr( "Zoom reset" ) ); insilmaril@2: a->setShortcut (Qt::CTRL + Qt::Key_0 ); insilmaril@0: a->addTo( tb ); insilmaril@5: viewMenu->addAction (a); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) ); insilmaril@2: insilmaril@2: a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in" ), this); insilmaril@2: a->setStatusTip (tr( "Zoom in" )); insilmaril@2: a->setShortcut (Qt::CTRL + Qt::Key_Plus); insilmaril@0: a->addTo( tb ); insilmaril@5: viewMenu->addAction (a); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) ); insilmaril@2: insilmaril@2: a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out" ), this); insilmaril@2: a->setStatusTip (tr( "Zoom out" )); insilmaril@2: a->setShortcut (Qt::CTRL + Qt::Key_Minus ); insilmaril@0: a->addTo( tb ); insilmaril@5: viewMenu->addAction (a); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) ); insilmaril@2: insilmaril@2: insilmaril@2: a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor" ),this); insilmaril@2: a->setStatusTip ( tr( "Show Note Editor" )); insilmaril@2: a->setShortcut ( Qt::CTRL + Qt::Key_E ); 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@5: viewMenu->addAction (a); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) ); insilmaril@0: actionViewToggleNoteEditor=a; insilmaril@2: insilmaril@2: a = new QAction( tr( "Show history window" ),this ); insilmaril@2: a->setStatusTip ( tr( "Show history window" )); insilmaril@2: a->setShortcut ( Qt::CTRL + Qt::Key_H ); insilmaril@2: a->setToggleAction(false); insilmaril@5: viewMenu->addAction (a); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) ); insilmaril@2: actionViewToggleHistoryWindow=a; insilmaril@2: insilmaril@2: a = new QAction(tr( "Next Window" ), this); insilmaril@2: a->setStatusTip ( tr( "&Next Window" ) ); insilmaril@2: a->setShortcut (Qt::ALT + Qt::Key_N ); insilmaril@5: viewMenu->addAction (a); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) ); insilmaril@2: insilmaril@2: a = new QAction (tr( "Previous Window" ), this ); insilmaril@2: a->setStatusTip (tr( "&Previous Window" )); insilmaril@2: a->setShortcut (Qt::ALT + Qt::Key_P ); insilmaril@5: viewMenu->addAction (a); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) ); insilmaril@2: } insilmaril@2: insilmaril@2: // Mode Actions insilmaril@2: void Main::setupModeActions() insilmaril@2: { insilmaril@2: //QPopupMenu *menu = new QPopupMenu( this ); insilmaril@2: //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu ); insilmaril@2: insilmaril@3: QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Toolbars") ); insilmaril@18: tb->setObjectName ("modesTB"); insilmaril@2: QAction *a; insilmaril@3: actionGroupModModes=new QActionGroup ( this); insilmaril@2: actionGroupModModes->setExclusive (true); insilmaril@2: a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches" ), actionGroupModModes); insilmaril@2: a->setShortcut (Qt::Key_J); insilmaril@2: a->setStatusTip ( tr( "Use modifier to color branches" )); insilmaril@2: a->setToggleAction(true); insilmaril@2: a->addTo (tb); insilmaril@2: a->setOn(true); insilmaril@2: actionModModeColor=a; insilmaril@2: insilmaril@2: a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy" ), actionGroupModModes ); insilmaril@2: a->setShortcut( Qt::Key_K); insilmaril@2: a->setStatusTip( tr( "Use modifier to copy" )); insilmaril@2: a->setToggleAction(true); insilmaril@2: a->addTo (tb); insilmaril@2: actionModModeCopy=a; insilmaril@2: insilmaril@2: a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks" ), actionGroupModModes ); insilmaril@2: a->setShortcut (Qt::Key_L); insilmaril@2: a->setStatusTip( tr( "Use modifier to draw xLinks" )); insilmaril@2: a->setToggleAction(true); insilmaril@2: a->addTo (tb); insilmaril@2: actionModModeLink=a; insilmaril@0: } insilmaril@0: insilmaril@0: // Flag Actions insilmaril@0: void Main::setupFlagActions() insilmaril@0: { insilmaril@2: // Create System Flags insilmaril@2: systemFlagsDefault = new FlagRowObj (); insilmaril@2: systemFlagsDefault->setVisibility (false); insilmaril@2: systemFlagsDefault->setName ("systemFlagsDef"); insilmaril@2: insilmaril@2: FlagObj *fo = new FlagObj (); insilmaril@2: fo->load(QPixmap(flagsPath+"flag-note.png")); insilmaril@2: fo->setName("note"); insilmaril@2: fo->setToolTip(tr("Note","Systemflag")); insilmaril@2: systemFlagsDefault->addFlag (fo); // makes deep copy insilmaril@2: insilmaril@2: fo->load(QPixmap(flagsPath+"flag-url.png")); insilmaril@2: fo->setName("url"); insilmaril@2: fo->setToolTip(tr("WWW Document (external)","Systemflag")); insilmaril@2: systemFlagsDefault->addFlag (fo); insilmaril@2: insilmaril@2: fo->load(QPixmap(flagsPath+"flag-vymlink.png")); insilmaril@2: fo->setName("vymLink"); insilmaril@2: fo->setToolTip(tr("Link to another vym map","Systemflag")); insilmaril@2: systemFlagsDefault->addFlag (fo); insilmaril@2: insilmaril@2: fo->load(QPixmap(flagsPath+"flag-scrolled-right.png")); insilmaril@2: fo->setName("scrolledright"); insilmaril@2: fo->setToolTip(tr("subtree is scrolled","Systemflag")); insilmaril@2: systemFlagsDefault->addFlag (fo); insilmaril@2: insilmaril@2: fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png")); insilmaril@2: fo->setName("tmpUnscrolledright"); insilmaril@2: fo->setToolTip(tr("subtree is temporary scrolled","Systemflag")); insilmaril@2: systemFlagsDefault->addFlag (fo); insilmaril@2: insilmaril@2: fo->load(QPixmap(flagsPath+"flag-hideexport.png")); insilmaril@2: fo->setName("hideInExport"); insilmaril@2: fo->setToolTip(tr("Hide object in exported maps","Systemflag")); insilmaril@2: systemFlagsDefault->addFlag (fo); insilmaril@2: insilmaril@2: // Create Standard Flags insilmaril@3: QToolBar *tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar")); insilmaril@18: tb->setObjectName ("standardFlagTB"); insilmaril@3: insilmaril@2: standardFlagsDefault = new FlagRowObj (); insilmaril@2: standardFlagsDefault->setVisibility (false); insilmaril@2: standardFlagsDefault->setName ("standardFlagsDef"); insilmaril@3: standardFlagsDefault->setToolBar (tb); insilmaril@2: insilmaril@2: fo->load(QPixmap(flagsPath+"flag-exclamationmark.png")); insilmaril@2: fo->setName ("exclamationmark"); insilmaril@2: fo->setGroup("standard-mark"); insilmaril@3: QAction *a=new QAction (fo->getPixmap(),fo->getName(),this); insilmaril@3: tb->addAction (a); insilmaril@3: fo->setAction (a); insilmaril@3: a->setCheckable(true); insilmaril@3: a->setObjectName(fo->getName()); insilmaril@3: a->setToolTip(tr("Take care!","Standardflag")); insilmaril@13: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@2: standardFlagsDefault->addFlag (fo); // makes deep copy insilmaril@2: insilmaril@2: fo->load(QPixmap(flagsPath+"flag-questionmark.png")); insilmaril@2: fo->setName("questionmark"); insilmaril@2: fo->setGroup("standard-mark"); insilmaril@3: a=new QAction (fo->getPixmap(),fo->getName(),this); insilmaril@3: tb->addAction (a); insilmaril@3: fo->setAction (a); insilmaril@3: a->setCheckable(true); insilmaril@3: a->setObjectName(fo->getName()); insilmaril@3: a->setToolTip(tr("Really?","Standardflag")); insilmaril@13: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@2: standardFlagsDefault->addFlag (fo); insilmaril@2: insilmaril@2: fo->load(QPixmap(flagsPath+"flag-hook-green.png")); insilmaril@2: fo->setName("hook-green"); insilmaril@2: fo->setGroup("standard-hook"); insilmaril@3: a=new QAction (fo->getPixmap(),fo->getName(),this); insilmaril@3: tb->addAction (a); insilmaril@3: fo->setAction (a); insilmaril@3: a->setCheckable(true); insilmaril@3: a->setObjectName(fo->getName()); insilmaril@3: a->setToolTip(tr("ok!","Standardflag")); insilmaril@13: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@2: standardFlagsDefault->addFlag (fo); insilmaril@2: insilmaril@2: fo->load(QPixmap(flagsPath+"flag-cross-red.png")); insilmaril@2: fo->setName("cross-red"); insilmaril@2: fo->setGroup("standard-hook"); insilmaril@3: a=new QAction (fo->getPixmap(),fo->getName(),this); insilmaril@3: tb->addAction (a); insilmaril@3: fo->setAction (a); insilmaril@3: a->setCheckable(true); insilmaril@3: a->setObjectName(fo->getName()); insilmaril@3: a->setToolTip(tr("Not ok!","Standardflag")); insilmaril@13: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@2: standardFlagsDefault->addFlag (fo); insilmaril@2: insilmaril@2: fo->load(QPixmap(flagsPath+"flag-stopsign.png")); insilmaril@2: fo->setName("stopsign"); insilmaril@3: a=new QAction (fo->getPixmap(),fo->getName(),this); insilmaril@3: tb->addAction (a); insilmaril@3: fo->setAction (a); insilmaril@3: a->setCheckable(true); insilmaril@3: a->setObjectName(fo->getName()); insilmaril@3: a->setToolTip(tr("This won't work!","Standardflag")); insilmaril@13: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@2: standardFlagsDefault->addFlag (fo); insilmaril@2: insilmaril@2: fo->load(QPixmap(flagsPath+"flag-smiley-good.png")); insilmaril@2: fo->setName("smiley-good"); insilmaril@2: fo->setGroup("standard-smiley"); insilmaril@3: a=new QAction (fo->getPixmap(),fo->getName(),this); insilmaril@3: tb->addAction (a); insilmaril@3: fo->setAction (a); insilmaril@3: a->setCheckable(true); insilmaril@3: a->setObjectName(fo->getName()); insilmaril@3: a->setToolTip(tr("Good","Standardflag")); insilmaril@13: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@2: standardFlagsDefault->addFlag (fo); insilmaril@2: insilmaril@2: fo->load(QPixmap(flagsPath+"flag-smiley-sad.png")); insilmaril@2: fo->setName("smiley-sad"); insilmaril@2: fo->setGroup("standard-smiley"); insilmaril@3: a=new QAction (fo->getPixmap(),fo->getName(),this); insilmaril@3: tb->addAction (a); insilmaril@3: fo->setAction (a); insilmaril@3: a->setCheckable(true); insilmaril@3: a->setObjectName(fo->getName()); insilmaril@3: a->setToolTip(tr("Bad","Standardflag")); insilmaril@13: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@2: standardFlagsDefault->addFlag (fo); insilmaril@2: insilmaril@2: fo->load(QPixmap(flagsPath+"flag-smiley-omg.png")); insilmaril@2: // Original omg.png (in KDE emoticons) insilmaril@2: fo->setName("smiley-omg"); insilmaril@2: fo->setGroup("standard-smiley"); insilmaril@3: a=new QAction (fo->getPixmap(),fo->getName(),this); insilmaril@3: tb->addAction (a); insilmaril@3: fo->setAction (a); insilmaril@3: a->setCheckable(true); insilmaril@3: a->setObjectName(fo->getName()); insilmaril@3: a->setToolTip(tr("Oh no!","Standardflag")); insilmaril@13: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@2: standardFlagsDefault->addFlag (fo); insilmaril@2: insilmaril@2: fo->load(QPixmap(flagsPath+"flag-kalarm.png")); insilmaril@2: fo->setName("clock"); insilmaril@3: a=new QAction (fo->getPixmap(),fo->getName(),this); insilmaril@3: tb->addAction (a); insilmaril@3: fo->setAction (a); insilmaril@3: a->setCheckable(true); insilmaril@3: a->setObjectName(fo->getName()); insilmaril@3: a->setToolTip(tr("Time critical","Standardflag")); insilmaril@13: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@2: standardFlagsDefault->addFlag (fo); insilmaril@2: insilmaril@2: fo->load(QPixmap(flagsPath+"flag-phone.png")); insilmaril@2: fo->setName("phone"); insilmaril@3: a=new QAction (fo->getPixmap(),fo->getName(),this); insilmaril@3: tb->addAction (a); insilmaril@3: fo->setAction (a); insilmaril@3: a->setCheckable(true); insilmaril@3: a->setObjectName(fo->getName()); insilmaril@3: a->setToolTip(tr("Call...","Standardflag")); insilmaril@13: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@2: standardFlagsDefault->addFlag (fo); insilmaril@2: insilmaril@2: fo->load(QPixmap(flagsPath+"flag-lamp.png")); insilmaril@2: fo->setName("lamp"); insilmaril@3: a=new QAction (fo->getPixmap(),fo->getName(),this); insilmaril@3: tb->addAction (a); insilmaril@3: fo->setAction (a); insilmaril@3: a->setCheckable(true); insilmaril@3: a->setObjectName(fo->getName()); insilmaril@3: a->setToolTip(tr("Idea!","Standardflag")); insilmaril@13: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@2: standardFlagsDefault->addFlag (fo); insilmaril@2: insilmaril@2: fo->load(QPixmap(flagsPath+"flag-arrow-up.png")); insilmaril@2: fo->setName("arrow-up"); insilmaril@2: fo->setGroup("standard-arrow"); insilmaril@3: a=new QAction (fo->getPixmap(),fo->getName(),this); insilmaril@3: tb->addAction (a); insilmaril@3: fo->setAction (a); insilmaril@3: a->setCheckable(true); insilmaril@3: a->setObjectName(fo->getName()); insilmaril@3: a->setToolTip(tr("Important","Standardflag")); insilmaril@13: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@2: standardFlagsDefault->addFlag (fo); insilmaril@2: insilmaril@2: fo->load(QPixmap(flagsPath+"flag-arrow-down.png")); insilmaril@2: fo->setName("arrow-down"); insilmaril@2: fo->setGroup("standard-arrow"); insilmaril@3: a=new QAction (fo->getPixmap(),fo->getName(),this); insilmaril@3: tb->addAction (a); insilmaril@3: fo->setAction (a); insilmaril@3: a->setCheckable(true); insilmaril@3: a->setObjectName(fo->getName()); insilmaril@3: a->setToolTip(tr("Unimportant","Standardflag")); insilmaril@13: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@2: standardFlagsDefault->addFlag (fo); insilmaril@2: insilmaril@2: fo->load(QPixmap(flagsPath+"flag-arrow-2up.png")); insilmaril@2: fo->setName("2arrow-up"); insilmaril@2: fo->setGroup("standard-arrow"); insilmaril@3: a=new QAction (fo->getPixmap(),fo->getName(),this); insilmaril@3: tb->addAction (a); insilmaril@3: fo->setAction (a); insilmaril@3: a->setCheckable(true); insilmaril@3: a->setObjectName(fo->getName()); insilmaril@3: a->setToolTip(tr("Very important!","Standardflag")); insilmaril@13: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@2: standardFlagsDefault->addFlag (fo); insilmaril@2: insilmaril@2: fo->load(QPixmap(flagsPath+"flag-arrow-2down.png")); insilmaril@2: fo->setName("2arrow-down"); insilmaril@2: fo->setGroup("standard-arrow"); insilmaril@3: a=new QAction (fo->getPixmap(),fo->getName(),this); insilmaril@3: tb->addAction (a); insilmaril@3: fo->setAction (a); insilmaril@3: a->setCheckable(true); insilmaril@3: a->setObjectName(fo->getName()); insilmaril@3: a->setToolTip(tr("Very unimportant!","Standardflag")); insilmaril@13: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@2: standardFlagsDefault->addFlag (fo); insilmaril@2: insilmaril@2: fo->load(QPixmap(flagsPath+"flag-thumb-up.png")); insilmaril@2: fo->setName("thumb-up"); insilmaril@2: fo->setGroup("standard-thumb"); insilmaril@3: a=new QAction (fo->getPixmap(),fo->getName(),this); insilmaril@3: tb->addAction (a); insilmaril@3: fo->setAction (a); insilmaril@3: a->setCheckable(true); insilmaril@3: a->setObjectName(fo->getName()); insilmaril@3: a->setToolTip(tr("I like this","Standardflag")); insilmaril@13: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@2: standardFlagsDefault->addFlag (fo); insilmaril@2: insilmaril@2: fo->load(QPixmap(flagsPath+"flag-thumb-down.png")); insilmaril@2: fo->setName("thumb-down"); insilmaril@2: fo->setGroup("standard-thumb"); insilmaril@3: a=new QAction (fo->getPixmap(),fo->getName(),this); insilmaril@3: tb->addAction (a); insilmaril@3: fo->setAction (a); insilmaril@3: a->setCheckable(true); insilmaril@3: a->setObjectName(fo->getName()); insilmaril@3: a->setToolTip(tr("I do not like this","Standardflag")); insilmaril@13: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@2: standardFlagsDefault->addFlag (fo); insilmaril@2: insilmaril@2: fo->load(QPixmap(flagsPath+"flag-rose.png")); insilmaril@2: fo->setName("rose"); insilmaril@3: a=new QAction (fo->getPixmap(),fo->getName(),this); insilmaril@3: tb->addAction (a); insilmaril@3: fo->setAction (a); insilmaril@3: a->setCheckable(true); insilmaril@3: a->setObjectName(fo->getName()); insilmaril@3: a->setToolTip(tr("Rose","Standardflag")); insilmaril@13: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@2: standardFlagsDefault->addFlag (fo); insilmaril@2: insilmaril@2: fo->load(QPixmap(flagsPath+"flag-heart.png")); insilmaril@2: fo->setName("heart"); insilmaril@3: a=new QAction (fo->getPixmap(),fo->getName(),this); insilmaril@3: tb->addAction (a); insilmaril@3: a->setCheckable(true); insilmaril@3: a->setObjectName(fo->getName()); insilmaril@3: a->setToolTip(tr("I just love... ","Standardflag")); insilmaril@13: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@2: standardFlagsDefault->addFlag (fo); insilmaril@2: insilmaril@2: fo->load(QPixmap(flagsPath+"flag-present.png")); insilmaril@2: fo->setName("present"); insilmaril@3: a=new QAction (fo->getPixmap(),fo->getName(),this); insilmaril@3: tb->addAction (a); insilmaril@3: fo->setAction (a); insilmaril@3: a->setCheckable(true); insilmaril@3: a->setObjectName(fo->getName()); insilmaril@3: a->setToolTip(tr("Surprise!","Standardflag")); insilmaril@13: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@2: standardFlagsDefault->addFlag (fo); insilmaril@2: insilmaril@2: fo->load(QPixmap(flagsPath+"flag-flash.png")); insilmaril@2: fo->setName("flash"); insilmaril@3: a=new QAction (fo->getPixmap(),fo->getName(),this); insilmaril@3: tb->addAction (a); insilmaril@3: fo->setAction (a); insilmaril@3: a->setCheckable(true); insilmaril@3: a->setObjectName(fo->getName()); insilmaril@3: a->setToolTip(tr("Dangerous","Standardflag")); insilmaril@13: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@2: standardFlagsDefault->addFlag (fo); insilmaril@2: insilmaril@2: fo->load(QPixmap(flagsPath+"flag-info.png")); insilmaril@2: // Original: xsldbg_output.png insilmaril@2: fo->setName("info"); insilmaril@3: a=new QAction (fo->getPixmap(),fo->getName(),this); insilmaril@3: tb->addAction (a); insilmaril@3: fo->setAction (a); insilmaril@3: a->setCheckable(true); insilmaril@3: a->setObjectName(fo->getName()); insilmaril@3: a->setToolTip(tr("Info","Standardflag")); insilmaril@13: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@2: standardFlagsDefault->addFlag (fo); insilmaril@2: insilmaril@2: fo->load(QPixmap(flagsPath+"flag-lifebelt.png")); insilmaril@2: // Original khelpcenter.png insilmaril@2: fo->setName("lifebelt"); insilmaril@3: a=new QAction (fo->getPixmap(),fo->getName(),this); insilmaril@3: tb->addAction (a); insilmaril@3: fo->setAction (a); insilmaril@3: a->setCheckable(true); insilmaril@3: a->setObjectName(fo->getName()); insilmaril@3: a->setToolTip(tr("This will help","Standardflag")); insilmaril@13: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@2: standardFlagsDefault->addFlag (fo); insilmaril@2: insilmaril@2: delete (fo); insilmaril@0: } insilmaril@0: insilmaril@0: // Settings Actions insilmaril@0: void Main::setupSettingsActions() insilmaril@0: { insilmaril@5: QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" )); insilmaril@0: insilmaril@0: QAction *a; insilmaril@0: insilmaril@2: a = new QAction( tr( "Set application to open pdf files"), this); insilmaril@2: a->setStatusTip ( tr( "Set application to open pdf files")); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) ); insilmaril@5: settingsMenu->addAction (a); insilmaril@0: insilmaril@2: a = new QAction( tr( "Set application to open external links"), this); insilmaril@2: a->setStatusTip( tr( "Set application to open external links")); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) ); insilmaril@5: settingsMenu->addAction (a); insilmaril@5: insilmaril@5: settingsMenu->addSeparator(); insilmaril@2: a = new QAction( tr( "Edit branch after adding it" ), this ); insilmaril@2: a->setStatusTip( tr( "Edit branch after adding it" )); insilmaril@0: a->setToggleAction(true); insilmaril@17: a->setOn ( settings.value ("/mapeditor/editmode/autoEdit",true).toBool()); insilmaril@5: settingsMenu->addAction (a); insilmaril@0: actionSettingsAutoedit=a; insilmaril@0: insilmaril@2: a= new QAction( tr( "Select branch after adding it" ), this ); insilmaril@2: a->setStatusTip( tr( "Select branch after adding it" )); insilmaril@0: a->setToggleAction(true); insilmaril@17: a->setOn ( settings.value ("/mapeditor/editmode/autoSelectHeading",false).toBool() ); insilmaril@5: settingsMenu->addAction (a); insilmaril@0: actionSettingsAutoselectHeading=a; insilmaril@0: insilmaril@2: a= new QAction(tr( "Select existing heading" ), this); insilmaril@2: a->setStatusTip( tr( "Select heading before editing" )); insilmaril@0: a->setToggleAction(true); insilmaril@17: a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() ); insilmaril@5: settingsMenu->addAction (a); insilmaril@0: actionSettingsAutoselectText=a; insilmaril@0: insilmaril@2: a= new QAction( tr( "Delete key" ), this); insilmaril@2: a->setStatusTip( tr( "Delete key for deleting branches" )); insilmaril@0: a->setToggleAction(true); insilmaril@13: a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",false).toBool() ); insilmaril@5: settingsMenu->addAction (a); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) ); insilmaril@0: actionSettingsUseDelKey=a; insilmaril@2: insilmaril@2: a= new QAction( tr( "Exclusive flags" ), this); insilmaril@2: a->setStatusTip( tr( "Use exclusive flags in flag toolbars" )); insilmaril@2: a->setToggleAction(true); insilmaril@13: a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() ); insilmaril@5: settingsMenu->addAction (a); insilmaril@2: actionSettingsUseFlagGroups=a; insilmaril@2: insilmaril@2: a= new QAction( tr( "Use hide flags" ), this); insilmaril@2: a->setStatusTip( tr( "Use hide flag during exports " )); insilmaril@2: a->setToggleAction(true); insilmaril@13: a->setOn ( settings.value ("/export/useHideExport",true).toBool() ); insilmaril@5: settingsMenu->addAction (a); insilmaril@2: actionSettingsUseHideExport=a; insilmaril@0: } insilmaril@0: insilmaril@0: // Test Actions insilmaril@0: void Main::setupTestActions() insilmaril@0: { insilmaril@5: QMenu *testMenu = menuBar()->addMenu( tr( "&Test" )); insilmaril@0: insilmaril@0: QAction *a; insilmaril@2: a = new QAction( tr( "test flag" ), this); insilmaril@2: a->setStatusTip( tr( "Call test function" )); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( testFunction() ) ); insilmaril@5: testMenu->addAction (a); insilmaril@0: } insilmaril@0: insilmaril@0: // Help Actions insilmaril@0: void Main::setupHelpActions() insilmaril@0: { insilmaril@5: QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help" )); insilmaril@0: insilmaril@0: QAction *a; insilmaril@2: a = new QAction( tr( "Open VYM Documentation (pdf) " ), this ); insilmaril@2: a->setStatusTip( tr( "Open VYM Documentation (pdf)" )); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) ); insilmaril@5: helpMenu->addAction (a); insilmaril@0: insilmaril@2: a = new QAction( tr( "About VYM" ), this); insilmaril@2: a->setStatusTip( tr( "About VYM")+" "__VYM); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) ); insilmaril@5: helpMenu->addAction (a); insilmaril@0: insilmaril@2: a = new QAction( tr( "About QT" ), this); insilmaril@2: a->setStatusTip( tr( "Information about QT toolkit" )); insilmaril@13: connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) ); insilmaril@5: helpMenu->addAction (a); 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@4: branchContextMenu =new QMenu (this); insilmaril@2: insilmaril@2: // Submenu "Add" insilmaril@4: branchAddContextMenu =branchContextMenu->addMenu (tr("Add")); insilmaril@4: branchAddContextMenu->addAction (actionEditPaste ); insilmaril@4: branchAddContextMenu->addAction ( actionEditAddBranch ); insilmaril@4: branchAddContextMenu->addAction ( actionEditAddBranchHere ); insilmaril@4: branchAddContextMenu->addAction ( actionEditAddBranchAbove); insilmaril@4: branchAddContextMenu->addAction ( actionEditAddBranchBelow ); insilmaril@4: branchAddContextMenu->addSeparator(); insilmaril@4: branchAddContextMenu->addAction ( actionEditLoadImage); insilmaril@4: branchAddContextMenu->addSeparator(); insilmaril@4: branchAddContextMenu->addAction ( actionEditImportAdd ); insilmaril@4: branchAddContextMenu->addAction ( actionEditImportReplace ); insilmaril@2: insilmaril@2: // Submenu "Remove" insilmaril@4: branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove")); insilmaril@4: branchRemoveContextMenu->addAction (actionEditCut); insilmaril@4: branchRemoveContextMenu->addAction ( actionEditDelete ); insilmaril@4: branchRemoveContextMenu->addAction ( actionEditRemoveBranchKeepChilds ); insilmaril@4: branchRemoveContextMenu->addAction ( actionEditRemoveChilds ); insilmaril@2: insilmaril@2: insilmaril@0: actionEditSaveBranch->addTo( branchContextMenu ); insilmaril@2: insilmaril@4: branchContextMenu->addSeparator(); insilmaril@5: branchContextMenu->addAction ( actionFormatFrameNone ); insilmaril@5: branchContextMenu->addAction ( actionFormatFrameRectangle); insilmaril@5: insilmaril@5: branchContextMenu->addSeparator(); insilmaril@5: branchContextMenu->addAction ( actionFormatIncludeImagesVer ); insilmaril@5: branchContextMenu->addAction ( actionFormatIncludeImagesHor ); insilmaril@5: branchContextMenu->addAction ( actionFormatHideLinkUnselected ); insilmaril@2: insilmaril@17: // Submenu for Links (URLs, vymLinks) insilmaril@17: branchLinksContextMenu =new QMenu (this); insilmaril@17: insilmaril@17: branchContextMenu->addSeparator(); insilmaril@17: branchLinksContextMenu=branchContextMenu->addMenu(tr("URLs and vymLinks")); insilmaril@17: branchLinksContextMenu->addAction ( actionEditOpenURL ); insilmaril@17: branchLinksContextMenu->addAction ( actionEditOpenURLTab ); insilmaril@17: branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs ); insilmaril@17: branchLinksContextMenu->addAction ( actionEditURL ); insilmaril@17: branchLinksContextMenu->addAction ( actionEditHeading2URL ); insilmaril@17: branchLinksContextMenu->addAction ( actionEditBugzilla2URL ); insilmaril@17: if (settings.value( "/mainwindow/showTestMenu",true).toBool() ) insilmaril@17: { insilmaril@17: branchLinksContextMenu->addAction ( actionEditFATE2URL ); insilmaril@17: } insilmaril@17: branchLinksContextMenu->addSeparator(); insilmaril@17: branchLinksContextMenu->addAction ( actionEditOpenVymLink ); insilmaril@17: branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks ); insilmaril@17: branchLinksContextMenu->addAction ( actionEditVymLink ); insilmaril@17: branchLinksContextMenu->addAction ( actionEditDeleteVymLink ); insilmaril@17: insilmaril@17: insilmaril@17: // Context Menu for XLinks in a branch menu insilmaril@2: // This will be populated "on demand" in MapEditor::updateActions insilmaril@5: branchContextMenu->addSeparator(); insilmaril@17: branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink")); insilmaril@17: branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink")); insilmaril@17: connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) ); insilmaril@17: connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) ); insilmaril@17: insilmaril@2: insilmaril@0: // Context menu for floatimage insilmaril@4: floatimageContextMenu =new QMenu (this); insilmaril@11: a= new QAction (tr ("Save image"),this); insilmaril@11: connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage())); insilmaril@11: floatimageContextMenu->addAction (a); insilmaril@2: insilmaril@4: floatimageContextMenu->addSeparator(); insilmaril@0: actionEditCopy->addTo( floatimageContextMenu ); insilmaril@0: actionEditCut->addTo( floatimageContextMenu ); insilmaril@0: insilmaril@4: floatimageContextMenu->addSeparator(); insilmaril@4: floatimageContextMenu->addAction ( actionFormatHideLinkUnselected ); insilmaril@4: insilmaril@0: insilmaril@0: // Context menu for canvas insilmaril@4: canvasContextMenu =new QMenu (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@13: int j=settings.readNumEntry( "/lastMaps/number",0); insilmaril@0: for (int i=1;i<=j;i++) insilmaril@0: { insilmaril@13: s=settings.value(QString("/lastMaps/map-%1").arg(i),"").toString(); insilmaril@0: if (!s.isEmpty() && j<=maxLastMaps) insilmaril@0: lastMaps.append(s); insilmaril@0: } insilmaril@0: setupLastMapsMenu(); insilmaril@7: connect( fileLastMapsMenu, SIGNAL( triggered(QAction *) ), this, SLOT( fileLoadLast(QAction*) ) ); 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@4: fileLastMapsMenu->clear(); insilmaril@0: for (it = lastMaps.begin(); it != lastMaps.end(); ++it ) insilmaril@4: fileLastMapsMenu->addAction (*it ); 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@2: 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@2: QMessageBox mb( __VYM, insilmaril@2: 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@2: Q3FileDialog fd(this,caption); insilmaril@2: fd.setMode (Q3FileDialog::DirectoryOnly); insilmaril@2: 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@2: Main *m = new Main(0, 0, Qt::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@2: MapEditor* medit = new MapEditor ( NULL,true); insilmaril@0: tabWidget->addTab (medit,fn); insilmaril@0: tabWidget->showPage(medit); insilmaril@0: medit->viewport()->setFocus(); insilmaril@2: // For the very first map we do not have flagrows yet... insilmaril@0: medit->select("mc:"); insilmaril@0: } insilmaril@0: insilmaril@2: ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode) insilmaril@0: { insilmaril@2: 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@2: QMessageBox mb( __VYM, insilmaril@2: 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@2: "Do you want to").arg(fn), insilmaril@0: QMessageBox::Warning, insilmaril@0: QMessageBox::Yes | QMessageBox::Default, insilmaril@0: QMessageBox::Cancel | QMessageBox::Escape, insilmaril@2: 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@2: 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@3: me= new MapEditor ( NULL,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@2: QMessageBox mb( __VYM, insilmaril@2: 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@2: 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@2: 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@2: 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@2: err=unzipDir (tmpMapDir,fn); insilmaril@2: if (err==nozip) insilmaril@0: { insilmaril@2: mapfile=fn; insilmaril@2: me->setZipped(false); insilmaril@0: } else insilmaril@0: { insilmaril@2: me->setZipped(true); insilmaril@2: insilmaril@2: // Look for mapname.xml insilmaril@2: mapfile= fn.left(fn.findRev(".",-1,true)); insilmaril@2: mapfile=mapfile.section( '/', -1 ); insilmaril@2: QFile file( tmpMapDir + "/" + mapfile + ".xml"); insilmaril@2: if (!file.exists() ) insilmaril@0: { insilmaril@2: // mapname.xml does not exist, well, insilmaril@2: // maybe some renamed the mapname.vym file... insilmaril@2: // Try to find any .xml in the toplevel insilmaril@2: // directory of the .vym file insilmaril@2: QStringList flist=QDir (tmpMapDir).entryList("*.xml"); insilmaril@2: if (flist.count()==1) insilmaril@0: { insilmaril@2: // Only one entry, take this one insilmaril@2: mapfile=tmpMapDir + "/"+flist.first(); insilmaril@0: } else insilmaril@2: { insilmaril@2: for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it ) insilmaril@2: *it=tmpMapDir + "/" + *it; insilmaril@2: // TODO Multiple entries, load all (but only the first one into this ME) insilmaril@2: //mainWindow->fileLoadFromTmp (flist); insilmaril@2: //returnCode=1; // Silently forget this attempt to load insilmaril@2: qWarning ("MainWindow::load (fn) multimap found..."); insilmaril@2: } insilmaril@0: insilmaril@2: if (flist.isEmpty() ) insilmaril@2: { insilmaril@2: QMessageBox::critical( 0, tr( "Critical Load Error" ), insilmaril@2: tr("Couldn't find a map (*.xml) in .vym archive.\n")); insilmaril@2: err=aborted; insilmaril@2: } insilmaril@2: } //file doesn't exist insilmaril@2: else insilmaril@2: mapfile=file.name(); insilmaril@0: } insilmaril@0: insilmaril@2: if (err!=aborted) insilmaril@2: { insilmaril@2: // Save existing filename in case we import insilmaril@2: QString fn_org=me->getFilePath(); insilmaril@0: insilmaril@2: // Finally load map into mapEditor insilmaril@2: me->setFilePath (mapfile,fn); insilmaril@2: err=me->load(mapfile,lmode); insilmaril@0: insilmaril@2: // Restore old (maybe empty) filepath, if this is an import insilmaril@2: if (lmode!=NewMap) insilmaril@2: me->setFilePath (fn_org); insilmaril@2: } insilmaril@2: insilmaril@2: // Finally check for errors and go home insilmaril@2: if (err==aborted) insilmaril@2: { insilmaril@2: if (lmode==NewMap) fileCloseMap(); insilmaril@2: statusBar()->message( "Could not load " + fn, statusbarTime ); insilmaril@2: } 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@2: if (fn.left(9)!="/tmp/vym-") insilmaril@2: { insilmaril@2: // Only append to lastMaps if not loaded from a tmpDir insilmaril@2: // e.g. imported bookmarks are in a tmpDir insilmaril@2: lastMaps.prepend(me->getFilePath() ); insilmaril@2: setupLastMapsMenu(); insilmaril@2: } insilmaril@0: actionFilePrint->setEnabled (true); insilmaril@0: } insilmaril@0: statusBar()->message( "Loaded " + fn, statusbarTime ); insilmaril@0: } insilmaril@0: insilmaril@2: // Delete tmpDir insilmaril@2: removeDir (QDir(tmpMapDir)); insilmaril@0: } insilmaril@2: return err; insilmaril@0: } insilmaril@0: insilmaril@0: insilmaril@0: void Main::fileLoad(const LoadMode &lmode) insilmaril@0: { insilmaril@2: Q3FileDialog *fd=new Q3FileDialog( this); insilmaril@11: fd->setDir (lastFileDir); insilmaril@2: fd->setMode (Q3FileDialog::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@2: QStringList flist = fd->selectedFiles(); insilmaril@2: QStringList::Iterator it = flist.begin(); insilmaril@2: while( it != flist.end() ) insilmaril@2: { insilmaril@2: fn = *it; insilmaril@2: fileLoad(*it, lmode); insilmaril@2: ++it; insilmaril@2: } insilmaril@0: } insilmaril@2: delete (fd); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::fileLoad() insilmaril@0: { insilmaril@0: fileLoad (NewMap); insilmaril@0: } insilmaril@0: insilmaril@7: void Main::fileLoadLast(QAction *a) insilmaril@0: { insilmaril@7: fileLoad(lastMaps.at(fileLastMapsMenu->actions().indexOf(a)) ,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@2: ErrorCode err=success; insilmaril@0: insilmaril@0: QString safeFilePath; insilmaril@0: insilmaril@0: bool saveZipped=currentMapEditor()->saveZipped(); insilmaril@0: insilmaril@2: MapEditor * me=currentMapEditor(); insilmaril@2: if (me) insilmaril@0: { insilmaril@2: 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@2: QMessageBox mb( __VYM, insilmaril@2: 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@2: "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@2: safeFilePath=me->getFilePath(); insilmaril@2: me->setFilePath (tmpMapDir+"/"+ insilmaril@2: me->getMapName()+ ".xml", insilmaril@0: safeFilePath); insilmaril@2: me->save (savemode); insilmaril@2: me->setFilePath (safeFilePath); insilmaril@0: insilmaril@2: zipDir (tmpMapDir,fn); insilmaril@0: } // save zipped insilmaril@0: else insilmaril@0: { insilmaril@0: // Save unzipped. insilmaril@2: safeFilePath=me->getFilePath(); insilmaril@2: me->setFilePath (fn, safeFilePath); insilmaril@2: me->save (savemode); insilmaril@2: 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@2: if (saveZipped && !tmpMapDir.isEmpty()) insilmaril@0: // Delete tmpDir insilmaril@2: removeDir (QDir(tmpMapDir)); insilmaril@0: insilmaril@0: if (err==success) insilmaril@2: { insilmaril@0: statusBar()->message( insilmaril@2: tr("Saved %1").arg(me->getFilePath()), insilmaril@0: statusbarTime ); insilmaril@2: lastMaps.prepend(me->getFilePath() ); insilmaril@2: setupLastMapsMenu(); insilmaril@2: } else insilmaril@0: statusBar()->message( insilmaril@2: 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@2: fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this ); insilmaril@0: else insilmaril@2: fn = Q3FileDialog::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@2: QMessageBox mb( __VYM, insilmaril@2: 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@2: 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@2: if (savemode==CompleteMap) insilmaril@2: tabWidget->setTabLabel (currentMapEditor(), insilmaril@2: 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@2: void Main::fileImportKDEBookmarks() insilmaril@2: { insilmaril@2: ImportKDEBookmarks im; insilmaril@2: im.transform(); insilmaril@2: if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() ) insilmaril@2: currentMapEditor()->setFilePath (""); insilmaril@2: } insilmaril@2: insilmaril@2: void Main::fileImportFirefoxBookmarks() insilmaril@2: { insilmaril@2: Q3FileDialog *fd=new Q3FileDialog( this); insilmaril@2: fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox"); insilmaril@2: fd->setMode (Q3FileDialog::ExistingFiles); insilmaril@2: fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)"); insilmaril@2: fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks")); insilmaril@2: fd->show(); insilmaril@2: insilmaril@2: if ( fd->exec() == QDialog::Accepted ) insilmaril@2: { insilmaril@2: ImportFirefoxBookmarks im; insilmaril@2: QStringList flist = fd->selectedFiles(); insilmaril@2: QStringList::Iterator it = flist.begin(); insilmaril@2: while( it != flist.end() ) insilmaril@2: { insilmaril@2: im.setFile (*it); insilmaril@2: if (im.transform() && insilmaril@2: success==fileLoad (im.getTransformedFile(),NewMap) && insilmaril@2: currentMapEditor() ) insilmaril@2: currentMapEditor()->setFilePath (""); insilmaril@2: ++it; insilmaril@2: } insilmaril@2: } insilmaril@2: delete (fd); insilmaril@2: } insilmaril@2: insilmaril@2: void Main::fileImportMM() insilmaril@2: { insilmaril@2: ImportMM im; insilmaril@2: insilmaril@2: Q3FileDialog *fd=new Q3FileDialog( this); insilmaril@11: fd->setDir (lastFileDir); insilmaril@2: fd->setMode (Q3FileDialog::ExistingFiles); insilmaril@2: fd->addFilter ("Mind Manager (*.mmap)"); insilmaril@2: fd->setCaption(tr("Import")+" "+"Mind Manager"); insilmaril@2: fd->show(); insilmaril@2: insilmaril@2: if ( fd->exec() == QDialog::Accepted ) insilmaril@2: { insilmaril@2: lastFileDir=fd->dirPath(); insilmaril@2: QStringList flist = fd->selectedFiles(); insilmaril@2: QStringList::Iterator it = flist.begin(); insilmaril@2: while( it != flist.end() ) insilmaril@2: { insilmaril@2: im.setFile (*it); insilmaril@2: if (im.transform() && insilmaril@2: success==fileLoad (im.getTransformedFile(),NewMap) && insilmaril@2: currentMapEditor() ) insilmaril@2: currentMapEditor()->setFilePath (""); insilmaril@2: insilmaril@2: ++it; insilmaril@2: } insilmaril@2: } insilmaril@2: delete (fd); insilmaril@2: insilmaril@2: } insilmaril@2: insilmaril@0: void Main::fileImportDir() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->importDir(); insilmaril@0: } insilmaril@0: 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@2: MapEditor *me=currentMapEditor(); insilmaril@0: QString dir; insilmaril@2: if (me) insilmaril@0: { insilmaril@0: ExportXHTMLDialog dia(this); insilmaril@2: dia.setFilePath (me->getFilePath() ); insilmaril@2: 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@2: me->exportXML (dia.getDir() ); insilmaril@2: dia.doExport(me->getMapName() ); insilmaril@0: if (dia.hasChanged()) insilmaril@2: me->setChanged(); insilmaril@0: } insilmaril@0: } insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@4: void Main::fileExportImage() insilmaril@0: { insilmaril@2: MapEditor *me=currentMapEditor(); insilmaril@2: if (me) insilmaril@0: { insilmaril@4: QStringList fl; insilmaril@4: QFileDialog *fd=new QFileDialog (this); insilmaril@4: fd->setCaption (tr("Export map as image")); insilmaril@4: fd->setFileMode(QFileDialog::AnyFile); insilmaril@4: fd->setFilters (imageIO.getFilters() ); insilmaril@4: fd->setDirectory (lastImageDir); insilmaril@4: if (fd->exec()) insilmaril@4: { insilmaril@4: fl=fd->selectedFiles(); insilmaril@4: qWarning ("Selected "+fl.first()+" filter: "+fd->selectedFilter()); insilmaril@4: me->exportImage (fl.first(), imageIO.getType (fd->selectedFilter() ) ); insilmaril@4: } insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@0: void Main::fileExportASCII() insilmaril@0: { insilmaril@2: MapEditor *me=currentMapEditor(); insilmaril@2: if (me) insilmaril@2: { insilmaril@2: ExportASCII ex; insilmaril@2: ex.setMapCenter(me->getMapCenter()); insilmaril@2: ex.addFilter ("TXT (*.txt)"); insilmaril@2: ex.setCaption(__VYM " -" +tr("Export as ASCII")+" "+tr("(still experimental)")); insilmaril@2: if (ex.execDialog() ) insilmaril@2: { insilmaril@2: me->setExportMode(true); insilmaril@2: ex.doExport(); insilmaril@2: me->setExportMode(false); insilmaril@2: } insilmaril@2: } insilmaril@2: } insilmaril@2: insilmaril@2: void Main::fileExportLaTeX() insilmaril@2: { insilmaril@2: MapEditor *me=currentMapEditor(); insilmaril@2: if (me) insilmaril@2: { insilmaril@2: ExportLaTeX ex; insilmaril@2: ex.setMapCenter(me->getMapCenter()); insilmaril@2: ex.addFilter ("Tex (*.tex)"); insilmaril@2: ex.setCaption(__VYM " -" +tr("Export as LaTeX")+" "+tr("(still experimental)")); insilmaril@2: if (ex.execDialog() ) insilmaril@2: { insilmaril@2: me->setExportMode(true); insilmaril@2: ex.doExport(); insilmaril@2: me->setExportMode(false); insilmaril@2: } insilmaril@2: } insilmaril@2: } insilmaril@2: insilmaril@2: void Main::fileExportKDEBookmarks() insilmaril@2: { insilmaril@2: ExportKDEBookmarks ex; insilmaril@2: MapEditor *me=currentMapEditor(); insilmaril@2: if (me) insilmaril@2: { insilmaril@2: ex.setMapCenter (me->getMapCenter() ); insilmaril@2: ex.doExport(); insilmaril@2: } insilmaril@2: } insilmaril@2: insilmaril@2: void Main::fileExportTaskjuggler() insilmaril@2: { insilmaril@2: ExportTaskjuggler ex; insilmaril@2: MapEditor *me=currentMapEditor(); insilmaril@2: if (me) insilmaril@2: { insilmaril@2: ex.setMapCenter (me->getMapCenter() ); insilmaril@2: ex.setCaption ( __VYM " - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)")); insilmaril@2: ex.addFilter ("Taskjuggler (*.tjp)"); insilmaril@2: if (ex.execDialog() ) insilmaril@2: { insilmaril@2: me->setExportMode(true); insilmaril@2: ex.doExport(); insilmaril@2: me->setExportMode(false); insilmaril@2: } insilmaril@2: } insilmaril@2: } insilmaril@2: insilmaril@2: void Main::fileExportOOPresentation() insilmaril@2: { insilmaril@2: ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to")+" Open Office"); insilmaril@9: // TODO add preview in dialog insilmaril@2: //ImagePreview *p =new ImagePreview (fd); insilmaril@2: //fd->setContentsPreviewEnabled( TRUE ); insilmaril@2: //fd->setContentsPreview( p, p ); insilmaril@2: //fd->setPreviewMode( QFileDialog::Contents ); insilmaril@2: fd->setCaption(__VYM " - " +tr("Export to")+" Open Office"); insilmaril@9: fd->setDir (QDir().current()); insilmaril@11: if (fd->foundConfig()) insilmaril@2: { insilmaril@11: fd->show(); insilmaril@11: insilmaril@11: if ( fd->exec() == QDialog::Accepted ) insilmaril@11: { insilmaril@11: QString fn=fd->selectedFile(); insilmaril@17: if (!fn.contains (".odp")) insilmaril@17: fn +=".odp"; insilmaril@17: insilmaril@11: //lastImageDir=fn.left(fn.findRev ("/")); insilmaril@11: if (currentMapEditor()) insilmaril@11: currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig()); insilmaril@11: } insilmaril@11: } else insilmaril@11: { insilmaril@11: QMessageBox::warning(0, insilmaril@11: tr("Warning"), insilmaril@11: tr("Couldn't find configuration for export to Open Office\n")); insilmaril@2: } insilmaril@0: } insilmaril@0: insilmaril@0: void Main::fileCloseMap() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: { insilmaril@0: if (currentMapEditor()->hasChanged()) insilmaril@0: { insilmaril@2: QMessageBox mb( __VYM, insilmaril@2: 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@2: 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@16: mb.setModal (true); insilmaril@0: mb.show(); 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@2: void Main::editRedo() insilmaril@0: { insilmaril@2: if (currentMapEditor()) insilmaril@2: 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: 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@2: 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@16: void Main::openTabs(QStringList urls) insilmaril@16: { insilmaril@16: if (!urls.isEmpty()) insilmaril@16: { insilmaril@16: bool success=true; insilmaril@16: QStringList args; insilmaril@16: QString browser=settings.value("/mainwindow/readerURL" ).toString(); insilmaril@16: QProcess *p; insilmaril@16: if (!procBrowser || procBrowser->state()!=QProcess::Running) insilmaril@16: { insilmaril@16: QString u=urls.takeFirst(); insilmaril@16: procBrowser = new QProcess( this ); insilmaril@16: args<start(browser,args); insilmaril@16: if ( !procBrowser->waitForStarted()) insilmaril@16: { insilmaril@16: // try to set path to browser insilmaril@16: QMessageBox::warning(0, insilmaril@16: tr("Warning"), insilmaril@16: tr("Couldn't find a viewer to open %1.\n").arg(u)+ insilmaril@16: tr("Please use Settings->")+tr("Set application to open an URL")); insilmaril@16: return; insilmaril@16: } insilmaril@16: sleep (3); insilmaril@16: } insilmaril@16: if (browser.contains("konqueror")) insilmaril@16: { insilmaril@16: for (int i=0; ipid())<< insilmaril@16: "konqueror-mainwindow#1"<< insilmaril@16: "newTab" << insilmaril@16: urls.at(i); insilmaril@16: p->start ("dcop",args); insilmaril@16: if ( !p->waitForStarted() ) success=false; insilmaril@16: } insilmaril@16: if (!success) insilmaril@16: QMessageBox::warning(0, insilmaril@16: tr("Warning"), insilmaril@16: tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror")); insilmaril@16: return; insilmaril@16: } else if (browser.contains ("firefox") || browser.contains ("mozilla") ) insilmaril@16: { insilmaril@16: for (int i=0; istart (browser,args); insilmaril@16: if ( !p->waitForStarted() ) success=false; insilmaril@16: } insilmaril@16: if (!success) insilmaril@16: QMessageBox::warning(0, insilmaril@16: tr("Warning"), insilmaril@16: tr("Couldn't start %1 to open a new tab").arg(browser)); insilmaril@16: return; insilmaril@16: } insilmaril@16: QMessageBox::warning(0, insilmaril@16: tr("Warning"), insilmaril@16: tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing.")); insilmaril@16: } insilmaril@16: } insilmaril@16: insilmaril@0: void Main::editOpenURL() insilmaril@0: { insilmaril@2: // Open new browser insilmaril@0: if (currentMapEditor()) insilmaril@2: { insilmaril@2: QString url=currentMapEditor()->getURL(); insilmaril@16: QStringList args; insilmaril@2: if (url=="") return; insilmaril@13: QString browser=settings.value("/mainwindow/readerURL" ).toString(); insilmaril@16: procBrowser = new QProcess( this ); insilmaril@16: args<start(browser,args); insilmaril@16: if ( !procBrowser->waitForStarted()) insilmaril@2: { insilmaril@2: // try to set path to browser insilmaril@2: QMessageBox::warning(0, insilmaril@2: tr("Warning"), insilmaril@2: tr("Couldn't find a viewer to open %1.\n").arg(url)+ insilmaril@2: tr("Please use Settings->")+tr("Set application to open an URL")); insilmaril@2: settingsURL() ; insilmaril@2: } insilmaril@2: } insilmaril@2: } insilmaril@2: void Main::editOpenURLTab() insilmaril@2: { insilmaril@2: if (currentMapEditor()) insilmaril@2: { insilmaril@16: QStringList urls; insilmaril@16: urls.append(currentMapEditor()->getURL()); insilmaril@16: openTabs (urls); insilmaril@2: } insilmaril@0: } insilmaril@16: void Main::editOpenMultipleURLTabs() insilmaril@16: { insilmaril@16: if (currentMapEditor()) insilmaril@16: { insilmaril@16: QStringList urls; insilmaril@17: urls=currentMapEditor()->getURLs(); insilmaril@16: openTabs (urls); insilmaril@16: } insilmaril@16: } insilmaril@16: 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@2: void Main::editFATE2URL() insilmaril@2: { insilmaril@2: if (currentMapEditor()) insilmaril@2: currentMapEditor()->editFATE2URL(); insilmaril@2: } insilmaril@2: insilmaril@16: void Main::editHeading() insilmaril@16: { insilmaril@16: if (lineedit->isVisible()) insilmaril@16: { insilmaril@16: if (currentMapEditor()) insilmaril@17: { insilmaril@17: MapEditor *me=currentMapEditor(); insilmaril@17: QString oldSel=me->getSelectString(); insilmaril@17: if (me->select (editSel)) insilmaril@17: me->setHeading(lineedit->text()); insilmaril@17: me->select (oldSel); insilmaril@17: } insilmaril@16: lineedit->releaseKeyboard(); insilmaril@16: lineedit->hide(); insilmaril@16: setFocus(); insilmaril@16: } else insilmaril@16: { insilmaril@16: if (currentMapEditor()) insilmaril@16: { insilmaril@16: bool ok; insilmaril@16: QPoint p; insilmaril@16: QString s=currentMapEditor()->getHeading(ok,p); insilmaril@16: insilmaril@16: if (ok) insilmaril@16: { insilmaril@16: #if defined(Q_OS_MACX) insilmaril@16: p = currentMapEditor()->mapToGlobal( currentMapEditor()->worldMatrix().map( p)); insilmaril@16: QDialog *d =new QDialog(NULL); insilmaril@16: QLineEdit *le=new QLineEdit (d); insilmaril@16: d->setWindowFlags (Qt::FramelessWindowHint); insilmaril@16: d->setGeometry(p.x(),p.y(),200,25); insilmaril@16: le->resize (d->size()); insilmaril@16: le->setText (s); insilmaril@16: le->selectAll(); insilmaril@16: connect (le, SIGNAL (returnPressed()), d, SLOT (accept())); insilmaril@16: d->activateWindow(); insilmaril@16: d->exec(); insilmaril@16: currentMapEditor()->setHeading (le->text()); insilmaril@16: #else insilmaril@16: p = currentMapEditor()->mapTo(this, currentMapEditor()->worldMatrix().map( p)); insilmaril@16: lineedit->setGeometry(p.x(),p.y(),200,25); insilmaril@16: lineedit->setText(s); insilmaril@16: lineedit->setCursorPosition(1); insilmaril@16: lineedit->selectAll(); insilmaril@16: lineedit->show(); insilmaril@16: lineedit->grabKeyboard(); insilmaril@16: lineedit->setFocus(); insilmaril@17: insilmaril@17: editSel=currentMapEditor()->getSelectString(); insilmaril@16: #endif insilmaril@16: insilmaril@16: } insilmaril@16: } insilmaril@16: } insilmaril@16: } insilmaril@16: insilmaril@17: void Main::openVymLinks(const QStringList &vl) insilmaril@0: { insilmaril@17: for (int j=0; jcount() -1;i++) insilmaril@0: { insilmaril@0: me=(MapEditor*)tabWidget->page(i); insilmaril@17: if (vl.at(j)==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@17: if (!QFile(vl.at(j)).exists() ) insilmaril@0: QMessageBox::critical( 0, tr( "Critical Error" ), insilmaril@17: tr("Couldn't open map %1").arg(vl.at(j))); insilmaril@0: else insilmaril@0: { insilmaril@17: fileLoad (vl.at(j), 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@17: void Main::editOpenVymLink() insilmaril@17: { insilmaril@17: if (currentMapEditor()) insilmaril@17: { insilmaril@17: QStringList vl; insilmaril@17: vl.append(currentMapEditor()->getVymLink()); insilmaril@17: openVymLinks (vl); insilmaril@17: } insilmaril@17: } insilmaril@17: insilmaril@17: void Main::editOpenMultipleVymLinks() insilmaril@17: { insilmaril@17: QString currentVymLink; insilmaril@17: if (currentMapEditor()) insilmaril@17: { insilmaril@17: QStringList vl=currentMapEditor()->getVymLinks(); insilmaril@17: openVymLinks (vl); insilmaril@17: } insilmaril@17: } insilmaril@17: 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@2: void Main::editToggleHideExport() insilmaril@2: { insilmaril@2: if (currentMapEditor()) insilmaril@2: currentMapEditor()->toggleHideExport(); insilmaril@2: } insilmaril@2: 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::editNewBranch() insilmaril@0: { insilmaril@16: insilmaril@16: if (!lineedit->isVisible() && currentMapEditor()) insilmaril@0: currentMapEditor()->addNewBranch(0); insilmaril@0: } insilmaril@0: insilmaril@2: void Main::editNewBranchHere() insilmaril@2: { insilmaril@2: if (currentMapEditor()) insilmaril@2: currentMapEditor()->addNewBranchHere(); insilmaril@2: } insilmaril@2: 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@2: void Main::editRemoveBranchKeepChilds() insilmaril@2: { insilmaril@2: if (currentMapEditor()) insilmaril@2: currentMapEditor()->removeBranchKeepChilds(); insilmaril@2: } insilmaril@2: insilmaril@2: void Main::editRemoveChilds() insilmaril@2: { insilmaril@2: if (currentMapEditor()) insilmaril@2: currentMapEditor()->removeChilds(); insilmaril@2: } insilmaril@2: insilmaril@0: void Main::editDeleteSelection() insilmaril@0: { insilmaril@2: 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@11: void Main::editSaveImage() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@11: currentMapEditor()->saveFloatImage(); insilmaril@0: } insilmaril@0: insilmaril@7: void Main::editFollowXLink(QAction *a) insilmaril@7: { insilmaril@7: insilmaril@7: if (currentMapEditor()) insilmaril@17: currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a)); insilmaril@7: } insilmaril@7: insilmaril@7: void Main::editEditXLink(QAction *a) insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@17: currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a)); insilmaril@0: } insilmaril@0: 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@2: void Main::formatIncludeImagesVer() insilmaril@2: { insilmaril@2: if (currentMapEditor()) insilmaril@2: currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn()); insilmaril@2: } insilmaril@2: insilmaril@2: void Main::formatIncludeImagesHor() insilmaril@2: { insilmaril@2: if (currentMapEditor()) insilmaril@2: currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn()); insilmaril@2: } insilmaril@2: insilmaril@2: void Main::formatHideLinkUnselected() insilmaril@2: { insilmaril@2: if (currentMapEditor()) insilmaril@2: currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn()); insilmaril@2: } insilmaril@2: insilmaril@0: void Main::viewZoomReset() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: { insilmaril@2: QMatrix 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@2: QMatrix 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@2: QMatrix 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@2: insilmaril@2: void Main::modModeColor() insilmaril@2: { insilmaril@2: } insilmaril@2: insilmaril@2: void Main::modModeLink() insilmaril@2: { insilmaril@2: } insilmaril@2: 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@2: "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal, insilmaril@13: settings.value("/mainwindow/readerPDF").toString(), &ok, this ); insilmaril@0: if (ok) insilmaril@13: settings.setValue ("/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@2: "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal, insilmaril@13: settings.value("/mainwindow/readerURL").toString() insilmaril@0: , &ok, this ); insilmaril@0: if (ok) insilmaril@13: settings.setValue ("/mainwindow/readerURL",text); insilmaril@0: return ok; insilmaril@0: } insilmaril@0: insilmaril@2: void Main::settingsToggleDelKey() insilmaril@2: { insilmaril@2: if (actionSettingsUseDelKey->isOn()) insilmaril@2: { insilmaril@2: actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete)); insilmaril@2: } else insilmaril@2: { insilmaril@2: actionEditDelete->setAccel (QKeySequence ("")); insilmaril@2: } insilmaril@2: } insilmaril@2: 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@2: void Main::windowToggleHistory() insilmaril@2: { insilmaril@2: if (currentMapEditor()) insilmaril@2: currentMapEditor()->toggleHistoryWindow(); insilmaril@2: } insilmaril@2: insilmaril@2: void Main::updateNoteFlag() insilmaril@2: { insilmaril@2: if (currentMapEditor()) insilmaril@2: currentMapEditor()->updateNoteFlag(); insilmaril@2: } insilmaril@2: 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@15: currentMapEditor()->testFunction(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::helpDoc() insilmaril@0: { insilmaril@0: QString docpath; insilmaril@2: #if defined(Q_OS_MACX) insilmaril@2: docpath="./vym.app/Contents/vym.pdf"; insilmaril@2: #else insilmaril@2: // default path in SUSE LINUX insilmaril@2: docpath="/usr/share/doc/packages/vym/doc/vym.pdf"; insilmaril@2: #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@2: // Try yet another one for Knoppix insilmaril@2: docpath="/usr/share/doc/packages/vym/vym.pdf"; insilmaril@2: if (!QFile (docpath).exists() ) insilmaril@2: { insilmaril@2: QMessageBox::critical(0, insilmaril@2: tr("Critcal error"), insilmaril@2: tr("Couldn't find the documentation\n" insilmaril@2: "vym.pdf in various places.")); insilmaril@2: return; insilmaril@2: } insilmaril@0: } insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@0: Process *pdfProc = new Process(); insilmaril@0: pdfProc->clearArguments(); insilmaril@13: pdfProc->addArgument( settings.value("/mainwindow/readerPDF").toString()); insilmaril@0: pdfProc->addArgument( docpath); insilmaril@0: insilmaril@0: if ( !pdfProc->start() ) insilmaril@0: { insilmaril@0: // error handling insilmaril@2: QMessageBox::warning(0, insilmaril@2: tr("Warning"), insilmaril@2: tr("Couldn't find a viewer to open %1.\n").arg("vym.pdf")+ insilmaril@2: tr("Please use Settings->")+tr("Set application to open PDF files")); insilmaril@2: settingsPDF(); insilmaril@0: return; insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@0: insilmaril@0: void Main::helpAbout() insilmaril@0: { insilmaril@2: AboutDialog ad; insilmaril@2: ad.setName ("aboutwindow"); insilmaril@2: ad.setMinimumSize(500,500); insilmaril@2: ad.resize (QSize (500,500)); insilmaril@2: 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: