insilmaril@3: #include insilmaril@3: insilmaril@0: #include "mainwindow.h" insilmaril@0: insilmaril@0: #include insilmaril@0: #include insilmaril@0: #include insilmaril@2: #include insilmaril@0: #include insilmaril@0: #include insilmaril@0: #include insilmaril@0: #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@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@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* actionSettingsPasteNewHeading; 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@4: extern QMenu* branchLinksContextMenu; insilmaril@4: extern QMenu* branchLinksContextMenuDup; insilmaril@4: extern QMenu* floatimageContextMenu; insilmaril@4: extern QMenu* saveImageFormatMenu; 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@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@0: resize (settings.readNumEntry( "/vym/mainwindow/geometry/width", 800), insilmaril@0: settings.readNumEntry( "/vym/mainwindow/geometry/height",600)); insilmaril@0: move (settings.readNumEntry( "/vym/mainwindow/geometry/posX", 100), insilmaril@0: settings.readNumEntry( "/vym/mainwindow/geometry/posY", 100)); insilmaril@0: insilmaril@0: insilmaril@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@0: p="/vym/mainwindow/readerURL"; insilmaril@0: #if defined(Q_OS_LINUX) insilmaril@0: s=settings.readEntry (p,"konqueror"); insilmaril@0: #else insilmaril@0: #if defined(Q_OS_MACX) insilmaril@2: s=settings.readEntry (p,"/usr/bin/open"); insilmaril@0: #else insilmaril@0: s=settings.readEntry (p,"mozilla"); insilmaril@0: #endif insilmaril@0: #endif insilmaril@0: settings.writeEntry( p,s); insilmaril@0: insilmaril@0: // application to open PDFs insilmaril@0: p="/vym/mainwindow/readerPDF"; insilmaril@0: #if defined(Q_OS_LINUX) insilmaril@0: s=settings.readEntry (p,"acroread"); insilmaril@0: #else insilmaril@0: #if defined(Q_OS_MACX) insilmaril@2: s=settings.readEntry (p,"/usr/bin/open"); insilmaril@0: #else insilmaril@0: s=settings.readEntry (p,"acroread"); insilmaril@0: #endif insilmaril@0: #endif insilmaril@0: settings.writeEntry( p,s); insilmaril@0: insilmaril@0: insilmaril@0: maxLastMaps=9; insilmaril@0: insilmaril@0: // Create tab widget which holds the maps insilmaril@0: tabWidget= new QTabWidget (this); insilmaril@0: connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ), insilmaril@0: this, SLOT( editorChanged( QWidget * ) ) ); insilmaril@0: insilmaril@0: setCentralWidget(tabWidget); insilmaril@0: insilmaril@0: setupFileActions(); insilmaril@0: setupEditActions(); insilmaril@0: setupFormatActions(); insilmaril@0: setupViewActions(); insilmaril@2: setupModeActions(); insilmaril@0: setupFlagActions(); insilmaril@0: setupSettingsActions(); insilmaril@0: setupContextMenus(); insilmaril@0: if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) setupTestActions(); insilmaril@0: setupHelpActions(); insilmaril@0: insilmaril@0: // After menu is created, we can enable some actions insilmaril@5: //FIXME QT3 testing actionFilePrint->setEnabled (true); insilmaril@0: insilmaril@0: statusBar(); insilmaril@0: insilmaril@0: insilmaril@0: // Initialize Find window insilmaril@0: findWindow=new FindWindow(NULL,"findwindow"); insilmaril@0: connect (findWindow, SIGNAL( findButton(QString) ), insilmaril@0: this, SLOT(editFind(QString) ) ); insilmaril@0: connect (findWindow, SIGNAL( somethingChanged() ), insilmaril@0: this, SLOT(editFindChanged() ) ); insilmaril@0: insilmaril@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@0: settings.writeEntry( "/vym/mainwindow/geometry/width", width() ); insilmaril@0: settings.writeEntry( "/vym/mainwindow/geometry/height", height() ); insilmaril@0: settings.writeEntry( "/vym/mainwindow/geometry/posX", pos().x() ); insilmaril@0: settings.writeEntry( "/vym/mainwindow/geometry/posY", pos().y() ); insilmaril@0: insilmaril@2: settings.writeEntry( "/vym/version/version", __VYM_VERSION ); insilmaril@2: settings.writeEntry( "/vym/version/builddate", __BUILD_DATE ); insilmaril@0: insilmaril@0: settings.writeEntry( "/vym/mapeditor/editmode/autoselectheading",actionSettingsAutoselectHeading->isOn() ); insilmaril@0: settings.writeEntry( "/vym/mapeditor/editmode/autoselecttext",actionSettingsAutoselectText->isOn() ); insilmaril@0: settings.writeEntry( "/vym/mapeditor/editmode/pastenewheading",actionSettingsPasteNewHeading->isOn() ); insilmaril@0: settings.writeEntry( "/vym/mapeditor/editmode/autoedit",actionSettingsAutoedit->isOn() ); insilmaril@0: settings.writeEntry( "/vym/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() ); insilmaril@2: settings.writeEntry( "/vym/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() ); insilmaril@2: settings.writeEntry( "/vym/export/useHideExport",actionSettingsUseHideExport->isOn() ); insilmaril@0: insilmaril@0: QString s; insilmaril@0: int maps=lastMaps.count(); insilmaril@0: settings.writeEntry( "/vym/lastMaps/number",maps ); insilmaril@0: for (int i=1;i<=maps;i++) insilmaril@0: { insilmaril@0: s=QString("/vym/lastMaps/map-%1").arg(i); insilmaril@0: if (!s.isEmpty() && i<=maxLastMaps) insilmaril@2: settings.writeEntry (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@4: QMenu *fileMenu = menuBar()->addMenu ( tr ("&File") ); insilmaril@3: QToolBar *tb = addToolBar( tr ("&File") ); 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@2: connect( a, SIGNAL( activated() ), 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@2: connect( a, SIGNAL( activated() ), 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@2: connect( a, SIGNAL( activated() ), 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@0: connect( a, SIGNAL( activated() ), 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@2: connect( a, SIGNAL( activated() ), this, SLOT( fileImportKDEBookmarks() ) ); insilmaril@2: insilmaril@2: if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) 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@2: connect( a, SIGNAL( activated() ), 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@2: connect( a, SIGNAL( activated() ), 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@0: connect( a, SIGNAL( activated() ), 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@4: connect( a, SIGNAL( activated() ), 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@4: connect( a, SIGNAL( activated() ), 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@4: connect( a, SIGNAL( activated() ), 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@4: connect( a, SIGNAL( activated() ), 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@4: connect( a, SIGNAL( activated() ), 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@4: connect( a, SIGNAL( activated() ), 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@4: connect( a, SIGNAL( activated() ), 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@4: connect( a, SIGNAL( activated() ), 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@2: connect( a, SIGNAL( activated() ), 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@0: connect( a, SIGNAL( activated() ), 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@0: connect( a, SIGNAL( activated() ), this, SLOT( fileExitVYM() ) ); insilmaril@0: } insilmaril@0: insilmaril@0: insilmaril@0: //Edit Actions insilmaril@0: void Main::setupEditActions() insilmaril@0: { insilmaril@3: QToolBar *tb = addToolBar( tr ("&Edit") ); insilmaril@0: tb->setLabel( "Edit Actions" ); 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@0: connect( a, SIGNAL( activated() ), 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@2: if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) insilmaril@2: { insilmaril@2: a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo" ), this); insilmaril@2: a->setStatusTip (tr( "Redo" )); insilmaril@2: a->setShortcut (Qt::CTRL + Qt::Key_Y ); insilmaril@5: editMenu->addAction (a); insilmaril@2: connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) ); insilmaril@2: } 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@2: connect( a, SIGNAL( activated() ), 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@2: connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); insilmaril@2: insilmaril@2: a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste" ),this); insilmaril@0: connect( a, SIGNAL( activated() ), 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: /* insilmaril@5: a = new QAction(tr( "Edit heading" ),this); insilmaril@5: a->setStatusTip ( tr( "edit Heading" )); insilmaril@5: a->setShortcut ( Qt::Key_Enter); insilmaril@5: connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) ); insilmaril@5: actionListBranches.append(a); insilmaril@5: */ insilmaril@5: a = new QAction( tr( "Edit heading" ), this); insilmaril@5: a->setStatusTip (tr( "edit Heading" )); insilmaril@5: a->setShortcut (Qt::Key_Return ); insilmaril@5: connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) ); insilmaril@5: //actionListBranches.append(a); insilmaril@5: editMenu->addAction (a); insilmaril@5: actionEditHeading=a; insilmaril@5: /* insilmaril@5: a = new QAction( tr( "Edit heading" ),this); insilmaril@5: a->setStatusTip (tr( "edit Heading" )); insilmaril@5: a->setShortcut ( Qt::Key_F2 ); insilmaril@5: connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) ); insilmaril@5: a->setEnabled (false); insilmaril@5: actionListBranches.append(a); insilmaril@5: */ 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@5: connect( a, SIGNAL( activated() ), this, SLOT( editDeleteSelection() ) ); insilmaril@5: a->setEnabled (false); 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@5: connect( alt, SIGNAL( activated() ), 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@5: // a->setEnabled (false); insilmaril@5: connect( a, SIGNAL( activated() ), 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@5: connect( a, SIGNAL( activated() ), 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@5: connect( a, SIGNAL( activated() ), 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@5: connect( a, SIGNAL( activated() ), 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@5: connect( a, SIGNAL( activated() ), 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@5: connect( a, SIGNAL( activated() ), 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@5: connect( a, SIGNAL( activated() ), 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@2: connect( a, SIGNAL( activated() ), this, SLOT( editMoveUp() ) ); insilmaril@0: actionEditMoveUp=a; insilmaril@2: insilmaril@2: a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down" ),this); insilmaril@0: connect( a, SIGNAL( activated() ), 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@0: connect( a, SIGNAL( activated() ), 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@2: connect( alt, SIGNAL( activated() ), 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@0: connect( a, SIGNAL( activated() ), 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@0: connect( a, SIGNAL( activated() ), 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@0: a->setEnabled (false); insilmaril@2: connect( a, SIGNAL( activated() ), 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@2: a->setEnabled (false); insilmaril@2: connect( a, SIGNAL( activated() ), this, SLOT( editOpenURLTab() ) ); insilmaril@2: actionEditOpenURLTab=a; insilmaril@2: insilmaril@2: a = new QAction(QPixmap(), tr( "Edit URL"+QString("...") ), this); insilmaril@2: a->setStatusTip ( tr( "Edit URL" ) ); insilmaril@2: a->setShortcut (Qt::SHIFT + Qt::CTRL+Qt::Key_U ); insilmaril@2: a->setEnabled (false); insilmaril@2: actionListBranches.append(a); insilmaril@0: connect( a, SIGNAL( activated() ), 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@0: connect( a, SIGNAL( activated() ), 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@0: connect( a, SIGNAL( activated() ), 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@2: connect( a, SIGNAL( activated() ), this, SLOT( editFATE2URL() ) ); insilmaril@2: actionEditFATE2URL=a; insilmaril@0: insilmaril@2: a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Jump to 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@2: connect( a, SIGNAL( activated() ), this, SLOT( editOpenVymLink() ) ); insilmaril@0: actionEditOpenVymLink=a; insilmaril@0: 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@0: connect( a, SIGNAL( activated() ), 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@0: connect( a, SIGNAL( activated() ), 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@2: connect( a, SIGNAL( activated() ), 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@0: connect( a, SIGNAL( activated() ), 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@0: connect( a, SIGNAL( activated() ), 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@0: connect( a, SIGNAL( activated() ), 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@0: connect( a, SIGNAL( activated() ), 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@2: connect( a, SIGNAL( activated() ), 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@2: connect( a, SIGNAL( activated() ), 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@0: connect( a, SIGNAL( activated() ), 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@0: connect( a, SIGNAL( activated() ), 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@0: connect( a, SIGNAL( activated() ), 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@0: connect( a, SIGNAL( activated() ), 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@0: a->setEnabled (false); insilmaril@5: editMenu->addAction (a); insilmaril@2: actionListBranches.append(a); insilmaril@0: actionEditSelectFirst=a; insilmaril@0: connect( a, SIGNAL( activated() ), 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@0: connect( a, SIGNAL( activated() ), 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@0: connect( a, SIGNAL( activated() ), 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@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@2: connect( a, SIGNAL( activated() ), 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@0: connect( a, SIGNAL( activated() ), 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@0: connect( a, SIGNAL( activated() ), 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@0: connect( a, SIGNAL( activated() ), 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@0: connect( a, SIGNAL( activated() ), 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@0: connect( a, SIGNAL( activated() ), 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@0: connect( a, SIGNAL( activated() ), 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@0: connect( a, SIGNAL( activated() ), 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@0: connect( a, SIGNAL( activated() ), 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@0: connect( a, SIGNAL( activated() ), 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@2: connect( a, SIGNAL( activated() ), 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@2: connect( a, SIGNAL( activated() ), 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@2: connect( a, SIGNAL( activated() ), 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@0: connect( a, SIGNAL( activated() ), 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@2: connect( a, SIGNAL( activated() ), 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@2: connect( a, SIGNAL( activated() ), 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@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@2: connect( a, SIGNAL( activated() ), 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@2: connect( a, SIGNAL( activated() ), 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@2: connect( a, SIGNAL( activated() ), 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@2: connect( a, SIGNAL( activated() ), 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@2: connect( a, SIGNAL( activated() ), 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@0: connect( a, SIGNAL( activated() ), 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@0: connect( a, SIGNAL( activated() ), 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@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@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@3: connect (a, SIGNAL( activated() ), 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@3: connect (a, SIGNAL( activated() ), 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@3: connect (a, SIGNAL( activated() ), 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@3: connect (a, SIGNAL( activated() ), 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@3: connect (a, SIGNAL( activated() ), 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@3: connect (a, SIGNAL( activated() ), 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@3: connect (a, SIGNAL( activated() ), 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@3: connect (a, SIGNAL( activated() ), 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@3: connect (a, SIGNAL( activated() ), 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@3: connect (a, SIGNAL( activated() ), 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@3: connect (a, SIGNAL( activated() ), 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@3: connect (a, SIGNAL( activated() ), 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@3: connect (a, SIGNAL( activated() ), 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@3: connect (a, SIGNAL( activated() ), 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@3: connect (a, SIGNAL( activated() ), 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@3: connect (a, SIGNAL( activated() ), 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@3: connect (a, SIGNAL( activated() ), 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@3: connect (a, SIGNAL( activated() ), 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@3: connect (a, SIGNAL( activated() ), 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@3: connect (a, SIGNAL( activated() ), 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@3: connect (a, SIGNAL( activated() ), 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@3: connect (a, SIGNAL( activated() ), 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@3: connect (a, SIGNAL( activated() ), 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@0: connect( a, SIGNAL( activated() ), 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@0: connect( a, SIGNAL( activated() ), 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@0: a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoedit",true) ); 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@0: a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselect",false) ); 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@0: a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselectexistingtext",true) ); insilmaril@5: settingsMenu->addAction (a); insilmaril@0: actionSettingsAutoselectText=a; insilmaril@0: insilmaril@2: a= new QAction(tr( "pasting into new branch" ), this ); insilmaril@2: a->setStatusTip( tr( "Pasting into new branch" )); insilmaril@0: a->setToggleAction(true); insilmaril@0: a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/newheadingisempty",true) ); insilmaril@5: settingsMenu->addAction (a); insilmaril@0: actionSettingsPasteNewHeading=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@0: a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useDelKey",false) ); insilmaril@5: settingsMenu->addAction (a); insilmaril@2: connect( a, SIGNAL( activated() ), 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@2: a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useFlagGroups",true) ); 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@2: a->setOn ( settings.readBoolEntry ("/vym/export/useHideExport",true) ); 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@0: connect( a, SIGNAL( activated() ), 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@0: connect( a, SIGNAL( activated() ), 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@0: connect( a, SIGNAL( activated() ), 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@0: connect( a, SIGNAL( activated() ), 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 ( actionEditLoadImage); 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 ( actionEditOpenURL ); insilmaril@5: branchContextMenu->addAction ( actionEditOpenURLTab ); insilmaril@5: branchContextMenu->addAction ( actionEditURL ); insilmaril@5: branchContextMenu->addAction ( actionEditHeading2URL ); insilmaril@5: branchContextMenu->addAction ( actionEditBugzilla2URL ); insilmaril@0: if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) insilmaril@2: { insilmaril@5: branchContextMenu->addAction ( actionEditFATE2URL ); insilmaril@2: } insilmaril@5: branchContextMenu->addSeparator(); insilmaril@5: branchContextMenu->addAction ( actionEditOpenVymLink ); insilmaril@5: branchContextMenu->addAction ( actionEditVymLink ); insilmaril@5: branchContextMenu->addAction ( actionEditDeleteVymLink ); insilmaril@2: insilmaril@5: 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@2: // Context Menu for links in a branch menu insilmaril@2: // This will be populated "on demand" in MapEditor::updateActions insilmaril@5: branchContextMenu->addSeparator(); insilmaril@5: /* FIXME not yet ported from QT3 insilmaril@2: branchLinksContextMenu =new Q3PopupMenu (this); insilmaril@2: branchLinksContextMenuDup =new Q3PopupMenu (this); insilmaril@2: branchContextMenu->insertItem (tr("Edit XLink"),branchLinksContextMenuDup); insilmaril@2: connect( branchLinksContextMenuDup, SIGNAL( activated(int) ), this, SLOT( editEditXLink(int ) ) ); insilmaril@2: insilmaril@2: branchContextMenu->insertItem (tr("Goto XLink"),branchLinksContextMenu); insilmaril@2: connect( branchLinksContextMenu, SIGNAL( activated(int) ), this, SLOT( editFollowXLink(int ) ) ); insilmaril@5: */ insilmaril@2: insilmaril@0: // Context menu for floatimage insilmaril@4: floatimageContextMenu =new QMenu (this); insilmaril@4: saveImageFormatMenu=floatimageContextMenu->addMenu (tr("Save image")); insilmaril@4: insilmaril@2: foreach (QByteArray format, QImageWriter::supportedImageFormats()) insilmaril@2: { insilmaril@2: QString text = tr("%1...").arg(QString(format).toUpper()); insilmaril@4: a= new QAction (text,this); insilmaril@4: saveImageFormatMenu->addAction ( a ); insilmaril@2: } insilmaril@2: insilmaril@2: /* FIXME not needed any longer insilmaril@2: Q3StrList fmt = QImageWriter::supportedImageFormats(); insilmaril@0: for (const char* f = fmt.first(); f; f = fmt.next()) insilmaril@0: { insilmaril@0: saveImageFormatMenu->insertItem( f ); insilmaril@0: exportImageFormatMenu->insertItem( f ); insilmaril@0: } insilmaril@2: */ insilmaril@4: // connect( saveImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( editSaveImage(int ) ) ); insilmaril@4: // connect( exportImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( fileExportImage(int ) ) ); insilmaril@0: 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@0: int j=settings.readNumEntry( "/vym/lastMaps/number",0); insilmaril@0: for (int i=1;i<=j;i++) insilmaril@0: { insilmaril@0: s=settings.readEntry(QString("/vym/lastMaps/map-%1").arg(i),""); insilmaril@0: if (!s.isEmpty() && j<=maxLastMaps) insilmaril@0: lastMaps.append(s); insilmaril@0: } insilmaril@0: setupLastMapsMenu(); insilmaril@4: // connect( lastMapsMenu, SIGNAL( activated(int) ), this, SLOT( fileLoadLast(int ) ) ); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::setupLastMapsMenu() insilmaril@0: { insilmaril@0: // Remove double entries insilmaril@0: QStringList::Iterator it=lastMaps.begin(); insilmaril@0: QStringList::Iterator jt; insilmaril@0: while (it!=lastMaps.end() ) insilmaril@0: { insilmaril@0: jt=it; insilmaril@0: ++jt; insilmaril@0: while (jt!=lastMaps.end() ) insilmaril@0: { insilmaril@0: if (*it == *jt) insilmaril@0: jt=lastMaps.remove(jt); insilmaril@0: else insilmaril@0: jt++; insilmaril@0: } insilmaril@0: it++; insilmaril@0: } insilmaril@0: insilmaril@0: // Limit length of list to maxLastMaps insilmaril@0: while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back(); insilmaril@0: insilmaril@0: // build Menu from lastMaps string list insilmaril@4: fileLastMapsMenu->clear(); insilmaril@4: /* FIXME add actions instead of strings in QT4 insilmaril@0: for (it = lastMaps.begin(); it != lastMaps.end(); ++it ) insilmaril@4: fileLastMapsMenu->addAction (*it ); insilmaril@4: */ insilmaril@0: insilmaril@0: } insilmaril@0: insilmaril@0: void Main::hideEvent (QHideEvent * ) insilmaril@0: { insilmaril@0: if (!textEditor->isMinimized() ) textEditor->hide(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::showEvent (QShowEvent * ) insilmaril@0: { insilmaril@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@0: if (!lastFileDir.isEmpty()) insilmaril@0: 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@0: void Main::fileLoadLast(int i) insilmaril@0: { insilmaril@4: fileLoad(QString(*lastMaps.at(fileLastMapsMenu->indexOf (i)) ),NewMap); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::fileSave(const SaveMode &savemode) insilmaril@0: { insilmaril@0: // tmp dir for zipping insilmaril@0: QString tmpMapDir; insilmaril@0: insilmaril@0: // Error codes insilmaril@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@2: if (!lastFileDir.isEmpty()) insilmaril@2: 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@2: // FIXME add extra info 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@2: //fd->setDir (lastImageDir); insilmaril@2: fd->show(); insilmaril@2: insilmaril@2: if ( fd->exec() == QDialog::Accepted ) insilmaril@2: { insilmaril@2: QString fn=fd->selectedFile(); insilmaril@2: //lastImageDir=fn.left(fn.findRev ("/")); insilmaril@2: if (currentMapEditor()) insilmaril@2: currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig()); 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@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@0: void Main::editOpenURL() insilmaril@0: { insilmaril@2: // Open new browser insilmaril@0: if (currentMapEditor()) insilmaril@2: { insilmaril@2: QString url=currentMapEditor()->getURL(); insilmaril@2: if (url=="") return; insilmaril@2: QString browser=settings.readEntry("/vym/mainwindow/readerURL" ); insilmaril@2: procBrowser = new Q3Process( this ); insilmaril@2: insilmaril@2: procBrowser->addArgument( browser); insilmaril@2: procBrowser->addArgument( url); insilmaril@2: insilmaril@2: if ( !procBrowser->start() ) 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@2: QString url=currentMapEditor()->getURL(); insilmaril@2: if (url=="") return; insilmaril@2: QString browser=settings.readEntry("/vym/mainwindow/readerURL" ); insilmaril@2: if (procBrowser && procBrowser->isRunning()) insilmaril@2: { insilmaril@2: if (browser.contains("konqueror")) insilmaril@2: { insilmaril@2: // Try to open new tab in existing konqueror started previously by vym insilmaril@2: Q3Process *p=new Q3Process (this); insilmaril@2: p->addArgument ("dcop"); insilmaril@2: p->addArgument (QString("konqueror-%1").arg(procBrowser->processIdentifier())); insilmaril@2: p->addArgument ("konqueror-mainwindow#1"); insilmaril@2: p->addArgument ("newTab"); insilmaril@2: p->addArgument (url); insilmaril@2: if ( !p->start() ) insilmaril@2: // try to set browser insilmaril@2: QMessageBox::warning(0, insilmaril@2: tr("Warning"), insilmaril@2: tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror")); insilmaril@2: return; insilmaril@2: } else if (browser.contains ("firefox") || browser.contains ("mozilla") ) insilmaril@2: { insilmaril@2: // Try to open new tab in firefox insilmaril@2: Q3Process *p=new Q3Process (this); insilmaril@2: p->addArgument (browser); insilmaril@2: p->addArgument ("-remote"); insilmaril@2: p->addArgument (QString("openurl(%1,new-tab)").arg(url)); insilmaril@2: if ( !p->start() ) insilmaril@2: // try to set browser insilmaril@2: QMessageBox::warning(0, insilmaril@2: tr("Warning"), insilmaril@2: tr("Couldn't start %1 to open a new tab").arg(browser)); insilmaril@2: return; insilmaril@2: } insilmaril@2: } insilmaril@2: // Open new browser insilmaril@2: editOpenURL(); insilmaril@2: } insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editURL() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->editURL(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editHeading2URL() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->editHeading2URL(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editBugzilla2URL() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->editBugzilla2URL(); insilmaril@0: } insilmaril@0: insilmaril@2: void Main::editFATE2URL() insilmaril@2: { insilmaril@2: if (currentMapEditor()) insilmaril@2: currentMapEditor()->editFATE2URL(); insilmaril@2: } insilmaril@2: insilmaril@0: void Main::editOpenVymLink() insilmaril@0: { insilmaril@0: // Get current path to map insilmaril@0: QString currentVymLink; insilmaril@0: if (currentMapEditor()) insilmaril@0: { insilmaril@0: currentVymLink=currentMapEditor()->getVymLink(); insilmaril@0: // compare path with already loaded maps insilmaril@0: int index=-1; insilmaril@0: int i; insilmaril@0: MapEditor *me; insilmaril@0: for (i=0;i<=tabWidget->count() -1;i++) insilmaril@0: { insilmaril@0: me=(MapEditor*)tabWidget->page(i); insilmaril@0: if (currentVymLink==me->getFilePath() ) insilmaril@0: { insilmaril@0: index=i; insilmaril@0: break; insilmaril@0: } insilmaril@0: } insilmaril@0: if (index<0) insilmaril@0: // Load map insilmaril@0: { insilmaril@0: if (!QFile(currentVymLink).exists() ) insilmaril@0: QMessageBox::critical( 0, tr( "Critical Error" ), insilmaril@2: tr("Couldn't open map %1").arg(currentVymLink)); insilmaril@0: else insilmaril@0: { insilmaril@0: fileLoad (currentVymLink, NewMap); insilmaril@0: tabWidget->setCurrentPage (tabWidget->count()-1); insilmaril@0: } insilmaril@0: } else insilmaril@0: // Go to tab containing the map insilmaril@0: tabWidget->setCurrentPage (index); insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editVymLink() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->editVymLink(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editDeleteVymLink() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->deleteVymLink(); insilmaril@0: } insilmaril@0: insilmaril@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::editHeading() insilmaril@0: { insilmaril@3: qWarning ("Main::editHeading called"); insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->editHeading(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editNewBranch() insilmaril@0: { insilmaril@3: //FIXME insilmaril@3: // tried to see if maybe currentMapEditor is not set, but insilmaril@3: // ME does not seem to send a key event anyway...:q insilmaril@3: //here i was last time... insilmaril@3: insilmaril@3: cout << "Main::editNewBranch\n"; insilmaril@0: if (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@0: void Main::editSaveImage(int item) insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->saveFloatImage(item); insilmaril@0: } insilmaril@0: insilmaril@2: void Main::editFollowXLink(int item) insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@2: currentMapEditor()->followXLink(branchLinksContextMenu->indexOf(item)); insilmaril@2: } insilmaril@2: insilmaril@2: void Main::editEditXLink(int item) insilmaril@2: { insilmaril@2: if (currentMapEditor()) insilmaril@2: currentMapEditor()->editXLink(branchLinksContextMenuDup->indexOf(item)); 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@0: settings.readEntry("/vym/mainwindow/readerPDF"), &ok, this ); insilmaril@0: if (ok) insilmaril@0: settings.writeEntry ("/vym/mainwindow/readerPDF",text); insilmaril@0: return ok; insilmaril@0: } insilmaril@0: insilmaril@0: insilmaril@0: bool Main::settingsURL() insilmaril@0: { insilmaril@0: // Default browser is set in constructor insilmaril@0: bool ok; insilmaril@0: QString text = QInputDialog::getText( insilmaril@2: "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal, insilmaril@0: settings.readEntry("/vym/mainwindow/readerURL") insilmaril@0: , &ok, this ); insilmaril@0: if (ok) insilmaril@0: settings.writeEntry ("/vym/mainwindow/readerURL",text); insilmaril@0: return ok; insilmaril@0: } insilmaril@0: insilmaril@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@0: 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@0: pdfProc->addArgument( settings.readEntry("/vym/mainwindow/readerPDF")); insilmaril@0: pdfProc->addArgument( docpath); insilmaril@0: insilmaril@0: if ( !pdfProc->start() ) insilmaril@0: { insilmaril@0: // error handling insilmaril@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: