1 #include "mainwindow.h"
7 #include "aboutdialog.h"
8 #include "branchpropwindow.h"
9 #include "exportoofiledialog.h"
11 #include "exportxhtmldialog.h"
13 #include "flagrowobj.h"
14 #include "historywindow.h"
16 #include "mapeditor.h"
21 #include "texteditor.h"
22 #include "warningdialog.h"
24 extern TextEditor *textEditor;
25 extern Main *mainWindow;
26 extern QString tmpVymDir;
27 extern QString clipboardDir;
28 extern bool clipboardEmpty;
29 extern int statusbarTime;
30 extern FlagRowObj* standardFlagsDefault;
31 extern FlagRowObj* systemFlagsDefault;
32 extern QString vymName;
33 extern QString vymVersion;
34 extern QString vymBuildDate;
36 QMenu* branchContextMenu;
37 QMenu* branchAddContextMenu;
38 QMenu* branchRemoveContextMenu;
39 QMenu* branchLinksContextMenu;
40 QMenu* branchXLinksContextMenuEdit;
41 QMenu* branchXLinksContextMenuFollow;
42 QMenu* floatimageContextMenu;
43 QMenu* canvasContextMenu;
44 QMenu* fileLastMapsMenu;
45 QMenu* fileImportMenu;
46 QMenu* fileExportMenu;
49 extern Settings settings;
50 extern Options options;
51 extern ImageIO imageIO;
53 extern QDir vymBaseDir;
54 extern QDir lastImageDir;
55 extern QDir lastFileDir;
56 extern QString iconPath;
57 extern QString flagsPath;
59 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
60 QMainWindow(parent,name,f)
64 setCaption ("VYM - View Your Mind");
66 // Load window settings
67 resize (settings.value( "/mainwindow/geometry/size",QSize (800,600)).toSize());
68 move (settings.value( "/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
71 // Sometimes we may need to remember old selections
75 currentColor=Qt::black;
77 // Create unique temporary directory
79 tmpVymDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
82 qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
86 // Create direcctory for clipboard
87 clipboardDir=tmpVymDir+"/clipboard";
89 d.mkdir (clipboardDir,true);
90 makeSubDirs (clipboardDir);
95 // Initialize history window;
96 historyWindow=new HistoryWindow();
98 // Initialize properties window
99 branchPropertyWindow = new BranchPropertyWindow();
100 branchPropertyWindow->move (20,20);
102 // Initialize script editor
103 scriptEditor = new SimpleScriptEditor();
104 scriptEditor->move (50,50);
106 connect( scriptEditor, SIGNAL( runScript ( QString ) ),
107 this, SLOT( runScript( QString ) ) );
109 // Initialize some settings, which are platform dependant
112 // application to open URLs
113 p="/mainwindow/readerURL";
114 #if defined(Q_OS_LINUX)
115 s=settings.value (p,"konqueror").toString();
117 #if defined(Q_OS_MACX)
118 s=settings.value (p,"/usr/bin/open").toString();
120 s=settings.value (p,"mozilla");
123 settings.setValue( p,s);
125 // application to open PDFs
126 p="/mainwindow/readerPDF";
127 #if defined(Q_OS_LINUX)
128 s=settings.value (p,"acroread").toString();
130 #if defined(Q_OS_MACX)
131 s=settings.value (p,"/usr/bin/open").toString();
133 s=settings.value (p,"acroread").toString();
136 settings.setValue( p,s);
139 // Create tab widget which holds the maps
140 tabWidget= new QTabWidget (this);
141 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
142 this, SLOT( editorChanged( QWidget * ) ) );
144 lineedit=new QLineEdit (this);
147 setCentralWidget(tabWidget);
151 setupFormatActions();
155 setupSettingsActions();
157 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
162 restoreState (settings.value("/mainwindow/state",0).toByteArray());
164 // Satellite windows //////////////////////////////////////////
166 // Initialize Find window
167 findWindow=new FindWindow(NULL);
168 findWindow->move (x(),y()+70);
169 connect (findWindow, SIGNAL( findButton(QString) ),
170 this, SLOT(editFind(QString) ) );
171 connect (findWindow, SIGNAL( somethingChanged() ),
172 this, SLOT(editFindChanged() ) );
174 // Connect TextEditor, so that we can update flags if text changes
175 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
176 connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
178 // Connect HistoryWindow, so that we can update flags
179 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
187 settings.setValue ( "/mainwindow/geometry/size", size() );
188 settings.setValue ( "/mainwindow/geometry/pos", pos() );
189 settings.setValue ("/mainwindow/state",saveState(0));
191 settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
192 settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
193 settings.setValue( "/version/version", vymVersion );
194 settings.setValue( "/version/builddate", vymBuildDate );
196 settings.setValue( "/mapeditor/editmode/autoSelectHeading",actionSettingsAutoSelectHeading->isOn() );
197 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
198 settings.setValue( "/mapeditor/editmode/autoEdit",actionSettingsAutoEdit->isOn() );
199 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
200 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
201 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
203 //FIXME save branchPropWindow settings
204 //FIXME save scriptEditor settings
206 // call the destructors
208 delete historyWindow;
210 // Remove temporary directory
211 removeDir (QDir(tmpVymDir));
214 void Main::loadCmdLine()
216 /* TODO draw some kind of splashscreen while loading...
222 QStringList flist=options.getFileList();
223 QStringList::Iterator it=flist.begin();
225 while (it !=flist.end() )
227 fileLoad (*it, NewMap);
233 void Main::statusMessage(const QString &s)
235 statusBar()->message (s);
238 void Main::closeEvent (QCloseEvent* )
244 void Main::setupFileActions()
246 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
247 QToolBar *tb = addToolBar( tr ("&Map") );
248 tb->setObjectName ("mapTB");
251 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New...","File menu" ),this);
252 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
253 a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map
255 fileMenu->addAction (a);
256 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
258 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
259 a->setStatusTip (tr( "Open","Status tip File menu" ) );
260 a->setShortcut ( Qt::CTRL + Qt::Key_O ); //Open map
262 fileMenu->addAction (a);
263 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
265 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
266 fileMenu->addSeparator();
268 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
269 a->setStatusTip ( tr( "Save","Status tip file menu" ));
270 a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map
272 fileMenu->addAction (a);
273 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
276 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
277 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
278 fileMenu->addAction (a);
279 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
281 fileMenu->addSeparator();
283 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
285 a = new QAction(tr("KDE Bookmarks"), this);
286 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE bookmarks")));
287 a->addTo (fileImportMenu);
288 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) );
290 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
292 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
293 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
294 a->addTo (fileImportMenu);
295 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
298 a = new QAction("Mind Manager...",this);
299 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
300 fileImportMenu->addAction (a);
301 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
303 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
304 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
305 fileImportMenu->addAction (a);
306 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
308 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
310 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
311 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
312 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
313 fileExportMenu->addAction (a);
315 a = new QAction( "Open Office...", this);
316 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
317 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
318 fileExportMenu->addAction (a);
320 a = new QAction( "Webpage (XHTML)...",this );
321 a->setShortcut (Qt::ALT + Qt::Key_X); //Export XHTML
322 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
323 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
324 fileExportMenu->addAction (a);
326 a = new QAction( "Text (ASCII)...", this);
327 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
328 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
329 fileExportMenu->addAction (a);
331 a = new QAction( tr("KDE Bookmarks","File menu"), this);
332 a->setStatusTip( tr( "Export as %1").arg(tr("KDE Bookmarks" )));
333 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
334 fileExportMenu->addAction (a);
336 a = new QAction( "Taskjuggler...", this );
337 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
338 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
339 fileExportMenu->addAction (a);
341 a = new QAction( "LaTeX...", this);
342 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
343 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
344 fileExportMenu->addAction (a);
346 a = new QAction( "XML..." , this );
347 a->setStatusTip (tr( "Export as %1").arg("XML"));
348 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
349 fileExportMenu->addAction (a);
351 fileMenu->addSeparator();
353 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
354 a->setStatusTip ( tr( "Print" ,"File menu") );
355 a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map
357 fileMenu->addAction (a);
358 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
361 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
362 a->setStatusTip (tr( "Close Map" ) );
363 a->setShortcut (Qt::ALT + Qt::Key_C ); //Close map
364 fileMenu->addAction (a);
365 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
367 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
368 a->setStatusTip ( tr( "Exit")+" "+vymName );
369 a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym
370 fileMenu->addAction (a);
371 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
376 void Main::setupEditActions()
378 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
379 tb->setLabel( "Edit Actions" );
380 tb->setObjectName ("actionsTB");
381 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
385 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
386 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
387 a->setStatusTip (tr( "Undo" ) );
388 a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action
389 a->setEnabled (false);
391 editMenu->addAction (a);
394 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
395 a->setStatusTip (tr( "Redo" ));
396 a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action
398 editMenu->addAction (a);
399 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
402 editMenu->addSeparator();
403 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
404 a->setStatusTip ( tr( "Copy" ) );
405 a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy
406 a->setEnabled (false);
408 editMenu->addAction (a);
409 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
412 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
413 a->setStatusTip ( tr( "Cut" ) );
414 a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut
415 a->setEnabled (false);
417 editMenu->addAction (a);
419 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
421 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
422 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
423 a->setStatusTip ( tr( "Paste" ) );
424 a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste
425 a->setEnabled (false);
427 editMenu->addAction (a);
430 // Shortcuts to modify heading:
431 a = new QAction(tr( "Edit heading","Edit menu" ),this);
432 a->setStatusTip ( tr( "edit Heading" ));
433 a->setShortcut ( Qt::Key_Enter); //Edit heading
434 // a->setShortcutContext (Qt::WindowShortcut);
436 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
437 actionListBranches.append(a);
438 a = new QAction( tr( "Edit heading","Edit menu" ), this);
439 a->setStatusTip (tr( "edit Heading" ));
440 a->setShortcut (Qt::Key_Return ); //Edit heading
441 //a->setShortcutContext (Qt::WindowShortcut);
443 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
444 actionListBranches.append(a);
445 editMenu->addAction (a);
447 a = new QAction( tr( "Edit heading","Edit menu" ), this);
448 a->setStatusTip (tr( "edit Heading" ));
449 a->setShortcut ( Qt::Key_F2 ); //Edit heading
450 a->setShortcutContext (Qt::WindowShortcut);
452 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
453 actionListBranches.append(a);
455 // Shortcut to delete selection
456 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
457 a->setStatusTip (tr( "Delete Selection" ));
458 a->setShortcut ( Qt::Key_Delete); //Delete selection
459 a->setShortcutContext (Qt::WindowShortcut);
461 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
464 // Shortcut to add branch
465 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
466 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
467 alt->setShortcut (Qt::Key_A); //Add branch
468 alt->setShortcutContext (Qt::WindowShortcut);
470 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
471 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
472 a->setStatusTip ( tr( "Add a branch as child of selection" ));
473 a->setShortcut (Qt::Key_Insert); //Add branch
474 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
475 actionListBranches.append(a);
476 #if defined (Q_OS_MACX)
477 // In OSX show different shortcut in menues, the keys work indepently always
478 actionEditAddBranch=alt;
480 actionEditAddBranch=a;
482 editMenu->addAction (actionEditAddBranch);
483 tb->addAction (actionEditAddBranch);
486 // Add branch by inserting it at selection
487 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
488 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
489 a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch
490 a->setShortcutContext (Qt::WindowShortcut);
492 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
493 a->setEnabled (false);
494 actionListBranches.append(a);
495 actionEditAddBranchBefore=a;
496 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
497 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
498 a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch
499 a->setShortcutContext (Qt::WindowShortcut);
501 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
502 actionListBranches.append(a);
505 a = new QAction(tr( "Add branch above","Edit menu" ), this);
506 a->setStatusTip ( tr( "Add a branch above selection" ));
507 a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
508 a->setShortcutContext (Qt::WindowShortcut);
510 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
511 a->setEnabled (false);
512 actionListBranches.append(a);
513 actionEditAddBranchAbove=a;
514 a = new QAction(tr( "Add branch above","Edit menu" ), this);
515 a->setStatusTip ( tr( "Add a branch above selection" ));
516 a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above
517 a->setShortcutContext (Qt::WindowShortcut);
519 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
520 actionListBranches.append(a);
523 a = new QAction(tr( "Add branch below","Edit menu" ), this);
524 a->setStatusTip ( tr( "Add a branch below selection" ));
525 a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
526 a->setShortcutContext (Qt::WindowShortcut);
528 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
529 a->setEnabled (false);
530 actionListBranches.append(a);
531 actionEditAddBranchBelow=a;
532 a = new QAction(tr( "Add branch below","Edit menu" ), this);
533 a->setStatusTip ( tr( "Add a branch below selection" ));
534 a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below
535 a->setShortcutContext (Qt::WindowShortcut);
537 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
538 actionListBranches.append(a);
540 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
541 a->setStatusTip ( tr( "Move branch up" ) );
542 a->setShortcut (Qt::Key_PageUp ); // Move branch up
543 a->setEnabled (false);
545 editMenu->addAction (a);
546 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
549 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
550 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
551 a->setStatusTip (tr( "Move branch down" ) );
552 a->setShortcut ( Qt::Key_PageDown ); // Move branch down
553 a->setEnabled (false);
555 editMenu->addAction (a);
556 actionEditMoveDown=a;
559 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this);
560 a->setShortcut ( Qt::Key_ScrollLock );
561 a->setStatusTip (tr( "Scroll branch" ) );
562 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
564 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
565 alt->setShortcut ( Qt::Key_S ); // Scroll branch
566 alt->setStatusTip (tr( "Scroll branch" ));
567 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
568 #if defined(Q_OS_MACX)
569 actionEditToggleScroll=alt;
571 actionEditToggleScroll=a;
573 actionEditToggleScroll->setEnabled (false);
574 actionEditToggleScroll->setToggleAction(true);
575 tb->addAction (actionEditToggleScroll);
576 editMenu->addAction ( actionEditToggleScroll);
577 editMenu->addAction (actionEditToggleScroll);
580 actionListBranches.append(actionEditToggleScroll);
582 a = new QAction( tr( "Unscroll all scrolled branches","Edit menu" ), this);
583 a->setStatusTip (tr( "Unscroll all" ));
584 editMenu->addAction (a);
585 connect( a, SIGNAL( triggered() ), this, SLOT( editUnScrollAll() ) );
587 editMenu->addSeparator();
589 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
590 a->setStatusTip (tr( "Find" ) );
591 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
592 editMenu->addAction (a);
593 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
595 editMenu->addSeparator();
597 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
598 a->setShortcut (Qt::CTRL + Qt::Key_U );
599 a->setShortcut (tr( "Open URL" ));
602 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
605 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
606 a->setStatusTip (tr( "Open URL in new tab" ));
607 a->setShortcut (Qt::CTRL+Qt::Key_U );
609 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
610 actionEditOpenURLTab=a;
612 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
613 a->setStatusTip (tr( "Open all URLs in subtree" ));
615 actionListBranches.append(a);
616 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
617 actionEditOpenMultipleURLTabs=a;
619 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
620 a->setStatusTip ( tr( "Edit URL" ) );
621 a->setShortcut (Qt::SHIFT + Qt::CTRL + Qt::Key_U );
622 //a->setShortcut ( Qt::Key_U );
623 a->setShortcutContext (Qt::WindowShortcut);
624 actionListBranches.append(a);
626 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
629 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
630 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
631 a->setEnabled (false);
632 actionListBranches.append(a);
633 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
634 actionEditHeading2URL=a;
636 a = new QAction(tr( "Create URL to Bugzilla","Edit menu" ), this);
637 a->setStatusTip ( tr( "Create URL to Bugzilla" ));
638 a->setEnabled (false);
639 actionListBranches.append(a);
640 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
641 actionEditBugzilla2URL=a;
643 a = new QAction(tr( "Create URL to FATE","Edit menu" ), this);
644 a->setStatusTip ( tr( "Create URL to FATE" ));
645 a->setEnabled (false);
646 actionListBranches.append(a);
647 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
648 actionEditFATE2URL=a;
650 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
651 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
653 a->setEnabled (false);
654 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
655 actionEditOpenVymLink=a;
657 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
658 a->setStatusTip ( tr( "Open all vym links in subtree" ));
659 a->setEnabled (false);
660 actionListBranches.append(a);
661 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
662 actionEditOpenMultipleVymLinks=a;
665 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
666 a->setEnabled (false);
667 a->setStatusTip ( tr( "Edit link to another vym map" ));
668 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
669 actionListBranches.append(a);
672 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
673 a->setStatusTip ( tr( "Delete link to another vym map" ));
674 a->setEnabled (false);
675 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
676 actionEditDeleteVymLink=a;
678 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
679 a->setStatusTip ( tr( "Hide object in exports" ) );
680 a->setShortcut (Qt::Key_H );
681 a->setToggleAction(true);
683 a->setEnabled (false);
684 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
685 actionEditToggleHideExport=a;
687 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
688 a->setStatusTip ( tr( "Edit Map Info" ));
689 a->setEnabled (true);
690 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
693 // Import at selection (adding to selection)
694 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
695 a->setStatusTip (tr( "Add map at selection" ));
696 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
697 a->setEnabled (false);
698 actionListBranches.append(a);
699 actionEditImportAdd=a;
701 // Import at selection (replacing selection)
702 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
703 a->setStatusTip (tr( "Replace selection with map" ));
704 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
705 a->setEnabled (false);
706 actionListBranches.append(a);
707 actionEditImportReplace=a;
710 a = new QAction( tr( "Save selection","Edit menu" ), this);
711 a->setStatusTip (tr( "Save selection" ));
712 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
713 a->setEnabled (false);
714 actionListBranches.append(a);
715 actionEditSaveBranch=a;
717 // Only remove branch, not its childs
718 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
719 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
720 a->setShortcut (Qt::ALT + Qt::Key_Delete );
721 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChilds() ) );
722 a->setEnabled (false);
724 actionListBranches.append(a);
725 actionEditDeleteKeepChilds=a;
727 // Only remove childs of a branch
728 a = new QAction( tr( "Remove childs","Edit menu" ), this);
729 a->setStatusTip (tr( "Remove childs of branch" ));
730 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
731 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChilds() ) );
732 a->setEnabled (false);
733 actionListBranches.append(a);
734 actionEditDeleteChilds=a;
736 // Shortcuts for navigating with cursor:
737 a = new QAction(tr( "Select upper branch","Edit menu" ), this);
738 a->setStatusTip ( tr( "Select upper branch" ));
739 a->setShortcut (Qt::Key_Up );
740 a->setShortcutContext (Qt::WindowShortcut);
742 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
743 a = new QAction( tr( "Select lower branch","Edit menu" ),this);
744 a->setStatusTip (tr( "Select lower branch" ));
745 a->setShortcut ( Qt::Key_Down );
746 a->setShortcutContext (Qt::WindowShortcut);
748 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
749 a = new QAction(tr( "Select left branch","Edit menu" ), this);
750 a->setStatusTip ( tr( "Select left branch" ));
751 a->setShortcut (Qt::Key_Left );
752 a->setShortcutContext (Qt::WindowShortcut);
754 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
755 a = new QAction( tr( "Select child branch","Edit menu" ), this);
756 a->setStatusTip (tr( "Select right branch" ));
757 a->setShortcut (Qt::Key_Right);
758 a->setShortcutContext (Qt::WindowShortcut);
760 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
761 a = new QAction( tr( "Select first branch","Edit menu" ), this);
762 a->setStatusTip (tr( "Select first branch" ));
763 a->setShortcut (Qt::Key_Home );
764 a->setShortcutContext (Qt::WindowShortcut);
766 a->setEnabled (false);
767 editMenu->addAction (a);
768 actionListBranches.append(a);
769 actionEditSelectFirst=a;
770 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
771 a = new QAction( tr( "Select last branch","Edit menu" ),this);
772 a->setStatusTip (tr( "Select last branch" ));
773 a->setShortcut ( Qt::Key_End );
774 a->setShortcutContext (Qt::WindowShortcut);
776 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
777 a->setEnabled (false);
778 editMenu->addAction (a);
779 actionListBranches.append(a);
780 actionEditSelectLast=a;
782 a = new QAction( tr( "Add Image...","Edit menu" ), this);
783 a->setStatusTip (tr( "Add Image" ));
784 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
785 actionEditLoadImage=a;
787 a = new QAction( tr( "Property Dialog","Dialog to edit properties of selection" )+QString ("..."), this);
788 a->setStatusTip (tr( "Set properties for selection" ));
789 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
790 a->setShortcutContext (Qt::WindowShortcut);
792 connect( a, SIGNAL( triggered() ), this, SLOT( showPropertyDialog() ) );
793 actionTogglePropertyDialog=a;
797 void Main::setupFormatActions()
799 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
801 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
802 tb->setObjectName ("formatTB");
805 pix.fill (Qt::black);
806 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
807 a->setStatusTip ( tr( "Set Color" ));
808 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
810 formatMenu->addAction (a);
812 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
813 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
814 a->setShortcut (Qt::CTRL + Qt::Key_K );
815 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
816 a->setEnabled (false);
818 formatMenu->addAction (a);
819 actionListBranches.append(a);
820 actionFormatPickColor=a;
822 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
823 a->setStatusTip ( tr( "Color branch" ) );
824 a->setShortcut (Qt::CTRL + Qt::Key_B);
825 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
826 a->setEnabled (false);
828 formatMenu->addAction (a);
829 actionListBranches.append(a);
830 actionFormatColorSubtree=a;
832 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
833 a->setStatusTip ( tr( "Color Subtree" ));
834 a->setShortcut (Qt::CTRL + Qt::Key_T);
835 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
836 a->setEnabled (false);
837 formatMenu->addAction (a);
839 actionListBranches.append(a);
840 actionFormatColorSubtree=a;
842 formatMenu->addSeparator();
843 actionGroupFormatLinkStyles=new QActionGroup ( this);
844 actionGroupFormatLinkStyles->setExclusive (true);
845 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
846 a->setStatusTip (tr( "Line" ));
847 a->setToggleAction(true);
848 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
849 formatMenu->addAction (a);
850 actionFormatLinkStyleLine=a;
851 a= new QAction( tr( "Linkstyle Parabel" ), actionGroupFormatLinkStyles);
852 a->setStatusTip (tr( "Line" ));
853 a->setToggleAction(true);
854 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
855 formatMenu->addAction (a);
856 actionFormatLinkStyleParabel=a;
857 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
858 a->setStatusTip (tr( "PolyLine" ));
859 a->setToggleAction(true);
860 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
861 formatMenu->addAction (a);
862 actionFormatLinkStylePolyLine=a;
863 a= new QAction( tr( "Linkstyle Thick Parabel" ), actionGroupFormatLinkStyles);
864 a->setStatusTip (tr( "PolyParabel" ) );
865 a->setToggleAction(true);
866 a->setChecked (true);
867 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
868 formatMenu->addAction (a);
869 actionFormatLinkStylePolyParabel=a;
871 a = new QAction( tr( "Include images vertically","Branch attribute" ), this);
872 a->setStatusTip ( tr ("Include top and bottom position of images into branch"));
873 a->setToggleAction(true);
874 connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesVer() ) );
875 actionFormatIncludeImagesVer=a;
877 a = new QAction( tr( "Include images horizontally","Branch attribute" ), this);
878 a->setStatusTip ( tr ("Include left and right position of images into branch"));
879 a->setToggleAction(true);
880 connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesHor() ) );
881 actionFormatIncludeImagesHor=a;
883 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
884 a->setStatusTip (tr( "Hide link" ));
885 a->setToggleAction(true);
886 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
887 actionFormatHideLinkUnselected=a;
889 formatMenu->addSeparator();
890 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
891 a->setStatusTip (tr( "Use same color for links and headings" ));
892 a->setToggleAction(true);
893 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
894 formatMenu->addAction (a);
895 actionFormatLinkColorHint=a;
897 pix.fill (Qt::white);
898 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
899 a->setStatusTip (tr( "Set Link Color" ));
900 formatMenu->addAction (a);
901 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
902 actionFormatLinkColor=a;
904 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
905 a->setStatusTip (tr( "Set Selection Color" ));
906 formatMenu->addAction (a);
907 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
908 actionFormatSelectionColor=a;
910 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
911 a->setStatusTip (tr( "Set Background Color" ));
912 formatMenu->addAction (a);
913 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
914 actionFormatBackColor=a;
916 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
917 a->setStatusTip (tr( "Set Background image" ));
918 formatMenu->addAction (a);
919 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
920 actionFormatBackImage=a;
924 void Main::setupViewActions()
926 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
927 tb->setLabel( "View Actions" );
928 tb->setObjectName ("viewTB");
929 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
932 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
933 a->setStatusTip ( tr( "Zoom reset" ) );
934 a->setShortcut (Qt::CTRL + Qt::Key_0 );
936 viewMenu->addAction (a);
937 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
939 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
940 a->setStatusTip (tr( "Zoom in" ));
941 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
943 viewMenu->addAction (a);
944 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
946 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
947 a->setStatusTip (tr( "Zoom out" ));
948 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
950 viewMenu->addAction (a);
951 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
954 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
955 a->setStatusTip ( tr( "Show Note Editor" ));
956 a->setShortcut ( Qt::CTRL + Qt::Key_E );
957 a->setToggleAction(true);
958 if (textEditor->showWithMain())
963 viewMenu->addAction (a);
964 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
965 actionViewToggleNoteEditor=a;
967 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
968 a->setStatusTip ( tr( "Show History Window" ));
969 a->setShortcut ( Qt::CTRL + Qt::Key_H );
970 a->setToggleAction(true);
972 viewMenu->addAction (a);
973 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
974 actionViewToggleHistoryWindow=a;
976 viewMenu->addAction (actionTogglePropertyDialog );
978 a = new QAction(tr( "Antialiasing","View action" ),this );
979 a->setStatusTip ( tr( "Antialiasing" ));
980 a->setToggleAction(true);
981 a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
982 viewMenu->addAction (a);
983 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
984 actionViewToggleAntiAlias=a;
986 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
987 a->setStatusTip (a->text());
988 a->setToggleAction(true);
989 a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
990 viewMenu->addAction (a);
991 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
992 actionViewToggleSmoothPixmapTransform=a;
994 a = new QAction(tr( "Next Window","View action" ), this);
995 a->setStatusTip (a->text());
996 a->setShortcut (Qt::ALT + Qt::Key_N );
997 viewMenu->addAction (a);
998 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1000 a = new QAction (tr( "Previous Window","View action" ), this );
1001 a->setStatusTip (a->text());
1002 a->setShortcut (Qt::ALT + Qt::Key_P );
1003 viewMenu->addAction (a);
1004 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1008 void Main::setupModeActions()
1010 //QPopupMenu *menu = new QPopupMenu( this );
1011 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1013 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1014 tb->setObjectName ("modesTB");
1016 actionGroupModModes=new QActionGroup ( this);
1017 actionGroupModModes->setExclusive (true);
1018 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1019 a->setShortcut (Qt::Key_J);
1020 a->setStatusTip ( tr( "Use modifier to color branches" ));
1021 a->setToggleAction(true);
1024 actionModModeColor=a;
1026 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1027 a->setShortcut( Qt::Key_K);
1028 a->setStatusTip( tr( "Use modifier to copy" ));
1029 a->setToggleAction(true);
1031 actionModModeCopy=a;
1033 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1034 a->setShortcut (Qt::Key_L);
1035 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1036 a->setToggleAction(true);
1038 actionModModeXLink=a;
1042 void Main::setupFlagActions()
1044 // Create System Flags
1045 systemFlagsDefault = new FlagRowObj ();
1046 systemFlagsDefault->setVisibility (false);
1047 systemFlagsDefault->setName ("systemFlagsDef");
1049 FlagObj *fo = new FlagObj ();
1050 fo->load(QPixmap(flagsPath+"flag-note.png"));
1051 fo->setName("note");
1052 fo->setToolTip(tr("Note","Systemflag"));
1053 systemFlagsDefault->addFlag (fo); // makes deep copy
1055 fo->load(QPixmap(flagsPath+"flag-url.png"));
1057 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
1058 systemFlagsDefault->addFlag (fo);
1060 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1061 fo->setName("vymLink");
1062 fo->setToolTip(tr("Link to another vym map","Systemflag"));
1063 systemFlagsDefault->addFlag (fo);
1065 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1066 fo->setName("scrolledright");
1067 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
1068 systemFlagsDefault->addFlag (fo);
1070 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1071 fo->setName("tmpUnscrolledright");
1072 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
1073 systemFlagsDefault->addFlag (fo);
1075 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1076 fo->setName("hideInExport");
1077 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
1078 systemFlagsDefault->addFlag (fo);
1080 // Create Standard Flags
1081 QToolBar *tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1082 tb->setObjectName ("standardFlagTB");
1084 standardFlagsDefault = new FlagRowObj ();
1085 standardFlagsDefault->setVisibility (false);
1086 standardFlagsDefault->setName ("standardFlagsDef");
1087 standardFlagsDefault->setToolBar (tb);
1089 fo->load(flagsPath+"flag-exclamationmark.png");
1090 fo->setName ("exclamationmark");
1091 fo->setGroup("standard-mark");
1092 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1095 a->setCheckable(true);
1096 a->setObjectName(fo->getName());
1097 a->setToolTip(tr("Take care!","Standardflag"));
1098 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1099 standardFlagsDefault->addFlag (fo); // makes deep copy
1101 fo->load(flagsPath+"flag-questionmark.png");
1102 fo->setName("questionmark");
1103 fo->setGroup("standard-mark");
1104 a=new QAction (fo->getPixmap(),fo->getName(),this);
1107 a->setCheckable(true);
1108 a->setObjectName(fo->getName());
1109 a->setToolTip(tr("Really?","Standardflag"));
1110 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1111 standardFlagsDefault->addFlag (fo);
1113 fo->load(flagsPath+"flag-hook-green.png");
1114 fo->setName("hook-green");
1115 fo->setGroup("standard-hook");
1116 a=new QAction (fo->getPixmap(),fo->getName(),this);
1119 a->setCheckable(true);
1120 a->setObjectName(fo->getName());
1121 a->setToolTip(tr("ok!","Standardflag"));
1122 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1123 standardFlagsDefault->addFlag (fo);
1125 fo->load(flagsPath+"flag-cross-red.png");
1126 fo->setName("cross-red");
1127 fo->setGroup("standard-hook");
1128 a=new QAction (fo->getPixmap(),fo->getName(),this);
1131 a->setCheckable(true);
1132 a->setObjectName(fo->getName());
1133 a->setToolTip(tr("Not ok!","Standardflag"));
1134 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1135 standardFlagsDefault->addFlag (fo);
1137 fo->load(flagsPath+"flag-stopsign.png");
1138 fo->setName("stopsign");
1139 a=new QAction (fo->getPixmap(),fo->getName(),this);
1142 a->setCheckable(true);
1143 a->setObjectName(fo->getName());
1144 a->setToolTip(tr("This won't work!","Standardflag"));
1145 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1146 standardFlagsDefault->addFlag (fo);
1148 fo->load(flagsPath+"flag-smiley-good.png");
1149 fo->setName("smiley-good");
1150 fo->setGroup("standard-smiley");
1151 a=new QAction (fo->getPixmap(),fo->getName(),this);
1154 a->setCheckable(true);
1155 a->setObjectName(fo->getName());
1156 a->setToolTip(tr("Good","Standardflag"));
1157 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1158 standardFlagsDefault->addFlag (fo);
1160 fo->load(flagsPath+"flag-smiley-sad.png");
1161 fo->setName("smiley-sad");
1162 fo->setGroup("standard-smiley");
1163 a=new QAction (fo->getPixmap(),fo->getName(),this);
1166 a->setCheckable(true);
1167 a->setObjectName(fo->getName());
1168 a->setToolTip(tr("Bad","Standardflag"));
1169 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1170 standardFlagsDefault->addFlag (fo);
1172 fo->load(flagsPath+"flag-smiley-omg.png");
1173 // Original omg.png (in KDE emoticons)
1174 fo->setName("smiley-omg");
1175 fo->setGroup("standard-smiley");
1176 a=new QAction (fo->getPixmap(),fo->getName(),this);
1179 a->setCheckable(true);
1180 a->setObjectName(fo->getName());
1181 a->setToolTip(tr("Oh no!","Standardflag"));
1182 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1183 standardFlagsDefault->addFlag (fo);
1185 fo->load(flagsPath+"flag-kalarm.png");
1186 fo->setName("clock");
1187 a=new QAction (fo->getPixmap(),fo->getName(),this);
1190 a->setCheckable(true);
1191 a->setObjectName(fo->getName());
1192 a->setToolTip(tr("Time critical","Standardflag"));
1193 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1194 standardFlagsDefault->addFlag (fo);
1196 fo->load(flagsPath+"flag-phone.png");
1197 fo->setName("phone");
1198 a=new QAction (fo->getPixmap(),fo->getName(),this);
1201 a->setCheckable(true);
1202 a->setObjectName(fo->getName());
1203 a->setToolTip(tr("Call...","Standardflag"));
1204 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1205 standardFlagsDefault->addFlag (fo);
1207 fo->load(flagsPath+"flag-lamp.png");
1208 fo->setName("lamp");
1209 a=new QAction (fo->getPixmap(),fo->getName(),this);
1212 a->setCheckable(true);
1213 a->setObjectName(fo->getName());
1214 a->setToolTip(tr("Idea!","Standardflag"));
1215 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1216 standardFlagsDefault->addFlag (fo);
1218 fo->load(flagsPath+"flag-arrow-up.png");
1219 fo->setName("arrow-up");
1220 fo->setGroup("standard-arrow");
1221 a=new QAction (fo->getPixmap(),fo->getName(),this);
1224 a->setCheckable(true);
1225 a->setObjectName(fo->getName());
1226 a->setToolTip(tr("Important","Standardflag"));
1227 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1228 standardFlagsDefault->addFlag (fo);
1230 fo->load(flagsPath+"flag-arrow-down.png");
1231 fo->setName("arrow-down");
1232 fo->setGroup("standard-arrow");
1233 a=new QAction (fo->getPixmap(),fo->getName(),this);
1236 a->setCheckable(true);
1237 a->setObjectName(fo->getName());
1238 a->setToolTip(tr("Unimportant","Standardflag"));
1239 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1240 standardFlagsDefault->addFlag (fo);
1242 fo->load(flagsPath+"flag-arrow-2up.png");
1243 fo->setName("2arrow-up");
1244 fo->setGroup("standard-arrow");
1245 a=new QAction (fo->getPixmap(),fo->getName(),this);
1248 a->setCheckable(true);
1249 a->setObjectName(fo->getName());
1250 a->setToolTip(tr("Very important!","Standardflag"));
1251 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1252 standardFlagsDefault->addFlag (fo);
1254 fo->load(flagsPath+"flag-arrow-2down.png");
1255 fo->setName("2arrow-down");
1256 fo->setGroup("standard-arrow");
1257 a=new QAction (fo->getPixmap(),fo->getName(),this);
1260 a->setCheckable(true);
1261 a->setObjectName(fo->getName());
1262 a->setToolTip(tr("Very unimportant!","Standardflag"));
1263 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1264 standardFlagsDefault->addFlag (fo);
1266 fo->load(flagsPath+"flag-thumb-up.png");
1267 fo->setName("thumb-up");
1268 fo->setGroup("standard-thumb");
1269 a=new QAction (fo->getPixmap(),fo->getName(),this);
1272 a->setCheckable(true);
1273 a->setObjectName(fo->getName());
1274 a->setToolTip(tr("I like this","Standardflag"));
1275 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1276 standardFlagsDefault->addFlag (fo);
1278 fo->load(flagsPath+"flag-thumb-down.png");
1279 fo->setName("thumb-down");
1280 fo->setGroup("standard-thumb");
1281 a=new QAction (fo->getPixmap(),fo->getName(),this);
1284 a->setCheckable(true);
1285 a->setObjectName(fo->getName());
1286 a->setToolTip(tr("I do not like this","Standardflag"));
1287 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1288 standardFlagsDefault->addFlag (fo);
1290 fo->load(flagsPath+"flag-rose.png");
1291 fo->setName("rose");
1292 a=new QAction (fo->getPixmap(),fo->getName(),this);
1295 a->setCheckable(true);
1296 a->setObjectName(fo->getName());
1297 a->setToolTip(tr("Rose","Standardflag"));
1298 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1299 standardFlagsDefault->addFlag (fo);
1301 fo->load(flagsPath+"flag-heart.png");
1302 fo->setName("heart");
1303 a=new QAction (fo->getPixmap(),fo->getName(),this);
1305 a->setCheckable(true);
1306 a->setObjectName(fo->getName());
1307 a->setToolTip(tr("I just love... ","Standardflag"));
1308 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1309 standardFlagsDefault->addFlag (fo);
1311 fo->load(flagsPath+"flag-present.png");
1312 fo->setName("present");
1313 a=new QAction (fo->getPixmap(),fo->getName(),this);
1316 a->setCheckable(true);
1317 a->setObjectName(fo->getName());
1318 a->setToolTip(tr("Surprise!","Standardflag"));
1319 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1320 standardFlagsDefault->addFlag (fo);
1322 fo->load(flagsPath+"flag-flash.png");
1323 fo->setName("flash");
1324 a=new QAction (fo->getPixmap(),fo->getName(),this);
1327 a->setCheckable(true);
1328 a->setObjectName(fo->getName());
1329 a->setToolTip(tr("Dangerous","Standardflag"));
1330 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1331 standardFlagsDefault->addFlag (fo);
1333 fo->load(flagsPath+"flag-info.png");
1334 // Original: xsldbg_output.png
1335 fo->setName("info");
1336 a=new QAction (fo->getPixmap(),fo->getName(),this);
1339 a->setCheckable(true);
1340 a->setObjectName(fo->getName());
1341 a->setToolTip(tr("Info","Standardflag"));
1342 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1343 standardFlagsDefault->addFlag (fo);
1345 fo->load(flagsPath+"flag-lifebelt.png");
1346 // Original khelpcenter.png
1347 fo->setName("lifebelt");
1348 a=new QAction (fo->getPixmap(),fo->getName(),this);
1351 a->setCheckable(true);
1352 a->setObjectName(fo->getName());
1353 a->setToolTip(tr("This will help","Standardflag"));
1354 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1355 standardFlagsDefault->addFlag (fo);
1361 void Main::setupSettingsActions()
1363 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1367 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1368 a->setStatusTip ( tr( "Set application to open pdf files"));
1369 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1370 settingsMenu->addAction (a);
1372 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1373 a->setStatusTip( tr( "Set application to open external links"));
1374 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1375 settingsMenu->addAction (a);
1377 settingsMenu->addSeparator();
1378 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1379 a->setStatusTip( tr( "Edit branch after adding it" ));
1380 a->setToggleAction(true);
1381 a->setOn ( settings.value ("/mapeditor/editmode/autoEdit",true).toBool());
1382 settingsMenu->addAction (a);
1383 actionSettingsAutoEdit=a;
1385 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1386 a->setStatusTip( tr( "Select branch after adding it" ));
1387 a->setToggleAction(true);
1388 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectHeading",false).toBool() );
1389 settingsMenu->addAction (a);
1390 actionSettingsAutoSelectHeading=a;
1392 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1393 a->setStatusTip( tr( "Select heading before editing" ));
1394 a->setToggleAction(true);
1395 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1396 settingsMenu->addAction (a);
1397 actionSettingsAutoSelectText=a;
1399 a= new QAction( tr( "Delete key","Settings action" ), this);
1400 a->setStatusTip( tr( "Delete key for deleting branches" ));
1401 a->setToggleAction(true);
1402 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",false).toBool() );
1403 settingsMenu->addAction (a);
1404 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1405 actionSettingsUseDelKey=a;
1407 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1408 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1409 a->setToggleAction(true);
1410 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1411 settingsMenu->addAction (a);
1412 actionSettingsUseFlagGroups=a;
1414 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1415 a->setStatusTip( tr( "Use hide flag during exports " ));
1416 a->setToggleAction(true);
1417 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1418 settingsMenu->addAction (a);
1419 actionSettingsUseHideExport=a;
1423 void Main::setupTestActions()
1425 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1428 a = new QAction( "Test function" , this);
1429 a->setStatusTip( "Call test function" );
1430 a->setShortcut (Qt::Key_F4 );
1431 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction() ) );
1432 testMenu->addAction (a);
1433 a = new QAction( "Command" , this);
1434 a->setStatusTip( "Enter command to call in editor" );
1435 a->setShortcut (Qt::Key_F5 );
1436 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1437 testMenu->addAction (a);
1441 void Main::setupHelpActions()
1443 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1446 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1447 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1448 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1449 helpMenu->addAction (a);
1451 a = new QAction( tr( "About VYM","Help action" ), this);
1452 a->setStatusTip( tr( "About VYM")+vymName);
1453 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1454 helpMenu->addAction (a);
1456 a = new QAction( tr( "About QT","Help action" ), this);
1457 a->setStatusTip( tr( "Information about QT toolkit" ));
1458 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1459 helpMenu->addAction (a);
1463 void Main::setupContextMenus()
1467 // Context Menu for branch or mapcenter
1468 branchContextMenu =new QMenu (this);
1469 branchContextMenu->addAction (actionTogglePropertyDialog);
1470 branchContextMenu->addSeparator();
1473 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1474 branchAddContextMenu->addAction (actionEditPaste );
1475 branchAddContextMenu->addAction ( actionEditAddBranch );
1476 branchAddContextMenu->addAction ( actionEditAddBranchBefore );
1477 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1478 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1479 branchAddContextMenu->addSeparator();
1480 branchAddContextMenu->addAction ( actionEditImportAdd );
1481 branchAddContextMenu->addAction ( actionEditImportReplace );
1484 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1485 branchRemoveContextMenu->addAction (actionEditCut);
1486 branchRemoveContextMenu->addAction ( actionEditDelete );
1487 branchRemoveContextMenu->addAction ( actionEditDeleteKeepChilds );
1488 branchRemoveContextMenu->addAction ( actionEditDeleteChilds );
1491 actionEditSaveBranch->addTo( branchContextMenu );
1493 branchContextMenu->addSeparator();
1494 branchContextMenu->addAction ( actionEditLoadImage);
1495 branchContextMenu->addAction ( actionFormatIncludeImagesVer );
1496 branchContextMenu->addAction ( actionFormatIncludeImagesHor );
1498 // Submenu for Links (URLs, vymLinks)
1499 branchLinksContextMenu =new QMenu (this);
1501 branchContextMenu->addSeparator();
1502 branchLinksContextMenu=branchContextMenu->addMenu(tr("URLs and vymLinks","Context menu name"));
1503 branchLinksContextMenu->addAction ( actionEditOpenURL );
1504 branchLinksContextMenu->addAction ( actionEditOpenURLTab );
1505 branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
1506 branchLinksContextMenu->addAction ( actionEditURL );
1507 branchLinksContextMenu->addAction ( actionEditHeading2URL );
1508 branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
1509 if (settings.value( "/mainwindow/showTestMenu",true).toBool() )
1511 branchLinksContextMenu->addAction ( actionEditFATE2URL );
1513 branchLinksContextMenu->addSeparator();
1514 branchLinksContextMenu->addAction ( actionEditOpenVymLink );
1515 branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
1516 branchLinksContextMenu->addAction ( actionEditVymLink );
1517 branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
1520 // Context Menu for XLinks in a branch menu
1521 // This will be populated "on demand" in MapEditor::updateActions
1522 branchContextMenu->addSeparator();
1523 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1524 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1525 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1526 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1529 // Context menu for floatimage
1530 floatimageContextMenu =new QMenu (this);
1531 a= new QAction (tr ("Save image","Context action"),this);
1532 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1533 floatimageContextMenu->addAction (a);
1535 floatimageContextMenu->addSeparator();
1536 actionEditCopy->addTo( floatimageContextMenu );
1537 actionEditCut->addTo( floatimageContextMenu );
1539 floatimageContextMenu->addSeparator();
1540 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1543 // Context menu for canvas
1544 canvasContextMenu =new QMenu (this);
1545 actionEditMapInfo->addTo( canvasContextMenu );
1546 canvasContextMenu->insertSeparator();
1547 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1548 canvasContextMenu->insertSeparator();
1549 actionFormatLinkColorHint->addTo( canvasContextMenu );
1550 actionFormatLinkColor->addTo( canvasContextMenu );
1551 actionFormatSelectionColor->addTo( canvasContextMenu );
1552 actionFormatBackColor->addTo( canvasContextMenu );
1553 actionFormatBackImage->addTo( canvasContextMenu );
1555 // Menu for last opened files
1557 for (int i = 0; i < MaxRecentFiles; ++i)
1559 recentFileActs[i] = new QAction(this);
1560 recentFileActs[i]->setVisible(false);
1561 fileLastMapsMenu->addAction(recentFileActs[i]);
1562 connect(recentFileActs[i], SIGNAL(triggered()),
1563 this, SLOT(fileLoadRecent()));
1565 setupRecentMapsMenu();
1568 void Main::setupRecentMapsMenu()
1570 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1572 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1574 for (int i = 0; i < numRecentFiles; ++i) {
1575 //QString text = tr("&%1 %2").arg(i + 1).arg(strippedName(files[i]));
1576 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1577 recentFileActs[i]->setText(text);
1578 recentFileActs[i]->setData(files[i]);
1579 recentFileActs[i]->setVisible(true);
1581 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1582 recentFileActs[j]->setVisible(false);
1585 void Main::hideEvent (QHideEvent * )
1587 if (!textEditor->isMinimized() ) textEditor->hide();
1590 void Main::showEvent (QShowEvent * )
1592 if (textEditor->showWithMain()) textEditor->showNormal();
1595 bool Main::reallyWriteDirectory(const QString &dir)
1597 QStringList eList = QDir(dir).entryList();
1598 if (eList.first() ==".") eList.pop_front(); // remove "."
1599 if (eList.first() =="..") eList.pop_front(); // remove "."
1600 if (!eList.isEmpty())
1602 QMessageBox mb( vymName,
1603 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?","write directory").arg(dir),
1604 QMessageBox::Warning,
1606 QMessageBox::Cancel | QMessageBox::Default,
1607 QMessageBox::QMessageBox::NoButton );
1609 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1610 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1613 case QMessageBox::Yes:
1616 case QMessageBox::Cancel:
1624 QString Main::browseDirectory (const QString &caption)
1626 QFileDialog fd(this,caption);
1627 fd.setMode (QFileDialog::DirectoryOnly);
1628 fd.setCaption(vymName+ " - "+caption);
1629 fd.setDir (lastFileDir);
1632 if ( fd.exec() == QDialog::Accepted )
1633 return fd.selectedFile();
1638 MapEditor* Main::currentMapEditor() const
1640 if ( tabWidget->currentPage() &&
1641 tabWidget->currentPage()->inherits( "MapEditor" ) )
1642 return (MapEditor*)tabWidget->currentPage();
1647 void Main::editorChanged(QWidget *)
1649 // Unselect all possibly selected objects
1650 // (Important to update note editor)
1653 for (i=0;i<=tabWidget->count() -1;i++)
1656 me=(MapEditor*)tabWidget->page(i);
1659 currentMapEditor()->reselect();
1661 // Update actions to in menus and toolbars according to editor
1665 void Main::fileNew()
1667 QString fn="unnamed";
1668 MapEditor* me = new MapEditor ( NULL);
1669 tabWidget->addTab (me,fn);
1670 tabWidget->showPage(me);
1671 me->viewport()->setFocus();
1672 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1673 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1675 // For the very first map we do not have flagrows yet...
1679 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1681 ErrorCode err=success;
1683 // fn is usually the archive, mapfile the file after uncompressing
1686 // Make fn absolute (needed for unzip)
1687 fn=QDir (fn).absPath();
1693 // Check, if map is already loaded
1695 while (i<=tabWidget->count() -1)
1697 me=(MapEditor*)tabWidget->page(i);
1698 if (me->getFilePath() == fn)
1700 // Already there, ask for confirmation
1701 QMessageBox mb( vymName,
1702 tr("The map %1\nis already opened."
1703 "Opening the same map in multiple editors may lead \n"
1704 "to confusion when finishing working with vym."
1705 "Do you want to").arg(fn),
1706 QMessageBox::Warning,
1707 QMessageBox::Yes | QMessageBox::Default,
1708 QMessageBox::Cancel | QMessageBox::Escape,
1709 QMessageBox::NoButton);
1710 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1711 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1714 case QMessageBox::Yes:
1716 i=tabWidget->count();
1718 case QMessageBox::Cancel:
1730 if ( !fn.isEmpty() )
1732 me = currentMapEditor();
1733 int tabIndex=tabWidget->currentPageIndex();
1734 // Check first, if mapeditor exists
1735 // If it is not default AND we want a new map,
1736 // create a new mapeditor in a new tab
1737 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1739 me= new MapEditor ( NULL);
1740 tabWidget->addTab (me,fn);
1741 tabIndex=tabWidget->indexOf (me);
1742 tabWidget->setCurrentPage (tabIndex);
1743 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1744 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1747 // Check, if file exists (important for creating new files
1748 // from command line
1749 if (!QFile(fn).exists() )
1751 QMessageBox mb( vymName,
1752 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1753 QMessageBox::Question,
1755 QMessageBox::Cancel | QMessageBox::Default,
1756 QMessageBox::NoButton );
1758 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1759 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1762 case QMessageBox::Yes:
1764 currentMapEditor()->setFilePath(fn);
1765 tabWidget->setTabLabel (currentMapEditor(),
1766 currentMapEditor()->getFileName() );
1767 statusBar()->message( "Created " + fn , statusbarTime );
1770 case QMessageBox::Cancel:
1771 // don't create new map
1772 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1779 //tabWidget->currentPage() won't be NULL here, because of above...
1780 tabWidget->showPage(me);
1781 me->viewport()->setFocus();
1783 // Create temporary directory for packing
1785 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
1788 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1789 tr("Couldn't create temporary directory before load\n"));
1793 // Try to unzip file
1794 err=unzipDir (tmpMapDir,fn);
1798 me->setZipped(false);
1801 me->setZipped(true);
1803 // Look for mapname.xml
1804 mapfile= fn.left(fn.findRev(".",-1,true));
1805 mapfile=mapfile.section( '/', -1 );
1806 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1807 if (!file.exists() )
1809 // mapname.xml does not exist, well,
1810 // maybe someone renamed the mapname.vym file...
1811 // Try to find any .xml in the toplevel
1812 // directory of the .vym file
1813 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1814 if (flist.count()==1)
1816 // Only one entry, take this one
1817 mapfile=tmpMapDir + "/"+flist.first();
1820 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1821 *it=tmpMapDir + "/" + *it;
1822 // TODO Multiple entries, load all (but only the first one into this ME)
1823 //mainWindow->fileLoadFromTmp (flist);
1824 //returnCode=1; // Silently forget this attempt to load
1825 qWarning ("MainWindow::load (fn) multimap found...");
1828 if (flist.isEmpty() )
1830 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1831 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1834 } //file doesn't exist
1836 mapfile=file.name();
1841 // Save existing filename in case we import
1842 QString fn_org=me->getFilePath();
1844 // Finally load map into mapEditor
1845 me->setFilePath (mapfile,fn);
1846 err=me->load(mapfile,lmode);
1848 // Restore old (maybe empty) filepath, if this is an import
1850 me->setFilePath (fn_org);
1853 // Finally check for errors and go home
1856 if (lmode==NewMap) fileCloseMap();
1857 statusBar()->message( "Could not load " + fn, statusbarTime );
1862 me->setFilePath (fn);
1863 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1864 if (fn.left(9)!="/tmp/vym-")
1866 // Only append to lastMaps if not loaded from a tmpDir
1867 // e.g. imported bookmarks are in a tmpDir
1868 addRecentMap(me->getFilePath() );
1870 actionFilePrint->setEnabled (true);
1872 statusBar()->message( "Loaded " + fn, statusbarTime );
1876 removeDir (QDir(tmpMapDir));
1882 void Main::fileLoad(const LoadMode &lmode)
1884 QStringList filters;
1885 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1886 QFileDialog *fd=new QFileDialog( this);
1887 fd->setDir (lastFileDir);
1888 fd->setFileMode (QFileDialog::ExistingFiles);
1889 fd->setFilters (filters);
1893 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1896 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1899 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1905 if ( fd->exec() == QDialog::Accepted )
1907 lastFileDir=fd->directory().path();
1908 QStringList flist = fd->selectedFiles();
1909 QStringList::Iterator it = flist.begin();
1910 while( it != flist.end() )
1913 fileLoad(*it, lmode);
1920 void Main::fileLoad()
1925 void Main::fileLoadRecent()
1927 QAction *action = qobject_cast<QAction *>(sender());
1929 fileLoad (action->data().toString(), NewMap);
1932 void Main::addRecentMap (const QString &fileName)
1935 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1936 files.removeAll(fileName);
1937 files.prepend(fileName);
1938 while (files.size() > MaxRecentFiles)
1941 settings.setValue("/mainwindow/recentFileList", files);
1943 setupRecentMapsMenu();
1946 void Main::fileSave(const SaveMode &savemode)
1948 // tmp dir for zipping
1952 ErrorCode err=success;
1954 QString safeFilePath;
1956 bool saveZipped=currentMapEditor()->saveZipped();
1958 MapEditor * me=currentMapEditor();
1961 QString fn=me->getFilePath();
1962 // filename=unnamed, filepath="" in constructor...
1963 if ( !fn.isEmpty() )
1965 // We have a filepath, go on saving
1966 // First remove existing file, we
1967 // don't want to add to old zip archives
1971 QMessageBox::warning( 0, tr( "Save Error" ),
1972 fn+ tr("\ncould not be removed before saving"));
1974 // Look, if we should zip the data:
1977 QMessageBox mb( vymName,
1978 tr("The map %1\ndid not use the compressed "
1979 "vym file format.\nWriting it uncompressed will also write images \n"
1980 "and flags and thus may overwrite files in the "
1981 "given directory\n\nDo you want to write the map").arg(fn),
1982 QMessageBox::Warning,
1983 QMessageBox::Yes | QMessageBox::Default,
1985 QMessageBox::Cancel | QMessageBox::Escape);
1986 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
1987 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
1988 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1991 case QMessageBox::Yes:
1992 // save compressed (default file format)
1995 case QMessageBox::No:
1996 // save uncompressed
1999 case QMessageBox::Cancel:
2008 // Create temporary directory for packing
2010 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
2013 QMessageBox::critical( 0, tr( "Critical Load Error" ),
2014 tr("Couldn't create temporary directory before save\n"));
2018 safeFilePath=me->getFilePath();
2019 me->setFilePath (tmpMapDir+"/"+
2020 me->getMapName()+ ".xml",
2022 me->save (savemode);
2023 me->setFilePath (safeFilePath);
2025 zipDir (tmpMapDir,fn);
2030 safeFilePath=me->getFilePath();
2031 me->setFilePath (fn, safeFilePath);
2032 me->save (savemode);
2033 me->setFilePath (safeFilePath);
2035 } // filepath available
2038 // We have no filepath yet,
2039 // call fileSaveAs() now, this will call fileSave()
2041 fileSaveAs(savemode);
2045 if (saveZipped && !tmpMapDir.isEmpty())
2047 removeDir (QDir(tmpMapDir));
2051 statusBar()->message(
2052 tr("Saved %1").arg(me->getFilePath()),
2054 addRecentMap (me->getFilePath() );
2056 statusBar()->message(
2057 tr("Couldn't save ").arg(me->getFilePath()),
2061 void Main::fileSave()
2063 fileSave (CompleteMap);
2066 void Main::fileSaveAs(const SaveMode& savemode)
2070 if (currentMapEditor())
2072 if (savemode==CompleteMap)
2073 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2075 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2076 if ( !fn.isEmpty() )
2078 // Check for existing file
2079 if (QFile (fn).exists())
2081 QMessageBox mb( vymName,
2082 tr("The file %1\nexists already. Do you want to").arg(fn),
2083 QMessageBox::Warning,
2084 QMessageBox::Yes | QMessageBox::Default,
2085 QMessageBox::Cancel | QMessageBox::Escape,
2086 QMessageBox::NoButton);
2087 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2088 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2091 case QMessageBox::Yes:
2094 case QMessageBox::Cancel:
2101 // New file, add extension to filename, if missing
2102 // This is always .vym or .vyp, depending on savemode
2103 if (savemode==CompleteMap)
2105 if (!fn.contains (".vym") && !fn.contains (".xml"))
2109 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2118 currentMapEditor()->setFilePath(fn);
2122 if (savemode==CompleteMap)
2123 tabWidget->setTabLabel (currentMapEditor(),
2124 currentMapEditor()->getFileName() );
2130 void Main::fileSaveAs()
2132 fileSaveAs (CompleteMap);
2135 void Main::fileImportKDEBookmarks()
2137 ImportKDEBookmarks im;
2139 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2140 currentMapEditor()->setFilePath ("");
2143 void Main::fileImportFirefoxBookmarks()
2145 Q3FileDialog *fd=new Q3FileDialog( this);
2146 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2147 fd->setMode (Q3FileDialog::ExistingFiles);
2148 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2149 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2152 if ( fd->exec() == QDialog::Accepted )
2154 ImportFirefoxBookmarks im;
2155 QStringList flist = fd->selectedFiles();
2156 QStringList::Iterator it = flist.begin();
2157 while( it != flist.end() )
2160 if (im.transform() &&
2161 success==fileLoad (im.getTransformedFile(),NewMap) &&
2162 currentMapEditor() )
2163 currentMapEditor()->setFilePath ("");
2170 void Main::fileImportMM()
2174 Q3FileDialog *fd=new Q3FileDialog( this);
2175 fd->setDir (lastFileDir);
2176 fd->setMode (Q3FileDialog::ExistingFiles);
2177 fd->addFilter ("Mind Manager (*.mmap)");
2178 fd->setCaption(tr("Import")+" "+"Mind Manager");
2181 if ( fd->exec() == QDialog::Accepted )
2183 lastFileDir=fd->dirPath();
2184 QStringList flist = fd->selectedFiles();
2185 QStringList::Iterator it = flist.begin();
2186 while( it != flist.end() )
2189 if (im.transform() &&
2190 success==fileLoad (im.getTransformedFile(),NewMap) &&
2191 currentMapEditor() )
2192 currentMapEditor()->setFilePath ("");
2201 void Main::fileImportDir()
2203 if (currentMapEditor())
2204 currentMapEditor()->importDir();
2207 void Main::fileExportXML()
2209 if (currentMapEditor())
2211 QString dir=browseDirectory(tr("Export XML to directory"));
2212 if (dir !="" && reallyWriteDirectory(dir) )
2213 currentMapEditor()->exportXML(dir);
2218 void Main::fileExportXHTML()
2220 MapEditor *me=currentMapEditor();
2224 ExportXHTMLDialog dia(this);
2225 dia.setFilePath (me->getFilePath() );
2226 dia.setMapName (me->getMapName() );
2229 if (dia.exec()==QDialog::Accepted)
2231 QString dir=dia.getDir();
2232 // Check, if warnings should be used before overwriting
2233 // the output directory
2235 warn.showCancelButton (true);
2236 warn.setText(QString(
2237 "The directory %1 is not empty.\n"
2238 "Do you risk to overwrite some of its contents?").arg(dir));
2239 warn.setCaption("Warning: Directory not empty");
2240 warn.setShowAgainName("mainwindow/overwrite-dir-xhtml");
2241 if (warn.exec()==QDialog::Accepted)
2243 me->exportXML (dia.getDir() );
2244 dia.doExport(me->getMapName() );
2245 if (dia.hasChanged())
2252 void Main::fileExportImage()
2254 MapEditor *me=currentMapEditor();
2258 QFileDialog *fd=new QFileDialog (this);
2259 fd->setCaption (tr("Export map as image"));
2260 fd->setFileMode(QFileDialog::AnyFile);
2261 fd->setFilters (imageIO.getFilters() );
2262 fd->setDirectory (lastImageDir);
2265 fl=fd->selectedFiles();
2266 qWarning ("Selected "+fl.first()+" filter: "+fd->selectedFilter());
2267 me->exportImage (fl.first(), imageIO.getType (fd->selectedFilter() ) );
2272 void Main::fileExportASCII()
2274 MapEditor *me=currentMapEditor();
2278 ex.setMapCenter(me->getMapCenter());
2279 ex.addFilter ("TXT (*.txt)");
2280 ex.setDir(lastImageDir);
2281 ex.setCaption(vymName+ " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
2282 if (ex.execDialog() )
2284 me->setExportMode(true);
2286 me->setExportMode(false);
2291 void Main::fileExportLaTeX()
2293 MapEditor *me=currentMapEditor();
2297 ex.setMapCenter(me->getMapCenter());
2298 ex.addFilter ("Tex (*.tex)");
2299 ex.setDir(lastImageDir);
2300 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2301 if (ex.execDialog() )
2303 me->setExportMode(true);
2305 me->setExportMode(false);
2310 void Main::fileExportKDEBookmarks()
2312 ExportKDEBookmarks ex;
2313 MapEditor *me=currentMapEditor();
2316 ex.setMapCenter (me->getMapCenter() );
2321 void Main::fileExportTaskjuggler()
2323 ExportTaskjuggler ex;
2324 MapEditor *me=currentMapEditor();
2327 ex.setMapCenter (me->getMapCenter() );
2328 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2329 ex.setDir(lastImageDir);
2330 ex.addFilter ("Taskjuggler (*.tjp)");
2331 if (ex.execDialog() )
2333 me->setExportMode(true);
2335 me->setExportMode(false);
2340 void Main::fileExportOOPresentation()
2342 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2343 // TODO add preview in dialog
2344 //ImagePreview *p =new ImagePreview (fd);
2345 //fd->setContentsPreviewEnabled( TRUE );
2346 //fd->setContentsPreview( p, p );
2347 //fd->setPreviewMode( QFileDialog::Contents );
2348 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2349 fd->setDir (QDir().current());
2350 if (fd->foundConfig())
2354 if ( fd->exec() == QDialog::Accepted )
2356 QString fn=fd->selectedFile();
2357 if (!fn.contains (".odp"))
2360 //lastImageDir=fn.left(fn.findRev ("/"));
2361 if (currentMapEditor())
2362 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2366 QMessageBox::warning(0,
2368 tr("Couldn't find configuration for export to Open Office\n"));
2372 void Main::fileCloseMap()
2374 if (currentMapEditor())
2376 if (currentMapEditor()->hasChanged())
2378 QMessageBox mb( vymName,
2379 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2380 QMessageBox::Warning,
2381 QMessageBox::Yes | QMessageBox::Default,
2383 QMessageBox::Cancel | QMessageBox::Escape );
2384 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2385 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2388 case QMessageBox::Yes:
2390 fileSave(CompleteMap);
2392 case QMessageBox::No:
2393 // close without saving
2395 case QMessageBox::Cancel:
2400 currentMapEditor()->closeMap();
2401 tabWidget->removePage(currentMapEditor());
2402 if (tabWidget->count()==0)
2403 actionFilePrint->setEnabled (false);
2407 void Main::filePrint()
2409 if (currentMapEditor())
2410 currentMapEditor()->print();
2413 void Main::fileExitVYM()
2415 // Check if one or more editors have changed
2418 for (i=0;i<=tabWidget->count() -1;i++)
2421 me=(MapEditor*)tabWidget->page(i);
2423 // If something changed, ask what to do
2424 if (me->isUnsaved())
2426 tabWidget->setCurrentPage(i);
2427 QMessageBox mb( vymName,
2428 tr("This map is not saved yet. Do you want to"),
2429 QMessageBox::Warning,
2430 QMessageBox::Yes | QMessageBox::Default,
2432 QMessageBox::Cancel | QMessageBox::Escape );
2433 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2434 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2437 mb.setActiveWindow();
2438 switch( mb.exec() ) {
2439 case QMessageBox::Yes:
2440 // save (the changed editors) and exit
2441 fileSave(CompleteMap);
2443 case QMessageBox::No:
2444 // exit without saving
2446 case QMessageBox::Cancel:
2447 // don't save and don't exit
2451 } // loop over all MEs
2455 void Main::editUndo()
2457 if (currentMapEditor())
2458 currentMapEditor()->undo();
2461 void Main::editRedo()
2463 if (currentMapEditor())
2464 currentMapEditor()->redo();
2467 void Main::gotoHistoryStep (int i)
2469 if (currentMapEditor())
2470 currentMapEditor()->gotoHistoryStep (i);
2473 void Main::editCopy()
2475 if (currentMapEditor())
2476 currentMapEditor()->copy();
2479 void Main::editPaste()
2481 if (currentMapEditor())
2482 currentMapEditor()->paste();
2485 void Main::editCut()
2487 if (currentMapEditor())
2488 currentMapEditor()->cut();
2491 void Main::editOpenFindWindow()
2493 findWindow->popup();
2494 findWindow->raise();
2495 findWindow->setActiveWindow();
2498 void Main::editFind(QString s)
2501 BranchObj *bo=currentMapEditor()->findText(s, cs);
2504 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2507 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2508 tr("No matches found for \"%1\"").arg(s));
2512 void Main::editFindChanged()
2513 { // Notify editor, to abort the current find process
2514 currentMapEditor()->findReset();
2517 void Main::openTabs(QStringList urls)
2519 if (!urls.isEmpty())
2523 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2525 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2527 QString u=urls.takeFirst();
2528 procBrowser = new QProcess( this );
2530 procBrowser->start(browser,args);
2531 if ( !procBrowser->waitForStarted())
2533 // try to set path to browser
2534 QMessageBox::warning(0,
2536 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2537 tr("Please use Settings->")+tr("Set application to open an URL"));
2542 if (browser.contains("konqueror"))
2544 for (int i=0; i<urls.size(); i++)
2547 // Try to open new tab in existing konqueror started previously by vym
2548 p=new QProcess (this);
2550 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2551 "konqueror-mainwindow#1"<<
2554 p->start ("dcop",args);
2555 if ( !p->waitForStarted() ) success=false;
2558 QMessageBox::warning(0,
2560 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2562 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2564 for (int i=0; i<urls.size(); i++)
2566 // Try to open new tab in firefox
2567 p=new QProcess (this);
2568 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2569 p->start (browser,args);
2570 if ( !p->waitForStarted() ) success=false;
2573 QMessageBox::warning(0,
2575 tr("Couldn't start %1 to open a new tab").arg(browser));
2578 QMessageBox::warning(0,
2580 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2584 void Main::editOpenURL()
2587 if (currentMapEditor())
2589 QString url=currentMapEditor()->getURL();
2591 if (url=="") return;
2592 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2593 procBrowser = new QProcess( this );
2595 procBrowser->start(browser,args);
2596 if ( !procBrowser->waitForStarted())
2598 // try to set path to browser
2599 QMessageBox::warning(0,
2601 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2602 tr("Please use Settings->")+tr("Set application to open an URL"));
2607 void Main::editOpenURLTab()
2609 if (currentMapEditor())
2612 urls.append(currentMapEditor()->getURL());
2616 void Main::editOpenMultipleURLTabs()
2618 if (currentMapEditor())
2621 urls=currentMapEditor()->getURLs();
2627 void Main::editURL()
2629 if (currentMapEditor())
2630 currentMapEditor()->editURL();
2633 void Main::editHeading2URL()
2635 if (currentMapEditor())
2636 currentMapEditor()->editHeading2URL();
2639 void Main::editBugzilla2URL()
2641 if (currentMapEditor())
2642 currentMapEditor()->editBugzilla2URL();
2645 void Main::editFATE2URL()
2647 if (currentMapEditor())
2648 currentMapEditor()->editFATE2URL();
2651 void Main::editHeadingFinished()
2653 // only called from editHeading(), so there is a currentME
2654 MapEditor *me=currentMapEditor();
2657 QPoint p; //Not used here, only to find out pos of branch
2659 QString s=me->getHeading(ok,p);
2661 #if defined(Q_OS_MACX)
2663 if (ok && s!=lineedit->text())
2664 me->setHeading(lineedit->text());
2666 lineedit->releaseKeyboard();
2670 if (!prevSelection.isEmpty()) me->select(prevSelection);
2675 void Main::editHeading()
2677 if (currentMapEditor())
2679 MapEditor *me=currentMapEditor();
2680 QString oldSel=me->getSelectString();
2682 if (lineedit->isVisible())
2683 editHeadingFinished();
2688 QString s=currentMapEditor()->getHeading(ok,p);
2692 #if defined(Q_OS_MACX)
2693 p=currentMapEditor()->mapTo (this,p);
2694 QDialog *d =new QDialog(NULL);
2695 QLineEdit *le=new QLineEdit (d);
2696 d->setWindowFlags (Qt::FramelessWindowHint);
2697 d->setGeometry(p.x(),p.y(),230,25);
2698 le->resize (d->width()-10,d->height());
2701 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2702 d->activateWindow();
2704 currentMapEditor()->setHeading (le->text());
2707 editHeadingFinished();
2709 p=currentMapEditor()->mapTo (this,p);
2710 lineedit->setGeometry(p.x(),p.y(),230,25);
2711 lineedit->setText(s);
2712 lineedit->setCursorPosition(1);
2713 lineedit->selectAll();
2715 lineedit->grabKeyboard();
2716 lineedit->setFocus();
2720 } // currentMapEditor()
2723 void Main::openVymLinks(const QStringList &vl)
2725 for (int j=0; j<vl.size(); j++)
2727 // compare path with already loaded maps
2731 for (i=0;i<=tabWidget->count() -1;i++)
2733 me=(MapEditor*)tabWidget->page(i);
2734 if (vl.at(j)==me->getFilePath() )
2743 if (!QFile(vl.at(j)).exists() )
2744 QMessageBox::critical( 0, tr( "Critical Error" ),
2745 tr("Couldn't open map %1").arg(vl.at(j)));
2748 fileLoad (vl.at(j), NewMap);
2749 tabWidget->setCurrentPage (tabWidget->count()-1);
2752 // Go to tab containing the map
2753 tabWidget->setCurrentPage (index);
2757 void Main::editOpenVymLink()
2759 if (currentMapEditor())
2762 vl.append(currentMapEditor()->getVymLink());
2767 void Main::editOpenMultipleVymLinks()
2769 QString currentVymLink;
2770 if (currentMapEditor())
2772 QStringList vl=currentMapEditor()->getVymLinks();
2777 void Main::editVymLink()
2779 if (currentMapEditor())
2780 currentMapEditor()->editVymLink();
2783 void Main::editDeleteVymLink()
2785 if (currentMapEditor())
2786 currentMapEditor()->deleteVymLink();
2789 void Main::editToggleHideExport()
2791 if (currentMapEditor())
2792 currentMapEditor()->toggleHideExport();
2795 void Main::editMapInfo()
2797 if (currentMapEditor())
2798 currentMapEditor()->editMapInfo();
2801 void Main::editMoveUp()
2803 if (currentMapEditor())
2804 currentMapEditor()->moveBranchUp();
2807 void Main::editMoveDown()
2809 if (currentMapEditor())
2810 currentMapEditor()->moveBranchDown();
2813 void Main::editToggleScroll()
2815 if (currentMapEditor())
2817 currentMapEditor()->toggleScroll();
2821 void Main::editUnScrollAll()
2823 if (currentMapEditor())
2824 currentMapEditor()->unscrollChilds();
2827 void Main::editNewBranch()
2829 MapEditor *me=currentMapEditor();
2830 if (!lineedit->isVisible() && me)
2832 BranchObj *bo=(BranchObj*)me->getSelection();
2833 BranchObj *newbo=me->addNewBranch(0);
2836 me->select (newbo->getSelectString());
2840 if (actionSettingsAutoEdit->isOn())
2842 if (!actionSettingsAutoSelectHeading->isOn())
2843 prevSelection=bo->getSelectString();
2849 void Main::editNewBranchBefore()
2851 MapEditor *me=currentMapEditor();
2852 if (!lineedit->isVisible() && me)
2854 BranchObj *bo=(BranchObj*)me->getSelection();
2855 BranchObj *newbo=me->addNewBranchBefore();
2858 me->select (newbo->getSelectString());
2862 if (actionSettingsAutoEdit->isOn())
2864 if (!actionSettingsAutoSelectHeading->isOn())
2865 prevSelection=bo->getSelectString();
2871 void Main::editNewBranchAbove()
2873 MapEditor *me=currentMapEditor();
2874 if (!lineedit->isVisible() && me)
2876 BranchObj *bo=(BranchObj*)me->getSelection();
2877 BranchObj *newbo=me->addNewBranch (-1);
2880 me->select (newbo->getSelectString());
2884 if (actionSettingsAutoEdit->isOn())
2886 if (!actionSettingsAutoSelectHeading->isOn())
2887 prevSelection=bo->getSelectString();
2893 void Main::editNewBranchBelow()
2895 MapEditor *me=currentMapEditor();
2896 if (!lineedit->isVisible() && me)
2898 BranchObj *bo=(BranchObj*)me->getSelection();
2899 BranchObj *newbo=me->addNewBranch (1);
2902 me->select (newbo->getSelectString());
2906 if (actionSettingsAutoEdit->isOn())
2908 if (!actionSettingsAutoSelectHeading->isOn())
2909 prevSelection=bo->getSelectString();
2915 void Main::editImportAdd()
2917 fileLoad (ImportAdd);
2920 void Main::editImportReplace()
2922 fileLoad (ImportReplace);
2925 void Main::editSaveBranch()
2927 fileSaveAs (PartOfMap);
2930 void Main::editDeleteKeepChilds()
2932 if (currentMapEditor())
2933 currentMapEditor()->deleteKeepChilds();
2936 void Main::editDeleteChilds()
2938 if (currentMapEditor())
2939 currentMapEditor()->deleteChilds();
2942 void Main::editDeleteSelection()
2944 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2945 currentMapEditor()->deleteSelection();
2948 void Main::editUpperBranch()
2950 if (currentMapEditor())
2951 currentMapEditor()->selectUpperBranch();
2954 void Main::editLowerBranch()
2956 if (currentMapEditor())
2957 currentMapEditor()->selectLowerBranch();
2960 void Main::editLeftBranch()
2962 if (currentMapEditor())
2963 currentMapEditor()->selectLeftBranch();
2966 void Main::editRightBranch()
2968 if (currentMapEditor())
2969 currentMapEditor()->selectRightBranch();
2972 void Main::editFirstBranch()
2974 if (currentMapEditor())
2975 currentMapEditor()->selectFirstBranch();
2978 void Main::editLastBranch()
2980 if (currentMapEditor())
2981 currentMapEditor()->selectLastBranch();
2984 void Main::editLoadImage()
2986 if (currentMapEditor())
2987 currentMapEditor()->loadFloatImage();
2990 void Main::editSaveImage()
2992 if (currentMapEditor())
2993 currentMapEditor()->saveFloatImage();
2996 void Main::editFollowXLink(QAction *a)
2999 if (currentMapEditor())
3000 currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
3003 void Main::editEditXLink(QAction *a)
3005 if (currentMapEditor())
3006 currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3009 void Main::formatSelectColor()
3011 if (currentMapEditor())
3013 QColor col = QColorDialog::getColor((currentColor ), this );
3014 if ( !col.isValid() ) return;
3015 colorChanged( col );
3019 void Main::formatPickColor()
3021 if (currentMapEditor())
3022 colorChanged( currentMapEditor()->getCurrentHeadingColor() );
3025 void Main::colorChanged(QColor c)
3027 QPixmap pix( 16, 16 );
3029 actionFormatColor->setIconSet( pix );
3033 void Main::formatColorBranch()
3035 if (currentMapEditor())
3036 currentMapEditor()->colorBranch(currentColor);
3039 void Main::formatColorSubtree()
3041 if (currentMapEditor())
3042 currentMapEditor()->colorSubtree (currentColor);
3045 void Main::formatLinkStyleLine()
3047 if (currentMapEditor())
3048 currentMapEditor()->setMapLinkStyle("StyleLine");
3051 void Main::formatLinkStyleParabel()
3053 if (currentMapEditor())
3054 currentMapEditor()->setMapLinkStyle("StyleParabel");
3057 void Main::formatLinkStylePolyLine()
3059 if (currentMapEditor())
3060 currentMapEditor()->setMapLinkStyle("StylePolyLine");
3063 void Main::formatLinkStylePolyParabel()
3065 if (currentMapEditor())
3066 currentMapEditor()->setMapLinkStyle("StylePolyParabel");
3069 void Main::formatSelectBackColor()
3071 if (currentMapEditor())
3072 currentMapEditor()->selectMapBackgroundColor();
3075 void Main::formatSelectBackImage()
3077 if (currentMapEditor())
3078 currentMapEditor()->selectMapBackgroundImage();
3081 void Main::formatSelectLinkColor()
3083 if (currentMapEditor())
3084 currentMapEditor()->selectMapLinkColor();
3087 void Main::formatSelectSelectionColor()
3089 if (currentMapEditor())
3090 currentMapEditor()->selectMapSelectionColor();
3093 void Main::formatToggleLinkColorHint()
3095 currentMapEditor()->toggleMapLinkColorHint();
3099 void Main::formatIncludeImagesVer()
3101 if (currentMapEditor())
3102 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
3105 void Main::formatIncludeImagesHor()
3107 if (currentMapEditor())
3108 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
3111 void Main::formatHideLinkUnselected() //FIXME get rid of this with imagepropertydialog
3113 if (currentMapEditor())
3114 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3117 void Main::viewZoomReset()
3119 if (currentMapEditor())
3123 currentMapEditor()->setMatrix( m );
3127 void Main::viewZoomIn()
3129 if (currentMapEditor())
3131 QMatrix m = currentMapEditor()->matrix();
3132 m.scale( 1.25, 1.25 );
3133 currentMapEditor()->setMatrix( m );
3137 void Main::viewZoomOut()
3139 if (currentMapEditor())
3141 QMatrix m = currentMapEditor()->matrix();
3142 m.scale( 0.8, 0.8 );
3143 currentMapEditor()->setMatrix( m );
3147 bool Main::settingsPDF()
3149 // Default browser is set in constructor
3151 QString text = QInputDialog::getText(
3152 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3153 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3155 settings.setValue ("/mainwindow/readerPDF",text);
3160 bool Main::settingsURL()
3162 // Default browser is set in constructor
3164 QString text = QInputDialog::getText(
3165 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3166 settings.value("/mainwindow/readerURL").toString()
3169 settings.setValue ("/mainwindow/readerURL",text);
3173 void Main::settingsToggleDelKey()
3175 if (actionSettingsUseDelKey->isOn())
3177 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3180 actionEditDelete->setAccel (QKeySequence (""));
3184 void Main::windowToggleNoteEditor()
3186 if (textEditor->showWithMain() )
3187 windowHideNoteEditor();
3189 windowShowNoteEditor();
3192 void Main::windowToggleHistory()
3194 if (historyWindow->isVisible())
3195 historyWindow->hide();
3197 historyWindow->show();
3201 void Main::windowToggleAntiAlias()
3203 bool b=actionViewToggleAntiAlias->isOn();
3205 for (int i=0;i<tabWidget->count();i++)
3208 me=(MapEditor*)tabWidget->page(i);
3209 me->setAntiAlias(b);
3214 void Main::windowToggleSmoothPixmap()
3216 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3218 for (int i=0;i<tabWidget->count();i++)
3221 me=(MapEditor*)tabWidget->page(i);
3222 me->setSmoothPixmap(b);
3226 void Main::updateHistory(SimpleSettings &undoSet)
3228 historyWindow->update (undoSet);
3231 void Main::updateNoteFlag()
3233 if (currentMapEditor())
3234 currentMapEditor()->updateNoteFlag();
3237 void Main::updateSatellites(MapEditor *me)
3239 branchPropertyWindow->setMapEditor (me);
3242 void Main::updateActions()
3244 MapEditor *me=currentMapEditor();
3247 historyWindow->setCaption (tr("History for %1").arg(currentMapEditor()->getFileName()));
3249 // updateActions is also called when NoteEditor is closed
3250 actionViewToggleNoteEditor->setOn (textEditor->showWithMain());
3251 actionViewToggleHistoryWindow->setOn (historyWindow->showWithMain());
3253 if (me->getMapLinkColorHint()==HeadingColor)
3254 actionFormatLinkColorHint->setOn(true);
3256 actionFormatLinkColorHint->setOn(false);
3258 switch (me->getMapLinkStyle())
3261 actionFormatLinkStyleLine->setOn(true);
3264 actionFormatLinkStyleParabel->setOn(true);
3267 actionFormatLinkStylePolyLine->setOn(true);
3269 case StylePolyParabel:
3270 actionFormatLinkStylePolyParabel->setOn(true);
3277 QPixmap pix( 16, 16 );
3278 pix.fill( me->getMapBackgroundColor() );
3279 actionFormatBackColor->setIconSet( pix );
3280 pix.fill( me->getSelectionColor() );
3281 actionFormatSelectionColor->setIconSet( pix );
3282 pix.fill( me->getMapDefLinkColor() );
3283 actionFormatLinkColor->setIconSet( pix );
3286 actionFileSave->setEnabled( me->isUnsaved() );
3287 if (me->isUndoAvailable())
3288 actionEditUndo->setEnabled( true);
3290 actionEditUndo->setEnabled( false);
3292 if (me->isRedoAvailable())
3293 actionEditRedo->setEnabled( true);
3295 actionEditRedo->setEnabled( false);
3297 LinkableMapObj *selection=me->getSelection();
3300 if ( (typeid(*selection) == typeid(BranchObj)) ||
3301 (typeid(*selection) == typeid(MapCenterObj)) )
3303 BranchObj *bo=(BranchObj*)selection;
3304 // Take care of links
3305 if (bo->countXLinks()==0)
3307 branchXLinksContextMenuEdit->clear();
3308 branchXLinksContextMenuFollow->clear();
3313 branchXLinksContextMenuEdit->clear();
3314 branchXLinksContextMenuFollow->clear();
3315 for (int i=0; i<=bo->countXLinks();i++)
3317 bot=bo->XLinkTargetAt(i);
3320 s=bot->getHeading();
3323 branchXLinksContextMenuFollow->addAction (s);
3324 branchXLinksContextMenuEdit->addAction (s);
3329 standardFlagsDefault->setEnabled (true);
3331 actionEditToggleScroll->setEnabled (true);
3332 if ( bo->isScrolled() )
3333 actionEditToggleScroll->setOn(true);
3335 actionEditToggleScroll->setOn(false);
3337 if ( bo->getURL().isEmpty() )
3339 actionEditOpenURL->setEnabled (false);
3340 actionEditOpenURLTab->setEnabled (false);
3344 actionEditOpenURL->setEnabled (true);
3345 actionEditOpenURLTab->setEnabled (true);
3347 if ( bo->getVymLink().isEmpty() )
3349 actionEditOpenVymLink->setEnabled (false);
3350 actionEditDeleteVymLink->setEnabled (false);
3353 actionEditOpenVymLink->setEnabled (true);
3354 actionEditDeleteVymLink->setEnabled (true);
3357 if (bo->canMoveBranchUp())
3358 actionEditMoveUp->setEnabled (true);
3360 actionEditMoveUp->setEnabled (false);
3361 if (bo->canMoveBranchDown())
3362 actionEditMoveDown->setEnabled (true);
3364 actionEditMoveDown->setEnabled (false);
3367 actionEditToggleHideExport->setEnabled (true);
3368 actionEditToggleHideExport->setOn (bo->hideInExport() );
3370 actionEditCopy->setEnabled (true);
3371 actionEditCut->setEnabled (true);
3372 if (!clipboardEmpty)
3373 actionEditPaste->setEnabled (true);
3375 actionEditPaste->setEnabled (false);
3376 for (int i=0; i<actionListBranches.size(); ++i)
3377 actionListBranches.at(i)->setEnabled(true);
3378 actionEditDelete->setEnabled (true);
3379 actionFormatIncludeImagesVer->setOn
3380 ( ((BranchObj*)selection)->getIncludeImagesVer());
3381 actionFormatIncludeImagesHor->setOn
3382 ( ((BranchObj*)selection)->getIncludeImagesHor());
3383 actionFormatHideLinkUnselected->setOn
3384 (selection->getHideLinkUnselected());
3386 if ( (typeid(*selection) == typeid(FloatImageObj)) )
3388 FloatObj *fo=(FloatImageObj*)selection;
3390 actionEditOpenURL->setEnabled (false);
3391 actionEditOpenVymLink->setEnabled (false);
3392 actionEditDeleteVymLink->setEnabled (false);
3393 actionEditToggleHideExport->setEnabled (true);
3394 actionEditToggleHideExport->setOn (fo->hideInExport() );
3397 actionEditCopy->setEnabled (true);
3398 actionEditCut->setEnabled (true);
3399 actionEditPaste->setEnabled (false);
3400 for (int i=0; i<actionListBranches.size(); ++i)
3401 actionListBranches.at(i)->setEnabled(false);
3402 actionEditDelete->setEnabled (true);
3403 actionFormatHideLinkUnselected->setOn
3404 ( selection->getHideLinkUnselected());
3405 actionEditMoveUp->setEnabled (false);
3406 actionEditMoveDown->setEnabled (false);
3411 actionEditCopy->setEnabled (false);
3412 actionEditCut->setEnabled (false);
3413 actionEditPaste->setEnabled (false);
3414 for (int i=0; i<actionListBranches.size(); ++i)
3415 actionListBranches.at(i)->setEnabled(false);
3417 actionEditToggleScroll->setEnabled (false);
3418 actionEditOpenURL->setEnabled (false);
3419 actionEditOpenVymLink->setEnabled (false);
3420 actionEditDeleteVymLink->setEnabled (false);
3421 actionEditHeading2URL->setEnabled (false);
3422 actionEditDelete->setEnabled (false);
3423 actionEditMoveUp->setEnabled (false);
3424 actionEditMoveDown->setEnabled (false);
3425 actionEditToggleHideExport->setEnabled (false);
3429 ModMode Main::getModMode()
3431 if (actionModModeColor->isOn()) return ModModeColor;
3432 if (actionModModeCopy->isOn()) return ModModeCopy;
3433 if (actionModModeXLink->isOn()) return ModModeXLink;
3437 bool Main::autoEdit()
3439 return actionSettingsAutoEdit->isOn();
3442 bool Main::autoSelectHeading()
3444 return actionSettingsAutoSelectHeading->isOn();
3447 bool Main::useFlagGroups()
3449 return actionSettingsUseFlagGroups->isOn();
3452 void Main::windowShowNoteEditor()
3454 textEditor->setShowWithMain(true);
3456 actionViewToggleNoteEditor->setOn (true);
3459 void Main::windowHideNoteEditor()
3461 textEditor->setShowWithMain(false);
3463 actionViewToggleNoteEditor->setOn (false);
3466 void Main::setScript (const QString &script)
3468 scriptEditor->setScript (script);
3471 void Main::runScript (const QString &script)
3473 if (currentMapEditor())
3474 currentMapEditor()->runScript (script);
3477 void Main::showPropertyDialog()
3479 if(currentMapEditor())
3481 LinkableMapObj *sel=currentMapEditor()->getSelection();
3482 if (sel && (typeid(*sel) == typeid(BranchObj) ||
3483 typeid(*sel) == typeid(MapCenterObj)))
3485 branchPropertyWindow->show();
3486 branchPropertyWindow->setMapEditor(currentMapEditor());
3487 branchPropertyWindow->setBranch((BranchObj*)sel);
3492 branchPropertyWindow->setBranch(NULL);
3495 void Main::windowNextEditor()
3497 if (tabWidget->currentPageIndex() < tabWidget->count())
3498 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3501 void Main::windowPreviousEditor()
3503 if (tabWidget->currentPageIndex() >0)
3504 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3507 void Main::standardFlagChanged()
3509 if (currentMapEditor())
3510 currentMapEditor()->toggleStandardFlag(sender()->name());
3513 void Main::testFunction()
3515 if (!currentMapEditor()) return;
3516 currentMapEditor()->testFunction();
3519 void Main::testCommand()
3521 if (!currentMapEditor()) return;
3522 scriptEditor->show();
3525 QString com = QInputDialog::getText(
3526 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3527 if (ok) currentMapEditor()->parseAtom(com);
3531 void Main::helpDoc()
3533 QString locale = QLocale::system().name();
3535 if (locale.left(2)=="es")
3536 docname="vym_es.pdf";
3540 QStringList searchList;
3542 #if defined(Q_OS_MACX)
3543 searchList << "./vym.app/Contents";
3545 // default path in SUSE LINUX
3546 searchList <<"/usr/share/doc/packages/vym/doc";
3549 searchList << "doc"; // relative path for easy testing in tarball
3550 searchList << "doc/tex"; // Easy testing working on vym.tex
3551 searchList << "/usr/share/doc/vym"; // Debian
3552 searchList << "/usr/share/doc/packages";// Knoppix
3556 for (int i=0; i<searchList.count(); ++i)
3558 docfile.setFileName(QDir::convertSeparators(searchList.at(i)+"/"+docname));
3559 if (docfile.exists() )
3568 QMessageBox::critical(0,
3569 tr("Critcal error"),
3570 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3575 Process *pdfProc = new Process();
3576 args <<docfile.fileName();
3578 pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
3579 if ( !pdfProc->waitForStarted() )
3582 QMessageBox::warning(0,
3584 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3585 tr("Please use Settings->")+tr("Set application to open PDF files"));
3592 void Main::helpAbout()
3595 ad.setName ("aboutwindow");
3596 ad.setMinimumSize(500,500);
3597 ad.resize (QSize (500,500));
3601 void Main::helpAboutQT()
3603 QMessageBox::aboutQt( this, "Qt Application Example" );