insilmaril@0: #include "mainwindow.h" insilmaril@0: insilmaril@366: #include insilmaril@390: insilmaril@0: #include insilmaril@611: #include insilmaril@0: insilmaril@205: #include "aboutdialog.h" insilmaril@421: #include "branchpropwindow.h" insilmaril@205: #include "exportoofiledialog.h" insilmaril@228: #include "exports.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@442: #include "warningdialog.h" insilmaril@0: insilmaril@608: #if defined(Q_OS_WIN32) insilmaril@608: // Define only this structure as opposed to insilmaril@608: // including full 'windows.h'. FindWindow insilmaril@608: // clashes with the one in Win32 API. insilmaril@608: typedef struct _PROCESS_INFORMATION insilmaril@608: { insilmaril@608: long hProcess; insilmaril@608: long hThread; insilmaril@608: long dwProcessId; insilmaril@608: long dwThreadId; insilmaril@608: } PROCESS_INFORMATION, *LPPROCESS_INFORMATION; insilmaril@608: #endif insilmaril@608: insilmaril@0: extern TextEditor *textEditor; insilmaril@0: extern Main *mainWindow; insilmaril@164: extern QString tmpVymDir; insilmaril@166: extern QString clipboardDir; insilmaril@491: extern QString clipboardFile; 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@502: extern bool debug; 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@625: #if defined(Q_OS_WIN32) insilmaril@625: extern QDir vymInstallDir; insilmaril@625: #endif 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@625: #if defined(Q_OS_WIN32) insilmaril@625: if (settings.value("/mainwindow/geometry/maximized", false).toBool()) insilmaril@625: { anng888@632: setWindowState(Qt::WindowMaximized); insilmaril@625: } insilmaril@625: else insilmaril@625: #endif insilmaril@625: { insilmaril@625: resize (settings.value("/mainwindow/geometry/size", QSize (800,600)).toSize()); insilmaril@625: move (settings.value("/mainwindow/geometry/pos", QPoint(300,100)).toPoint()); insilmaril@625: } 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@608: tmpVymDir=makeTmpDir (ok,"vym"); 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@502: if (debug) qDebug (QString("vym tmpDir=%1").arg(tmpVymDir) ); insilmaril@164: insilmaril@166: // Create direcctory for clipboard insilmaril@166: clipboardDir=tmpVymDir+"/clipboard"; insilmaril@502: clipboardFile="map.xml"; 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@486: // Satellite windows ////////////////////////////////////////// insilmaril@486: insilmaril@486: // history window insilmaril@404: historyWindow=new HistoryWindow(); insilmaril@486: connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions())); insilmaril@486: insilmaril@486: // properties window insilmaril@421: branchPropertyWindow = new BranchPropertyWindow(); insilmaril@486: connect (branchPropertyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions())); insilmaril@486: insilmaril@486: // Connect TextEditor, so that we can update flags if text changes insilmaril@486: connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag())); insilmaril@486: connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions())); insilmaril@486: insilmaril@486: // Connect HistoryWindow, so that we can update flags insilmaril@486: connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions())); insilmaril@473: insilmaril@421: insilmaril@432: // Initialize script editor insilmaril@432: scriptEditor = new SimpleScriptEditor(); insilmaril@432: scriptEditor->move (50,50); insilmaril@432: insilmaril@432: connect( scriptEditor, SIGNAL( runScript ( QString ) ), insilmaril@432: this, SLOT( runScript( QString ) ) ); insilmaril@432: insilmaril@486: insilmaril@486: // Initialize Find window insilmaril@486: findWindow=new FindWindow(NULL); insilmaril@486: findWindow->move (x(),y()+70); insilmaril@486: connect (findWindow, SIGNAL( findButton(QString) ), insilmaril@486: this, SLOT(editFind(QString) ) ); insilmaril@486: connect (findWindow, SIGNAL( somethingChanged() ), insilmaril@486: this, SLOT(editFindChanged() ) ); insilmaril@486: 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@608: s=settings.value (p,"xdg-open").toString(); insilmaril@0: #else insilmaril@0: #if defined(Q_OS_MACX) insilmaril@366: s=settings.value (p,"/usr/bin/open").toString(); insilmaril@608: insilmaril@608: #else insilmaril@608: #if defined(Q_OS_WIN32) insilmaril@608: // Assume that system has been set up so that insilmaril@608: // Explorer automagically opens up the URL insilmaril@608: // in the user's preferred browser. insilmaril@608: s=settings.value (p,"explorer").toString(); insilmaril@608: #else insilmaril@608: s=settings.value (p,"mozilla").toString(); insilmaril@608: #endif 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@608: s=settings.value (p,"xdg-open").toString(); insilmaril@0: #else insilmaril@0: #if defined(Q_OS_MACX) insilmaril@366: s=settings.value (p,"/usr/bin/open").toString(); insilmaril@625: #elif defined(Q_OS_WIN32) insilmaril@625: s=settings.value (p,"acrord32").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@600: // width of xLinksMenu insilmaril@600: xLinkMenuWidth=60; 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@528: setupNetworkActions(); insilmaril@0: setupSettingsActions(); insilmaril@0: setupContextMenus(); insilmaril@445: setupMacros(); 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: updateGeometry(); insilmaril@0: } insilmaril@0: insilmaril@0: Main::~Main() insilmaril@0: { insilmaril@0: // Save Settings insilmaril@625: #if defined(Q_OS_WIN32) insilmaril@625: settings.setValue ("/mainwindow/geometry/maximized", isMaximized()); insilmaril@625: #endif insilmaril@625: settings.setValue ("/mainwindow/geometry/size", size()); insilmaril@625: 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@491: settings.setValue( "/mapeditor/autosave/use",actionSettingsAutosaveToggle->isOn() ); insilmaril@537: settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isOn() ); insilmaril@625: settings.setValue( "/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() ); insilmaril@390: settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() ); insilmaril@537: settings.setValue( "/mapeditor/editmode/autoEditNewBranch",actionSettingsAutoEditNewBranch->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@473: //TODO save scriptEditor settings insilmaril@432: insilmaril@404: // call the destructors insilmaril@442: delete textEditor; insilmaril@404: delete historyWindow; insilmaril@473: delete branchPropertyWindow; 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@502: 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@491: a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this); insilmaril@395: a->setStatusTip ( tr( "New map","Status tip File menu" ) ); insilmaril@442: a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map insilmaril@0: a->addTo( tb ); insilmaril@366: fileMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) ); insilmaril@0: insilmaril@494: a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this); insilmaril@491: a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) ); insilmaril@491: a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N ); //New map insilmaril@491: fileMenu->addAction (a); insilmaril@491: connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) ); insilmaril@689: actionFileNewCopy=a; insilmaril@491: 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@442: a->setShortcut ( Qt::CTRL + Qt::Key_O ); //Open map 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@442: a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map 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@571: a = new QAction("Freemind...",this); insilmaril@571: a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Freemind") ); insilmaril@571: fileImportMenu->addAction (a); insilmaril@571: connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFreemind() ) ); insilmaril@571: 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@442: a->setShortcut (Qt::ALT + Qt::Key_X); //Export XHTML 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@497: a = new QAction( "Spreadsheet (CSV)...", this); insilmaril@497: a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" ))); insilmaril@497: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) ); insilmaril@497: fileExportMenu->addAction (a); insilmaril@497: 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@442: a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map 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@473: a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map 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@442: a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym 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@442: a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action 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@442: a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action 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@442: a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy 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@442: a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut 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@442: a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste 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@442: a->setShortcut ( Qt::Key_Enter); //Edit heading 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@442: a->setShortcut (Qt::Key_Return ); //Edit heading 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@445: //a->setShortcut ( Qt::Key_F2 ); //Edit heading 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@442: a->setShortcut ( Qt::Key_Delete); //Delete selection 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@684: // Shortcut to add mapcenter insilmaril@684: a= new QAction(tr( "Add mapcenter","Canvas context menu" ), this); insilmaril@684: connect( a, SIGNAL( triggered() ), this, SLOT( editAddMapCenter() ) ); insilmaril@684: actionEditAddMapCenter = a; insilmaril@684: insilmaril@684: 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@442: alt->setShortcut (Qt::Key_A); //Add branch 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@442: a->setShortcut (Qt::Key_Insert); //Add branch 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@442: a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch 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@442: a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch 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@442: a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above 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@442: a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above 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@442: a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below 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@442: a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below 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@442: a->setShortcut (Qt::Key_PageUp ); // Move branch up 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@442: a->setShortcut ( Qt::Key_PageDown ); // Move branch down insilmaril@0: a->setEnabled (false); insilmaril@366: tb->addAction (a); insilmaril@366: editMenu->addAction (a); insilmaril@0: actionEditMoveDown=a; insilmaril@98: insilmaril@608: a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this ); insilmaril@608: connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) ); insilmaril@608: a->setEnabled (true); insilmaril@608: a->addTo( tb ); insilmaril@613: editMenu->addAction (a); insilmaril@608: actionEditSortChildren=a; 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@442: alt->setShortcut ( Qt::Key_S ); // Scroll branch 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@473: a = new QAction( tr( "Unscroll childs","Edit menu" ), this); insilmaril@473: a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" )); insilmaril@366: editMenu->addAction (a); insilmaril@473: connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChilds() ) ); 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@442: a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find 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@528: //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@528: 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@528: a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this); insilmaril@528: a->setStatusTip ( tr( "Edit local URL" ) ); insilmaril@528: a->setShortcut (Qt::SHIFT + Qt::Key_U ); insilmaril@528: a->setShortcutContext (Qt::WindowShortcut); insilmaril@528: actionListBranches.append(a); insilmaril@528: addAction(a); insilmaril@528: connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) ); insilmaril@600: actionEditLocalURL=a; insilmaril@528: 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@486: a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this); insilmaril@486: a->setStatusTip ( tr( "Create URL to Novell 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@486: a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this); insilmaril@486: a->setStatusTip ( tr( "Create URL to Novell 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@473: a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this); insilmaril@442: a->setStatusTip (tr( "Set properties for selection" )); insilmaril@442: a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window insilmaril@442: a->setShortcutContext (Qt::WindowShortcut); insilmaril@486: a->setToggleAction (true); insilmaril@442: addAction (a); insilmaril@473: connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) ); insilmaril@486: actionViewTogglePropertyWindow=a; 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@442: a->setShortcut (Qt::CTRL + Qt::Key_B); 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@505: a= new QAction( tr( "Linkstyle Curve" ), 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@505: a= new QAction( tr( "Linkstyle Thick Curve" ), 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@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@442: a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this ); insilmaril@442: a->setStatusTip (tr( "Set Selection Color" )); insilmaril@442: formatMenu->addAction (a); insilmaril@442: connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) ); insilmaril@442: actionFormatSelectionColor=a; insilmaril@442: 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@526: a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this); insilmaril@526: a->setStatusTip (tr( "Show selection" )); insilmaril@526: a->setShortcut (Qt::Key_Period); insilmaril@526: a->addTo( tb ); insilmaril@526: viewMenu->addAction (a); insilmaril@526: connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) ); insilmaril@526: insilmaril@486: viewMenu->addSeparator(); 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: a->addTo( tb ); insilmaril@366: viewMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) ); insilmaril@0: actionViewToggleNoteEditor=a; insilmaril@294: insilmaril@442: a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this ); insilmaril@442: 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@486: viewMenu->addAction (actionViewTogglePropertyWindow); insilmaril@486: insilmaril@486: viewMenu->addSeparator(); insilmaril@442: 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@473: a = new QAction(tr( "Next Map","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@473: a = new QAction (tr( "Previous Map","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@582: QToolBar *tb=NULL; insilmaril@582: bool avis=true; insilmaril@582: 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@582: setupFlag (fo,tb,avis,"note",tr("Note","SystemFlag")); insilmaril@166: insilmaril@269: fo->load(QPixmap(flagsPath+"flag-url.png")); insilmaril@582: setupFlag (fo,tb,avis,"url",tr("URL to Document ","SystemFlag")); insilmaril@166: insilmaril@269: fo->load(QPixmap(flagsPath+"flag-vymlink.png")); insilmaril@582: setupFlag (fo,tb,avis,"vymLink",tr("Link to another vym map","SystemFlag")); insilmaril@166: insilmaril@269: fo->load(QPixmap(flagsPath+"flag-scrolled-right.png")); insilmaril@582: setupFlag (fo,tb,avis,"scrolledright",tr("subtree is scrolled","SystemFlag")); insilmaril@166: insilmaril@269: fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png")); insilmaril@582: setupFlag (fo,tb,avis,"tmpUnscrolledright",tr("subtree is temporary scrolled","SystemFlag")); insilmaril@166: insilmaril@269: fo->load(QPixmap(flagsPath+"flag-hideexport.png")); insilmaril@582: setupFlag (fo,tb,avis,"hideInExport",tr("Hide object in exported maps","SystemFlag")); insilmaril@243: insilmaril@166: // Create Standard Flags insilmaril@582: 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->setGroup("standard-mark"); insilmaril@582: setupFlag (fo,tb,avis,"exclamationmark",tr("Take care!","Standardflag")); insilmaril@166: insilmaril@408: fo->load(flagsPath+"flag-questionmark.png"); insilmaril@166: fo->setGroup("standard-mark"); insilmaril@582: setupFlag (fo,tb,avis,"questionmark",tr("Really?","Standardflag")); insilmaril@166: insilmaril@408: fo->load(flagsPath+"flag-hook-green.png"); insilmaril@166: fo->setGroup("standard-hook"); insilmaril@582: setupFlag (fo,tb,avis,"hook-green",tr("ok!","Standardflag")); insilmaril@166: insilmaril@408: fo->load(flagsPath+"flag-cross-red.png"); insilmaril@166: fo->setGroup("standard-hook"); insilmaril@582: setupFlag (fo,tb,avis,"cross-red",tr("Not ok!","Standardflag")); insilmaril@582: fo->unsetGroup(); insilmaril@166: insilmaril@408: fo->load(flagsPath+"flag-stopsign.png"); insilmaril@582: setupFlag (fo,tb,avis,"stopsign",tr("This won't work!","Standardflag")); insilmaril@166: insilmaril@408: fo->load(flagsPath+"flag-smiley-good.png"); insilmaril@166: fo->setGroup("standard-smiley"); insilmaril@582: setupFlag (fo,tb,avis,"smiley-good",tr("Good","Standardflag")); insilmaril@166: insilmaril@408: fo->load(flagsPath+"flag-smiley-sad.png"); insilmaril@166: fo->setGroup("standard-smiley"); insilmaril@585: setupFlag (fo,tb,avis,"smiley-sad",tr("Bad","Standardflag")); insilmaril@166: insilmaril@408: fo->load(flagsPath+"flag-smiley-omg.png"); insilmaril@582: fo->setGroup("standard-smiley"); insilmaril@582: setupFlag (fo,tb,avis,"smiley-omb",tr("Oh no!","Standardflag")); insilmaril@269: // Original omg.png (in KDE emoticons) insilmaril@582: fo->unsetGroup(); insilmaril@269: insilmaril@408: fo->load(flagsPath+"flag-kalarm.png"); insilmaril@582: setupFlag (fo,tb,avis,"clock",tr("Time critical","Standardflag")); insilmaril@166: insilmaril@408: fo->load(flagsPath+"flag-phone.png"); insilmaril@582: setupFlag (fo,tb,avis,"phone",tr("Call...","Standardflag")); insilmaril@269: insilmaril@408: fo->load(flagsPath+"flag-lamp.png"); insilmaril@582: setupFlag (fo,tb,avis,"lamp",tr("Idea!","Standardflag")); insilmaril@166: insilmaril@408: fo->load(flagsPath+"flag-arrow-up.png"); insilmaril@166: fo->setGroup("standard-arrow"); insilmaril@582: setupFlag (fo,tb,avis,"arrow-up",tr("Important","Standardflag")); insilmaril@166: insilmaril@408: fo->load(flagsPath+"flag-arrow-down.png"); insilmaril@166: fo->setGroup("standard-arrow"); insilmaril@582: setupFlag (fo,tb,avis,"arrow-down",tr("Unimportant","Standardflag")); insilmaril@166: insilmaril@408: fo->load(flagsPath+"flag-arrow-2up.png"); insilmaril@269: fo->setGroup("standard-arrow"); insilmaril@582: setupFlag (fo,tb,avis,"2arrow-up",tr("Very important!","Standardflag")); insilmaril@269: insilmaril@408: fo->load(flagsPath+"flag-arrow-2down.png"); insilmaril@269: fo->setGroup("standard-arrow"); insilmaril@614: setupFlag (fo,tb,avis,"2arrow-down",tr("Very unimportant!","Standardflag")); insilmaril@582: fo->unsetGroup(); insilmaril@269: insilmaril@408: fo->load(flagsPath+"flag-thumb-up.png"); insilmaril@166: fo->setGroup("standard-thumb"); insilmaril@582: setupFlag (fo,tb,avis,"thumb-up",tr("I like this","Standardflag")); insilmaril@166: insilmaril@408: fo->load(flagsPath+"flag-thumb-down.png"); insilmaril@166: fo->setGroup("standard-thumb"); insilmaril@582: setupFlag (fo,tb,avis,"thumb-down",tr("I do not like this","Standardflag")); insilmaril@582: fo->unsetGroup(); insilmaril@166: insilmaril@408: fo->load(flagsPath+"flag-rose.png"); insilmaril@582: setupFlag (fo,tb,avis,"rose",tr("Rose","Standardflag")); insilmaril@269: insilmaril@408: fo->load(flagsPath+"flag-heart.png"); insilmaril@582: setupFlag (fo,tb,avis,"heart",tr("I just love...","Standardflag")); insilmaril@564: insilmaril@408: fo->load(flagsPath+"flag-present.png"); insilmaril@582: setupFlag (fo,tb,avis,"present",tr("Surprise!","Standardflag")); insilmaril@564: insilmaril@564: fo->load(flagsPath+"flag-flash.png"); insilmaril@582: setupFlag (fo,tb,avis,"flash",tr("Dangerous","Standardflag")); insilmaril@564: insilmaril@564: // Original: xsldbg_output.png insilmaril@564: fo->load(flagsPath+"flag-info.png"); insilmaril@582: setupFlag (fo,tb,avis,"info",tr("Info","Standardflag")); insilmaril@564: insilmaril@564: // Original khelpcenter.png insilmaril@564: fo->load(flagsPath+"flag-lifebelt.png"); insilmaril@582: setupFlag (fo,tb,avis,"lifebelt",tr("This will help","Standardflag")); insilmaril@564: insilmaril@564: // Freemind flags insilmaril@564: insilmaril@582: avis=false; insilmaril@582: insilmaril@564: fo->load(flagsPath+"freemind/warning.png"); insilmaril@582: setupFlag (fo,tb, avis, "freemind-warning",tr("Important","Freemind-Flag")); insilmaril@564: insilmaril@564: for (int i=1; i<8; i++) insilmaril@564: { insilmaril@564: fo->load(flagsPath+QString("freemind/priority-%1.png").arg(i)); insilmaril@582: setupFlag (fo,tb, avis,QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag")); insilmaril@564: } insilmaril@564: insilmaril@564: fo->load(flagsPath+"freemind/back.png"); insilmaril@582: setupFlag (fo,tb,avis,"freemind-back",tr("Back","Freemind-Flag")); insilmaril@564: insilmaril@564: fo->load(flagsPath+"freemind/forward.png"); insilmaril@582: setupFlag (fo,tb,avis,"freemind-forward",tr("Forward","Freemind-Flag")); insilmaril@564: insilmaril@564: fo->load(flagsPath+"freemind/attach.png"); insilmaril@582: setupFlag (fo,tb,avis,"freemind-attach",tr("Look here","Freemind-Flag")); insilmaril@564: insilmaril@564: fo->load(flagsPath+"freemind/clanbomber.png"); insilmaril@582: setupFlag (fo,tb,avis,"freemind-clanbomber",tr("Dangerous","Freemind-Flag")); insilmaril@564: insilmaril@564: fo->load(flagsPath+"freemind/desktopnew.png"); insilmaril@582: setupFlag (fo,tb,avis,"freemind-desktopnew",tr("Don't forget","Freemind-Flag")); insilmaril@564: insilmaril@564: fo->load(flagsPath+"freemind/flag.png"); insilmaril@582: setupFlag (fo,tb,avis,"freemind-flag",tr("Flag","Freemind-Flag")); insilmaril@564: insilmaril@564: insilmaril@564: fo->load(flagsPath+"freemind/gohome.png"); insilmaril@582: setupFlag (fo,tb,avis,"freemind-gohome",tr("Home","Freemind-Flag")); insilmaril@564: insilmaril@564: insilmaril@564: fo->load(flagsPath+"freemind/kaddressbook.png"); insilmaril@582: setupFlag (fo,tb,avis,"freemind-kaddressbook",tr("Telephone","Freemind-Flag")); insilmaril@564: insilmaril@564: fo->load(flagsPath+"freemind/knotify.png"); insilmaril@582: setupFlag (fo,tb,avis,"freemind-knotify",tr("Music","Freemind-Flag")); insilmaril@564: insilmaril@564: fo->load(flagsPath+"freemind/korn.png"); insilmaril@582: setupFlag (fo,tb,avis,"freemind-korn",tr("Mailbox","Freemind-Flag")); insilmaril@564: insilmaril@564: fo->load(flagsPath+"freemind/mail.png"); insilmaril@582: setupFlag (fo,tb,avis,"freemind-mail",tr("Maix","Freemind-Flag")); insilmaril@564: insilmaril@564: fo->load(flagsPath+"freemind/password.png"); insilmaril@582: setupFlag (fo,tb,avis,"freemind-password",tr("Password","Freemind-Flag")); insilmaril@564: insilmaril@564: fo->load(flagsPath+"freemind/pencil.png"); insilmaril@582: setupFlag (fo,tb,avis,"freemind-pencil",tr("To be improved","Freemind-Flag")); insilmaril@564: insilmaril@564: fo->load(flagsPath+"freemind/stop.png"); insilmaril@582: setupFlag (fo,tb,avis,"freemind-stop",tr("Stop","Freemind-Flag")); insilmaril@564: insilmaril@564: fo->load(flagsPath+"freemind/wizard.png"); insilmaril@582: setupFlag (fo,tb,avis,"freemind-wizard",tr("Magic","Freemind-Flag")); insilmaril@564: insilmaril@564: fo->load(flagsPath+"freemind/xmag.png"); insilmaril@582: setupFlag (fo,tb,avis,"freemind-xmag",tr("To be discussed","Freemind-Flag")); insilmaril@564: insilmaril@564: fo->load(flagsPath+"freemind/bell.png"); insilmaril@582: setupFlag (fo,tb,avis,"freemind-bell",tr("Reminder","Freemind-Flag")); insilmaril@564: insilmaril@564: fo->load(flagsPath+"freemind/bookmark.png"); insilmaril@582: setupFlag (fo,tb,avis,"freemind-bookmark",tr("Excellent","Freemind-Flag")); insilmaril@564: insilmaril@564: fo->load(flagsPath+"freemind/penguin.png"); insilmaril@582: setupFlag (fo,tb,avis,"freemind-penguin",tr("Linux","Freemind-Flag")); insilmaril@564: insilmaril@564: fo->load(flagsPath+"freemind/licq.png"); insilmaril@582: setupFlag (fo,tb,avis,"freemind-licq",tr("Sweet","Freemind-Flag")); insilmaril@564: insilmaril@564: delete (fo); insilmaril@564: } insilmaril@564: insilmaril@582: void Main::setupFlag (FlagObj *fo, QToolBar *tb, bool aw, const QString &name, const QString &tooltip) insilmaril@564: { insilmaril@564: fo->setName(name); insilmaril@582: fo->setToolTip (tooltip); insilmaril@564: QAction *a=new QAction (fo->getPixmap(),fo->getName(),this); insilmaril@582: if (tb) insilmaril@582: { insilmaril@582: // StandardFlag insilmaril@582: tb->addAction (a); insilmaril@582: fo->setAction (a); insilmaril@582: fo->setAlwaysVisible(aw); insilmaril@582: a->setCheckable(true); insilmaril@582: a->setObjectName(fo->getName()); insilmaril@582: a->setToolTip(tooltip); insilmaril@582: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@582: standardFlagsDefault->addFlag (fo); insilmaril@582: } else insilmaril@582: { insilmaril@582: // SystemFlag insilmaril@582: systemFlagsDefault->addFlag (fo); insilmaril@582: } insilmaril@0: } insilmaril@528: // Network Actions insilmaril@528: void Main::setupNetworkActions() insilmaril@528: { insilmaril@528: if (!settings.value( "/mainwindow/showTestMenu",false).toBool() ) insilmaril@528: return; insilmaril@635: QMenu *netMenu = menuBar()->addMenu( "Network" ); insilmaril@528: insilmaril@528: QAction *a; insilmaril@528: insilmaril@528: a = new QAction( "Start TCPserver for MapEditor",this); insilmaril@528: //a->setStatusTip ( "Set application to open pdf files")); insilmaril@528: a->setShortcut ( Qt::Key_T ); //New TCP server insilmaril@528: connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) ); insilmaril@528: netMenu->addAction (a); insilmaril@528: insilmaril@528: a = new QAction( "Connect MapEditor to server",this); insilmaril@528: //a->setStatusTip ( "Set application to open pdf files")); insilmaril@528: a->setShortcut ( Qt::Key_C ); // Connect to server insilmaril@528: connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) ); insilmaril@528: netMenu->addAction (a); insilmaril@528: } insilmaril@528: 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@473: a = new QAction( tr( "Set path for macros","Settings action")+"...", this); insilmaril@450: a->setStatusTip( tr( "Set path for macros")); insilmaril@450: connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) ); insilmaril@450: settingsMenu->addAction (a); insilmaril@450: insilmaril@473: a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this); insilmaril@473: a->setStatusTip( tr( "Set number of undo levels")); insilmaril@473: connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) ); insilmaril@473: settingsMenu->addAction (a); insilmaril@473: insilmaril@366: settingsMenu->addSeparator(); insilmaril@473: insilmaril@473: a = new QAction( tr( "Autosave","Settings action"), this); insilmaril@473: a->setStatusTip( tr( "Autosave")); insilmaril@473: a->setToggleAction(true); insilmaril@628: a->setOn ( settings.value ("/mapeditor/autosave/use",false).toBool()); insilmaril@473: connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) ); insilmaril@473: settingsMenu->addAction (a); insilmaril@473: actionSettingsAutosaveToggle=a; insilmaril@473: insilmaril@473: a = new QAction( tr( "Autosave time","Settings action")+"...", this); insilmaril@473: a->setStatusTip( tr( "Autosave time")); insilmaril@473: connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) ); insilmaril@473: settingsMenu->addAction (a); insilmaril@473: actionSettingsAutosaveTime=a; insilmaril@473: insilmaril@628: a = new QAction( tr( "Write backup file on save","Settings action"), this); insilmaril@628: a->setStatusTip( tr( "Write backup file on save")); insilmaril@625: a->setToggleAction(true); insilmaril@625: a->setOn ( settings.value ("/mainwindow/writeBackupFile",false).toBool()); insilmaril@625: connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) ); insilmaril@625: settingsMenu->addAction (a); insilmaril@625: actionSettingsWriteBackupFile=a; insilmaril@625: insilmaril@473: settingsMenu->addSeparator(); insilmaril@473: 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@537: a->setOn ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool()); insilmaril@366: settingsMenu->addAction (a); insilmaril@537: actionSettingsAutoEditNewBranch=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@537: a->setOn ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() ); insilmaril@366: settingsMenu->addAction (a); insilmaril@537: actionSettingsAutoSelectNewBranch=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@505: a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",true).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@689: insilmaril@689: a = new QAction( tr( "Animation","Settings action"), this); insilmaril@689: a->setStatusTip( tr( "Animation")); insilmaril@689: a->setToggleAction(true); insilmaril@689: a->setOn (settings.value("/animation/use",false).toBool() ); insilmaril@689: connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) ); insilmaril@689: if (settings.value( "/mainwindow/showTestMenu",false).toBool() ) insilmaril@689: { insilmaril@689: settingsMenu->addAction (a); insilmaril@689: } insilmaril@689: actionSettingsUseAnimation=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@527: a = new QAction( "Test function 1" , this); insilmaril@527: a->setStatusTip( "Call test function 1" ); insilmaril@527: testMenu->addAction (a); insilmaril@527: connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) ); insilmaril@527: insilmaril@527: a = new QAction( "Test function 2" , this); insilmaril@527: a->setStatusTip( "Call test function 2" ); insilmaril@366: testMenu->addAction (a); insilmaril@527: connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) ); insilmaril@527: insilmaril@395: a = new QAction( "Command" , this); insilmaril@395: a->setStatusTip( "Enter command to call in editor" ); 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@505: a = new QAction( tr( "Open VYM example maps ","Help action" ), this ); insilmaril@505: a->setStatusTip( tr( "Open VYM example maps " )); insilmaril@505: connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) ); insilmaril@505: helpMenu->addAction (a); insilmaril@505: 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@486: branchContextMenu->addAction (actionViewTogglePropertyWindow); insilmaril@421: branchContextMenu->addSeparator(); insilmaril@421: 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@689: actionFileNewCopy->addTo (branchContextMenu ); insilmaril@98: insilmaril@366: branchContextMenu->addSeparator(); insilmaril@398: branchContextMenu->addAction ( actionEditLoadImage); insilmaril@366: insilmaril@366: // Submenu for Links (URLs, vymLinks) insilmaril@366: branchLinksContextMenu =new QMenu (this); insilmaril@366: insilmaril@366: branchContextMenu->addSeparator(); insilmaril@473: branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, 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@600: branchLinksContextMenu->addAction ( actionEditLocalURL ); insilmaril@366: branchLinksContextMenu->addAction ( actionEditHeading2URL ); insilmaril@366: branchLinksContextMenu->addAction ( actionEditBugzilla2URL ); insilmaril@528: if (settings.value( "/mainwindow/showTestMenu",false).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@684: if (settings.value( "/mainwindow/showTestMenu",false).toBool() ) insilmaril@684: actionEditAddMapCenter->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@442: actionFormatSelectionColor->addTo( canvasContextMenu ); insilmaril@0: actionFormatBackColor->addTo( canvasContextMenu ); insilmaril@505: // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME makes vym too slow: postponed for later version 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@445: recentFileActions[i] = new QAction(this); insilmaril@445: recentFileActions[i]->setVisible(false); insilmaril@445: fileLastMapsMenu->addAction(recentFileActions[i]); insilmaril@445: connect(recentFileActions[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(files[i]); insilmaril@445: recentFileActions[i]->setText(text); insilmaril@445: recentFileActions[i]->setData(files[i]); insilmaril@445: recentFileActions[i]->setVisible(true); insilmaril@401: } insilmaril@401: for (int j = numRecentFiles; j < MaxRecentFiles; ++j) insilmaril@445: recentFileActions[j]->setVisible(false); insilmaril@445: } insilmaril@445: insilmaril@445: void Main::setupMacros() insilmaril@445: { insilmaril@445: for (int i = 0; i <= 11; i++) insilmaril@445: { insilmaril@445: macroActions[i] = new QAction(this); insilmaril@445: macroActions[i]->setData(i); insilmaril@445: addAction (macroActions[i]); insilmaril@445: connect(macroActions[i], SIGNAL(triggered()), insilmaril@445: this, SLOT(callMacro())); insilmaril@445: } insilmaril@445: macroActions[0]->setShortcut ( Qt::Key_F1 ); insilmaril@445: macroActions[1]->setShortcut ( Qt::Key_F2 ); insilmaril@445: macroActions[2]->setShortcut ( Qt::Key_F3 ); insilmaril@445: macroActions[3]->setShortcut ( Qt::Key_F4 ); insilmaril@445: macroActions[4]->setShortcut ( Qt::Key_F5 ); insilmaril@445: macroActions[5]->setShortcut ( Qt::Key_F6 ); insilmaril@445: macroActions[6]->setShortcut ( Qt::Key_F7 ); insilmaril@445: macroActions[7]->setShortcut ( Qt::Key_F8 ); insilmaril@445: macroActions[8]->setShortcut ( Qt::Key_F9 ); insilmaril@445: macroActions[9]->setShortcut ( Qt::Key_F10 ); insilmaril@445: macroActions[10]->setShortcut ( Qt::Key_F11 ); insilmaril@445: macroActions[11]->setShortcut ( Qt::Key_F12 ); 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@491: if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal(); insilmaril@0: } 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: MapEditor *me; insilmaril@473: for (int 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@491: void Main::fileNewCopy() insilmaril@491: { insilmaril@491: QString fn="unnamed"; insilmaril@491: MapEditor* oldME =currentMapEditor(); insilmaril@491: if (oldME) insilmaril@491: { insilmaril@491: oldME->copy(); insilmaril@491: MapEditor* newME = new MapEditor ( NULL); insilmaril@491: if (newME) insilmaril@491: { insilmaril@491: tabWidget->addTab (newME,fn); insilmaril@491: tabWidget->showPage(newME); insilmaril@491: newME->viewport()->setFocus(); insilmaril@491: newME->setAntiAlias (actionViewToggleAntiAlias->isOn()); insilmaril@491: newME->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn()); insilmaril@491: // For the very first map we do not have flagrows yet... insilmaril@491: newME->select("mc:"); insilmaril@571: newME->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap); insilmaril@491: } insilmaril@491: insilmaril@491: } insilmaril@491: } insilmaril@491: insilmaril@571: ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype) 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@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@676: me->setFilePath (fn); insilmaril@676: err=me->load(fn,lmode,ftype); 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@608: if (!isInTmpDir (fn)) 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@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@473: void Main::fileSave(MapEditor *me, const SaveMode &savemode) insilmaril@0: { insilmaril@676: if (!me) return; insilmaril@679: insilmaril@676: if ( me->getFilePath().isEmpty() ) insilmaril@676: { insilmaril@676: // We have no filepath yet, insilmaril@676: // call fileSaveAs() now, this will call fileSave() insilmaril@676: // again. insilmaril@676: // First switch to editor insilmaril@676: tabWidget->setCurrentWidget (me); insilmaril@676: fileSaveAs(savemode); insilmaril@676: } insilmaril@676: insilmaril@676: if (me->save (savemode)==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@473: fileSave (currentMapEditor(), CompleteMap); insilmaril@473: } insilmaril@473: insilmaril@473: void Main::fileSave(MapEditor *me) insilmaril@473: { insilmaril@473: fileSave (me,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@473: fileSave(currentMapEditor(), 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@571: success==fileLoad (im.getTransformedFile(),NewMap,FreemindMap) && insilmaril@327: currentMapEditor() ) insilmaril@327: currentMapEditor()->setFilePath (""); insilmaril@327: ++it; insilmaril@327: } insilmaril@327: } insilmaril@327: delete (fd); insilmaril@314: } insilmaril@314: insilmaril@571: void Main::fileImportFreemind() insilmaril@571: { insilmaril@571: QStringList filters; insilmaril@571: filters <<"Freemind map (*.mm)"<<"All files (*)"; insilmaril@571: QFileDialog *fd=new QFileDialog( this); insilmaril@571: fd->setDir (lastFileDir); insilmaril@571: fd->setFileMode (QFileDialog::ExistingFiles); insilmaril@571: fd->setFilters (filters); insilmaril@571: fd->setCaption(vymName+ " - " +tr("Load Freemind map")); insilmaril@571: fd->show(); insilmaril@571: insilmaril@571: QString fn; insilmaril@571: if ( fd->exec() == QDialog::Accepted ) insilmaril@571: { insilmaril@571: lastFileDir=fd->directory().path(); insilmaril@571: QStringList flist = fd->selectedFiles(); insilmaril@571: QStringList::Iterator it = flist.begin(); insilmaril@571: while( it != flist.end() ) insilmaril@571: { insilmaril@571: fn = *it; insilmaril@571: if ( fileLoad (fn,NewMap, FreemindMap) ) insilmaril@571: { insilmaril@571: currentMapEditor()->setFilePath (""); insilmaril@571: } insilmaril@571: ++it; insilmaril@571: } insilmaril@571: } insilmaril@571: delete (fd); insilmaril@571: } insilmaril@571: insilmaril@571: 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@526: void Main::fileExportXML() insilmaril@0: { insilmaril@526: MapEditor *me=currentMapEditor(); insilmaril@526: if (me) me->exportXML(); insilmaril@0: } insilmaril@0: insilmaril@0: insilmaril@517: void Main::fileExportXHTML() insilmaril@0: { insilmaril@260: MapEditor *me=currentMapEditor(); insilmaril@517: if (me) me->exportXHTML(); insilmaril@0: } insilmaril@0: insilmaril@517: void Main::fileExportImage() insilmaril@0: { insilmaril@260: MapEditor *me=currentMapEditor(); insilmaril@514: if (me) me->exportImage(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::fileExportASCII() insilmaril@0: { insilmaril@260: MapEditor *me=currentMapEditor(); insilmaril@514: if (me) me->exportASCII(); insilmaril@0: } insilmaril@0: insilmaril@517: void Main::fileExportCSV() //FIXME not scriptable yet insilmaril@497: { insilmaril@497: MapEditor *me=currentMapEditor(); insilmaril@497: if (me) insilmaril@497: { insilmaril@497: ExportCSV ex; insilmaril@645: ex.setModel (me->getModel()); insilmaril@497: ex.addFilter ("CSV (*.csv)"); insilmaril@497: ex.setDir(lastImageDir); insilmaril@497: ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)")); insilmaril@497: if (ex.execDialog() ) insilmaril@497: { insilmaril@497: me->setExportMode(true); insilmaril@497: ex.doExport(); insilmaril@497: me->setExportMode(false); insilmaril@497: } insilmaril@497: } insilmaril@497: } insilmaril@497: insilmaril@517: void Main::fileExportLaTeX() //FIXME not scriptable yet insilmaril@163: { insilmaril@260: MapEditor *me=currentMapEditor(); insilmaril@260: if (me) insilmaril@228: { insilmaril@228: ExportLaTeX ex; insilmaril@645: ex.setModel (me->getModel()); insilmaril@228: ex.addFilter ("Tex (*.tex)"); insilmaril@424: ex.setDir(lastImageDir); 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@517: void Main::fileExportKDEBookmarks() //FIXME not scriptable yet insilmaril@243: { insilmaril@243: ExportKDEBookmarks ex; insilmaril@260: MapEditor *me=currentMapEditor(); insilmaril@260: if (me) insilmaril@243: { insilmaril@645: ex.setModel (me->getModel()); insilmaril@243: ex.doExport(); insilmaril@243: } insilmaril@243: } insilmaril@243: insilmaril@517: void Main::fileExportTaskjuggler() //FIXME not scriptable yet insilmaril@228: { insilmaril@228: ExportTaskjuggler ex; insilmaril@260: MapEditor *me=currentMapEditor(); insilmaril@260: if (me) insilmaril@228: { insilmaril@645: ex.setModel (me->getModel()); insilmaril@404: ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)")); insilmaril@424: ex.setDir(lastImageDir); 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@517: void Main::fileExportOOPresentation() //FIXME not scriptable yet 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@625: MapEditor *me = currentMapEditor(); insilmaril@625: if (me) insilmaril@0: { insilmaril@625: if (me->hasChanged()) insilmaril@0: { insilmaril@404: QMessageBox mb( vymName, insilmaril@625: tr("The map %1 has been modified but not saved yet. Do you want to").arg(me->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@625: fileSave(me, 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@625: me->closeMap(); insilmaril@625: tabWidget->removePage(me); insilmaril@0: if (tabWidget->count()==0) insilmaril@0: actionFilePrint->setEnabled (false); insilmaril@625: delete me; insilmaril@625: } 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@486: if (me->hasChanged()) 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@473: fileSave(currentMapEditor(), 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@608: #if defined(Q_OS_WIN32) insilmaril@608: // There's no sleep in VCEE, replace it with Qt's QThread::wait(). insilmaril@608: this->thread()->wait(3000); insilmaril@608: #else insilmaril@366: sleep (3); insilmaril@608: #endif insilmaril@366: } insilmaril@366: if (browser.contains("konqueror")) insilmaril@366: { insilmaril@366: for (int i=0; ipid()->dwProcessId)<< insilmaril@608: "konqueror-mainwindow#1"<< insilmaril@608: "newTab" << insilmaril@366: urls.at(i); insilmaril@608: #else insilmaril@608: args<< QString("konqueror-%1").arg(procBrowser->pid())<< insilmaril@608: "konqueror-mainwindow#1"<< insilmaril@608: "newTab" << insilmaril@608: urls.at(i); insilmaril@608: #endif insilmaril@366: p->start ("dcop",args); insilmaril@680: //cout << qPrintable (args.join(" "))<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@528: void Main::editLocalURL() insilmaril@528: { insilmaril@528: if (currentMapEditor()) insilmaril@528: currentMapEditor()->editLocalURL(); insilmaril@528: } insilmaril@528: 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@421: if (me) insilmaril@421: { insilmaril@491: me->setStateEditHeading (false); insilmaril@421: QPoint p; //Not used here, only to find out pos of branch insilmaril@421: bool ok; insilmaril@421: QString s=me->getHeading(ok,p); insilmaril@394: insilmaril@625: #if defined(Q_OS_MACX) || defined(Q_OS_WIN32) insilmaril@394: #else insilmaril@421: if (ok && s!=lineedit->text()) insilmaril@421: me->setHeading(lineedit->text()); insilmaril@421: insilmaril@421: lineedit->releaseKeyboard(); insilmaril@421: lineedit->hide(); insilmaril@421: setFocus(); insilmaril@394: #endif insilmaril@537: if (!actionSettingsAutoSelectNewBranch->isOn() && insilmaril@537: !prevSelection.isEmpty()) insilmaril@537: me->select(prevSelection); insilmaril@421: prevSelection=""; insilmaril@421: } 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@531: QString s=me->getHeading(ok,p); insilmaril@366: insilmaril@366: if (ok) insilmaril@366: { insilmaril@491: me->setStateEditHeading (true); insilmaril@625: #if defined(Q_OS_MACX) || defined(Q_OS_WIN32) insilmaril@531: p=me->mapToGlobal (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@531: me->setHeading (le->text()); insilmaril@394: delete (le); insilmaril@394: delete (d); insilmaril@394: editHeadingFinished(); insilmaril@366: #else insilmaril@531: p=me->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@616: void Main::editAttributeFinished() insilmaril@616: { insilmaril@616: // only called from editHeading(), so there is a currentME insilmaril@616: insilmaril@616: /* insilmaril@616: MapEditor *me=currentMapEditor(); insilmaril@616: if (me) insilmaril@616: { insilmaril@616: me->setStateEditHeading (false); insilmaril@616: QPoint p; //Not used here, only to find out pos of branch insilmaril@616: bool ok; insilmaril@616: QString s=me->getHeading(ok,p); insilmaril@616: insilmaril@616: #if defined(Q_OS_MACX) insilmaril@616: #else insilmaril@616: if (ok && s!=lineedit->text()) insilmaril@616: me->setHeading(lineedit->text()); insilmaril@616: insilmaril@616: lineedit->releaseKeyboard(); insilmaril@616: lineedit->hide(); insilmaril@616: setFocus(); insilmaril@616: #endif insilmaril@616: if (!actionSettingsAutoSelectNewBranch->isOn() && insilmaril@616: !prevSelection.isEmpty()) insilmaril@616: me->select(prevSelection); insilmaril@616: prevSelection=""; insilmaril@616: } insilmaril@616: */ insilmaril@616: } insilmaril@616: insilmaril@628: #include "attribute.h" insilmaril@625: #include "attributedialog.h" insilmaril@616: void Main::editAttribute() insilmaril@616: { insilmaril@628: MapEditor *me=currentMapEditor(); insilmaril@628: if (me) insilmaril@628: { insilmaril@628: BranchObj *bo=me->getSelectedBranch(); insilmaril@628: if (bo) insilmaril@628: { insilmaril@628: AttributeDialog dia(this); insilmaril@628: dia.setTable (me->attributeTable() ); insilmaril@628: dia.setBranch (bo); insilmaril@638: dia.setMode (Definition); insilmaril@638: dia.updateTable(); insilmaril@628: dia.exec(); insilmaril@628: } insilmaril@628: } insilmaril@616: /* insilmaril@616: if (currentMapEditor()) insilmaril@616: { insilmaril@616: MapEditor *me=currentMapEditor(); insilmaril@616: QString oldSel=me->getSelectString(); insilmaril@616: insilmaril@616: if (lineedit->isVisible()) insilmaril@616: editAttributeFinished(); insilmaril@616: else insilmaril@616: { insilmaril@616: bool ok; insilmaril@616: QPoint p; insilmaril@616: QString s=me->getHeading(ok,p); insilmaril@616: insilmaril@616: if (ok) insilmaril@616: { insilmaril@616: me->setStateEditHeading (true); insilmaril@616: #if defined(Q_OS_MACX) insilmaril@616: p=me->mapToGlobal (p); insilmaril@616: QDialog *d =new QDialog(NULL); insilmaril@616: QLineEdit *le=new QLineEdit (d); insilmaril@616: d->setWindowFlags (Qt::FramelessWindowHint); insilmaril@616: d->setGeometry(p.x(),p.y(),230,25); insilmaril@616: le->resize (d->width()-10,d->height()); insilmaril@616: le->setText (s); insilmaril@616: le->selectAll(); insilmaril@616: connect (le, SIGNAL (returnPressed()), d, SLOT (accept())); insilmaril@616: d->activateWindow(); insilmaril@616: d->exec(); insilmaril@616: me->setHeading (le->text()); insilmaril@616: delete (le); insilmaril@616: delete (d); insilmaril@616: editHeadingFinished(); insilmaril@616: #else insilmaril@616: p=me->mapTo (this,p); insilmaril@616: lineedit->setGeometry(p.x(),p.y(),230,25); insilmaril@616: lineedit->setText(s); insilmaril@616: lineedit->setCursorPosition(1); insilmaril@616: lineedit->selectAll(); insilmaril@616: lineedit->show(); insilmaril@616: lineedit->grabKeyboard(); insilmaril@616: lineedit->setFocus(); insilmaril@616: #endif insilmaril@616: } insilmaril@616: } insilmaril@616: } // currentMapEditor() insilmaril@616: insilmaril@616: */ insilmaril@616: } insilmaril@616: 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@608: void Main::editSortChildren() insilmaril@608: { insilmaril@608: if (currentMapEditor()) insilmaril@608: currentMapEditor()->sortChildren(); insilmaril@608: } insilmaril@608: insilmaril@0: void Main::editToggleScroll() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: { insilmaril@0: currentMapEditor()->toggleScroll(); insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@473: void Main::editUnscrollChilds() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@428: currentMapEditor()->unscrollChilds(); insilmaril@394: } insilmaril@394: insilmaril@684: void Main::editAddMapCenter() insilmaril@684: { insilmaril@684: MapEditor *me=currentMapEditor(); insilmaril@684: if (!lineedit->isVisible() && me) insilmaril@684: { insilmaril@684: me->addMapCenter (); insilmaril@684: } insilmaril@684: } insilmaril@684: 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@684: prevSelection=me->getModel()->getSelectString(bo); insilmaril@394: if (newbo) insilmaril@684: me->select (newbo); insilmaril@394: else insilmaril@394: return; insilmaril@394: insilmaril@537: if (actionSettingsAutoEditNewBranch->isOn()) insilmaril@394: { insilmaril@394: editHeading(); insilmaril@534: return; insilmaril@534: } insilmaril@534: if (!prevSelection.isEmpty()) insilmaril@534: { insilmaril@534: me->select(prevSelection); insilmaril@534: prevSelection=""; insilmaril@394: } insilmaril@534: 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@684: me->select (newbo); insilmaril@394: else insilmaril@394: return; insilmaril@394: insilmaril@537: if (actionSettingsAutoEditNewBranch->isOn()) insilmaril@394: { insilmaril@537: if (!actionSettingsAutoSelectNewBranch->isOn()) insilmaril@684: prevSelection=me->getModel()->getSelectString(bo); //TODO access directly 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@684: me->select (newbo); insilmaril@394: else insilmaril@394: return; insilmaril@394: insilmaril@537: if (actionSettingsAutoEditNewBranch->isOn()) insilmaril@394: { insilmaril@537: if (!actionSettingsAutoSelectNewBranch->isOn()) insilmaril@684: prevSelection=me->getModel()->getSelectString (bo); // TODO access directly 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@684: me->select (newbo); insilmaril@394: else insilmaril@394: return; insilmaril@394: insilmaril@537: if (actionSettingsAutoEditNewBranch->isOn()) insilmaril@394: { insilmaril@537: if (!actionSettingsAutoSelectNewBranch->isOn()) insilmaril@684: prevSelection=me->getModel()->getSelectString(bo); //TODO access directly 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@625: { insilmaril@398: currentMapEditor()->setMapLinkStyle("StyleLine"); insilmaril@625: actionFormatLinkStyleLine->setOn(true); insilmaril@625: } insilmaril@0: } insilmaril@0: insilmaril@0: void Main::formatLinkStyleParabel() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@625: { insilmaril@398: currentMapEditor()->setMapLinkStyle("StyleParabel"); insilmaril@625: actionFormatLinkStyleParabel->setOn(true); insilmaril@625: } insilmaril@0: } insilmaril@0: insilmaril@0: void Main::formatLinkStylePolyLine() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@625: { insilmaril@398: currentMapEditor()->setMapLinkStyle("StylePolyLine"); insilmaril@625: actionFormatLinkStylePolyLine->setOn(true); insilmaril@625: } insilmaril@0: } insilmaril@0: insilmaril@0: void Main::formatLinkStylePolyParabel() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@625: { insilmaril@398: currentMapEditor()->setMapLinkStyle("StylePolyParabel"); insilmaril@625: actionFormatLinkStylePolyParabel->setOn(true); insilmaril@625: } 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@442: void Main::formatSelectSelectionColor() insilmaril@442: { insilmaril@442: if (currentMapEditor()) insilmaril@442: currentMapEditor()->selectMapSelectionColor(); insilmaril@442: } insilmaril@442: insilmaril@0: void Main::formatToggleLinkColorHint() insilmaril@0: { insilmaril@398: currentMapEditor()->toggleMapLinkColorHint(); insilmaril@0: } insilmaril@0: insilmaril@0: insilmaril@421: void Main::formatHideLinkUnselected() //FIXME get rid of this with imagepropertydialog 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@526: void Main::viewCenter() insilmaril@526: { insilmaril@526: MapEditor *me=currentMapEditor(); insilmaril@526: if (me) insilmaril@526: { insilmaril@526: me->ensureSelectionVisible(); insilmaril@526: } insilmaril@526: } insilmaril@526: insilmaril@528: void Main::networkStartServer() insilmaril@528: { insilmaril@528: MapEditor *me=currentMapEditor(); insilmaril@528: if (me) me->newServer(); insilmaril@528: } insilmaril@528: insilmaril@528: void Main::networkConnect() insilmaril@528: { insilmaril@528: MapEditor *me=currentMapEditor(); insilmaril@531: if (me) me->connectToServer(); insilmaril@528: } insilmaril@528: 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@450: void Main::settingsMacroDir() insilmaril@450: { insilmaril@625: QDir defdir(vymBaseDir.path() + "/macros"); insilmaril@450: if (!defdir.exists()) insilmaril@450: defdir=vymBaseDir; insilmaril@450: QDir dir=QFileDialog::getExistingDirectory ( insilmaril@450: this, insilmaril@450: tr ("Directory with vym macros:"), insilmaril@450: settings.value ("/macros/macroDir",defdir.path()).toString() insilmaril@450: ); insilmaril@450: if (dir.exists()) insilmaril@625: settings.setValue ("/macros/macroDir",dir.absolutePath()); insilmaril@450: } insilmaril@450: insilmaril@473: void Main::settingsUndoLevels() insilmaril@473: { insilmaril@473: bool ok; insilmaril@473: int i = QInputDialog::getInteger( insilmaril@473: this, insilmaril@473: tr("QInputDialog::getInteger()"), insilmaril@473: tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok); insilmaril@473: if (ok) insilmaril@473: { insilmaril@473: settings.setValue ("/mapeditor/stepsTotal",i); insilmaril@473: QMessageBox::information( this, tr( "VYM -Information:" ), insilmaril@473: tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i)); insilmaril@473: } insilmaril@473: } insilmaril@473: insilmaril@473: void Main::settingsAutosaveToggle() insilmaril@473: { insilmaril@531: settings.setValue ("/mapeditor/autosave/use",actionSettingsAutosaveToggle->isOn() ); insilmaril@473: } insilmaril@473: insilmaril@473: void Main::settingsAutosaveTime() insilmaril@473: { insilmaril@473: bool ok; insilmaril@473: int i = QInputDialog::getInteger( insilmaril@473: this, insilmaril@473: tr("QInputDialog::getInteger()"), insilmaril@473: tr("Number of seconds before autosave:"), settings.value("/mapeditor/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok); insilmaril@473: if (ok) insilmaril@473: settings.setValue ("/mapeditor/autosave/ms",i * 1000); insilmaril@473: } insilmaril@473: insilmaril@625: void Main::settingsWriteBackupFileToggle() insilmaril@625: { insilmaril@625: settings.setValue ("/mapeditor/writeBackupFile",actionSettingsWriteBackupFile->isOn() ); insilmaril@625: } insilmaril@625: insilmaril@689: void Main::settingsToggleAnimation() insilmaril@689: { insilmaril@689: settings.setValue ("/animation/use",actionSettingsUseAnimation->isOn() ); insilmaril@689: } insilmaril@689: 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@502: if (textEditor->isVisible() ) insilmaril@497: windowHideNoteEditor(); insilmaril@497: else insilmaril@497: 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@473: void Main::windowToggleProperty() insilmaril@473: { insilmaril@473: if (branchPropertyWindow->isVisible()) insilmaril@473: branchPropertyWindow->hide(); insilmaril@473: else insilmaril@473: branchPropertyWindow->show(); insilmaril@486: insilmaril@473: if(currentMapEditor()) insilmaril@473: { insilmaril@628: BranchObj *bo=currentMapEditor()->getSelectedBranch(); insilmaril@628: if (bo) insilmaril@473: { insilmaril@473: branchPropertyWindow->setMapEditor(currentMapEditor()); insilmaril@628: branchPropertyWindow->setBranch(bo); insilmaril@473: return; insilmaril@473: } insilmaril@473: insilmaril@473: } insilmaril@473: branchPropertyWindow->setBranch(NULL); insilmaril@473: } insilmaril@473: 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@442: void Main::updateSatellites(MapEditor *me) insilmaril@442: { insilmaril@442: branchPropertyWindow->setMapEditor (me); insilmaril@442: } insilmaril@442: insilmaril@390: void Main::updateActions() insilmaril@390: { insilmaril@390: MapEditor *me=currentMapEditor(); insilmaril@390: if (!me) return; insilmaril@390: insilmaril@491: historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(currentMapEditor()->getFileName())); insilmaril@407: insilmaril@390: // updateActions is also called when NoteEditor is closed insilmaril@486: actionViewToggleNoteEditor->setOn (textEditor->isVisible()); insilmaril@486: actionViewToggleHistoryWindow->setOn (historyWindow->isVisible()); insilmaril@486: actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible()); insilmaril@390: insilmaril@473: if (me->getMapLinkColorHint()==LinkableMapObj::HeadingColor) insilmaril@390: actionFormatLinkColorHint->setOn(true); insilmaril@390: else insilmaril@390: actionFormatLinkColorHint->setOn(false); insilmaril@390: insilmaril@398: switch (me->getMapLinkStyle()) insilmaril@390: { insilmaril@473: case LinkableMapObj::Line: insilmaril@390: actionFormatLinkStyleLine->setOn(true); insilmaril@390: break; insilmaril@473: case LinkableMapObj::Parabel: insilmaril@390: actionFormatLinkStyleParabel->setOn(true); insilmaril@390: break; insilmaril@473: case LinkableMapObj::PolyLine: insilmaril@390: actionFormatLinkStylePolyLine->setOn(true); insilmaril@390: break; insilmaril@473: case LinkableMapObj::PolyParabel: insilmaril@390: actionFormatLinkStylePolyParabel->setOn(true); insilmaril@390: break; insilmaril@390: default: insilmaril@390: break; insilmaril@390: } insilmaril@390: insilmaril@442: // Update colors insilmaril@390: QPixmap pix( 16, 16 ); insilmaril@398: pix.fill( me->getMapBackgroundColor() ); insilmaril@390: actionFormatBackColor->setIconSet( pix ); insilmaril@442: pix.fill( me->getSelectionColor() ); insilmaril@442: actionFormatSelectionColor->setIconSet( pix ); insilmaril@398: pix.fill( me->getMapDefLinkColor() ); insilmaril@390: actionFormatLinkColor->setIconSet( pix ); insilmaril@390: insilmaril@442: insilmaril@486: actionFileSave->setEnabled( me->hasChanged() ); 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@600: if (s.length()>xLinkMenuWidth) insilmaril@600: s=s.left(xLinkMenuWidth)+"..."; 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: 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@473: Main::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@537: bool Main::autoEditNewBranch() insilmaril@390: { insilmaril@537: return actionSettingsAutoEditNewBranch->isOn(); insilmaril@390: } insilmaril@390: insilmaril@537: bool Main::autoSelectNewBranch() insilmaril@390: { insilmaril@537: return actionSettingsAutoSelectNewBranch->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@497: textEditor->setShowWithMain(true); insilmaril@0: textEditor->show(); insilmaril@0: actionViewToggleNoteEditor->setOn (true); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::windowHideNoteEditor() insilmaril@0: { insilmaril@497: textEditor->setShowWithMain(false); insilmaril@0: textEditor->hide(); insilmaril@0: actionViewToggleNoteEditor->setOn (false); insilmaril@0: } insilmaril@0: insilmaril@434: void Main::setScript (const QString &script) insilmaril@434: { insilmaril@434: scriptEditor->setScript (script); insilmaril@434: } insilmaril@434: insilmaril@434: void Main::runScript (const QString &script) insilmaril@432: { insilmaril@432: if (currentMapEditor()) insilmaril@432: currentMapEditor()->runScript (script); insilmaril@432: } insilmaril@432: insilmaril@514: void Main::runScriptEverywhere (const QString &script) insilmaril@514: { insilmaril@514: MapEditor *me; insilmaril@514: for (int i=0;i<=tabWidget->count() -1;i++) insilmaril@514: { insilmaril@514: me=(MapEditor*)tabWidget->page(i); insilmaril@514: if (me) me->runScript (script); insilmaril@514: } insilmaril@514: } insilmaril@514: 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@421: if (currentMapEditor()) insilmaril@421: currentMapEditor()->toggleStandardFlag(sender()->name()); insilmaril@0: } insilmaril@0: insilmaril@527: void Main::testFunction1() insilmaril@0: { insilmaril@393: if (!currentMapEditor()) return; insilmaril@689: currentMapEditor()->testFunction1(); insilmaril@689: //editAttribute(); insilmaril@527: } insilmaril@527: insilmaril@527: void Main::testFunction2() insilmaril@527: { insilmaril@527: if (!currentMapEditor()) return; insilmaril@564: currentMapEditor()->testFunction2(); insilmaril@0: } insilmaril@0: insilmaril@393: void Main::testCommand() insilmaril@393: { insilmaril@393: if (!currentMapEditor()) return; insilmaril@432: scriptEditor->show(); insilmaril@432: /* 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@432: */ 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@420: insilmaril@420: QStringList searchList; insilmaril@395: QDir docdir; insilmaril@103: #if defined(Q_OS_MACX) insilmaril@537: searchList << "./vym.app/Contents/Resources/doc"; insilmaril@625: #elif defined(Q_OS_WIN32) insilmaril@625: searchList << vymInstallDir.path() + "/share/doc/packages/vym"; insilmaril@103: #else insilmaril@608: #if defined(VYM_DOCDIR) insilmaril@608: searchList << VYM_DOCDIR; insilmaril@608: #endif insilmaril@103: // default path in SUSE LINUX insilmaril@625: searchList << "/usr/share/doc/packages/vym"; insilmaril@103: #endif insilmaril@0: insilmaril@420: searchList << "doc"; // relative path for easy testing in tarball insilmaril@420: searchList << "doc/tex"; // Easy testing working on vym.tex insilmaril@420: searchList << "/usr/share/doc/vym"; // Debian insilmaril@420: searchList << "/usr/share/doc/packages";// Knoppix insilmaril@420: insilmaril@420: bool found=false; insilmaril@420: QFile docfile; insilmaril@420: for (int i=0; istart( settings.value("/mainwindow/readerPDF").toString(),args); insilmaril@408: if ( !pdfProc->waitForStarted() ) insilmaril@0: { insilmaril@0: // error handling insilmaril@266: QMessageBox::warning(0, insilmaril@266: tr("Warning"), insilmaril@420: tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+ 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@505: void Main::helpDemo() insilmaril@505: { insilmaril@505: QStringList filters; insilmaril@505: filters <<"VYM example map (*.vym)"; insilmaril@505: QFileDialog *fd=new QFileDialog( this); insilmaril@595: #if defined(Q_OS_MACX) insilmaril@595: fd->setDir (QDir("./vym.app/Contents/Resources/demos")); insilmaril@595: #else insilmaril@595: // default path in SUSE LINUX insilmaril@595: fd->setDir (QDir(vymBaseDir.path()+"/demos")); insilmaril@595: #endif insilmaril@595: insilmaril@505: fd->setFileMode (QFileDialog::ExistingFiles); insilmaril@505: fd->setFilters (filters); insilmaril@505: fd->setCaption(vymName+ " - " +tr("Load vym example map")); insilmaril@505: fd->show(); insilmaril@505: insilmaril@505: QString fn; insilmaril@505: if ( fd->exec() == QDialog::Accepted ) insilmaril@505: { insilmaril@505: lastFileDir=fd->directory().path(); insilmaril@505: QStringList flist = fd->selectedFiles(); insilmaril@505: QStringList::Iterator it = flist.begin(); insilmaril@505: while( it != flist.end() ) insilmaril@505: { insilmaril@505: fn = *it; insilmaril@505: fileLoad(*it, NewMap); insilmaril@505: ++it; insilmaril@505: } insilmaril@505: } insilmaril@505: delete (fd); insilmaril@505: } insilmaril@505: insilmaril@505: 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: insilmaril@445: void Main::callMacro () insilmaril@445: { insilmaril@445: QAction *action = qobject_cast(sender()); insilmaril@445: int i=-1; insilmaril@445: if (action) insilmaril@445: { insilmaril@445: i=action->data().toInt(); insilmaril@447: QString mDir (settings.value ("macros/macroDir").toString() ); insilmaril@447: insilmaril@447: QString fn=mDir + QString("/macro-%1.vys").arg(i+1); insilmaril@447: QFile f (fn); insilmaril@447: if ( !f.open( QIODevice::ReadOnly ) ) insilmaril@447: { insilmaril@447: QMessageBox::warning(0, insilmaril@447: tr("Warning"), insilmaril@447: tr("Couldn't find a macro at %1.\n").arg(fn)+ insilmaril@447: tr("Please use Settings->")+tr("Set directory for vym macros")); insilmaril@447: return; insilmaril@447: } insilmaril@447: insilmaril@447: QTextStream ts( &f ); insilmaril@447: QString m= ts.read(); insilmaril@447: insilmaril@445: if (! m.isEmpty()) insilmaril@445: { insilmaril@658: //cout <<"Main::callMacro m="<runScript (m); insilmaril@445: } insilmaril@445: } insilmaril@445: } insilmaril@445: insilmaril@608: insilmaril@608: insilmaril@608: ////////////////////////////////// insilmaril@608: /* insilmaril@608: @@ -2544,18 +2576,27 @@ insilmaril@608: // Try to open new tab in existing konqueror started previously by vym insilmaril@608: p=new QProcess (this); insilmaril@608: args.clear(); insilmaril@608: - args<< QString("konqueror-%1").arg(procBrowser->pid())<< insilmaril@608: - "konqueror-mainwindow#1"<< insilmaril@608: - "newTab" << insilmaril@608: +#if defined(Q_OS_WIN32) insilmaril@608: + // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure. insilmaril@608: + // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic. insilmaril@608: + args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<< insilmaril@608: + "konqueror-mainwindow#1"<< insilmaril@608: + "newTab" << insilmaril@608: urls.at(i); insilmaril@608: +#else insilmaril@608: + args<< QString("konqueror-%1").arg(procBrowser->pid())<< insilmaril@608: + "konqueror-mainwindow#1"<< insilmaril@608: + "newTab" << insilmaril@608: + urls.at(i); insilmaril@608: +#endif insilmaril@608: p->start ("dcop",args); insilmaril@608: if ( !p->waitForStarted() ) success=false; insilmaril@608: } insilmaril@608: */