1 #include "mainwindow.h"
8 #include "aboutdialog.h"
9 #include "branchpropwindow.h"
10 #include "branchitem.h"
11 #include "exportoofiledialog.h"
14 #include "findresultwidget.h"
15 #include "findwidget.h"
17 #include "historywindow.h"
19 #include "mapeditor.h"
24 #include "shortcuts.h"
25 #include "texteditor.h"
26 #include "treeeditor.h"
27 #include "warningdialog.h"
28 #include "xlinkitem.h"
30 //#include <modeltest.h> // FIXME-3
32 #if defined(Q_OS_WIN32)
33 // Define only this structure as opposed to
34 // including full 'windows.h'. FindWindow
35 // clashes with the one in Win32 API.
36 typedef struct _PROCESS_INFORMATION
42 } PROCESS_INFORMATION, *LPPROCESS_INFORMATION;
45 extern TextEditor *textEditor;
46 extern Main *mainWindow;
47 extern FindWidget *findWidget;
48 extern FindResultWidget *findResultWidget;
49 extern QString tmpVymDir;
50 extern QString clipboardDir;
51 extern QString clipboardFile;
52 extern bool clipboardEmpty;
53 extern int statusbarTime;
54 extern FlagRow *standardFlagsMaster;
55 extern FlagRow *systemFlagsMaster;
56 extern QString vymName;
57 extern QString vymVersion;
58 extern QString vymBuildDate;
61 QMenu* branchContextMenu;
62 QMenu* branchAddContextMenu;
63 QMenu* branchRemoveContextMenu;
64 QMenu* branchLinksContextMenu;
65 QMenu* branchXLinksContextMenuEdit;
66 QMenu* floatimageContextMenu;
67 QMenu* canvasContextMenu;
68 QMenu* fileLastMapsMenu;
69 QMenu* fileImportMenu;
70 QMenu* fileExportMenu;
73 extern Settings settings;
74 extern Options options;
75 extern ImageIO imageIO;
77 extern QDir vymBaseDir;
78 extern QDir lastImageDir;
79 extern QDir lastFileDir;
80 #if defined(Q_OS_WIN32)
81 extern QDir vymInstallDir;
83 extern QString iconPath;
84 extern QString flagsPath;
87 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
88 QMainWindow(parent,name,f)
92 setCaption ("VYM - View Your Mind");
94 // Load window settings
95 #if defined(Q_OS_WIN32)
96 if (settings.value("/mainwindow/geometry/maximized", false).toBool())
98 setWindowState(Qt::WindowMaximized);
103 resize (settings.value("/mainwindow/geometry/size", QSize (800,600)).toSize());
104 move (settings.value("/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
107 // Sometimes we may need to remember old selections
111 currentColor=Qt::black;
113 // Create unique temporary directory
115 tmpVymDir=makeTmpDir (ok,"vym");
118 qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
121 if (debug) qDebug (QString("vym tmpDir=%1").arg(tmpVymDir) );
123 // Create direcctory for clipboard
124 clipboardDir=tmpVymDir+"/clipboard";
125 clipboardFile="map.xml";
126 QDir d(clipboardDir);
127 d.mkdir (clipboardDir,true);
128 makeSubDirs (clipboardDir);
131 // Remember PID of our friendly webbrowser
132 browserPID=new qint64;
136 findResultWidget=new FindResultWidget ();
137 QDockWidget *dw= new QDockWidget (tr ("Search results","FindResultWidget"),this);
138 dw->setWidget (findResultWidget);
139 dw->setObjectName ("FindResultWidget");
141 addDockWidget (Qt::RightDockWidgetArea,dw);
142 connect (findResultWidget, SIGNAL (noteSelected (QString, int)),this, SLOT (selectInNoteEditor (QString, int)));
145 // Satellite windows //////////////////////////////////////////
147 historyWindow=new HistoryWindow();
148 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
151 branchPropertyWindow = new BranchPropertyWindow();
152 connect (branchPropertyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
154 // Connect TextEditor, so that we can update flags if text changes
155 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
156 connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
158 // Initialize script editor
159 scriptEditor = new SimpleScriptEditor();
160 scriptEditor->move (50,50);
162 connect( scriptEditor, SIGNAL( runScript ( QString ) ),
163 this, SLOT( runScript( QString ) ) );
165 // Initialize some settings, which are platform dependant
168 // application to open URLs
169 p="/mainwindow/readerURL";
170 #if defined(Q_OS_LINUX)
171 s=settings.value (p,"xdg-open").toString();
173 #if defined(Q_OS_MACX)
174 s=settings.value (p,"/usr/bin/open").toString();
177 #if defined(Q_OS_WIN32)
178 // Assume that system has been set up so that
179 // Explorer automagically opens up the URL
180 // in the user's preferred browser.
181 s=settings.value (p,"explorer").toString();
183 s=settings.value (p,"mozilla").toString();
187 settings.setValue( p,s);
189 // application to open PDFs
190 p="/mainwindow/readerPDF";
191 #if defined(Q_OS_LINUX)
192 s=settings.value (p,"xdg-open").toString();
194 #if defined(Q_OS_MACX)
195 s=settings.value (p,"/usr/bin/open").toString();
196 #elif defined(Q_OS_WIN32)
197 s=settings.value (p,"acrord32").toString();
199 s=settings.value (p,"acroread").toString();
202 settings.setValue( p,s);
204 // width of xLinksMenu
208 QWidget* centralWidget = new QWidget (this);
209 QVBoxLayout *layout=new QVBoxLayout (centralWidget);
210 setCentralWidget(centralWidget);
212 // Create tab widget which holds the maps
213 tabWidget= new QTabWidget (centralWidget);
214 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
215 this, SLOT( editorChanged( QWidget * ) ) );
218 findWidget = new FindWidget (centralWidget);
220 layout->addWidget (tabWidget);
221 layout->addWidget (findWidget);
224 findWidget, SIGNAL (nextButton (QString) ),
225 this, SLOT (editFindNext(QString) ) );
227 findWidget , SIGNAL (hideFindWidget() ),
228 this, SLOT (editHideFindWidget() ) );
232 setupFormatActions();
236 setupNetworkActions();
237 setupSettingsActions();
240 if (options.isOn("shortcuts")) switchboard.print();
241 if (options.isOn("shortcutsLaTeX")) switchboard.printLaTeX();
243 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
246 // Status bar and progress bar there
250 progressCounterTotal=0;
252 progressDialog.setLabelText (tr("Loading maps","Mainwindow"));
253 progressDialog.setAutoReset(false);
254 progressDialog.setAutoClose(false);
255 //progressDialog.setWindowModality (Qt::WindowModal); // That forces mainwindo to update and slows down
256 //progressDialog.setCancelButton (NULL);
258 restoreState (settings.value("/mainwindow/state",0).toByteArray());
266 #if defined(Q_OS_WIN32)
267 settings.setValue ("/mainwindow/geometry/maximized", isMaximized());
269 settings.setValue ("/mainwindow/geometry/size", size());
270 settings.setValue ("/mainwindow/geometry/pos", pos());
271 settings.setValue ("/mainwindow/state",saveState(0));
273 settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
274 settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
275 settings.setValue( "/version/version", vymVersion );
276 settings.setValue( "/version/builddate", vymBuildDate );
278 settings.setValue( "/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
279 settings.setValue ("/mainwindow/autoLayout/use",actionSettingsAutoLayoutToggle->isOn() );
280 settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isOn() );
281 settings.setValue( "/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
282 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
283 settings.setValue( "/mapeditor/editmode/autoEditNewBranch",actionSettingsAutoEditNewBranch->isOn() );
284 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
285 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
286 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
288 //TODO save scriptEditor settings
290 // call the destructors
292 delete historyWindow;
293 delete branchPropertyWindow;
295 // Remove temporary directory
296 removeDir (QDir(tmpVymDir));
299 void Main::loadCmdLine()
301 /* TODO draw some kind of splashscreen while loading...
307 QStringList flist=options.getFileList();
308 QStringList::Iterator it=flist.begin();
310 progressCounter=flist.count();
311 progressCounterTotal=flist.count();
312 while (it !=flist.end() )
314 fileLoad (*it, NewMap);
320 void Main::statusMessage(const QString &s)
322 // Surpress messages while progressdialog during
325 statusBar()->message( s);
328 void Main::setProgressMaximum (int max)
330 if (progressCounterTotal!=0)
332 progressDialog.setRange (0,progressCounterTotal*1000);
334 progressDialog.setRange (0,max+10);
336 progressDialog.setValue (0);
337 progressMax=max*1000;
338 //cout << "Main max="<<max<<" v="<<progressDialog.value()<<endl;
339 progressDialog.show();
342 void Main::addProgressValue (float v)
344 //cout << "addVal v="<<v*1000<<"/"<<progressMax<<" cur="<<progressDialog.value()<<" counter="<<v+progressCounter<<"/"<<progressCounterTotal<<endl;
345 if (progressCounterTotal!=0)
346 progressDialog.setValue ( (v+progressCounterTotal-progressCounter)*1000 );
348 progressDialog.setValue (v+progressDialog.value());
351 void Main::removeProgressCounter()
355 if (progressCounter<=0)
358 progressCounterTotal=0;
359 progressDialog.reset();
360 progressDialog.hide();
364 void Main::closeEvent (QCloseEvent* )
370 void Main::setupFileActions()
372 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
373 QToolBar *tb = addToolBar( tr ("&Map") );
374 tb->setObjectName ("mapTB");
377 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this);
378 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
379 a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map
380 switchboard.addConnection(a,tr("File","Shortcut group"));
382 fileMenu->addAction (a);
383 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
385 a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this);
386 a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) );
387 a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N ); //New map
388 switchboard.addConnection(a,tr("File","Shortcut group"));
389 fileMenu->addAction (a);
390 connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) );
393 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
394 a->setStatusTip (tr( "Open","Status tip File menu" ) );
395 a->setShortcut ( Qt::CTRL + Qt::Key_O ); //Open map
396 switchboard.addConnection(a,tr("File","Shortcut group"));
398 fileMenu->addAction (a);
399 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
401 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
402 fileMenu->addSeparator();
404 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
405 a->setStatusTip ( tr( "Save","Status tip file menu" ));
406 a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map
407 switchboard.addConnection(a,tr("File","Shortcut group"));
409 fileMenu->addAction (a);
410 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
413 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
414 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
415 switchboard.addConnection(a,tr("File","Shortcut group"));
416 fileMenu->addAction (a);
417 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
419 fileMenu->addSeparator();
421 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
423 a = new QAction(tr("KDE 3 Bookmarks"), this);
424 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 3 bookmarks")));
425 switchboard.addConnection(a,tr("File","Shortcut group"));
426 a->addTo (fileImportMenu);
427 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE3Bookmarks() ) );
429 a = new QAction(tr("KDE 4 Bookmarks"), this);
430 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 4 bookmarks")));
431 a->addTo (fileImportMenu);
432 switchboard.addConnection(a,tr("File","Shortcut group"));
433 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE4Bookmarks() ) );
435 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
437 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
438 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
439 a->addTo (fileImportMenu);
440 switchboard.addConnection(a,tr("File","Shortcut group"));
441 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
444 a = new QAction("Freemind...",this);
445 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Freemind") );
446 switchboard.addConnection(a,tr("File","Shortcut group"));
447 fileImportMenu->addAction (a);
448 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFreemind() ) );
450 a = new QAction("Mind Manager...",this);
451 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
452 switchboard.addConnection(a,tr("File","Shortcut group"));
453 fileImportMenu->addAction (a);
454 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
456 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
457 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
458 switchboard.addConnection(a,tr("File","Shortcut group"));
459 fileImportMenu->addAction (a);
460 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
462 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
464 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
465 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
466 switchboard.addConnection(a,tr("File","Shortcut group"));
467 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
468 fileExportMenu->addAction (a);
470 a = new QAction( "Open Office...", this);
471 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
472 switchboard.addConnection(a,tr("File","Shortcut group"));
473 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
474 fileExportMenu->addAction (a);
476 a = new QAction( "Webpage (HTML)...",this );
477 a->setShortcut (Qt::ALT + Qt::Key_X); //Export HTML
478 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (HTML)","status tip file menu")));
479 switchboard.addConnection(a,tr("File","Shortcut group"));
480 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportHTML() ) );
481 fileExportMenu->addAction (a);
483 a = new QAction( "Text (A&O report)...", this);
484 a->setStatusTip ( tr( "Export as %1").arg("A&O report "+tr("(still experimental)" )));
485 switchboard.addConnection(a,tr("File","Shortcut group"));
486 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportAO() ) );
487 fileExportMenu->addAction (a);
489 a = new QAction( "Text (ASCII)...", this);
490 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
491 switchboard.addConnection(a,tr("File","Shortcut group"));
492 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
493 fileExportMenu->addAction (a);
495 a = new QAction( "Spreadsheet (CSV)...", this);
496 a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
497 switchboard.addConnection(a,tr("File","Shortcut group"));
498 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
499 fileExportMenu->addAction (a);
501 a = new QAction( tr("KDE 3 Bookmarks","File menu"), this);
502 a->setStatusTip( tr( "Export as %1").arg(tr("KDE 3 Bookmarks" )));
503 switchboard.addConnection(a,tr("File","Shortcut group"));
504 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE3Bookmarks() ) );
505 fileExportMenu->addAction (a);
507 a = new QAction( tr("KDE 4 Bookmarks","File menu"), this);
508 a->setStatusTip( tr( "Export as %1").arg(tr("KDE 4 Bookmarks" )));
509 switchboard.addConnection(a,tr("File","Shortcut group"));
510 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE4Bookmarks() ) );
511 fileExportMenu->addAction (a);
513 a = new QAction( "Taskjuggler...", this );
514 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
515 switchboard.addConnection(a,tr("File","Shortcut group"));
516 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
517 fileExportMenu->addAction (a);
519 a = new QAction( "LaTeX...", this);
520 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
521 switchboard.addConnection(a,tr("File","Shortcut group"));
522 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
523 fileExportMenu->addAction (a);
525 a = new QAction( "XML..." , this );
526 a->setStatusTip (tr( "Export as %1").arg("XML"));
527 switchboard.addConnection(a,tr("File","Shortcut group"));
528 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
529 fileExportMenu->addAction (a);
531 fileMenu->addSeparator();
533 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
534 a->setStatusTip ( tr( "Print" ,"File menu") );
535 a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map
537 switchboard.addConnection(a,tr("File","Shortcut group"));
538 fileMenu->addAction (a);
539 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
542 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
543 a->setStatusTip (tr( "Close Map" ) );
544 a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map
545 switchboard.addConnection(a,tr("File","Shortcut group"));
546 fileMenu->addAction (a);
547 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
549 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
550 a->setStatusTip ( tr( "Exit")+" "+vymName );
551 a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym
552 switchboard.addConnection(a,tr("File","Shortcut group"));
553 fileMenu->addAction (a);
554 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
559 void Main::setupEditActions()
561 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
562 tb->setLabel( "Edit Actions" );
563 tb->setObjectName ("actionsTB");
564 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
567 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
568 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
569 a->setStatusTip (tr( "Undo" ) );
570 a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action
571 a->setEnabled (false);
572 switchboard.addConnection(a,tr("Edit","Shortcut group"));
574 editMenu->addAction (a);
577 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
578 a->setStatusTip (tr( "Redo" ));
579 a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action
580 switchboard.addConnection(a,tr("Edit","Shortcut group"));
582 editMenu->addAction (a);
583 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
586 editMenu->addSeparator();
587 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
588 a->setStatusTip ( tr( "Copy" ) );
589 a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy
590 a->setEnabled (false);
591 switchboard.addConnection(a,tr("Edit","Shortcut group"));
593 editMenu->addAction (a);
594 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
597 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
598 a->setStatusTip ( tr( "Cut" ) );
599 a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut
600 a->setEnabled (false);
602 switchboard.addConnection(a,tr("Edit","Shortcut group"));
603 editMenu->addAction (a);
605 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
607 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
608 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
609 a->setStatusTip ( tr( "Paste" ) );
610 a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste
611 a->setEnabled (false);
613 switchboard.addConnection(a,tr("Edit","Shortcut group"));
614 editMenu->addAction (a);
617 // Shortcut to delete selection
618 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
619 a->setStatusTip (tr( "Delete Selection" ));
620 a->setShortcut ( Qt::Key_Delete); //Delete selection
621 a->setShortcutContext (Qt::WindowShortcut);
622 switchboard.addConnection(a,tr("Edit","Shortcut group"));
624 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
627 // Shortcut to add attribute
628 a= new QAction(tr( "Add attribute" ), this);
629 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
631 a->setShortcut ( Qt::Key_Q);
632 a->setShortcutContext (Qt::WindowShortcut);
633 switchboard.addConnection(a,tr("Edit","Shortcut group"));
636 connect( a, SIGNAL( triggered() ), this, SLOT( editAddAttribute() ) );
637 actionAddAttribute= a;
640 // Shortcut to add mapcenter
641 a= new QAction(QPixmap(iconPath+"newmapcenter.png"),tr( "Add mapcenter","Canvas context menu" ), this);
642 a->setShortcut ( Qt::Key_M);
643 a->setShortcutContext (Qt::WindowShortcut);
644 switchboard.addConnection(a,tr("Edit","Shortcut group"));
645 connect( a, SIGNAL( triggered() ), this, SLOT( editAddMapCenter() ) );
646 //actionListBranches.append(a);
648 actionAddMapCenter = a;
651 // Shortcut to add branch
652 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
653 a->setStatusTip ( tr( "Add a branch as child of selection" ));
654 a->setShortcut (Qt::Key_A); //Add branch
655 a->setShortcutContext (Qt::WindowShortcut);
656 switchboard.addConnection(a,tr("Edit","Shortcut group"));
658 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
659 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
660 a->setStatusTip ( tr( "Add a branch as child of selection" ));
661 a->setShortcut (Qt::Key_Insert); //Add branch
662 switchboard.addConnection(a,tr("Edit","Shortcut group"));
663 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
664 actionListBranches.append(a);
666 editMenu->addAction (actionAddBranch);
667 tb->addAction (actionAddBranch);
670 // Add branch by inserting it at selection
671 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
672 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
673 a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch
674 a->setShortcutContext (Qt::WindowShortcut);
675 switchboard.addConnection(a,tr("Edit","Shortcut group"));
677 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
678 actionListBranches.append(a);
679 actionAddBranchBefore=a;
682 a = new QAction(tr( "Add branch above","Edit menu" ), this);
683 a->setStatusTip ( tr( "Add a branch above selection" ));
684 a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
685 a->setShortcutContext (Qt::WindowShortcut);
686 switchboard.addConnection(a,tr("Edit","Shortcut group"));
688 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
689 a->setEnabled (false);
690 actionListBranches.append(a);
691 actionAddBranchAbove=a;
692 a = new QAction(tr( "Add branch above","Edit menu" ), this);
693 a->setStatusTip ( tr( "Add a branch above selection" ));
694 a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above
695 a->setShortcutContext (Qt::WindowShortcut);
696 switchboard.addConnection(a,tr("Edit","Shortcut group"));
698 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
699 actionListBranches.append(a);
702 a = new QAction(tr( "Add branch below","Edit menu" ), this);
703 a->setStatusTip ( tr( "Add a branch below selection" ));
704 a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
705 a->setShortcutContext (Qt::WindowShortcut);
706 switchboard.addConnection(a,tr("Edit","Shortcut group"));
708 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
709 a->setEnabled (false);
710 actionListBranches.append(a);
711 actionAddBranchBelow=a;
712 a = new QAction(tr( "Add branch below","Edit menu" ), this);
713 a->setStatusTip ( tr( "Add a branch below selection" ));
714 a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below
715 a->setShortcutContext (Qt::WindowShortcut);
716 switchboard.addConnection(a,tr("Edit","Shortcut group"));
718 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
719 actionListBranches.append(a);
721 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
722 a->setStatusTip ( tr( "Move branch up" ) );
723 a->setShortcut (Qt::Key_PageUp ); // Move branch up //FIXME-2 If already on top, GraphicsView scrolls up, probably because this action is disabled?!
724 a->setEnabled (false);
725 switchboard.addConnection(a,tr("Edit","Shortcut group"));
727 editMenu->addAction (a);
728 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
731 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
732 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
733 a->setStatusTip (tr( "Move branch down" ) );
734 a->setShortcut ( Qt::Key_PageDown ); // Move branch down
735 a->setEnabled (false);
736 switchboard.addConnection(a,tr("Edit","Shortcut group"));
738 editMenu->addAction (a);
741 a = new QAction(QPixmap(), tr( "&Detach","Context menu" ),this);
742 a->setStatusTip ( tr( "Detach branch and use as mapcenter","Context menu" ) );
743 a->setShortcut ( Qt::Key_D ); // Detach branch
744 switchboard.addConnection(a,tr("Edit","Shortcut group"));
745 editMenu->addAction (a);
746 connect( a, SIGNAL( triggered() ), this, SLOT( editDetach() ) );
749 a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this );
750 connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) );
751 a->setEnabled (true);
753 switchboard.addConnection(a,tr("Edit","Shortcut group"));
754 editMenu->addAction (a);
755 actionSortChildren=a;
757 a = new QAction( QPixmap(iconPath+"editsortback.png" ), tr( "Sort children backwards","Edit menu" ), this );
758 connect( a, SIGNAL( activated() ), this, SLOT( editSortBackChildren() ) );
759 a->setEnabled (true);
761 switchboard.addConnection(a,tr("Edit","Shortcut group"));
762 editMenu->addAction (a);
763 actionSortBackChildren=a;
765 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
766 a->setShortcut ( Qt::Key_S ); // Scroll branch
767 a->setStatusTip (tr( "Scroll branch" ));
768 switchboard.addConnection(a,tr("Edit","Shortcut group"));
769 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
770 a->setEnabled (false);
771 a->setToggleAction(true);
772 actionToggleScroll=a;
773 tb->addAction (actionToggleScroll);
774 editMenu->addAction ( actionToggleScroll);
775 editMenu->addAction (actionToggleScroll);
777 actionListBranches.append(actionToggleScroll);
779 a = new QAction( QPixmap(), tr( "Expand all branches","Edit menu" ), this);
780 a->setShortcut ( Qt::SHIFT + Qt::Key_X ); // Expand all branches
781 a->setStatusTip (tr( "Expand all branches" ));
782 switchboard.addConnection(a,tr("Edit","Shortcut group"));
783 connect( a, SIGNAL( triggered() ), this, SLOT( editExpandAll() ) );
785 actionExpandAll->setEnabled (false);
786 actionExpandAll->setToggleAction(false);
787 //tb->addAction (actionExpandAll);
788 editMenu->addAction ( actionExpandAll);
790 actionListBranches.append(actionExpandAll);
792 a = new QAction( QPixmap(), tr( "Expand one level","Edit menu" ), this);
793 a->setShortcut ( Qt::Key_Greater ); // Expand one level in tree editor
794 switchboard.addConnection(a,tr("Edit","Shortcut group"));
795 a->setStatusTip (tr( "Expand one level in tree editor" ));
796 connect( a, SIGNAL( triggered() ), this, SLOT( editExpandOneLevel() ) );
797 a->setEnabled (false);
798 a->setToggleAction(false);
799 actionExpandOneLevel=a;
801 editMenu->addAction ( a);
803 actionListBranches.append(a);
805 a = new QAction( QPixmap(), tr( "Collapse one level","Edit menu" ), this);
806 a->setShortcut ( Qt::Key_Less); // Collapse one level in tree editor
807 switchboard.addConnection(a,tr("Edit","Shortcut group"));
808 a->setStatusTip (tr( "Collapse one level in tree editor" ));
809 connect( a, SIGNAL( triggered() ), this, SLOT( editCollapseOneLevel() ) );
810 a->setEnabled (false);
811 a->setToggleAction(false);
812 actionCollapseOneLevel=a;
814 editMenu->addAction ( a);
816 actionListBranches.append(a);
818 a = new QAction( tr( "Unscroll children","Edit menu" ), this);
819 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
820 switchboard.addConnection(a,tr("Edit","Shortcut group"));
821 editMenu->addAction (a);
822 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChildren() ) );
824 editMenu->addSeparator();
826 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
827 a->setStatusTip (tr( "Find" ) );
828 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
829 switchboard.addConnection(a,tr("Edit","Shortcut group"));
830 editMenu->addAction (a);
831 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWidget() ) );
833 a = new QAction( tr( "Find duplicate URLs","Edit menu"), this);
834 //a->setStatusTip (tr( "Find" ) );
835 a->setShortcut (Qt::SHIFT + Qt::Key_F); //Find duplicate URLs
836 switchboard.addConnection(a,tr("Edit","Shortcut group"));
837 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
838 editMenu->addAction (a);
839 connect( a, SIGNAL( triggered() ), this, SLOT( editFindDuplicateURLs() ) );
841 editMenu->addSeparator();
843 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
844 a->setShortcut (Qt::SHIFT + Qt::Key_U );
845 switchboard.addConnection(a,tr("Edit","Shortcut group"));
848 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
851 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
852 a->setStatusTip (tr( "Open URL in new tab" ));
853 //a->setShortcut (Qt::CTRL+Qt::Key_U );
854 switchboard.addConnection(a,tr("Edit","Shortcut group"));
856 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
859 a = new QAction( tr( "Open all URLs in subtree (including scrolled branches)","Edit menu" ), this);
860 a->setStatusTip (tr( "Open all URLs in subtree (including scrolled branches)" ));
861 a->setShortcut ( Qt::CTRL + Qt::Key_U );
862 switchboard.addConnection(a,tr("Edit","Shortcut group"));
864 actionListBranches.append(a);
865 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVisURLTabs() ) );
866 actionOpenMultipleVisURLTabs=a;
868 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
869 a->setStatusTip (tr( "Open all URLs in subtree" ));
870 switchboard.addConnection(a,tr("Edit","Shortcut group"));
872 actionListBranches.append(a);
873 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
874 actionOpenMultipleURLTabs=a;
876 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
877 a->setStatusTip ( tr( "Edit URL" ) );
878 a->setShortcut ( Qt::Key_U );
879 a->setShortcutContext (Qt::WindowShortcut);
880 switchboard.addConnection(a,tr("Edit","Shortcut group"));
881 actionListBranches.append(a);
883 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
886 a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
887 a->setStatusTip ( tr( "Edit local URL" ) );
888 //a->setShortcut (Qt::SHIFT + Qt::Key_U );
889 a->setShortcutContext (Qt::WindowShortcut);
890 switchboard.addConnection(a,tr("Edit","Shortcut group"));
891 actionListBranches.append(a);
893 connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
896 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
897 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
898 a->setEnabled (false);
899 switchboard.addConnection(a,tr("Edit","Shortcut group"));
900 actionListBranches.append(a);
901 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
904 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
905 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
906 a->setEnabled (false);
907 actionListBranches.append(a);
908 a->setShortcut ( Qt::Key_B );
909 a->setShortcutContext (Qt::WindowShortcut);
910 switchboard.addConnection(a,tr("Edit","Shortcut group"));
912 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
913 actionBugzilla2URL=a;
915 a = new QAction(tr( "Get data from Novell Bugzilla","Edit menu" ), this);
916 a->setStatusTip ( tr( "Get data from Novell Bugzilla" ));
917 a->setEnabled (false);
918 actionListBranches.append(a);
919 a->setShortcut ( Qt::Key_B + Qt::SHIFT);
920 a->setShortcutContext (Qt::WindowShortcut);
921 switchboard.addConnection(a,tr("Edit","Shortcut group"));
923 connect( a, SIGNAL( triggered() ), this, SLOT( getBugzillaData() ) );
924 actionGetBugzillaData=a;
926 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
927 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
928 a->setEnabled (false);
929 switchboard.addConnection(a,tr("Edit","Shortcut group"));
930 actionListBranches.append(a);
931 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
934 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
935 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
937 a->setEnabled (false);
938 switchboard.addConnection(a,tr("Edit","Shortcut group"));
939 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
942 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
943 a->setStatusTip ( tr( "Open all vym links in subtree" ));
944 a->setEnabled (false);
945 switchboard.addConnection(a,tr("Edit","Shortcut group"));
946 actionListBranches.append(a);
947 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
948 actionOpenMultipleVymLinks=a;
951 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
952 a->setEnabled (false);
953 a->setStatusTip ( tr( "Edit link to another vym map" ));
954 switchboard.addConnection(a,tr("Edit","Shortcut group"));
955 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
956 actionListBranches.append(a);
959 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
960 a->setStatusTip ( tr( "Delete link to another vym map" ));
961 a->setEnabled (false);
962 switchboard.addConnection(a,tr("Edit","Shortcut group"));
963 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
964 actionDeleteVymLink=a;
966 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
967 a->setStatusTip ( tr( "Hide object in exports" ) );
968 a->setShortcut (Qt::Key_H );
969 a->setToggleAction(true);
971 a->setEnabled (false);
972 switchboard.addConnection(a,tr("Edit","Shortcut group"));
973 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
974 actionToggleHideExport=a;
976 a = new QAction(tr( "Add timestamp","Edit menu" ), this);
977 a->setStatusTip ( tr( "Add timestamp" ));
978 a->setEnabled (false);
979 actionListBranches.append(a);
980 a->setShortcut ( Qt::Key_T ); // Add timestamp
981 a->setShortcutContext (Qt::WindowShortcut);
982 switchboard.addConnection(a,tr("Edit","Shortcut group"));
984 connect( a, SIGNAL( triggered() ), this, SLOT( editAddTimestamp() ) );
985 actionAddTimestamp=a;
987 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
988 a->setStatusTip ( tr( "Edit Map Info" ));
989 a->setEnabled (true);
990 switchboard.addConnection(a,tr("Edit","Shortcut group"));
991 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
994 // Import at selection (adding to selection)
995 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
996 a->setStatusTip (tr( "Add map at selection" ));
997 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
998 a->setEnabled (false);
999 switchboard.addConnection(a,tr("Edit","Shortcut group"));
1000 actionListBranches.append(a);
1003 // Import at selection (replacing selection)
1004 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
1005 a->setStatusTip (tr( "Replace selection with map" ));
1006 switchboard.addConnection(a,tr("Edit","Shortcut group"));
1007 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
1008 a->setEnabled (false);
1009 actionListBranches.append(a);
1010 actionImportReplace=a;
1013 a = new QAction( tr( "Save selection","Edit menu" ), this);
1014 a->setStatusTip (tr( "Save selection" ));
1015 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
1016 a->setEnabled (false);
1017 switchboard.addConnection(a,tr("Edit","Shortcut group"));
1018 actionListBranches.append(a);
1021 // Only remove branch, not its children
1022 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
1023 a->setStatusTip ( tr( "Remove only branch and keep its children" ));
1024 a->setShortcut (Qt::ALT + Qt::Key_Delete );
1025 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChildren() ) );
1026 a->setEnabled (false);
1027 switchboard.addConnection(a,tr("Edit","Shortcut group"));
1029 actionListBranches.append(a);
1030 actionDeleteKeepChildren=a;
1032 // Only remove children of a branch
1033 a = new QAction( tr( "Remove children","Edit menu" ), this);
1034 a->setStatusTip (tr( "Remove children of branch" ));
1035 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
1036 switchboard.addConnection(a,tr("Edit","Shortcut group"));
1037 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChildren() ) );
1038 a->setEnabled (false);
1039 actionListBranches.append(a);
1040 actionDeleteChildren=a;
1042 a = new QAction( tr( "Add Image...","Edit menu" ), this);
1043 a->setStatusTip (tr( "Add Image" ));
1044 switchboard.addConnection(a,tr("Edit","Shortcut group"));
1045 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
1048 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
1049 a->setStatusTip (tr( "Set properties for selection" ));
1050 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
1051 a->setShortcutContext (Qt::WindowShortcut);
1052 a->setToggleAction (true);
1053 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1055 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
1056 actionViewTogglePropertyWindow=a;
1060 void Main::setupFormatActions()
1062 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
1064 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
1065 tb->setObjectName ("formatTB");
1067 QPixmap pix( 16,16);
1068 pix.fill (Qt::black);
1069 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
1070 a->setStatusTip ( tr( "Set Color" ));
1071 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
1073 formatMenu->addAction (a);
1074 actionFormatColor=a;
1075 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
1076 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
1077 a->setShortcut (Qt::CTRL + Qt::Key_K );
1078 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
1079 a->setEnabled (false);
1081 formatMenu->addAction (a);
1082 actionListBranches.append(a);
1083 actionFormatPickColor=a;
1085 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
1086 a->setStatusTip ( tr( "Color branch" ) );
1087 a->setShortcut (Qt::CTRL + Qt::Key_B + Qt::SHIFT);
1088 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
1089 a->setEnabled (false);
1091 formatMenu->addAction (a);
1092 actionListBranches.append(a);
1093 actionFormatColorSubtree=a;
1095 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
1096 a->setStatusTip ( tr( "Color Subtree" ));
1097 a->setShortcut (Qt::CTRL + Qt::Key_B); // Color subtree
1098 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
1099 a->setEnabled (false);
1100 formatMenu->addAction (a);
1102 actionListBranches.append(a);
1103 actionFormatColorSubtree=a;
1105 formatMenu->addSeparator();
1106 actionGroupFormatLinkStyles=new QActionGroup ( this);
1107 actionGroupFormatLinkStyles->setExclusive (true);
1108 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
1109 a->setStatusTip (tr( "Line" ));
1110 a->setToggleAction(true);
1111 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
1112 formatMenu->addAction (a);
1113 actionFormatLinkStyleLine=a;
1114 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
1115 a->setStatusTip (tr( "Line" ));
1116 a->setToggleAction(true);
1117 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
1118 formatMenu->addAction (a);
1119 actionFormatLinkStyleParabel=a;
1120 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
1121 a->setStatusTip (tr( "PolyLine" ));
1122 a->setToggleAction(true);
1123 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
1124 formatMenu->addAction (a);
1125 actionFormatLinkStylePolyLine=a;
1126 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
1127 a->setStatusTip (tr( "PolyParabel" ) );
1128 a->setToggleAction(true);
1129 a->setChecked (true);
1130 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
1131 formatMenu->addAction (a);
1132 actionFormatLinkStylePolyParabel=a;
1134 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
1135 a->setStatusTip (tr( "Hide link" ));
1136 a->setToggleAction(true);
1137 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
1138 actionFormatHideLinkUnselected=a;
1140 formatMenu->addSeparator();
1141 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
1142 a->setStatusTip (tr( "Use same color for links and headings" ));
1143 a->setToggleAction(true);
1144 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
1145 formatMenu->addAction (a);
1146 actionFormatLinkColorHint=a;
1148 pix.fill (Qt::white);
1149 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
1150 a->setStatusTip (tr( "Set Link Color" ));
1151 formatMenu->addAction (a);
1152 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
1153 actionFormatLinkColor=a;
1155 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
1156 a->setStatusTip (tr( "Set Selection Color" ));
1157 formatMenu->addAction (a);
1158 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
1159 actionFormatSelectionColor=a;
1161 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
1162 a->setStatusTip (tr( "Set Background Color" ));
1163 formatMenu->addAction (a);
1164 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
1165 actionFormatBackColor=a;
1167 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
1168 a->setStatusTip (tr( "Set Background image" ));
1169 formatMenu->addAction (a);
1170 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
1171 actionFormatBackImage=a;
1175 void Main::setupViewActions()
1177 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
1178 tb->setLabel( "View Actions" );
1179 tb->setObjectName ("viewTB");
1180 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
1184 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
1185 a->setStatusTip ( tr( "Zoom reset" ) );
1186 a->setShortcut (Qt::Key_Comma); // Reset zoom
1187 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1189 viewMenu->addAction (a);
1190 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
1192 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
1193 a->setStatusTip (tr( "Zoom in" ));
1194 a->setShortcut(Qt::Key_Plus);
1195 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1197 viewMenu->addAction (a);
1198 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
1200 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
1201 a->setStatusTip (tr( "Zoom out" ));
1202 a->setShortcut(Qt::Key_Minus);
1203 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1205 viewMenu->addAction (a);
1206 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1208 a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
1209 a->setStatusTip (tr( "Show selection" ));
1210 a->setShortcut(Qt::Key_Period);
1211 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1213 viewMenu->addAction (a);
1214 connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
1216 viewMenu->addSeparator();
1218 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
1219 a->setStatusTip ( tr( "Show Note Editor" ));
1220 a->setShortcut ( Qt::CTRL + Qt::Key_E ); // Toggle Note Editor
1221 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1222 a->setToggleAction(true);
1224 viewMenu->addAction (a);
1225 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1226 actionViewToggleNoteEditor=a;
1228 // Original icon is "category" from KDE
1229 a = new QAction(QPixmap(iconPath+"treeeditor.png"), tr( "Show tree editor","View action" ),this);
1230 a->setStatusTip ( tr( "Show tree editor" ));
1231 a->setShortcut ( Qt::CTRL + Qt::Key_T ); // Toggle Tree Editor // FIXME-3 originally: color subtree
1232 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1233 a->setToggleAction(true);
1235 viewMenu->addAction (a);
1236 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleTreeEditor() ) );
1237 actionViewToggleTreeEditor=a;
1239 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
1240 a->setStatusTip ( tr( "Show History Window" ));
1241 a->setShortcut ( Qt::CTRL + Qt::Key_H ); // Toggle history window
1242 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1243 a->setToggleAction(true);
1245 viewMenu->addAction (a);
1246 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1247 actionViewToggleHistoryWindow=a;
1249 viewMenu->addAction (actionViewTogglePropertyWindow);
1251 viewMenu->addSeparator();
1253 a = new QAction(tr( "Antialiasing","View action" ),this );
1254 a->setStatusTip ( tr( "Antialiasing" ));
1255 a->setToggleAction(true);
1256 a->setChecked (settings.value("/mainwindow/view/AntiAlias",true).toBool());
1257 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1258 viewMenu->addAction (a);
1259 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
1260 actionViewToggleAntiAlias=a;
1262 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1263 a->setStatusTip (a->text());
1264 a->setToggleAction(true);
1265 a->setChecked (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1266 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1267 viewMenu->addAction (a);
1268 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1269 actionViewToggleSmoothPixmapTransform=a;
1271 a = new QAction(tr( "Next Map","View action" ), this);
1272 a->setStatusTip (a->text());
1273 a->setShortcut (Qt::ALT + Qt::Key_N );
1274 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1275 viewMenu->addAction (a);
1276 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1278 a = new QAction (tr( "Previous Map","View action" ), this );
1279 a->setStatusTip (a->text());
1280 a->setShortcut (Qt::ALT + Qt::Key_P );
1281 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1282 viewMenu->addAction (a);
1283 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1287 void Main::setupModeActions()
1289 //QPopupMenu *menu = new QPopupMenu( this );
1290 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1292 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1293 tb->setObjectName ("modesTB");
1295 actionGroupModModes=new QActionGroup ( this);
1296 actionGroupModModes->setExclusive (true);
1297 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1298 a->setShortcut (Qt::Key_J);
1299 switchboard.addConnection(a,tr("Modes","Shortcut group"));
1300 a->setStatusTip ( tr( "Use modifier to color branches" ));
1301 a->setToggleAction(true);
1303 a->setChecked(true);
1304 actionModModeColor=a;
1306 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1307 a->setShortcut( Qt::Key_K);
1308 switchboard.addConnection(a,tr("Modes","Shortcut group"));
1309 a->setStatusTip( tr( "Use modifier to copy" ));
1310 a->setToggleAction(true);
1312 actionModModeCopy=a;
1314 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1315 a->setShortcut (Qt::Key_L);
1316 switchboard.addConnection(a,tr("Modes","Shortcut group"));
1317 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1318 a->setToggleAction(true);
1320 actionModModeXLink=a;
1324 void Main::setupFlagActions()
1326 // Create System Flags
1329 Flag *flag=new Flag(flagsPath+"flag-note.png");
1330 setupFlag (flag,tb,"system-note",tr("Note","SystemFlag"));
1332 flag=new Flag(flagsPath+"flag-url.png");
1333 setupFlag (flag,tb,"system-url",tr("URL to Document ","SystemFlag"));
1335 flag=new Flag(flagsPath+"flag-url-bugzilla-novell.png");
1336 setupFlag (flag,tb,"system-url-bugzilla-novell",tr("URL to Bugzilla ","SystemFlag"));
1338 flag=new Flag(flagsPath+"flag-vymlink.png");
1339 setupFlag (flag,tb,"system-vymLink",tr("Link to another vym map","SystemFlag"));
1341 flag=new Flag(flagsPath+"flag-scrolled-right.png");
1342 setupFlag (flag,tb,"system-scrolledright",tr("subtree is scrolled","SystemFlag"));
1344 flag=new Flag(flagsPath+"flag-tmpUnscrolled-right.png");
1345 setupFlag (flag,tb,"system-tmpUnscrolledRight",tr("subtree is temporary scrolled","SystemFlag"));
1347 flag=new Flag(flagsPath+"flag-hideexport.png");
1348 setupFlag (flag,tb,"system-hideInExport",tr("Hide object in exported maps","SystemFlag"));
1350 // Create Standard Flags
1351 tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1352 tb->setObjectName ("standardFlagTB");
1353 standardFlagsMaster->setToolBar (tb);
1355 flag=new Flag(flagsPath+"flag-exclamationmark.png");
1356 flag->setGroup("standard-mark");
1357 setupFlag (flag,tb,"exclamationmark",tr("Take care!","Standardflag"));
1359 flag=new Flag(flagsPath+"flag-questionmark.png");
1360 flag->setGroup("standard-mark");
1361 setupFlag (flag,tb,"questionmark",tr("Really?","Standardflag"));
1363 flag=new Flag(flagsPath+"flag-hook-green.png");
1364 flag->setGroup("standard-status");
1365 setupFlag (flag,tb,"hook-green",tr("Status - ok,done","Standardflag"));
1367 flag=new Flag(flagsPath+"flag-wip.png");
1368 flag->setGroup("standard-status");
1369 setupFlag (flag,tb,"wip",tr("Status - work in progress","Standardflag"));
1371 flag=new Flag(flagsPath+"flag-cross-red.png");
1372 flag->setGroup("standard-status");
1373 setupFlag (flag,tb,"cross-red",tr("Status - missing, not started","Standardflag"));
1376 flag=new Flag(flagsPath+"flag-stopsign.png");
1377 setupFlag (flag,tb,"stopsign",tr("This won't work!","Standardflag"));
1379 flag=new Flag(flagsPath+"flag-smiley-good.png");
1380 flag->setGroup("standard-smiley");
1381 setupFlag (flag,tb,"smiley-good",tr("Good","Standardflag"));
1383 flag=new Flag(flagsPath+"flag-smiley-sad.png");
1384 flag->setGroup("standard-smiley");
1385 setupFlag (flag,tb,"smiley-sad",tr("Bad","Standardflag"));
1387 flag=new Flag(flagsPath+"flag-smiley-omg.png");
1388 flag->setGroup("standard-smiley");
1389 setupFlag (flag,tb,"smiley-omb",tr("Oh no!","Standardflag"));
1390 // Original omg.png (in KDE emoticons)
1393 flag=new Flag(flagsPath+"flag-kalarm.png");
1394 setupFlag (flag,tb,"clock",tr("Time critical","Standardflag"));
1396 flag=new Flag(flagsPath+"flag-phone.png");
1397 setupFlag (flag,tb,"phone",tr("Call...","Standardflag"));
1399 flag=new Flag(flagsPath+"flag-lamp.png");
1400 setupFlag (flag,tb,"lamp",tr("Idea!","Standardflag"));
1402 flag=new Flag(flagsPath+"flag-arrow-up.png");
1403 flag->setGroup("standard-arrow");
1404 setupFlag (flag,tb,"arrow-up",tr("Important","Standardflag"));
1406 flag=new Flag(flagsPath+"flag-arrow-down.png");
1407 flag->setGroup("standard-arrow");
1408 setupFlag (flag,tb,"arrow-down",tr("Unimportant","Standardflag"));
1410 flag=new Flag(flagsPath+"flag-arrow-2up.png");
1411 flag->setGroup("standard-arrow");
1412 setupFlag (flag,tb,"2arrow-up",tr("Very important!","Standardflag"));
1414 flag=new Flag(flagsPath+"flag-arrow-2down.png");
1415 flag->setGroup("standard-arrow");
1416 setupFlag (flag,tb,"2arrow-down",tr("Very unimportant!","Standardflag"));
1419 flag=new Flag(flagsPath+"flag-thumb-up.png");
1420 flag->setGroup("standard-thumb");
1421 setupFlag (flag,tb,"thumb-up",tr("I like this","Standardflag"));
1423 flag=new Flag(flagsPath+"flag-thumb-down.png");
1424 flag->setGroup("standard-thumb");
1425 setupFlag (flag,tb,"thumb-down",tr("I do not like this","Standardflag"));
1428 flag=new Flag(flagsPath+"flag-rose.png");
1429 setupFlag (flag,tb,"rose",tr("Rose","Standardflag"));
1431 flag=new Flag(flagsPath+"flag-heart.png");
1432 setupFlag (flag,tb,"heart",tr("I just love...","Standardflag"));
1434 flag=new Flag(flagsPath+"flag-present.png");
1435 setupFlag (flag,tb,"present",tr("Surprise!","Standardflag"));
1437 flag=new Flag(flagsPath+"flag-flash.png");
1438 setupFlag (flag,tb,"flash",tr("Dangerous","Standardflag"));
1440 // Original: xsldbg_output.png
1441 flag=new Flag(flagsPath+"flag-info.png");
1442 setupFlag (flag,tb,"info",tr("Info","Standardflag"));
1444 // Original khelpcenter.png
1445 flag=new Flag(flagsPath+"flag-lifebelt.png");
1446 setupFlag (flag,tb,"lifebelt",tr("This will help","Standardflag"));
1449 flag=new Flag(flagsPath+"freemind/warning.png");
1450 flag->setVisible(false);
1451 setupFlag (flag,tb, "freemind-warning",tr("Important","Freemind-Flag"));
1453 for (int i=1; i<8; i++)
1455 flag=new Flag(flagsPath+QString("freemind/priority-%1.png").arg(i));
1456 flag->setVisible(false);
1457 flag->setGroup ("Freemind-priority");
1458 setupFlag (flag,tb, QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
1461 flag=new Flag(flagsPath+"freemind/back.png");
1462 flag->setVisible(false);
1463 setupFlag (flag,tb,"freemind-back",tr("Back","Freemind-Flag"));
1465 flag=new Flag(flagsPath+"freemind/forward.png");
1466 flag->setVisible(false);
1467 setupFlag (flag,tb,"freemind-forward",tr("forward","Freemind-Flag"));
1469 flag=new Flag(flagsPath+"freemind/attach.png");
1470 flag->setVisible(false);
1471 setupFlag (flag,tb,"freemind-attach",tr("Look here","Freemind-Flag"));
1473 flag=new Flag(flagsPath+"freemind/clanbomber.png");
1474 flag->setVisible(false);
1475 setupFlag (flag,tb,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
1477 flag=new Flag(flagsPath+"freemind/desktopnew.png");
1478 flag->setVisible(false);
1479 setupFlag (flag,tb,"freemind-desktopnew",tr("Don't flagrget","Freemind-Flag"));
1481 flag=new Flag(flagsPath+"freemind/flag.png");
1482 flag->setVisible(false);
1483 setupFlag (flag,tb,"freemind-flag",tr("Flag","Freemind-Flag"));
1486 flag=new Flag(flagsPath+"freemind/gohome.png");
1487 flag->setVisible(false);
1488 setupFlag (flag,tb,"freemind-gohome",tr("Home","Freemind-Flag"));
1490 flag=new Flag(flagsPath+"freemind/kaddressbook.png");
1491 flag->setVisible(false);
1492 setupFlag (flag,tb,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
1494 flag=new Flag(flagsPath+"freemind/knotify.png");
1495 flag->setVisible(false);
1496 setupFlag (flag,tb,"freemind-knotify",tr("Music","Freemind-Flag"));
1498 flag=new Flag(flagsPath+"freemind/korn.png");
1499 flag->setVisible(false);
1500 setupFlag (flag,tb,"freemind-korn",tr("Mailbox","Freemind-Flag"));
1502 flag=new Flag(flagsPath+"freemind/mail.png");
1503 flag->setVisible(false);
1504 setupFlag (flag,tb,"freemind-mail",tr("Maix","Freemind-Flag"));
1506 flag=new Flag(flagsPath+"freemind/password.png");
1507 flag->setVisible(false);
1508 setupFlag (flag,tb,"freemind-password",tr("Password","Freemind-Flag"));
1510 flag=new Flag(flagsPath+"freemind/pencil.png");
1511 flag->setVisible(false);
1512 setupFlag (flag,tb,"freemind-pencil",tr("To be improved","Freemind-Flag"));
1514 flag=new Flag(flagsPath+"freemind/stop.png");
1515 flag->setVisible(false);
1516 setupFlag (flag,tb,"freemind-stop",tr("Stop","Freemind-Flag"));
1518 flag=new Flag(flagsPath+"freemind/wizard.png");
1519 flag->setVisible(false);
1520 setupFlag (flag,tb,"freemind-wizard",tr("Magic","Freemind-Flag"));
1522 flag=new Flag(flagsPath+"freemind/xmag.png");
1523 flag->setVisible(false);
1524 setupFlag (flag,tb,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
1526 flag=new Flag(flagsPath+"freemind/bell.png");
1527 flag->setVisible(false);
1528 setupFlag (flag,tb,"freemind-bell",tr("Reminder","Freemind-Flag"));
1530 flag=new Flag(flagsPath+"freemind/bookmark.png");
1531 flag->setVisible(false);
1532 setupFlag (flag,tb,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
1534 flag= new Flag(flagsPath+"freemind/penguin.png");
1535 flag->setVisible(false);
1536 setupFlag (flag,tb,"freemind-penguin",tr("Linux","Freemind-Flag"));
1538 flag=new Flag (flagsPath+"freemind/licq.png");
1539 flag->setVisible(false);
1540 setupFlag (flag,tb,"freemind-licq",tr("Sweet","Freemind-Flag"));
1543 void Main::setupFlag (Flag *flag, QToolBar *tb, const QString &name, const QString &tooltip)
1545 flag->setName(name);
1546 flag->setToolTip (tooltip);
1550 a=new QAction (flag->getPixmap(),name,this);
1553 flag->setAction (a);
1554 a->setVisible (flag->isVisible());
1555 a->setCheckable(true);
1556 a->setObjectName(name);
1557 a->setToolTip(tooltip);
1558 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1559 standardFlagsMaster->addFlag (flag);
1563 systemFlagsMaster->addFlag (flag);
1568 void Main::setupNetworkActions()
1570 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1572 QMenu *netMenu = menuBar()->addMenu( "Network" );
1576 a = new QAction( "Start TCPserver for MapEditor",this);
1577 //a->setStatusTip ( "Set application to open pdf files"));
1578 //a->setShortcut ( Qt::ALT + Qt::Key_T ); //New TCP server
1579 switchboard.addConnection(a,tr("Network shortcuts","Shortcut group"));
1580 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1581 netMenu->addAction (a);
1583 a = new QAction( "Connect MapEditor to server",this);
1584 //a->setStatusTip ( "Set application to open pdf files"));
1585 a->setShortcut ( Qt::ALT + Qt::Key_C ); // Connect to server
1586 switchboard.addConnection(a,tr("Network shortcuts","Shortcut group"));
1587 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1588 netMenu->addAction (a);
1592 void Main::setupSettingsActions()
1594 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1598 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1599 a->setStatusTip ( tr( "Set application to open pdf files"));
1600 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1601 settingsMenu->addAction (a);
1603 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1604 a->setStatusTip( tr( "Set application to open external links"));
1605 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1606 settingsMenu->addAction (a);
1608 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1609 a->setStatusTip( tr( "Set path for macros"));
1610 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1611 settingsMenu->addAction (a);
1613 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1614 a->setStatusTip( tr( "Set number of undo levels"));
1615 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1616 settingsMenu->addAction (a);
1618 settingsMenu->addSeparator();
1620 a = new QAction( tr( "Autosave","Settings action"), this);
1621 a->setStatusTip( tr( "Autosave"));
1622 a->setToggleAction(true);
1623 a->setChecked ( settings.value ("/mainwindow/autosave/use",false).toBool());
1624 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1625 settingsMenu->addAction (a);
1626 actionSettingsAutosaveToggle=a;
1628 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1629 a->setStatusTip( tr( "Autosave time"));
1630 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1631 settingsMenu->addAction (a);
1632 actionSettingsAutosaveTime=a;
1634 a = new QAction( tr( "Write backup file on save","Settings action"), this);
1635 a->setStatusTip( tr( "Write backup file on save"));
1636 a->setToggleAction(true);
1637 a->setChecked ( settings.value ("/mainwindow/writeBackupFile",false).toBool());
1638 connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) );
1639 settingsMenu->addAction (a);
1640 actionSettingsWriteBackupFile=a;
1642 settingsMenu->addSeparator();
1644 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1645 a->setStatusTip( tr( "Edit branch after adding it" ));
1646 a->setToggleAction(true);
1647 a->setChecked ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1648 settingsMenu->addAction (a);
1649 actionSettingsAutoEditNewBranch=a;
1651 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1652 a->setStatusTip( tr( "Select branch after adding it" ));
1653 a->setToggleAction(true);
1654 a->setChecked ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1655 settingsMenu->addAction (a);
1656 actionSettingsAutoSelectNewBranch=a;
1658 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1659 a->setStatusTip( tr( "Select heading before editing" ));
1660 a->setToggleAction(true);
1661 a->setChecked ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1662 settingsMenu->addAction (a);
1663 actionSettingsAutoSelectText=a;
1665 a= new QAction( tr( "Delete key","Settings action" ), this);
1666 a->setStatusTip( tr( "Delete key for deleting branches" ));
1667 a->setToggleAction(true);
1668 a->setChecked ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1669 settingsMenu->addAction (a);
1670 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1671 actionSettingsUseDelKey=a;
1673 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1674 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1675 a->setToggleAction(true);
1676 a->setChecked ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1677 settingsMenu->addAction (a);
1678 actionSettingsUseFlagGroups=a;
1680 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1681 a->setStatusTip( tr( "Use hide flag during exports " ));
1682 a->setToggleAction(true);
1683 a->setChecked ( settings.value ("/export/useHideExport",true).toBool() );
1684 settingsMenu->addAction (a);
1685 actionSettingsUseHideExport=a;
1687 settingsMenu->addSeparator();
1689 a = new QAction( tr( "Animation","Settings action"), this);
1690 a->setStatusTip( tr( "Animation"));
1691 a->setToggleAction(true);
1692 a->setChecked (settings.value("/animation/use",true).toBool() );
1693 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) );
1694 settingsMenu->addAction (a);
1695 actionSettingsUseAnimation=a;
1697 a = new QAction( tr( "Automatic layout","Settings action"), this);
1698 a->setStatusTip( tr( "Automatic layout"));
1699 a->setToggleAction(true);
1700 a->setChecked ( settings.value ("/mainwindow/autoLayout/use",true).toBool());
1701 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutoLayoutToggle() ) );
1702 settingsMenu->addAction (a);
1703 actionSettingsAutoLayoutToggle=a;
1708 void Main::setupTestActions()
1710 QMenu *testMenu = menuBar()->addMenu( tr( "Test" ));
1713 a = new QAction( "Test function 1" , this);
1714 a->setStatusTip( "Call test function 1" );
1715 a->setShortcut (Qt::SHIFT + Qt::Key_T); // Test function 1
1716 switchboard.addConnection(a,tr("Test shortcuts","Shortcut group"));
1717 testMenu->addAction (a);
1718 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1720 a = new QAction( "Test function 2" , this);
1721 a->setStatusTip( "Call test function 2" );
1722 a->setShortcut (Qt::ALT + Qt::Key_T); // Test function 2
1723 switchboard.addConnection(a,tr("Test shortcuts","Shortcut group"));
1724 testMenu->addAction (a);
1725 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1727 a = new QAction( "Command" , this);
1728 a->setStatusTip( "Enter command to call in editor" );
1729 switchboard.addConnection(a,tr("Test shortcuts","Shortcut group"));
1730 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1731 testMenu->addAction (a);
1735 void Main::setupHelpActions()
1737 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1740 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1741 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1742 switchboard.addConnection(a,tr("Help shortcuts","Shortcut group"));
1743 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1744 helpMenu->addAction (a);
1746 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1747 a->setStatusTip( tr( "Open VYM example maps " ));
1748 switchboard.addConnection(a,tr("Help shortcuts","Shortcut group"));
1749 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1750 helpMenu->addAction (a);
1752 a = new QAction( tr( "About VYM","Help action" ), this);
1753 a->setStatusTip( tr( "About VYM")+vymName);
1754 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1755 helpMenu->addAction (a);
1757 a = new QAction( tr( "About QT","Help action" ), this);
1758 a->setStatusTip( tr( "Information about QT toolkit" ));
1759 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1760 helpMenu->addAction (a);
1764 void Main::setupContextMenus()
1766 // Context Menu for branch or mapcenter
1767 branchContextMenu =new QMenu (this);
1768 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1769 branchContextMenu->addSeparator();
1772 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1773 branchAddContextMenu->addAction (actionPaste );
1774 branchAddContextMenu->addAction ( actionAddMapCenter );
1775 branchAddContextMenu->addAction ( actionAddBranch );
1776 branchAddContextMenu->addAction ( actionAddBranchBefore );
1777 branchAddContextMenu->addAction ( actionAddBranchAbove);
1778 branchAddContextMenu->addAction ( actionAddBranchBelow );
1779 branchAddContextMenu->addSeparator();
1780 branchAddContextMenu->addAction ( actionImportAdd );
1781 branchAddContextMenu->addAction ( actionImportReplace );
1784 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1785 branchRemoveContextMenu->addAction (actionCut);
1786 branchRemoveContextMenu->addAction ( actionDelete );
1787 branchRemoveContextMenu->addAction ( actionDeleteKeepChildren );
1788 branchRemoveContextMenu->addAction ( actionDeleteChildren );
1791 actionSaveBranch->addTo( branchContextMenu );
1792 actionFileNewCopy->addTo (branchContextMenu );
1793 actionDetach->addTo (branchContextMenu );
1795 branchContextMenu->addSeparator();
1796 branchContextMenu->addAction ( actionLoadImage);
1797 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1798 branchContextMenu->addAction ( actionAddAttribute);
1800 // Submenu for Links (URLs, vymLinks)
1801 branchLinksContextMenu =new QMenu (this);
1803 branchContextMenu->addSeparator();
1804 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1805 branchLinksContextMenu->addAction ( actionOpenURL );
1806 branchLinksContextMenu->addAction ( actionOpenURLTab );
1807 branchLinksContextMenu->addAction ( actionOpenMultipleVisURLTabs );
1808 branchLinksContextMenu->addAction ( actionOpenMultipleURLTabs );
1809 branchLinksContextMenu->addAction ( actionURL );
1810 branchLinksContextMenu->addAction ( actionLocalURL );
1811 branchLinksContextMenu->addAction ( actionHeading2URL );
1812 branchLinksContextMenu->addAction ( actionBugzilla2URL );
1813 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1815 branchLinksContextMenu->addAction ( actionGetBugzillaData );
1816 branchLinksContextMenu->addAction ( actionFATE2URL );
1818 branchLinksContextMenu->addSeparator();
1819 branchLinksContextMenu->addAction ( actionOpenVymLink );
1820 branchLinksContextMenu->addAction ( actionOpenMultipleVymLinks );
1821 branchLinksContextMenu->addAction ( actionVymLink );
1822 branchLinksContextMenu->addAction ( actionDeleteVymLink );
1825 // Context Menu for XLinks in a branch menu
1826 // This will be populated "on demand" in MapEditor::updateActions
1827 branchContextMenu->addSeparator();
1828 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1829 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1832 // Context menu for floatimage
1833 floatimageContextMenu =new QMenu (this);
1834 QAction *a= new QAction (tr ("Save image","Context action"),this);
1835 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1836 floatimageContextMenu->addAction (a);
1838 floatimageContextMenu->addSeparator();
1839 actionCopy->addTo( floatimageContextMenu );
1840 actionCut->addTo( floatimageContextMenu );
1842 floatimageContextMenu->addSeparator();
1843 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1846 // Context menu for canvas
1847 canvasContextMenu =new QMenu (this);
1848 actionAddMapCenter->addTo( canvasContextMenu );
1849 actionMapInfo->addTo( canvasContextMenu );
1850 canvasContextMenu->insertSeparator();
1851 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1852 canvasContextMenu->insertSeparator();
1853 actionFormatLinkColorHint->addTo( canvasContextMenu );
1854 actionFormatLinkColor->addTo( canvasContextMenu );
1855 actionFormatSelectionColor->addTo( canvasContextMenu );
1856 actionFormatBackColor->addTo( canvasContextMenu );
1857 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME-4 makes vym too slow: postponed for later version
1859 // Menu for last opened files
1861 for (int i = 0; i < MaxRecentFiles; ++i)
1863 recentFileActions[i] = new QAction(this);
1864 recentFileActions[i]->setVisible(false);
1865 fileLastMapsMenu->addAction(recentFileActions[i]);
1866 connect(recentFileActions[i], SIGNAL(triggered()),
1867 this, SLOT(fileLoadRecent()));
1869 setupRecentMapsMenu();
1872 void Main::setupRecentMapsMenu()
1874 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1876 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1878 for (int i = 0; i < numRecentFiles; ++i) {
1879 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1880 recentFileActions[i]->setText(text);
1881 recentFileActions[i]->setData(files[i]);
1882 recentFileActions[i]->setVisible(true);
1884 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1885 recentFileActions[j]->setVisible(false);
1888 void Main::setupMacros()
1890 for (int i = 0; i <= 11; i++)
1892 macroActions[i] = new QAction(this);
1893 macroActions[i]->setData(i);
1894 addAction (macroActions[i]);
1895 //switchboard.addConnection(macroActions[i],tr("Macro shortcuts","Shortcut group"));
1896 connect(macroActions[i], SIGNAL(triggered()),
1897 this, SLOT(callMacro()));
1899 macroActions[0]->setShortcut ( Qt::Key_F1 );
1900 macroActions[1]->setShortcut ( Qt::Key_F2 );
1901 macroActions[2]->setShortcut ( Qt::Key_F3 );
1902 macroActions[3]->setShortcut ( Qt::Key_F4 );
1903 macroActions[4]->setShortcut ( Qt::Key_F5 );
1904 macroActions[5]->setShortcut ( Qt::Key_F6 );
1905 macroActions[6]->setShortcut ( Qt::Key_F7 );
1906 macroActions[7]->setShortcut ( Qt::Key_F8 );
1907 macroActions[8]->setShortcut ( Qt::Key_F9 );
1908 macroActions[9]->setShortcut ( Qt::Key_F10 );
1909 macroActions[10]->setShortcut ( Qt::Key_F11 );
1910 macroActions[11]->setShortcut ( Qt::Key_F12 );
1913 void Main::hideEvent (QHideEvent * )
1915 if (!textEditor->isMinimized() ) textEditor->hide();
1918 void Main::showEvent (QShowEvent * )
1920 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1924 MapEditor* Main::currentMapEditor() const
1926 if ( tabWidget->currentPage())
1927 return vymViews.at(tabWidget->currentIndex())->getMapEditor();
1931 uint Main::currentModelID() const
1934 return currentModel()->getID();
1938 VymModel* Main::currentModel() const
1940 if ( tabWidget->currentPage())
1941 return vymViews.at(tabWidget->currentIndex())->getModel();
1945 VymModel* Main::getModel(uint id) const
1948 for (int i=0; i<vymViews.count();i++)
1949 if (vymViews.at(i)->getModel()->getID()==id)
1950 return vymViews.at(i)->getModel();
1955 void Main::editorChanged(QWidget *)
1957 // Unselect all possibly selected objects
1958 // (Important to update note editor)
1960 for (int i=0;i<=tabWidget->count() -1;i++)
1962 m= vymViews.at(i)->getModel();
1963 if (m) m->unselect();
1966 if (m) m->reselect();
1968 // Update actions to in menus and toolbars according to editor
1972 void Main::fileNew()
1974 VymModel *vm=new VymModel;
1976 /////////////////////////////////////
1977 // new ModelTest(vm, this); //FIXME-3
1978 /////////////////////////////////////
1980 VymView *vv=new VymView (vm);
1981 vymViews.append (vv);
1982 tabWidget->addTab (vv,tr("unnamed","MainWindow: name for new and empty file"));
1983 tabWidget->setCurrentIndex (vymViews.count() );
1986 // Create MapCenter for empty map
1990 // For the very first map we do not have flagrows yet...
1994 void Main::fileNewCopy()
1996 QString fn="unnamed";
1997 VymModel *srcModel=currentModel();
2002 VymModel *dstModel=vymViews.last()->getModel();
2003 dstModel->select("mc:");
2004 dstModel->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
2008 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
2010 ErrorCode err=success;
2012 // fn is usually the archive, mapfile the file after uncompressing
2015 // Make fn absolute (needed for unzip)
2016 fn=QDir (fn).absPath();
2022 // Check, if map is already loaded
2024 while (i<=tabWidget->count() -1)
2026 if (vymViews.at(i)->getModel()->getFilePath() == fn)
2028 // Already there, ask for confirmation
2029 QMessageBox mb( vymName,
2030 tr("The map %1\nis already opened."
2031 "Opening the same map in multiple editors may lead \n"
2032 "to confusion when finishing working with vym."
2033 "Do you want to").arg(fn),
2034 QMessageBox::Warning,
2035 QMessageBox::Yes | QMessageBox::Default,
2036 QMessageBox::Cancel | QMessageBox::Escape,
2037 QMessageBox::NoButton);
2038 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
2039 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2042 case QMessageBox::Yes:
2043 // end loop and load anyway
2044 i=tabWidget->count();
2046 case QMessageBox::Cancel:
2056 int tabIndex=tabWidget->currentPageIndex();
2059 if ( !fn.isEmpty() )
2061 vm = currentModel();
2062 // Check first, if mapeditor exists
2063 // If it is not default AND we want a new map,
2064 // create a new mapeditor in a new tab
2065 if ( lmode==NewMap && (!vm || !vm->isDefault() ) )
2068 VymView *vv=new VymView (vm);
2069 vymViews.append (vv);
2070 tabWidget->addTab (vv,fn);
2071 tabIndex=tabWidget->count()-1;
2072 tabWidget->setCurrentPage (tabIndex);
2076 // Check, if file exists (important for creating new files
2077 // from command line
2078 if (!QFile(fn).exists() )
2080 QMessageBox mb( vymName,
2081 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
2082 QMessageBox::Question,
2084 QMessageBox::Cancel | QMessageBox::Default,
2085 QMessageBox::NoButton );
2087 mb.setButtonText( QMessageBox::Yes, tr("Create"));
2088 mb.setButtonText( QMessageBox::No, tr("Cancel"));
2091 case QMessageBox::Yes:
2093 currentMapEditor()->getModel()->setFilePath(fn);
2094 tabWidget->setTabText (tabIndex,
2095 currentMapEditor()->getModel()->getFileName() );
2096 statusBar()->message( "Created " + fn , statusbarTime );
2099 case QMessageBox::Cancel:
2100 // don't create new map
2101 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
2108 //tabWidget->currentPage() won't be NULL here, because of above...
2109 tabWidget->setCurrentIndex (tabIndex);
2110 //FIXME-3 no me anymore... me->viewport()->setFocus();
2114 // Save existing filename in case we import
2115 QString fn_org=vm->getFilePath();
2117 // Finally load map into mapEditor
2118 vm->setFilePath (fn);
2119 err=vm->load(fn,lmode,ftype);
2121 // Restore old (maybe empty) filepath, if this is an import
2123 vm->setFilePath (fn_org);
2126 // Finally check for errors and go home
2129 if (lmode==NewMap) fileCloseMap();
2130 statusBar()->message( "Could not load " + fn, statusbarTime );
2135 vm->setFilePath (fn);
2136 tabWidget->setTabText (tabIndex, vm->getFileName());
2137 if (!isInTmpDir (fn))
2139 // Only append to lastMaps if not loaded from a tmpDir
2140 // e.g. imported bookmarks are in a tmpDir
2141 addRecentMap(vm->getFilePath() );
2143 actionFilePrint->setEnabled (true);
2145 statusBar()->message( "Loaded " + fn, statusbarTime );
2152 void Main::fileLoad(const LoadMode &lmode)
2154 QStringList filters;
2155 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
2156 QFileDialog *fd=new QFileDialog( this);
2157 fd->setDir (lastFileDir);
2158 fd->setFileMode (QFileDialog::ExistingFiles);
2159 fd->setFilters (filters);
2163 fd->setCaption(vymName+ " - " +tr("Load vym map"));
2166 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
2169 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
2175 if ( fd->exec() == QDialog::Accepted )
2177 lastFileDir=fd->directory().path();
2178 QStringList flist = fd->selectedFiles();
2179 QStringList::Iterator it = flist.begin();
2181 progressCounter=flist.count();
2182 progressCounterTotal=flist.count();
2183 while( it != flist.end() )
2186 fileLoad(*it, lmode);
2193 void Main::fileLoad()
2198 void Main::fileLoadRecent()
2200 QAction *action = qobject_cast<QAction *>(sender());
2202 fileLoad (action->data().toString(), NewMap);
2205 void Main::addRecentMap (const QString &fileName)
2208 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
2209 files.removeAll(fileName);
2210 files.prepend(fileName);
2211 while (files.size() > MaxRecentFiles)
2214 settings.setValue("/mainwindow/recentFileList", files);
2216 setupRecentMapsMenu();
2219 void Main::fileSave(VymModel *m, const SaveMode &savemode)
2223 if ( m->getFilePath().isEmpty() )
2225 // We have no filepath yet,
2226 // call fileSaveAs() now, this will call fileSave()
2228 // First switch to editor
2229 //FIXME-3 needed??? tabWidget->setCurrentWidget (m->getMapEditor());
2230 fileSaveAs(savemode);
2233 if (m->save (savemode)==success)
2235 statusBar()->message(
2236 tr("Saved %1").arg(m->getFilePath()),
2238 addRecentMap (m->getFilePath() );
2240 statusBar()->message(
2241 tr("Couldn't save ").arg(m->getFilePath()),
2245 void Main::fileSave()
2247 fileSave (currentModel(), CompleteMap);
2250 void Main::fileSave(VymModel *m)
2252 fileSave (m,CompleteMap);
2255 void Main::fileSaveAs(const SaveMode& savemode)
2259 if (currentMapEditor())
2261 if (savemode==CompleteMap)
2262 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2264 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2265 if ( !fn.isEmpty() )
2267 // Check for existing file
2268 if (QFile (fn).exists())
2270 QMessageBox mb( vymName,
2271 tr("The file %1\nexists already. Do you want to").arg(fn),
2272 QMessageBox::Warning,
2273 QMessageBox::Yes | QMessageBox::Default,
2274 QMessageBox::Cancel | QMessageBox::Escape,
2275 QMessageBox::NoButton);
2276 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2277 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2280 case QMessageBox::Yes:
2283 case QMessageBox::Cancel:
2290 // New file, add extension to filename, if missing
2291 // This is always .vym or .vyp, depending on savemode
2292 if (savemode==CompleteMap)
2294 if (!fn.contains (".vym") && !fn.contains (".xml"))
2298 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2307 VymModel *m=currentModel();
2309 fileSave(m, savemode);
2311 // Set name of tab, assuming current tab is the one we just saved
2312 if (savemode==CompleteMap)
2313 tabWidget->setTabText (tabWidget->currentIndex(), m->getFileName() );
2319 void Main::fileSaveAs()
2321 fileSaveAs (CompleteMap);
2324 void Main::fileImportKDE3Bookmarks()
2326 ImportKDE3Bookmarks im;
2328 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2329 currentMapEditor()->getModel()->setFilePath ("");
2332 void Main::fileImportKDE4Bookmarks()
2334 ImportKDE4Bookmarks im;
2336 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2337 currentMapEditor()->getModel()->setFilePath ("");
2340 void Main::fileImportFirefoxBookmarks()
2342 Q3FileDialog *fd=new Q3FileDialog( this);
2343 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2344 fd->setMode (Q3FileDialog::ExistingFiles);
2345 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2346 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2349 if ( fd->exec() == QDialog::Accepted )
2351 ImportFirefoxBookmarks im;
2352 QStringList flist = fd->selectedFiles();
2353 QStringList::Iterator it = flist.begin();
2354 while( it != flist.end() )
2357 if (im.transform() &&
2358 aborted!=fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2359 currentMapEditor() )
2360 currentMapEditor()->getModel()->setFilePath ("");
2367 void Main::fileImportFreemind()
2369 QStringList filters;
2370 filters <<"Freemind map (*.mm)"<<"All files (*)";
2371 QFileDialog *fd=new QFileDialog( this);
2372 fd->setDir (lastFileDir);
2373 fd->setFileMode (QFileDialog::ExistingFiles);
2374 fd->setFilters (filters);
2375 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2379 if ( fd->exec() == QDialog::Accepted )
2381 lastFileDir=fd->directory().path();
2382 QStringList flist = fd->selectedFiles();
2383 QStringList::Iterator it = flist.begin();
2384 while( it != flist.end() )
2387 if ( fileLoad (fn,NewMap, FreemindMap) )
2389 currentMapEditor()->getModel()->setFilePath ("");
2398 void Main::fileImportMM()
2402 Q3FileDialog *fd=new Q3FileDialog( this);
2403 fd->setDir (lastFileDir);
2404 fd->setMode (Q3FileDialog::ExistingFiles);
2405 fd->addFilter ("Mind Manager (*.mmap)");
2406 fd->setCaption(tr("Import")+" "+"Mind Manager");
2409 if ( fd->exec() == QDialog::Accepted )
2411 lastFileDir=fd->dirPath();
2412 QStringList flist = fd->selectedFiles();
2413 QStringList::Iterator it = flist.begin();
2414 while( it != flist.end() )
2417 if (im.transform() &&
2418 success==fileLoad (im.getTransformedFile(),NewMap) &&
2419 currentMapEditor() )
2420 currentMapEditor()->getModel()->setFilePath ("");
2427 void Main::fileImportDir()
2429 VymModel *m=currentModel();
2430 if (m) m->importDir();
2433 void Main::fileExportXML()
2435 VymModel *m=currentModel();
2436 if (m) m->exportXML();
2439 void Main::fileExportHTML()
2441 VymModel *m=currentModel();
2442 if (m) m->exportHTML();
2445 void Main::fileExportImage()
2447 VymModel *m=currentModel();
2448 if (m) m->exportImage();
2451 void Main::fileExportAO()
2453 VymModel *m=currentModel();
2454 if (m) m->exportAO();
2457 void Main::fileExportASCII()
2459 VymModel *m=currentModel();
2460 if (m) m->exportASCII();
2463 void Main::fileExportCSV() //FIXME-3 not scriptable yet
2465 VymModel *m=currentModel();
2470 ex.addFilter ("CSV (*.csv)");
2471 ex.setDir(lastImageDir);
2472 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2473 if (ex.execDialog() )
2475 m->setExportMode(true);
2477 m->setExportMode(false);
2482 void Main::fileExportLaTeX() //FIXME-3 not scriptable yet
2484 VymModel *m=currentModel();
2489 ex.addFilter ("Tex (*.tex)");
2490 ex.setDir(lastImageDir);
2491 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2492 if (ex.execDialog() )
2494 m->setExportMode(true);
2496 m->setExportMode(false);
2501 void Main::fileExportKDE3Bookmarks() //FIXME-3 not scriptable yet
2503 ExportKDE3Bookmarks ex;
2504 VymModel *m=currentModel();
2512 void Main::fileExportKDE4Bookmarks() //FIXME-3 not scriptable yet
2514 ExportKDE4Bookmarks ex;
2515 VymModel *m=currentModel();
2523 void Main::fileExportTaskjuggler() //FIXME-3 not scriptable yet
2525 ExportTaskjuggler ex;
2526 VymModel *m=currentModel();
2530 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2531 ex.setDir(lastImageDir);
2532 ex.addFilter ("Taskjuggler (*.tjp)");
2533 if (ex.execDialog() )
2535 m->setExportMode(true);
2537 m->setExportMode(false);
2542 void Main::fileExportOOPresentation() //FIXME-3 not scriptable yet
2544 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2545 // TODO add preview in dialog
2546 //ImagePreview *p =new ImagePreview (fd);
2547 //fd->setContentsPreviewEnabled( TRUE );
2548 //fd->setContentsPreview( p, p );
2549 //fd->setPreviewMode( QFileDialog::Contents );
2550 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2551 fd->setDir (QDir().current());
2552 if (fd->foundConfig())
2556 if ( fd->exec() == QDialog::Accepted )
2558 QString fn=fd->selectedFile();
2559 if (!fn.contains (".odp"))
2562 //lastImageDir=fn.left(fn.findRev ("/"));
2563 VymModel *m=currentModel();
2564 if (m) m->exportOOPresentation(fn,fd->selectedConfig());
2568 QMessageBox::warning(0,
2570 tr("Couldn't find configuration for export to Open Office\n"));
2574 void Main::fileCloseMap()
2576 VymModel *m=currentModel();
2579 if (m->hasChanged())
2581 QMessageBox mb( vymName,
2582 tr("The map %1 has been modified but not saved yet. Do you want to").arg(m->getFileName()),
2583 QMessageBox::Warning,
2584 QMessageBox::Yes | QMessageBox::Default,
2586 QMessageBox::Cancel | QMessageBox::Escape );
2587 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2588 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2591 case QMessageBox::Yes:
2593 fileSave(m, CompleteMap);
2595 case QMessageBox::No:
2596 // close without saving
2598 case QMessageBox::Cancel:
2603 // And here comes the segfault, because removeTab triggers
2604 // FIXME-3 currentChanged->Main::editorChanged -> updateActions and VM is not NULL yet...
2605 vymViews.removeAt (tabWidget->currentIndex() );
2606 tabWidget->removeTab (tabWidget->currentIndex() );
2608 delete (m); // changing model still will try to update selection in editors, remove model first
2609 //delete (m->getMapEditor());
2615 void Main::filePrint()
2617 if (currentMapEditor())
2618 currentMapEditor()->print();
2621 void Main::fileExitVYM()
2623 // Check if one or more editors have changed
2625 for (i=0;i<=vymViews.count() -1;i++)
2627 // If something changed, ask what to do
2628 if (vymViews.at(i)->getModel()->hasChanged())
2630 tabWidget->setCurrentPage(i);
2631 QMessageBox mb( vymName,
2632 tr("This map is not saved yet. Do you want to"),
2633 QMessageBox::Warning,
2634 QMessageBox::Yes | QMessageBox::Default,
2636 QMessageBox::Cancel | QMessageBox::Escape );
2637 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2638 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2641 mb.setActiveWindow();
2642 switch( mb.exec() ) {
2643 case QMessageBox::Yes:
2644 // save (the changed editors) and exit
2645 fileSave(currentModel(), CompleteMap);
2647 case QMessageBox::No:
2648 // exit without saving
2650 case QMessageBox::Cancel:
2651 // don't save and don't exit
2655 } // loop over all MEs
2659 void Main::editUndo()
2661 VymModel *m=currentModel();
2665 void Main::editRedo()
2667 VymModel *m=currentModel();
2671 void Main::gotoHistoryStep (int i)
2673 VymModel *m=currentModel();
2674 if (m) m->gotoHistoryStep(i);
2677 void Main::editCopy()
2679 VymModel *m=currentModel();
2683 void Main::editPaste()
2685 VymModel *m=currentModel();
2689 void Main::editCut()
2691 VymModel *m=currentModel();
2695 void Main::editOpenFindWidget()
2697 if (!findWidget->isVisible())
2700 findWidget->setFocus();
2701 } else if (!findResultWidget->parentWidget()->isVisible())
2702 findResultWidget->parentWidget()->show();
2706 findResultWidget->parentWidget()->hide();
2710 void Main::editHideFindWidget()
2712 // findWidget hides itself, but we want
2713 // to have focus back at mapEditor usually
2714 MapEditor *me=currentMapEditor();
2715 if (me) me->setFocus();
2718 void Main::editFindNext(QString s)
2720 Qt::CaseSensitivity cs=Qt::CaseInsensitive;
2721 VymModel *m=currentModel();
2724 m->findAll (findResultWidget->getResultModel(),s,cs);
2726 BranchItem *bi=m->findText(s, cs);
2729 findWidget->setStatus (FindWidget::Success);
2732 findWidget->setStatus (FindWidget::Failed);
2736 void Main::editFindDuplicateURLs() //FIXME-4 feature: use FindResultWidget for display
2738 VymModel *m=currentModel();
2739 if (m) m->findDuplicateURLs();
2742 void Main::openTabs(QStringList urls)
2744 if (!urls.isEmpty())
2748 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2749 //qDebug ()<<"Services: "<<QDBusConnection::sessionBus().interface()->registeredServiceNames().value();
2750 if (*browserPID==0 ||
2751 (browser.contains("konqueror") &&
2752 !QDBusConnection::sessionBus().interface()->registeredServiceNames().value().contains (QString("org.kde.konqueror-%1").arg(*browserPID)))
2755 // Start a new browser, if there is not one running already or
2756 // if a previously started konqueror is gone.
2757 if (debug) cout <<"Main::openTabs no konqueror-"<<*browserPID<<" found\n";
2758 QString u=urls.takeFirst();
2760 QString workDir=QDir::currentDirPath();
2761 if (!QProcess::startDetached(browser,args,workDir,browserPID))
2763 // try to set path to browser
2764 QMessageBox::warning(0,
2766 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2767 tr("Please use Settings->")+tr("Set application to open an URL"));
2770 if (debug) cout << "Main::openTabs Started konqueror-"<<*browserPID<<endl;
2771 #if defined(Q_OS_WIN32)
2772 // There's no sleep in VCEE, replace it with Qt's QThread::wait().
2773 this->thread()->wait(3000);
2775 sleep (3); //FIXME-3 needed?
2779 if (browser.contains("konqueror"))
2781 for (int i=0; i<urls.size(); i++)
2784 // Try to open new tab in existing konqueror started previously by vym
2788 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2789 "konqueror-mainwindow#1"<<
2793 args<< QString("org.kde.konqueror-%1").arg(*browserPID)<<
2794 "/konqueror/MainWindow_1"<<
2798 if (debug) cout << "MainWindow::openURLs args="<<args.join(" ").toStdString()<<endl;
2799 if (!QProcess::startDetached ("qdbus",args))
2803 QMessageBox::warning(0,
2805 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2807 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2809 for (int i=0; i<urls.size(); i++)
2811 // Try to open new tab in firefox
2812 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2813 if (!QProcess::startDetached (browser,args))
2817 QMessageBox::warning(0,
2819 tr("Couldn't start %1 to open a new tab").arg(browser));
2822 QMessageBox::warning(0,
2824 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2828 void Main::editOpenURL()
2831 VymModel *m=currentModel();
2834 QString url=m->getURL();
2836 if (url=="") return;
2837 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2839 QString workDir=QDir::currentDirPath();
2840 if (!procBrowser->startDetached(browser,args))
2842 // try to set path to browser
2843 QMessageBox::warning(0,
2845 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2846 tr("Please use Settings->")+tr("Set application to open an URL"));
2851 void Main::editOpenURLTab()
2853 VymModel *m=currentModel();
2857 urls.append(m->getURL());
2862 void Main::editOpenMultipleVisURLTabs(bool ignoreScrolled)
2864 VymModel *m=currentModel();
2868 urls=m->getURLs(ignoreScrolled);
2873 void Main::editOpenMultipleURLTabs()
2875 editOpenMultipleVisURLTabs (false);
2879 void Main::editURL()
2881 VymModel *m=currentModel();
2882 if (m) m->editURL();
2885 void Main::editLocalURL()
2887 VymModel *m=currentModel();
2888 if (m) m->editLocalURL();
2891 void Main::editHeading2URL()
2893 VymModel *m=currentModel();
2894 if (m) m->editHeading2URL();
2897 void Main::editBugzilla2URL()
2899 VymModel *m=currentModel();
2900 if (m) m->editBugzilla2URL();
2903 void Main::getBugzillaData()
2905 VymModel *m=currentModel();
2907 QProgressDialog progress ("Doing stuff","cancl",0,10,this);
2908 progress.setWindowModality(Qt::WindowModal);
2909 //progress.setCancelButton (NULL);
2911 progress.setMinimumDuration (0);
2912 progress.setValue (1);
2913 progress.setValue (5);
2917 QProgressBar *pb=new QProgressBar;
2923 if (m) m->getBugzillaData();
2926 void Main::editFATE2URL()
2928 VymModel *m=currentModel();
2929 if (m) m->editFATE2URL();
2932 void Main::editHeadingFinished(VymModel *m)
2936 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2937 !prevSelection.isEmpty())
2938 m->select(prevSelection);
2943 void Main::openVymLinks(const QStringList &vl)
2945 for (int j=0; j<vl.size(); j++)
2947 // compare path with already loaded maps
2950 for (i=0;i<=vymViews.count() -1;i++)
2952 if (vl.at(j)==vymViews.at(i)->getModel()->getFilePath() )
2961 if (!QFile(vl.at(j)).exists() )
2962 QMessageBox::critical( 0, tr( "Critical Error" ),
2963 tr("Couldn't open map %1").arg(vl.at(j)));
2966 fileLoad (vl.at(j), NewMap);
2967 tabWidget->setCurrentIndex (tabWidget->count()-1);
2970 // Go to tab containing the map
2971 tabWidget->setCurrentIndex (index);
2975 void Main::editOpenVymLink()
2977 VymModel *m=currentModel();
2981 vl.append(m->getVymLink());
2986 void Main::editOpenMultipleVymLinks()
2988 QString currentVymLink;
2989 VymModel *m=currentModel();
2992 QStringList vl=m->getVymLinks();
2997 void Main::editVymLink()
2999 VymModel *m=currentModel();
3004 void Main::editDeleteVymLink()
3006 VymModel *m=currentModel();
3007 if (m) m->deleteVymLink();
3010 void Main::editToggleHideExport()
3012 VymModel *m=currentModel();
3013 if (m) m->toggleHideExport();
3016 void Main::editAddTimestamp()
3018 VymModel *m=currentModel();
3019 if (m) m->addTimestamp();
3022 void Main::editMapInfo()
3024 VymModel *m=currentModel();
3027 ExtraInfoDialog dia;
3028 dia.setMapName (m->getFileName() );
3029 dia.setAuthor (m->getAuthor() );
3030 dia.setComment(m->getComment() );
3034 stats+=tr("%1 items on map\n","Info about map").arg (m->getScene()->items().size(),6);
3040 BranchItem *cur=NULL;
3041 BranchItem *prev=NULL;
3042 m->nextBranch(cur,prev);
3045 if (!cur->getNote().isEmpty() ) n++;
3046 f+= cur->imageCount();
3048 xl+=cur->xlinkCount();
3049 m->nextBranch(cur,prev);
3052 stats+=QString ("%1 xLinks \n").arg (xl,6);
3053 stats+=QString ("%1 notes\n").arg (n,6);
3054 stats+=QString ("%1 images\n").arg (f,6);
3055 stats+=QString ("%1 branches\n").arg (m->branchCount(),6);
3056 dia.setStats (stats);
3058 // Finally show dialog
3059 if (dia.exec() == QDialog::Accepted)
3061 m->setAuthor (dia.getAuthor() );
3062 m->setComment (dia.getComment() );
3066 void Main::editMoveUp()
3068 VymModel *m=currentModel();
3072 void Main::editMoveDown()
3074 VymModel *m=currentModel();
3075 if (m) m->moveDown();
3078 void Main::editDetach()
3080 VymModel *m=currentModel();
3084 void Main::editSortChildren()
3086 VymModel *m=currentModel();
3087 if (m) m->sortChildren(false);
3090 void Main::editSortBackChildren()
3092 VymModel *m=currentModel();
3093 if (m) m->sortChildren(true);
3096 void Main::editToggleScroll()
3098 VymModel *m=currentModel();
3099 if (m) m->toggleScroll();
3102 void Main::editExpandAll()
3104 VymModel *m=currentModel();
3105 if (m) m->emitExpandAll();
3108 void Main::editExpandOneLevel()
3110 VymModel *m=currentModel();
3111 if (m) m->emitExpandOneLevel();
3114 void Main::editCollapseOneLevel()
3116 VymModel *m=currentModel();
3117 if (m) m->emitCollapseOneLevel();
3120 void Main::editUnscrollChildren()
3122 VymModel *m=currentModel();
3123 if (m) m->unscrollChildren();
3126 void Main::editAddAttribute()
3128 VymModel *m=currentModel();
3136 void Main::editAddMapCenter()
3138 VymModel *m=currentModel();
3139 if (m) m->select (m->addMapCenter ());
3142 void Main::editNewBranch()
3144 VymModel *m=currentModel();
3147 BranchItem *bi=m->addNewBranch();
3150 if (actionSettingsAutoEditNewBranch->isOn()
3151 && !actionSettingsAutoSelectNewBranch->isOn() )
3152 prevSelection=m->getSelectString();
3154 prevSelection=QString();
3156 if (actionSettingsAutoSelectNewBranch->isOn()
3157 || actionSettingsAutoEditNewBranch->isOn())
3160 if (actionSettingsAutoEditNewBranch->isOn())
3161 currentMapEditor()->editHeading();
3166 void Main::editNewBranchBefore()
3168 VymModel *m=currentModel();
3171 BranchItem *bi=m->addNewBranchBefore();
3178 if (actionSettingsAutoEditNewBranch->isOn())
3180 if (!actionSettingsAutoSelectNewBranch->isOn())
3181 prevSelection=m->getSelectString(bi);
3182 currentMapEditor()->editHeading();
3187 void Main::editNewBranchAbove()
3189 VymModel *m=currentModel();
3192 BranchItem *bi=m->addNewBranch (-1);
3200 if (actionSettingsAutoEditNewBranch->isOn())
3202 if (!actionSettingsAutoSelectNewBranch->isOn())
3203 prevSelection=m->getSelectString (bi);
3204 currentMapEditor()->editHeading();
3209 void Main::editNewBranchBelow()
3211 VymModel *m=currentModel();
3214 BranchItem *bi=m->addNewBranch (1);
3221 if (actionSettingsAutoEditNewBranch->isOn())
3223 if (!actionSettingsAutoSelectNewBranch->isOn())
3224 prevSelection=m->getSelectString(bi);
3225 currentMapEditor()->editHeading();
3230 void Main::editImportAdd()
3232 fileLoad (ImportAdd);
3235 void Main::editImportReplace()
3237 fileLoad (ImportReplace);
3240 void Main::editSaveBranch()
3242 fileSaveAs (PartOfMap);
3245 void Main::editDeleteKeepChildren()
3247 VymModel *m=currentModel();
3248 if (m) m->deleteKeepChildren();
3251 void Main::editDeleteChildren()
3253 VymModel *m=currentModel();
3254 if (m) m->deleteChildren();
3257 void Main::editDeleteSelection()
3259 VymModel *m=currentModel();
3260 if (m && actionSettingsUseDelKey->isOn())
3261 m->deleteSelection();
3264 void Main::editLoadImage()
3266 VymModel *m=currentModel();
3267 if (m) m->loadFloatImage();
3270 void Main::editSaveImage()
3272 VymModel *m=currentModel();
3273 if (m) m->saveFloatImage();
3276 void Main::editEditXLink(QAction *a)
3278 VymModel *m=currentModel();
3280 m->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3283 void Main::formatSelectColor()
3285 QColor col = QColorDialog::getColor((currentColor ), this );
3286 if ( !col.isValid() ) return;
3287 colorChanged( col );
3290 void Main::formatPickColor()
3292 VymModel *m=currentModel();
3294 colorChanged( m->getCurrentHeadingColor() );
3297 void Main::colorChanged(QColor c)
3299 QPixmap pix( 16, 16 );
3301 actionFormatColor->setIconSet( pix );
3305 void Main::formatColorBranch()
3307 VymModel *m=currentModel();
3308 if (m) m->colorBranch(currentColor);
3311 void Main::formatColorSubtree()
3313 VymModel *m=currentModel();
3314 if (m) m->colorSubtree (currentColor);
3317 void Main::formatLinkStyleLine()
3319 VymModel *m=currentModel();
3322 m->setMapLinkStyle("StyleLine");
3323 actionFormatLinkStyleLine->setChecked(true);
3327 void Main::formatLinkStyleParabel()
3329 VymModel *m=currentModel();
3332 m->setMapLinkStyle("StyleParabel");
3333 actionFormatLinkStyleParabel->setChecked(true);
3337 void Main::formatLinkStylePolyLine()
3339 VymModel *m=currentModel();
3342 m->setMapLinkStyle("StylePolyLine");
3343 actionFormatLinkStylePolyLine->setChecked(true);
3347 void Main::formatLinkStylePolyParabel()
3349 VymModel *m=currentModel();
3352 m->setMapLinkStyle("StylePolyParabel");
3353 actionFormatLinkStylePolyParabel->setChecked(true);
3357 void Main::formatSelectBackColor()
3359 VymModel *m=currentModel();
3360 if (m) m->selectMapBackgroundColor();
3363 void Main::formatSelectBackImage()
3365 VymModel *m=currentModel();
3367 m->selectMapBackgroundImage();
3370 void Main::formatSelectLinkColor()
3372 VymModel *m=currentModel();
3375 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3376 m->setMapDefLinkColor( col );
3380 void Main::formatSelectSelectionColor()
3382 VymModel *m=currentModel();
3385 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3386 m->setSelectionColor (col);
3391 void Main::formatToggleLinkColorHint()
3393 VymModel *m=currentModel();
3394 if (m) m->toggleMapLinkColorHint();
3398 void Main::formatHideLinkUnselected() //FIXME-3 get rid of this with imagepropertydialog
3400 VymModel *m=currentModel();
3402 m->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3405 void Main::viewZoomReset()
3407 MapEditor *me=currentMapEditor();
3408 if (me) me->setZoomFactorTarget (1);
3411 void Main::viewZoomIn()
3413 MapEditor *me=currentMapEditor();
3414 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*1.15);
3417 void Main::viewZoomOut()
3419 MapEditor *me=currentMapEditor();
3420 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*0.85);
3423 void Main::viewCenter()
3425 VymModel *m=currentModel();
3426 if (m) m->emitShowSelection();
3429 void Main::networkStartServer()
3431 VymModel *m=currentModel();
3432 if (m) m->newServer();
3435 void Main::networkConnect()
3437 VymModel *m=currentModel();
3438 if (m) m->connectToServer();
3441 bool Main::settingsPDF()
3443 // Default browser is set in constructor
3445 QString text = QInputDialog::getText(
3446 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3447 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3449 settings.setValue ("/mainwindow/readerPDF",text);
3454 bool Main::settingsURL()
3456 // Default browser is set in constructor
3458 QString text = QInputDialog::getText(
3459 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3460 settings.value("/mainwindow/readerURL").toString()
3463 settings.setValue ("/mainwindow/readerURL",text);
3467 void Main::settingsMacroDir()
3469 QDir defdir(vymBaseDir.path() + "/macros");
3470 if (!defdir.exists())
3472 QDir dir=QFileDialog::getExistingDirectory (
3474 tr ("Directory with vym macros:"),
3475 settings.value ("/macros/macroDir",defdir.path()).toString()
3478 settings.setValue ("/macros/macroDir",dir.absolutePath());
3481 void Main::settingsUndoLevels()
3484 int i = QInputDialog::getInteger(
3486 tr("QInputDialog::getInteger()"),
3487 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3490 settings.setValue ("/mapeditor/stepsTotal",i);
3491 QMessageBox::information( this, tr( "VYM -Information:" ),
3492 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3496 void Main::settingsAutosaveToggle()
3498 settings.setValue ("/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
3501 void Main::settingsAutosaveTime()
3504 int i = QInputDialog::getInteger(
3506 tr("QInputDialog::getInteger()"),
3507 tr("Number of seconds before autosave:"), settings.value("/mainwindow/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3509 settings.setValue ("/mainwindow/autosave/ms",i * 1000);
3512 void Main::settingsAutoLayoutToggle()
3514 settings.setValue ("/mainwindow/autoLayout/use",actionSettingsAutosaveToggle->isOn() );
3517 void Main::settingsWriteBackupFileToggle()
3519 settings.setValue ("/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
3522 void Main::settingsToggleAnimation()
3524 settings.setValue ("/animation/use",actionSettingsUseAnimation->isOn() );
3527 void Main::settingsToggleDelKey()
3529 if (actionSettingsUseDelKey->isOn())
3531 actionDelete->setAccel (QKeySequence (Qt::Key_Delete));
3534 actionDelete->setAccel (QKeySequence (""));
3538 void Main::windowToggleNoteEditor()
3540 if (textEditor->isVisible() )
3541 windowHideNoteEditor();
3543 windowShowNoteEditor();
3546 void Main::windowToggleTreeEditor()
3548 if ( tabWidget->currentPage())
3549 vymViews.at(tabWidget->currentIndex())->toggleTreeEditor();
3552 void Main::windowToggleHistory()
3554 if (historyWindow->isVisible())
3555 historyWindow->hide();
3557 historyWindow->show();
3561 void Main::windowToggleProperty()
3563 if (branchPropertyWindow->isVisible())
3564 branchPropertyWindow->hide();
3566 branchPropertyWindow->show();
3567 branchPropertyWindow->setModel (currentModel() );
3570 void Main::windowToggleAntiAlias()
3572 bool b=actionViewToggleAntiAlias->isOn();
3574 for (int i=0;i<vymViews.count();i++)
3576 me=vymViews.at(i)->getMapEditor();
3577 if (me) me->setAntiAlias(b);
3582 bool Main::isAliased()
3584 return actionViewToggleAntiAlias->isOn();
3587 bool Main::hasSmoothPixmapTransform()
3589 return actionViewToggleSmoothPixmapTransform->isOn();
3592 void Main::windowToggleSmoothPixmap()
3594 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3596 for (int i=0;i<vymViews.count();i++)
3599 me=vymViews.at(i)->getMapEditor();
3600 if (me) me->setSmoothPixmap(b);
3604 void Main::updateHistory(SimpleSettings &undoSet)
3606 historyWindow->update (undoSet);
3609 void Main::updateNoteFlag()
3611 // this slot is connected to TextEditor::textHasChanged()
3612 VymModel *m=currentModel();
3613 if (m) m->updateNoteFlag();
3616 void Main::updateNoteEditor(QModelIndex index )
3618 TreeItem *ti=((VymModel*) QObject::sender())->getItem(index);
3620 cout << "Main::updateNoteEditor model="<<sender();
3621 cout << " item="<<ti->getHeadingStd()<<" ("<<ti<<")"<<endl;
3623 textEditor->setNote (ti->getNoteObj() );
3626 void Main::selectInNoteEditor(QString s,int i)
3628 // TreeItem is already selected at this time, therefor
3629 // the note is already in the editor
3630 textEditor->findText (s,0,i);
3633 void Main::changeSelection (VymModel *model, const QItemSelection &newsel, const QItemSelection &oldsel)
3635 branchPropertyWindow->setModel (model ); //FIXME-3 this used to be called from BranchObj::select(). Maybe use signal now...
3637 if (model && model==currentModel() )
3641 if (!oldsel.indexes().isEmpty() )
3643 ti=model->getItem(oldsel.indexes().first());
3645 // Don't update note if both treeItem and textEditor are empty
3646 //if (! (ti->hasEmptyNote() && textEditor->isEmpty() ))
3647 // ti->setNoteObj (textEditor->getNoteObj(),false );
3649 if (!newsel.indexes().isEmpty() )
3651 ti=model->getItem(newsel.indexes().first());
3652 if (!ti->hasEmptyNote() )
3653 textEditor->setNote(ti->getNoteObj() );
3655 textEditor->setNote(NoteObj() ); //FIXME-4 maybe add a clear() to TE
3657 // Show URL and link in statusbar
3659 QString s=ti->getURL();
3660 if (!s.isEmpty() ) status+="URL: "+s+" ";
3662 if (!s.isEmpty() ) status+="Link: "+s;
3663 if (!status.isEmpty() ) statusMessage (status);
3666 textEditor->setInactive();
3672 void Main::updateActions()
3674 // updateActions is also called when satellites are closed //FIXME-2 doesn't update immediatly, e.g. historyWindow is still visible, when "close" is pressed
3675 actionViewToggleNoteEditor->setChecked (textEditor->isVisible());
3676 actionViewToggleHistoryWindow->setChecked (historyWindow->isVisible());
3677 actionViewTogglePropertyWindow->setChecked (branchPropertyWindow->isVisible());
3678 if ( tabWidget->currentPage())
3679 actionViewToggleTreeEditor->setChecked (
3680 vymViews.at(tabWidget->currentIndex())->getTreeEditor()->isVisible()
3683 VymModel *m =currentModel();
3687 actionFilePrint->setEnabled (true);
3689 // Link style in context menu
3690 switch (m->getMapLinkStyle())
3692 case LinkableMapObj::Line:
3693 actionFormatLinkStyleLine->setChecked(true);
3695 case LinkableMapObj::Parabel:
3696 actionFormatLinkStyleParabel->setChecked(true);
3698 case LinkableMapObj::PolyLine:
3699 actionFormatLinkStylePolyLine->setChecked(true);
3701 case LinkableMapObj::PolyParabel:
3702 actionFormatLinkStylePolyParabel->setChecked(true);
3709 QPixmap pix( 16, 16 );
3710 pix.fill( m->getMapBackgroundColor() );
3711 actionFormatBackColor->setIconSet( pix );
3712 pix.fill( m->getSelectionColor() );
3713 actionFormatSelectionColor->setIconSet( pix );
3714 pix.fill( m->getMapDefLinkColor() );
3715 actionFormatLinkColor->setIconSet( pix );
3718 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName()));
3721 // Expanding/collapsing
3722 actionExpandAll->setEnabled (true);
3723 actionExpandOneLevel->setEnabled (true);
3724 actionCollapseOneLevel->setEnabled (true);
3728 actionFilePrint->setEnabled (false);
3730 // Expanding/collapsing
3731 actionExpandAll->setEnabled (false);
3732 actionExpandOneLevel->setEnabled (false);
3733 actionCollapseOneLevel->setEnabled (false);
3736 if (m && m->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3737 actionFormatLinkColorHint->setChecked(true);
3739 actionFormatLinkColorHint->setChecked(false);
3742 if (m && m->hasChanged() )
3743 actionFileSave->setEnabled( true);
3745 actionFileSave->setEnabled( false);
3746 if (m && m->isUndoAvailable())
3747 actionUndo->setEnabled( true);
3749 actionUndo->setEnabled( false);
3751 if (m && m->isRedoAvailable())
3752 actionRedo->setEnabled( true);
3754 actionRedo->setEnabled( false);
3758 TreeItem *selti=m->getSelectedItem();
3759 BranchItem *selbi=m->getSelectedBranch();
3762 if (selbi || selti->getType()==TreeItem::Image)
3764 actionFormatHideLinkUnselected->setChecked (((MapItem*)selti)->getHideLinkUnselected());
3765 actionFormatHideLinkUnselected->setEnabled (true);
3770 // Take care of xlinks
3771 branchXLinksContextMenuEdit->clear();
3772 if (selbi->xlinkCount()>0)
3776 for (int i=0; i<selbi->xlinkCount();++i)
3778 bi=selbi->getXLinkNum(i)->getPartnerBranch();
3782 if (s.length()>xLinkMenuWidth)
3783 s=s.left(xLinkMenuWidth)+"...";
3784 branchXLinksContextMenuEdit->addAction (s);
3789 standardFlagsMaster->updateToolBar (selbi->activeStandardFlagNames() );
3792 actionToggleScroll->setEnabled (true);
3793 if ( selbi->isScrolled() )
3794 actionToggleScroll->setChecked(true);
3796 actionToggleScroll->setChecked(false);
3798 if ( selti->getURL().isEmpty() )
3800 actionOpenURL->setEnabled (false);
3801 actionOpenURLTab->setEnabled (false);
3805 actionOpenURL->setEnabled (true);
3806 actionOpenURLTab->setEnabled (true);
3808 if ( selti->getVymLink().isEmpty() )
3810 actionOpenVymLink->setEnabled (false);
3811 actionDeleteVymLink->setEnabled (false);
3814 actionOpenVymLink->setEnabled (true);
3815 actionDeleteVymLink->setEnabled (true);
3818 if (selbi->canMoveUp())
3819 actionMoveUp->setEnabled (true);
3821 actionMoveUp->setEnabled (false);
3822 if (selbi->canMoveDown())
3823 actionMoveDown->setEnabled (true);
3825 actionMoveDown->setEnabled (false);
3827 actionSortChildren->setEnabled (true);
3828 actionSortBackChildren->setEnabled (true);
3830 actionToggleHideExport->setEnabled (true);
3831 actionToggleHideExport->setChecked (selbi->hideInExport() );
3833 actionCopy->setEnabled (true);
3834 actionCut->setEnabled (true);
3835 if (!clipboardEmpty)
3836 actionPaste->setEnabled (true);
3838 actionPaste->setEnabled (false);
3839 for (int i=0; i<actionListBranches.size(); ++i)
3840 actionListBranches.at(i)->setEnabled(true);
3841 actionDelete->setEnabled (true);
3843 if ( selti->getType()==TreeItem::Image)
3845 actionOpenURL->setEnabled (false);
3846 actionOpenVymLink->setEnabled (false);
3847 actionDeleteVymLink->setEnabled (false);
3848 actionToggleHideExport->setEnabled (true);
3849 actionToggleHideExport->setChecked (selti->hideInExport() );
3852 actionCopy->setEnabled (true);
3853 actionCut->setEnabled (true);
3854 actionPaste->setEnabled (false); //FIXME-4 why not allowing copy of images?
3855 for (int i=0; i<actionListBranches.size(); ++i)
3856 actionListBranches.at(i)->setEnabled(false);
3857 actionDelete->setEnabled (true);
3858 actionMoveUp->setEnabled (false);
3859 actionMoveDown->setEnabled (false);
3864 actionCopy->setEnabled (false);
3865 actionCut->setEnabled (false);
3866 actionPaste->setEnabled (false);
3867 for (int i=0; i<actionListBranches.size(); ++i)
3868 actionListBranches.at(i)->setEnabled(false);
3870 actionToggleScroll->setEnabled (false);
3871 actionOpenURL->setEnabled (false);
3872 actionOpenVymLink->setEnabled (false);
3873 actionDeleteVymLink->setEnabled (false);
3874 actionHeading2URL->setEnabled (false);
3875 actionDelete->setEnabled (false);
3876 actionMoveUp->setEnabled (false);
3877 actionMoveDown->setEnabled (false);
3878 actionFormatHideLinkUnselected->setEnabled (false);
3879 actionSortChildren->setEnabled (false);
3880 actionSortBackChildren->setEnabled (false);
3881 actionToggleHideExport->setEnabled (false);
3886 Main::ModMode Main::getModMode()
3888 if (actionModModeColor->isOn()) return ModModeColor;
3889 if (actionModModeCopy->isOn()) return ModModeCopy;
3890 if (actionModModeXLink->isOn()) return ModModeXLink;
3894 bool Main::autoEditNewBranch()
3896 return actionSettingsAutoEditNewBranch->isOn();
3899 bool Main::autoSelectNewBranch()
3901 return actionSettingsAutoSelectNewBranch->isOn();
3904 void Main::windowShowNoteEditor()
3906 textEditor->setShowWithMain(true);
3908 actionViewToggleNoteEditor->setChecked (true);
3911 void Main::windowHideNoteEditor()
3913 textEditor->setShowWithMain(false);
3915 actionViewToggleNoteEditor->setChecked (false);
3918 void Main::setScript (const QString &script)
3920 scriptEditor->setScript (script);
3923 void Main::runScript (const QString &script)
3925 VymModel *m=currentModel();
3926 if (m) m->runScript (script);
3929 void Main::runScriptEverywhere (const QString &script)
3932 for (int i=0;i<=tabWidget->count() -1;i++)
3934 me=(MapEditor*)tabWidget->page(i);
3935 if (me) me->getModel()->runScript (script);
3939 void Main::windowNextEditor()
3941 if (tabWidget->currentIndex() < tabWidget->count())
3942 tabWidget->setCurrentIndex (tabWidget->currentIndex() +1);
3945 void Main::windowPreviousEditor()
3947 if (tabWidget->currentIndex() >0)
3948 tabWidget->setCurrentIndex (tabWidget->currentIndex() -1);
3951 void Main::standardFlagChanged()
3955 if ( actionSettingsUseFlagGroups->isOn() )
3956 currentModel()->toggleStandardFlag(sender()->name(),standardFlagsMaster);
3958 currentModel()->toggleStandardFlag(sender()->name());
3964 void Main::testFunction1()
3967 #include "attributeitem.h"
3968 VymModel *m=currentModel();
3971 BranchItem *selbi=m->getSelectedBranch();
3974 QList<QVariant> cData;
3975 cData << "new ai" << "undef";
3977 AttributeItem *ai=new AttributeItem (cData,selbi);
3978 ai->set ("Key 1","Val a",AttributeItem::FreeString);
3980 m->addAttribute (ai);
3984 if (!currentMapEditor()) return;
3985 currentMapEditor()->testFunction1();
3988 void Main::testFunction2()
3990 if (!currentMapEditor()) return;
3991 currentMapEditor()->testFunction2();
3994 void Main::testCommand()
3996 if (!currentMapEditor()) return;
3997 scriptEditor->show();
4000 QString com = QInputDialog::getText(
4001 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
4002 if (ok) currentMapEditor()->parseAtom(com);
4006 void Main::helpDoc()
4008 QString locale = QLocale::system().name();
4010 if (locale.left(2)=="es")
4011 docname="vym_es.pdf";
4015 QStringList searchList;
4017 #if defined(Q_OS_MACX)
4018 searchList << "./vym.app/Contents/Resources/doc";
4019 #elif defined(Q_OS_WIN32)
4020 searchList << vymInstallDir.path() + "/share/doc/packages/vym";
4022 #if defined(VYM_DOCDIR)
4023 searchList << VYM_DOCDIR;
4025 // default path in SUSE LINUX
4026 searchList << "/usr/share/doc/packages/vym";
4029 searchList << "doc"; // relative path for easy testing in tarball
4030 searchList << "doc/tex"; // Easy testing working on vym.tex
4031 searchList << "/usr/share/doc/vym"; // Debian
4032 searchList << "/usr/share/doc/packages";// Knoppix
4036 for (int i=0; i<searchList.count(); ++i)
4038 docfile.setFileName(searchList.at(i)+"/"+docname);
4039 if (docfile.exists())
4048 QMessageBox::critical(0,
4049 tr("Critcal error"),
4050 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
4055 Process *pdfProc = new Process();
4056 args << QDir::toNativeSeparators(docfile.fileName());
4058 if (!pdfProc->startDetached( settings.value("/mainwindow/readerPDF").toString(),args) )
4061 QMessageBox::warning(0,
4063 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
4064 tr("Please use Settings->")+tr("Set application to open PDF files"));
4071 void Main::helpDemo()
4073 QStringList filters;
4074 filters <<"VYM example map (*.vym)";
4075 QFileDialog *fd=new QFileDialog( this);
4076 #if defined(Q_OS_MACX)
4077 fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
4079 // default path in SUSE LINUX
4080 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
4083 fd->setFileMode (QFileDialog::ExistingFiles);
4084 fd->setFilters (filters);
4085 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
4089 if ( fd->exec() == QDialog::Accepted )
4091 lastFileDir=fd->directory().path();
4092 QStringList flist = fd->selectedFiles();
4093 QStringList::Iterator it = flist.begin();
4094 while( it != flist.end() )
4097 fileLoad(*it, NewMap);
4105 void Main::helpAbout()
4108 ad.setName ("aboutwindow");
4109 ad.setMinimumSize(500,500);
4110 ad.resize (QSize (500,500));
4114 void Main::helpAboutQT()
4116 QMessageBox::aboutQt( this, "Qt Application Example" );
4119 void Main::callMacro ()
4121 QAction *action = qobject_cast<QAction *>(sender());
4125 i=action->data().toInt();
4126 QString mDir (settings.value ("macros/macroDir").toString() );
4128 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
4130 if ( !f.open( QIODevice::ReadOnly ) )
4132 QMessageBox::warning(0,
4134 tr("Couldn't find a macro at %1.\n").arg(fn)+
4135 tr("Please use Settings->")+tr("Set directory for vym macros"));
4139 QTextStream ts( &f );
4140 QString macro= ts.read();
4142 if (! macro.isEmpty())
4144 VymModel *m=currentModel();
4145 if (m) m->runScript(macro);