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