insilmaril@0: #include "mainwindow.h" insilmaril@0: insilmaril@366: #include insilmaril@390: insilmaril@0: #include insilmaril@0: insilmaril@205: #include "aboutdialog.h" insilmaril@205: #include "exportoofiledialog.h" insilmaril@228: #include "exports.h" insilmaril@205: #include "exportxhtmldialog.h" insilmaril@205: #include "file.h" insilmaril@0: #include "flagrowobj.h" insilmaril@377: #include "historywindow.h" insilmaril@205: #include "imports.h" insilmaril@0: #include "mapeditor.h" insilmaril@205: #include "misc.h" insilmaril@205: #include "options.h" insilmaril@0: #include "process.h" insilmaril@0: #include "settings.h" insilmaril@205: #include "texteditor.h" insilmaril@0: insilmaril@0: extern TextEditor *textEditor; insilmaril@0: extern Main *mainWindow; insilmaril@164: extern QString tmpVymDir; insilmaril@166: extern QString clipboardDir; insilmaril@166: extern bool clipboardEmpty; insilmaril@0: extern int statusbarTime; insilmaril@0: extern FlagRowObj* standardFlagsDefault; insilmaril@166: extern FlagRowObj* systemFlagsDefault; insilmaril@404: extern QString vymName; insilmaril@404: extern QString vymVersion; insilmaril@404: extern QString vymBuildDate; insilmaril@0: insilmaril@390: QMenu* branchContextMenu; insilmaril@390: QMenu* branchAddContextMenu; insilmaril@390: QMenu* branchRemoveContextMenu; insilmaril@390: QMenu* branchLinksContextMenu; insilmaril@390: QMenu* branchXLinksContextMenuEdit; insilmaril@390: QMenu* branchXLinksContextMenuFollow; insilmaril@390: QMenu* floatimageContextMenu; insilmaril@390: QMenu* canvasContextMenu; insilmaril@390: QMenu* fileLastMapsMenu; insilmaril@390: QMenu* fileImportMenu; insilmaril@390: QMenu* fileExportMenu; insilmaril@0: insilmaril@0: insilmaril@0: extern Settings settings; insilmaril@0: extern Options options; insilmaril@366: extern ImageIO imageIO; insilmaril@366: insilmaril@269: extern QDir vymBaseDir; insilmaril@366: extern QDir lastImageDir; insilmaril@366: extern QDir lastFileDir; insilmaril@269: extern QString iconPath; insilmaril@269: extern QString flagsPath; insilmaril@0: insilmaril@366: Main::Main(QWidget* parent, const char* name, Qt::WFlags f) : insilmaril@0: QMainWindow(parent,name,f) insilmaril@0: { insilmaril@0: mainWindow=this; insilmaril@0: insilmaril@0: setCaption ("VYM - View Your Mind"); insilmaril@0: insilmaril@0: // Load window settings insilmaril@366: resize (settings.value( "/mainwindow/geometry/size",QSize (800,600)).toSize()); insilmaril@366: move (settings.value( "/mainwindow/geometry/pos", QPoint(300,100)).toPoint()); insilmaril@0: insilmaril@0: insilmaril@394: // Sometimes we may need to remember old selections insilmaril@394: prevSelection=""; insilmaril@394: insilmaril@395: // Default color insilmaril@395: currentColor=Qt::black; insilmaril@395: insilmaril@164: // Create unique temporary directory insilmaril@366: bool ok; insilmaril@366: tmpVymDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX"); insilmaril@366: if (!ok) insilmaril@366: { insilmaril@366: qWarning ("Mainwindow: Could not create temporary directory, failed to start vym"); insilmaril@366: exit (1); insilmaril@366: } insilmaril@164: insilmaril@166: // Create direcctory for clipboard insilmaril@166: clipboardDir=tmpVymDir+"/clipboard"; insilmaril@166: QDir d(clipboardDir); insilmaril@166: d.mkdir (clipboardDir,true); insilmaril@166: makeSubDirs (clipboardDir); insilmaril@166: clipboardEmpty=true; insilmaril@164: insilmaril@266: procBrowser=NULL; insilmaril@266: insilmaril@404: // Initialize history window; insilmaril@404: historyWindow=new HistoryWindow(); insilmaril@93: insilmaril@0: // Initialize some settings, which are platform dependant insilmaril@0: QString p,s; insilmaril@0: insilmaril@0: // application to open URLs insilmaril@366: p="/mainwindow/readerURL"; insilmaril@0: #if defined(Q_OS_LINUX) insilmaril@366: s=settings.value (p,"konqueror").toString(); insilmaril@0: #else insilmaril@0: #if defined(Q_OS_MACX) insilmaril@366: s=settings.value (p,"/usr/bin/open").toString(); insilmaril@0: #else insilmaril@366: s=settings.value (p,"mozilla"); insilmaril@0: #endif insilmaril@0: #endif insilmaril@366: settings.setValue( p,s); insilmaril@0: insilmaril@0: // application to open PDFs insilmaril@366: p="/mainwindow/readerPDF"; insilmaril@0: #if defined(Q_OS_LINUX) insilmaril@366: s=settings.value (p,"acroread").toString(); insilmaril@0: #else insilmaril@0: #if defined(Q_OS_MACX) insilmaril@366: s=settings.value (p,"/usr/bin/open").toString(); insilmaril@0: #else insilmaril@366: s=settings.value (p,"acroread").toString(); insilmaril@0: #endif insilmaril@0: #endif insilmaril@366: settings.setValue( p,s); insilmaril@0: 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@366: lineedit=new QLineEdit (this); insilmaril@366: lineedit->hide(); insilmaril@366: insilmaril@0: setCentralWidget(tabWidget); insilmaril@0: insilmaril@0: setupFileActions(); insilmaril@0: setupEditActions(); insilmaril@0: setupFormatActions(); insilmaril@0: setupViewActions(); insilmaril@89: setupModeActions(); insilmaril@0: setupFlagActions(); insilmaril@0: setupSettingsActions(); insilmaril@0: setupContextMenus(); insilmaril@366: if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions(); insilmaril@0: setupHelpActions(); insilmaril@0: insilmaril@0: statusBar(); insilmaril@0: insilmaril@366: restoreState (settings.value("/mainwindow/state",0).toByteArray()); insilmaril@0: insilmaril@0: // Initialize Find window insilmaril@374: findWindow=new FindWindow(NULL); insilmaril@374: findWindow->move (x(),y()+70); insilmaril@0: connect (findWindow, SIGNAL( findButton(QString) ), insilmaril@0: this, SLOT(editFind(QString) ) ); insilmaril@0: connect (findWindow, SIGNAL( somethingChanged() ), insilmaril@0: this, SLOT(editFindChanged() ) ); insilmaril@0: insilmaril@160: // Connect TextEditor, so that we can update flags if text changes insilmaril@160: connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag())); insilmaril@393: connect (textEditor, SIGNAL (textEditorClosed() ), this, SLOT (updateActions())); insilmaril@160: insilmaril@0: updateGeometry(); insilmaril@0: } insilmaril@0: insilmaril@0: Main::~Main() insilmaril@0: { insilmaril@0: // Save Settings insilmaril@366: settings.setValue ( "/mainwindow/geometry/size", size() ); insilmaril@366: settings.setValue ( "/mainwindow/geometry/pos", pos() ); insilmaril@366: settings.setValue ("/mainwindow/state",saveState(0)); insilmaril@366: insilmaril@408: settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn()); insilmaril@408: settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn()); insilmaril@404: settings.setValue( "/version/version", vymVersion ); insilmaril@404: settings.setValue( "/version/builddate", vymBuildDate ); insilmaril@366: insilmaril@390: settings.setValue( "/mapeditor/editmode/autoSelectHeading",actionSettingsAutoSelectHeading->isOn() ); insilmaril@390: settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() ); insilmaril@390: settings.setValue( "/mapeditor/editmode/autoEdit",actionSettingsAutoEdit->isOn() ); insilmaril@366: settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() ); insilmaril@366: settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() ); insilmaril@366: settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() ); insilmaril@0: insilmaril@404: // call the destructors insilmaril@0: delete (textEditor); insilmaril@404: delete historyWindow; insilmaril@164: insilmaril@164: // Remove temporary directory insilmaril@164: removeDir (QDir(tmpVymDir)); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::loadCmdLine() insilmaril@0: { insilmaril@0: /* TODO draw some kind of splashscreen while loading... insilmaril@0: if (qApp->argc()>1) insilmaril@0: { insilmaril@0: } insilmaril@0: */ insilmaril@0: insilmaril@0: QStringList flist=options.getFileList(); insilmaril@0: QStringList::Iterator it=flist.begin(); insilmaril@0: insilmaril@0: while (it !=flist.end() ) insilmaril@0: { insilmaril@0: fileLoad (*it, NewMap); insilmaril@0: *it++; insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@0: insilmaril@0: void Main::statusMessage(const QString &s) insilmaril@0: { insilmaril@0: statusBar()->message (s); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::closeEvent (QCloseEvent* ) insilmaril@0: { insilmaril@0: fileExitVYM(); insilmaril@0: } insilmaril@0: insilmaril@0: // File Actions insilmaril@0: void Main::setupFileActions() insilmaril@0: { insilmaril@366: QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") ); insilmaril@366: QToolBar *tb = addToolBar( tr ("&Map") ); insilmaril@366: tb->setObjectName ("mapTB"); insilmaril@0: insilmaril@0: QAction *a; insilmaril@395: a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New...","File menu" ),this); insilmaril@395: a->setStatusTip ( tr( "New map","Status tip File menu" ) ); insilmaril@366: a->setShortcut ( Qt::CTRL + Qt::Key_N ); insilmaril@0: a->addTo( tb ); insilmaril@366: fileMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) ); insilmaril@0: insilmaril@395: a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this); insilmaril@395: a->setStatusTip (tr( "Open","Status tip File menu" ) ); insilmaril@366: a->setShortcut ( Qt::CTRL + Qt::Key_O ); insilmaril@0: a->addTo( tb ); insilmaril@366: fileMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) ); insilmaril@0: insilmaril@395: fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu")); insilmaril@366: fileMenu->addSeparator(); insilmaril@0: insilmaril@395: a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this); insilmaril@395: a->setStatusTip ( tr( "Save","Status tip file menu" )); insilmaril@366: a->setShortcut (Qt::CTRL + Qt::Key_S ); insilmaril@0: a->addTo( tb ); insilmaril@366: fileMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) ); insilmaril@0: actionFileSave=a; insilmaril@0: insilmaril@395: a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this); insilmaril@395: a->setStatusTip (tr( "Save &As","Status tip file menu" ) ); insilmaril@366: fileMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) ); insilmaril@366: insilmaril@366: fileMenu->addSeparator(); insilmaril@366: insilmaril@395: fileImportMenu = fileMenu->addMenu (tr("Import","File menu")); insilmaril@366: insilmaril@366: a = new QAction(tr("KDE Bookmarks"), this); insilmaril@395: a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE bookmarks"))); insilmaril@366: a->addTo (fileImportMenu); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) ); insilmaril@366: insilmaril@366: if (settings.value( "/mainwindow/showTestMenu",false).toBool()) insilmaril@331: { insilmaril@395: a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this); insilmaril@395: a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) )); insilmaril@366: a->addTo (fileImportMenu); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) ); insilmaril@331: } insilmaril@314: insilmaril@366: a = new QAction("Mind Manager...",this); insilmaril@395: a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") ); insilmaril@366: fileImportMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) ); insilmaril@366: insilmaril@395: a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this); insilmaril@395: a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) ); insilmaril@366: fileImportMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) ); insilmaril@366: insilmaril@395: fileExportMenu = fileMenu->addMenu (tr("Export","File menu")); insilmaril@395: insilmaril@395: a = new QAction( tr("Image%1","File export menu").arg("..."), this); insilmaril@395: a->setStatusTip( tr( "Export map as image","status tip file menu" )); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) ); insilmaril@366: fileExportMenu->addAction (a); insilmaril@366: insilmaril@395: a = new QAction( "Open Office...", this); insilmaril@395: a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" )); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) ); insilmaril@366: fileExportMenu->addAction (a); insilmaril@366: insilmaril@366: a = new QAction( "Webpage (XHTML)...",this ); insilmaril@366: a->setShortcut (Qt::ALT + Qt::Key_X); insilmaril@395: a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu"))); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) ); insilmaril@366: fileExportMenu->addAction (a); insilmaril@366: insilmaril@366: a = new QAction( "Text (ASCII)...", this); insilmaril@395: a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" ))); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) ); insilmaril@366: fileExportMenu->addAction (a); insilmaril@366: insilmaril@395: a = new QAction( tr("KDE Bookmarks","File menu"), this); insilmaril@395: a->setStatusTip( tr( "Export as %1").arg(tr("KDE Bookmarks" ))); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) ); insilmaril@366: fileExportMenu->addAction (a); insilmaril@366: insilmaril@366: a = new QAction( "Taskjuggler...", this ); insilmaril@395: a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" ))); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) ); insilmaril@366: fileExportMenu->addAction (a); insilmaril@366: insilmaril@366: a = new QAction( "LaTeX...", this); insilmaril@395: a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" ))); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) ); insilmaril@366: fileExportMenu->addAction (a); insilmaril@366: insilmaril@366: a = new QAction( "XML..." , this ); insilmaril@395: a->setStatusTip (tr( "Export as %1").arg("XML")); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) ); insilmaril@366: fileExportMenu->addAction (a); insilmaril@366: insilmaril@366: fileMenu->addSeparator(); insilmaril@366: insilmaril@366: a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this); insilmaril@395: a->setStatusTip ( tr( "Print" ,"File menu") ); insilmaril@366: a->setShortcut (Qt::CTRL + Qt::Key_P ); insilmaril@0: a->addTo( tb ); insilmaril@366: fileMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) ); insilmaril@0: actionFilePrint=a; insilmaril@0: insilmaril@395: a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this); insilmaril@366: a->setStatusTip (tr( "Close Map" ) ); insilmaril@366: a->setShortcut (Qt::ALT + Qt::Key_C ); insilmaril@366: fileMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) ); insilmaril@366: insilmaril@404: a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this); insilmaril@404: a->setStatusTip ( tr( "Exit")+" "+vymName ); insilmaril@366: a->setShortcut (Qt::CTRL + Qt::Key_Q ); insilmaril@366: fileMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) ); insilmaril@0: } insilmaril@0: insilmaril@0: insilmaril@0: //Edit Actions insilmaril@0: void Main::setupEditActions() insilmaril@0: { insilmaril@395: QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") ); insilmaril@0: tb->setLabel( "Edit Actions" ); insilmaril@366: tb->setObjectName ("actionsTB"); insilmaril@395: QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") ); insilmaril@0: insilmaril@0: QAction *a; insilmaril@102: QAction *alt; insilmaril@395: a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) ); insilmaril@366: a->setStatusTip (tr( "Undo" ) ); insilmaril@366: a->setShortcut ( Qt::CTRL + Qt::Key_Z ); insilmaril@0: a->setEnabled (false); insilmaril@366: tb->addAction (a); insilmaril@366: editMenu->addAction (a); insilmaril@0: actionEditUndo=a; insilmaril@163: insilmaril@395: a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this); insilmaril@366: a->setStatusTip (tr( "Redo" )); insilmaril@366: a->setShortcut (Qt::CTRL + Qt::Key_Y ); insilmaril@366: tb->addAction (a); insilmaril@366: editMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) ); insilmaril@366: actionEditRedo=a; insilmaril@163: insilmaril@366: editMenu->addSeparator(); insilmaril@395: a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this); insilmaril@366: a->setStatusTip ( tr( "Copy" ) ); insilmaril@366: a->setShortcut (Qt::CTRL + Qt::Key_C ); insilmaril@0: a->setEnabled (false); insilmaril@366: tb->addAction (a); insilmaril@366: editMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) ); insilmaril@0: actionEditCopy=a; insilmaril@366: insilmaril@395: a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this); insilmaril@366: a->setStatusTip ( tr( "Cut" ) ); insilmaril@366: a->setShortcut (Qt::CTRL + Qt::Key_X ); insilmaril@0: a->setEnabled (false); insilmaril@366: tb->addAction (a); insilmaril@366: editMenu->addAction (a); insilmaril@0: actionEditCut=a; insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) ); insilmaril@366: insilmaril@395: a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) ); insilmaril@366: a->setStatusTip ( tr( "Paste" ) ); insilmaril@366: a->setShortcut ( Qt::CTRL + Qt::Key_V ); insilmaril@0: a->setEnabled (false); insilmaril@366: tb->addAction (a); insilmaril@366: editMenu->addAction (a); insilmaril@0: actionEditPaste=a; insilmaril@98: insilmaril@351: // Shortcuts to modify heading: insilmaril@395: a = new QAction(tr( "Edit heading","Edit menu" ),this); insilmaril@366: a->setStatusTip ( tr( "edit Heading" )); insilmaril@366: a->setShortcut ( Qt::Key_Enter); insilmaril@366: // a->setShortcutContext (Qt::WindowShortcut); insilmaril@366: addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) ); insilmaril@351: actionListBranches.append(a); insilmaril@395: a = new QAction( tr( "Edit heading","Edit menu" ), this); insilmaril@366: a->setStatusTip (tr( "edit Heading" )); insilmaril@366: a->setShortcut (Qt::Key_Return ); insilmaril@366: //a->setShortcutContext (Qt::WindowShortcut); insilmaril@366: addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) ); insilmaril@351: actionListBranches.append(a); insilmaril@366: editMenu->addAction (a); insilmaril@351: actionEditHeading=a; insilmaril@395: a = new QAction( tr( "Edit heading","Edit menu" ), this); insilmaril@366: a->setStatusTip (tr( "edit Heading" )); insilmaril@366: a->setShortcut ( Qt::Key_F2 ); insilmaril@366: a->setShortcutContext (Qt::WindowShortcut); insilmaril@366: addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) ); insilmaril@351: actionListBranches.append(a); insilmaril@351: insilmaril@351: // Shortcut to delete selection insilmaril@395: a = new QAction( tr( "Delete Selection","Edit menu" ),this); insilmaril@366: a->setStatusTip (tr( "Delete Selection" )); insilmaril@366: a->setShortcut ( Qt::Key_Delete); insilmaril@366: a->setShortcutContext (Qt::WindowShortcut); insilmaril@366: addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) ); insilmaril@351: actionEditDelete=a; insilmaril@351: insilmaril@351: // Shortcut to add branch insilmaril@395: alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this); insilmaril@366: alt->setStatusTip ( tr( "Add a branch as child of selection" )); insilmaril@366: alt->setShortcut (Qt::Key_A); insilmaril@366: alt->setShortcutContext (Qt::WindowShortcut); insilmaril@366: addAction (alt); insilmaril@366: connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) ); insilmaril@395: a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this); insilmaril@366: a->setStatusTip ( tr( "Add a branch as child of selection" )); insilmaril@366: a->setShortcut (Qt::Key_Insert); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) ); insilmaril@351: actionListBranches.append(a); insilmaril@351: #if defined (Q_OS_MACX) insilmaril@366: // In OSX show different shortcut in menues, the keys work indepently always insilmaril@351: actionEditAddBranch=alt; insilmaril@351: #else insilmaril@351: actionEditAddBranch=a; insilmaril@351: #endif insilmaril@366: editMenu->addAction (actionEditAddBranch); insilmaril@366: tb->addAction (actionEditAddBranch); insilmaril@366: insilmaril@351: insilmaril@351: // Add branch by inserting it at selection insilmaril@395: a = new QAction(tr( "Add branch (insert)","Edit menu" ), this); insilmaril@366: a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" )); insilmaril@366: a->setShortcut (Qt::ALT + Qt::Key_Insert ); insilmaril@366: a->setShortcutContext (Qt::WindowShortcut); insilmaril@366: addAction (a); insilmaril@394: connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) ); insilmaril@351: a->setEnabled (false); insilmaril@351: actionListBranches.append(a); insilmaril@394: actionEditAddBranchBefore=a; insilmaril@395: a = new QAction(tr( "Add branch (insert)","Edit menu" ),this); insilmaril@366: a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" )); insilmaril@366: a->setShortcut ( Qt::ALT + Qt::Key_A ); insilmaril@366: a->setShortcutContext (Qt::WindowShortcut); insilmaril@366: addAction (a); insilmaril@394: connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) ); insilmaril@351: actionListBranches.append(a); insilmaril@351: insilmaril@351: // Add branch above insilmaril@395: a = new QAction(tr( "Add branch above","Edit menu" ), this); insilmaril@366: a->setStatusTip ( tr( "Add a branch above selection" )); insilmaril@366: a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); insilmaril@366: a->setShortcutContext (Qt::WindowShortcut); insilmaril@366: addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) ); insilmaril@351: a->setEnabled (false); insilmaril@351: actionListBranches.append(a); insilmaril@351: actionEditAddBranchAbove=a; insilmaril@395: a = new QAction(tr( "Add branch above","Edit menu" ), this); insilmaril@366: a->setStatusTip ( tr( "Add a branch above selection" )); insilmaril@366: a->setShortcut (Qt::SHIFT+Qt::Key_A ); insilmaril@366: a->setShortcutContext (Qt::WindowShortcut); insilmaril@366: addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) ); insilmaril@351: actionListBranches.append(a); insilmaril@351: insilmaril@351: // Add branch below insilmaril@395: a = new QAction(tr( "Add branch below","Edit menu" ), this); insilmaril@366: a->setStatusTip ( tr( "Add a branch below selection" )); insilmaril@366: a->setShortcut (Qt::CTRL +Qt::Key_Insert ); insilmaril@366: a->setShortcutContext (Qt::WindowShortcut); insilmaril@366: addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) ); insilmaril@351: a->setEnabled (false); insilmaril@351: actionListBranches.append(a); insilmaril@351: actionEditAddBranchBelow=a; insilmaril@395: a = new QAction(tr( "Add branch below","Edit menu" ), this); insilmaril@366: a->setStatusTip ( tr( "Add a branch below selection" )); insilmaril@366: a->setShortcut (Qt::CTRL +Qt::Key_A ); insilmaril@366: a->setShortcutContext (Qt::WindowShortcut); insilmaril@366: addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) ); insilmaril@351: actionListBranches.append(a); insilmaril@351: insilmaril@395: a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this); insilmaril@366: a->setStatusTip ( tr( "Move branch up" ) ); insilmaril@366: a->setShortcut (Qt::Key_PageUp ); insilmaril@0: a->setEnabled (false); insilmaril@366: tb->addAction (a); insilmaril@366: editMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) ); insilmaril@0: actionEditMoveUp=a; insilmaril@98: insilmaril@395: a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) ); insilmaril@366: a->setStatusTip (tr( "Move branch down" ) ); insilmaril@366: a->setShortcut ( Qt::Key_PageDown ); insilmaril@0: a->setEnabled (false); insilmaril@366: tb->addAction (a); insilmaril@366: editMenu->addAction (a); insilmaril@0: actionEditMoveDown=a; insilmaril@98: insilmaril@0: insilmaril@395: a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this); insilmaril@366: a->setShortcut ( Qt::Key_ScrollLock ); insilmaril@366: a->setStatusTip (tr( "Scroll branch" ) ); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) ); insilmaril@375: insilmaril@395: alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this); insilmaril@366: alt->setShortcut ( Qt::Key_S ); insilmaril@366: alt->setStatusTip (tr( "Scroll branch" )); insilmaril@366: connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) ); insilmaril@102: #if defined(Q_OS_MACX) insilmaril@102: actionEditToggleScroll=alt; insilmaril@102: #else insilmaril@102: actionEditToggleScroll=a; insilmaril@102: #endif insilmaril@102: actionEditToggleScroll->setEnabled (false); insilmaril@250: actionEditToggleScroll->setToggleAction(true); insilmaril@366: tb->addAction (actionEditToggleScroll); insilmaril@366: editMenu->addAction ( actionEditToggleScroll); insilmaril@366: editMenu->addAction (actionEditToggleScroll); insilmaril@375: addAction (a); insilmaril@375: addAction (alt); insilmaril@102: actionListBranches.append(actionEditToggleScroll); insilmaril@0: insilmaril@395: a = new QAction( tr( "Unscroll all scrolled branches","Edit menu" ), this); insilmaril@366: a->setStatusTip (tr( "Unscroll all" )); insilmaril@366: editMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editUnScrollAll() ) ); insilmaril@0: insilmaril@366: editMenu->addSeparator(); insilmaril@366: insilmaril@395: a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this); insilmaril@366: a->setStatusTip (tr( "Find" ) ); insilmaril@366: a->setShortcut (Qt::CTRL + Qt::Key_F ); insilmaril@366: editMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) ); insilmaril@0: insilmaril@366: editMenu->addSeparator(); insilmaril@366: insilmaril@395: a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this); insilmaril@366: a->setShortcut (Qt::CTRL + Qt::Key_U ); insilmaril@366: a->setShortcut (tr( "Open URL" )); insilmaril@366: tb->addAction (a); insilmaril@366: addAction(a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) ); insilmaril@0: actionEditOpenURL=a; insilmaril@0: insilmaril@395: a = new QAction( tr( "Open URL in new tab","Edit menu" ), this); insilmaril@366: a->setStatusTip (tr( "Open URL in new tab" )); insilmaril@366: a->setShortcut (Qt::CTRL+Qt::Key_U ); insilmaril@366: addAction(a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) ); insilmaril@266: actionEditOpenURLTab=a; insilmaril@266: insilmaril@395: a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this); insilmaril@366: a->setStatusTip (tr( "Open all URLs in subtree" )); insilmaril@366: addAction(a); insilmaril@366: actionListBranches.append(a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) ); insilmaril@366: actionEditOpenMultipleURLTabs=a; insilmaril@366: insilmaril@395: a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this); insilmaril@366: a->setStatusTip ( tr( "Edit URL" ) ); insilmaril@366: a->setShortcut (Qt::SHIFT + Qt::CTRL + Qt::Key_U ); insilmaril@366: //a->setShortcut ( Qt::Key_U ); insilmaril@366: a->setShortcutContext (Qt::WindowShortcut); insilmaril@366: actionListBranches.append(a); insilmaril@366: addAction(a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) ); insilmaril@366: actionEditURL=a; insilmaril@366: insilmaril@395: a = new QAction( tr( "Use heading for URL","Edit menu" ), this); insilmaril@366: a->setStatusTip ( tr( "Use heading of selected branch as URL" )); insilmaril@0: a->setEnabled (false); insilmaril@98: actionListBranches.append(a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) ); insilmaril@366: actionEditHeading2URL=a; insilmaril@366: insilmaril@395: a = new QAction(tr( "Create URL to Bugzilla","Edit menu" ), this); insilmaril@366: a->setStatusTip ( tr( "Create URL to Bugzilla" )); insilmaril@0: a->setEnabled (false); insilmaril@98: actionListBranches.append(a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) ); insilmaril@366: actionEditBugzilla2URL=a; insilmaril@0: insilmaril@395: a = new QAction(tr( "Create URL to FATE","Edit menu" ), this); insilmaril@366: a->setStatusTip ( tr( "Create URL to FATE" )); insilmaril@0: a->setEnabled (false); insilmaril@98: actionListBranches.append(a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) ); insilmaril@366: actionEditFATE2URL=a; insilmaril@366: insilmaril@395: a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this); insilmaril@366: a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" )); insilmaril@366: tb->addAction (a); insilmaril@366: a->setEnabled (false); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) ); insilmaril@366: actionEditOpenVymLink=a; insilmaril@366: insilmaril@395: a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this); insilmaril@366: a->setStatusTip ( tr( "Open all vym links in subtree" )); insilmaril@175: a->setEnabled (false); insilmaril@175: actionListBranches.append(a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) ); insilmaril@366: actionEditOpenMultipleVymLinks=a; insilmaril@0: insilmaril@366: insilmaril@395: a = new QAction(tr( "Edit vym link...","Edit menu" ), this); insilmaril@0: a->setEnabled (false); insilmaril@366: a->setStatusTip ( tr( "Edit link to another vym map" )); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) ); insilmaril@98: actionListBranches.append(a); insilmaril@0: actionEditVymLink=a; insilmaril@0: insilmaril@395: a = new QAction(tr( "Delete vym link","Edit menu" ),this); insilmaril@366: a->setStatusTip ( tr( "Delete link to another vym map" )); insilmaril@0: a->setEnabled (false); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) ); insilmaril@0: actionEditDeleteVymLink=a; insilmaril@0: insilmaril@395: a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this); insilmaril@366: a->setStatusTip ( tr( "Hide object in exports" ) ); insilmaril@366: a->setShortcut (Qt::Key_H ); insilmaril@243: a->setToggleAction(true); insilmaril@366: tb->addAction (a); insilmaril@243: a->setEnabled (false); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) ); insilmaril@243: actionEditToggleHideExport=a; insilmaril@243: insilmaril@395: a = new QAction(tr( "Edit Map Info...","Edit menu" ),this); insilmaril@366: a->setStatusTip ( tr( "Edit Map Info" )); insilmaril@0: a->setEnabled (true); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) ); insilmaril@0: actionEditMapInfo=a; insilmaril@0: insilmaril@0: // Import at selection (adding to selection) insilmaril@395: a = new QAction( tr( "Add map (insert)","Edit menu" ),this); insilmaril@366: a->setStatusTip (tr( "Add map at selection" )); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) ); insilmaril@0: a->setEnabled (false); insilmaril@98: actionListBranches.append(a); insilmaril@0: actionEditImportAdd=a; insilmaril@0: insilmaril@0: // Import at selection (replacing selection) insilmaril@395: a = new QAction( tr( "Add map (replace)","Edit menu" ), this); insilmaril@366: a->setStatusTip (tr( "Replace selection with map" )); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) ); insilmaril@0: a->setEnabled (false); insilmaril@98: actionListBranches.append(a); insilmaril@0: actionEditImportReplace=a; insilmaril@0: insilmaril@0: // Save selection insilmaril@395: a = new QAction( tr( "Save selection","Edit menu" ), this); insilmaril@366: a->setStatusTip (tr( "Save selection" )); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) ); insilmaril@0: a->setEnabled (false); insilmaril@98: actionListBranches.append(a); insilmaril@0: actionEditSaveBranch=a; insilmaril@0: insilmaril@98: // Only remove branch, not its childs insilmaril@395: a = new QAction(tr( "Remove only branch ","Edit menu" ), this); insilmaril@366: a->setStatusTip ( tr( "Remove only branch and keep its childs" )); insilmaril@366: a->setShortcut (Qt::ALT + Qt::Key_Delete ); insilmaril@395: connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChilds() ) ); insilmaril@98: a->setEnabled (false); insilmaril@375: addAction (a); insilmaril@98: actionListBranches.append(a); insilmaril@395: actionEditDeleteKeepChilds=a; insilmaril@98: insilmaril@98: // Only remove childs of a branch insilmaril@395: a = new QAction( tr( "Remove childs","Edit menu" ), this); insilmaril@366: a->setStatusTip (tr( "Remove childs of branch" )); insilmaril@366: a->setShortcut (Qt::SHIFT + Qt::Key_Delete ); insilmaril@395: connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChilds() ) ); insilmaril@98: a->setEnabled (false); insilmaril@98: actionListBranches.append(a); insilmaril@395: actionEditDeleteChilds=a; insilmaril@98: insilmaril@0: // Shortcuts for navigating with cursor: insilmaril@395: a = new QAction(tr( "Select upper branch","Edit menu" ), this); insilmaril@366: a->setStatusTip ( tr( "Select upper branch" )); insilmaril@366: a->setShortcut (Qt::Key_Up ); insilmaril@366: a->setShortcutContext (Qt::WindowShortcut); insilmaril@366: addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) ); insilmaril@395: a = new QAction( tr( "Select lower branch","Edit menu" ),this); insilmaril@366: a->setStatusTip (tr( "Select lower branch" )); insilmaril@366: a->setShortcut ( Qt::Key_Down ); insilmaril@366: a->setShortcutContext (Qt::WindowShortcut); insilmaril@366: addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) ); insilmaril@395: a = new QAction(tr( "Select left branch","Edit menu" ), this); insilmaril@366: a->setStatusTip ( tr( "Select left branch" )); insilmaril@366: a->setShortcut (Qt::Key_Left ); insilmaril@366: a->setShortcutContext (Qt::WindowShortcut); insilmaril@366: addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) ); insilmaril@395: a = new QAction( tr( "Select child branch","Edit menu" ), this); insilmaril@366: a->setStatusTip (tr( "Select right branch" )); insilmaril@366: a->setShortcut (Qt::Key_Right); insilmaril@366: a->setShortcutContext (Qt::WindowShortcut); insilmaril@366: addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) ); insilmaril@395: a = new QAction( tr( "Select first branch","Edit menu" ), this); insilmaril@366: a->setStatusTip (tr( "Select first branch" )); insilmaril@366: a->setShortcut (Qt::Key_Home ); insilmaril@366: a->setShortcutContext (Qt::WindowShortcut); insilmaril@366: addAction (a); insilmaril@0: a->setEnabled (false); insilmaril@366: editMenu->addAction (a); insilmaril@98: actionListBranches.append(a); insilmaril@0: actionEditSelectFirst=a; insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) ); insilmaril@395: a = new QAction( tr( "Select last branch","Edit menu" ),this); insilmaril@366: a->setStatusTip (tr( "Select last branch" )); insilmaril@366: a->setShortcut ( Qt::Key_End ); insilmaril@366: a->setShortcutContext (Qt::WindowShortcut); insilmaril@366: addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) ); insilmaril@0: a->setEnabled (false); insilmaril@366: editMenu->addAction (a); insilmaril@98: actionListBranches.append(a); insilmaril@0: actionEditSelectLast=a; insilmaril@0: insilmaril@395: a = new QAction( tr( "Add Image...","Edit menu" ), this); insilmaril@366: a->setStatusTip (tr( "Add Image" )); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) ); insilmaril@0: actionEditLoadImage=a; insilmaril@89: insilmaril@0: } insilmaril@0: insilmaril@0: // Format Actions insilmaril@0: void Main::setupFormatActions() insilmaril@0: { insilmaril@395: QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu")); insilmaril@395: insilmaril@395: QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name")); insilmaril@366: tb->setObjectName ("formatTB"); insilmaril@0: QAction *a; insilmaril@0: QPixmap pix( 16,16); insilmaril@366: pix.fill (Qt::black); insilmaril@366: a= new QAction(pix, tr( "Set &Color" )+QString("..."), this); insilmaril@366: a->setStatusTip ( tr( "Set Color" )); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) ); insilmaril@366: a->addTo( tb ); insilmaril@366: formatMenu->addAction (a); insilmaril@366: actionFormatColor=a; insilmaril@395: a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this); insilmaril@366: a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) ); insilmaril@366: a->setShortcut (Qt::CTRL + Qt::Key_K ); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) ); insilmaril@0: a->setEnabled (false); insilmaril@0: a->addTo( tb ); insilmaril@366: formatMenu->addAction (a); insilmaril@98: actionListBranches.append(a); insilmaril@0: actionFormatPickColor=a; insilmaril@366: insilmaril@417: a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this); insilmaril@366: a->setStatusTip ( tr( "Color branch" ) ); insilmaril@366: a->setShortcut (Qt::CTRL + Qt::Key_I); insilmaril@417: connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) ); insilmaril@0: a->setEnabled (false); insilmaril@0: a->addTo( tb ); insilmaril@366: formatMenu->addAction (a); insilmaril@98: actionListBranches.append(a); insilmaril@417: actionFormatColorSubtree=a; insilmaril@417: insilmaril@417: a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this); insilmaril@366: a->setStatusTip ( tr( "Color Subtree" )); insilmaril@366: a->setShortcut (Qt::CTRL + Qt::Key_T); insilmaril@417: connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) ); insilmaril@0: a->setEnabled (false); insilmaril@366: formatMenu->addAction (a); insilmaril@0: a->addTo( tb ); insilmaril@98: actionListBranches.append(a); insilmaril@0: actionFormatColorSubtree=a; insilmaril@0: insilmaril@366: formatMenu->addSeparator(); insilmaril@366: actionGroupFormatLinkStyles=new QActionGroup ( this); insilmaril@0: actionGroupFormatLinkStyles->setExclusive (true); insilmaril@366: a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles); insilmaril@366: a->setStatusTip (tr( "Line" )); insilmaril@0: a->setToggleAction(true); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) ); insilmaril@366: formatMenu->addAction (a); insilmaril@0: actionFormatLinkStyleLine=a; insilmaril@366: a= new QAction( tr( "Linkstyle Parabel" ), actionGroupFormatLinkStyles); insilmaril@366: a->setStatusTip (tr( "Line" )); insilmaril@0: a->setToggleAction(true); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) ); insilmaril@366: formatMenu->addAction (a); insilmaril@0: actionFormatLinkStyleParabel=a; insilmaril@366: a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles ); insilmaril@366: a->setStatusTip (tr( "PolyLine" )); insilmaril@0: a->setToggleAction(true); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) ); insilmaril@366: formatMenu->addAction (a); insilmaril@0: actionFormatLinkStylePolyLine=a; insilmaril@366: a= new QAction( tr( "Linkstyle Thick Parabel" ), actionGroupFormatLinkStyles); insilmaril@366: a->setStatusTip (tr( "PolyParabel" ) ); insilmaril@0: a->setToggleAction(true); insilmaril@366: a->setChecked (true); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) ); insilmaril@366: formatMenu->addAction (a); insilmaril@0: actionFormatLinkStylePolyParabel=a; insilmaril@0: insilmaril@366: actionGroupFormatFrameTypes=new QActionGroup ( this); insilmaril@0: actionGroupFormatFrameTypes->setExclusive (true); insilmaril@395: a = new QAction( tr( "No Frame","Branch attribute" ), actionGroupFormatFrameTypes ); insilmaril@366: a->setStatusTip (tr("No Frame")); insilmaril@0: a->setToggleAction(true); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameNone() ) ); insilmaril@0: actionFormatFrameNone=a; insilmaril@395: a = new QAction( tr( "Rectangle""Branch attribute" ), actionGroupFormatFrameTypes); insilmaril@366: a->setStatusTip (tr( "Rectangle" )); insilmaril@0: a->setToggleAction(true); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameRectangle() ) ); insilmaril@0: actionFormatFrameRectangle=a; insilmaril@0: insilmaril@395: a = new QAction( tr( "Include images vertically","Branch attribute" ), this); insilmaril@366: a->setStatusTip ( tr ("Include top and bottom position of images into branch")); insilmaril@175: a->setToggleAction(true); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesVer() ) ); insilmaril@175: actionFormatIncludeImagesVer=a; insilmaril@175: insilmaril@395: a = new QAction( tr( "Include images horizontally","Branch attribute" ), this); insilmaril@366: a->setStatusTip ( tr ("Include left and right position of images into branch")); insilmaril@175: a->setToggleAction(true); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesHor() ) ); insilmaril@175: actionFormatIncludeImagesHor=a; insilmaril@175: insilmaril@395: a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this); insilmaril@366: a->setStatusTip (tr( "Hide link" )); insilmaril@160: a->setToggleAction(true); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) ); insilmaril@160: actionFormatHideLinkUnselected=a; insilmaril@160: insilmaril@366: formatMenu->addSeparator(); insilmaril@395: a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this); insilmaril@366: a->setStatusTip (tr( "Use same color for links and headings" )); insilmaril@0: a->setToggleAction(true); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) ); insilmaril@366: formatMenu->addAction (a); insilmaril@0: actionFormatLinkColorHint=a; insilmaril@366: insilmaril@366: pix.fill (Qt::white); insilmaril@366: a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this ); insilmaril@366: a->setStatusTip (tr( "Set Link Color" )); insilmaril@366: formatMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) ); insilmaril@366: actionFormatLinkColor=a; insilmaril@366: insilmaril@366: a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this ); insilmaril@366: a->setStatusTip (tr( "Set Background Color" )); insilmaril@366: formatMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) ); insilmaril@366: actionFormatBackColor=a; insilmaril@408: insilmaril@408: a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this ); insilmaril@408: a->setStatusTip (tr( "Set Background image" )); insilmaril@408: formatMenu->addAction (a); insilmaril@408: connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) ); insilmaril@408: actionFormatBackImage=a; insilmaril@0: } insilmaril@0: insilmaril@0: // View Actions insilmaril@0: void Main::setupViewActions() insilmaril@0: { insilmaril@395: QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") ); insilmaril@0: tb->setLabel( "View Actions" ); insilmaril@366: tb->setObjectName ("viewTB"); insilmaril@366: QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" )); insilmaril@0: insilmaril@0: QAction *a; insilmaril@395: a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this); insilmaril@366: a->setStatusTip ( tr( "Zoom reset" ) ); insilmaril@366: a->setShortcut (Qt::CTRL + Qt::Key_0 ); insilmaril@0: a->addTo( tb ); insilmaril@366: viewMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) ); insilmaril@366: insilmaril@395: a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this); insilmaril@366: a->setStatusTip (tr( "Zoom in" )); insilmaril@366: a->setShortcut (Qt::CTRL + Qt::Key_Plus); insilmaril@0: a->addTo( tb ); insilmaril@366: viewMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) ); insilmaril@366: insilmaril@395: a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this); insilmaril@366: a->setStatusTip (tr( "Zoom out" )); insilmaril@366: a->setShortcut (Qt::CTRL + Qt::Key_Minus ); insilmaril@0: a->addTo( tb ); insilmaril@366: viewMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) ); insilmaril@366: insilmaril@366: insilmaril@395: a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this); insilmaril@366: a->setStatusTip ( tr( "Show Note Editor" )); insilmaril@366: 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@366: viewMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) ); insilmaril@0: actionViewToggleNoteEditor=a; insilmaril@294: insilmaril@404: a = new QAction(QPixmap(iconPath+"history.png"), tr( "Show history window","View action" ),this ); insilmaril@366: a->setStatusTip ( tr( "Show history window" )); insilmaril@366: a->setShortcut ( Qt::CTRL + Qt::Key_H ); insilmaril@407: a->setToggleAction(true); insilmaril@404: a->addTo( tb ); insilmaril@366: viewMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) ); insilmaril@294: actionViewToggleHistoryWindow=a; insilmaril@294: insilmaril@408: a = new QAction(tr( "Antialiasing","View action" ),this ); insilmaril@408: a->setStatusTip ( tr( "Antialiasing" )); insilmaril@408: a->setToggleAction(true); insilmaril@408: a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool()); insilmaril@408: viewMenu->addAction (a); insilmaril@408: connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) ); insilmaril@408: actionViewToggleAntiAlias=a; insilmaril@408: insilmaril@408: a = new QAction(tr( "Smooth pixmap transformations","View action" ),this ); insilmaril@408: a->setStatusTip (a->text()); insilmaril@408: a->setToggleAction(true); insilmaril@408: a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool()); insilmaril@408: viewMenu->addAction (a); insilmaril@408: connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) ); insilmaril@408: actionViewToggleSmoothPixmapTransform=a; insilmaril@408: insilmaril@395: a = new QAction(tr( "Next Window","View action" ), this); insilmaril@408: a->setStatusTip (a->text()); insilmaril@366: a->setShortcut (Qt::ALT + Qt::Key_N ); insilmaril@366: viewMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) ); insilmaril@366: insilmaril@395: a = new QAction (tr( "Previous Window","View action" ), this ); insilmaril@408: a->setStatusTip (a->text()); insilmaril@366: a->setShortcut (Qt::ALT + Qt::Key_P ); insilmaril@366: viewMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) ); insilmaril@0: } insilmaril@0: insilmaril@89: // Mode Actions insilmaril@89: void Main::setupModeActions() insilmaril@89: { insilmaril@89: //QPopupMenu *menu = new QPopupMenu( this ); insilmaril@89: //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu ); insilmaril@89: insilmaril@395: QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") ); insilmaril@366: tb->setObjectName ("modesTB"); insilmaril@89: QAction *a; insilmaril@366: actionGroupModModes=new QActionGroup ( this); insilmaril@89: actionGroupModModes->setExclusive (true); insilmaril@395: a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes); insilmaril@366: a->setShortcut (Qt::Key_J); insilmaril@366: a->setStatusTip ( tr( "Use modifier to color branches" )); insilmaril@89: a->setToggleAction(true); insilmaril@89: a->addTo (tb); insilmaril@89: a->setOn(true); insilmaril@89: actionModModeColor=a; insilmaril@104: insilmaril@395: a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes ); insilmaril@366: a->setShortcut( Qt::Key_K); insilmaril@366: a->setStatusTip( tr( "Use modifier to copy" )); insilmaril@104: a->setToggleAction(true); insilmaril@104: a->addTo (tb); insilmaril@104: actionModModeCopy=a; insilmaril@104: insilmaril@395: a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes ); insilmaril@366: a->setShortcut (Qt::Key_L); insilmaril@366: a->setStatusTip( tr( "Use modifier to draw xLinks" )); insilmaril@89: a->setToggleAction(true); insilmaril@89: a->addTo (tb); insilmaril@390: actionModModeXLink=a; insilmaril@89: } insilmaril@89: insilmaril@0: // Flag Actions insilmaril@0: void Main::setupFlagActions() insilmaril@0: { insilmaril@166: // Create System Flags insilmaril@166: systemFlagsDefault = new FlagRowObj (); insilmaril@166: systemFlagsDefault->setVisibility (false); insilmaril@166: systemFlagsDefault->setName ("systemFlagsDef"); insilmaril@166: insilmaril@166: FlagObj *fo = new FlagObj (); insilmaril@269: fo->load(QPixmap(flagsPath+"flag-note.png")); insilmaril@166: fo->setName("note"); insilmaril@166: fo->setToolTip(tr("Note","Systemflag")); insilmaril@166: systemFlagsDefault->addFlag (fo); // makes deep copy insilmaril@166: insilmaril@269: fo->load(QPixmap(flagsPath+"flag-url.png")); insilmaril@166: fo->setName("url"); insilmaril@166: fo->setToolTip(tr("WWW Document (external)","Systemflag")); insilmaril@166: systemFlagsDefault->addFlag (fo); insilmaril@166: insilmaril@269: fo->load(QPixmap(flagsPath+"flag-vymlink.png")); insilmaril@166: fo->setName("vymLink"); insilmaril@166: fo->setToolTip(tr("Link to another vym map","Systemflag")); insilmaril@166: systemFlagsDefault->addFlag (fo); insilmaril@166: insilmaril@269: fo->load(QPixmap(flagsPath+"flag-scrolled-right.png")); insilmaril@166: fo->setName("scrolledright"); insilmaril@166: fo->setToolTip(tr("subtree is scrolled","Systemflag")); insilmaril@166: systemFlagsDefault->addFlag (fo); insilmaril@166: insilmaril@269: fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png")); insilmaril@166: fo->setName("tmpUnscrolledright"); insilmaril@166: fo->setToolTip(tr("subtree is temporary scrolled","Systemflag")); insilmaril@166: systemFlagsDefault->addFlag (fo); insilmaril@166: insilmaril@269: fo->load(QPixmap(flagsPath+"flag-hideexport.png")); insilmaril@243: fo->setName("hideInExport"); insilmaril@243: fo->setToolTip(tr("Hide object in exported maps","Systemflag")); insilmaril@243: systemFlagsDefault->addFlag (fo); insilmaril@243: insilmaril@166: // Create Standard Flags insilmaril@366: QToolBar *tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar")); insilmaril@366: tb->setObjectName ("standardFlagTB"); insilmaril@366: insilmaril@166: standardFlagsDefault = new FlagRowObj (); insilmaril@166: standardFlagsDefault->setVisibility (false); insilmaril@166: standardFlagsDefault->setName ("standardFlagsDef"); insilmaril@366: standardFlagsDefault->setToolBar (tb); insilmaril@166: insilmaril@408: fo->load(flagsPath+"flag-exclamationmark.png"); insilmaril@166: fo->setName ("exclamationmark"); insilmaril@166: fo->setGroup("standard-mark"); insilmaril@366: QAction *a=new QAction (fo->getPixmap(),fo->getName(),this); insilmaril@366: tb->addAction (a); insilmaril@366: fo->setAction (a); insilmaril@366: a->setCheckable(true); insilmaril@366: a->setObjectName(fo->getName()); insilmaril@366: a->setToolTip(tr("Take care!","Standardflag")); insilmaril@366: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@166: standardFlagsDefault->addFlag (fo); // makes deep copy insilmaril@166: insilmaril@408: fo->load(flagsPath+"flag-questionmark.png"); insilmaril@166: fo->setName("questionmark"); insilmaril@166: fo->setGroup("standard-mark"); insilmaril@366: a=new QAction (fo->getPixmap(),fo->getName(),this); insilmaril@366: tb->addAction (a); insilmaril@366: fo->setAction (a); insilmaril@366: a->setCheckable(true); insilmaril@366: a->setObjectName(fo->getName()); insilmaril@366: a->setToolTip(tr("Really?","Standardflag")); insilmaril@366: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@166: standardFlagsDefault->addFlag (fo); insilmaril@166: insilmaril@408: fo->load(flagsPath+"flag-hook-green.png"); insilmaril@166: fo->setName("hook-green"); insilmaril@166: fo->setGroup("standard-hook"); insilmaril@366: a=new QAction (fo->getPixmap(),fo->getName(),this); insilmaril@366: tb->addAction (a); insilmaril@366: fo->setAction (a); insilmaril@366: a->setCheckable(true); insilmaril@366: a->setObjectName(fo->getName()); insilmaril@366: a->setToolTip(tr("ok!","Standardflag")); insilmaril@366: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@166: standardFlagsDefault->addFlag (fo); insilmaril@166: insilmaril@408: fo->load(flagsPath+"flag-cross-red.png"); insilmaril@166: fo->setName("cross-red"); insilmaril@166: fo->setGroup("standard-hook"); insilmaril@366: a=new QAction (fo->getPixmap(),fo->getName(),this); insilmaril@366: tb->addAction (a); insilmaril@366: fo->setAction (a); insilmaril@366: a->setCheckable(true); insilmaril@366: a->setObjectName(fo->getName()); insilmaril@366: a->setToolTip(tr("Not ok!","Standardflag")); insilmaril@366: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@166: standardFlagsDefault->addFlag (fo); insilmaril@166: insilmaril@408: fo->load(flagsPath+"flag-stopsign.png"); insilmaril@166: fo->setName("stopsign"); insilmaril@366: a=new QAction (fo->getPixmap(),fo->getName(),this); insilmaril@366: tb->addAction (a); insilmaril@366: fo->setAction (a); insilmaril@366: a->setCheckable(true); insilmaril@366: a->setObjectName(fo->getName()); insilmaril@366: a->setToolTip(tr("This won't work!","Standardflag")); insilmaril@366: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@166: standardFlagsDefault->addFlag (fo); insilmaril@166: insilmaril@408: fo->load(flagsPath+"flag-smiley-good.png"); insilmaril@166: fo->setName("smiley-good"); insilmaril@166: fo->setGroup("standard-smiley"); insilmaril@366: a=new QAction (fo->getPixmap(),fo->getName(),this); insilmaril@366: tb->addAction (a); insilmaril@366: fo->setAction (a); insilmaril@366: a->setCheckable(true); insilmaril@366: a->setObjectName(fo->getName()); insilmaril@366: a->setToolTip(tr("Good","Standardflag")); insilmaril@366: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@166: standardFlagsDefault->addFlag (fo); insilmaril@166: insilmaril@408: fo->load(flagsPath+"flag-smiley-sad.png"); insilmaril@166: fo->setName("smiley-sad"); insilmaril@166: fo->setGroup("standard-smiley"); insilmaril@366: a=new QAction (fo->getPixmap(),fo->getName(),this); insilmaril@366: tb->addAction (a); insilmaril@366: fo->setAction (a); insilmaril@366: a->setCheckable(true); insilmaril@366: a->setObjectName(fo->getName()); insilmaril@366: a->setToolTip(tr("Bad","Standardflag")); insilmaril@366: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@166: standardFlagsDefault->addFlag (fo); insilmaril@166: insilmaril@408: fo->load(flagsPath+"flag-smiley-omg.png"); insilmaril@269: // Original omg.png (in KDE emoticons) insilmaril@269: fo->setName("smiley-omg"); insilmaril@269: fo->setGroup("standard-smiley"); insilmaril@366: a=new QAction (fo->getPixmap(),fo->getName(),this); insilmaril@366: tb->addAction (a); insilmaril@366: fo->setAction (a); insilmaril@366: a->setCheckable(true); insilmaril@366: a->setObjectName(fo->getName()); insilmaril@366: a->setToolTip(tr("Oh no!","Standardflag")); insilmaril@366: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@269: standardFlagsDefault->addFlag (fo); insilmaril@269: insilmaril@408: fo->load(flagsPath+"flag-kalarm.png"); insilmaril@166: fo->setName("clock"); insilmaril@366: a=new QAction (fo->getPixmap(),fo->getName(),this); insilmaril@366: tb->addAction (a); insilmaril@366: fo->setAction (a); insilmaril@366: a->setCheckable(true); insilmaril@366: a->setObjectName(fo->getName()); insilmaril@366: a->setToolTip(tr("Time critical","Standardflag")); insilmaril@366: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@166: standardFlagsDefault->addFlag (fo); insilmaril@166: insilmaril@408: fo->load(flagsPath+"flag-phone.png"); insilmaril@269: fo->setName("phone"); insilmaril@366: a=new QAction (fo->getPixmap(),fo->getName(),this); insilmaril@366: tb->addAction (a); insilmaril@366: fo->setAction (a); insilmaril@366: a->setCheckable(true); insilmaril@366: a->setObjectName(fo->getName()); insilmaril@366: a->setToolTip(tr("Call...","Standardflag")); insilmaril@366: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@269: standardFlagsDefault->addFlag (fo); insilmaril@269: insilmaril@408: fo->load(flagsPath+"flag-lamp.png"); insilmaril@166: fo->setName("lamp"); insilmaril@366: a=new QAction (fo->getPixmap(),fo->getName(),this); insilmaril@366: tb->addAction (a); insilmaril@366: fo->setAction (a); insilmaril@366: a->setCheckable(true); insilmaril@366: a->setObjectName(fo->getName()); insilmaril@366: a->setToolTip(tr("Idea!","Standardflag")); insilmaril@366: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@166: standardFlagsDefault->addFlag (fo); insilmaril@166: insilmaril@408: fo->load(flagsPath+"flag-arrow-up.png"); insilmaril@166: fo->setName("arrow-up"); insilmaril@166: fo->setGroup("standard-arrow"); insilmaril@366: a=new QAction (fo->getPixmap(),fo->getName(),this); insilmaril@366: tb->addAction (a); insilmaril@366: fo->setAction (a); insilmaril@366: a->setCheckable(true); insilmaril@366: a->setObjectName(fo->getName()); insilmaril@366: a->setToolTip(tr("Important","Standardflag")); insilmaril@366: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@166: standardFlagsDefault->addFlag (fo); insilmaril@166: insilmaril@408: fo->load(flagsPath+"flag-arrow-down.png"); insilmaril@166: fo->setName("arrow-down"); insilmaril@166: fo->setGroup("standard-arrow"); insilmaril@366: a=new QAction (fo->getPixmap(),fo->getName(),this); insilmaril@366: tb->addAction (a); insilmaril@366: fo->setAction (a); insilmaril@366: a->setCheckable(true); insilmaril@366: a->setObjectName(fo->getName()); insilmaril@366: a->setToolTip(tr("Unimportant","Standardflag")); insilmaril@366: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@166: standardFlagsDefault->addFlag (fo); insilmaril@166: insilmaril@408: fo->load(flagsPath+"flag-arrow-2up.png"); insilmaril@269: fo->setName("2arrow-up"); insilmaril@269: fo->setGroup("standard-arrow"); insilmaril@366: a=new QAction (fo->getPixmap(),fo->getName(),this); insilmaril@366: tb->addAction (a); insilmaril@366: fo->setAction (a); insilmaril@366: a->setCheckable(true); insilmaril@366: a->setObjectName(fo->getName()); insilmaril@366: a->setToolTip(tr("Very important!","Standardflag")); insilmaril@366: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@269: standardFlagsDefault->addFlag (fo); insilmaril@269: insilmaril@408: fo->load(flagsPath+"flag-arrow-2down.png"); insilmaril@269: fo->setName("2arrow-down"); insilmaril@269: fo->setGroup("standard-arrow"); insilmaril@366: a=new QAction (fo->getPixmap(),fo->getName(),this); insilmaril@366: tb->addAction (a); insilmaril@366: fo->setAction (a); insilmaril@366: a->setCheckable(true); insilmaril@366: a->setObjectName(fo->getName()); insilmaril@366: a->setToolTip(tr("Very unimportant!","Standardflag")); insilmaril@366: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@269: standardFlagsDefault->addFlag (fo); insilmaril@269: insilmaril@408: fo->load(flagsPath+"flag-thumb-up.png"); insilmaril@166: fo->setName("thumb-up"); insilmaril@166: fo->setGroup("standard-thumb"); insilmaril@366: a=new QAction (fo->getPixmap(),fo->getName(),this); insilmaril@366: tb->addAction (a); insilmaril@366: fo->setAction (a); insilmaril@366: a->setCheckable(true); insilmaril@366: a->setObjectName(fo->getName()); insilmaril@366: a->setToolTip(tr("I like this","Standardflag")); insilmaril@366: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@166: standardFlagsDefault->addFlag (fo); insilmaril@166: insilmaril@408: fo->load(flagsPath+"flag-thumb-down.png"); insilmaril@166: fo->setName("thumb-down"); insilmaril@166: fo->setGroup("standard-thumb"); insilmaril@366: a=new QAction (fo->getPixmap(),fo->getName(),this); insilmaril@366: tb->addAction (a); insilmaril@366: fo->setAction (a); insilmaril@366: a->setCheckable(true); insilmaril@366: a->setObjectName(fo->getName()); insilmaril@366: a->setToolTip(tr("I do not like this","Standardflag")); insilmaril@366: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@166: standardFlagsDefault->addFlag (fo); insilmaril@166: insilmaril@408: fo->load(flagsPath+"flag-rose.png"); insilmaril@269: fo->setName("rose"); insilmaril@366: a=new QAction (fo->getPixmap(),fo->getName(),this); insilmaril@366: tb->addAction (a); insilmaril@366: fo->setAction (a); insilmaril@366: a->setCheckable(true); insilmaril@366: a->setObjectName(fo->getName()); insilmaril@366: a->setToolTip(tr("Rose","Standardflag")); insilmaril@366: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@269: standardFlagsDefault->addFlag (fo); insilmaril@269: insilmaril@408: fo->load(flagsPath+"flag-heart.png"); insilmaril@166: fo->setName("heart"); insilmaril@366: a=new QAction (fo->getPixmap(),fo->getName(),this); insilmaril@366: tb->addAction (a); insilmaril@366: a->setCheckable(true); insilmaril@366: a->setObjectName(fo->getName()); insilmaril@366: a->setToolTip(tr("I just love... ","Standardflag")); insilmaril@366: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@166: standardFlagsDefault->addFlag (fo); insilmaril@166: insilmaril@408: fo->load(flagsPath+"flag-present.png"); insilmaril@269: fo->setName("present"); insilmaril@366: a=new QAction (fo->getPixmap(),fo->getName(),this); insilmaril@366: tb->addAction (a); insilmaril@366: fo->setAction (a); insilmaril@366: a->setCheckable(true); insilmaril@366: a->setObjectName(fo->getName()); insilmaril@366: a->setToolTip(tr("Surprise!","Standardflag")); insilmaril@366: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@269: standardFlagsDefault->addFlag (fo); insilmaril@269: insilmaril@408: fo->load(flagsPath+"flag-flash.png"); insilmaril@166: fo->setName("flash"); insilmaril@366: a=new QAction (fo->getPixmap(),fo->getName(),this); insilmaril@366: tb->addAction (a); insilmaril@366: fo->setAction (a); insilmaril@366: a->setCheckable(true); insilmaril@366: a->setObjectName(fo->getName()); insilmaril@366: a->setToolTip(tr("Dangerous","Standardflag")); insilmaril@366: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@166: standardFlagsDefault->addFlag (fo); insilmaril@166: insilmaril@408: fo->load(flagsPath+"flag-info.png"); insilmaril@269: // Original: xsldbg_output.png insilmaril@269: fo->setName("info"); insilmaril@366: a=new QAction (fo->getPixmap(),fo->getName(),this); insilmaril@366: tb->addAction (a); insilmaril@366: fo->setAction (a); insilmaril@366: a->setCheckable(true); insilmaril@366: a->setObjectName(fo->getName()); insilmaril@366: a->setToolTip(tr("Info","Standardflag")); insilmaril@366: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@269: standardFlagsDefault->addFlag (fo); insilmaril@269: insilmaril@408: fo->load(flagsPath+"flag-lifebelt.png"); insilmaril@269: // Original khelpcenter.png insilmaril@166: fo->setName("lifebelt"); insilmaril@366: a=new QAction (fo->getPixmap(),fo->getName(),this); insilmaril@366: tb->addAction (a); insilmaril@366: fo->setAction (a); insilmaril@366: a->setCheckable(true); insilmaril@366: a->setObjectName(fo->getName()); insilmaril@366: a->setToolTip(tr("This will help","Standardflag")); insilmaril@366: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@166: standardFlagsDefault->addFlag (fo); insilmaril@243: insilmaril@166: delete (fo); insilmaril@0: } insilmaril@0: insilmaril@0: // Settings Actions insilmaril@0: void Main::setupSettingsActions() insilmaril@0: { insilmaril@366: QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" )); insilmaril@0: insilmaril@0: QAction *a; insilmaril@0: insilmaril@395: a = new QAction( tr( "Set application to open pdf files","Settings action"), this); insilmaril@366: a->setStatusTip ( tr( "Set application to open pdf files")); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) ); insilmaril@366: settingsMenu->addAction (a); insilmaril@366: insilmaril@395: a = new QAction( tr( "Set application to open external links","Settings action"), this); insilmaril@366: a->setStatusTip( tr( "Set application to open external links")); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) ); insilmaril@366: settingsMenu->addAction (a); insilmaril@366: insilmaril@366: settingsMenu->addSeparator(); insilmaril@395: a = new QAction( tr( "Edit branch after adding it","Settings action" ), this ); insilmaril@366: a->setStatusTip( tr( "Edit branch after adding it" )); insilmaril@0: a->setToggleAction(true); insilmaril@366: a->setOn ( settings.value ("/mapeditor/editmode/autoEdit",true).toBool()); insilmaril@366: settingsMenu->addAction (a); insilmaril@390: actionSettingsAutoEdit=a; insilmaril@0: insilmaril@395: a= new QAction( tr( "Select branch after adding it","Settings action" ), this ); insilmaril@366: a->setStatusTip( tr( "Select branch after adding it" )); insilmaril@0: a->setToggleAction(true); insilmaril@366: a->setOn ( settings.value ("/mapeditor/editmode/autoSelectHeading",false).toBool() ); insilmaril@366: settingsMenu->addAction (a); insilmaril@390: actionSettingsAutoSelectHeading=a; insilmaril@0: insilmaril@395: a= new QAction(tr( "Select existing heading","Settings action" ), this); insilmaril@366: a->setStatusTip( tr( "Select heading before editing" )); insilmaril@0: a->setToggleAction(true); insilmaril@366: a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() ); insilmaril@366: settingsMenu->addAction (a); insilmaril@390: actionSettingsAutoSelectText=a; insilmaril@0: insilmaril@395: a= new QAction( tr( "Delete key","Settings action" ), this); insilmaril@366: a->setStatusTip( tr( "Delete key for deleting branches" )); insilmaril@0: a->setToggleAction(true); insilmaril@366: a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",false).toBool() ); insilmaril@366: settingsMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) ); insilmaril@366: actionSettingsUseDelKey=a; insilmaril@366: insilmaril@395: a= new QAction( tr( "Exclusive flags","Settings action" ), this); insilmaril@366: a->setStatusTip( tr( "Use exclusive flags in flag toolbars" )); insilmaril@0: a->setToggleAction(true); insilmaril@366: a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() ); insilmaril@366: settingsMenu->addAction (a); insilmaril@103: actionSettingsUseFlagGroups=a; insilmaril@260: insilmaril@395: a= new QAction( tr( "Use hide flags","Settings action" ), this); insilmaril@366: a->setStatusTip( tr( "Use hide flag during exports " )); insilmaril@260: a->setToggleAction(true); insilmaril@366: a->setOn ( settings.value ("/export/useHideExport",true).toBool() ); insilmaril@366: settingsMenu->addAction (a); insilmaril@260: actionSettingsUseHideExport=a; insilmaril@0: } insilmaril@0: insilmaril@0: // Test Actions insilmaril@0: void Main::setupTestActions() insilmaril@0: { insilmaril@366: QMenu *testMenu = menuBar()->addMenu( tr( "&Test" )); insilmaril@0: insilmaril@0: QAction *a; insilmaril@395: a = new QAction( "Test function" , this); insilmaril@395: a->setStatusTip( "Call test function" ); insilmaril@393: a->setShortcut (Qt::Key_F4 ); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( testFunction() ) ); insilmaril@366: testMenu->addAction (a); insilmaril@395: a = new QAction( "Command" , this); insilmaril@395: a->setStatusTip( "Enter command to call in editor" ); insilmaril@393: a->setShortcut (Qt::Key_F5 ); insilmaril@393: connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) ); insilmaril@393: testMenu->addAction (a); insilmaril@0: } insilmaril@0: insilmaril@0: // Help Actions insilmaril@0: void Main::setupHelpActions() insilmaril@0: { insilmaril@395: QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" )); insilmaril@0: insilmaril@0: QAction *a; insilmaril@395: a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this ); insilmaril@366: a->setStatusTip( tr( "Open VYM Documentation (pdf)" )); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) ); insilmaril@366: helpMenu->addAction (a); insilmaril@366: insilmaril@395: a = new QAction( tr( "About VYM","Help action" ), this); insilmaril@404: a->setStatusTip( tr( "About VYM")+vymName); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) ); insilmaril@366: helpMenu->addAction (a); insilmaril@366: insilmaril@395: a = new QAction( tr( "About QT","Help action" ), this); insilmaril@366: a->setStatusTip( tr( "Information about QT toolkit" )); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) ); insilmaril@366: 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@366: branchContextMenu =new QMenu (this); insilmaril@98: insilmaril@98: // Submenu "Add" insilmaril@366: branchAddContextMenu =branchContextMenu->addMenu (tr("Add")); insilmaril@366: branchAddContextMenu->addAction (actionEditPaste ); insilmaril@366: branchAddContextMenu->addAction ( actionEditAddBranch ); insilmaril@394: branchAddContextMenu->addAction ( actionEditAddBranchBefore ); insilmaril@366: branchAddContextMenu->addAction ( actionEditAddBranchAbove); insilmaril@366: branchAddContextMenu->addAction ( actionEditAddBranchBelow ); insilmaril@366: branchAddContextMenu->addSeparator(); insilmaril@366: branchAddContextMenu->addAction ( actionEditImportAdd ); insilmaril@366: branchAddContextMenu->addAction ( actionEditImportReplace ); insilmaril@98: insilmaril@98: // Submenu "Remove" insilmaril@395: branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name")); insilmaril@366: branchRemoveContextMenu->addAction (actionEditCut); insilmaril@366: branchRemoveContextMenu->addAction ( actionEditDelete ); insilmaril@395: branchRemoveContextMenu->addAction ( actionEditDeleteKeepChilds ); insilmaril@395: branchRemoveContextMenu->addAction ( actionEditDeleteChilds ); insilmaril@98: insilmaril@98: insilmaril@0: actionEditSaveBranch->addTo( branchContextMenu ); insilmaril@98: insilmaril@366: branchContextMenu->addSeparator(); insilmaril@366: branchContextMenu->addAction ( actionFormatFrameNone ); insilmaril@366: branchContextMenu->addAction ( actionFormatFrameRectangle); insilmaril@398: branchContextMenu->addAction ( actionFormatHideLinkUnselected ); insilmaril@366: insilmaril@366: branchContextMenu->addSeparator(); insilmaril@398: branchContextMenu->addAction ( actionEditLoadImage); insilmaril@366: branchContextMenu->addAction ( actionFormatIncludeImagesVer ); insilmaril@366: branchContextMenu->addAction ( actionFormatIncludeImagesHor ); insilmaril@366: insilmaril@366: // Submenu for Links (URLs, vymLinks) insilmaril@366: branchLinksContextMenu =new QMenu (this); insilmaril@366: insilmaril@366: branchContextMenu->addSeparator(); insilmaril@395: branchLinksContextMenu=branchContextMenu->addMenu(tr("URLs and vymLinks","Context menu name")); insilmaril@366: branchLinksContextMenu->addAction ( actionEditOpenURL ); insilmaril@366: branchLinksContextMenu->addAction ( actionEditOpenURLTab ); insilmaril@366: branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs ); insilmaril@366: branchLinksContextMenu->addAction ( actionEditURL ); insilmaril@366: branchLinksContextMenu->addAction ( actionEditHeading2URL ); insilmaril@366: branchLinksContextMenu->addAction ( actionEditBugzilla2URL ); insilmaril@366: if (settings.value( "/mainwindow/showTestMenu",true).toBool() ) insilmaril@366: { insilmaril@366: branchLinksContextMenu->addAction ( actionEditFATE2URL ); insilmaril@366: } insilmaril@366: branchLinksContextMenu->addSeparator(); insilmaril@366: branchLinksContextMenu->addAction ( actionEditOpenVymLink ); insilmaril@366: branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks ); insilmaril@366: branchLinksContextMenu->addAction ( actionEditVymLink ); insilmaril@366: branchLinksContextMenu->addAction ( actionEditDeleteVymLink ); insilmaril@366: insilmaril@366: insilmaril@366: // Context Menu for XLinks in a branch menu insilmaril@89: // This will be populated "on demand" in MapEditor::updateActions insilmaril@366: branchContextMenu->addSeparator(); insilmaril@395: branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name")); insilmaril@395: branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name")); insilmaril@366: connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) ); insilmaril@366: connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) ); insilmaril@366: insilmaril@105: insilmaril@0: // Context menu for floatimage insilmaril@366: floatimageContextMenu =new QMenu (this); insilmaril@395: a= new QAction (tr ("Save image","Context action"),this); insilmaril@366: connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage())); insilmaril@366: floatimageContextMenu->addAction (a); insilmaril@366: insilmaril@366: floatimageContextMenu->addSeparator(); insilmaril@0: actionEditCopy->addTo( floatimageContextMenu ); insilmaril@0: actionEditCut->addTo( floatimageContextMenu ); insilmaril@0: insilmaril@366: floatimageContextMenu->addSeparator(); insilmaril@366: floatimageContextMenu->addAction ( actionFormatHideLinkUnselected ); insilmaril@366: insilmaril@0: insilmaril@0: // Context menu for canvas insilmaril@366: 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@408: actionFormatBackImage->addTo( canvasContextMenu ); insilmaril@0: insilmaril@0: // Menu for last opened files insilmaril@401: // Create actions insilmaril@401: for (int i = 0; i < MaxRecentFiles; ++i) insilmaril@0: { insilmaril@401: recentFileActs[i] = new QAction(this); insilmaril@401: recentFileActs[i]->setVisible(false); insilmaril@401: fileLastMapsMenu->addAction(recentFileActs[i]); insilmaril@401: connect(recentFileActs[i], SIGNAL(triggered()), insilmaril@401: this, SLOT(fileLoadRecent())); insilmaril@401: } insilmaril@401: setupRecentMapsMenu(); insilmaril@0: } insilmaril@0: insilmaril@401: void Main::setupRecentMapsMenu() insilmaril@0: { insilmaril@401: QStringList files = settings.value("/mainwindow/recentFileList").toStringList(); insilmaril@401: insilmaril@401: int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles); insilmaril@401: insilmaril@401: for (int i = 0; i < numRecentFiles; ++i) { insilmaril@401: //QString text = tr("&%1 %2").arg(i + 1).arg(strippedName(files[i])); insilmaril@401: QString text = tr("&%1 %2").arg(i + 1).arg(files[i]); insilmaril@401: recentFileActs[i]->setText(text); insilmaril@401: recentFileActs[i]->setData(files[i]); insilmaril@401: recentFileActs[i]->setVisible(true); insilmaril@401: } insilmaril@401: for (int j = numRecentFiles; j < MaxRecentFiles; ++j) insilmaril@401: recentFileActs[j]->setVisible(false); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::hideEvent (QHideEvent * ) insilmaril@0: { insilmaril@0: if (!textEditor->isMinimized() ) textEditor->hide(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::showEvent (QShowEvent * ) insilmaril@0: { insilmaril@117: if (textEditor->showWithMain()) textEditor->showNormal(); insilmaril@0: } insilmaril@0: insilmaril@0: bool Main::reallyWriteDirectory(const QString &dir) insilmaril@0: { insilmaril@0: QStringList eList = QDir(dir).entryList(); insilmaril@0: if (eList.first() ==".") eList.pop_front(); // remove "." insilmaril@0: if (eList.first() =="..") eList.pop_front(); // remove "." insilmaril@0: if (!eList.isEmpty()) insilmaril@0: { insilmaril@404: QMessageBox mb( vymName, insilmaril@395: tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?","write directory").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@404: QFileDialog fd(this,caption); insilmaril@404: fd.setMode (QFileDialog::DirectoryOnly); insilmaril@404: fd.setCaption(vymName+ " - "+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: 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@407: updateActions(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::fileNew() insilmaril@0: { insilmaril@0: QString fn="unnamed"; insilmaril@408: MapEditor* me = new MapEditor ( NULL); insilmaril@408: tabWidget->addTab (me,fn); insilmaril@408: tabWidget->showPage(me); insilmaril@408: me->viewport()->setFocus(); insilmaril@408: me->setAntiAlias (actionViewToggleAntiAlias->isOn()); insilmaril@408: me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn()); insilmaril@408: insilmaril@366: // For the very first map we do not have flagrows yet... insilmaril@408: me->select("mc:"); insilmaril@0: } insilmaril@0: insilmaril@205: ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode) insilmaril@0: { insilmaril@205: ErrorCode err=success; insilmaril@0: insilmaril@0: // fn is usually the archive, mapfile the file after uncompressing insilmaril@0: QString mapfile; insilmaril@0: insilmaril@0: // Make fn absolute (needed for unzip) insilmaril@0: fn=QDir (fn).absPath(); insilmaril@0: insilmaril@0: MapEditor *me; insilmaril@0: insilmaril@0: if (lmode==NewMap) insilmaril@0: { insilmaril@0: // Check, if map is already loaded insilmaril@0: int i=0; insilmaril@0: while (i<=tabWidget->count() -1) insilmaril@0: { insilmaril@0: me=(MapEditor*)tabWidget->page(i); insilmaril@0: if (me->getFilePath() == fn) insilmaril@0: { insilmaril@0: // Already there, ask for confirmation insilmaril@404: QMessageBox mb( vymName, insilmaril@159: tr("The map %1\nis already opened." insilmaril@0: "Opening the same map in multiple editors may lead \n" insilmaril@0: "to confusion when finishing working with vym." insilmaril@159: "Do you want to").arg(fn), insilmaril@0: QMessageBox::Warning, insilmaril@0: QMessageBox::Yes | QMessageBox::Default, insilmaril@0: QMessageBox::Cancel | QMessageBox::Escape, insilmaril@366: QMessageBox::NoButton); insilmaril@0: mb.setButtonText( QMessageBox::Yes, tr("Open anyway") ); insilmaril@0: mb.setButtonText( QMessageBox::Cancel, tr("Cancel")); insilmaril@0: switch( mb.exec() ) insilmaril@0: { insilmaril@0: case QMessageBox::Yes: insilmaril@0: // load anyway insilmaril@0: i=tabWidget->count(); insilmaril@0: break; insilmaril@0: case QMessageBox::Cancel: insilmaril@0: // do nothing insilmaril@205: return aborted; insilmaril@0: break; insilmaril@0: } insilmaril@0: } insilmaril@0: i++; insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@0: insilmaril@0: // Try to load map insilmaril@0: if ( !fn.isEmpty() ) insilmaril@0: { insilmaril@0: me = currentMapEditor(); insilmaril@0: int tabIndex=tabWidget->currentPageIndex(); insilmaril@0: // Check first, if mapeditor exists insilmaril@0: // If it is not default AND we want a new map, insilmaril@0: // create a new mapeditor in a new tab insilmaril@0: if ( lmode==NewMap && (!me || !me->isDefault() ) ) insilmaril@0: { insilmaril@390: me= new MapEditor ( NULL); insilmaril@0: tabWidget->addTab (me,fn); insilmaril@0: tabIndex=tabWidget->indexOf (me); insilmaril@0: tabWidget->setCurrentPage (tabIndex); insilmaril@408: me->setAntiAlias (actionViewToggleAntiAlias->isOn()); insilmaril@408: me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn()); 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@404: QMessageBox mb( vymName, insilmaril@159: tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn), insilmaril@0: QMessageBox::Question, insilmaril@0: QMessageBox::Yes , insilmaril@0: QMessageBox::Cancel | QMessageBox::Default, insilmaril@366: QMessageBox::NoButton ); insilmaril@0: insilmaril@0: mb.setButtonText( QMessageBox::Yes, tr("Create")); insilmaril@0: mb.setButtonText( QMessageBox::No, tr("Cancel")); insilmaril@0: switch( mb.exec() ) insilmaril@0: { insilmaril@0: case QMessageBox::Yes: insilmaril@0: // Create new map insilmaril@0: currentMapEditor()->setFilePath(fn); insilmaril@0: tabWidget->setTabLabel (currentMapEditor(), insilmaril@0: currentMapEditor()->getFileName() ); insilmaril@0: statusBar()->message( "Created " + fn , statusbarTime ); insilmaril@205: return success; insilmaril@0: insilmaril@0: case QMessageBox::Cancel: insilmaril@0: // don't create new map insilmaril@0: statusBar()->message( "Loading " + fn + " failed!", statusbarTime ); insilmaril@0: fileCloseMap(); insilmaril@205: return aborted; insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@0: insilmaril@0: //tabWidget->currentPage() won't be NULL here, because of above... insilmaril@0: tabWidget->showPage(me); insilmaril@0: me->viewport()->setFocus(); insilmaril@0: insilmaril@0: // Create temporary directory for packing insilmaril@377: bool ok; insilmaril@377: QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX"); insilmaril@377: if (!ok) insilmaril@377: { insilmaril@377: QMessageBox::critical( 0, tr( "Critical Load Error" ), insilmaril@377: tr("Couldn't create temporary directory before load\n")); insilmaril@377: return aborted; insilmaril@377: } insilmaril@0: insilmaril@0: // Try to unzip file insilmaril@185: err=unzipDir (tmpMapDir,fn); insilmaril@185: if (err==nozip) insilmaril@0: { insilmaril@185: mapfile=fn; insilmaril@185: me->setZipped(false); insilmaril@0: } else insilmaril@0: { insilmaril@185: me->setZipped(true); insilmaril@185: insilmaril@185: // Look for mapname.xml insilmaril@185: mapfile= fn.left(fn.findRev(".",-1,true)); insilmaril@185: mapfile=mapfile.section( '/', -1 ); insilmaril@185: QFile file( tmpMapDir + "/" + mapfile + ".xml"); insilmaril@185: if (!file.exists() ) insilmaril@0: { insilmaril@185: // mapname.xml does not exist, well, insilmaril@185: // maybe some renamed the mapname.vym file... insilmaril@185: // Try to find any .xml in the toplevel insilmaril@185: // directory of the .vym file insilmaril@185: QStringList flist=QDir (tmpMapDir).entryList("*.xml"); insilmaril@185: if (flist.count()==1) insilmaril@0: { insilmaril@185: // Only one entry, take this one insilmaril@185: mapfile=tmpMapDir + "/"+flist.first(); insilmaril@0: } else insilmaril@185: { insilmaril@185: for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it ) insilmaril@185: *it=tmpMapDir + "/" + *it; insilmaril@185: // TODO Multiple entries, load all (but only the first one into this ME) insilmaril@185: //mainWindow->fileLoadFromTmp (flist); insilmaril@185: //returnCode=1; // Silently forget this attempt to load insilmaril@185: qWarning ("MainWindow::load (fn) multimap found..."); insilmaril@185: } insilmaril@0: insilmaril@185: if (flist.isEmpty() ) insilmaril@185: { insilmaril@185: QMessageBox::critical( 0, tr( "Critical Load Error" ), insilmaril@185: tr("Couldn't find a map (*.xml) in .vym archive.\n")); insilmaril@185: err=aborted; insilmaril@185: } insilmaril@185: } //file doesn't exist insilmaril@185: else insilmaril@185: mapfile=file.name(); insilmaril@0: } insilmaril@0: insilmaril@185: if (err!=aborted) insilmaril@185: { insilmaril@185: // Save existing filename in case we import insilmaril@185: QString fn_org=me->getFilePath(); insilmaril@106: insilmaril@185: // Finally load map into mapEditor insilmaril@185: me->setFilePath (mapfile,fn); insilmaril@205: err=me->load(mapfile,lmode); insilmaril@106: insilmaril@185: // Restore old (maybe empty) filepath, if this is an import insilmaril@185: if (lmode!=NewMap) insilmaril@185: me->setFilePath (fn_org); insilmaril@185: } insilmaril@0: insilmaril@185: // Finally check for errors and go home insilmaril@185: if (err==aborted) insilmaril@185: { insilmaril@185: if (lmode==NewMap) fileCloseMap(); insilmaril@185: statusBar()->message( "Could not load " + fn, statusbarTime ); insilmaril@185: } else insilmaril@0: { insilmaril@0: if (lmode==NewMap) insilmaril@0: { insilmaril@0: me->setFilePath (fn); insilmaril@0: tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName()); insilmaril@205: if (fn.left(9)!="/tmp/vym-") insilmaril@205: { insilmaril@205: // Only append to lastMaps if not loaded from a tmpDir insilmaril@205: // e.g. imported bookmarks are in a tmpDir insilmaril@401: addRecentMap(me->getFilePath() ); insilmaril@205: } insilmaril@0: actionFilePrint->setEnabled (true); insilmaril@0: } insilmaril@0: statusBar()->message( "Loaded " + fn, statusbarTime ); insilmaril@0: } insilmaril@0: insilmaril@185: // Delete tmpDir insilmaril@185: removeDir (QDir(tmpMapDir)); insilmaril@0: } insilmaril@205: return err; insilmaril@0: } insilmaril@0: insilmaril@0: insilmaril@0: void Main::fileLoad(const LoadMode &lmode) insilmaril@0: { insilmaril@377: QStringList filters; insilmaril@389: filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)"; insilmaril@377: QFileDialog *fd=new QFileDialog( this); insilmaril@366: fd->setDir (lastFileDir); insilmaril@377: fd->setFileMode (QFileDialog::ExistingFiles); insilmaril@377: fd->setFilters (filters); insilmaril@0: switch (lmode) insilmaril@0: { insilmaril@0: case NewMap: insilmaril@404: fd->setCaption(vymName+ " - " +tr("Load vym map")); insilmaril@0: break; insilmaril@0: case ImportAdd: insilmaril@404: fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection")); insilmaril@0: break; insilmaril@0: case ImportReplace: insilmaril@404: fd->setCaption(vymName+ " - " +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@377: lastFileDir=fd->directory().path(); insilmaril@185: QStringList flist = fd->selectedFiles(); insilmaril@185: QStringList::Iterator it = flist.begin(); insilmaril@185: while( it != flist.end() ) insilmaril@185: { insilmaril@185: fn = *it; insilmaril@185: fileLoad(*it, lmode); insilmaril@185: ++it; insilmaril@185: } insilmaril@0: } insilmaril@185: delete (fd); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::fileLoad() insilmaril@0: { insilmaril@0: fileLoad (NewMap); insilmaril@0: } insilmaril@0: insilmaril@401: void Main::fileLoadRecent() insilmaril@0: { insilmaril@401: QAction *action = qobject_cast(sender()); insilmaril@401: if (action) insilmaril@401: fileLoad (action->data().toString(), NewMap); insilmaril@401: } insilmaril@401: insilmaril@401: void Main::addRecentMap (const QString &fileName) insilmaril@401: { insilmaril@401: insilmaril@401: QStringList files = settings.value("/mainwindow/recentFileList").toStringList(); insilmaril@401: files.removeAll(fileName); insilmaril@401: files.prepend(fileName); insilmaril@401: while (files.size() > MaxRecentFiles) insilmaril@401: files.removeLast(); insilmaril@401: insilmaril@401: settings.setValue("/mainwindow/recentFileList", files); insilmaril@401: insilmaril@401: setupRecentMapsMenu(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::fileSave(const SaveMode &savemode) insilmaril@0: { insilmaril@0: // tmp dir for zipping insilmaril@0: QString tmpMapDir; insilmaril@0: insilmaril@0: // Error codes insilmaril@205: ErrorCode err=success; insilmaril@0: insilmaril@0: QString safeFilePath; insilmaril@0: insilmaril@0: bool saveZipped=currentMapEditor()->saveZipped(); insilmaril@0: insilmaril@151: MapEditor * me=currentMapEditor(); insilmaril@151: if (me) insilmaril@0: { insilmaril@151: QString fn=me->getFilePath(); insilmaril@0: // filename=unnamed, filepath="" in constructor... insilmaril@0: if ( !fn.isEmpty() ) insilmaril@0: { insilmaril@0: // We have a filepath, go on saving insilmaril@0: // First remove existing file, we insilmaril@0: // don't want to add to old zip archives insilmaril@0: QFile f(fn); insilmaril@0: if (f.exists() ) insilmaril@0: if (!f.remove()) insilmaril@0: QMessageBox::warning( 0, tr( "Save Error" ), insilmaril@0: fn+ tr("\ncould not be removed before saving")); insilmaril@0: insilmaril@0: // Look, if we should zip the data: insilmaril@0: if (!saveZipped) insilmaril@0: { insilmaril@404: QMessageBox mb( vymName, insilmaril@159: tr("The map %1\ndid not use the compressed " insilmaril@0: "vym file format.\nWriting it uncompressed will also write images \n" insilmaril@0: "and flags and thus may overwrite files in the " insilmaril@159: "given directory\n\nDo you want to write the map").arg(fn), insilmaril@0: QMessageBox::Warning, insilmaril@0: QMessageBox::Yes | QMessageBox::Default, insilmaril@0: QMessageBox::No , insilmaril@0: QMessageBox::Cancel | QMessageBox::Escape); insilmaril@0: mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") ); insilmaril@0: mb.setButtonText( QMessageBox::No, tr("uncompressed") ); insilmaril@0: mb.setButtonText( QMessageBox::Cancel, tr("Cancel")); insilmaril@0: switch( mb.exec() ) insilmaril@0: { insilmaril@0: case QMessageBox::Yes: insilmaril@0: // save compressed (default file format) insilmaril@0: saveZipped=true; insilmaril@0: break; insilmaril@0: case QMessageBox::No: insilmaril@0: // save uncompressed insilmaril@0: saveZipped=false; insilmaril@0: break; insilmaril@0: case QMessageBox::Cancel: insilmaril@0: // do nothing insilmaril@0: return; insilmaril@0: break; insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@0: if (saveZipped) insilmaril@0: { insilmaril@377: // Create temporary directory for packing insilmaril@377: bool ok; insilmaril@377: QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX"); insilmaril@377: if (!ok) insilmaril@377: { insilmaril@377: QMessageBox::critical( 0, tr( "Critical Load Error" ), insilmaril@377: tr("Couldn't create temporary directory before save\n")); insilmaril@377: return; insilmaril@377: } insilmaril@377: insilmaril@151: safeFilePath=me->getFilePath(); insilmaril@151: me->setFilePath (tmpMapDir+"/"+ insilmaril@151: me->getMapName()+ ".xml", insilmaril@0: safeFilePath); insilmaril@151: me->save (savemode); insilmaril@151: me->setFilePath (safeFilePath); insilmaril@0: insilmaril@175: zipDir (tmpMapDir,fn); insilmaril@0: } // save zipped insilmaril@0: else insilmaril@0: { insilmaril@0: // Save unzipped. insilmaril@151: safeFilePath=me->getFilePath(); insilmaril@151: me->setFilePath (fn, safeFilePath); insilmaril@151: me->save (savemode); insilmaril@151: me->setFilePath (safeFilePath); insilmaril@0: } // save zipped insilmaril@0: } // filepath available insilmaril@0: else insilmaril@0: { insilmaril@0: // We have no filepath yet, insilmaril@0: // call fileSaveAs() now, this will call fileSave() insilmaril@0: // again. insilmaril@0: fileSaveAs(savemode); insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@250: if (saveZipped && !tmpMapDir.isEmpty()) insilmaril@0: // Delete tmpDir insilmaril@175: removeDir (QDir(tmpMapDir)); insilmaril@0: insilmaril@0: if (err==success) insilmaril@151: { insilmaril@0: statusBar()->message( insilmaril@159: tr("Saved %1").arg(me->getFilePath()), insilmaril@0: statusbarTime ); insilmaril@401: addRecentMap (me->getFilePath() ); insilmaril@151: } else insilmaril@0: statusBar()->message( insilmaril@159: tr("Couldn't save ").arg(me->getFilePath()), insilmaril@0: statusbarTime ); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::fileSave() insilmaril@0: { insilmaril@0: fileSave (CompleteMap); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::fileSaveAs(const SaveMode& savemode) insilmaril@0: { insilmaril@0: QString fn; insilmaril@0: insilmaril@0: if (currentMapEditor()) insilmaril@0: { insilmaril@0: if (savemode==CompleteMap) insilmaril@366: fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this ); insilmaril@0: else insilmaril@366: 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@404: QMessageBox mb( vymName, insilmaril@159: tr("The file %1\nexists already. Do you want to").arg(fn), insilmaril@0: QMessageBox::Warning, insilmaril@0: QMessageBox::Yes | QMessageBox::Default, insilmaril@0: QMessageBox::Cancel | QMessageBox::Escape, insilmaril@366: QMessageBox::NoButton); insilmaril@0: mb.setButtonText( QMessageBox::Yes, tr("Overwrite") ); insilmaril@0: mb.setButtonText( QMessageBox::Cancel, tr("Cancel")); insilmaril@0: switch( mb.exec() ) insilmaril@0: { insilmaril@0: case QMessageBox::Yes: insilmaril@0: // save insilmaril@0: break; insilmaril@0: case QMessageBox::Cancel: insilmaril@0: // do nothing insilmaril@0: return; insilmaril@0: break; insilmaril@0: } insilmaril@0: } else insilmaril@0: { insilmaril@0: // New file, add extension to filename, if missing insilmaril@0: // This is always .vym or .vyp, depending on savemode insilmaril@0: if (savemode==CompleteMap) insilmaril@0: { insilmaril@0: if (!fn.contains (".vym") && !fn.contains (".xml")) insilmaril@0: fn +=".vym"; insilmaril@0: } else insilmaril@0: { insilmaril@0: if (!fn.contains (".vyp") && !fn.contains (".xml")) insilmaril@0: fn +=".vyp"; insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@0: insilmaril@0: insilmaril@0: insilmaril@0: // Save now insilmaril@0: currentMapEditor()->setFilePath(fn); insilmaril@0: fileSave(savemode); insilmaril@0: insilmaril@0: // Set name of tab insilmaril@94: if (savemode==CompleteMap) insilmaril@94: tabWidget->setTabLabel (currentMapEditor(), insilmaril@94: currentMapEditor()->getFileName() ); insilmaril@0: return; insilmaril@0: } insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@0: void Main::fileSaveAs() insilmaril@0: { insilmaril@0: fileSaveAs (CompleteMap); insilmaril@0: } insilmaril@0: insilmaril@205: void Main::fileImportKDEBookmarks() insilmaril@205: { insilmaril@205: ImportKDEBookmarks im; insilmaril@205: im.transform(); insilmaril@205: if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() ) insilmaril@205: currentMapEditor()->setFilePath (""); insilmaril@205: } insilmaril@205: insilmaril@314: void Main::fileImportFirefoxBookmarks() insilmaril@314: { insilmaril@366: Q3FileDialog *fd=new Q3FileDialog( this); insilmaril@327: fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox"); insilmaril@366: fd->setMode (Q3FileDialog::ExistingFiles); insilmaril@327: fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)"); insilmaril@327: fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks")); insilmaril@327: fd->show(); insilmaril@327: insilmaril@327: if ( fd->exec() == QDialog::Accepted ) insilmaril@327: { insilmaril@327: ImportFirefoxBookmarks im; insilmaril@327: QStringList flist = fd->selectedFiles(); insilmaril@327: QStringList::Iterator it = flist.begin(); insilmaril@327: while( it != flist.end() ) insilmaril@327: { insilmaril@327: im.setFile (*it); insilmaril@327: if (im.transform() && insilmaril@327: success==fileLoad (im.getTransformedFile(),NewMap) && insilmaril@327: currentMapEditor() ) insilmaril@327: currentMapEditor()->setFilePath (""); insilmaril@327: ++it; insilmaril@327: } insilmaril@327: } insilmaril@327: delete (fd); insilmaril@314: } insilmaril@314: insilmaril@215: void Main::fileImportMM() insilmaril@215: { insilmaril@215: ImportMM im; insilmaril@215: insilmaril@366: Q3FileDialog *fd=new Q3FileDialog( this); insilmaril@366: fd->setDir (lastFileDir); insilmaril@366: fd->setMode (Q3FileDialog::ExistingFiles); insilmaril@215: fd->addFilter ("Mind Manager (*.mmap)"); insilmaril@215: fd->setCaption(tr("Import")+" "+"Mind Manager"); insilmaril@215: fd->show(); insilmaril@215: insilmaril@215: if ( fd->exec() == QDialog::Accepted ) insilmaril@215: { insilmaril@215: lastFileDir=fd->dirPath(); insilmaril@215: QStringList flist = fd->selectedFiles(); insilmaril@215: QStringList::Iterator it = flist.begin(); insilmaril@215: while( it != flist.end() ) insilmaril@215: { insilmaril@215: im.setFile (*it); insilmaril@215: if (im.transform() && insilmaril@215: success==fileLoad (im.getTransformedFile(),NewMap) && insilmaril@215: currentMapEditor() ) insilmaril@215: currentMapEditor()->setFilePath (""); insilmaril@215: insilmaril@215: ++it; insilmaril@215: } insilmaril@215: } insilmaril@215: delete (fd); insilmaril@215: insilmaril@215: } insilmaril@215: insilmaril@215: void Main::fileImportDir() insilmaril@215: { insilmaril@215: if (currentMapEditor()) insilmaril@215: currentMapEditor()->importDir(); insilmaril@215: } insilmaril@215: insilmaril@0: void Main::fileExportXML() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: { insilmaril@0: QString dir=browseDirectory(tr("Export XML to directory")); insilmaril@0: if (dir !="" && reallyWriteDirectory(dir) ) insilmaril@0: currentMapEditor()->exportXML(dir); insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@0: insilmaril@0: void Main::fileExportXHTML() insilmaril@0: { insilmaril@260: MapEditor *me=currentMapEditor(); insilmaril@0: QString dir; insilmaril@260: if (me) insilmaril@0: { insilmaril@0: ExportXHTMLDialog dia(this); insilmaril@260: dia.setFilePath (me->getFilePath() ); insilmaril@260: dia.setMapName (me->getMapName() ); insilmaril@0: dia.readSettings(); insilmaril@0: insilmaril@0: if (dia.exec()==QDialog::Accepted) insilmaril@0: { insilmaril@0: QString dir=dia.getDir(); insilmaril@0: // Check, if warnings should be used before overwriting insilmaril@0: // the output directory insilmaril@0: bool ok; insilmaril@0: if (dia.warnings()) insilmaril@0: ok=reallyWriteDirectory(dir); insilmaril@0: else insilmaril@0: ok=true; insilmaril@0: insilmaril@0: if (ok) insilmaril@0: { insilmaril@260: me->exportXML (dia.getDir() ); insilmaril@260: dia.doExport(me->getMapName() ); insilmaril@0: if (dia.hasChanged()) insilmaril@260: me->setChanged(); insilmaril@0: } insilmaril@0: } insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@366: void Main::fileExportImage() insilmaril@0: { insilmaril@260: MapEditor *me=currentMapEditor(); insilmaril@260: if (me) insilmaril@0: { insilmaril@366: QStringList fl; insilmaril@366: QFileDialog *fd=new QFileDialog (this); insilmaril@366: fd->setCaption (tr("Export map as image")); insilmaril@366: fd->setFileMode(QFileDialog::AnyFile); insilmaril@366: fd->setFilters (imageIO.getFilters() ); insilmaril@366: fd->setDirectory (lastImageDir); insilmaril@366: if (fd->exec()) insilmaril@366: { insilmaril@366: fl=fd->selectedFiles(); insilmaril@366: qWarning ("Selected "+fl.first()+" filter: "+fd->selectedFilter()); insilmaril@366: me->exportImage (fl.first(), imageIO.getType (fd->selectedFilter() ) ); insilmaril@366: } insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@0: void Main::fileExportASCII() insilmaril@0: { insilmaril@260: MapEditor *me=currentMapEditor(); insilmaril@260: if (me) insilmaril@228: { insilmaril@228: ExportASCII ex; insilmaril@260: ex.setMapCenter(me->getMapCenter()); insilmaril@228: ex.addFilter ("TXT (*.txt)"); insilmaril@404: ex.setCaption(vymName+ " -" +tr("Export as ASCII")+" "+tr("(still experimental)")); insilmaril@260: if (ex.execDialog() ) insilmaril@260: { insilmaril@260: me->setExportMode(true); insilmaril@260: ex.doExport(); insilmaril@260: me->setExportMode(false); insilmaril@260: } insilmaril@228: } insilmaril@0: } insilmaril@0: insilmaril@163: void Main::fileExportLaTeX() insilmaril@163: { insilmaril@260: MapEditor *me=currentMapEditor(); insilmaril@260: if (me) insilmaril@228: { insilmaril@228: ExportLaTeX ex; insilmaril@260: ex.setMapCenter(me->getMapCenter()); insilmaril@228: ex.addFilter ("Tex (*.tex)"); insilmaril@404: ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)")); insilmaril@260: if (ex.execDialog() ) insilmaril@260: { insilmaril@260: me->setExportMode(true); insilmaril@260: ex.doExport(); insilmaril@260: me->setExportMode(false); insilmaril@260: } insilmaril@228: } insilmaril@228: } insilmaril@228: insilmaril@243: void Main::fileExportKDEBookmarks() insilmaril@243: { insilmaril@243: ExportKDEBookmarks ex; insilmaril@260: MapEditor *me=currentMapEditor(); insilmaril@260: if (me) insilmaril@243: { insilmaril@260: ex.setMapCenter (me->getMapCenter() ); insilmaril@243: ex.doExport(); insilmaril@243: } insilmaril@243: } insilmaril@243: insilmaril@228: void Main::fileExportTaskjuggler() insilmaril@228: { insilmaril@228: ExportTaskjuggler ex; insilmaril@260: MapEditor *me=currentMapEditor(); insilmaril@260: if (me) insilmaril@228: { insilmaril@260: ex.setMapCenter (me->getMapCenter() ); insilmaril@404: ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)")); insilmaril@243: ex.addFilter ("Taskjuggler (*.tjp)"); insilmaril@260: if (ex.execDialog() ) insilmaril@260: { insilmaril@260: me->setExportMode(true); insilmaril@260: ex.doExport(); insilmaril@260: me->setExportMode(false); insilmaril@260: } insilmaril@228: } insilmaril@163: } insilmaril@163: insilmaril@163: void Main::fileExportOOPresentation() insilmaril@163: { insilmaril@404: ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office"); insilmaril@366: // TODO add preview in dialog insilmaril@185: //ImagePreview *p =new ImagePreview (fd); insilmaril@185: //fd->setContentsPreviewEnabled( TRUE ); insilmaril@185: //fd->setContentsPreview( p, p ); insilmaril@185: //fd->setPreviewMode( QFileDialog::Contents ); insilmaril@404: fd->setCaption(vymName+" - " +tr("Export to")+" Open Office"); insilmaril@366: fd->setDir (QDir().current()); insilmaril@357: if (fd->foundConfig()) insilmaril@357: { insilmaril@357: fd->show(); insilmaril@185: insilmaril@357: if ( fd->exec() == QDialog::Accepted ) insilmaril@357: { insilmaril@357: QString fn=fd->selectedFile(); insilmaril@366: if (!fn.contains (".odp")) insilmaril@366: fn +=".odp"; insilmaril@366: insilmaril@357: //lastImageDir=fn.left(fn.findRev ("/")); insilmaril@357: if (currentMapEditor()) insilmaril@357: currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig()); insilmaril@357: } insilmaril@357: } else insilmaril@185: { insilmaril@357: QMessageBox::warning(0, insilmaril@366: tr("Warning"), insilmaril@366: tr("Couldn't find configuration for export to Open Office\n")); insilmaril@185: } insilmaril@163: } insilmaril@163: insilmaril@0: void Main::fileCloseMap() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: { insilmaril@0: if (currentMapEditor()->hasChanged()) insilmaril@0: { insilmaril@404: QMessageBox mb( vymName, insilmaril@159: tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()), insilmaril@0: QMessageBox::Warning, insilmaril@0: QMessageBox::Yes | QMessageBox::Default, insilmaril@0: QMessageBox::No, insilmaril@0: QMessageBox::Cancel | QMessageBox::Escape ); insilmaril@0: mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") ); insilmaril@0: mb.setButtonText( QMessageBox::No, tr("Discard changes")); insilmaril@0: switch( mb.exec() ) insilmaril@0: { insilmaril@0: case QMessageBox::Yes: insilmaril@0: // save and close insilmaril@0: fileSave(CompleteMap); insilmaril@0: break; insilmaril@0: case QMessageBox::No: insilmaril@0: // close without saving insilmaril@0: break; insilmaril@0: case QMessageBox::Cancel: insilmaril@0: // do nothing insilmaril@0: return; insilmaril@0: } insilmaril@0: } insilmaril@0: currentMapEditor()->closeMap(); insilmaril@0: tabWidget->removePage(currentMapEditor()); insilmaril@0: if (tabWidget->count()==0) insilmaril@0: actionFilePrint->setEnabled (false); insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@0: void Main::filePrint() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->print(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::fileExitVYM() insilmaril@0: { insilmaril@0: // Check if one or more editors have changed insilmaril@0: MapEditor *me; insilmaril@0: int i; insilmaril@0: for (i=0;i<=tabWidget->count() -1;i++) insilmaril@0: { insilmaril@0: insilmaril@0: me=(MapEditor*)tabWidget->page(i); insilmaril@0: insilmaril@0: // If something changed, ask what to do insilmaril@0: if (me->isUnsaved()) insilmaril@0: { insilmaril@0: tabWidget->setCurrentPage(i); insilmaril@404: QMessageBox mb( vymName, 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@366: mb.setModal (true); insilmaril@0: mb.show(); insilmaril@0: mb.setActiveWindow(); insilmaril@0: switch( mb.exec() ) { insilmaril@0: case QMessageBox::Yes: insilmaril@0: // save (the changed editors) and exit insilmaril@0: fileSave(CompleteMap); insilmaril@0: break; insilmaril@0: case QMessageBox::No: insilmaril@0: // exit without saving insilmaril@0: break; insilmaril@0: case QMessageBox::Cancel: insilmaril@0: // don't save and don't exit insilmaril@0: return; insilmaril@0: } insilmaril@0: } insilmaril@0: } // loop over all MEs insilmaril@0: qApp->quit(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editUndo() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->undo(); insilmaril@0: } insilmaril@0: insilmaril@163: void Main::editRedo() insilmaril@0: { insilmaril@163: if (currentMapEditor()) insilmaril@163: currentMapEditor()->redo(); insilmaril@0: } insilmaril@0: insilmaril@404: void Main::gotoHistoryStep (int i) insilmaril@404: { insilmaril@404: if (currentMapEditor()) insilmaril@404: currentMapEditor()->gotoHistoryStep (i); insilmaril@404: } insilmaril@404: 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@349: 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@366: void Main::openTabs(QStringList urls) insilmaril@366: { insilmaril@366: if (!urls.isEmpty()) insilmaril@366: { insilmaril@366: bool success=true; insilmaril@366: QStringList args; insilmaril@366: QString browser=settings.value("/mainwindow/readerURL" ).toString(); insilmaril@366: QProcess *p; insilmaril@366: if (!procBrowser || procBrowser->state()!=QProcess::Running) insilmaril@366: { insilmaril@366: QString u=urls.takeFirst(); insilmaril@366: procBrowser = new QProcess( this ); insilmaril@366: args<start(browser,args); insilmaril@366: if ( !procBrowser->waitForStarted()) insilmaril@366: { insilmaril@366: // try to set path to browser insilmaril@366: QMessageBox::warning(0, insilmaril@366: tr("Warning"), insilmaril@366: tr("Couldn't find a viewer to open %1.\n").arg(u)+ insilmaril@366: tr("Please use Settings->")+tr("Set application to open an URL")); insilmaril@366: return; insilmaril@366: } insilmaril@366: sleep (3); insilmaril@366: } insilmaril@366: if (browser.contains("konqueror")) insilmaril@366: { insilmaril@366: for (int i=0; ipid())<< insilmaril@366: "konqueror-mainwindow#1"<< insilmaril@366: "newTab" << insilmaril@366: urls.at(i); insilmaril@366: p->start ("dcop",args); insilmaril@366: if ( !p->waitForStarted() ) success=false; insilmaril@366: } insilmaril@366: if (!success) insilmaril@366: QMessageBox::warning(0, insilmaril@366: tr("Warning"), insilmaril@366: tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror")); insilmaril@366: return; insilmaril@366: } else if (browser.contains ("firefox") || browser.contains ("mozilla") ) insilmaril@366: { insilmaril@366: for (int i=0; istart (browser,args); insilmaril@366: if ( !p->waitForStarted() ) success=false; insilmaril@366: } insilmaril@366: if (!success) insilmaril@366: QMessageBox::warning(0, insilmaril@366: tr("Warning"), insilmaril@366: tr("Couldn't start %1 to open a new tab").arg(browser)); insilmaril@366: return; insilmaril@366: } insilmaril@366: QMessageBox::warning(0, insilmaril@366: tr("Warning"), insilmaril@366: tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing.")); insilmaril@366: } insilmaril@366: } insilmaril@366: insilmaril@0: void Main::editOpenURL() insilmaril@0: { insilmaril@266: // Open new browser insilmaril@0: if (currentMapEditor()) insilmaril@266: { insilmaril@266: QString url=currentMapEditor()->getURL(); insilmaril@366: QStringList args; insilmaril@266: if (url=="") return; insilmaril@366: QString browser=settings.value("/mainwindow/readerURL" ).toString(); insilmaril@266: procBrowser = new QProcess( this ); insilmaril@366: args<start(browser,args); insilmaril@366: if ( !procBrowser->waitForStarted()) insilmaril@266: { insilmaril@266: // try to set path to browser insilmaril@266: QMessageBox::warning(0, insilmaril@266: tr("Warning"), insilmaril@266: tr("Couldn't find a viewer to open %1.\n").arg(url)+ insilmaril@266: tr("Please use Settings->")+tr("Set application to open an URL")); insilmaril@266: settingsURL() ; insilmaril@266: } insilmaril@266: } insilmaril@266: } insilmaril@266: void Main::editOpenURLTab() insilmaril@266: { insilmaril@266: if (currentMapEditor()) insilmaril@266: { insilmaril@366: QStringList urls; insilmaril@366: urls.append(currentMapEditor()->getURL()); insilmaril@366: openTabs (urls); insilmaril@266: } insilmaril@0: } insilmaril@366: void Main::editOpenMultipleURLTabs() insilmaril@366: { insilmaril@366: if (currentMapEditor()) insilmaril@366: { insilmaril@366: QStringList urls; insilmaril@366: urls=currentMapEditor()->getURLs(); insilmaril@366: openTabs (urls); insilmaril@366: } insilmaril@366: } insilmaril@366: insilmaril@0: insilmaril@0: void Main::editURL() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->editURL(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editHeading2URL() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->editHeading2URL(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editBugzilla2URL() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->editBugzilla2URL(); insilmaril@0: } insilmaril@0: insilmaril@175: void Main::editFATE2URL() insilmaril@175: { insilmaril@175: if (currentMapEditor()) insilmaril@175: currentMapEditor()->editFATE2URL(); insilmaril@175: } insilmaril@175: insilmaril@394: void Main::editHeadingFinished() insilmaril@394: { insilmaril@394: // only called from editHeading(), so there is a currentME insilmaril@394: MapEditor *me=currentMapEditor(); insilmaril@394: insilmaril@394: #if defined(Q_OS_MACX) insilmaril@394: #else insilmaril@394: me->setHeading(lineedit->text()); insilmaril@394: insilmaril@394: lineedit->releaseKeyboard(); insilmaril@394: lineedit->hide(); insilmaril@394: setFocus(); insilmaril@394: #endif insilmaril@394: if (!prevSelection.isEmpty()) me->select(prevSelection); insilmaril@394: prevSelection=""; insilmaril@394: } insilmaril@394: insilmaril@366: void Main::editHeading() insilmaril@0: { insilmaril@394: if (currentMapEditor()) insilmaril@0: { insilmaril@394: MapEditor *me=currentMapEditor(); insilmaril@394: QString oldSel=me->getSelectString(); insilmaril@394: insilmaril@394: if (lineedit->isVisible()) insilmaril@394: editHeadingFinished(); insilmaril@394: else insilmaril@366: { insilmaril@366: bool ok; insilmaril@366: QPoint p; insilmaril@366: QString s=currentMapEditor()->getHeading(ok,p); insilmaril@366: insilmaril@366: if (ok) insilmaril@366: { insilmaril@366: #if defined(Q_OS_MACX) insilmaril@408: p=currentMapEditor()->mapTo (this,p); insilmaril@366: QDialog *d =new QDialog(NULL); insilmaril@366: QLineEdit *le=new QLineEdit (d); insilmaril@366: d->setWindowFlags (Qt::FramelessWindowHint); insilmaril@394: d->setGeometry(p.x(),p.y(),230,25); insilmaril@394: le->resize (d->width()-10,d->height()); insilmaril@366: le->setText (s); insilmaril@366: le->selectAll(); insilmaril@366: connect (le, SIGNAL (returnPressed()), d, SLOT (accept())); insilmaril@366: d->activateWindow(); insilmaril@366: d->exec(); insilmaril@366: currentMapEditor()->setHeading (le->text()); insilmaril@394: delete (le); insilmaril@394: delete (d); insilmaril@394: editHeadingFinished(); insilmaril@366: #else insilmaril@408: p=currentMapEditor()->mapTo (this,p); insilmaril@394: lineedit->setGeometry(p.x(),p.y(),230,25); insilmaril@366: lineedit->setText(s); insilmaril@366: lineedit->setCursorPosition(1); insilmaril@366: lineedit->selectAll(); insilmaril@366: lineedit->show(); insilmaril@366: lineedit->grabKeyboard(); insilmaril@366: lineedit->setFocus(); insilmaril@366: #endif insilmaril@366: } insilmaril@366: } insilmaril@394: } // currentMapEditor() insilmaril@366: } insilmaril@366: insilmaril@366: void Main::openVymLinks(const QStringList &vl) insilmaril@366: { insilmaril@366: for (int j=0; jcount() -1;i++) insilmaril@0: { insilmaril@0: me=(MapEditor*)tabWidget->page(i); insilmaril@366: if (vl.at(j)==me->getFilePath() ) insilmaril@0: { insilmaril@0: index=i; insilmaril@0: break; insilmaril@0: } insilmaril@0: } insilmaril@0: if (index<0) insilmaril@0: // Load map insilmaril@0: { insilmaril@366: if (!QFile(vl.at(j)).exists() ) insilmaril@0: QMessageBox::critical( 0, tr( "Critical Error" ), insilmaril@366: tr("Couldn't open map %1").arg(vl.at(j))); insilmaril@0: else insilmaril@0: { insilmaril@366: fileLoad (vl.at(j), NewMap); insilmaril@0: tabWidget->setCurrentPage (tabWidget->count()-1); insilmaril@0: } insilmaril@0: } else insilmaril@0: // Go to tab containing the map insilmaril@0: tabWidget->setCurrentPage (index); insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@366: void Main::editOpenVymLink() insilmaril@366: { insilmaril@366: if (currentMapEditor()) insilmaril@366: { insilmaril@366: QStringList vl; insilmaril@366: vl.append(currentMapEditor()->getVymLink()); insilmaril@366: openVymLinks (vl); insilmaril@366: } insilmaril@366: } insilmaril@366: insilmaril@366: void Main::editOpenMultipleVymLinks() insilmaril@366: { insilmaril@366: QString currentVymLink; insilmaril@366: if (currentMapEditor()) insilmaril@366: { insilmaril@366: QStringList vl=currentMapEditor()->getVymLinks(); insilmaril@366: openVymLinks (vl); insilmaril@366: } insilmaril@366: } insilmaril@366: insilmaril@0: void Main::editVymLink() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->editVymLink(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editDeleteVymLink() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->deleteVymLink(); insilmaril@0: } insilmaril@0: insilmaril@243: void Main::editToggleHideExport() insilmaril@243: { insilmaril@243: if (currentMapEditor()) insilmaril@294: currentMapEditor()->toggleHideExport(); insilmaril@243: } insilmaril@243: insilmaril@0: void Main::editMapInfo() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->editMapInfo(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editMoveUp() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->moveBranchUp(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editMoveDown() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->moveBranchDown(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editToggleScroll() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: { insilmaril@0: currentMapEditor()->toggleScroll(); insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editUnScrollAll() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@394: currentMapEditor()->unScrollAll(); insilmaril@394: } insilmaril@394: insilmaril@394: void Main::editNewBranch() insilmaril@394: { insilmaril@394: MapEditor *me=currentMapEditor(); insilmaril@394: if (!lineedit->isVisible() && me) insilmaril@0: { insilmaril@394: BranchObj *bo=(BranchObj*)me->getSelection(); insilmaril@394: BranchObj *newbo=me->addNewBranch(0); insilmaril@394: insilmaril@394: if (newbo) insilmaril@394: me->select (newbo->getSelectString()); insilmaril@394: else insilmaril@394: return; insilmaril@394: insilmaril@394: if (actionSettingsAutoEdit->isOn()) insilmaril@394: { insilmaril@394: if (!actionSettingsAutoSelectHeading->isOn()) insilmaril@394: prevSelection=bo->getSelectString(); insilmaril@394: editHeading(); insilmaril@394: } insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@394: void Main::editNewBranchBefore() insilmaril@0: { insilmaril@394: MapEditor *me=currentMapEditor(); insilmaril@394: if (!lineedit->isVisible() && me) insilmaril@394: { insilmaril@394: BranchObj *bo=(BranchObj*)me->getSelection(); insilmaril@394: BranchObj *newbo=me->addNewBranchBefore(); insilmaril@394: insilmaril@394: if (newbo) insilmaril@394: me->select (newbo->getSelectString()); insilmaril@394: else insilmaril@394: return; insilmaril@394: insilmaril@394: if (actionSettingsAutoEdit->isOn()) insilmaril@394: { insilmaril@394: if (!actionSettingsAutoSelectHeading->isOn()) insilmaril@394: prevSelection=bo->getSelectString(); insilmaril@394: editHeading(); insilmaril@394: } insilmaril@394: } insilmaril@98: } insilmaril@98: insilmaril@0: void Main::editNewBranchAbove() insilmaril@0: { insilmaril@394: MapEditor *me=currentMapEditor(); insilmaril@394: if (!lineedit->isVisible() && me) insilmaril@394: { insilmaril@394: BranchObj *bo=(BranchObj*)me->getSelection(); insilmaril@394: BranchObj *newbo=me->addNewBranch (-1); insilmaril@394: insilmaril@394: if (newbo) insilmaril@394: me->select (newbo->getSelectString()); insilmaril@394: else insilmaril@394: return; insilmaril@394: insilmaril@394: if (actionSettingsAutoEdit->isOn()) insilmaril@394: { insilmaril@394: if (!actionSettingsAutoSelectHeading->isOn()) insilmaril@394: prevSelection=bo->getSelectString(); insilmaril@394: editHeading(); insilmaril@394: } insilmaril@394: } insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editNewBranchBelow() insilmaril@0: { insilmaril@394: MapEditor *me=currentMapEditor(); insilmaril@394: if (!lineedit->isVisible() && me) insilmaril@394: { insilmaril@394: BranchObj *bo=(BranchObj*)me->getSelection(); insilmaril@394: BranchObj *newbo=me->addNewBranch (1); insilmaril@394: insilmaril@394: if (newbo) insilmaril@394: me->select (newbo->getSelectString()); insilmaril@394: else insilmaril@394: return; insilmaril@394: insilmaril@394: if (actionSettingsAutoEdit->isOn()) insilmaril@394: { insilmaril@394: if (!actionSettingsAutoSelectHeading->isOn()) insilmaril@394: prevSelection=bo->getSelectString(); insilmaril@394: editHeading(); insilmaril@394: } insilmaril@394: } 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@395: void Main::editDeleteKeepChilds() insilmaril@98: { insilmaril@98: if (currentMapEditor()) insilmaril@395: currentMapEditor()->deleteKeepChilds(); insilmaril@98: } insilmaril@98: insilmaril@395: void Main::editDeleteChilds() insilmaril@98: { insilmaril@98: if (currentMapEditor()) insilmaril@395: currentMapEditor()->deleteChilds(); insilmaril@98: } insilmaril@98: insilmaril@0: void Main::editDeleteSelection() insilmaril@0: { insilmaril@151: if (currentMapEditor() && actionSettingsUseDelKey->isOn()) insilmaril@0: currentMapEditor()->deleteSelection(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editUpperBranch() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->selectUpperBranch(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editLowerBranch() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->selectLowerBranch(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editLeftBranch() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->selectLeftBranch(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editRightBranch() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->selectRightBranch(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editFirstBranch() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->selectFirstBranch(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editLastBranch() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->selectLastBranch(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editLoadImage() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->loadFloatImage(); insilmaril@0: } insilmaril@0: insilmaril@366: void Main::editSaveImage() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@366: currentMapEditor()->saveFloatImage(); insilmaril@0: } insilmaril@0: insilmaril@366: void Main::editFollowXLink(QAction *a) insilmaril@366: { insilmaril@366: insilmaril@366: if (currentMapEditor()) insilmaril@366: currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a)); insilmaril@366: } insilmaril@366: insilmaril@366: void Main::editEditXLink(QAction *a) insilmaril@89: { insilmaril@89: if (currentMapEditor()) insilmaril@366: currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a)); insilmaril@94: } insilmaril@94: insilmaril@0: void Main::formatSelectColor() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: { insilmaril@395: QColor col = QColorDialog::getColor((currentColor ), this ); insilmaril@0: if ( !col.isValid() ) return; insilmaril@0: colorChanged( col ); insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@0: void Main::formatPickColor() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@395: colorChanged( currentMapEditor()->getCurrentHeadingColor() ); 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@395: currentColor=c; insilmaril@0: } insilmaril@0: insilmaril@0: void Main::formatColorBranch() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@395: currentMapEditor()->colorBranch(currentColor); insilmaril@0: } insilmaril@0: insilmaril@417: void Main::formatColorSubtree() insilmaril@417: { insilmaril@417: if (currentMapEditor()) insilmaril@417: currentMapEditor()->colorSubtree (currentColor); insilmaril@417: } insilmaril@417: insilmaril@0: void Main::formatLinkStyleLine() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@398: currentMapEditor()->setMapLinkStyle("StyleLine"); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::formatLinkStyleParabel() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@398: currentMapEditor()->setMapLinkStyle("StyleParabel"); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::formatLinkStylePolyLine() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@398: currentMapEditor()->setMapLinkStyle("StylePolyLine"); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::formatLinkStylePolyParabel() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@398: currentMapEditor()->setMapLinkStyle("StylePolyParabel"); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::formatSelectBackColor() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@398: currentMapEditor()->selectMapBackgroundColor(); insilmaril@0: } insilmaril@0: insilmaril@408: void Main::formatSelectBackImage() insilmaril@408: { insilmaril@408: if (currentMapEditor()) insilmaril@408: currentMapEditor()->selectMapBackgroundImage(); insilmaril@408: } insilmaril@408: insilmaril@0: void Main::formatSelectLinkColor() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@398: currentMapEditor()->selectMapLinkColor(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::formatToggleLinkColorHint() insilmaril@0: { insilmaril@398: currentMapEditor()->toggleMapLinkColorHint(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::formatFrameNone() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->setFrame(NoFrame); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::formatFrameRectangle() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->setFrame(Rectangle); insilmaril@0: } insilmaril@0: insilmaril@175: void Main::formatIncludeImagesVer() insilmaril@175: { insilmaril@175: if (currentMapEditor()) insilmaril@175: currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn()); insilmaril@175: } insilmaril@175: insilmaril@175: void Main::formatIncludeImagesHor() insilmaril@175: { insilmaril@175: if (currentMapEditor()) insilmaril@175: currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn()); insilmaril@175: } insilmaril@175: insilmaril@160: void Main::formatHideLinkUnselected() insilmaril@160: { insilmaril@160: if (currentMapEditor()) insilmaril@160: currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn()); insilmaril@160: } insilmaril@160: insilmaril@0: void Main::viewZoomReset() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: { insilmaril@366: QMatrix m; insilmaril@0: m.reset(); insilmaril@408: currentMapEditor()->setMatrix( m ); insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@0: void Main::viewZoomIn() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: { insilmaril@408: QMatrix m = currentMapEditor()->matrix(); insilmaril@0: m.scale( 1.25, 1.25 ); insilmaril@408: currentMapEditor()->setMatrix( m ); insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@0: void Main::viewZoomOut() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: { insilmaril@408: QMatrix m = currentMapEditor()->matrix(); insilmaril@0: m.scale( 0.8, 0.8 ); insilmaril@408: currentMapEditor()->setMatrix( m ); insilmaril@0: } insilmaril@0: } insilmaril@89: insilmaril@0: bool Main::settingsPDF() insilmaril@0: { insilmaril@0: // Default browser is set in constructor insilmaril@0: bool ok; insilmaril@0: QString text = QInputDialog::getText( insilmaril@266: "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal, insilmaril@366: settings.value("/mainwindow/readerPDF").toString(), &ok, this ); insilmaril@0: if (ok) insilmaril@366: settings.setValue ("/mainwindow/readerPDF",text); insilmaril@0: return ok; insilmaril@0: } insilmaril@0: insilmaril@0: insilmaril@0: bool Main::settingsURL() insilmaril@0: { insilmaril@0: // Default browser is set in constructor insilmaril@0: bool ok; insilmaril@0: QString text = QInputDialog::getText( insilmaril@266: "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal, insilmaril@366: settings.value("/mainwindow/readerURL").toString() insilmaril@0: , &ok, this ); insilmaril@0: if (ok) insilmaril@366: settings.setValue ("/mainwindow/readerURL",text); insilmaril@0: return ok; insilmaril@0: } insilmaril@0: insilmaril@327: void Main::settingsToggleDelKey() insilmaril@327: { insilmaril@327: if (actionSettingsUseDelKey->isOn()) insilmaril@327: { insilmaril@366: actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete)); insilmaril@327: } else insilmaril@327: { insilmaril@327: actionEditDelete->setAccel (QKeySequence ("")); insilmaril@327: } insilmaril@327: } insilmaril@327: insilmaril@0: void Main::windowToggleNoteEditor() insilmaril@0: { insilmaril@0: if (textEditor->showWithMain() ) insilmaril@0: windowHideNoteEditor(); insilmaril@0: else insilmaril@0: windowShowNoteEditor(); insilmaril@0: } insilmaril@0: insilmaril@294: void Main::windowToggleHistory() insilmaril@294: { insilmaril@404: if (historyWindow->isVisible()) insilmaril@404: historyWindow->hide(); insilmaril@404: else insilmaril@404: historyWindow->show(); insilmaril@404: insilmaril@404: } insilmaril@404: insilmaril@408: void Main::windowToggleAntiAlias() insilmaril@408: { insilmaril@408: bool b=actionViewToggleAntiAlias->isOn(); insilmaril@408: MapEditor *me; insilmaril@408: for (int i=0;icount();i++) insilmaril@408: { insilmaril@408: insilmaril@408: me=(MapEditor*)tabWidget->page(i); insilmaril@408: me->setAntiAlias(b); insilmaril@408: } insilmaril@408: insilmaril@408: } insilmaril@408: insilmaril@408: void Main::windowToggleSmoothPixmap() insilmaril@408: { insilmaril@408: bool b=actionViewToggleSmoothPixmapTransform->isOn(); insilmaril@408: MapEditor *me; insilmaril@408: for (int i=0;icount();i++) insilmaril@408: { insilmaril@408: insilmaril@408: me=(MapEditor*)tabWidget->page(i); insilmaril@408: me->setSmoothPixmap(b); insilmaril@408: } insilmaril@408: } insilmaril@408: insilmaril@404: void Main::updateHistory(SimpleSettings &undoSet) insilmaril@404: { insilmaril@404: historyWindow->update (undoSet); insilmaril@294: } insilmaril@294: insilmaril@160: void Main::updateNoteFlag() insilmaril@160: { insilmaril@160: if (currentMapEditor()) insilmaril@160: currentMapEditor()->updateNoteFlag(); insilmaril@160: } insilmaril@160: insilmaril@390: void Main::updateActions() insilmaril@390: { insilmaril@390: MapEditor *me=currentMapEditor(); insilmaril@390: if (!me) return; insilmaril@390: insilmaril@407: historyWindow->setCaption (tr("History for %1").arg(currentMapEditor()->getFileName())); insilmaril@407: insilmaril@390: // updateActions is also called when NoteEditor is closed insilmaril@393: actionViewToggleNoteEditor->setOn (textEditor->showWithMain()); insilmaril@390: insilmaril@398: if (me->getMapLinkColorHint()==HeadingColor) insilmaril@390: actionFormatLinkColorHint->setOn(true); insilmaril@390: else insilmaril@390: actionFormatLinkColorHint->setOn(false); insilmaril@390: insilmaril@398: switch (me->getMapLinkStyle()) insilmaril@390: { insilmaril@390: case StyleLine: insilmaril@390: actionFormatLinkStyleLine->setOn(true); insilmaril@390: break; insilmaril@390: case StyleParabel: insilmaril@390: actionFormatLinkStyleParabel->setOn(true); insilmaril@390: break; insilmaril@390: case StylePolyLine: insilmaril@390: actionFormatLinkStylePolyLine->setOn(true); insilmaril@390: break; insilmaril@390: case StylePolyParabel: insilmaril@390: actionFormatLinkStylePolyParabel->setOn(true); insilmaril@390: break; insilmaril@390: default: insilmaril@390: break; insilmaril@390: } insilmaril@390: insilmaril@390: QPixmap pix( 16, 16 ); insilmaril@398: pix.fill( me->getMapBackgroundColor() ); insilmaril@390: actionFormatBackColor->setIconSet( pix ); insilmaril@398: pix.fill( me->getMapDefLinkColor() ); insilmaril@390: actionFormatLinkColor->setIconSet( pix ); insilmaril@390: insilmaril@390: actionFileSave->setEnabled( me->isUnsaved() ); insilmaril@390: if (me->isUndoAvailable()) insilmaril@390: actionEditUndo->setEnabled( true); insilmaril@390: else insilmaril@390: actionEditUndo->setEnabled( false); insilmaril@390: insilmaril@390: if (me->isRedoAvailable()) insilmaril@390: actionEditRedo->setEnabled( true); insilmaril@390: else insilmaril@390: actionEditRedo->setEnabled( false); insilmaril@390: insilmaril@390: LinkableMapObj *selection=me->getSelection(); insilmaril@390: if (selection) insilmaril@390: { insilmaril@390: if ( (typeid(*selection) == typeid(BranchObj)) || insilmaril@390: (typeid(*selection) == typeid(MapCenterObj)) ) insilmaril@390: { insilmaril@390: BranchObj *bo=(BranchObj*)selection; insilmaril@390: // Take care of links insilmaril@390: if (bo->countXLinks()==0) insilmaril@390: { insilmaril@390: branchXLinksContextMenuEdit->clear(); insilmaril@390: branchXLinksContextMenuFollow->clear(); insilmaril@390: } else insilmaril@390: { insilmaril@390: BranchObj *bot; insilmaril@390: QString s; insilmaril@390: branchXLinksContextMenuEdit->clear(); insilmaril@390: branchXLinksContextMenuFollow->clear(); insilmaril@390: for (int i=0; i<=bo->countXLinks();i++) insilmaril@390: { insilmaril@390: bot=bo->XLinkTargetAt(i); insilmaril@390: if (bot) insilmaril@390: { insilmaril@390: s=bot->getHeading(); insilmaril@390: if (s.length()>25) insilmaril@390: s=s.left(25)+"..."; insilmaril@390: branchXLinksContextMenuFollow->addAction (s); insilmaril@390: branchXLinksContextMenuEdit->addAction (s); insilmaril@390: } insilmaril@390: } insilmaril@390: } insilmaril@390: insilmaril@390: standardFlagsDefault->setEnabled (true); insilmaril@390: insilmaril@390: actionEditToggleScroll->setEnabled (true); insilmaril@390: if ( bo->isScrolled() ) insilmaril@390: actionEditToggleScroll->setOn(true); insilmaril@390: else insilmaril@390: actionEditToggleScroll->setOn(false); insilmaril@390: insilmaril@390: if ( bo->getURL().isEmpty() ) insilmaril@390: { insilmaril@390: actionEditOpenURL->setEnabled (false); insilmaril@390: actionEditOpenURLTab->setEnabled (false); insilmaril@390: } insilmaril@390: else insilmaril@390: { insilmaril@390: actionEditOpenURL->setEnabled (true); insilmaril@390: actionEditOpenURLTab->setEnabled (true); insilmaril@390: } insilmaril@390: if ( bo->getVymLink().isEmpty() ) insilmaril@390: { insilmaril@390: actionEditOpenVymLink->setEnabled (false); insilmaril@390: actionEditDeleteVymLink->setEnabled (false); insilmaril@390: } else insilmaril@390: { insilmaril@390: actionEditOpenVymLink->setEnabled (true); insilmaril@390: actionEditDeleteVymLink->setEnabled (true); insilmaril@390: } insilmaril@390: insilmaril@390: if (bo->canMoveBranchUp()) insilmaril@390: actionEditMoveUp->setEnabled (true); insilmaril@390: else insilmaril@390: actionEditMoveUp->setEnabled (false); insilmaril@390: if (bo->canMoveBranchDown()) insilmaril@390: actionEditMoveDown->setEnabled (true); insilmaril@390: else insilmaril@390: actionEditMoveDown->setEnabled (false); insilmaril@390: insilmaril@390: insilmaril@390: actionEditToggleHideExport->setEnabled (true); insilmaril@390: actionEditToggleHideExport->setOn (bo->hideInExport() ); insilmaril@390: insilmaril@390: actionEditCopy->setEnabled (true); insilmaril@390: actionEditCut->setEnabled (true); insilmaril@390: if (!clipboardEmpty) insilmaril@390: actionEditPaste->setEnabled (true); insilmaril@390: else insilmaril@390: actionEditPaste->setEnabled (false); insilmaril@406: for (int i=0; isetEnabled(true); insilmaril@390: actionEditDelete->setEnabled (true); insilmaril@390: switch (selection->getFrameType()) insilmaril@390: { insilmaril@390: case NoFrame: insilmaril@390: actionFormatFrameNone->setOn(true); insilmaril@390: break; insilmaril@390: case Rectangle: insilmaril@390: actionFormatFrameRectangle->setOn(true); insilmaril@390: break; insilmaril@390: default: insilmaril@390: break; insilmaril@390: } insilmaril@390: actionFormatIncludeImagesVer->setOn insilmaril@390: ( ((BranchObj*)selection)->getIncludeImagesVer()); insilmaril@390: actionFormatIncludeImagesHor->setOn insilmaril@390: ( ((BranchObj*)selection)->getIncludeImagesHor()); insilmaril@390: actionFormatHideLinkUnselected->setOn insilmaril@390: (selection->getHideLinkUnselected()); insilmaril@390: } insilmaril@390: if ( (typeid(*selection) == typeid(FloatImageObj)) ) insilmaril@390: { insilmaril@390: FloatObj *fo=(FloatImageObj*)selection; insilmaril@390: insilmaril@390: actionEditOpenURL->setEnabled (false); insilmaril@390: actionEditOpenVymLink->setEnabled (false); insilmaril@390: actionEditDeleteVymLink->setEnabled (false); insilmaril@390: actionEditToggleHideExport->setEnabled (true); insilmaril@390: actionEditToggleHideExport->setOn (fo->hideInExport() ); insilmaril@390: insilmaril@390: insilmaril@390: actionEditCopy->setEnabled (true); insilmaril@390: actionEditCut->setEnabled (true); insilmaril@390: actionEditPaste->setEnabled (false); insilmaril@406: for (int i=0; isetEnabled(false); insilmaril@390: actionEditDelete->setEnabled (true); insilmaril@390: actionFormatHideLinkUnselected->setOn insilmaril@390: ( selection->getHideLinkUnselected()); insilmaril@390: actionEditMoveUp->setEnabled (false); insilmaril@390: actionEditMoveDown->setEnabled (false); insilmaril@390: } insilmaril@390: insilmaril@390: } else insilmaril@390: { insilmaril@390: actionEditCopy->setEnabled (false); insilmaril@390: actionEditCut->setEnabled (false); insilmaril@390: actionEditPaste->setEnabled (false); insilmaril@406: for (int i=0; isetEnabled(false); insilmaril@390: insilmaril@390: actionEditToggleScroll->setEnabled (false); insilmaril@390: actionEditOpenURL->setEnabled (false); insilmaril@390: actionEditOpenVymLink->setEnabled (false); insilmaril@390: actionEditDeleteVymLink->setEnabled (false); insilmaril@390: actionEditHeading2URL->setEnabled (false); insilmaril@390: actionEditDelete->setEnabled (false); insilmaril@390: actionEditMoveUp->setEnabled (false); insilmaril@390: actionEditMoveDown->setEnabled (false); insilmaril@390: actionEditToggleHideExport->setEnabled (false); insilmaril@390: } insilmaril@390: } insilmaril@390: insilmaril@390: ModMode Main::getModMode() insilmaril@390: { insilmaril@390: if (actionModModeColor->isOn()) return ModModeColor; insilmaril@390: if (actionModModeCopy->isOn()) return ModModeCopy; insilmaril@390: if (actionModModeXLink->isOn()) return ModModeXLink; insilmaril@390: return ModModeNone; insilmaril@390: } insilmaril@390: insilmaril@390: bool Main::autoEdit() insilmaril@390: { insilmaril@390: return actionSettingsAutoEdit->isOn(); insilmaril@390: } insilmaril@390: insilmaril@390: bool Main::autoSelectHeading() insilmaril@390: { insilmaril@390: return actionSettingsAutoSelectHeading->isOn(); insilmaril@390: } insilmaril@390: insilmaril@390: bool Main::useFlagGroups() insilmaril@390: { insilmaril@390: return actionSettingsUseFlagGroups->isOn(); insilmaril@390: } insilmaril@390: 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@393: if (!currentMapEditor()) return; insilmaril@388: currentMapEditor()->testFunction(); insilmaril@0: } insilmaril@0: insilmaril@393: void Main::testCommand() insilmaril@393: { insilmaril@393: if (!currentMapEditor()) return; insilmaril@393: bool ok; insilmaril@393: QString com = QInputDialog::getText( insilmaril@404: vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this ); insilmaril@393: if (ok) currentMapEditor()->parseAtom(com); insilmaril@393: } insilmaril@393: insilmaril@0: void Main::helpDoc() insilmaril@0: { insilmaril@395: QString locale = QLocale::system().name(); insilmaril@395: QString docname; insilmaril@395: if (locale.left(2)=="es") insilmaril@395: docname="vym_es.pdf"; insilmaril@395: else insilmaril@395: docname="vym.pdf"; insilmaril@395: QDir docdir; insilmaril@103: #if defined(Q_OS_MACX) insilmaril@395: docdir.setPath("./vym.app/Contents"); insilmaril@103: #else insilmaril@103: // default path in SUSE LINUX insilmaril@395: docdir.setPath("/usr/share/doc/packages/vym/doc"); insilmaril@103: #endif insilmaril@0: insilmaril@395: if (!docdir.exists() ) insilmaril@0: { insilmaril@0: // relative path for easy testing in tarball insilmaril@395: docdir.setPath("doc"); insilmaril@395: if (!docdir.exists() ) insilmaril@0: { insilmaril@0: // relative path for testing while still writing vym.tex insilmaril@395: docdir.setPath("doc/tex/vym.pdf"); insilmaril@395: if (!docdir.exists() ) insilmaril@0: { insilmaril@175: // Try yet another one for Knoppix insilmaril@395: docdir.setPath("/usr/share/doc/packages/vym"); insilmaril@395: if (!docdir.exists() ) insilmaril@175: { insilmaril@175: QMessageBox::critical(0, insilmaril@175: tr("Critcal error"), insilmaril@175: tr("Couldn't find the documentation\n" insilmaril@395: "vym.pdf in various directories.")); insilmaril@175: return; insilmaril@175: } insilmaril@0: } insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@395: QString docpath=docdir.path()+"/"+docname; insilmaril@408: QStringList args; insilmaril@0: Process *pdfProc = new Process(); insilmaril@408: args <start( settings.value("/mainwindow/readerPDF").toString()); insilmaril@408: if ( !pdfProc->waitForStarted() ) insilmaril@0: { insilmaril@0: // error handling insilmaril@266: QMessageBox::warning(0, insilmaril@266: tr("Warning"), insilmaril@395: tr("Couldn't find a viewer to open %1.\n").arg(docpath)+ insilmaril@266: tr("Please use Settings->")+tr("Set application to open PDF files")); insilmaril@266: settingsPDF(); insilmaril@0: return; insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@0: insilmaril@0: void Main::helpAbout() insilmaril@0: { insilmaril@148: AboutDialog ad; insilmaril@150: ad.setName ("aboutwindow"); insilmaril@148: ad.setMinimumSize(500,500); insilmaril@148: ad.resize (QSize (500,500)); insilmaril@148: ad.exec(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::helpAboutQT() insilmaril@0: { insilmaril@0: QMessageBox::aboutQt( this, "Qt Application Example" ); insilmaril@0: } insilmaril@0: