insilmaril@0: #include "mainwindow.h" insilmaril@0: insilmaril@59: #include insilmaril@0: insilmaril@0: #include insilmaril@0: #include insilmaril@0: insilmaril@59: #include "aboutdialog.h" insilmaril@59: #include "branchpropwindow.h" insilmaril@59: #include "exportoofiledialog.h" insilmaril@59: #include "exports.h" insilmaril@59: #include "file.h" insilmaril@0: #include "flagrowobj.h" insilmaril@59: #include "historywindow.h" insilmaril@59: #include "imports.h" insilmaril@0: #include "mapeditor.h" insilmaril@59: #include "misc.h" insilmaril@59: #include "options.h" insilmaril@0: #include "process.h" insilmaril@0: #include "settings.h" insilmaril@59: #include "texteditor.h" insilmaril@59: #include "warningdialog.h" insilmaril@59: insilmaril@59: #if defined(Q_OS_WIN32) insilmaril@59: // Define only this structure as opposed to insilmaril@59: // including full 'windows.h'. FindWindow insilmaril@59: // clashes with the one in Win32 API. insilmaril@59: typedef struct _PROCESS_INFORMATION insilmaril@59: { insilmaril@59: long hProcess; insilmaril@59: long hThread; insilmaril@59: long dwProcessId; insilmaril@59: long dwThreadId; insilmaril@59: } PROCESS_INFORMATION, *LPPROCESS_INFORMATION; insilmaril@59: #endif insilmaril@0: insilmaril@0: extern TextEditor *textEditor; insilmaril@0: extern Main *mainWindow; insilmaril@59: extern QString tmpVymDir; insilmaril@59: extern QString clipboardDir; insilmaril@59: extern QString clipboardFile; insilmaril@59: extern bool clipboardEmpty; insilmaril@0: extern int statusbarTime; insilmaril@0: extern FlagRowObj* standardFlagsDefault; insilmaril@59: extern FlagRowObj* systemFlagsDefault; insilmaril@59: extern QString vymName; insilmaril@59: extern QString vymVersion; insilmaril@59: extern QString vymBuildDate; insilmaril@59: extern bool debug; insilmaril@59: insilmaril@59: QMenu* branchContextMenu; insilmaril@59: QMenu* branchAddContextMenu; insilmaril@59: QMenu* branchRemoveContextMenu; insilmaril@59: QMenu* branchLinksContextMenu; insilmaril@59: QMenu* branchXLinksContextMenuEdit; insilmaril@59: QMenu* branchXLinksContextMenuFollow; insilmaril@59: QMenu* floatimageContextMenu; insilmaril@59: QMenu* canvasContextMenu; insilmaril@59: QMenu* fileLastMapsMenu; insilmaril@59: QMenu* fileImportMenu; insilmaril@59: QMenu* fileExportMenu; insilmaril@0: insilmaril@0: insilmaril@0: extern Settings settings; insilmaril@0: extern Options options; insilmaril@59: extern ImageIO imageIO; insilmaril@59: insilmaril@59: extern QDir vymBaseDir; insilmaril@59: extern QDir lastImageDir; insilmaril@59: extern QDir lastFileDir; insilmaril@59: #if defined(Q_OS_WIN32) insilmaril@59: extern QDir vymInstallDir; insilmaril@0: #endif insilmaril@59: extern QString iconPath; insilmaril@59: extern QString flagsPath; insilmaril@59: insilmaril@59: 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@59: setObjectName ("MainWindow"); insilmaril@59: insilmaril@0: setCaption ("VYM - View Your Mind"); insilmaril@0: insilmaril@0: // Load window settings insilmaril@59: #if defined(Q_OS_WIN32) insilmaril@59: if (settings.value("/mainwindow/geometry/maximized", false).toBool()) insilmaril@59: { insilmaril@59: setWindowState(Qt::WindowMaximized); insilmaril@59: } insilmaril@59: else insilmaril@59: #endif insilmaril@59: { insilmaril@59: resize (settings.value("/mainwindow/geometry/size", QSize (800,600)).toSize()); insilmaril@59: move (settings.value("/mainwindow/geometry/pos", QPoint(300,100)).toPoint()); insilmaril@59: } insilmaril@59: insilmaril@59: // Sometimes we may need to remember old selections insilmaril@59: prevSelection=""; insilmaril@59: insilmaril@59: // Default color insilmaril@59: currentColor=Qt::black; insilmaril@59: insilmaril@59: // Create unique temporary directory insilmaril@59: bool ok; insilmaril@59: tmpVymDir=makeTmpDir (ok,"vym"); insilmaril@59: if (!ok) insilmaril@59: { insilmaril@59: qWarning ("Mainwindow: Could not create temporary directory, failed to start vym"); insilmaril@59: exit (1); insilmaril@59: } insilmaril@59: if (debug) qDebug (QString("vym tmpDir=%1").arg(tmpVymDir) ); insilmaril@59: insilmaril@59: // Create direcctory for clipboard insilmaril@59: clipboardDir=tmpVymDir+"/clipboard"; insilmaril@59: clipboardFile="map.xml"; insilmaril@59: QDir d(clipboardDir); insilmaril@59: d.mkdir (clipboardDir,true); insilmaril@59: makeSubDirs (clipboardDir); insilmaril@59: clipboardEmpty=true; insilmaril@59: insilmaril@59: procBrowser=NULL; insilmaril@59: insilmaril@59: // Satellite windows ////////////////////////////////////////// insilmaril@59: insilmaril@59: // history window insilmaril@59: historyWindow=new HistoryWindow(); insilmaril@59: connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions())); insilmaril@59: insilmaril@59: // properties window insilmaril@59: branchPropertyWindow = new BranchPropertyWindow(); insilmaril@59: connect (branchPropertyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions())); insilmaril@59: insilmaril@59: // Connect TextEditor, so that we can update flags if text changes insilmaril@59: connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag())); insilmaril@59: connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions())); insilmaril@59: insilmaril@59: // Connect HistoryWindow, so that we can update flags insilmaril@59: connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions())); insilmaril@59: insilmaril@59: insilmaril@59: // Initialize script editor insilmaril@59: scriptEditor = new SimpleScriptEditor(); insilmaril@59: scriptEditor->move (50,50); insilmaril@59: insilmaril@59: connect( scriptEditor, SIGNAL( runScript ( QString ) ), insilmaril@59: this, SLOT( runScript( QString ) ) ); insilmaril@59: insilmaril@59: insilmaril@59: // Initialize Find window insilmaril@59: findWindow=new FindWindow(NULL); insilmaril@59: findWindow->move (x(),y()+70); insilmaril@59: connect (findWindow, SIGNAL( findButton(QString) ), insilmaril@59: this, SLOT(editFind(QString) ) ); insilmaril@59: connect (findWindow, SIGNAL( somethingChanged() ), insilmaril@59: this, SLOT(editFindChanged() ) ); insilmaril@0: insilmaril@0: // Initialize some settings, which are platform dependant insilmaril@0: QString p,s; insilmaril@0: insilmaril@0: // application to open URLs insilmaril@59: p="/mainwindow/readerURL"; insilmaril@0: #if defined(Q_OS_LINUX) insilmaril@59: s=settings.value (p,"xdg-open").toString(); insilmaril@0: #else insilmaril@0: #if defined(Q_OS_MACX) insilmaril@59: s=settings.value (p,"/usr/bin/open").toString(); insilmaril@59: insilmaril@59: #else insilmaril@59: #if defined(Q_OS_WIN32) insilmaril@59: // Assume that system has been set up so that insilmaril@59: // Explorer automagically opens up the URL insilmaril@59: // in the user's preferred browser. insilmaril@59: s=settings.value (p,"explorer").toString(); insilmaril@59: #else insilmaril@59: s=settings.value (p,"mozilla").toString(); insilmaril@59: #endif insilmaril@0: #endif insilmaril@0: #endif insilmaril@59: settings.setValue( p,s); insilmaril@0: insilmaril@0: // application to open PDFs insilmaril@59: p="/mainwindow/readerPDF"; insilmaril@0: #if defined(Q_OS_LINUX) insilmaril@59: s=settings.value (p,"xdg-open").toString(); insilmaril@0: #else insilmaril@0: #if defined(Q_OS_MACX) insilmaril@59: s=settings.value (p,"/usr/bin/open").toString(); insilmaril@59: #elif defined(Q_OS_WIN32) insilmaril@59: s=settings.value (p,"acrord32").toString(); insilmaril@0: #else insilmaril@59: s=settings.value (p,"acroread").toString(); insilmaril@0: #endif insilmaril@0: #endif insilmaril@59: settings.setValue( p,s); insilmaril@59: insilmaril@59: // width of xLinksMenu insilmaril@59: 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@59: lineedit=new QLineEdit (this); insilmaril@59: lineedit->hide(); insilmaril@59: insilmaril@0: setCentralWidget(tabWidget); insilmaril@0: insilmaril@0: setupFileActions(); insilmaril@0: setupEditActions(); insilmaril@0: setupFormatActions(); insilmaril@0: setupViewActions(); insilmaril@59: setupModeActions(); insilmaril@0: setupFlagActions(); insilmaril@59: setupNetworkActions(); insilmaril@0: setupSettingsActions(); insilmaril@0: setupContextMenus(); insilmaril@59: setupMacros(); insilmaril@59: if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions(); insilmaril@0: setupHelpActions(); insilmaril@0: insilmaril@0: statusBar(); insilmaril@0: insilmaril@59: restoreState (settings.value("/mainwindow/state",0).toByteArray()); insilmaril@0: insilmaril@0: updateGeometry(); insilmaril@0: } insilmaril@0: insilmaril@0: Main::~Main() insilmaril@0: { insilmaril@59: //cout << "Destr MainWindow\n"; insilmaril@0: // Save Settings insilmaril@59: #if defined(Q_OS_WIN32) insilmaril@59: settings.setValue ("/mainwindow/geometry/maximized", isMaximized()); insilmaril@59: #endif insilmaril@59: settings.setValue ("/mainwindow/geometry/size", size()); insilmaril@59: settings.setValue ("/mainwindow/geometry/pos", pos()); insilmaril@59: settings.setValue ("/mainwindow/state",saveState(0)); insilmaril@59: insilmaril@59: settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn()); insilmaril@59: settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn()); insilmaril@59: settings.setValue( "/version/version", vymVersion ); insilmaril@59: settings.setValue( "/version/builddate", vymBuildDate ); insilmaril@59: insilmaril@59: settings.setValue( "/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() ); insilmaril@59: settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isOn() ); insilmaril@59: settings.setValue( "/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() ); insilmaril@59: settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() ); insilmaril@59: settings.setValue( "/mapeditor/editmode/autoEditNewBranch",actionSettingsAutoEditNewBranch->isOn() ); insilmaril@59: settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() ); insilmaril@59: settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() ); insilmaril@59: settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() ); insilmaril@59: insilmaril@59: //TODO save scriptEditor settings insilmaril@59: insilmaril@59: // call the destructors insilmaril@59: delete textEditor; insilmaril@59: delete historyWindow; insilmaril@59: delete branchPropertyWindow; insilmaril@59: insilmaril@59: // Remove temporary directory insilmaril@59: 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@59: 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@59: QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") ); insilmaril@59: QToolBar *tb = addToolBar( tr ("&Map") ); insilmaril@59: tb->setObjectName ("mapTB"); insilmaril@0: insilmaril@0: QAction *a; insilmaril@59: a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this); insilmaril@59: a->setStatusTip ( tr( "New map","Status tip File menu" ) ); insilmaril@59: a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map insilmaril@0: a->addTo( tb ); insilmaril@59: fileMenu->addAction (a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) ); insilmaril@0: insilmaril@59: a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this); insilmaril@59: a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) ); insilmaril@59: a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N ); //New map insilmaril@59: fileMenu->addAction (a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) ); insilmaril@59: actionFileNewCopy=a; insilmaril@59: insilmaril@59: a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this); insilmaril@59: a->setStatusTip (tr( "Open","Status tip File menu" ) ); insilmaril@59: a->setShortcut ( Qt::CTRL + Qt::Key_O ); //Open map insilmaril@0: a->addTo( tb ); insilmaril@59: fileMenu->addAction (a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) ); insilmaril@0: insilmaril@59: fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu")); insilmaril@59: fileMenu->addSeparator(); insilmaril@0: insilmaril@59: a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this); insilmaril@59: a->setStatusTip ( tr( "Save","Status tip file menu" )); insilmaril@59: a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map insilmaril@0: a->addTo( tb ); insilmaril@59: fileMenu->addAction (a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) ); insilmaril@0: actionFileSave=a; insilmaril@0: insilmaril@59: a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this); insilmaril@59: a->setStatusTip (tr( "Save &As","Status tip file menu" ) ); insilmaril@59: fileMenu->addAction (a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) ); insilmaril@59: insilmaril@59: fileMenu->addSeparator(); insilmaril@59: insilmaril@59: fileImportMenu = fileMenu->addMenu (tr("Import","File menu")); insilmaril@59: insilmaril@62: a = new QAction(tr("KDE 3 Bookmarks"), this); insilmaril@62: a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 3 bookmarks"))); insilmaril@59: a->addTo (fileImportMenu); insilmaril@62: connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE3Bookmarks() ) ); insilmaril@62: insilmaril@62: a = new QAction(tr("KDE 4 Bookmarks"), this); insilmaril@62: a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 4 bookmarks"))); insilmaril@62: a->addTo (fileImportMenu); insilmaril@62: connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE4Bookmarks() ) ); insilmaril@59: insilmaril@59: if (settings.value( "/mainwindow/showTestMenu",false).toBool()) insilmaril@59: { insilmaril@59: a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this); insilmaril@59: a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) )); insilmaril@59: a->addTo (fileImportMenu); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) ); insilmaril@59: } insilmaril@59: insilmaril@59: a = new QAction("Freemind...",this); insilmaril@59: a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Freemind") ); insilmaril@59: fileImportMenu->addAction (a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFreemind() ) ); insilmaril@59: insilmaril@59: a = new QAction("Mind Manager...",this); insilmaril@59: a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") ); insilmaril@59: fileImportMenu->addAction (a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) ); insilmaril@59: insilmaril@59: a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this); insilmaril@59: a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) ); insilmaril@59: fileImportMenu->addAction (a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) ); insilmaril@59: insilmaril@59: fileExportMenu = fileMenu->addMenu (tr("Export","File menu")); insilmaril@59: insilmaril@59: a = new QAction( tr("Image%1","File export menu").arg("..."), this); insilmaril@59: a->setStatusTip( tr( "Export map as image","status tip file menu" )); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) ); insilmaril@59: fileExportMenu->addAction (a); insilmaril@59: insilmaril@59: a = new QAction( "Open Office...", this); insilmaril@59: a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" )); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) ); insilmaril@59: fileExportMenu->addAction (a); insilmaril@59: insilmaril@59: a = new QAction( "Webpage (XHTML)...",this ); insilmaril@59: a->setShortcut (Qt::ALT + Qt::Key_X); //Export XHTML insilmaril@59: a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu"))); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) ); insilmaril@59: fileExportMenu->addAction (a); insilmaril@59: insilmaril@59: a = new QAction( "Text (ASCII)...", this); insilmaril@59: a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" ))); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) ); insilmaril@59: fileExportMenu->addAction (a); insilmaril@59: insilmaril@59: a = new QAction( "Spreadsheet (CSV)...", this); insilmaril@59: a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" ))); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) ); insilmaril@59: fileExportMenu->addAction (a); insilmaril@59: insilmaril@62: a = new QAction( tr("KDE 3 Bookmarks","File menu"), this); insilmaril@62: a->setStatusTip( tr( "Export as %1").arg(tr("KDE 3 Bookmarks" ))); insilmaril@62: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE3Bookmarks() ) ); insilmaril@62: fileExportMenu->addAction (a); insilmaril@62: insilmaril@62: a = new QAction( tr("KDE 4 Bookmarks","File menu"), this); insilmaril@62: a->setStatusTip( tr( "Export as %1").arg(tr("KDE 4 Bookmarks" ))); insilmaril@62: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE4Bookmarks() ) ); insilmaril@59: fileExportMenu->addAction (a); insilmaril@59: insilmaril@59: a = new QAction( "Taskjuggler...", this ); insilmaril@59: a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" ))); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) ); insilmaril@59: fileExportMenu->addAction (a); insilmaril@59: insilmaril@59: a = new QAction( "LaTeX...", this); insilmaril@59: a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" ))); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) ); insilmaril@59: fileExportMenu->addAction (a); insilmaril@59: insilmaril@59: a = new QAction( "XML..." , this ); insilmaril@59: a->setStatusTip (tr( "Export as %1").arg("XML")); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) ); insilmaril@59: fileExportMenu->addAction (a); insilmaril@59: insilmaril@59: fileMenu->addSeparator(); insilmaril@59: insilmaril@59: a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this); insilmaril@59: a->setStatusTip ( tr( "Print" ,"File menu") ); insilmaril@59: a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map insilmaril@0: a->addTo( tb ); insilmaril@59: fileMenu->addAction (a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) ); insilmaril@0: actionFilePrint=a; insilmaril@0: insilmaril@59: a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this); insilmaril@59: a->setStatusTip (tr( "Close Map" ) ); insilmaril@59: a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map insilmaril@59: fileMenu->addAction (a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) ); insilmaril@59: insilmaril@59: a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this); insilmaril@59: a->setStatusTip ( tr( "Exit")+" "+vymName ); insilmaril@59: a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym insilmaril@59: fileMenu->addAction (a); insilmaril@59: 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@59: QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") ); insilmaril@0: tb->setLabel( "Edit Actions" ); insilmaril@59: tb->setObjectName ("actionsTB"); insilmaril@59: QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") ); insilmaril@0: insilmaril@0: QAction *a; insilmaril@59: QAction *alt; insilmaril@59: a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) ); insilmaril@59: a->setStatusTip (tr( "Undo" ) ); insilmaril@59: a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action insilmaril@0: a->setEnabled (false); insilmaril@59: tb->addAction (a); insilmaril@59: editMenu->addAction (a); insilmaril@0: actionEditUndo=a; insilmaril@59: insilmaril@59: a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this); insilmaril@59: a->setStatusTip (tr( "Redo" )); insilmaril@59: a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action insilmaril@59: tb->addAction (a); insilmaril@59: editMenu->addAction (a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) ); insilmaril@59: actionEditRedo=a; insilmaril@59: insilmaril@59: editMenu->addSeparator(); insilmaril@59: a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this); insilmaril@59: a->setStatusTip ( tr( "Copy" ) ); insilmaril@59: a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy insilmaril@0: a->setEnabled (false); insilmaril@59: tb->addAction (a); insilmaril@59: editMenu->addAction (a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) ); insilmaril@0: actionEditCopy=a; insilmaril@59: insilmaril@59: a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this); insilmaril@59: a->setStatusTip ( tr( "Cut" ) ); insilmaril@59: a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut insilmaril@0: a->setEnabled (false); insilmaril@59: tb->addAction (a); insilmaril@59: editMenu->addAction (a); insilmaril@0: actionEditCut=a; insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) ); insilmaril@59: insilmaril@59: a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) ); insilmaril@59: a->setStatusTip ( tr( "Paste" ) ); insilmaril@59: a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste insilmaril@0: a->setEnabled (false); insilmaril@59: tb->addAction (a); insilmaril@59: editMenu->addAction (a); insilmaril@0: actionEditPaste=a; insilmaril@59: insilmaril@59: // Shortcuts to modify heading: insilmaril@59: a = new QAction(tr( "Edit heading","Edit menu" ),this); insilmaril@59: a->setStatusTip ( tr( "edit Heading" )); insilmaril@59: a->setShortcut ( Qt::Key_Enter); //Edit heading insilmaril@59: // a->setShortcutContext (Qt::WindowShortcut); insilmaril@59: addAction (a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) ); insilmaril@59: actionListBranches.append(a); insilmaril@59: a = new QAction( tr( "Edit heading","Edit menu" ), this); insilmaril@59: a->setStatusTip (tr( "edit Heading" )); insilmaril@59: a->setShortcut (Qt::Key_Return ); //Edit heading insilmaril@59: //a->setShortcutContext (Qt::WindowShortcut); insilmaril@59: addAction (a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) ); insilmaril@59: actionListBranches.append(a); insilmaril@59: editMenu->addAction (a); insilmaril@59: actionEditHeading=a; insilmaril@59: a = new QAction( tr( "Edit heading","Edit menu" ), this); insilmaril@59: a->setStatusTip (tr( "edit Heading" )); insilmaril@59: //a->setShortcut ( Qt::Key_F2 ); //Edit heading insilmaril@59: a->setShortcutContext (Qt::WindowShortcut); insilmaril@59: addAction (a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) ); insilmaril@59: actionListBranches.append(a); insilmaril@59: insilmaril@59: // Shortcut to delete selection insilmaril@59: a = new QAction( tr( "Delete Selection","Edit menu" ),this); insilmaril@59: a->setStatusTip (tr( "Delete Selection" )); insilmaril@59: a->setShortcut ( Qt::Key_Delete); //Delete selection insilmaril@59: a->setShortcutContext (Qt::WindowShortcut); insilmaril@59: addAction (a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) ); insilmaril@59: actionEditDelete=a; insilmaril@59: insilmaril@59: // Shortcut to add mapcenter insilmaril@59: a= new QAction(tr( "Add mapcenter","Canvas context menu" ), this); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( editAddMapCenter() ) ); insilmaril@59: actionEditAddMapCenter = a; insilmaril@59: insilmaril@59: insilmaril@59: // Shortcut to add branch insilmaril@59: alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this); insilmaril@59: alt->setStatusTip ( tr( "Add a branch as child of selection" )); insilmaril@59: alt->setShortcut (Qt::Key_A); //Add branch insilmaril@59: alt->setShortcutContext (Qt::WindowShortcut); insilmaril@59: addAction (alt); insilmaril@59: connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) ); insilmaril@59: a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this); insilmaril@59: a->setStatusTip ( tr( "Add a branch as child of selection" )); insilmaril@59: a->setShortcut (Qt::Key_Insert); //Add branch insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) ); insilmaril@59: actionListBranches.append(a); insilmaril@59: #if defined (Q_OS_MACX) insilmaril@59: // In OSX show different shortcut in menues, the keys work indepently always insilmaril@59: actionEditAddBranch=alt; insilmaril@59: #else insilmaril@59: actionEditAddBranch=a; insilmaril@59: #endif insilmaril@59: editMenu->addAction (actionEditAddBranch); insilmaril@59: tb->addAction (actionEditAddBranch); insilmaril@59: insilmaril@59: insilmaril@59: // Add branch by inserting it at selection insilmaril@59: a = new QAction(tr( "Add branch (insert)","Edit menu" ), this); insilmaril@59: a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" )); insilmaril@59: a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch insilmaril@59: a->setShortcutContext (Qt::WindowShortcut); insilmaril@59: addAction (a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) ); insilmaril@0: a->setEnabled (false); insilmaril@59: actionListBranches.append(a); insilmaril@59: actionEditAddBranchBefore=a; insilmaril@59: a = new QAction(tr( "Add branch (insert)","Edit menu" ),this); insilmaril@59: a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" )); insilmaril@59: a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch insilmaril@59: a->setShortcutContext (Qt::WindowShortcut); insilmaril@59: addAction (a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) ); insilmaril@59: actionListBranches.append(a); insilmaril@59: insilmaril@59: // Add branch above insilmaril@59: a = new QAction(tr( "Add branch above","Edit menu" ), this); insilmaril@59: a->setStatusTip ( tr( "Add a branch above selection" )); insilmaril@59: a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above insilmaril@59: a->setShortcutContext (Qt::WindowShortcut); insilmaril@59: addAction (a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) ); insilmaril@59: a->setEnabled (false); insilmaril@59: actionListBranches.append(a); insilmaril@59: actionEditAddBranchAbove=a; insilmaril@59: a = new QAction(tr( "Add branch above","Edit menu" ), this); insilmaril@59: a->setStatusTip ( tr( "Add a branch above selection" )); insilmaril@59: a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above insilmaril@59: a->setShortcutContext (Qt::WindowShortcut); insilmaril@59: addAction (a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) ); insilmaril@59: actionListBranches.append(a); insilmaril@59: insilmaril@59: // Add branch below insilmaril@59: a = new QAction(tr( "Add branch below","Edit menu" ), this); insilmaril@59: a->setStatusTip ( tr( "Add a branch below selection" )); insilmaril@59: a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below insilmaril@59: a->setShortcutContext (Qt::WindowShortcut); insilmaril@59: addAction (a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) ); insilmaril@59: a->setEnabled (false); insilmaril@59: actionListBranches.append(a); insilmaril@59: actionEditAddBranchBelow=a; insilmaril@59: a = new QAction(tr( "Add branch below","Edit menu" ), this); insilmaril@59: a->setStatusTip ( tr( "Add a branch below selection" )); insilmaril@59: a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below insilmaril@59: a->setShortcutContext (Qt::WindowShortcut); insilmaril@59: addAction (a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) ); insilmaril@59: actionListBranches.append(a); insilmaril@59: insilmaril@59: a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this); insilmaril@59: a->setStatusTip ( tr( "Move branch up" ) ); insilmaril@59: a->setShortcut (Qt::Key_PageUp ); // Move branch up insilmaril@59: a->setEnabled (false); insilmaril@59: tb->addAction (a); insilmaril@59: editMenu->addAction (a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) ); insilmaril@0: actionEditMoveUp=a; insilmaril@59: insilmaril@59: a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) ); insilmaril@59: a->setStatusTip (tr( "Move branch down" ) ); insilmaril@59: a->setShortcut ( Qt::Key_PageDown ); // Move branch down insilmaril@0: a->setEnabled (false); insilmaril@59: tb->addAction (a); insilmaril@59: editMenu->addAction (a); insilmaril@0: actionEditMoveDown=a; insilmaril@0: insilmaril@59: a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this ); insilmaril@59: connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) ); insilmaril@59: a->setEnabled (true); insilmaril@59: a->addTo( tb ); insilmaril@59: editMenu->addAction (a); insilmaril@59: actionEditSortChildren=a; insilmaril@59: insilmaril@59: a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this); insilmaril@59: a->setShortcut ( Qt::Key_ScrollLock ); insilmaril@59: a->setStatusTip (tr( "Scroll branch" ) ); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) ); insilmaril@59: insilmaril@59: alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this); insilmaril@59: alt->setShortcut ( Qt::Key_S ); // Scroll branch insilmaril@59: alt->setStatusTip (tr( "Scroll branch" )); insilmaril@59: connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) ); insilmaril@59: #if defined(Q_OS_MACX) insilmaril@59: actionEditToggleScroll=alt; insilmaril@59: #else insilmaril@59: actionEditToggleScroll=a; insilmaril@59: #endif insilmaril@59: actionEditToggleScroll->setEnabled (false); insilmaril@59: actionEditToggleScroll->setToggleAction(true); insilmaril@59: tb->addAction (actionEditToggleScroll); insilmaril@59: editMenu->addAction ( actionEditToggleScroll); insilmaril@59: editMenu->addAction (actionEditToggleScroll); insilmaril@59: addAction (a); insilmaril@59: addAction (alt); insilmaril@59: actionListBranches.append(actionEditToggleScroll); insilmaril@0: insilmaril@59: a = new QAction( tr( "Unscroll childs","Edit menu" ), this); insilmaril@59: a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" )); insilmaril@59: editMenu->addAction (a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChilds() ) ); insilmaril@59: insilmaril@59: editMenu->addSeparator(); insilmaril@59: insilmaril@59: a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this); insilmaril@59: a->setStatusTip (tr( "Find" ) ); insilmaril@59: a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find insilmaril@59: editMenu->addAction (a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) ); insilmaril@0: insilmaril@59: editMenu->addSeparator(); insilmaril@59: insilmaril@59: a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this); insilmaril@59: a->setShortcut (Qt::CTRL + Qt::Key_U ); insilmaril@59: a->setShortcut (tr( "Open URL" )); insilmaril@59: tb->addAction (a); insilmaril@59: addAction(a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) ); insilmaril@0: actionEditOpenURL=a; insilmaril@0: insilmaril@59: a = new QAction( tr( "Open URL in new tab","Edit menu" ), this); insilmaril@59: a->setStatusTip (tr( "Open URL in new tab" )); insilmaril@59: //a->setShortcut (Qt::CTRL+Qt::Key_U ); insilmaril@59: addAction(a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) ); insilmaril@59: actionEditOpenURLTab=a; insilmaril@59: insilmaril@59: a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this); insilmaril@59: a->setStatusTip (tr( "Open all URLs in subtree" )); insilmaril@59: addAction(a); insilmaril@59: actionListBranches.append(a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) ); insilmaril@59: actionEditOpenMultipleURLTabs=a; insilmaril@59: insilmaril@59: a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this); insilmaril@59: a->setStatusTip ( tr( "Edit URL" ) ); insilmaril@59: a->setShortcut ( Qt::Key_U ); insilmaril@59: a->setShortcutContext (Qt::WindowShortcut); insilmaril@59: actionListBranches.append(a); insilmaril@59: addAction(a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) ); insilmaril@0: actionEditURL=a; insilmaril@0: insilmaril@59: a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this); insilmaril@59: a->setStatusTip ( tr( "Edit local URL" ) ); insilmaril@59: a->setShortcut (Qt::SHIFT + Qt::Key_U ); insilmaril@59: a->setShortcutContext (Qt::WindowShortcut); insilmaril@59: actionListBranches.append(a); insilmaril@59: addAction(a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) ); insilmaril@59: actionEditLocalURL=a; insilmaril@59: insilmaril@59: a = new QAction( tr( "Use heading for URL","Edit menu" ), this); insilmaril@59: a->setStatusTip ( tr( "Use heading of selected branch as URL" )); insilmaril@0: a->setEnabled (false); insilmaril@59: actionListBranches.append(a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) ); insilmaril@0: actionEditHeading2URL=a; insilmaril@0: insilmaril@59: a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this); insilmaril@59: a->setStatusTip ( tr( "Create URL to Novell Bugzilla" )); insilmaril@0: a->setEnabled (false); insilmaril@59: actionListBranches.append(a); insilmaril@76: a->setShortcut ( Qt::Key_B ); insilmaril@76: a->setShortcutContext (Qt::WindowShortcut); insilmaril@76: addAction(a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) ); insilmaril@0: actionEditBugzilla2URL=a; insilmaril@0: insilmaril@59: a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this); insilmaril@59: a->setStatusTip ( tr( "Create URL to Novell FATE" )); insilmaril@59: a->setEnabled (false); insilmaril@59: actionListBranches.append(a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) ); insilmaril@59: actionEditFATE2URL=a; insilmaril@0: insilmaril@59: a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this); insilmaril@59: a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" )); insilmaril@59: tb->addAction (a); insilmaril@0: a->setEnabled (false); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) ); insilmaril@0: actionEditOpenVymLink=a; insilmaril@0: insilmaril@59: a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this); insilmaril@59: a->setStatusTip ( tr( "Open all vym links in subtree" )); insilmaril@0: a->setEnabled (false); insilmaril@59: actionListBranches.append(a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) ); insilmaril@59: actionEditOpenMultipleVymLinks=a; insilmaril@59: insilmaril@59: insilmaril@59: a = new QAction(tr( "Edit vym link...","Edit menu" ), this); insilmaril@59: a->setEnabled (false); insilmaril@59: a->setStatusTip ( tr( "Edit link to another vym map" )); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) ); insilmaril@59: actionListBranches.append(a); insilmaril@0: actionEditVymLink=a; insilmaril@0: insilmaril@59: a = new QAction(tr( "Delete vym link","Edit menu" ),this); insilmaril@59: a->setStatusTip ( tr( "Delete link to another vym map" )); insilmaril@0: a->setEnabled (false); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) ); insilmaril@0: actionEditDeleteVymLink=a; insilmaril@0: insilmaril@59: a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this); insilmaril@59: a->setStatusTip ( tr( "Hide object in exports" ) ); insilmaril@59: a->setShortcut (Qt::Key_H ); insilmaril@59: a->setToggleAction(true); insilmaril@59: tb->addAction (a); insilmaril@59: a->setEnabled (false); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) ); insilmaril@59: actionEditToggleHideExport=a; insilmaril@59: insilmaril@59: a = new QAction(tr( "Edit Map Info...","Edit menu" ),this); insilmaril@59: a->setStatusTip ( tr( "Edit Map Info" )); insilmaril@0: a->setEnabled (true); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) ); insilmaril@0: actionEditMapInfo=a; insilmaril@0: insilmaril@59: // Import at selection (adding to selection) insilmaril@59: a = new QAction( tr( "Add map (insert)","Edit menu" ),this); insilmaril@59: a->setStatusTip (tr( "Add map at selection" )); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) ); insilmaril@0: a->setEnabled (false); insilmaril@59: actionListBranches.append(a); insilmaril@59: actionEditImportAdd=a; insilmaril@59: insilmaril@59: // Import at selection (replacing selection) insilmaril@59: a = new QAction( tr( "Add map (replace)","Edit menu" ), this); insilmaril@59: a->setStatusTip (tr( "Replace selection with map" )); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) ); insilmaril@0: a->setEnabled (false); insilmaril@59: actionListBranches.append(a); insilmaril@59: actionEditImportReplace=a; insilmaril@59: insilmaril@59: // Save selection insilmaril@59: a = new QAction( tr( "Save selection","Edit menu" ), this); insilmaril@59: a->setStatusTip (tr( "Save selection" )); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) ); insilmaril@0: a->setEnabled (false); insilmaril@59: actionListBranches.append(a); insilmaril@59: actionEditSaveBranch=a; insilmaril@59: insilmaril@59: // Only remove branch, not its childs insilmaril@59: a = new QAction(tr( "Remove only branch ","Edit menu" ), this); insilmaril@59: a->setStatusTip ( tr( "Remove only branch and keep its childs" )); insilmaril@59: a->setShortcut (Qt::ALT + Qt::Key_Delete ); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChilds() ) ); insilmaril@0: a->setEnabled (false); insilmaril@59: addAction (a); insilmaril@59: actionListBranches.append(a); insilmaril@59: actionEditDeleteKeepChilds=a; insilmaril@59: insilmaril@59: // Only remove childs of a branch insilmaril@59: a = new QAction( tr( "Remove childs","Edit menu" ), this); insilmaril@59: a->setStatusTip (tr( "Remove childs of branch" )); insilmaril@59: a->setShortcut (Qt::SHIFT + Qt::Key_Delete ); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChilds() ) ); insilmaril@0: a->setEnabled (false); insilmaril@59: actionListBranches.append(a); insilmaril@59: actionEditDeleteChilds=a; insilmaril@59: insilmaril@59: // Shortcuts for navigating with cursor: insilmaril@59: a = new QAction(tr( "Select upper branch","Edit menu" ), this); insilmaril@59: a->setStatusTip ( tr( "Select upper branch" )); insilmaril@59: a->setShortcut (Qt::Key_Up ); insilmaril@59: a->setShortcutContext (Qt::WindowShortcut); insilmaril@59: addAction (a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) ); insilmaril@59: a = new QAction( tr( "Select lower branch","Edit menu" ),this); insilmaril@59: a->setStatusTip (tr( "Select lower branch" )); insilmaril@59: a->setShortcut ( Qt::Key_Down ); insilmaril@59: a->setShortcutContext (Qt::WindowShortcut); insilmaril@59: addAction (a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) ); insilmaril@59: a = new QAction(tr( "Select left branch","Edit menu" ), this); insilmaril@59: a->setStatusTip ( tr( "Select left branch" )); insilmaril@59: a->setShortcut (Qt::Key_Left ); insilmaril@59: a->setShortcutContext (Qt::WindowShortcut); insilmaril@59: addAction (a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) ); insilmaril@59: a = new QAction( tr( "Select child branch","Edit menu" ), this); insilmaril@59: a->setStatusTip (tr( "Select right branch" )); insilmaril@59: a->setShortcut (Qt::Key_Right); insilmaril@59: a->setShortcutContext (Qt::WindowShortcut); insilmaril@59: addAction (a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) ); insilmaril@59: a = new QAction( tr( "Select first branch","Edit menu" ), this); insilmaril@59: a->setStatusTip (tr( "Select first branch" )); insilmaril@59: a->setShortcut (Qt::Key_Home ); insilmaril@59: a->setShortcutContext (Qt::WindowShortcut); insilmaril@59: addAction (a); insilmaril@0: a->setEnabled (false); insilmaril@59: editMenu->addAction (a); insilmaril@59: actionListBranches.append(a); insilmaril@59: actionEditSelectFirst=a; insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) ); insilmaril@59: a = new QAction( tr( "Select last branch","Edit menu" ),this); insilmaril@59: a->setStatusTip (tr( "Select last branch" )); insilmaril@59: a->setShortcut ( Qt::Key_End ); insilmaril@59: a->setShortcutContext (Qt::WindowShortcut); insilmaril@59: addAction (a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) ); insilmaril@0: a->setEnabled (false); insilmaril@59: editMenu->addAction (a); insilmaril@59: actionListBranches.append(a); insilmaril@0: actionEditSelectLast=a; insilmaril@0: insilmaril@59: a = new QAction( tr( "Add Image...","Edit menu" ), this); insilmaril@59: a->setStatusTip (tr( "Add Image" )); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) ); insilmaril@0: actionEditLoadImage=a; insilmaril@59: insilmaril@59: a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this); insilmaril@59: a->setStatusTip (tr( "Set properties for selection" )); insilmaril@59: a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window insilmaril@59: a->setShortcutContext (Qt::WindowShortcut); insilmaril@59: a->setToggleAction (true); insilmaril@59: addAction (a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) ); insilmaril@59: actionViewTogglePropertyWindow=a; insilmaril@0: } insilmaril@0: insilmaril@0: // Format Actions insilmaril@0: void Main::setupFormatActions() insilmaril@0: { insilmaril@59: QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu")); insilmaril@59: insilmaril@59: QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name")); insilmaril@59: tb->setObjectName ("formatTB"); insilmaril@0: QAction *a; insilmaril@0: QPixmap pix( 16,16); insilmaril@59: pix.fill (Qt::black); insilmaril@59: a= new QAction(pix, tr( "Set &Color" )+QString("..."), this); insilmaril@59: a->setStatusTip ( tr( "Set Color" )); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) ); insilmaril@59: a->addTo( tb ); insilmaril@59: formatMenu->addAction (a); insilmaril@59: actionFormatColor=a; insilmaril@59: a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this); insilmaril@59: a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) ); insilmaril@59: a->setShortcut (Qt::CTRL + Qt::Key_K ); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) ); insilmaril@0: a->setEnabled (false); insilmaril@0: a->addTo( tb ); insilmaril@59: formatMenu->addAction (a); insilmaril@59: actionListBranches.append(a); insilmaril@0: actionFormatPickColor=a; insilmaril@59: insilmaril@59: a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this); insilmaril@59: a->setStatusTip ( tr( "Color branch" ) ); insilmaril@59: a->setShortcut (Qt::CTRL + Qt::Key_B); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) ); insilmaril@0: a->setEnabled (false); insilmaril@0: a->addTo( tb ); insilmaril@59: formatMenu->addAction (a); insilmaril@59: actionListBranches.append(a); insilmaril@59: actionFormatColorSubtree=a; insilmaril@59: insilmaril@59: a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this); insilmaril@59: a->setStatusTip ( tr( "Color Subtree" )); insilmaril@59: a->setShortcut (Qt::CTRL + Qt::Key_T); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) ); insilmaril@0: a->setEnabled (false); insilmaril@59: formatMenu->addAction (a); insilmaril@0: a->addTo( tb ); insilmaril@59: actionListBranches.append(a); insilmaril@0: actionFormatColorSubtree=a; insilmaril@0: insilmaril@59: formatMenu->addSeparator(); insilmaril@59: actionGroupFormatLinkStyles=new QActionGroup ( this); insilmaril@0: actionGroupFormatLinkStyles->setExclusive (true); insilmaril@59: a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles); insilmaril@59: a->setStatusTip (tr( "Line" )); insilmaril@0: a->setToggleAction(true); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) ); insilmaril@59: formatMenu->addAction (a); insilmaril@0: actionFormatLinkStyleLine=a; insilmaril@59: a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles); insilmaril@59: a->setStatusTip (tr( "Line" )); insilmaril@0: a->setToggleAction(true); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) ); insilmaril@59: formatMenu->addAction (a); insilmaril@0: actionFormatLinkStyleParabel=a; insilmaril@59: a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles ); insilmaril@59: a->setStatusTip (tr( "PolyLine" )); insilmaril@0: a->setToggleAction(true); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) ); insilmaril@59: formatMenu->addAction (a); insilmaril@0: actionFormatLinkStylePolyLine=a; insilmaril@59: a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles); insilmaril@59: a->setStatusTip (tr( "PolyParabel" ) ); insilmaril@0: a->setToggleAction(true); insilmaril@59: a->setChecked (true); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) ); insilmaril@59: formatMenu->addAction (a); insilmaril@0: actionFormatLinkStylePolyParabel=a; insilmaril@0: insilmaril@59: a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this); insilmaril@59: a->setStatusTip (tr( "Hide link" )); insilmaril@0: a->setToggleAction(true); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) ); insilmaril@59: actionFormatHideLinkUnselected=a; insilmaril@59: insilmaril@59: formatMenu->addSeparator(); insilmaril@59: a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this); insilmaril@59: a->setStatusTip (tr( "Use same color for links and headings" )); insilmaril@0: a->setToggleAction(true); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) ); insilmaril@59: formatMenu->addAction (a); insilmaril@0: actionFormatLinkColorHint=a; insilmaril@59: insilmaril@59: pix.fill (Qt::white); insilmaril@59: a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this ); insilmaril@59: a->setStatusTip (tr( "Set Link Color" )); insilmaril@59: formatMenu->addAction (a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) ); insilmaril@59: actionFormatLinkColor=a; insilmaril@59: insilmaril@59: a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this ); insilmaril@59: a->setStatusTip (tr( "Set Selection Color" )); insilmaril@59: formatMenu->addAction (a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) ); insilmaril@59: actionFormatSelectionColor=a; insilmaril@59: insilmaril@59: a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this ); insilmaril@59: a->setStatusTip (tr( "Set Background Color" )); insilmaril@59: formatMenu->addAction (a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) ); insilmaril@59: actionFormatBackColor=a; insilmaril@59: insilmaril@59: a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this ); insilmaril@59: a->setStatusTip (tr( "Set Background image" )); insilmaril@59: formatMenu->addAction (a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) ); insilmaril@59: actionFormatBackImage=a; insilmaril@0: } insilmaril@0: insilmaril@0: // View Actions insilmaril@0: void Main::setupViewActions() insilmaril@0: { insilmaril@59: QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") ); insilmaril@0: tb->setLabel( "View Actions" ); insilmaril@59: tb->setObjectName ("viewTB"); insilmaril@59: QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" )); insilmaril@0: insilmaril@0: QAction *a; insilmaril@59: a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this); insilmaril@59: a->setStatusTip ( tr( "Zoom reset" ) ); insilmaril@59: a->setShortcut (Qt::CTRL + Qt::Key_0 ); insilmaril@0: a->addTo( tb ); insilmaril@59: viewMenu->addAction (a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) ); insilmaril@59: insilmaril@59: a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this); insilmaril@59: a->setStatusTip (tr( "Zoom in" )); insilmaril@59: a->setShortcut (Qt::CTRL + Qt::Key_Plus); insilmaril@0: a->addTo( tb ); insilmaril@59: viewMenu->addAction (a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) ); insilmaril@59: insilmaril@59: a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this); insilmaril@59: a->setStatusTip (tr( "Zoom out" )); insilmaril@59: a->setShortcut (Qt::CTRL + Qt::Key_Minus ); insilmaril@0: a->addTo( tb ); insilmaril@59: viewMenu->addAction (a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) ); insilmaril@59: insilmaril@59: a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this); insilmaril@59: a->setStatusTip (tr( "Show selection" )); insilmaril@59: a->setShortcut (Qt::Key_Period); insilmaril@59: a->addTo( tb ); insilmaril@59: viewMenu->addAction (a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) ); insilmaril@59: insilmaril@59: viewMenu->addSeparator(); insilmaril@59: insilmaril@59: a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this); insilmaril@59: a->setStatusTip ( tr( "Show Note Editor" )); insilmaril@59: a->setShortcut ( Qt::CTRL + Qt::Key_E ); insilmaril@0: a->setToggleAction(true); insilmaril@0: a->addTo( tb ); insilmaril@59: viewMenu->addAction (a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) ); insilmaril@0: actionViewToggleNoteEditor=a; insilmaril@59: insilmaril@59: a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this ); insilmaril@59: a->setStatusTip ( tr( "Show History Window" )); insilmaril@59: a->setShortcut ( Qt::CTRL + Qt::Key_H ); insilmaril@59: a->setToggleAction(true); insilmaril@59: a->addTo( tb ); insilmaril@59: viewMenu->addAction (a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) ); insilmaril@59: actionViewToggleHistoryWindow=a; insilmaril@59: insilmaril@59: viewMenu->addAction (actionViewTogglePropertyWindow); insilmaril@59: insilmaril@59: viewMenu->addSeparator(); insilmaril@59: insilmaril@59: a = new QAction(tr( "Antialiasing","View action" ),this ); insilmaril@59: a->setStatusTip ( tr( "Antialiasing" )); insilmaril@59: a->setToggleAction(true); insilmaril@59: a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool()); insilmaril@59: viewMenu->addAction (a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) ); insilmaril@59: actionViewToggleAntiAlias=a; insilmaril@59: insilmaril@59: a = new QAction(tr( "Smooth pixmap transformations","View action" ),this ); insilmaril@59: a->setStatusTip (a->text()); insilmaril@59: a->setToggleAction(true); insilmaril@59: a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool()); insilmaril@59: viewMenu->addAction (a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) ); insilmaril@59: actionViewToggleSmoothPixmapTransform=a; insilmaril@59: insilmaril@59: a = new QAction(tr( "Next Map","View action" ), this); insilmaril@59: a->setStatusTip (a->text()); insilmaril@59: a->setShortcut (Qt::ALT + Qt::Key_N ); insilmaril@59: viewMenu->addAction (a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) ); insilmaril@59: insilmaril@59: a = new QAction (tr( "Previous Map","View action" ), this ); insilmaril@59: a->setStatusTip (a->text()); insilmaril@59: a->setShortcut (Qt::ALT + Qt::Key_P ); insilmaril@59: viewMenu->addAction (a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) ); insilmaril@59: } insilmaril@59: insilmaril@59: // Mode Actions insilmaril@59: void Main::setupModeActions() insilmaril@59: { insilmaril@59: //QPopupMenu *menu = new QPopupMenu( this ); insilmaril@59: //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu ); insilmaril@59: insilmaril@59: QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") ); insilmaril@59: tb->setObjectName ("modesTB"); insilmaril@59: QAction *a; insilmaril@59: actionGroupModModes=new QActionGroup ( this); insilmaril@59: actionGroupModModes->setExclusive (true); insilmaril@59: a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes); insilmaril@59: a->setShortcut (Qt::Key_J); insilmaril@59: a->setStatusTip ( tr( "Use modifier to color branches" )); insilmaril@59: a->setToggleAction(true); insilmaril@59: a->addTo (tb); insilmaril@59: a->setOn(true); insilmaril@59: actionModModeColor=a; insilmaril@59: insilmaril@59: a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes ); insilmaril@59: a->setShortcut( Qt::Key_K); insilmaril@59: a->setStatusTip( tr( "Use modifier to copy" )); insilmaril@59: a->setToggleAction(true); insilmaril@59: a->addTo (tb); insilmaril@59: actionModModeCopy=a; insilmaril@59: insilmaril@59: a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes ); insilmaril@59: a->setShortcut (Qt::Key_L); insilmaril@59: a->setStatusTip( tr( "Use modifier to draw xLinks" )); insilmaril@59: a->setToggleAction(true); insilmaril@59: a->addTo (tb); insilmaril@59: actionModModeXLink=a; insilmaril@0: } insilmaril@0: insilmaril@0: // Flag Actions insilmaril@0: void Main::setupFlagActions() insilmaril@0: { insilmaril@59: // Create System Flags insilmaril@59: QToolBar *tb=NULL; insilmaril@59: bool avis=true; insilmaril@59: insilmaril@59: systemFlagsDefault = new FlagRowObj (); insilmaril@59: systemFlagsDefault->setVisibility (false); insilmaril@59: systemFlagsDefault->setName ("systemFlagsDef"); insilmaril@59: insilmaril@59: FlagObj *fo = new FlagObj (); insilmaril@59: fo->load(QPixmap(flagsPath+"flag-note.png")); insilmaril@59: setupFlag (fo,tb,avis,"note",tr("Note","SystemFlag")); insilmaril@59: insilmaril@59: fo->load(QPixmap(flagsPath+"flag-url.png")); insilmaril@59: setupFlag (fo,tb,avis,"url",tr("URL to Document ","SystemFlag")); insilmaril@59: insilmaril@59: fo->load(QPixmap(flagsPath+"flag-vymlink.png")); insilmaril@59: setupFlag (fo,tb,avis,"vymLink",tr("Link to another vym map","SystemFlag")); insilmaril@59: insilmaril@59: fo->load(QPixmap(flagsPath+"flag-scrolled-right.png")); insilmaril@59: setupFlag (fo,tb,avis,"scrolledright",tr("subtree is scrolled","SystemFlag")); insilmaril@59: insilmaril@59: fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png")); insilmaril@59: setupFlag (fo,tb,avis,"tmpUnscrolledright",tr("subtree is temporary scrolled","SystemFlag")); insilmaril@59: insilmaril@59: fo->load(QPixmap(flagsPath+"flag-hideexport.png")); insilmaril@59: setupFlag (fo,tb,avis,"hideInExport",tr("Hide object in exported maps","SystemFlag")); insilmaril@59: insilmaril@59: // Create Standard Flags insilmaril@59: tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar")); insilmaril@59: tb->setObjectName ("standardFlagTB"); insilmaril@59: insilmaril@59: standardFlagsDefault = new FlagRowObj (); insilmaril@59: standardFlagsDefault->setVisibility (false); insilmaril@59: standardFlagsDefault->setName ("standardFlagsDef"); insilmaril@59: standardFlagsDefault->setToolBar (tb); insilmaril@59: insilmaril@59: fo->load(flagsPath+"flag-exclamationmark.png"); insilmaril@59: fo->setGroup("standard-mark"); insilmaril@59: setupFlag (fo,tb,avis,"exclamationmark",tr("Take care!","Standardflag")); insilmaril@59: insilmaril@59: fo->load(flagsPath+"flag-questionmark.png"); insilmaril@59: fo->setGroup("standard-mark"); insilmaril@59: setupFlag (fo,tb,avis,"questionmark",tr("Really?","Standardflag")); insilmaril@59: insilmaril@59: fo->load(flagsPath+"flag-hook-green.png"); insilmaril@59: fo->setGroup("standard-hook"); insilmaril@59: setupFlag (fo,tb,avis,"hook-green",tr("ok!","Standardflag")); insilmaril@59: insilmaril@59: fo->load(flagsPath+"flag-cross-red.png"); insilmaril@59: fo->setGroup("standard-hook"); insilmaril@59: setupFlag (fo,tb,avis,"cross-red",tr("Not ok!","Standardflag")); insilmaril@59: fo->unsetGroup(); insilmaril@59: insilmaril@59: fo->load(flagsPath+"flag-stopsign.png"); insilmaril@59: setupFlag (fo,tb,avis,"stopsign",tr("This won't work!","Standardflag")); insilmaril@59: insilmaril@59: fo->load(flagsPath+"flag-smiley-good.png"); insilmaril@59: fo->setGroup("standard-smiley"); insilmaril@59: setupFlag (fo,tb,avis,"smiley-good",tr("Good","Standardflag")); insilmaril@59: insilmaril@59: fo->load(flagsPath+"flag-smiley-sad.png"); insilmaril@59: fo->setGroup("standard-smiley"); insilmaril@59: setupFlag (fo,tb,avis,"smiley-sad",tr("Bad","Standardflag")); insilmaril@59: insilmaril@59: fo->load(flagsPath+"flag-smiley-omg.png"); insilmaril@59: fo->setGroup("standard-smiley"); insilmaril@59: setupFlag (fo,tb,avis,"smiley-omb",tr("Oh no!","Standardflag")); insilmaril@59: // Original omg.png (in KDE emoticons) insilmaril@59: fo->unsetGroup(); insilmaril@59: insilmaril@59: fo->load(flagsPath+"flag-kalarm.png"); insilmaril@59: setupFlag (fo,tb,avis,"clock",tr("Time critical","Standardflag")); insilmaril@59: insilmaril@59: fo->load(flagsPath+"flag-phone.png"); insilmaril@59: setupFlag (fo,tb,avis,"phone",tr("Call...","Standardflag")); insilmaril@59: insilmaril@59: fo->load(flagsPath+"flag-lamp.png"); insilmaril@59: setupFlag (fo,tb,avis,"lamp",tr("Idea!","Standardflag")); insilmaril@59: insilmaril@59: fo->load(flagsPath+"flag-arrow-up.png"); insilmaril@59: fo->setGroup("standard-arrow"); insilmaril@59: setupFlag (fo,tb,avis,"arrow-up",tr("Important","Standardflag")); insilmaril@59: insilmaril@59: fo->load(flagsPath+"flag-arrow-down.png"); insilmaril@59: fo->setGroup("standard-arrow"); insilmaril@59: setupFlag (fo,tb,avis,"arrow-down",tr("Unimportant","Standardflag")); insilmaril@59: insilmaril@59: fo->load(flagsPath+"flag-arrow-2up.png"); insilmaril@59: fo->setGroup("standard-arrow"); insilmaril@59: setupFlag (fo,tb,avis,"2arrow-up",tr("Very important!","Standardflag")); insilmaril@59: insilmaril@59: fo->load(flagsPath+"flag-arrow-2down.png"); insilmaril@59: fo->setGroup("standard-arrow"); insilmaril@59: setupFlag (fo,tb,avis,"2arrow-down",tr("Very unimportant!","Standardflag")); insilmaril@59: fo->unsetGroup(); insilmaril@59: insilmaril@59: fo->load(flagsPath+"flag-thumb-up.png"); insilmaril@59: fo->setGroup("standard-thumb"); insilmaril@59: setupFlag (fo,tb,avis,"thumb-up",tr("I like this","Standardflag")); insilmaril@59: insilmaril@59: fo->load(flagsPath+"flag-thumb-down.png"); insilmaril@59: fo->setGroup("standard-thumb"); insilmaril@59: setupFlag (fo,tb,avis,"thumb-down",tr("I do not like this","Standardflag")); insilmaril@59: fo->unsetGroup(); insilmaril@59: insilmaril@59: fo->load(flagsPath+"flag-rose.png"); insilmaril@59: setupFlag (fo,tb,avis,"rose",tr("Rose","Standardflag")); insilmaril@59: insilmaril@59: fo->load(flagsPath+"flag-heart.png"); insilmaril@59: setupFlag (fo,tb,avis,"heart",tr("I just love...","Standardflag")); insilmaril@59: insilmaril@59: fo->load(flagsPath+"flag-present.png"); insilmaril@59: setupFlag (fo,tb,avis,"present",tr("Surprise!","Standardflag")); insilmaril@59: insilmaril@59: fo->load(flagsPath+"flag-flash.png"); insilmaril@59: setupFlag (fo,tb,avis,"flash",tr("Dangerous","Standardflag")); insilmaril@59: insilmaril@59: // Original: xsldbg_output.png insilmaril@59: fo->load(flagsPath+"flag-info.png"); insilmaril@59: setupFlag (fo,tb,avis,"info",tr("Info","Standardflag")); insilmaril@59: insilmaril@59: // Original khelpcenter.png insilmaril@59: fo->load(flagsPath+"flag-lifebelt.png"); insilmaril@59: setupFlag (fo,tb,avis,"lifebelt",tr("This will help","Standardflag")); insilmaril@59: insilmaril@59: // Freemind flags insilmaril@59: insilmaril@59: avis=false; insilmaril@59: insilmaril@59: fo->load(flagsPath+"freemind/warning.png"); insilmaril@59: setupFlag (fo,tb, avis, "freemind-warning",tr("Important","Freemind-Flag")); insilmaril@59: insilmaril@59: for (int i=1; i<8; i++) insilmaril@59: { insilmaril@59: fo->load(flagsPath+QString("freemind/priority-%1.png").arg(i)); insilmaril@59: setupFlag (fo,tb, avis,QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag")); insilmaril@59: } insilmaril@59: insilmaril@59: fo->load(flagsPath+"freemind/back.png"); insilmaril@59: setupFlag (fo,tb,avis,"freemind-back",tr("Back","Freemind-Flag")); insilmaril@59: insilmaril@59: fo->load(flagsPath+"freemind/forward.png"); insilmaril@59: setupFlag (fo,tb,avis,"freemind-forward",tr("Forward","Freemind-Flag")); insilmaril@59: insilmaril@59: fo->load(flagsPath+"freemind/attach.png"); insilmaril@59: setupFlag (fo,tb,avis,"freemind-attach",tr("Look here","Freemind-Flag")); insilmaril@59: insilmaril@59: fo->load(flagsPath+"freemind/clanbomber.png"); insilmaril@59: setupFlag (fo,tb,avis,"freemind-clanbomber",tr("Dangerous","Freemind-Flag")); insilmaril@59: insilmaril@59: fo->load(flagsPath+"freemind/desktopnew.png"); insilmaril@59: setupFlag (fo,tb,avis,"freemind-desktopnew",tr("Don't forget","Freemind-Flag")); insilmaril@59: insilmaril@59: fo->load(flagsPath+"freemind/flag.png"); insilmaril@59: setupFlag (fo,tb,avis,"freemind-flag",tr("Flag","Freemind-Flag")); insilmaril@59: insilmaril@59: insilmaril@59: fo->load(flagsPath+"freemind/gohome.png"); insilmaril@59: setupFlag (fo,tb,avis,"freemind-gohome",tr("Home","Freemind-Flag")); insilmaril@59: insilmaril@59: insilmaril@59: fo->load(flagsPath+"freemind/kaddressbook.png"); insilmaril@59: setupFlag (fo,tb,avis,"freemind-kaddressbook",tr("Telephone","Freemind-Flag")); insilmaril@59: insilmaril@59: fo->load(flagsPath+"freemind/knotify.png"); insilmaril@59: setupFlag (fo,tb,avis,"freemind-knotify",tr("Music","Freemind-Flag")); insilmaril@59: insilmaril@59: fo->load(flagsPath+"freemind/korn.png"); insilmaril@59: setupFlag (fo,tb,avis,"freemind-korn",tr("Mailbox","Freemind-Flag")); insilmaril@59: insilmaril@59: fo->load(flagsPath+"freemind/mail.png"); insilmaril@59: setupFlag (fo,tb,avis,"freemind-mail",tr("Maix","Freemind-Flag")); insilmaril@59: insilmaril@59: fo->load(flagsPath+"freemind/password.png"); insilmaril@59: setupFlag (fo,tb,avis,"freemind-password",tr("Password","Freemind-Flag")); insilmaril@59: insilmaril@59: fo->load(flagsPath+"freemind/pencil.png"); insilmaril@59: setupFlag (fo,tb,avis,"freemind-pencil",tr("To be improved","Freemind-Flag")); insilmaril@59: insilmaril@59: fo->load(flagsPath+"freemind/stop.png"); insilmaril@59: setupFlag (fo,tb,avis,"freemind-stop",tr("Stop","Freemind-Flag")); insilmaril@59: insilmaril@59: fo->load(flagsPath+"freemind/wizard.png"); insilmaril@59: setupFlag (fo,tb,avis,"freemind-wizard",tr("Magic","Freemind-Flag")); insilmaril@59: insilmaril@59: fo->load(flagsPath+"freemind/xmag.png"); insilmaril@59: setupFlag (fo,tb,avis,"freemind-xmag",tr("To be discussed","Freemind-Flag")); insilmaril@59: insilmaril@59: fo->load(flagsPath+"freemind/bell.png"); insilmaril@59: setupFlag (fo,tb,avis,"freemind-bell",tr("Reminder","Freemind-Flag")); insilmaril@59: insilmaril@59: fo->load(flagsPath+"freemind/bookmark.png"); insilmaril@59: setupFlag (fo,tb,avis,"freemind-bookmark",tr("Excellent","Freemind-Flag")); insilmaril@59: insilmaril@59: fo->load(flagsPath+"freemind/penguin.png"); insilmaril@59: setupFlag (fo,tb,avis,"freemind-penguin",tr("Linux","Freemind-Flag")); insilmaril@59: insilmaril@59: fo->load(flagsPath+"freemind/licq.png"); insilmaril@59: setupFlag (fo,tb,avis,"freemind-licq",tr("Sweet","Freemind-Flag")); insilmaril@59: insilmaril@59: delete (fo); insilmaril@0: } insilmaril@0: insilmaril@59: void Main::setupFlag (FlagObj *fo, QToolBar *tb, bool aw, const QString &name, const QString &tooltip) insilmaril@59: { insilmaril@59: fo->setName(name); insilmaril@59: fo->setToolTip (tooltip); insilmaril@59: QAction *a=new QAction (fo->getPixmap(),fo->getName(),this); insilmaril@59: if (tb) insilmaril@59: { insilmaril@59: // StandardFlag insilmaril@59: tb->addAction (a); insilmaril@59: fo->setAction (a); insilmaril@59: fo->setAlwaysVisible(aw); insilmaril@59: a->setCheckable(true); insilmaril@59: a->setObjectName(fo->getName()); insilmaril@59: a->setToolTip(tooltip); insilmaril@59: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@59: standardFlagsDefault->addFlag (fo); insilmaril@59: } else insilmaril@59: { insilmaril@59: // SystemFlag insilmaril@59: systemFlagsDefault->addFlag (fo); insilmaril@59: } insilmaril@59: } insilmaril@59: // Network Actions insilmaril@59: void Main::setupNetworkActions() insilmaril@59: { insilmaril@59: if (!settings.value( "/mainwindow/showTestMenu",false).toBool() ) insilmaril@59: return; insilmaril@59: QMenu *netMenu = menuBar()->addMenu( "Network" ); insilmaril@59: insilmaril@59: QAction *a; insilmaril@59: insilmaril@59: a = new QAction( "Start TCPserver for MapEditor",this); insilmaril@59: //a->setStatusTip ( "Set application to open pdf files")); insilmaril@59: a->setShortcut ( Qt::Key_T ); //New TCP server insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) ); insilmaril@59: netMenu->addAction (a); insilmaril@59: insilmaril@59: a = new QAction( "Connect MapEditor to server",this); insilmaril@59: //a->setStatusTip ( "Set application to open pdf files")); insilmaril@59: a->setShortcut ( Qt::Key_C ); // Connect to server insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) ); insilmaril@59: netMenu->addAction (a); insilmaril@59: } insilmaril@59: insilmaril@0: // Settings Actions insilmaril@0: void Main::setupSettingsActions() insilmaril@0: { insilmaril@59: QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" )); insilmaril@0: insilmaril@0: QAction *a; insilmaril@0: insilmaril@59: a = new QAction( tr( "Set application to open pdf files","Settings action"), this); insilmaril@59: a->setStatusTip ( tr( "Set application to open pdf files")); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) ); insilmaril@59: settingsMenu->addAction (a); insilmaril@59: insilmaril@59: a = new QAction( tr( "Set application to open external links","Settings action"), this); insilmaril@59: a->setStatusTip( tr( "Set application to open external links")); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) ); insilmaril@59: settingsMenu->addAction (a); insilmaril@59: insilmaril@59: a = new QAction( tr( "Set path for macros","Settings action")+"...", this); insilmaril@59: a->setStatusTip( tr( "Set path for macros")); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) ); insilmaril@59: settingsMenu->addAction (a); insilmaril@59: insilmaril@59: a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this); insilmaril@59: a->setStatusTip( tr( "Set number of undo levels")); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) ); insilmaril@59: settingsMenu->addAction (a); insilmaril@59: insilmaril@59: settingsMenu->addSeparator(); insilmaril@59: insilmaril@59: a = new QAction( tr( "Autosave","Settings action"), this); insilmaril@59: a->setStatusTip( tr( "Autosave")); insilmaril@0: a->setToggleAction(true); insilmaril@59: a->setOn ( settings.value ("/mainwindow/autosave/use",false).toBool()); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) ); insilmaril@59: settingsMenu->addAction (a); insilmaril@59: actionSettingsAutosaveToggle=a; insilmaril@59: insilmaril@59: a = new QAction( tr( "Autosave time","Settings action")+"...", this); insilmaril@59: a->setStatusTip( tr( "Autosave time")); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) ); insilmaril@59: settingsMenu->addAction (a); insilmaril@59: actionSettingsAutosaveTime=a; insilmaril@59: insilmaril@59: a = new QAction( tr( "Write backup file on save","Settings action"), this); insilmaril@59: a->setStatusTip( tr( "Write backup file on save")); insilmaril@0: a->setToggleAction(true); insilmaril@59: a->setOn ( settings.value ("/mainwindow/writeBackupFile",false).toBool()); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) ); insilmaril@59: settingsMenu->addAction (a); insilmaril@59: actionSettingsWriteBackupFile=a; insilmaril@59: insilmaril@59: settingsMenu->addSeparator(); insilmaril@59: insilmaril@59: a = new QAction( tr( "Edit branch after adding it","Settings action" ), this ); insilmaril@59: a->setStatusTip( tr( "Edit branch after adding it" )); insilmaril@59: a->setToggleAction(true); insilmaril@59: a->setOn ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool()); insilmaril@59: settingsMenu->addAction (a); insilmaril@59: actionSettingsAutoEditNewBranch=a; insilmaril@59: insilmaril@59: a= new QAction( tr( "Select branch after adding it","Settings action" ), this ); insilmaril@59: a->setStatusTip( tr( "Select branch after adding it" )); insilmaril@59: a->setToggleAction(true); insilmaril@59: a->setOn ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() ); insilmaril@59: settingsMenu->addAction (a); insilmaril@59: actionSettingsAutoSelectNewBranch=a; insilmaril@0: insilmaril@59: a= new QAction(tr( "Select existing heading","Settings action" ), this); insilmaril@59: a->setStatusTip( tr( "Select heading before editing" )); insilmaril@0: a->setToggleAction(true); insilmaril@59: a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() ); insilmaril@59: settingsMenu->addAction (a); insilmaril@59: actionSettingsAutoSelectText=a; insilmaril@0: insilmaril@59: a= new QAction( tr( "Delete key","Settings action" ), this); insilmaril@59: a->setStatusTip( tr( "Delete key for deleting branches" )); insilmaril@0: a->setToggleAction(true); insilmaril@59: a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() ); insilmaril@59: settingsMenu->addAction (a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) ); insilmaril@59: actionSettingsUseDelKey=a; insilmaril@59: insilmaril@59: a= new QAction( tr( "Exclusive flags","Settings action" ), this); insilmaril@59: a->setStatusTip( tr( "Use exclusive flags in flag toolbars" )); insilmaril@59: a->setToggleAction(true); insilmaril@59: a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() ); insilmaril@59: settingsMenu->addAction (a); insilmaril@59: actionSettingsUseFlagGroups=a; insilmaril@0: insilmaril@59: a= new QAction( tr( "Use hide flags","Settings action" ), this); insilmaril@59: a->setStatusTip( tr( "Use hide flag during exports " )); insilmaril@0: a->setToggleAction(true); insilmaril@59: a->setOn ( settings.value ("/export/useHideExport",true).toBool() ); insilmaril@59: settingsMenu->addAction (a); insilmaril@59: actionSettingsUseHideExport=a; insilmaril@59: insilmaril@59: a = new QAction( tr( "Animation","Settings action"), this); insilmaril@59: a->setStatusTip( tr( "Animation")); insilmaril@59: a->setToggleAction(true); insilmaril@59: a->setOn (settings.value("/animation/use",false).toBool() ); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) ); insilmaril@59: if (settings.value( "/mainwindow/showTestMenu",false).toBool() ) insilmaril@59: { insilmaril@59: settingsMenu->addAction (a); insilmaril@59: } insilmaril@59: actionSettingsUseAnimation=a; insilmaril@0: } insilmaril@0: insilmaril@0: // Test Actions insilmaril@0: void Main::setupTestActions() insilmaril@0: { insilmaril@59: QMenu *testMenu = menuBar()->addMenu( tr( "&Test" )); insilmaril@0: insilmaril@0: QAction *a; insilmaril@59: a = new QAction( "Test function 1" , this); insilmaril@59: a->setStatusTip( "Call test function 1" ); insilmaril@59: testMenu->addAction (a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) ); insilmaril@59: insilmaril@59: a = new QAction( "Test function 2" , this); insilmaril@59: a->setStatusTip( "Call test function 2" ); insilmaril@59: testMenu->addAction (a); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) ); insilmaril@59: insilmaril@59: a = new QAction( "Command" , this); insilmaril@59: a->setStatusTip( "Enter command to call in editor" ); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) ); insilmaril@59: testMenu->addAction (a); insilmaril@0: } insilmaril@0: insilmaril@0: // Help Actions insilmaril@0: void Main::setupHelpActions() insilmaril@0: { insilmaril@59: QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" )); insilmaril@0: insilmaril@0: QAction *a; insilmaril@59: a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this ); insilmaril@59: a->setStatusTip( tr( "Open VYM Documentation (pdf)" )); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) ); insilmaril@59: helpMenu->addAction (a); insilmaril@59: insilmaril@59: a = new QAction( tr( "Open VYM example maps ","Help action" ), this ); insilmaril@59: a->setStatusTip( tr( "Open VYM example maps " )); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) ); insilmaril@59: helpMenu->addAction (a); insilmaril@59: insilmaril@59: a = new QAction( tr( "About VYM","Help action" ), this); insilmaril@59: a->setStatusTip( tr( "About VYM")+vymName); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) ); insilmaril@59: helpMenu->addAction (a); insilmaril@59: insilmaril@59: a = new QAction( tr( "About QT","Help action" ), this); insilmaril@59: a->setStatusTip( tr( "Information about QT toolkit" )); insilmaril@59: connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) ); insilmaril@59: 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@59: branchContextMenu =new QMenu (this); insilmaril@59: branchContextMenu->addAction (actionViewTogglePropertyWindow); insilmaril@59: branchContextMenu->addSeparator(); insilmaril@59: insilmaril@59: // Submenu "Add" insilmaril@59: branchAddContextMenu =branchContextMenu->addMenu (tr("Add")); insilmaril@59: branchAddContextMenu->addAction (actionEditPaste ); insilmaril@59: branchAddContextMenu->addAction ( actionEditAddBranch ); insilmaril@59: branchAddContextMenu->addAction ( actionEditAddBranchBefore ); insilmaril@59: branchAddContextMenu->addAction ( actionEditAddBranchAbove); insilmaril@59: branchAddContextMenu->addAction ( actionEditAddBranchBelow ); insilmaril@59: branchAddContextMenu->addSeparator(); insilmaril@59: branchAddContextMenu->addAction ( actionEditImportAdd ); insilmaril@59: branchAddContextMenu->addAction ( actionEditImportReplace ); insilmaril@59: insilmaril@59: // Submenu "Remove" insilmaril@59: branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name")); insilmaril@59: branchRemoveContextMenu->addAction (actionEditCut); insilmaril@59: branchRemoveContextMenu->addAction ( actionEditDelete ); insilmaril@59: branchRemoveContextMenu->addAction ( actionEditDeleteKeepChilds ); insilmaril@59: branchRemoveContextMenu->addAction ( actionEditDeleteChilds ); insilmaril@59: insilmaril@59: insilmaril@0: actionEditSaveBranch->addTo( branchContextMenu ); insilmaril@59: actionFileNewCopy->addTo (branchContextMenu ); insilmaril@59: insilmaril@59: branchContextMenu->addSeparator(); insilmaril@59: branchContextMenu->addAction ( actionEditLoadImage); insilmaril@59: insilmaril@59: // Submenu for Links (URLs, vymLinks) insilmaril@59: branchLinksContextMenu =new QMenu (this); insilmaril@59: insilmaril@59: branchContextMenu->addSeparator(); insilmaril@59: branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name")); insilmaril@59: branchLinksContextMenu->addAction ( actionEditOpenURL ); insilmaril@59: branchLinksContextMenu->addAction ( actionEditOpenURLTab ); insilmaril@59: branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs ); insilmaril@59: branchLinksContextMenu->addAction ( actionEditURL ); insilmaril@59: branchLinksContextMenu->addAction ( actionEditLocalURL ); insilmaril@59: branchLinksContextMenu->addAction ( actionEditHeading2URL ); insilmaril@59: branchLinksContextMenu->addAction ( actionEditBugzilla2URL ); insilmaril@59: if (settings.value( "/mainwindow/showTestMenu",false).toBool() ) insilmaril@59: { insilmaril@59: branchLinksContextMenu->addAction ( actionEditFATE2URL ); insilmaril@59: } insilmaril@59: branchLinksContextMenu->addSeparator(); insilmaril@59: branchLinksContextMenu->addAction ( actionEditOpenVymLink ); insilmaril@59: branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks ); insilmaril@59: branchLinksContextMenu->addAction ( actionEditVymLink ); insilmaril@59: branchLinksContextMenu->addAction ( actionEditDeleteVymLink ); insilmaril@59: insilmaril@59: insilmaril@59: // Context Menu for XLinks in a branch menu insilmaril@59: // This will be populated "on demand" in MapEditor::updateActions insilmaril@59: branchContextMenu->addSeparator(); insilmaril@59: branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name")); insilmaril@59: branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name")); insilmaril@59: connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) ); insilmaril@59: connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) ); insilmaril@59: insilmaril@59: insilmaril@0: // Context menu for floatimage insilmaril@59: floatimageContextMenu =new QMenu (this); insilmaril@59: a= new QAction (tr ("Save image","Context action"),this); insilmaril@59: connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage())); insilmaril@59: floatimageContextMenu->addAction (a); insilmaril@59: insilmaril@59: floatimageContextMenu->addSeparator(); insilmaril@0: actionEditCopy->addTo( floatimageContextMenu ); insilmaril@0: actionEditCut->addTo( floatimageContextMenu ); insilmaril@0: insilmaril@59: floatimageContextMenu->addSeparator(); insilmaril@59: floatimageContextMenu->addAction ( actionFormatHideLinkUnselected ); insilmaril@0: insilmaril@0: insilmaril@0: // Context menu for canvas insilmaril@59: canvasContextMenu =new QMenu (this); insilmaril@0: actionEditMapInfo->addTo( canvasContextMenu ); insilmaril@59: if (settings.value( "/mainwindow/showTestMenu",false).toBool() ) insilmaril@59: 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@59: actionFormatSelectionColor->addTo( canvasContextMenu ); insilmaril@0: actionFormatBackColor->addTo( canvasContextMenu ); insilmaril@59: // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME makes vym too slow: postponed for later version insilmaril@0: insilmaril@0: // Menu for last opened files insilmaril@59: // Create actions insilmaril@59: for (int i = 0; i < MaxRecentFiles; ++i) insilmaril@0: { insilmaril@59: recentFileActions[i] = new QAction(this); insilmaril@59: recentFileActions[i]->setVisible(false); insilmaril@59: fileLastMapsMenu->addAction(recentFileActions[i]); insilmaril@59: connect(recentFileActions[i], SIGNAL(triggered()), insilmaril@59: this, SLOT(fileLoadRecent())); insilmaril@59: } insilmaril@59: setupRecentMapsMenu(); insilmaril@0: } insilmaril@0: insilmaril@59: void Main::setupRecentMapsMenu() insilmaril@0: { insilmaril@59: QStringList files = settings.value("/mainwindow/recentFileList").toStringList(); insilmaril@59: insilmaril@59: int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles); insilmaril@59: insilmaril@59: for (int i = 0; i < numRecentFiles; ++i) { insilmaril@59: QString text = tr("&%1 %2").arg(i + 1).arg(files[i]); insilmaril@59: recentFileActions[i]->setText(text); insilmaril@59: recentFileActions[i]->setData(files[i]); insilmaril@59: recentFileActions[i]->setVisible(true); insilmaril@59: } insilmaril@59: for (int j = numRecentFiles; j < MaxRecentFiles; ++j) insilmaril@59: recentFileActions[j]->setVisible(false); insilmaril@59: } insilmaril@59: insilmaril@59: void Main::setupMacros() insilmaril@59: { insilmaril@59: for (int i = 0; i <= 11; i++) insilmaril@0: { insilmaril@59: macroActions[i] = new QAction(this); insilmaril@59: macroActions[i]->setData(i); insilmaril@59: addAction (macroActions[i]); insilmaril@59: connect(macroActions[i], SIGNAL(triggered()), insilmaril@59: this, SLOT(callMacro())); insilmaril@59: } insilmaril@59: macroActions[0]->setShortcut ( Qt::Key_F1 ); insilmaril@59: macroActions[1]->setShortcut ( Qt::Key_F2 ); insilmaril@59: macroActions[2]->setShortcut ( Qt::Key_F3 ); insilmaril@59: macroActions[3]->setShortcut ( Qt::Key_F4 ); insilmaril@59: macroActions[4]->setShortcut ( Qt::Key_F5 ); insilmaril@59: macroActions[5]->setShortcut ( Qt::Key_F6 ); insilmaril@59: macroActions[6]->setShortcut ( Qt::Key_F7 ); insilmaril@59: macroActions[7]->setShortcut ( Qt::Key_F8 ); insilmaril@59: macroActions[8]->setShortcut ( Qt::Key_F9 ); insilmaril@59: macroActions[9]->setShortcut ( Qt::Key_F10 ); insilmaril@59: macroActions[10]->setShortcut ( Qt::Key_F11 ); insilmaril@59: 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@59: 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@59: for (int i=0;i<=tabWidget->count() -1;i++) insilmaril@0: { insilmaril@0: me=(MapEditor*)tabWidget->page(i); insilmaril@0: me->unselect(); insilmaril@0: } insilmaril@59: me=currentMapEditor(); insilmaril@59: if (me) me->reselect(); insilmaril@0: insilmaril@0: // Update actions to in menus and toolbars according to editor insilmaril@59: updateActions(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::fileNew() insilmaril@0: { insilmaril@0: QString fn="unnamed"; insilmaril@59: MapEditor* me = new MapEditor ( NULL); insilmaril@59: tabWidget->addTab (me,fn); insilmaril@59: tabWidget->showPage(me); insilmaril@59: me->viewport()->setFocus(); insilmaril@59: me->setAntiAlias (actionViewToggleAntiAlias->isOn()); insilmaril@59: me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn()); insilmaril@59: insilmaril@59: // For the very first map we do not have flagrows yet... insilmaril@59: me->select("mc:"); insilmaril@0: } insilmaril@0: insilmaril@59: void Main::fileNewCopy() insilmaril@0: { insilmaril@59: QString fn="unnamed"; insilmaril@59: MapEditor* oldME =currentMapEditor(); insilmaril@59: if (oldME) insilmaril@59: { insilmaril@59: oldME->copy(); insilmaril@59: MapEditor* newME = new MapEditor ( NULL); insilmaril@59: if (newME) insilmaril@59: { insilmaril@59: tabWidget->addTab (newME,fn); insilmaril@59: tabWidget->showPage(newME); insilmaril@59: newME->viewport()->setFocus(); insilmaril@59: newME->setAntiAlias (actionViewToggleAntiAlias->isOn()); insilmaril@59: newME->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn()); insilmaril@59: // For the very first map we do not have flagrows yet... insilmaril@59: newME->select("mc:"); insilmaril@59: newME->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap); insilmaril@59: } insilmaril@59: insilmaril@59: } insilmaril@59: } insilmaril@59: insilmaril@59: ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype) insilmaril@59: { insilmaril@59: 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@59: QMessageBox mb( vymName, insilmaril@59: 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@59: "Do you want to").arg(fn), insilmaril@0: QMessageBox::Warning, insilmaril@0: QMessageBox::Yes | QMessageBox::Default, insilmaril@0: QMessageBox::Cancel | QMessageBox::Escape, insilmaril@59: 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@59: 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@59: me= new MapEditor ( NULL); insilmaril@0: tabWidget->addTab (me,fn); insilmaril@0: tabIndex=tabWidget->indexOf (me); insilmaril@0: tabWidget->setCurrentPage (tabIndex); insilmaril@59: me->setAntiAlias (actionViewToggleAntiAlias->isOn()); insilmaril@59: 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@59: /* insilmaril@59: */ insilmaril@0: if (!QFile(fn).exists() ) insilmaril@0: { insilmaril@59: QMessageBox mb( vymName, insilmaril@59: 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@59: 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@59: 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@59: return aborted; 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@59: if (err!=aborted) insilmaril@0: { insilmaril@59: // Save existing filename in case we import insilmaril@59: QString fn_org=me->getFilePath(); insilmaril@59: insilmaril@59: // Finally load map into mapEditor insilmaril@59: me->setFilePath (fn); insilmaril@59: err=me->load(fn,lmode,ftype); insilmaril@59: insilmaril@59: // Restore old (maybe empty) filepath, if this is an import insilmaril@59: if (lmode!=NewMap) insilmaril@59: me->setFilePath (fn_org); insilmaril@59: } insilmaril@59: insilmaril@59: // Finally check for errors and go home insilmaril@59: if (err==aborted) insilmaril@0: { insilmaril@59: if (lmode==NewMap) fileCloseMap(); insilmaril@59: statusBar()->message( "Could not load " + fn, statusbarTime ); insilmaril@59: } 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@59: if (!isInTmpDir (fn)) insilmaril@59: { insilmaril@59: // Only append to lastMaps if not loaded from a tmpDir insilmaril@59: // e.g. imported bookmarks are in a tmpDir insilmaril@59: addRecentMap(me->getFilePath() ); insilmaril@59: } insilmaril@0: actionFilePrint->setEnabled (true); insilmaril@0: } insilmaril@0: statusBar()->message( "Loaded " + fn, statusbarTime ); insilmaril@0: } insilmaril@0: } insilmaril@59: return err; insilmaril@0: } insilmaril@0: insilmaril@0: insilmaril@0: void Main::fileLoad(const LoadMode &lmode) insilmaril@0: { insilmaril@59: QStringList filters; insilmaril@59: filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)"; insilmaril@0: QFileDialog *fd=new QFileDialog( this); insilmaril@59: fd->setDir (lastFileDir); insilmaril@59: fd->setFileMode (QFileDialog::ExistingFiles); insilmaril@59: fd->setFilters (filters); insilmaril@0: switch (lmode) insilmaril@0: { insilmaril@0: case NewMap: insilmaril@59: fd->setCaption(vymName+ " - " +tr("Load vym map")); insilmaril@0: break; insilmaril@0: case ImportAdd: insilmaril@59: fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection")); insilmaril@0: break; insilmaril@0: case ImportReplace: insilmaril@59: 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@59: lastFileDir=fd->directory().path(); insilmaril@59: QStringList flist = fd->selectedFiles(); insilmaril@59: QStringList::Iterator it = flist.begin(); insilmaril@59: while( it != flist.end() ) insilmaril@59: { insilmaril@59: fn = *it; insilmaril@59: fileLoad(*it, lmode); insilmaril@59: ++it; insilmaril@59: } insilmaril@0: } insilmaril@59: delete (fd); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::fileLoad() insilmaril@0: { insilmaril@0: fileLoad (NewMap); insilmaril@0: } insilmaril@0: insilmaril@59: void Main::fileLoadRecent() insilmaril@0: { insilmaril@59: QAction *action = qobject_cast(sender()); insilmaril@59: if (action) insilmaril@59: fileLoad (action->data().toString(), NewMap); insilmaril@0: } insilmaril@0: insilmaril@59: void Main::addRecentMap (const QString &fileName) insilmaril@0: { insilmaril@59: insilmaril@59: QStringList files = settings.value("/mainwindow/recentFileList").toStringList(); insilmaril@59: files.removeAll(fileName); insilmaril@59: files.prepend(fileName); insilmaril@59: while (files.size() > MaxRecentFiles) insilmaril@59: files.removeLast(); insilmaril@59: insilmaril@59: settings.setValue("/mainwindow/recentFileList", files); insilmaril@59: insilmaril@59: setupRecentMapsMenu(); insilmaril@59: } insilmaril@59: insilmaril@59: void Main::fileSave(MapEditor *me, const SaveMode &savemode) insilmaril@59: { insilmaril@59: if (!me) return; insilmaril@59: insilmaril@59: if ( me->getFilePath().isEmpty() ) insilmaril@0: { insilmaril@59: // We have no filepath yet, insilmaril@59: // call fileSaveAs() now, this will call fileSave() insilmaril@59: // again. insilmaril@59: // First switch to editor insilmaril@59: tabWidget->setCurrentWidget (me); insilmaril@59: fileSaveAs(savemode); insilmaril@59: } insilmaril@59: insilmaril@59: if (me->save (savemode)==success) insilmaril@0: { insilmaril@0: statusBar()->message( insilmaril@59: tr("Saved %1").arg(me->getFilePath()), insilmaril@0: statusbarTime ); insilmaril@59: addRecentMap (me->getFilePath() ); insilmaril@59: } else insilmaril@0: statusBar()->message( insilmaril@59: tr("Couldn't save ").arg(me->getFilePath()), insilmaril@0: statusbarTime ); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::fileSave() insilmaril@0: { insilmaril@59: fileSave (currentMapEditor(), CompleteMap); insilmaril@59: } insilmaril@59: insilmaril@59: void Main::fileSave(MapEditor *me) insilmaril@59: { insilmaril@59: 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@59: fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this ); insilmaril@0: else insilmaril@59: 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@59: QMessageBox mb( vymName, insilmaril@59: 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@59: 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@59: fileSave(currentMapEditor(), savemode); insilmaril@0: insilmaril@0: // Set name of tab insilmaril@59: if (savemode==CompleteMap) insilmaril@59: tabWidget->setTabLabel (currentMapEditor(), insilmaril@59: 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@62: void Main::fileImportKDE3Bookmarks() insilmaril@59: { insilmaril@62: ImportKDE3Bookmarks im; insilmaril@59: im.transform(); insilmaril@62: if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() ) insilmaril@62: currentMapEditor()->setFilePath (""); insilmaril@62: } insilmaril@62: insilmaril@62: void Main::fileImportKDE4Bookmarks() insilmaril@62: { insilmaril@62: ImportKDE4Bookmarks im; insilmaril@62: im.transform(); insilmaril@62: if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() ) insilmaril@59: currentMapEditor()->setFilePath (""); insilmaril@59: } insilmaril@59: insilmaril@59: void Main::fileImportFirefoxBookmarks() insilmaril@59: { insilmaril@59: Q3FileDialog *fd=new Q3FileDialog( this); insilmaril@59: fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox"); insilmaril@59: fd->setMode (Q3FileDialog::ExistingFiles); insilmaril@59: fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)"); insilmaril@59: fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks")); insilmaril@59: fd->show(); insilmaril@59: insilmaril@59: if ( fd->exec() == QDialog::Accepted ) insilmaril@59: { insilmaril@59: ImportFirefoxBookmarks im; insilmaril@59: QStringList flist = fd->selectedFiles(); insilmaril@59: QStringList::Iterator it = flist.begin(); insilmaril@59: while( it != flist.end() ) insilmaril@59: { insilmaril@59: im.setFile (*it); insilmaril@59: if (im.transform() && insilmaril@62: aborted!=fileLoad (im.getTransformedFile(),NewMap,FreemindMap) && insilmaril@59: currentMapEditor() ) insilmaril@59: currentMapEditor()->setFilePath (""); insilmaril@59: ++it; insilmaril@59: } insilmaril@59: } insilmaril@59: delete (fd); insilmaril@59: } insilmaril@59: insilmaril@59: void Main::fileImportFreemind() insilmaril@59: { insilmaril@59: QStringList filters; insilmaril@59: filters <<"Freemind map (*.mm)"<<"All files (*)"; insilmaril@59: QFileDialog *fd=new QFileDialog( this); insilmaril@59: fd->setDir (lastFileDir); insilmaril@59: fd->setFileMode (QFileDialog::ExistingFiles); insilmaril@59: fd->setFilters (filters); insilmaril@59: fd->setCaption(vymName+ " - " +tr("Load Freemind map")); insilmaril@59: fd->show(); insilmaril@59: insilmaril@59: QString fn; insilmaril@59: if ( fd->exec() == QDialog::Accepted ) insilmaril@59: { insilmaril@59: lastFileDir=fd->directory().path(); insilmaril@59: QStringList flist = fd->selectedFiles(); insilmaril@59: QStringList::Iterator it = flist.begin(); insilmaril@59: while( it != flist.end() ) insilmaril@59: { insilmaril@59: fn = *it; insilmaril@59: if ( fileLoad (fn,NewMap, FreemindMap) ) insilmaril@59: { insilmaril@59: currentMapEditor()->setFilePath (""); insilmaril@59: } insilmaril@59: ++it; insilmaril@59: } insilmaril@59: } insilmaril@59: delete (fd); insilmaril@59: } insilmaril@59: insilmaril@59: insilmaril@59: void Main::fileImportMM() insilmaril@59: { insilmaril@59: ImportMM im; insilmaril@59: insilmaril@59: Q3FileDialog *fd=new Q3FileDialog( this); insilmaril@59: fd->setDir (lastFileDir); insilmaril@59: fd->setMode (Q3FileDialog::ExistingFiles); insilmaril@59: fd->addFilter ("Mind Manager (*.mmap)"); insilmaril@59: fd->setCaption(tr("Import")+" "+"Mind Manager"); insilmaril@59: fd->show(); insilmaril@59: insilmaril@59: if ( fd->exec() == QDialog::Accepted ) insilmaril@59: { insilmaril@59: lastFileDir=fd->dirPath(); insilmaril@59: QStringList flist = fd->selectedFiles(); insilmaril@59: QStringList::Iterator it = flist.begin(); insilmaril@59: while( it != flist.end() ) insilmaril@59: { insilmaril@59: im.setFile (*it); insilmaril@59: if (im.transform() && insilmaril@59: success==fileLoad (im.getTransformedFile(),NewMap) && insilmaril@59: currentMapEditor() ) insilmaril@59: currentMapEditor()->setFilePath (""); insilmaril@59: insilmaril@59: ++it; insilmaril@59: } insilmaril@59: } insilmaril@59: delete (fd); insilmaril@59: insilmaril@59: } insilmaril@59: insilmaril@0: void Main::fileImportDir() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->importDir(); insilmaril@0: } insilmaril@0: insilmaril@59: void Main::fileExportXML() insilmaril@0: { insilmaril@59: MapEditor *me=currentMapEditor(); insilmaril@59: if (me) me->exportXML(); insilmaril@59: } insilmaril@59: insilmaril@59: insilmaril@59: void Main::fileExportXHTML() insilmaril@59: { insilmaril@59: MapEditor *me=currentMapEditor(); insilmaril@59: if (me) me->exportXHTML(); insilmaril@59: } insilmaril@59: insilmaril@59: void Main::fileExportImage() insilmaril@59: { insilmaril@59: MapEditor *me=currentMapEditor(); insilmaril@59: if (me) me->exportImage(); insilmaril@59: } insilmaril@59: insilmaril@59: void Main::fileExportASCII() insilmaril@59: { insilmaril@59: MapEditor *me=currentMapEditor(); insilmaril@59: if (me) me->exportASCII(); insilmaril@59: } insilmaril@59: insilmaril@59: void Main::fileExportCSV() //FIXME not scriptable yet insilmaril@59: { insilmaril@59: MapEditor *me=currentMapEditor(); insilmaril@59: if (me) insilmaril@0: { insilmaril@59: ExportCSV ex; insilmaril@59: ex.setModel (me->getModel()); insilmaril@59: ex.addFilter ("CSV (*.csv)"); insilmaril@59: ex.setDir(lastImageDir); insilmaril@59: ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)")); insilmaril@59: if (ex.execDialog() ) insilmaril@59: { insilmaril@59: me->setExportMode(true); insilmaril@59: ex.doExport(); insilmaril@59: me->setExportMode(false); insilmaril@59: } insilmaril@59: } insilmaril@59: } insilmaril@59: insilmaril@59: void Main::fileExportLaTeX() //FIXME not scriptable yet insilmaril@59: { insilmaril@59: MapEditor *me=currentMapEditor(); insilmaril@59: if (me) insilmaril@59: { insilmaril@59: ExportLaTeX ex; insilmaril@59: ex.setModel (me->getModel()); insilmaril@59: ex.addFilter ("Tex (*.tex)"); insilmaril@59: ex.setDir(lastImageDir); insilmaril@59: ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)")); insilmaril@59: if (ex.execDialog() ) insilmaril@59: { insilmaril@59: me->setExportMode(true); insilmaril@59: ex.doExport(); insilmaril@59: me->setExportMode(false); insilmaril@59: } insilmaril@59: } insilmaril@59: } insilmaril@59: insilmaril@62: void Main::fileExportKDE3Bookmarks() //FIXME not scriptable yet insilmaril@59: { insilmaril@62: ExportKDE3Bookmarks ex; insilmaril@62: MapEditor *me=currentMapEditor(); insilmaril@62: if (me) insilmaril@62: { insilmaril@62: ex.setModel (me->getModel()); insilmaril@62: ex.doExport(); insilmaril@62: } insilmaril@62: } insilmaril@62: insilmaril@62: void Main::fileExportKDE4Bookmarks() //FIXME not scriptable yet insilmaril@62: { insilmaril@62: ExportKDE4Bookmarks ex; insilmaril@59: MapEditor *me=currentMapEditor(); insilmaril@59: if (me) insilmaril@59: { insilmaril@59: ex.setModel (me->getModel()); insilmaril@59: ex.doExport(); insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@59: void Main::fileExportTaskjuggler() //FIXME not scriptable yet insilmaril@0: { insilmaril@59: ExportTaskjuggler ex; insilmaril@59: MapEditor *me=currentMapEditor(); insilmaril@59: if (me) insilmaril@0: { insilmaril@59: ex.setModel (me->getModel()); insilmaril@59: ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)")); insilmaril@59: ex.setDir(lastImageDir); insilmaril@59: ex.addFilter ("Taskjuggler (*.tjp)"); insilmaril@59: if (ex.execDialog() ) insilmaril@0: { insilmaril@59: me->setExportMode(true); insilmaril@59: ex.doExport(); insilmaril@59: me->setExportMode(false); insilmaril@0: } insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@59: void Main::fileExportOOPresentation() //FIXME not scriptable yet insilmaril@0: { insilmaril@59: ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office"); insilmaril@59: // TODO add preview in dialog insilmaril@59: //ImagePreview *p =new ImagePreview (fd); insilmaril@59: //fd->setContentsPreviewEnabled( TRUE ); insilmaril@59: //fd->setContentsPreview( p, p ); insilmaril@59: //fd->setPreviewMode( QFileDialog::Contents ); insilmaril@59: fd->setCaption(vymName+" - " +tr("Export to")+" Open Office"); insilmaril@59: fd->setDir (QDir().current()); insilmaril@59: if (fd->foundConfig()) insilmaril@0: { insilmaril@59: fd->show(); insilmaril@59: insilmaril@59: if ( fd->exec() == QDialog::Accepted ) insilmaril@0: { insilmaril@59: QString fn=fd->selectedFile(); insilmaril@59: if (!fn.contains (".odp")) insilmaril@59: fn +=".odp"; insilmaril@59: insilmaril@59: //lastImageDir=fn.left(fn.findRev ("/")); insilmaril@59: if (currentMapEditor()) insilmaril@59: currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig()); insilmaril@0: } insilmaril@59: } else insilmaril@0: { insilmaril@59: QMessageBox::warning(0, insilmaril@59: tr("Warning"), insilmaril@59: tr("Couldn't find configuration for export to Open Office\n")); insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@0: void Main::fileCloseMap() insilmaril@0: { insilmaril@59: MapEditor *me = currentMapEditor(); insilmaril@59: if (me) insilmaril@0: { insilmaril@59: if (me->hasChanged()) insilmaril@0: { insilmaril@59: QMessageBox mb( vymName, insilmaril@59: 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@59: 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@59: //me->closeMap(); insilmaril@59: tabWidget->removePage(me); insilmaril@0: if (tabWidget->count()==0) insilmaril@0: actionFilePrint->setEnabled (false); insilmaril@59: insilmaril@59: //Remove mapEditor; insilmaril@59: // Better would be delete (me), but then we have a Qt error: insilmaril@59: // "QObject: Do not delete object, 'MapEditor', during its event handler!" insilmaril@59: // So we only remove data now and call deconstructor when vym closes later insilmaril@59: me->clear(); insilmaril@59: } 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@59: if (me->hasChanged()) insilmaril@0: { insilmaril@0: tabWidget->setCurrentPage(i); insilmaril@59: 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@59: 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@59: 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@59: me->clear(); // remove and unselect now, before mainWindow has gone... 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@59: void Main::editRedo() insilmaril@0: { insilmaril@59: if (currentMapEditor()) insilmaril@59: currentMapEditor()->redo(); insilmaril@59: } insilmaril@59: insilmaril@59: void Main::gotoHistoryStep (int i) insilmaril@59: { insilmaril@59: if (currentMapEditor()) insilmaril@59: currentMapEditor()->gotoHistoryStep (i); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editCopy() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->copy(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editPaste() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->paste(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editCut() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->cut(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editOpenFindWindow() insilmaril@0: { insilmaril@0: findWindow->popup(); insilmaril@0: findWindow->raise(); insilmaril@0: findWindow->setActiveWindow(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editFind(QString s) insilmaril@0: { insilmaril@0: bool cs=false; insilmaril@0: BranchObj *bo=currentMapEditor()->findText(s, cs); insilmaril@0: if (bo) insilmaril@0: { insilmaril@0: statusBar()->message( "Found: " + bo->getHeading(), statusbarTime ); insilmaril@0: } else insilmaril@0: { insilmaril@0: QMessageBox::information( findWindow, tr( "VYM -Information:" ), insilmaril@59: 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@59: void Main::openTabs(QStringList urls) insilmaril@59: { insilmaril@59: if (!urls.isEmpty()) insilmaril@59: { insilmaril@59: bool success=true; insilmaril@59: QStringList args; insilmaril@59: QString browser=settings.value("/mainwindow/readerURL" ).toString(); insilmaril@59: QProcess *p; insilmaril@59: if (!procBrowser || procBrowser->state()!=QProcess::Running) insilmaril@59: { insilmaril@59: QString u=urls.takeFirst(); insilmaril@59: procBrowser = new QProcess( this ); insilmaril@59: args<start(browser,args); insilmaril@59: if ( !procBrowser->waitForStarted()) insilmaril@59: { insilmaril@59: // try to set path to browser insilmaril@59: QMessageBox::warning(0, insilmaril@59: tr("Warning"), insilmaril@59: tr("Couldn't find a viewer to open %1.\n").arg(u)+ insilmaril@59: tr("Please use Settings->")+tr("Set application to open an URL")); insilmaril@59: return; insilmaril@59: } insilmaril@59: #if defined(Q_OS_WIN32) insilmaril@59: // There's no sleep in VCEE, replace it with Qt's QThread::wait(). insilmaril@59: this->thread()->wait(3000); insilmaril@59: #else insilmaril@59: sleep (3); insilmaril@59: #endif insilmaril@59: } insilmaril@59: if (browser.contains("konqueror")) insilmaril@59: { insilmaril@64: cout << "Main::openTabs urls="<pid()->dwProcessId)<< insilmaril@59: "konqueror-mainwindow#1"<< insilmaril@59: "newTab" << insilmaril@59: urls.at(i); insilmaril@59: #else insilmaril@59: args<< QString("konqueror-%1").arg(procBrowser->pid())<< insilmaril@59: "konqueror-mainwindow#1"<< insilmaril@59: "newTab" << insilmaril@59: urls.at(i); insilmaril@64: // qdbus org.kde.konqueror-15367 /konqueror/MainWindow_1 newTab www.suse.de false insilmaril@59: #endif insilmaril@59: p->start ("dcop",args); insilmaril@64: if (debug) insilmaril@64: cout << "MainWindo::openURLs i="<waitForStarted() ) success=false; insilmaril@59: } insilmaril@59: if (!success) insilmaril@59: QMessageBox::warning(0, insilmaril@59: tr("Warning"), insilmaril@59: tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror")); insilmaril@59: return; insilmaril@59: } else if (browser.contains ("firefox") || browser.contains ("mozilla") ) insilmaril@59: { insilmaril@59: for (int i=0; istart (browser,args); insilmaril@59: if ( !p->waitForStarted() ) success=false; insilmaril@59: } insilmaril@59: if (!success) insilmaril@59: QMessageBox::warning(0, insilmaril@59: tr("Warning"), insilmaril@59: tr("Couldn't start %1 to open a new tab").arg(browser)); insilmaril@59: return; insilmaril@59: } insilmaril@59: QMessageBox::warning(0, insilmaril@59: tr("Warning"), insilmaril@59: tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing.")); insilmaril@59: } insilmaril@59: } insilmaril@59: insilmaril@0: void Main::editOpenURL() insilmaril@0: { insilmaril@59: // Open new browser insilmaril@0: if (currentMapEditor()) insilmaril@59: { insilmaril@59: QString url=currentMapEditor()->getURL(); insilmaril@59: QStringList args; insilmaril@59: if (url=="") return; insilmaril@59: QString browser=settings.value("/mainwindow/readerURL" ).toString(); insilmaril@59: procBrowser = new QProcess( this ); insilmaril@59: args<start(browser,args); insilmaril@59: if ( !procBrowser->waitForStarted()) insilmaril@59: { insilmaril@59: // try to set path to browser insilmaril@59: QMessageBox::warning(0, insilmaril@59: tr("Warning"), insilmaril@59: tr("Couldn't find a viewer to open %1.\n").arg(url)+ insilmaril@59: tr("Please use Settings->")+tr("Set application to open an URL")); insilmaril@59: settingsURL() ; insilmaril@59: } insilmaril@59: } insilmaril@0: } insilmaril@59: void Main::editOpenURLTab() insilmaril@59: { insilmaril@59: if (currentMapEditor()) insilmaril@59: { insilmaril@59: QStringList urls; insilmaril@59: urls.append(currentMapEditor()->getURL()); insilmaril@59: openTabs (urls); insilmaril@59: } insilmaril@59: } insilmaril@59: void Main::editOpenMultipleURLTabs() insilmaril@59: { insilmaril@59: if (currentMapEditor()) insilmaril@59: { insilmaril@59: QStringList urls; insilmaril@59: urls=currentMapEditor()->getURLs(); insilmaril@64: insilmaril@59: openTabs (urls); insilmaril@59: } insilmaril@59: } insilmaril@59: insilmaril@0: insilmaril@0: void Main::editURL() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->editURL(); insilmaril@0: } insilmaril@0: insilmaril@59: void Main::editLocalURL() insilmaril@59: { insilmaril@59: if (currentMapEditor()) insilmaril@59: currentMapEditor()->editLocalURL(); insilmaril@59: } insilmaril@59: 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@59: void Main::editFATE2URL() insilmaril@0: { insilmaril@59: if (currentMapEditor()) insilmaril@59: currentMapEditor()->editFATE2URL(); insilmaril@59: } insilmaril@59: insilmaril@59: void Main::editHeadingFinished() insilmaril@59: { insilmaril@59: // only called from editHeading(), so there is a currentME insilmaril@59: MapEditor *me=currentMapEditor(); insilmaril@59: if (me) insilmaril@59: { insilmaril@59: me->setStateEditHeading (false); insilmaril@59: QPoint p; //Not used here, only to find out pos of branch insilmaril@59: bool ok; insilmaril@59: QString s=me->getHeading(ok,p); insilmaril@59: insilmaril@59: #if defined(Q_OS_MACX) || defined(Q_OS_WIN32) insilmaril@59: #else insilmaril@59: if (ok && s!=lineedit->text()) insilmaril@59: me->setHeading(lineedit->text()); insilmaril@59: insilmaril@59: lineedit->releaseKeyboard(); insilmaril@59: lineedit->hide(); insilmaril@59: setFocus(); insilmaril@59: #endif insilmaril@59: if (!actionSettingsAutoSelectNewBranch->isOn() && insilmaril@59: !prevSelection.isEmpty()) insilmaril@59: me->select(prevSelection); insilmaril@59: prevSelection=""; insilmaril@59: } insilmaril@59: } insilmaril@59: insilmaril@59: void Main::editHeading() insilmaril@59: { insilmaril@0: if (currentMapEditor()) insilmaril@0: { insilmaril@59: MapEditor *me=currentMapEditor(); insilmaril@59: QString oldSel=me->getSelectString(); insilmaril@59: insilmaril@59: if (lineedit->isVisible()) insilmaril@59: editHeadingFinished(); insilmaril@59: else insilmaril@59: { insilmaril@59: bool ok; insilmaril@59: QPoint p; insilmaril@59: QString s=me->getHeading(ok,p); insilmaril@59: insilmaril@59: if (ok) insilmaril@59: { insilmaril@59: me->setStateEditHeading (true); insilmaril@59: #if defined(Q_OS_MACX) || defined(Q_OS_WIN32) insilmaril@59: p=me->mapToGlobal (p); insilmaril@59: QDialog *d =new QDialog(NULL); insilmaril@59: QLineEdit *le=new QLineEdit (d); insilmaril@59: d->setWindowFlags (Qt::FramelessWindowHint); insilmaril@59: d->setGeometry(p.x(),p.y(),230,25); insilmaril@59: le->resize (d->width()-10,d->height()); insilmaril@59: le->setText (s); insilmaril@59: le->selectAll(); insilmaril@59: connect (le, SIGNAL (returnPressed()), d, SLOT (accept())); insilmaril@59: d->activateWindow(); insilmaril@59: d->exec(); insilmaril@59: me->setHeading (le->text()); insilmaril@59: delete (le); insilmaril@59: delete (d); insilmaril@59: editHeadingFinished(); insilmaril@59: #else insilmaril@59: p=me->mapTo (this,p); insilmaril@59: lineedit->setGeometry(p.x(),p.y(),230,25); insilmaril@59: lineedit->setText(s); insilmaril@59: lineedit->setCursorPosition(1); insilmaril@59: lineedit->selectAll(); insilmaril@59: lineedit->show(); insilmaril@59: lineedit->grabKeyboard(); insilmaril@59: lineedit->setFocus(); insilmaril@59: #endif insilmaril@59: } insilmaril@59: } insilmaril@59: } // currentMapEditor() insilmaril@59: } insilmaril@59: insilmaril@59: void Main::editAttributeFinished() insilmaril@59: { insilmaril@59: // only called from editHeading(), so there is a currentME insilmaril@59: insilmaril@59: /* insilmaril@59: MapEditor *me=currentMapEditor(); insilmaril@59: if (me) insilmaril@59: { insilmaril@59: me->setStateEditHeading (false); insilmaril@59: QPoint p; //Not used here, only to find out pos of branch insilmaril@59: bool ok; insilmaril@59: QString s=me->getHeading(ok,p); insilmaril@59: insilmaril@59: #if defined(Q_OS_MACX) insilmaril@59: #else insilmaril@59: if (ok && s!=lineedit->text()) insilmaril@59: me->setHeading(lineedit->text()); insilmaril@59: insilmaril@59: lineedit->releaseKeyboard(); insilmaril@59: lineedit->hide(); insilmaril@59: setFocus(); insilmaril@59: #endif insilmaril@59: if (!actionSettingsAutoSelectNewBranch->isOn() && insilmaril@59: !prevSelection.isEmpty()) insilmaril@59: me->select(prevSelection); insilmaril@59: prevSelection=""; insilmaril@59: } insilmaril@59: */ insilmaril@59: } insilmaril@59: insilmaril@59: #include "attribute.h" insilmaril@59: #include "attributedialog.h" insilmaril@59: void Main::editAttribute() insilmaril@59: { insilmaril@59: MapEditor *me=currentMapEditor(); insilmaril@59: if (me) insilmaril@59: { insilmaril@59: BranchObj *bo=me->getSelectedBranch(); insilmaril@59: if (bo) insilmaril@59: { insilmaril@59: AttributeDialog dia(this); insilmaril@59: dia.setTable (me->attributeTable() ); insilmaril@59: dia.setBranch (bo); insilmaril@59: dia.setMode (Definition); insilmaril@59: dia.updateTable(); insilmaril@59: dia.exec(); insilmaril@59: } insilmaril@59: } insilmaril@59: /* insilmaril@59: if (currentMapEditor()) insilmaril@59: { insilmaril@59: MapEditor *me=currentMapEditor(); insilmaril@59: QString oldSel=me->getSelectString(); insilmaril@59: insilmaril@59: if (lineedit->isVisible()) insilmaril@59: editAttributeFinished(); insilmaril@59: else insilmaril@59: { insilmaril@59: bool ok; insilmaril@59: QPoint p; insilmaril@59: QString s=me->getHeading(ok,p); insilmaril@59: insilmaril@59: if (ok) insilmaril@59: { insilmaril@59: me->setStateEditHeading (true); insilmaril@59: #if defined(Q_OS_MACX) insilmaril@59: p=me->mapToGlobal (p); insilmaril@59: QDialog *d =new QDialog(NULL); insilmaril@59: QLineEdit *le=new QLineEdit (d); insilmaril@59: d->setWindowFlags (Qt::FramelessWindowHint); insilmaril@59: d->setGeometry(p.x(),p.y(),230,25); insilmaril@59: le->resize (d->width()-10,d->height()); insilmaril@59: le->setText (s); insilmaril@59: le->selectAll(); insilmaril@59: connect (le, SIGNAL (returnPressed()), d, SLOT (accept())); insilmaril@59: d->activateWindow(); insilmaril@59: d->exec(); insilmaril@59: me->setHeading (le->text()); insilmaril@59: delete (le); insilmaril@59: delete (d); insilmaril@59: editHeadingFinished(); insilmaril@59: #else insilmaril@59: p=me->mapTo (this,p); insilmaril@59: lineedit->setGeometry(p.x(),p.y(),230,25); insilmaril@59: lineedit->setText(s); insilmaril@59: lineedit->setCursorPosition(1); insilmaril@59: lineedit->selectAll(); insilmaril@59: lineedit->show(); insilmaril@59: lineedit->grabKeyboard(); insilmaril@59: lineedit->setFocus(); insilmaril@59: #endif insilmaril@59: } insilmaril@59: } insilmaril@59: } // currentMapEditor() insilmaril@59: insilmaril@59: */ insilmaril@59: } insilmaril@59: insilmaril@59: void Main::openVymLinks(const QStringList &vl) insilmaril@59: { insilmaril@59: for (int j=0; jcount() -1;i++) insilmaril@0: { insilmaril@0: me=(MapEditor*)tabWidget->page(i); insilmaril@59: 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@59: if (!QFile(vl.at(j)).exists() ) insilmaril@0: QMessageBox::critical( 0, tr( "Critical Error" ), insilmaril@59: tr("Couldn't open map %1").arg(vl.at(j))); insilmaril@0: else insilmaril@0: { insilmaril@59: 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@59: void Main::editOpenVymLink() insilmaril@59: { insilmaril@59: if (currentMapEditor()) insilmaril@59: { insilmaril@59: QStringList vl; insilmaril@59: vl.append(currentMapEditor()->getVymLink()); insilmaril@59: openVymLinks (vl); insilmaril@59: } insilmaril@59: } insilmaril@59: insilmaril@59: void Main::editOpenMultipleVymLinks() insilmaril@59: { insilmaril@59: QString currentVymLink; insilmaril@59: if (currentMapEditor()) insilmaril@59: { insilmaril@59: QStringList vl=currentMapEditor()->getVymLinks(); insilmaril@59: openVymLinks (vl); insilmaril@59: } insilmaril@59: } insilmaril@59: 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@59: void Main::editToggleHideExport() insilmaril@59: { insilmaril@59: if (currentMapEditor()) insilmaril@59: currentMapEditor()->toggleHideExport(); insilmaril@59: } insilmaril@59: 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@59: void Main::editSortChildren() insilmaril@59: { insilmaril@59: if (currentMapEditor()) insilmaril@59: currentMapEditor()->sortChildren(); insilmaril@59: } insilmaril@59: insilmaril@0: void Main::editToggleScroll() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: { insilmaril@0: currentMapEditor()->toggleScroll(); insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@59: void Main::editUnscrollChilds() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@59: currentMapEditor()->unscrollChilds(); insilmaril@59: } insilmaril@59: insilmaril@59: void Main::editAddMapCenter() insilmaril@59: { insilmaril@59: MapEditor *me=currentMapEditor(); insilmaril@59: if (!lineedit->isVisible() && me) insilmaril@0: { insilmaril@59: me->addMapCenter (); insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editNewBranch() insilmaril@0: { insilmaril@59: MapEditor *me=currentMapEditor(); insilmaril@59: if (!lineedit->isVisible() && me) insilmaril@59: { insilmaril@59: BranchObj *bo=(BranchObj*)me->getSelection(); insilmaril@59: BranchObj *newbo=me->addNewBranch(0); insilmaril@59: insilmaril@59: prevSelection=me->getModel()->getSelectString(bo); insilmaril@59: if (newbo) insilmaril@59: me->select (newbo); insilmaril@59: else insilmaril@59: return; insilmaril@59: insilmaril@59: if (actionSettingsAutoEditNewBranch->isOn()) insilmaril@59: { insilmaril@59: editHeading(); insilmaril@59: return; insilmaril@59: } insilmaril@59: if (!prevSelection.isEmpty()) insilmaril@59: { insilmaril@59: me->select(prevSelection); insilmaril@59: prevSelection=""; insilmaril@59: } insilmaril@59: insilmaril@59: } insilmaril@59: } insilmaril@59: insilmaril@59: void Main::editNewBranchBefore() insilmaril@59: { insilmaril@59: MapEditor *me=currentMapEditor(); insilmaril@59: if (!lineedit->isVisible() && me) insilmaril@59: { insilmaril@59: BranchObj *bo=(BranchObj*)me->getSelection(); insilmaril@59: BranchObj *newbo=me->addNewBranchBefore(); insilmaril@59: insilmaril@59: if (newbo) insilmaril@59: me->select (newbo); insilmaril@59: else insilmaril@59: return; insilmaril@59: insilmaril@59: if (actionSettingsAutoEditNewBranch->isOn()) insilmaril@59: { insilmaril@59: if (!actionSettingsAutoSelectNewBranch->isOn()) insilmaril@59: prevSelection=me->getModel()->getSelectString(bo); //TODO access directly insilmaril@59: editHeading(); insilmaril@59: } insilmaril@59: } insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editNewBranchAbove() insilmaril@0: { insilmaril@59: MapEditor *me=currentMapEditor(); insilmaril@59: if (!lineedit->isVisible() && me) insilmaril@59: { insilmaril@59: BranchObj *bo=(BranchObj*)me->getSelection(); insilmaril@59: BranchObj *newbo=me->addNewBranch (-1); insilmaril@59: insilmaril@59: if (newbo) insilmaril@59: me->select (newbo); insilmaril@59: else insilmaril@59: return; insilmaril@59: insilmaril@59: if (actionSettingsAutoEditNewBranch->isOn()) insilmaril@59: { insilmaril@59: if (!actionSettingsAutoSelectNewBranch->isOn()) insilmaril@59: prevSelection=me->getModel()->getSelectString (bo); // TODO access directly insilmaril@59: editHeading(); insilmaril@59: } insilmaril@59: } insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editNewBranchBelow() insilmaril@0: { insilmaril@59: MapEditor *me=currentMapEditor(); insilmaril@59: if (!lineedit->isVisible() && me) insilmaril@59: { insilmaril@59: BranchObj *bo=(BranchObj*)me->getSelection(); insilmaril@59: BranchObj *newbo=me->addNewBranch (1); insilmaril@59: insilmaril@59: if (newbo) insilmaril@59: me->select (newbo); insilmaril@59: else insilmaril@59: return; insilmaril@59: insilmaril@59: if (actionSettingsAutoEditNewBranch->isOn()) insilmaril@59: { insilmaril@59: if (!actionSettingsAutoSelectNewBranch->isOn()) insilmaril@59: prevSelection=me->getModel()->getSelectString(bo); //TODO access directly insilmaril@59: editHeading(); insilmaril@59: } insilmaril@59: } 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@59: void Main::editDeleteKeepChilds() insilmaril@59: { insilmaril@59: if (currentMapEditor()) insilmaril@59: currentMapEditor()->deleteKeepChilds(); insilmaril@59: } insilmaril@59: insilmaril@59: void Main::editDeleteChilds() insilmaril@59: { insilmaril@59: if (currentMapEditor()) insilmaril@59: currentMapEditor()->deleteChilds(); insilmaril@59: } insilmaril@59: insilmaril@0: void Main::editDeleteSelection() insilmaril@0: { insilmaril@59: 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@59: void Main::editSaveImage() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@59: currentMapEditor()->saveFloatImage(); insilmaril@0: } insilmaril@0: insilmaril@59: void Main::editFollowXLink(QAction *a) insilmaril@59: { insilmaril@59: insilmaril@59: if (currentMapEditor()) insilmaril@59: currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a)); insilmaril@59: } insilmaril@59: insilmaril@59: void Main::editEditXLink(QAction *a) insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@59: currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a)); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::formatSelectColor() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: { insilmaril@59: 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@59: 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@59: currentColor=c; insilmaril@0: } insilmaril@0: insilmaril@0: void Main::formatColorBranch() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@59: currentMapEditor()->colorBranch(currentColor); insilmaril@59: } insilmaril@59: insilmaril@59: void Main::formatColorSubtree() insilmaril@59: { insilmaril@59: if (currentMapEditor()) insilmaril@59: currentMapEditor()->colorSubtree (currentColor); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::formatLinkStyleLine() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@59: { insilmaril@59: currentMapEditor()->setMapLinkStyle("StyleLine"); insilmaril@59: actionFormatLinkStyleLine->setOn(true); insilmaril@59: } insilmaril@0: } insilmaril@0: insilmaril@0: void Main::formatLinkStyleParabel() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@59: { insilmaril@59: currentMapEditor()->setMapLinkStyle("StyleParabel"); insilmaril@59: actionFormatLinkStyleParabel->setOn(true); insilmaril@59: } insilmaril@0: } insilmaril@0: insilmaril@0: void Main::formatLinkStylePolyLine() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@59: { insilmaril@59: currentMapEditor()->setMapLinkStyle("StylePolyLine"); insilmaril@59: actionFormatLinkStylePolyLine->setOn(true); insilmaril@59: } insilmaril@0: } insilmaril@0: insilmaril@0: void Main::formatLinkStylePolyParabel() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@59: { insilmaril@59: currentMapEditor()->setMapLinkStyle("StylePolyParabel"); insilmaril@59: actionFormatLinkStylePolyParabel->setOn(true); insilmaril@59: } insilmaril@0: } insilmaril@0: insilmaril@0: void Main::formatSelectBackColor() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@59: currentMapEditor()->selectMapBackgroundColor(); insilmaril@59: } insilmaril@59: insilmaril@59: void Main::formatSelectBackImage() insilmaril@59: { insilmaril@59: if (currentMapEditor()) insilmaril@59: currentMapEditor()->selectMapBackgroundImage(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::formatSelectLinkColor() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@59: currentMapEditor()->selectMapLinkColor(); insilmaril@59: } insilmaril@59: insilmaril@59: void Main::formatSelectSelectionColor() insilmaril@59: { insilmaril@59: if (currentMapEditor()) insilmaril@59: currentMapEditor()->selectMapSelectionColor(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::formatToggleLinkColorHint() insilmaril@0: { insilmaril@59: currentMapEditor()->toggleMapLinkColorHint(); insilmaril@0: } insilmaril@0: insilmaril@59: insilmaril@59: void Main::formatHideLinkUnselected() //FIXME get rid of this with imagepropertydialog insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@59: currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn()); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::viewZoomReset() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: { insilmaril@59: QMatrix m; insilmaril@0: m.reset(); insilmaril@59: currentMapEditor()->setMatrix( m ); insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@0: void Main::viewZoomIn() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: { insilmaril@59: QMatrix m = currentMapEditor()->matrix(); insilmaril@0: m.scale( 1.25, 1.25 ); insilmaril@59: currentMapEditor()->setMatrix( m ); insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@0: void Main::viewZoomOut() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: { insilmaril@59: QMatrix m = currentMapEditor()->matrix(); insilmaril@0: m.scale( 0.8, 0.8 ); insilmaril@59: currentMapEditor()->setMatrix( m ); insilmaril@0: } insilmaril@0: } insilmaril@59: insilmaril@59: void Main::viewCenter() insilmaril@59: { insilmaril@59: MapEditor *me=currentMapEditor(); insilmaril@59: if (me) insilmaril@59: { insilmaril@59: me->ensureSelectionVisible(); insilmaril@59: } insilmaril@59: } insilmaril@59: insilmaril@59: void Main::networkStartServer() insilmaril@59: { insilmaril@59: MapEditor *me=currentMapEditor(); insilmaril@59: if (me) me->newServer(); insilmaril@59: } insilmaril@59: insilmaril@59: void Main::networkConnect() insilmaril@59: { insilmaril@59: MapEditor *me=currentMapEditor(); insilmaril@59: if (me) me->connectToServer(); insilmaril@59: } insilmaril@59: 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@59: "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal, insilmaril@59: settings.value("/mainwindow/readerPDF").toString(), &ok, this ); insilmaril@0: if (ok) insilmaril@59: 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@59: "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal, insilmaril@59: settings.value("/mainwindow/readerURL").toString() insilmaril@0: , &ok, this ); insilmaril@0: if (ok) insilmaril@59: settings.setValue ("/mainwindow/readerURL",text); insilmaril@0: return ok; insilmaril@0: } insilmaril@0: insilmaril@59: void Main::settingsMacroDir() insilmaril@59: { insilmaril@59: QDir defdir(vymBaseDir.path() + "/macros"); insilmaril@59: if (!defdir.exists()) insilmaril@59: defdir=vymBaseDir; insilmaril@59: QDir dir=QFileDialog::getExistingDirectory ( insilmaril@59: this, insilmaril@59: tr ("Directory with vym macros:"), insilmaril@59: settings.value ("/macros/macroDir",defdir.path()).toString() insilmaril@59: ); insilmaril@59: if (dir.exists()) insilmaril@59: settings.setValue ("/macros/macroDir",dir.absolutePath()); insilmaril@59: } insilmaril@59: insilmaril@59: void Main::settingsUndoLevels() insilmaril@59: { insilmaril@59: bool ok; insilmaril@59: int i = QInputDialog::getInteger( insilmaril@59: this, insilmaril@59: tr("QInputDialog::getInteger()"), insilmaril@59: tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok); insilmaril@59: if (ok) insilmaril@59: { insilmaril@59: settings.setValue ("/mapeditor/stepsTotal",i); insilmaril@59: QMessageBox::information( this, tr( "VYM -Information:" ), insilmaril@59: tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i)); insilmaril@59: } insilmaril@59: } insilmaril@59: insilmaril@59: void Main::settingsAutosaveToggle() insilmaril@59: { insilmaril@59: settings.setValue ("/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() ); insilmaril@59: } insilmaril@59: insilmaril@59: void Main::settingsAutosaveTime() insilmaril@59: { insilmaril@59: bool ok; insilmaril@59: int i = QInputDialog::getInteger( insilmaril@59: this, insilmaril@59: tr("QInputDialog::getInteger()"), insilmaril@59: tr("Number of seconds before autosave:"), settings.value("/mainwindow/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok); insilmaril@59: if (ok) insilmaril@59: settings.setValue ("/mainwindow/autosave/ms",i * 1000); insilmaril@59: } insilmaril@59: insilmaril@59: void Main::settingsWriteBackupFileToggle() insilmaril@59: { insilmaril@59: settings.setValue ("/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() ); insilmaril@59: } insilmaril@59: insilmaril@59: void Main::settingsToggleAnimation() insilmaril@59: { insilmaril@59: settings.setValue ("/animation/use",actionSettingsUseAnimation->isOn() ); insilmaril@59: } insilmaril@59: insilmaril@59: void Main::settingsToggleDelKey() insilmaril@59: { insilmaril@59: if (actionSettingsUseDelKey->isOn()) insilmaril@59: { insilmaril@59: actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete)); insilmaril@59: } else insilmaril@59: { insilmaril@59: actionEditDelete->setAccel (QKeySequence ("")); insilmaril@59: } insilmaril@59: } insilmaril@59: insilmaril@0: void Main::windowToggleNoteEditor() insilmaril@0: { insilmaril@59: if (textEditor->isVisible() ) insilmaril@0: windowHideNoteEditor(); insilmaril@59: else insilmaril@59: windowShowNoteEditor(); insilmaril@59: } insilmaril@59: insilmaril@59: void Main::windowToggleHistory() insilmaril@59: { insilmaril@59: if (historyWindow->isVisible()) insilmaril@59: historyWindow->hide(); insilmaril@0: else insilmaril@59: historyWindow->show(); insilmaril@59: insilmaril@59: } insilmaril@59: insilmaril@59: void Main::windowToggleProperty() insilmaril@59: { insilmaril@59: if (branchPropertyWindow->isVisible()) insilmaril@59: branchPropertyWindow->hide(); insilmaril@59: else insilmaril@59: branchPropertyWindow->show(); insilmaril@59: insilmaril@59: if(currentMapEditor()) insilmaril@59: { insilmaril@59: BranchObj *bo=currentMapEditor()->getSelectedBranch(); insilmaril@59: if (bo) insilmaril@59: { insilmaril@59: branchPropertyWindow->setMapEditor(currentMapEditor()); insilmaril@59: branchPropertyWindow->setBranch(bo); insilmaril@59: return; insilmaril@59: } insilmaril@59: insilmaril@59: } insilmaril@59: branchPropertyWindow->setBranch(NULL); insilmaril@59: } insilmaril@59: insilmaril@59: void Main::windowToggleAntiAlias() insilmaril@59: { insilmaril@59: bool b=actionViewToggleAntiAlias->isOn(); insilmaril@59: MapEditor *me; insilmaril@59: for (int i=0;icount();i++) insilmaril@59: { insilmaril@59: insilmaril@59: me=(MapEditor*)tabWidget->page(i); insilmaril@59: me->setAntiAlias(b); insilmaril@59: } insilmaril@59: insilmaril@59: } insilmaril@59: insilmaril@59: void Main::windowToggleSmoothPixmap() insilmaril@59: { insilmaril@59: bool b=actionViewToggleSmoothPixmapTransform->isOn(); insilmaril@59: MapEditor *me; insilmaril@59: for (int i=0;icount();i++) insilmaril@59: { insilmaril@59: insilmaril@59: me=(MapEditor*)tabWidget->page(i); insilmaril@59: me->setSmoothPixmap(b); insilmaril@59: } insilmaril@59: } insilmaril@59: insilmaril@59: void Main::updateHistory(SimpleSettings &undoSet) insilmaril@59: { insilmaril@59: historyWindow->update (undoSet); insilmaril@59: } insilmaril@59: insilmaril@59: void Main::updateNoteFlag() insilmaril@59: { insilmaril@59: if (currentMapEditor()) insilmaril@59: currentMapEditor()->updateNoteFlag(); insilmaril@59: } insilmaril@59: insilmaril@59: void Main::updateSatellites(MapEditor *me) insilmaril@59: { insilmaril@59: branchPropertyWindow->setMapEditor (me); insilmaril@59: } insilmaril@59: insilmaril@59: void Main::updateActions() insilmaril@59: { insilmaril@59: MapEditor *me=currentMapEditor(); insilmaril@59: if (!me) return; insilmaril@59: insilmaril@59: historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(currentMapEditor()->getFileName())); insilmaril@59: insilmaril@59: // updateActions is also called when NoteEditor is closed insilmaril@59: actionViewToggleNoteEditor->setOn (textEditor->isVisible()); insilmaril@59: actionViewToggleHistoryWindow->setOn (historyWindow->isVisible()); insilmaril@59: actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible()); insilmaril@59: insilmaril@59: if (me->getMapLinkColorHint()==LinkableMapObj::HeadingColor) insilmaril@59: actionFormatLinkColorHint->setOn(true); insilmaril@59: else insilmaril@59: actionFormatLinkColorHint->setOn(false); insilmaril@59: insilmaril@59: switch (me->getMapLinkStyle()) insilmaril@59: { insilmaril@59: case LinkableMapObj::Line: insilmaril@59: actionFormatLinkStyleLine->setOn(true); insilmaril@59: break; insilmaril@59: case LinkableMapObj::Parabel: insilmaril@59: actionFormatLinkStyleParabel->setOn(true); insilmaril@59: break; insilmaril@59: case LinkableMapObj::PolyLine: insilmaril@59: actionFormatLinkStylePolyLine->setOn(true); insilmaril@59: break; insilmaril@59: case LinkableMapObj::PolyParabel: insilmaril@59: actionFormatLinkStylePolyParabel->setOn(true); insilmaril@59: break; insilmaril@59: default: insilmaril@59: break; insilmaril@59: } insilmaril@59: insilmaril@59: // Update colors insilmaril@59: QPixmap pix( 16, 16 ); insilmaril@59: pix.fill( me->getMapBackgroundColor() ); insilmaril@59: actionFormatBackColor->setIconSet( pix ); insilmaril@59: pix.fill( me->getSelectionColor() ); insilmaril@59: actionFormatSelectionColor->setIconSet( pix ); insilmaril@59: pix.fill( me->getMapDefLinkColor() ); insilmaril@59: actionFormatLinkColor->setIconSet( pix ); insilmaril@59: insilmaril@59: insilmaril@59: actionFileSave->setEnabled( me->hasChanged() ); insilmaril@59: if (me->isUndoAvailable()) insilmaril@59: actionEditUndo->setEnabled( true); insilmaril@59: else insilmaril@59: actionEditUndo->setEnabled( false); insilmaril@59: insilmaril@59: if (me->isRedoAvailable()) insilmaril@59: actionEditRedo->setEnabled( true); insilmaril@59: else insilmaril@59: actionEditRedo->setEnabled( false); insilmaril@59: insilmaril@59: LinkableMapObj *selection=me->getSelection(); insilmaril@59: if (selection) insilmaril@59: { insilmaril@59: if ( (typeid(*selection) == typeid(BranchObj)) || insilmaril@59: (typeid(*selection) == typeid(MapCenterObj)) ) insilmaril@59: { insilmaril@59: BranchObj *bo=(BranchObj*)selection; insilmaril@59: // Take care of links insilmaril@59: if (bo->countXLinks()==0) insilmaril@59: { insilmaril@59: branchXLinksContextMenuEdit->clear(); insilmaril@59: branchXLinksContextMenuFollow->clear(); insilmaril@59: } else insilmaril@59: { insilmaril@59: BranchObj *bot; insilmaril@59: QString s; insilmaril@59: branchXLinksContextMenuEdit->clear(); insilmaril@59: branchXLinksContextMenuFollow->clear(); insilmaril@59: for (int i=0; i<=bo->countXLinks();i++) insilmaril@59: { insilmaril@59: bot=bo->XLinkTargetAt(i); insilmaril@59: if (bot) insilmaril@59: { insilmaril@59: s=bot->getHeading(); insilmaril@59: if (s.length()>xLinkMenuWidth) insilmaril@59: s=s.left(xLinkMenuWidth)+"..."; insilmaril@59: branchXLinksContextMenuFollow->addAction (s); insilmaril@59: branchXLinksContextMenuEdit->addAction (s); insilmaril@59: } insilmaril@59: } insilmaril@59: } insilmaril@59: insilmaril@59: standardFlagsDefault->setEnabled (true); insilmaril@59: insilmaril@59: actionEditToggleScroll->setEnabled (true); insilmaril@59: if ( bo->isScrolled() ) insilmaril@59: actionEditToggleScroll->setOn(true); insilmaril@59: else insilmaril@59: actionEditToggleScroll->setOn(false); insilmaril@59: insilmaril@59: if ( bo->getURL().isEmpty() ) insilmaril@59: { insilmaril@59: actionEditOpenURL->setEnabled (false); insilmaril@59: actionEditOpenURLTab->setEnabled (false); insilmaril@59: } insilmaril@59: else insilmaril@59: { insilmaril@59: actionEditOpenURL->setEnabled (true); insilmaril@59: actionEditOpenURLTab->setEnabled (true); insilmaril@59: } insilmaril@59: if ( bo->getVymLink().isEmpty() ) insilmaril@59: { insilmaril@59: actionEditOpenVymLink->setEnabled (false); insilmaril@59: actionEditDeleteVymLink->setEnabled (false); insilmaril@59: } else insilmaril@59: { insilmaril@59: actionEditOpenVymLink->setEnabled (true); insilmaril@59: actionEditDeleteVymLink->setEnabled (true); insilmaril@59: } insilmaril@59: insilmaril@59: if (bo->canMoveBranchUp()) insilmaril@59: actionEditMoveUp->setEnabled (true); insilmaril@59: else insilmaril@59: actionEditMoveUp->setEnabled (false); insilmaril@59: if (bo->canMoveBranchDown()) insilmaril@59: actionEditMoveDown->setEnabled (true); insilmaril@59: else insilmaril@59: actionEditMoveDown->setEnabled (false); insilmaril@59: insilmaril@59: insilmaril@59: actionEditToggleHideExport->setEnabled (true); insilmaril@59: actionEditToggleHideExport->setOn (bo->hideInExport() ); insilmaril@59: insilmaril@59: actionEditCopy->setEnabled (true); insilmaril@59: actionEditCut->setEnabled (true); insilmaril@59: if (!clipboardEmpty) insilmaril@59: actionEditPaste->setEnabled (true); insilmaril@59: else insilmaril@59: actionEditPaste->setEnabled (false); insilmaril@59: for (int i=0; isetEnabled(true); insilmaril@59: actionEditDelete->setEnabled (true); insilmaril@59: actionFormatHideLinkUnselected->setOn insilmaril@59: (selection->getHideLinkUnselected()); insilmaril@59: } insilmaril@59: if ( (typeid(*selection) == typeid(FloatImageObj)) ) insilmaril@59: { insilmaril@59: FloatObj *fo=(FloatImageObj*)selection; insilmaril@59: insilmaril@59: actionEditOpenURL->setEnabled (false); insilmaril@59: actionEditOpenVymLink->setEnabled (false); insilmaril@59: actionEditDeleteVymLink->setEnabled (false); insilmaril@59: actionEditToggleHideExport->setEnabled (true); insilmaril@59: actionEditToggleHideExport->setOn (fo->hideInExport() ); insilmaril@59: insilmaril@59: insilmaril@59: actionEditCopy->setEnabled (true); insilmaril@59: actionEditCut->setEnabled (true); insilmaril@59: actionEditPaste->setEnabled (false); insilmaril@59: for (int i=0; isetEnabled(false); insilmaril@59: actionEditDelete->setEnabled (true); insilmaril@59: actionFormatHideLinkUnselected->setOn insilmaril@59: ( selection->getHideLinkUnselected()); insilmaril@59: actionEditMoveUp->setEnabled (false); insilmaril@59: actionEditMoveDown->setEnabled (false); insilmaril@59: } insilmaril@59: insilmaril@59: } else insilmaril@59: { insilmaril@59: actionEditCopy->setEnabled (false); insilmaril@59: actionEditCut->setEnabled (false); insilmaril@59: actionEditPaste->setEnabled (false); insilmaril@59: for (int i=0; isetEnabled(false); insilmaril@59: insilmaril@59: actionEditToggleScroll->setEnabled (false); insilmaril@59: actionEditOpenURL->setEnabled (false); insilmaril@59: actionEditOpenVymLink->setEnabled (false); insilmaril@59: actionEditDeleteVymLink->setEnabled (false); insilmaril@59: actionEditHeading2URL->setEnabled (false); insilmaril@59: actionEditDelete->setEnabled (false); insilmaril@59: actionEditMoveUp->setEnabled (false); insilmaril@59: actionEditMoveDown->setEnabled (false); insilmaril@59: actionEditToggleHideExport->setEnabled (false); insilmaril@59: } insilmaril@59: } insilmaril@59: insilmaril@59: Main::ModMode Main::getModMode() insilmaril@59: { insilmaril@59: if (actionModModeColor->isOn()) return ModModeColor; insilmaril@59: if (actionModModeCopy->isOn()) return ModModeCopy; insilmaril@59: if (actionModModeXLink->isOn()) return ModModeXLink; insilmaril@59: return ModModeNone; insilmaril@59: } insilmaril@59: insilmaril@59: bool Main::autoEditNewBranch() insilmaril@59: { insilmaril@59: return actionSettingsAutoEditNewBranch->isOn(); insilmaril@59: } insilmaril@59: insilmaril@59: bool Main::autoSelectNewBranch() insilmaril@59: { insilmaril@59: return actionSettingsAutoSelectNewBranch->isOn(); insilmaril@59: } insilmaril@59: insilmaril@59: bool Main::useFlagGroups() insilmaril@59: { insilmaril@59: return actionSettingsUseFlagGroups->isOn(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::windowShowNoteEditor() insilmaril@0: { insilmaril@0: textEditor->setShowWithMain(true); insilmaril@0: textEditor->show(); insilmaril@0: actionViewToggleNoteEditor->setOn (true); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::windowHideNoteEditor() insilmaril@0: { insilmaril@0: textEditor->setShowWithMain(false); insilmaril@0: textEditor->hide(); insilmaril@0: actionViewToggleNoteEditor->setOn (false); insilmaril@0: } insilmaril@0: insilmaril@59: void Main::setScript (const QString &script) insilmaril@59: { insilmaril@59: scriptEditor->setScript (script); insilmaril@59: } insilmaril@59: insilmaril@59: void Main::runScript (const QString &script) insilmaril@59: { insilmaril@59: if (currentMapEditor()) insilmaril@59: currentMapEditor()->runScript (script); insilmaril@59: } insilmaril@59: insilmaril@59: void Main::runScriptEverywhere (const QString &script) insilmaril@59: { insilmaril@59: MapEditor *me; insilmaril@59: for (int i=0;i<=tabWidget->count() -1;i++) insilmaril@59: { insilmaril@59: me=(MapEditor*)tabWidget->page(i); insilmaril@59: if (me) me->runScript (script); insilmaril@59: } insilmaril@59: } insilmaril@59: 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@59: if (currentMapEditor()) insilmaril@59: currentMapEditor()->toggleStandardFlag(sender()->name()); insilmaril@0: } insilmaril@0: insilmaril@59: void Main::testFunction1() insilmaril@0: { insilmaril@59: if (!currentMapEditor()) return; insilmaril@59: currentMapEditor()->testFunction1(); insilmaril@59: //editAttribute(); insilmaril@0: } insilmaril@0: insilmaril@59: void Main::testFunction2() insilmaril@0: { insilmaril@59: if (!currentMapEditor()) return; insilmaril@59: currentMapEditor()->testFunction2(); insilmaril@59: } insilmaril@59: insilmaril@59: void Main::testCommand() insilmaril@59: { insilmaril@59: if (!currentMapEditor()) return; insilmaril@59: scriptEditor->show(); insilmaril@59: /* insilmaril@59: bool ok; insilmaril@59: QString com = QInputDialog::getText( insilmaril@59: vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this ); insilmaril@59: if (ok) currentMapEditor()->parseAtom(com); insilmaril@59: */ insilmaril@0: } insilmaril@0: insilmaril@0: void Main::helpDoc() insilmaril@0: { insilmaril@59: QString locale = QLocale::system().name(); insilmaril@59: QString docname; insilmaril@59: if (locale.left(2)=="es") insilmaril@59: docname="vym_es.pdf"; insilmaril@59: else insilmaril@59: docname="vym.pdf"; insilmaril@59: insilmaril@59: QStringList searchList; insilmaril@59: QDir docdir; insilmaril@59: #if defined(Q_OS_MACX) insilmaril@59: searchList << "./vym.app/Contents/Resources/doc"; insilmaril@59: #elif defined(Q_OS_WIN32) insilmaril@59: searchList << vymInstallDir.path() + "/share/doc/packages/vym"; insilmaril@59: #else insilmaril@59: #if defined(VYM_DOCDIR) insilmaril@59: searchList << VYM_DOCDIR; insilmaril@59: #endif insilmaril@59: // default path in SUSE LINUX insilmaril@59: searchList << "/usr/share/doc/packages/vym"; insilmaril@59: #endif insilmaril@59: insilmaril@59: searchList << "doc"; // relative path for easy testing in tarball insilmaril@59: searchList << "doc/tex"; // Easy testing working on vym.tex insilmaril@59: searchList << "/usr/share/doc/vym"; // Debian insilmaril@59: searchList << "/usr/share/doc/packages";// Knoppix insilmaril@59: insilmaril@59: bool found=false; insilmaril@59: QFile docfile; insilmaril@59: for (int i=0; istart( settings.value("/mainwindow/readerPDF").toString(),args); insilmaril@59: if ( !pdfProc->waitForStarted() ) insilmaril@0: { insilmaril@0: // error handling insilmaril@59: QMessageBox::warning(0, insilmaril@59: tr("Warning"), insilmaril@59: tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+ insilmaril@59: tr("Please use Settings->")+tr("Set application to open PDF files")); insilmaril@59: settingsPDF(); insilmaril@0: return; insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@0: insilmaril@59: void Main::helpDemo() insilmaril@59: { insilmaril@59: QStringList filters; insilmaril@59: filters <<"VYM example map (*.vym)"; insilmaril@59: QFileDialog *fd=new QFileDialog( this); insilmaril@59: #if defined(Q_OS_MACX) insilmaril@59: fd->setDir (QDir("./vym.app/Contents/Resources/demos")); insilmaril@59: #else insilmaril@59: // default path in SUSE LINUX insilmaril@59: fd->setDir (QDir(vymBaseDir.path()+"/demos")); insilmaril@59: #endif insilmaril@59: insilmaril@59: fd->setFileMode (QFileDialog::ExistingFiles); insilmaril@59: fd->setFilters (filters); insilmaril@59: fd->setCaption(vymName+ " - " +tr("Load vym example map")); insilmaril@59: fd->show(); insilmaril@59: insilmaril@59: QString fn; insilmaril@59: if ( fd->exec() == QDialog::Accepted ) insilmaril@59: { insilmaril@59: lastFileDir=fd->directory().path(); insilmaril@59: QStringList flist = fd->selectedFiles(); insilmaril@59: QStringList::Iterator it = flist.begin(); insilmaril@59: while( it != flist.end() ) insilmaril@59: { insilmaril@59: fn = *it; insilmaril@59: fileLoad(*it, NewMap); insilmaril@59: ++it; insilmaril@59: } insilmaril@59: } insilmaril@59: delete (fd); insilmaril@59: } insilmaril@59: insilmaril@59: insilmaril@0: void Main::helpAbout() insilmaril@0: { insilmaril@59: AboutDialog ad; insilmaril@59: ad.setName ("aboutwindow"); insilmaril@59: ad.setMinimumSize(500,500); insilmaril@59: ad.resize (QSize (500,500)); insilmaril@59: 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@59: void Main::callMacro () insilmaril@59: { insilmaril@59: QAction *action = qobject_cast(sender()); insilmaril@59: int i=-1; insilmaril@59: if (action) insilmaril@59: { insilmaril@59: i=action->data().toInt(); insilmaril@59: QString mDir (settings.value ("macros/macroDir").toString() ); insilmaril@59: insilmaril@59: QString fn=mDir + QString("/macro-%1.vys").arg(i+1); insilmaril@59: QFile f (fn); insilmaril@59: if ( !f.open( QIODevice::ReadOnly ) ) insilmaril@59: { insilmaril@59: QMessageBox::warning(0, insilmaril@59: tr("Warning"), insilmaril@59: tr("Couldn't find a macro at %1.\n").arg(fn)+ insilmaril@59: tr("Please use Settings->")+tr("Set directory for vym macros")); insilmaril@59: return; insilmaril@59: } insilmaril@59: insilmaril@59: QTextStream ts( &f ); insilmaril@59: QString m= ts.read(); insilmaril@59: insilmaril@59: if (! m.isEmpty()) insilmaril@59: { insilmaril@59: //cout <<"Main::callMacro m="<runScript (m); insilmaril@59: } insilmaril@59: } insilmaril@59: } insilmaril@59: insilmaril@59: insilmaril@59: insilmaril@59: ////////////////////////////////// insilmaril@59: /* insilmaril@59: @@ -2544,18 +2576,27 @@ insilmaril@59: // Try to open new tab in existing konqueror started previously by vym insilmaril@59: p=new QProcess (this); insilmaril@59: args.clear(); insilmaril@59: - args<< QString("konqueror-%1").arg(procBrowser->pid())<< insilmaril@59: - "konqueror-mainwindow#1"<< insilmaril@59: - "newTab" << insilmaril@59: +#if defined(Q_OS_WIN32) insilmaril@59: + // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure. insilmaril@59: + // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic. insilmaril@59: + args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<< insilmaril@59: + "konqueror-mainwindow#1"<< insilmaril@59: + "newTab" << insilmaril@59: urls.at(i); insilmaril@59: +#else insilmaril@59: + args<< QString("konqueror-%1").arg(procBrowser->pid())<< insilmaril@59: + "konqueror-mainwindow#1"<< insilmaril@59: + "newTab" << insilmaril@59: + urls.at(i); insilmaril@59: +#endif insilmaril@59: p->start ("dcop",args); insilmaril@59: if ( !p->waitForStarted() ) success=false; insilmaril@59: } insilmaril@59: */