1 #include "mainwindow.h"
5 #include <q3filedialog.h>
13 #include "aboutdialog.h"
14 #include "exportoofiledialog.h"
16 #include "exportxhtmldialog.h"
18 #include "flagrowobj.h"
19 #include "historywindow.h"
21 #include "mapeditor.h"
26 #include "texteditor.h"
29 extern TextEditor *textEditor;
30 extern Main *mainWindow;
31 extern QString tmpVymDir;
32 extern QString clipboardDir;
33 extern bool clipboardEmpty;
34 extern int statusbarTime;
35 extern FlagRowObj* standardFlagsDefault;
36 extern FlagRowObj* systemFlagsDefault;
38 QMenu* branchContextMenu;
39 QMenu* branchAddContextMenu;
40 QMenu* branchRemoveContextMenu;
41 QMenu* branchLinksContextMenu;
42 QMenu* branchXLinksContextMenuEdit;
43 QMenu* branchXLinksContextMenuFollow;
44 QMenu* floatimageContextMenu;
45 QMenu* canvasContextMenu;
46 QMenu* fileLastMapsMenu;
47 QMenu* fileImportMenu;
48 QMenu* fileExportMenu;
51 extern Settings settings;
52 extern Options options;
53 extern ImageIO imageIO;
55 extern QDir vymBaseDir;
56 extern QDir lastImageDir;
57 extern QDir lastFileDir;
58 extern QString iconPath;
59 extern QString flagsPath;
61 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
62 QMainWindow(parent,name,f)
66 setCaption ("VYM - View Your Mind");
68 // Load window settings
69 resize (settings.value( "/mainwindow/geometry/size",QSize (800,600)).toSize());
70 move (settings.value( "/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
73 // Sometimes we may need to remember old selections
77 currentColor=Qt::black;
79 // Create unique temporary directory
81 tmpVymDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
84 qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
88 // Create direcctory for clipboard
89 clipboardDir=tmpVymDir+"/clipboard";
91 d.mkdir (clipboardDir,true);
92 makeSubDirs (clipboardDir);
97 // FIXME not used currently
98 // Set random seed (random used for object IDs)
99 // QTime t = QTime::currentTime(); // set random seed
100 // srand( t.hour()*12+t.minute()*60+t.second()*60 );
103 // Initialize some settings, which are platform dependant
106 // application to open URLs
107 p="/mainwindow/readerURL";
108 #if defined(Q_OS_LINUX)
109 s=settings.value (p,"konqueror").toString();
111 #if defined(Q_OS_MACX)
112 s=settings.value (p,"/usr/bin/open").toString();
114 s=settings.value (p,"mozilla");
117 settings.setValue( p,s);
119 // application to open PDFs
120 p="/mainwindow/readerPDF";
121 #if defined(Q_OS_LINUX)
122 s=settings.value (p,"acroread").toString();
124 #if defined(Q_OS_MACX)
125 s=settings.value (p,"/usr/bin/open").toString();
127 s=settings.value (p,"acroread").toString();
130 settings.setValue( p,s);
135 // Create tab widget which holds the maps
136 tabWidget= new QTabWidget (this);
137 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
138 this, SLOT( editorChanged( QWidget * ) ) );
140 lineedit=new QLineEdit (this);
143 setCentralWidget(tabWidget);
147 setupFormatActions();
151 setupSettingsActions();
153 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
158 restoreState (settings.value("/mainwindow/state",0).toByteArray());
160 // Initialize Find window
161 findWindow=new FindWindow(NULL);
162 findWindow->move (x(),y()+70);
163 connect (findWindow, SIGNAL( findButton(QString) ),
164 this, SLOT(editFind(QString) ) );
165 connect (findWindow, SIGNAL( somethingChanged() ),
166 this, SLOT(editFindChanged() ) );
168 // Connect TextEditor, so that we can update flags if text changes
169 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
170 connect (textEditor, SIGNAL (textEditorClosed() ), this, SLOT (updateActions()));
178 settings.setValue ( "/mainwindow/geometry/size", size() );
179 settings.setValue ( "/mainwindow/geometry/pos", pos() );
181 settings.setValue ("/mainwindow/state",saveState(0));
183 settings.setValue( "/version/version", __VYM_VERSION );
184 settings.setValue( "/version/builddate", __BUILD_DATE );
186 settings.setValue( "/mapeditor/editmode/autoSelectHeading",actionSettingsAutoSelectHeading->isOn() );
187 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
188 settings.setValue( "/mapeditor/editmode/autoEdit",actionSettingsAutoEdit->isOn() );
189 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
190 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
191 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
194 int maps=lastMaps.count();
195 settings.setValue( "/lastMaps/number",maps );
196 for (int i=1;i<=maps;i++)
198 s=QString("/lastMaps/map-%1").arg(i);
199 if (!s.isEmpty() && i<=maxLastMaps)
200 settings.setValue (s, lastMaps.at(i-1));
204 // To make the texteditor save its settings, call the destructor
207 // Remove temporary directory
208 removeDir (QDir(tmpVymDir));
211 void Main::loadCmdLine()
213 /* TODO draw some kind of splashscreen while loading...
219 QStringList flist=options.getFileList();
220 QStringList::Iterator it=flist.begin();
222 while (it !=flist.end() )
224 fileLoad (*it, NewMap);
230 void Main::statusMessage(const QString &s)
232 statusBar()->message (s);
235 void Main::closeEvent (QCloseEvent* )
241 void Main::setupFileActions()
243 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
244 QToolBar *tb = addToolBar( tr ("&Map") );
245 tb->setObjectName ("mapTB");
248 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New...","File menu" ),this);
249 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
250 a->setShortcut ( Qt::CTRL + Qt::Key_N );
252 fileMenu->addAction (a);
253 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
255 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
256 a->setStatusTip (tr( "Open","Status tip File menu" ) );
257 a->setShortcut ( Qt::CTRL + Qt::Key_O );
259 fileMenu->addAction (a);
260 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
262 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
263 fileMenu->addSeparator();
265 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
266 a->setStatusTip ( tr( "Save","Status tip file menu" ));
267 a->setShortcut (Qt::CTRL + Qt::Key_S );
269 fileMenu->addAction (a);
270 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
273 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
274 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
275 fileMenu->addAction (a);
276 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
278 fileMenu->addSeparator();
280 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
282 a = new QAction(tr("KDE Bookmarks"), this);
283 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE bookmarks")));
284 a->addTo (fileImportMenu);
285 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) );
287 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
289 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
290 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
291 a->addTo (fileImportMenu);
292 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
295 a = new QAction("Mind Manager...",this);
296 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
297 fileImportMenu->addAction (a);
298 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
300 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
301 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
302 fileImportMenu->addAction (a);
303 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
305 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
307 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
308 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
309 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
310 fileExportMenu->addAction (a);
312 a = new QAction( "Open Office...", this);
313 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
314 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
315 fileExportMenu->addAction (a);
317 a = new QAction( "Webpage (XHTML)...",this );
318 a->setShortcut (Qt::ALT + Qt::Key_X);
319 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
320 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
321 fileExportMenu->addAction (a);
323 a = new QAction( "Text (ASCII)...", this);
324 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
325 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
326 fileExportMenu->addAction (a);
328 a = new QAction( tr("KDE Bookmarks","File menu"), this);
329 a->setStatusTip( tr( "Export as %1").arg(tr("KDE Bookmarks" )));
330 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
331 fileExportMenu->addAction (a);
333 a = new QAction( "Taskjuggler...", this );
334 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
335 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
336 fileExportMenu->addAction (a);
338 a = new QAction( "LaTeX...", this);
339 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
340 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
341 fileExportMenu->addAction (a);
343 a = new QAction( "XML..." , this );
344 a->setStatusTip (tr( "Export as %1").arg("XML"));
345 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
346 fileExportMenu->addAction (a);
348 fileMenu->addSeparator();
350 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
351 a->setStatusTip ( tr( "Print" ,"File menu") );
352 a->setShortcut (Qt::CTRL + Qt::Key_P );
354 fileMenu->addAction (a);
355 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
358 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
359 a->setStatusTip (tr( "Close Map" ) );
360 a->setShortcut (Qt::ALT + Qt::Key_C );
361 fileMenu->addAction (a);
362 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
364 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+__VYM, this);
365 a->setStatusTip ( tr( "Exit")+" "+__VYM );
366 a->setShortcut (Qt::CTRL + Qt::Key_Q );
367 fileMenu->addAction (a);
368 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
373 void Main::setupEditActions()
375 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
376 tb->setLabel( "Edit Actions" );
377 tb->setObjectName ("actionsTB");
378 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
382 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
383 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
384 a->setStatusTip (tr( "Undo" ) );
385 a->setShortcut ( Qt::CTRL + Qt::Key_Z );
386 a->setEnabled (false);
388 editMenu->addAction (a);
391 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
392 a->setStatusTip (tr( "Redo" ));
393 a->setShortcut (Qt::CTRL + Qt::Key_Y );
395 editMenu->addAction (a);
396 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
399 editMenu->addSeparator();
400 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
401 a->setStatusTip ( tr( "Copy" ) );
402 a->setShortcut (Qt::CTRL + Qt::Key_C );
403 a->setEnabled (false);
405 editMenu->addAction (a);
406 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
409 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
410 a->setStatusTip ( tr( "Cut" ) );
411 a->setShortcut (Qt::CTRL + Qt::Key_X );
412 a->setEnabled (false);
414 editMenu->addAction (a);
416 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
418 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
419 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
420 a->setStatusTip ( tr( "Paste" ) );
421 a->setShortcut ( Qt::CTRL + Qt::Key_V );
422 a->setEnabled (false);
424 editMenu->addAction (a);
427 // Shortcuts to modify heading:
428 a = new QAction(tr( "Edit heading","Edit menu" ),this);
429 a->setStatusTip ( tr( "edit Heading" ));
430 a->setShortcut ( Qt::Key_Enter);
431 // a->setShortcutContext (Qt::WindowShortcut);
433 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
434 actionListBranches.append(a);
435 a = new QAction( tr( "Edit heading","Edit menu" ), this);
436 a->setStatusTip (tr( "edit Heading" ));
437 a->setShortcut (Qt::Key_Return );
438 //a->setShortcutContext (Qt::WindowShortcut);
440 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
441 actionListBranches.append(a);
442 editMenu->addAction (a);
444 a = new QAction( tr( "Edit heading","Edit menu" ), this);
445 a->setStatusTip (tr( "edit Heading" ));
446 a->setShortcut ( Qt::Key_F2 );
447 a->setShortcutContext (Qt::WindowShortcut);
449 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
450 actionListBranches.append(a);
452 // Shortcut to delete selection
453 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
454 a->setStatusTip (tr( "Delete Selection" ));
455 a->setShortcut ( Qt::Key_Delete);
456 a->setShortcutContext (Qt::WindowShortcut);
458 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
461 // Shortcut to add branch
462 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
463 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
464 alt->setShortcut (Qt::Key_A);
465 alt->setShortcutContext (Qt::WindowShortcut);
467 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
468 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
469 a->setStatusTip ( tr( "Add a branch as child of selection" ));
470 a->setShortcut (Qt::Key_Insert);
471 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
472 actionListBranches.append(a);
473 #if defined (Q_OS_MACX)
474 // In OSX show different shortcut in menues, the keys work indepently always
475 actionEditAddBranch=alt;
477 actionEditAddBranch=a;
479 editMenu->addAction (actionEditAddBranch);
480 tb->addAction (actionEditAddBranch);
483 // Add branch by inserting it at selection
484 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
485 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
486 a->setShortcut (Qt::ALT + Qt::Key_Insert );
487 a->setShortcutContext (Qt::WindowShortcut);
489 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
490 a->setEnabled (false);
491 actionListBranches.append(a);
492 actionEditAddBranchBefore=a;
493 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
494 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
495 a->setShortcut ( Qt::ALT + Qt::Key_A );
496 a->setShortcutContext (Qt::WindowShortcut);
498 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
499 actionListBranches.append(a);
502 a = new QAction(tr( "Add branch above","Edit menu" ), this);
503 a->setStatusTip ( tr( "Add a branch above selection" ));
504 a->setShortcut (Qt::SHIFT+Qt::Key_Insert );
505 a->setShortcutContext (Qt::WindowShortcut);
507 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
508 a->setEnabled (false);
509 actionListBranches.append(a);
510 actionEditAddBranchAbove=a;
511 a = new QAction(tr( "Add branch above","Edit menu" ), this);
512 a->setStatusTip ( tr( "Add a branch above selection" ));
513 a->setShortcut (Qt::SHIFT+Qt::Key_A );
514 a->setShortcutContext (Qt::WindowShortcut);
516 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
517 actionListBranches.append(a);
520 a = new QAction(tr( "Add branch below","Edit menu" ), this);
521 a->setStatusTip ( tr( "Add a branch below selection" ));
522 a->setShortcut (Qt::CTRL +Qt::Key_Insert );
523 a->setShortcutContext (Qt::WindowShortcut);
525 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
526 a->setEnabled (false);
527 actionListBranches.append(a);
528 actionEditAddBranchBelow=a;
529 a = new QAction(tr( "Add branch below","Edit menu" ), this);
530 a->setStatusTip ( tr( "Add a branch below selection" ));
531 a->setShortcut (Qt::CTRL +Qt::Key_A );
532 a->setShortcutContext (Qt::WindowShortcut);
534 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
535 actionListBranches.append(a);
537 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
538 a->setStatusTip ( tr( "Move branch up" ) );
539 a->setShortcut (Qt::Key_PageUp );
540 a->setEnabled (false);
542 editMenu->addAction (a);
543 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
546 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
547 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
548 a->setStatusTip (tr( "Move branch down" ) );
549 a->setShortcut ( Qt::Key_PageDown );
550 a->setEnabled (false);
552 editMenu->addAction (a);
553 actionEditMoveDown=a;
556 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this);
557 a->setShortcut ( Qt::Key_ScrollLock );
558 a->setStatusTip (tr( "Scroll branch" ) );
559 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
561 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
562 alt->setShortcut ( Qt::Key_S );
563 alt->setStatusTip (tr( "Scroll branch" ));
564 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
565 #if defined(Q_OS_MACX)
566 actionEditToggleScroll=alt;
568 actionEditToggleScroll=a;
570 actionEditToggleScroll->setEnabled (false);
571 actionEditToggleScroll->setToggleAction(true);
572 tb->addAction (actionEditToggleScroll);
573 editMenu->addAction ( actionEditToggleScroll);
574 editMenu->addAction (actionEditToggleScroll);
577 actionListBranches.append(actionEditToggleScroll);
579 a = new QAction( tr( "Unscroll all scrolled branches","Edit menu" ), this);
580 a->setStatusTip (tr( "Unscroll all" ));
581 editMenu->addAction (a);
582 connect( a, SIGNAL( triggered() ), this, SLOT( editUnScrollAll() ) );
584 editMenu->addSeparator();
586 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
587 a->setStatusTip (tr( "Find" ) );
588 a->setShortcut (Qt::CTRL + Qt::Key_F );
589 editMenu->addAction (a);
590 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
592 editMenu->addSeparator();
594 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
595 a->setShortcut (Qt::CTRL + Qt::Key_U );
596 a->setShortcut (tr( "Open URL" ));
599 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
602 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
603 a->setStatusTip (tr( "Open URL in new tab" ));
604 a->setShortcut (Qt::CTRL+Qt::Key_U );
606 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
607 actionEditOpenURLTab=a;
609 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
610 a->setStatusTip (tr( "Open all URLs in subtree" ));
612 actionListBranches.append(a);
613 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
614 actionEditOpenMultipleURLTabs=a;
616 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
617 a->setStatusTip ( tr( "Edit URL" ) );
618 a->setShortcut (Qt::SHIFT + Qt::CTRL + Qt::Key_U );
619 //a->setShortcut ( Qt::Key_U );
620 a->setShortcutContext (Qt::WindowShortcut);
621 actionListBranches.append(a);
623 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
626 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
627 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
628 a->setEnabled (false);
629 actionListBranches.append(a);
630 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
631 actionEditHeading2URL=a;
633 a = new QAction(tr( "Create URL to Bugzilla","Edit menu" ), this);
634 a->setStatusTip ( tr( "Create URL to Bugzilla" ));
635 a->setEnabled (false);
636 actionListBranches.append(a);
637 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
638 actionEditBugzilla2URL=a;
640 a = new QAction(tr( "Create URL to FATE","Edit menu" ), this);
641 a->setStatusTip ( tr( "Create URL to FATE" ));
642 a->setEnabled (false);
643 actionListBranches.append(a);
644 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
645 actionEditFATE2URL=a;
647 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
648 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
650 a->setEnabled (false);
651 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
652 actionEditOpenVymLink=a;
654 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
655 a->setStatusTip ( tr( "Open all vym links in subtree" ));
656 a->setEnabled (false);
657 actionListBranches.append(a);
658 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
659 actionEditOpenMultipleVymLinks=a;
662 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
663 a->setEnabled (false);
664 a->setStatusTip ( tr( "Edit link to another vym map" ));
665 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
666 actionListBranches.append(a);
669 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
670 a->setStatusTip ( tr( "Delete link to another vym map" ));
671 a->setEnabled (false);
672 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
673 actionEditDeleteVymLink=a;
675 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
676 a->setStatusTip ( tr( "Hide object in exports" ) );
677 a->setShortcut (Qt::Key_H );
678 a->setToggleAction(true);
680 a->setEnabled (false);
681 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
682 actionEditToggleHideExport=a;
684 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
685 a->setStatusTip ( tr( "Edit Map Info" ));
686 a->setEnabled (true);
687 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
690 // Import at selection (adding to selection)
691 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
692 a->setStatusTip (tr( "Add map at selection" ));
693 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
694 a->setEnabled (false);
695 actionListBranches.append(a);
696 actionEditImportAdd=a;
698 // Import at selection (replacing selection)
699 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
700 a->setStatusTip (tr( "Replace selection with map" ));
701 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
702 a->setEnabled (false);
703 actionListBranches.append(a);
704 actionEditImportReplace=a;
707 a = new QAction( tr( "Save selection","Edit menu" ), this);
708 a->setStatusTip (tr( "Save selection" ));
709 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
710 a->setEnabled (false);
711 actionListBranches.append(a);
712 actionEditSaveBranch=a;
714 // Only remove branch, not its childs
715 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
716 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
717 a->setShortcut (Qt::ALT + Qt::Key_Delete );
718 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChilds() ) );
719 a->setEnabled (false);
721 actionListBranches.append(a);
722 actionEditDeleteKeepChilds=a;
724 // Only remove childs of a branch
725 a = new QAction( tr( "Remove childs","Edit menu" ), this);
726 a->setStatusTip (tr( "Remove childs of branch" ));
727 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
728 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChilds() ) );
729 a->setEnabled (false);
730 actionListBranches.append(a);
731 actionEditDeleteChilds=a;
733 // Shortcuts for navigating with cursor:
734 a = new QAction(tr( "Select upper branch","Edit menu" ), this);
735 a->setStatusTip ( tr( "Select upper branch" ));
736 a->setShortcut (Qt::Key_Up );
737 a->setShortcutContext (Qt::WindowShortcut);
739 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
740 a = new QAction( tr( "Select lower branch","Edit menu" ),this);
741 a->setStatusTip (tr( "Select lower branch" ));
742 a->setShortcut ( Qt::Key_Down );
743 a->setShortcutContext (Qt::WindowShortcut);
745 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
746 a = new QAction(tr( "Select left branch","Edit menu" ), this);
747 a->setStatusTip ( tr( "Select left branch" ));
748 a->setShortcut (Qt::Key_Left );
749 a->setShortcutContext (Qt::WindowShortcut);
751 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
752 a = new QAction( tr( "Select child branch","Edit menu" ), this);
753 a->setStatusTip (tr( "Select right branch" ));
754 a->setShortcut (Qt::Key_Right);
755 a->setShortcutContext (Qt::WindowShortcut);
757 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
758 a = new QAction( tr( "Select first branch","Edit menu" ), this);
759 a->setStatusTip (tr( "Select first branch" ));
760 a->setShortcut (Qt::Key_Home );
761 a->setShortcutContext (Qt::WindowShortcut);
763 a->setEnabled (false);
764 editMenu->addAction (a);
765 actionListBranches.append(a);
766 actionEditSelectFirst=a;
767 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
768 a = new QAction( tr( "Select last branch","Edit menu" ),this);
769 a->setStatusTip (tr( "Select last branch" ));
770 a->setShortcut ( Qt::Key_End );
771 a->setShortcutContext (Qt::WindowShortcut);
773 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
774 a->setEnabled (false);
775 editMenu->addAction (a);
776 actionListBranches.append(a);
777 actionEditSelectLast=a;
779 a = new QAction( tr( "Add Image...","Edit menu" ), this);
780 a->setStatusTip (tr( "Add Image" ));
781 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
782 actionEditLoadImage=a;
787 void Main::setupFormatActions()
789 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
791 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
792 tb->setObjectName ("formatTB");
795 pix.fill (Qt::black);
796 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
797 a->setStatusTip ( tr( "Set Color" ));
798 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
800 formatMenu->addAction (a);
802 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
803 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
804 a->setShortcut (Qt::CTRL + Qt::Key_K );
805 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
806 a->setEnabled (false);
808 formatMenu->addAction (a);
809 actionListBranches.append(a);
810 actionFormatPickColor=a;
812 a= new QAction(QPixmap(iconPath+"formatcoloritem.png"), tr( "Color &branch","Edit menu" ), this);
813 a->setStatusTip ( tr( "Color branch" ) );
814 a->setShortcut (Qt::CTRL + Qt::Key_I);
815 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorItem() ) );
816 a->setEnabled (false);
818 formatMenu->addAction (a);
819 actionListBranches.append(a);
820 actionFormatColorBranch=a;
822 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color sub&tree","Edit menu" ), this);
823 a->setStatusTip ( tr( "Color Subtree" ));
824 a->setShortcut (Qt::CTRL + Qt::Key_T);
825 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
826 a->setEnabled (false);
827 formatMenu->addAction (a);
829 actionListBranches.append(a);
830 actionFormatColorSubtree=a;
832 formatMenu->addSeparator();
833 actionGroupFormatLinkStyles=new QActionGroup ( this);
834 actionGroupFormatLinkStyles->setExclusive (true);
835 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
836 a->setStatusTip (tr( "Line" ));
837 a->setToggleAction(true);
838 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
839 formatMenu->addAction (a);
840 actionFormatLinkStyleLine=a;
841 a= new QAction( tr( "Linkstyle Parabel" ), actionGroupFormatLinkStyles);
842 a->setStatusTip (tr( "Line" ));
843 a->setToggleAction(true);
844 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
845 formatMenu->addAction (a);
846 actionFormatLinkStyleParabel=a;
847 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
848 a->setStatusTip (tr( "PolyLine" ));
849 a->setToggleAction(true);
850 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
851 formatMenu->addAction (a);
852 actionFormatLinkStylePolyLine=a;
853 a= new QAction( tr( "Linkstyle Thick Parabel" ), actionGroupFormatLinkStyles);
854 a->setStatusTip (tr( "PolyParabel" ) );
855 a->setToggleAction(true);
856 a->setChecked (true);
857 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
858 formatMenu->addAction (a);
859 actionFormatLinkStylePolyParabel=a;
861 actionGroupFormatFrameTypes=new QActionGroup ( this);
862 actionGroupFormatFrameTypes->setExclusive (true);
863 a = new QAction( tr( "No Frame","Branch attribute" ), actionGroupFormatFrameTypes );
864 a->setStatusTip (tr("No Frame"));
865 a->setToggleAction(true);
866 connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameNone() ) );
867 actionFormatFrameNone=a;
868 a = new QAction( tr( "Rectangle""Branch attribute" ), actionGroupFormatFrameTypes);
869 a->setStatusTip (tr( "Rectangle" ));
870 a->setToggleAction(true);
871 connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameRectangle() ) );
872 actionFormatFrameRectangle=a;
874 a = new QAction( tr( "Include images vertically","Branch attribute" ), this);
875 a->setStatusTip ( tr ("Include top and bottom position of images into branch"));
876 a->setToggleAction(true);
877 connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesVer() ) );
878 actionFormatIncludeImagesVer=a;
880 a = new QAction( tr( "Include images horizontally","Branch attribute" ), this);
881 a->setStatusTip ( tr ("Include left and right position of images into branch"));
882 a->setToggleAction(true);
883 connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesHor() ) );
884 actionFormatIncludeImagesHor=a;
886 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
887 a->setStatusTip (tr( "Hide link" ));
888 a->setToggleAction(true);
889 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
890 actionFormatHideLinkUnselected=a;
892 formatMenu->addSeparator();
893 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
894 a->setStatusTip (tr( "Use same color for links and headings" ));
895 a->setToggleAction(true);
896 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
897 formatMenu->addAction (a);
898 actionFormatLinkColorHint=a;
900 pix.fill (Qt::white);
901 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
902 a->setStatusTip (tr( "Set Link Color" ));
903 formatMenu->addAction (a);
904 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
905 actionFormatLinkColor=a;
907 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
908 a->setStatusTip (tr( "Set Background Color" ));
909 formatMenu->addAction (a);
910 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
911 actionFormatBackColor=a;
915 void Main::setupViewActions()
917 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
918 tb->setLabel( "View Actions" );
919 tb->setObjectName ("viewTB");
920 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
923 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
924 a->setStatusTip ( tr( "Zoom reset" ) );
925 a->setShortcut (Qt::CTRL + Qt::Key_0 );
927 viewMenu->addAction (a);
928 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
930 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
931 a->setStatusTip (tr( "Zoom in" ));
932 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
934 viewMenu->addAction (a);
935 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
937 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
938 a->setStatusTip (tr( "Zoom out" ));
939 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
941 viewMenu->addAction (a);
942 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
945 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
946 a->setStatusTip ( tr( "Show Note Editor" ));
947 a->setShortcut ( Qt::CTRL + Qt::Key_E );
948 a->setToggleAction(true);
949 if (textEditor->showWithMain())
954 viewMenu->addAction (a);
955 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
956 actionViewToggleNoteEditor=a;
958 a = new QAction( tr( "Show history window","View action" ),this );
959 a->setStatusTip ( tr( "Show history window" ));
960 a->setShortcut ( Qt::CTRL + Qt::Key_H );
961 a->setToggleAction(false);
962 viewMenu->addAction (a);
963 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
964 actionViewToggleHistoryWindow=a;
966 a = new QAction(tr( "Next Window","View action" ), this);
967 a->setStatusTip ( tr( "&Next Window" ) );
968 a->setShortcut (Qt::ALT + Qt::Key_N );
969 viewMenu->addAction (a);
970 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
972 a = new QAction (tr( "Previous Window","View action" ), this );
973 a->setStatusTip (tr( "&Previous Window" ));
974 a->setShortcut (Qt::ALT + Qt::Key_P );
975 viewMenu->addAction (a);
976 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
980 void Main::setupModeActions()
982 //QPopupMenu *menu = new QPopupMenu( this );
983 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
985 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
986 tb->setObjectName ("modesTB");
988 actionGroupModModes=new QActionGroup ( this);
989 actionGroupModModes->setExclusive (true);
990 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
991 a->setShortcut (Qt::Key_J);
992 a->setStatusTip ( tr( "Use modifier to color branches" ));
993 a->setToggleAction(true);
996 actionModModeColor=a;
998 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
999 a->setShortcut( Qt::Key_K);
1000 a->setStatusTip( tr( "Use modifier to copy" ));
1001 a->setToggleAction(true);
1003 actionModModeCopy=a;
1005 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1006 a->setShortcut (Qt::Key_L);
1007 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1008 a->setToggleAction(true);
1010 actionModModeXLink=a;
1014 void Main::setupFlagActions()
1016 // Create System Flags
1017 systemFlagsDefault = new FlagRowObj ();
1018 systemFlagsDefault->setVisibility (false);
1019 systemFlagsDefault->setName ("systemFlagsDef");
1021 FlagObj *fo = new FlagObj ();
1022 fo->load(QPixmap(flagsPath+"flag-note.png"));
1023 fo->setName("note");
1024 fo->setToolTip(tr("Note","Systemflag"));
1025 systemFlagsDefault->addFlag (fo); // makes deep copy
1027 fo->load(QPixmap(flagsPath+"flag-url.png"));
1029 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
1030 systemFlagsDefault->addFlag (fo);
1032 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1033 fo->setName("vymLink");
1034 fo->setToolTip(tr("Link to another vym map","Systemflag"));
1035 systemFlagsDefault->addFlag (fo);
1037 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1038 fo->setName("scrolledright");
1039 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
1040 systemFlagsDefault->addFlag (fo);
1042 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1043 fo->setName("tmpUnscrolledright");
1044 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
1045 systemFlagsDefault->addFlag (fo);
1047 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1048 fo->setName("hideInExport");
1049 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
1050 systemFlagsDefault->addFlag (fo);
1052 // Create Standard Flags
1053 QToolBar *tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1054 tb->setObjectName ("standardFlagTB");
1056 standardFlagsDefault = new FlagRowObj ();
1057 standardFlagsDefault->setVisibility (false);
1058 standardFlagsDefault->setName ("standardFlagsDef");
1059 standardFlagsDefault->setToolBar (tb);
1061 fo->load(QPixmap(flagsPath+"flag-exclamationmark.png"));
1062 fo->setName ("exclamationmark");
1063 fo->setGroup("standard-mark");
1064 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1067 a->setCheckable(true);
1068 a->setObjectName(fo->getName());
1069 a->setToolTip(tr("Take care!","Standardflag"));
1070 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1071 standardFlagsDefault->addFlag (fo); // makes deep copy
1073 fo->load(QPixmap(flagsPath+"flag-questionmark.png"));
1074 fo->setName("questionmark");
1075 fo->setGroup("standard-mark");
1076 a=new QAction (fo->getPixmap(),fo->getName(),this);
1079 a->setCheckable(true);
1080 a->setObjectName(fo->getName());
1081 a->setToolTip(tr("Really?","Standardflag"));
1082 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1083 standardFlagsDefault->addFlag (fo);
1085 fo->load(QPixmap(flagsPath+"flag-hook-green.png"));
1086 fo->setName("hook-green");
1087 fo->setGroup("standard-hook");
1088 a=new QAction (fo->getPixmap(),fo->getName(),this);
1091 a->setCheckable(true);
1092 a->setObjectName(fo->getName());
1093 a->setToolTip(tr("ok!","Standardflag"));
1094 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1095 standardFlagsDefault->addFlag (fo);
1097 fo->load(QPixmap(flagsPath+"flag-cross-red.png"));
1098 fo->setName("cross-red");
1099 fo->setGroup("standard-hook");
1100 a=new QAction (fo->getPixmap(),fo->getName(),this);
1103 a->setCheckable(true);
1104 a->setObjectName(fo->getName());
1105 a->setToolTip(tr("Not ok!","Standardflag"));
1106 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1107 standardFlagsDefault->addFlag (fo);
1109 fo->load(QPixmap(flagsPath+"flag-stopsign.png"));
1110 fo->setName("stopsign");
1111 a=new QAction (fo->getPixmap(),fo->getName(),this);
1114 a->setCheckable(true);
1115 a->setObjectName(fo->getName());
1116 a->setToolTip(tr("This won't work!","Standardflag"));
1117 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1118 standardFlagsDefault->addFlag (fo);
1120 fo->load(QPixmap(flagsPath+"flag-smiley-good.png"));
1121 fo->setName("smiley-good");
1122 fo->setGroup("standard-smiley");
1123 a=new QAction (fo->getPixmap(),fo->getName(),this);
1126 a->setCheckable(true);
1127 a->setObjectName(fo->getName());
1128 a->setToolTip(tr("Good","Standardflag"));
1129 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1130 standardFlagsDefault->addFlag (fo);
1132 fo->load(QPixmap(flagsPath+"flag-smiley-sad.png"));
1133 fo->setName("smiley-sad");
1134 fo->setGroup("standard-smiley");
1135 a=new QAction (fo->getPixmap(),fo->getName(),this);
1138 a->setCheckable(true);
1139 a->setObjectName(fo->getName());
1140 a->setToolTip(tr("Bad","Standardflag"));
1141 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1142 standardFlagsDefault->addFlag (fo);
1144 fo->load(QPixmap(flagsPath+"flag-smiley-omg.png"));
1145 // Original omg.png (in KDE emoticons)
1146 fo->setName("smiley-omg");
1147 fo->setGroup("standard-smiley");
1148 a=new QAction (fo->getPixmap(),fo->getName(),this);
1151 a->setCheckable(true);
1152 a->setObjectName(fo->getName());
1153 a->setToolTip(tr("Oh no!","Standardflag"));
1154 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1155 standardFlagsDefault->addFlag (fo);
1157 fo->load(QPixmap(flagsPath+"flag-kalarm.png"));
1158 fo->setName("clock");
1159 a=new QAction (fo->getPixmap(),fo->getName(),this);
1162 a->setCheckable(true);
1163 a->setObjectName(fo->getName());
1164 a->setToolTip(tr("Time critical","Standardflag"));
1165 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1166 standardFlagsDefault->addFlag (fo);
1168 fo->load(QPixmap(flagsPath+"flag-phone.png"));
1169 fo->setName("phone");
1170 a=new QAction (fo->getPixmap(),fo->getName(),this);
1173 a->setCheckable(true);
1174 a->setObjectName(fo->getName());
1175 a->setToolTip(tr("Call...","Standardflag"));
1176 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1177 standardFlagsDefault->addFlag (fo);
1179 fo->load(QPixmap(flagsPath+"flag-lamp.png"));
1180 fo->setName("lamp");
1181 a=new QAction (fo->getPixmap(),fo->getName(),this);
1184 a->setCheckable(true);
1185 a->setObjectName(fo->getName());
1186 a->setToolTip(tr("Idea!","Standardflag"));
1187 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1188 standardFlagsDefault->addFlag (fo);
1190 fo->load(QPixmap(flagsPath+"flag-arrow-up.png"));
1191 fo->setName("arrow-up");
1192 fo->setGroup("standard-arrow");
1193 a=new QAction (fo->getPixmap(),fo->getName(),this);
1196 a->setCheckable(true);
1197 a->setObjectName(fo->getName());
1198 a->setToolTip(tr("Important","Standardflag"));
1199 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1200 standardFlagsDefault->addFlag (fo);
1202 fo->load(QPixmap(flagsPath+"flag-arrow-down.png"));
1203 fo->setName("arrow-down");
1204 fo->setGroup("standard-arrow");
1205 a=new QAction (fo->getPixmap(),fo->getName(),this);
1208 a->setCheckable(true);
1209 a->setObjectName(fo->getName());
1210 a->setToolTip(tr("Unimportant","Standardflag"));
1211 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1212 standardFlagsDefault->addFlag (fo);
1214 fo->load(QPixmap(flagsPath+"flag-arrow-2up.png"));
1215 fo->setName("2arrow-up");
1216 fo->setGroup("standard-arrow");
1217 a=new QAction (fo->getPixmap(),fo->getName(),this);
1220 a->setCheckable(true);
1221 a->setObjectName(fo->getName());
1222 a->setToolTip(tr("Very important!","Standardflag"));
1223 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1224 standardFlagsDefault->addFlag (fo);
1226 fo->load(QPixmap(flagsPath+"flag-arrow-2down.png"));
1227 fo->setName("2arrow-down");
1228 fo->setGroup("standard-arrow");
1229 a=new QAction (fo->getPixmap(),fo->getName(),this);
1232 a->setCheckable(true);
1233 a->setObjectName(fo->getName());
1234 a->setToolTip(tr("Very unimportant!","Standardflag"));
1235 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1236 standardFlagsDefault->addFlag (fo);
1238 fo->load(QPixmap(flagsPath+"flag-thumb-up.png"));
1239 fo->setName("thumb-up");
1240 fo->setGroup("standard-thumb");
1241 a=new QAction (fo->getPixmap(),fo->getName(),this);
1244 a->setCheckable(true);
1245 a->setObjectName(fo->getName());
1246 a->setToolTip(tr("I like this","Standardflag"));
1247 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1248 standardFlagsDefault->addFlag (fo);
1250 fo->load(QPixmap(flagsPath+"flag-thumb-down.png"));
1251 fo->setName("thumb-down");
1252 fo->setGroup("standard-thumb");
1253 a=new QAction (fo->getPixmap(),fo->getName(),this);
1256 a->setCheckable(true);
1257 a->setObjectName(fo->getName());
1258 a->setToolTip(tr("I do not like this","Standardflag"));
1259 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1260 standardFlagsDefault->addFlag (fo);
1262 fo->load(QPixmap(flagsPath+"flag-rose.png"));
1263 fo->setName("rose");
1264 a=new QAction (fo->getPixmap(),fo->getName(),this);
1267 a->setCheckable(true);
1268 a->setObjectName(fo->getName());
1269 a->setToolTip(tr("Rose","Standardflag"));
1270 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1271 standardFlagsDefault->addFlag (fo);
1273 fo->load(QPixmap(flagsPath+"flag-heart.png"));
1274 fo->setName("heart");
1275 a=new QAction (fo->getPixmap(),fo->getName(),this);
1277 a->setCheckable(true);
1278 a->setObjectName(fo->getName());
1279 a->setToolTip(tr("I just love... ","Standardflag"));
1280 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1281 standardFlagsDefault->addFlag (fo);
1283 fo->load(QPixmap(flagsPath+"flag-present.png"));
1284 fo->setName("present");
1285 a=new QAction (fo->getPixmap(),fo->getName(),this);
1288 a->setCheckable(true);
1289 a->setObjectName(fo->getName());
1290 a->setToolTip(tr("Surprise!","Standardflag"));
1291 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1292 standardFlagsDefault->addFlag (fo);
1294 fo->load(QPixmap(flagsPath+"flag-flash.png"));
1295 fo->setName("flash");
1296 a=new QAction (fo->getPixmap(),fo->getName(),this);
1299 a->setCheckable(true);
1300 a->setObjectName(fo->getName());
1301 a->setToolTip(tr("Dangerous","Standardflag"));
1302 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1303 standardFlagsDefault->addFlag (fo);
1305 fo->load(QPixmap(flagsPath+"flag-info.png"));
1306 // Original: xsldbg_output.png
1307 fo->setName("info");
1308 a=new QAction (fo->getPixmap(),fo->getName(),this);
1311 a->setCheckable(true);
1312 a->setObjectName(fo->getName());
1313 a->setToolTip(tr("Info","Standardflag"));
1314 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1315 standardFlagsDefault->addFlag (fo);
1317 fo->load(QPixmap(flagsPath+"flag-lifebelt.png"));
1318 // Original khelpcenter.png
1319 fo->setName("lifebelt");
1320 a=new QAction (fo->getPixmap(),fo->getName(),this);
1323 a->setCheckable(true);
1324 a->setObjectName(fo->getName());
1325 a->setToolTip(tr("This will help","Standardflag"));
1326 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1327 standardFlagsDefault->addFlag (fo);
1333 void Main::setupSettingsActions()
1335 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1339 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1340 a->setStatusTip ( tr( "Set application to open pdf files"));
1341 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1342 settingsMenu->addAction (a);
1344 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1345 a->setStatusTip( tr( "Set application to open external links"));
1346 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1347 settingsMenu->addAction (a);
1349 settingsMenu->addSeparator();
1350 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1351 a->setStatusTip( tr( "Edit branch after adding it" ));
1352 a->setToggleAction(true);
1353 a->setOn ( settings.value ("/mapeditor/editmode/autoEdit",true).toBool());
1354 settingsMenu->addAction (a);
1355 actionSettingsAutoEdit=a;
1357 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1358 a->setStatusTip( tr( "Select branch after adding it" ));
1359 a->setToggleAction(true);
1360 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectHeading",false).toBool() );
1361 settingsMenu->addAction (a);
1362 actionSettingsAutoSelectHeading=a;
1364 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1365 a->setStatusTip( tr( "Select heading before editing" ));
1366 a->setToggleAction(true);
1367 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1368 settingsMenu->addAction (a);
1369 actionSettingsAutoSelectText=a;
1371 a= new QAction( tr( "Delete key","Settings action" ), this);
1372 a->setStatusTip( tr( "Delete key for deleting branches" ));
1373 a->setToggleAction(true);
1374 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",false).toBool() );
1375 settingsMenu->addAction (a);
1376 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1377 actionSettingsUseDelKey=a;
1379 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1380 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1381 a->setToggleAction(true);
1382 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1383 settingsMenu->addAction (a);
1384 actionSettingsUseFlagGroups=a;
1386 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1387 a->setStatusTip( tr( "Use hide flag during exports " ));
1388 a->setToggleAction(true);
1389 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1390 settingsMenu->addAction (a);
1391 actionSettingsUseHideExport=a;
1395 void Main::setupTestActions()
1397 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1400 a = new QAction( "Test function" , this);
1401 a->setStatusTip( "Call test function" );
1402 a->setShortcut (Qt::Key_F4 );
1403 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction() ) );
1404 testMenu->addAction (a);
1405 a = new QAction( "Command" , this);
1406 a->setStatusTip( "Enter command to call in editor" );
1407 a->setShortcut (Qt::Key_F5 );
1408 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1409 testMenu->addAction (a);
1413 void Main::setupHelpActions()
1415 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1418 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1419 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1420 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1421 helpMenu->addAction (a);
1423 a = new QAction( tr( "About VYM","Help action" ), this);
1424 a->setStatusTip( tr( "About VYM")+" "__VYM);
1425 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1426 helpMenu->addAction (a);
1428 a = new QAction( tr( "About QT","Help action" ), this);
1429 a->setStatusTip( tr( "Information about QT toolkit" ));
1430 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1431 helpMenu->addAction (a);
1435 void Main::setupContextMenus()
1439 // Context Menu for branch or mapcenter
1440 branchContextMenu =new QMenu (this);
1443 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1444 branchAddContextMenu->addAction (actionEditPaste );
1445 branchAddContextMenu->addAction ( actionEditAddBranch );
1446 branchAddContextMenu->addAction ( actionEditAddBranchBefore );
1447 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1448 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1449 branchAddContextMenu->addSeparator();
1450 branchAddContextMenu->addAction ( actionEditImportAdd );
1451 branchAddContextMenu->addAction ( actionEditImportReplace );
1454 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1455 branchRemoveContextMenu->addAction (actionEditCut);
1456 branchRemoveContextMenu->addAction ( actionEditDelete );
1457 branchRemoveContextMenu->addAction ( actionEditDeleteKeepChilds );
1458 branchRemoveContextMenu->addAction ( actionEditDeleteChilds );
1461 actionEditSaveBranch->addTo( branchContextMenu );
1463 branchContextMenu->addSeparator();
1464 branchContextMenu->addAction ( actionFormatFrameNone );
1465 branchContextMenu->addAction ( actionFormatFrameRectangle);
1466 branchContextMenu->addAction ( actionFormatHideLinkUnselected );
1468 branchContextMenu->addSeparator();
1469 branchContextMenu->addAction ( actionEditLoadImage);
1470 branchContextMenu->addAction ( actionFormatIncludeImagesVer );
1471 branchContextMenu->addAction ( actionFormatIncludeImagesHor );
1473 // Submenu for Links (URLs, vymLinks)
1474 branchLinksContextMenu =new QMenu (this);
1476 branchContextMenu->addSeparator();
1477 branchLinksContextMenu=branchContextMenu->addMenu(tr("URLs and vymLinks","Context menu name"));
1478 branchLinksContextMenu->addAction ( actionEditOpenURL );
1479 branchLinksContextMenu->addAction ( actionEditOpenURLTab );
1480 branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
1481 branchLinksContextMenu->addAction ( actionEditURL );
1482 branchLinksContextMenu->addAction ( actionEditHeading2URL );
1483 branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
1484 if (settings.value( "/mainwindow/showTestMenu",true).toBool() )
1486 branchLinksContextMenu->addAction ( actionEditFATE2URL );
1488 branchLinksContextMenu->addSeparator();
1489 branchLinksContextMenu->addAction ( actionEditOpenVymLink );
1490 branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
1491 branchLinksContextMenu->addAction ( actionEditVymLink );
1492 branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
1495 // Context Menu for XLinks in a branch menu
1496 // This will be populated "on demand" in MapEditor::updateActions
1497 branchContextMenu->addSeparator();
1498 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1499 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1500 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1501 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1504 // Context menu for floatimage
1505 floatimageContextMenu =new QMenu (this);
1506 a= new QAction (tr ("Save image","Context action"),this);
1507 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1508 floatimageContextMenu->addAction (a);
1510 floatimageContextMenu->addSeparator();
1511 actionEditCopy->addTo( floatimageContextMenu );
1512 actionEditCut->addTo( floatimageContextMenu );
1514 floatimageContextMenu->addSeparator();
1515 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1518 // Context menu for canvas
1519 canvasContextMenu =new QMenu (this);
1520 actionEditMapInfo->addTo( canvasContextMenu );
1521 canvasContextMenu->insertSeparator();
1522 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1523 canvasContextMenu->insertSeparator();
1524 actionFormatLinkColorHint->addTo( canvasContextMenu );
1525 actionFormatLinkColor->addTo( canvasContextMenu );
1526 actionFormatBackColor->addTo( canvasContextMenu );
1528 // Menu for last opened files
1529 // Read settings initially
1531 int j=settings.readNumEntry( "/lastMaps/number",0);
1532 for (int i=1;i<=j;i++)
1534 s=settings.value(QString("/lastMaps/map-%1").arg(i),"").toString();
1535 if (!s.isEmpty() && j<=maxLastMaps)
1538 setupLastMapsMenu();
1539 connect( fileLastMapsMenu, SIGNAL( triggered(QAction *) ), this, SLOT( fileLoadLast(QAction*) ) );
1542 void Main::setupLastMapsMenu()
1544 // Remove double entries
1545 QStringList::Iterator it=lastMaps.begin();
1546 QStringList::Iterator jt;
1547 while (it!=lastMaps.end() )
1551 while (jt!=lastMaps.end() )
1554 jt=lastMaps.remove(jt);
1561 // Limit length of list to maxLastMaps
1562 while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
1564 // build Menu from lastMaps string list
1565 fileLastMapsMenu->clear();
1566 for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1567 fileLastMapsMenu->addAction (*it );
1570 void Main::hideEvent (QHideEvent * )
1572 if (!textEditor->isMinimized() ) textEditor->hide();
1575 void Main::showEvent (QShowEvent * )
1577 if (textEditor->showWithMain()) textEditor->showNormal();
1580 bool Main::reallyWriteDirectory(const QString &dir)
1582 QStringList eList = QDir(dir).entryList();
1583 if (eList.first() ==".") eList.pop_front(); // remove "."
1584 if (eList.first() =="..") eList.pop_front(); // remove "."
1585 if (!eList.isEmpty())
1587 QMessageBox mb( __VYM,
1588 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?","write directory").arg(dir),
1589 QMessageBox::Warning,
1591 QMessageBox::Cancel | QMessageBox::Default,
1592 QMessageBox::QMessageBox::NoButton );
1594 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1595 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1598 case QMessageBox::Yes:
1601 case QMessageBox::Cancel:
1609 QString Main::browseDirectory (const QString &caption)
1611 Q3FileDialog fd(this,caption);
1612 fd.setMode (Q3FileDialog::DirectoryOnly);
1613 fd.setCaption(__VYM " - "+caption);
1616 if ( fd.exec() == QDialog::Accepted )
1617 return fd.selectedFile();
1622 MapEditor* Main::currentMapEditor() const
1624 if ( tabWidget->currentPage() &&
1625 tabWidget->currentPage()->inherits( "MapEditor" ) )
1626 return (MapEditor*)tabWidget->currentPage();
1630 //TODO not used now, maybe use this for overview window later
1631 void Main::newView()
1633 // Open a new view... have it delete when closed.
1634 Main *m = new Main(0, 0, Qt::WDestructiveClose);
1635 qApp->setMainWidget(m);
1637 qApp->setMainWidget(0);
1640 void Main::editorChanged(QWidget *)
1642 // Unselect all possibly selected objects
1643 // (Important to update note editor)
1646 for (i=0;i<=tabWidget->count() -1;i++)
1649 me=(MapEditor*)tabWidget->page(i);
1652 currentMapEditor()->reselect();
1654 // Update actions to in menus and toolbars according to editor
1655 currentMapEditor()->updateActions();
1658 void Main::fileNew()
1660 QString fn="unnamed";
1661 MapEditor* medit = new MapEditor ( NULL);
1662 tabWidget->addTab (medit,fn);
1663 tabWidget->showPage(medit);
1664 medit->viewport()->setFocus();
1665 // For the very first map we do not have flagrows yet...
1666 medit->select("mc:");
1669 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1671 ErrorCode err=success;
1673 // fn is usually the archive, mapfile the file after uncompressing
1676 // Make fn absolute (needed for unzip)
1677 fn=QDir (fn).absPath();
1683 // Check, if map is already loaded
1685 while (i<=tabWidget->count() -1)
1687 me=(MapEditor*)tabWidget->page(i);
1688 if (me->getFilePath() == fn)
1690 // Already there, ask for confirmation
1691 QMessageBox mb( __VYM,
1692 tr("The map %1\nis already opened."
1693 "Opening the same map in multiple editors may lead \n"
1694 "to confusion when finishing working with vym."
1695 "Do you want to").arg(fn),
1696 QMessageBox::Warning,
1697 QMessageBox::Yes | QMessageBox::Default,
1698 QMessageBox::Cancel | QMessageBox::Escape,
1699 QMessageBox::NoButton);
1700 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1701 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1704 case QMessageBox::Yes:
1706 i=tabWidget->count();
1708 case QMessageBox::Cancel:
1720 if ( !fn.isEmpty() )
1722 me = currentMapEditor();
1723 int tabIndex=tabWidget->currentPageIndex();
1724 // Check first, if mapeditor exists
1725 // If it is not default AND we want a new map,
1726 // create a new mapeditor in a new tab
1727 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1729 me= new MapEditor ( NULL);
1730 tabWidget->addTab (me,fn);
1731 tabIndex=tabWidget->indexOf (me);
1732 tabWidget->setCurrentPage (tabIndex);
1735 // Check, if file exists (important for creating new files
1736 // from command line
1737 if (!QFile(fn).exists() )
1739 QMessageBox mb( __VYM,
1740 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1741 QMessageBox::Question,
1743 QMessageBox::Cancel | QMessageBox::Default,
1744 QMessageBox::NoButton );
1746 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1747 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1750 case QMessageBox::Yes:
1752 currentMapEditor()->setFilePath(fn);
1753 tabWidget->setTabLabel (currentMapEditor(),
1754 currentMapEditor()->getFileName() );
1755 statusBar()->message( "Created " + fn , statusbarTime );
1758 case QMessageBox::Cancel:
1759 // don't create new map
1760 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1767 //tabWidget->currentPage() won't be NULL here, because of above...
1768 tabWidget->showPage(me);
1769 me->viewport()->setFocus();
1771 // Create temporary directory for packing
1773 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
1776 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1777 tr("Couldn't create temporary directory before load\n"));
1781 // Try to unzip file
1782 err=unzipDir (tmpMapDir,fn);
1786 me->setZipped(false);
1789 me->setZipped(true);
1791 // Look for mapname.xml
1792 mapfile= fn.left(fn.findRev(".",-1,true));
1793 mapfile=mapfile.section( '/', -1 );
1794 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1795 if (!file.exists() )
1797 // mapname.xml does not exist, well,
1798 // maybe some renamed the mapname.vym file...
1799 // Try to find any .xml in the toplevel
1800 // directory of the .vym file
1801 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1802 if (flist.count()==1)
1804 // Only one entry, take this one
1805 mapfile=tmpMapDir + "/"+flist.first();
1808 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1809 *it=tmpMapDir + "/" + *it;
1810 // TODO Multiple entries, load all (but only the first one into this ME)
1811 //mainWindow->fileLoadFromTmp (flist);
1812 //returnCode=1; // Silently forget this attempt to load
1813 qWarning ("MainWindow::load (fn) multimap found...");
1816 if (flist.isEmpty() )
1818 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1819 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1822 } //file doesn't exist
1824 mapfile=file.name();
1829 // Save existing filename in case we import
1830 QString fn_org=me->getFilePath();
1832 // Finally load map into mapEditor
1833 me->setFilePath (mapfile,fn);
1834 err=me->load(mapfile,lmode);
1836 // Restore old (maybe empty) filepath, if this is an import
1838 me->setFilePath (fn_org);
1841 // Finally check for errors and go home
1844 if (lmode==NewMap) fileCloseMap();
1845 statusBar()->message( "Could not load " + fn, statusbarTime );
1850 me->setFilePath (fn);
1851 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1852 if (fn.left(9)!="/tmp/vym-")
1854 // Only append to lastMaps if not loaded from a tmpDir
1855 // e.g. imported bookmarks are in a tmpDir
1856 lastMaps.prepend(me->getFilePath() );
1857 setupLastMapsMenu();
1859 actionFilePrint->setEnabled (true);
1861 statusBar()->message( "Loaded " + fn, statusbarTime );
1865 removeDir (QDir(tmpMapDir));
1871 void Main::fileLoad(const LoadMode &lmode)
1873 QStringList filters;
1874 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1875 QFileDialog *fd=new QFileDialog( this);
1876 fd->setDir (lastFileDir);
1877 fd->setFileMode (QFileDialog::ExistingFiles);
1878 fd->setFilters (filters);
1882 fd->setCaption(__VYM " - " +tr("Load vym map"));
1885 fd->setCaption(__VYM " - " +tr("Import: Add vym map to selection"));
1888 fd->setCaption(__VYM " - " +tr("Import: Replace selection with vym map"));
1894 if ( fd->exec() == QDialog::Accepted )
1896 lastFileDir=fd->directory().path();
1897 QStringList flist = fd->selectedFiles();
1898 QStringList::Iterator it = flist.begin();
1899 while( it != flist.end() )
1902 fileLoad(*it, lmode);
1909 void Main::fileLoad()
1914 void Main::fileLoadLast(QAction *a)
1916 fileLoad(lastMaps.at(fileLastMapsMenu->actions().indexOf(a)) ,NewMap);
1919 void Main::fileSave(const SaveMode &savemode)
1921 // tmp dir for zipping
1925 ErrorCode err=success;
1927 QString safeFilePath;
1929 bool saveZipped=currentMapEditor()->saveZipped();
1931 MapEditor * me=currentMapEditor();
1934 QString fn=me->getFilePath();
1935 // filename=unnamed, filepath="" in constructor...
1936 if ( !fn.isEmpty() )
1938 // We have a filepath, go on saving
1939 // First remove existing file, we
1940 // don't want to add to old zip archives
1944 QMessageBox::warning( 0, tr( "Save Error" ),
1945 fn+ tr("\ncould not be removed before saving"));
1947 // Look, if we should zip the data:
1950 QMessageBox mb( __VYM,
1951 tr("The map %1\ndid not use the compressed "
1952 "vym file format.\nWriting it uncompressed will also write images \n"
1953 "and flags and thus may overwrite files in the "
1954 "given directory\n\nDo you want to write the map").arg(fn),
1955 QMessageBox::Warning,
1956 QMessageBox::Yes | QMessageBox::Default,
1958 QMessageBox::Cancel | QMessageBox::Escape);
1959 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
1960 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
1961 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1964 case QMessageBox::Yes:
1965 // save compressed (default file format)
1968 case QMessageBox::No:
1969 // save uncompressed
1972 case QMessageBox::Cancel:
1981 // Create temporary directory for packing
1983 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
1986 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1987 tr("Couldn't create temporary directory before save\n"));
1991 safeFilePath=me->getFilePath();
1992 me->setFilePath (tmpMapDir+"/"+
1993 me->getMapName()+ ".xml",
1995 me->save (savemode);
1996 me->setFilePath (safeFilePath);
1998 zipDir (tmpMapDir,fn);
2003 safeFilePath=me->getFilePath();
2004 me->setFilePath (fn, safeFilePath);
2005 me->save (savemode);
2006 me->setFilePath (safeFilePath);
2008 } // filepath available
2011 // We have no filepath yet,
2012 // call fileSaveAs() now, this will call fileSave()
2014 fileSaveAs(savemode);
2018 if (saveZipped && !tmpMapDir.isEmpty())
2020 removeDir (QDir(tmpMapDir));
2024 statusBar()->message(
2025 tr("Saved %1").arg(me->getFilePath()),
2027 lastMaps.prepend(me->getFilePath() );
2028 setupLastMapsMenu();
2030 statusBar()->message(
2031 tr("Couldn't save ").arg(me->getFilePath()),
2035 void Main::fileSave()
2037 fileSave (CompleteMap);
2040 void Main::fileSaveAs(const SaveMode& savemode)
2044 if (currentMapEditor())
2046 if (savemode==CompleteMap)
2047 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2049 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2050 if ( !fn.isEmpty() )
2052 // Check for existing file
2053 if (QFile (fn).exists())
2055 QMessageBox mb( __VYM,
2056 tr("The file %1\nexists already. Do you want to").arg(fn),
2057 QMessageBox::Warning,
2058 QMessageBox::Yes | QMessageBox::Default,
2059 QMessageBox::Cancel | QMessageBox::Escape,
2060 QMessageBox::NoButton);
2061 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2062 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2065 case QMessageBox::Yes:
2068 case QMessageBox::Cancel:
2075 // New file, add extension to filename, if missing
2076 // This is always .vym or .vyp, depending on savemode
2077 if (savemode==CompleteMap)
2079 if (!fn.contains (".vym") && !fn.contains (".xml"))
2083 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2092 currentMapEditor()->setFilePath(fn);
2096 if (savemode==CompleteMap)
2097 tabWidget->setTabLabel (currentMapEditor(),
2098 currentMapEditor()->getFileName() );
2104 void Main::fileSaveAs()
2106 fileSaveAs (CompleteMap);
2109 void Main::fileImportKDEBookmarks()
2111 ImportKDEBookmarks im;
2113 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2114 currentMapEditor()->setFilePath ("");
2117 void Main::fileImportFirefoxBookmarks()
2119 Q3FileDialog *fd=new Q3FileDialog( this);
2120 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2121 fd->setMode (Q3FileDialog::ExistingFiles);
2122 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2123 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2126 if ( fd->exec() == QDialog::Accepted )
2128 ImportFirefoxBookmarks im;
2129 QStringList flist = fd->selectedFiles();
2130 QStringList::Iterator it = flist.begin();
2131 while( it != flist.end() )
2134 if (im.transform() &&
2135 success==fileLoad (im.getTransformedFile(),NewMap) &&
2136 currentMapEditor() )
2137 currentMapEditor()->setFilePath ("");
2144 void Main::fileImportMM()
2148 Q3FileDialog *fd=new Q3FileDialog( this);
2149 fd->setDir (lastFileDir);
2150 fd->setMode (Q3FileDialog::ExistingFiles);
2151 fd->addFilter ("Mind Manager (*.mmap)");
2152 fd->setCaption(tr("Import")+" "+"Mind Manager");
2155 if ( fd->exec() == QDialog::Accepted )
2157 lastFileDir=fd->dirPath();
2158 QStringList flist = fd->selectedFiles();
2159 QStringList::Iterator it = flist.begin();
2160 while( it != flist.end() )
2163 if (im.transform() &&
2164 success==fileLoad (im.getTransformedFile(),NewMap) &&
2165 currentMapEditor() )
2166 currentMapEditor()->setFilePath ("");
2175 void Main::fileImportDir()
2177 if (currentMapEditor())
2178 currentMapEditor()->importDir();
2181 void Main::fileExportXML()
2183 if (currentMapEditor())
2185 QString dir=browseDirectory(tr("Export XML to directory"));
2186 if (dir !="" && reallyWriteDirectory(dir) )
2187 currentMapEditor()->exportXML(dir);
2192 void Main::fileExportXHTML()
2194 MapEditor *me=currentMapEditor();
2198 ExportXHTMLDialog dia(this);
2199 dia.setFilePath (me->getFilePath() );
2200 dia.setMapName (me->getMapName() );
2203 if (dia.exec()==QDialog::Accepted)
2205 QString dir=dia.getDir();
2206 // Check, if warnings should be used before overwriting
2207 // the output directory
2210 ok=reallyWriteDirectory(dir);
2216 me->exportXML (dia.getDir() );
2217 dia.doExport(me->getMapName() );
2218 if (dia.hasChanged())
2225 void Main::fileExportImage()
2227 MapEditor *me=currentMapEditor();
2231 QFileDialog *fd=new QFileDialog (this);
2232 fd->setCaption (tr("Export map as image"));
2233 fd->setFileMode(QFileDialog::AnyFile);
2234 fd->setFilters (imageIO.getFilters() );
2235 fd->setDirectory (lastImageDir);
2238 fl=fd->selectedFiles();
2239 qWarning ("Selected "+fl.first()+" filter: "+fd->selectedFilter());
2240 me->exportImage (fl.first(), imageIO.getType (fd->selectedFilter() ) );
2245 void Main::fileExportASCII()
2247 MapEditor *me=currentMapEditor();
2251 ex.setMapCenter(me->getMapCenter());
2252 ex.addFilter ("TXT (*.txt)");
2253 ex.setCaption(__VYM " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
2254 if (ex.execDialog() )
2256 me->setExportMode(true);
2258 me->setExportMode(false);
2263 void Main::fileExportLaTeX()
2265 MapEditor *me=currentMapEditor();
2269 ex.setMapCenter(me->getMapCenter());
2270 ex.addFilter ("Tex (*.tex)");
2271 ex.setCaption(__VYM " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2272 if (ex.execDialog() )
2274 me->setExportMode(true);
2276 me->setExportMode(false);
2281 void Main::fileExportKDEBookmarks()
2283 ExportKDEBookmarks ex;
2284 MapEditor *me=currentMapEditor();
2287 ex.setMapCenter (me->getMapCenter() );
2292 void Main::fileExportTaskjuggler()
2294 ExportTaskjuggler ex;
2295 MapEditor *me=currentMapEditor();
2298 ex.setMapCenter (me->getMapCenter() );
2299 ex.setCaption ( __VYM " - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2300 ex.addFilter ("Taskjuggler (*.tjp)");
2301 if (ex.execDialog() )
2303 me->setExportMode(true);
2305 me->setExportMode(false);
2310 void Main::fileExportOOPresentation()
2312 ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to")+" Open Office");
2313 // TODO add preview in dialog
2314 //ImagePreview *p =new ImagePreview (fd);
2315 //fd->setContentsPreviewEnabled( TRUE );
2316 //fd->setContentsPreview( p, p );
2317 //fd->setPreviewMode( QFileDialog::Contents );
2318 fd->setCaption(__VYM " - " +tr("Export to")+" Open Office");
2319 fd->setDir (QDir().current());
2320 if (fd->foundConfig())
2324 if ( fd->exec() == QDialog::Accepted )
2326 QString fn=fd->selectedFile();
2327 if (!fn.contains (".odp"))
2330 //lastImageDir=fn.left(fn.findRev ("/"));
2331 if (currentMapEditor())
2332 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2336 QMessageBox::warning(0,
2338 tr("Couldn't find configuration for export to Open Office\n"));
2342 void Main::fileCloseMap()
2344 if (currentMapEditor())
2346 if (currentMapEditor()->hasChanged())
2348 QMessageBox mb( __VYM,
2349 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2350 QMessageBox::Warning,
2351 QMessageBox::Yes | QMessageBox::Default,
2353 QMessageBox::Cancel | QMessageBox::Escape );
2354 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2355 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2358 case QMessageBox::Yes:
2360 fileSave(CompleteMap);
2362 case QMessageBox::No:
2363 // close without saving
2365 case QMessageBox::Cancel:
2370 currentMapEditor()->closeMap();
2371 tabWidget->removePage(currentMapEditor());
2372 if (tabWidget->count()==0)
2373 actionFilePrint->setEnabled (false);
2377 void Main::filePrint()
2379 if (currentMapEditor())
2380 currentMapEditor()->print();
2383 void Main::fileExitVYM()
2385 // Check if one or more editors have changed
2388 for (i=0;i<=tabWidget->count() -1;i++)
2391 me=(MapEditor*)tabWidget->page(i);
2393 // If something changed, ask what to do
2394 if (me->isUnsaved())
2396 tabWidget->setCurrentPage(i);
2397 QMessageBox mb( __VYM,
2398 tr("This map is not saved yet. Do you want to"),
2399 QMessageBox::Warning,
2400 QMessageBox::Yes | QMessageBox::Default,
2402 QMessageBox::Cancel | QMessageBox::Escape );
2403 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2404 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2407 mb.setActiveWindow();
2408 switch( mb.exec() ) {
2409 case QMessageBox::Yes:
2410 // save (the changed editors) and exit
2411 fileSave(CompleteMap);
2413 case QMessageBox::No:
2414 // exit without saving
2416 case QMessageBox::Cancel:
2417 // don't save and don't exit
2421 } // loop over all MEs
2425 void Main::editUndo()
2427 if (currentMapEditor())
2428 currentMapEditor()->undo();
2431 void Main::editRedo()
2433 if (currentMapEditor())
2434 currentMapEditor()->redo();
2437 void Main::editCopy()
2439 if (currentMapEditor())
2440 currentMapEditor()->copy();
2443 void Main::editPaste()
2445 if (currentMapEditor())
2446 currentMapEditor()->paste();
2449 void Main::editCut()
2451 if (currentMapEditor())
2452 currentMapEditor()->cut();
2455 void Main::editOpenFindWindow()
2457 findWindow->popup();
2458 findWindow->raise();
2459 findWindow->setActiveWindow();
2462 void Main::editFind(QString s)
2465 BranchObj *bo=currentMapEditor()->findText(s, cs);
2468 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2471 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2472 tr("No matches found for \"%1\"").arg(s));
2476 void Main::editFindChanged()
2477 { // Notify editor, to abort the current find process
2478 currentMapEditor()->findReset();
2481 void Main::openTabs(QStringList urls)
2483 if (!urls.isEmpty())
2487 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2489 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2491 QString u=urls.takeFirst();
2492 procBrowser = new QProcess( this );
2494 procBrowser->start(browser,args);
2495 if ( !procBrowser->waitForStarted())
2497 // try to set path to browser
2498 QMessageBox::warning(0,
2500 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2501 tr("Please use Settings->")+tr("Set application to open an URL"));
2506 if (browser.contains("konqueror"))
2508 for (int i=0; i<urls.size(); i++)
2511 // Try to open new tab in existing konqueror started previously by vym
2512 p=new QProcess (this);
2514 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2515 "konqueror-mainwindow#1"<<
2518 p->start ("dcop",args);
2519 if ( !p->waitForStarted() ) success=false;
2522 QMessageBox::warning(0,
2524 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2526 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2528 for (int i=0; i<urls.size(); i++)
2530 // Try to open new tab in firefox
2531 p=new QProcess (this);
2532 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2533 p->start (browser,args);
2534 if ( !p->waitForStarted() ) success=false;
2537 QMessageBox::warning(0,
2539 tr("Couldn't start %1 to open a new tab").arg(browser));
2542 QMessageBox::warning(0,
2544 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2548 void Main::editOpenURL()
2551 if (currentMapEditor())
2553 QString url=currentMapEditor()->getURL();
2555 if (url=="") return;
2556 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2557 procBrowser = new QProcess( this );
2559 procBrowser->start(browser,args);
2560 if ( !procBrowser->waitForStarted())
2562 // try to set path to browser
2563 QMessageBox::warning(0,
2565 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2566 tr("Please use Settings->")+tr("Set application to open an URL"));
2571 void Main::editOpenURLTab()
2573 if (currentMapEditor())
2576 urls.append(currentMapEditor()->getURL());
2580 void Main::editOpenMultipleURLTabs()
2582 if (currentMapEditor())
2585 urls=currentMapEditor()->getURLs();
2591 void Main::editURL()
2593 if (currentMapEditor())
2594 currentMapEditor()->editURL();
2597 void Main::editHeading2URL()
2599 if (currentMapEditor())
2600 currentMapEditor()->editHeading2URL();
2603 void Main::editBugzilla2URL()
2605 if (currentMapEditor())
2606 currentMapEditor()->editBugzilla2URL();
2609 void Main::editFATE2URL()
2611 if (currentMapEditor())
2612 currentMapEditor()->editFATE2URL();
2615 void Main::editHeadingFinished()
2617 // only called from editHeading(), so there is a currentME
2618 MapEditor *me=currentMapEditor();
2620 #if defined(Q_OS_MACX)
2622 me->setHeading(lineedit->text());
2624 lineedit->releaseKeyboard();
2628 if (!prevSelection.isEmpty()) me->select(prevSelection);
2632 void Main::editHeading()
2634 if (currentMapEditor())
2636 MapEditor *me=currentMapEditor();
2637 QString oldSel=me->getSelectString();
2639 if (lineedit->isVisible())
2640 editHeadingFinished();
2645 QString s=currentMapEditor()->getHeading(ok,p);
2649 #if defined(Q_OS_MACX)
2650 p = currentMapEditor()->mapToGlobal( currentMapEditor()->worldMatrix().map( p));
2651 QDialog *d =new QDialog(NULL);
2652 QLineEdit *le=new QLineEdit (d);
2653 d->setWindowFlags (Qt::FramelessWindowHint);
2654 d->setGeometry(p.x(),p.y(),230,25);
2655 le->resize (d->width()-10,d->height());
2658 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2659 d->activateWindow();
2661 currentMapEditor()->setHeading (le->text());
2664 editHeadingFinished();
2666 p = currentMapEditor()->mapTo(this, currentMapEditor()->worldMatrix().map( p));
2667 lineedit->setGeometry(p.x(),p.y(),230,25);
2668 lineedit->setText(s);
2669 lineedit->setCursorPosition(1);
2670 lineedit->selectAll();
2672 lineedit->grabKeyboard();
2673 lineedit->setFocus();
2677 } // currentMapEditor()
2680 void Main::openVymLinks(const QStringList &vl)
2682 for (int j=0; j<vl.size(); j++)
2684 // compare path with already loaded maps
2688 for (i=0;i<=tabWidget->count() -1;i++)
2690 me=(MapEditor*)tabWidget->page(i);
2691 if (vl.at(j)==me->getFilePath() )
2700 if (!QFile(vl.at(j)).exists() )
2701 QMessageBox::critical( 0, tr( "Critical Error" ),
2702 tr("Couldn't open map %1").arg(vl.at(j)));
2705 fileLoad (vl.at(j), NewMap);
2706 tabWidget->setCurrentPage (tabWidget->count()-1);
2709 // Go to tab containing the map
2710 tabWidget->setCurrentPage (index);
2714 void Main::editOpenVymLink()
2716 if (currentMapEditor())
2719 vl.append(currentMapEditor()->getVymLink());
2724 void Main::editOpenMultipleVymLinks()
2726 QString currentVymLink;
2727 if (currentMapEditor())
2729 QStringList vl=currentMapEditor()->getVymLinks();
2734 void Main::editVymLink()
2736 if (currentMapEditor())
2737 currentMapEditor()->editVymLink();
2740 void Main::editDeleteVymLink()
2742 if (currentMapEditor())
2743 currentMapEditor()->deleteVymLink();
2746 void Main::editToggleHideExport()
2748 if (currentMapEditor())
2749 currentMapEditor()->toggleHideExport();
2752 void Main::editMapInfo()
2754 if (currentMapEditor())
2755 currentMapEditor()->editMapInfo();
2758 void Main::editMoveUp()
2760 if (currentMapEditor())
2761 currentMapEditor()->moveBranchUp();
2764 void Main::editMoveDown()
2766 if (currentMapEditor())
2767 currentMapEditor()->moveBranchDown();
2770 void Main::editToggleScroll()
2772 if (currentMapEditor())
2774 currentMapEditor()->toggleScroll();
2778 void Main::editUnScrollAll()
2780 if (currentMapEditor())
2781 currentMapEditor()->unScrollAll();
2784 void Main::editNewBranch()
2786 MapEditor *me=currentMapEditor();
2787 if (!lineedit->isVisible() && me)
2789 BranchObj *bo=(BranchObj*)me->getSelection();
2790 BranchObj *newbo=me->addNewBranch(0);
2793 me->select (newbo->getSelectString());
2797 if (actionSettingsAutoEdit->isOn())
2799 if (!actionSettingsAutoSelectHeading->isOn())
2800 prevSelection=bo->getSelectString();
2806 void Main::editNewBranchBefore()
2808 MapEditor *me=currentMapEditor();
2809 if (!lineedit->isVisible() && me)
2811 BranchObj *bo=(BranchObj*)me->getSelection();
2812 BranchObj *newbo=me->addNewBranchBefore();
2815 me->select (newbo->getSelectString());
2819 if (actionSettingsAutoEdit->isOn())
2821 if (!actionSettingsAutoSelectHeading->isOn())
2822 prevSelection=bo->getSelectString();
2828 void Main::editNewBranchAbove()
2830 MapEditor *me=currentMapEditor();
2831 if (!lineedit->isVisible() && me)
2833 BranchObj *bo=(BranchObj*)me->getSelection();
2834 BranchObj *newbo=me->addNewBranch (-1);
2837 me->select (newbo->getSelectString());
2841 if (actionSettingsAutoEdit->isOn())
2843 if (!actionSettingsAutoSelectHeading->isOn())
2844 prevSelection=bo->getSelectString();
2850 void Main::editNewBranchBelow()
2852 MapEditor *me=currentMapEditor();
2853 if (!lineedit->isVisible() && me)
2855 BranchObj *bo=(BranchObj*)me->getSelection();
2856 BranchObj *newbo=me->addNewBranch (1);
2859 me->select (newbo->getSelectString());
2863 if (actionSettingsAutoEdit->isOn())
2865 if (!actionSettingsAutoSelectHeading->isOn())
2866 prevSelection=bo->getSelectString();
2872 void Main::editImportAdd()
2874 fileLoad (ImportAdd);
2877 void Main::editImportReplace()
2879 fileLoad (ImportReplace);
2882 void Main::editSaveBranch()
2884 fileSaveAs (PartOfMap);
2887 void Main::editDeleteKeepChilds()
2889 if (currentMapEditor())
2890 currentMapEditor()->deleteKeepChilds();
2893 void Main::editDeleteChilds()
2895 if (currentMapEditor())
2896 currentMapEditor()->deleteChilds();
2899 void Main::editDeleteSelection()
2901 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2902 currentMapEditor()->deleteSelection();
2905 void Main::editUpperBranch()
2907 if (currentMapEditor())
2908 currentMapEditor()->selectUpperBranch();
2911 void Main::editLowerBranch()
2913 if (currentMapEditor())
2914 currentMapEditor()->selectLowerBranch();
2917 void Main::editLeftBranch()
2919 if (currentMapEditor())
2920 currentMapEditor()->selectLeftBranch();
2923 void Main::editRightBranch()
2925 if (currentMapEditor())
2926 currentMapEditor()->selectRightBranch();
2929 void Main::editFirstBranch()
2931 if (currentMapEditor())
2932 currentMapEditor()->selectFirstBranch();
2935 void Main::editLastBranch()
2937 if (currentMapEditor())
2938 currentMapEditor()->selectLastBranch();
2941 void Main::editLoadImage()
2943 if (currentMapEditor())
2944 currentMapEditor()->loadFloatImage();
2947 void Main::editSaveImage()
2949 if (currentMapEditor())
2950 currentMapEditor()->saveFloatImage();
2953 void Main::editFollowXLink(QAction *a)
2956 if (currentMapEditor())
2957 currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
2960 void Main::editEditXLink(QAction *a)
2962 if (currentMapEditor())
2963 currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
2966 void Main::formatSelectColor()
2968 if (currentMapEditor())
2970 QColor col = QColorDialog::getColor((currentColor ), this );
2971 if ( !col.isValid() ) return;
2972 colorChanged( col );
2976 void Main::formatPickColor()
2978 if (currentMapEditor())
2979 colorChanged( currentMapEditor()->getCurrentHeadingColor() );
2982 void Main::colorChanged(QColor c)
2984 QPixmap pix( 16, 16 );
2986 actionFormatColor->setIconSet( pix );
2990 void Main::formatColorItem()
2992 if (currentMapEditor())
2993 currentMapEditor()->colorItem(currentColor);
2996 void Main::formatColorBranch()
2998 if (currentMapEditor())
2999 currentMapEditor()->colorBranch(currentColor);
3002 void Main::formatLinkStyleLine()
3004 if (currentMapEditor())
3005 currentMapEditor()->setMapLinkStyle("StyleLine");
3008 void Main::formatLinkStyleParabel()
3010 if (currentMapEditor())
3011 currentMapEditor()->setMapLinkStyle("StyleParabel");
3014 void Main::formatLinkStylePolyLine()
3016 if (currentMapEditor())
3017 currentMapEditor()->setMapLinkStyle("StylePolyLine");
3020 void Main::formatLinkStylePolyParabel()
3022 if (currentMapEditor())
3023 currentMapEditor()->setMapLinkStyle("StylePolyParabel");
3026 void Main::formatSelectBackColor()
3028 if (currentMapEditor())
3029 currentMapEditor()->selectMapBackgroundColor();
3032 void Main::formatSelectLinkColor()
3034 if (currentMapEditor())
3035 currentMapEditor()->selectMapLinkColor();
3038 void Main::formatToggleLinkColorHint()
3040 currentMapEditor()->toggleMapLinkColorHint();
3043 void Main::formatFrameNone()
3045 if (currentMapEditor())
3046 currentMapEditor()->setFrame(NoFrame);
3049 void Main::formatFrameRectangle()
3051 if (currentMapEditor())
3052 currentMapEditor()->setFrame(Rectangle);
3055 void Main::formatIncludeImagesVer()
3057 if (currentMapEditor())
3058 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
3061 void Main::formatIncludeImagesHor()
3063 if (currentMapEditor())
3064 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
3067 void Main::formatHideLinkUnselected()
3069 if (currentMapEditor())
3070 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3073 void Main::viewZoomReset()
3075 if (currentMapEditor())
3079 currentMapEditor()->setWorldMatrix( m );
3080 currentMapEditor()->setViewCenter();
3081 currentMapEditor()->adjustCanvasSize();
3085 void Main::viewZoomIn()
3087 if (currentMapEditor())
3089 QMatrix m = currentMapEditor()->worldMatrix();
3090 m.scale( 1.25, 1.25 );
3091 currentMapEditor()->setWorldMatrix( m );
3092 currentMapEditor()->setViewCenter();
3093 currentMapEditor()->adjustCanvasSize();
3097 void Main::viewZoomOut()
3099 if (currentMapEditor())
3101 QMatrix m = currentMapEditor()->worldMatrix();
3102 m.scale( 0.8, 0.8 );
3103 currentMapEditor()->setWorldMatrix( m );
3104 currentMapEditor()->setViewCenter();
3105 currentMapEditor()->adjustCanvasSize();
3109 bool Main::settingsPDF()
3111 // Default browser is set in constructor
3113 QString text = QInputDialog::getText(
3114 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3115 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3117 settings.setValue ("/mainwindow/readerPDF",text);
3122 bool Main::settingsURL()
3124 // Default browser is set in constructor
3126 QString text = QInputDialog::getText(
3127 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3128 settings.value("/mainwindow/readerURL").toString()
3131 settings.setValue ("/mainwindow/readerURL",text);
3135 void Main::settingsToggleDelKey()
3137 if (actionSettingsUseDelKey->isOn())
3139 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3142 actionEditDelete->setAccel (QKeySequence (""));
3146 void Main::windowToggleNoteEditor()
3148 if (textEditor->showWithMain() )
3149 windowHideNoteEditor();
3151 windowShowNoteEditor();
3154 void Main::windowToggleHistory()
3156 if (currentMapEditor())
3157 currentMapEditor()->toggleHistoryWindow();
3160 void Main::updateNoteFlag()
3162 if (currentMapEditor())
3163 currentMapEditor()->updateNoteFlag();
3166 void Main::updateActions()
3168 MapEditor *me=currentMapEditor();
3171 // updateActions is also called when NoteEditor is closed
3172 actionViewToggleNoteEditor->setOn (textEditor->showWithMain());
3175 if (me->getMapLinkColorHint()==HeadingColor)
3176 actionFormatLinkColorHint->setOn(true);
3178 actionFormatLinkColorHint->setOn(false);
3180 switch (me->getMapLinkStyle())
3183 actionFormatLinkStyleLine->setOn(true);
3186 actionFormatLinkStyleParabel->setOn(true);
3189 actionFormatLinkStylePolyLine->setOn(true);
3191 case StylePolyParabel:
3192 actionFormatLinkStylePolyParabel->setOn(true);
3198 QPixmap pix( 16, 16 );
3199 pix.fill( me->getMapBackgroundColor() );
3200 actionFormatBackColor->setIconSet( pix );
3201 pix.fill( me->getMapDefLinkColor() );
3202 actionFormatLinkColor->setIconSet( pix );
3204 actionFileSave->setEnabled( me->isUnsaved() );
3205 if (me->isUndoAvailable())
3206 actionEditUndo->setEnabled( true);
3208 actionEditUndo->setEnabled( false);
3210 if (me->isRedoAvailable())
3211 actionEditRedo->setEnabled( true);
3213 actionEditRedo->setEnabled( false);
3215 LinkableMapObj *selection=me->getSelection();
3218 if ( (typeid(*selection) == typeid(BranchObj)) ||
3219 (typeid(*selection) == typeid(MapCenterObj)) )
3221 BranchObj *bo=(BranchObj*)selection;
3222 // Take care of links
3223 if (bo->countXLinks()==0)
3225 branchXLinksContextMenuEdit->clear();
3226 branchXLinksContextMenuFollow->clear();
3231 branchXLinksContextMenuEdit->clear();
3232 branchXLinksContextMenuFollow->clear();
3233 for (int i=0; i<=bo->countXLinks();i++)
3235 bot=bo->XLinkTargetAt(i);
3238 s=bot->getHeading();
3241 branchXLinksContextMenuFollow->addAction (s);
3242 branchXLinksContextMenuEdit->addAction (s);
3247 standardFlagsDefault->setEnabled (true);
3249 actionEditToggleScroll->setEnabled (true);
3250 if ( bo->isScrolled() )
3251 actionEditToggleScroll->setOn(true);
3253 actionEditToggleScroll->setOn(false);
3255 if ( bo->getURL().isEmpty() )
3257 actionEditOpenURL->setEnabled (false);
3258 actionEditOpenURLTab->setEnabled (false);
3262 actionEditOpenURL->setEnabled (true);
3263 actionEditOpenURLTab->setEnabled (true);
3265 if ( bo->getVymLink().isEmpty() )
3267 actionEditOpenVymLink->setEnabled (false);
3268 actionEditDeleteVymLink->setEnabled (false);
3271 actionEditOpenVymLink->setEnabled (true);
3272 actionEditDeleteVymLink->setEnabled (true);
3275 if (bo->canMoveBranchUp())
3276 actionEditMoveUp->setEnabled (true);
3278 actionEditMoveUp->setEnabled (false);
3279 if (bo->canMoveBranchDown())
3280 actionEditMoveDown->setEnabled (true);
3282 actionEditMoveDown->setEnabled (false);
3285 actionEditToggleHideExport->setEnabled (true);
3286 actionEditToggleHideExport->setOn (bo->hideInExport() );
3288 actionEditCopy->setEnabled (true);
3289 actionEditCut->setEnabled (true);
3290 if (!clipboardEmpty)
3291 actionEditPaste->setEnabled (true);
3293 actionEditPaste->setEnabled (false);
3294 for (a=actionListBranches.first();a;a=actionListBranches.next())
3295 a->setEnabled(true);
3296 actionEditDelete->setEnabled (true);
3297 switch (selection->getFrameType())
3300 actionFormatFrameNone->setOn(true);
3303 actionFormatFrameRectangle->setOn(true);
3308 actionFormatIncludeImagesVer->setOn
3309 ( ((BranchObj*)selection)->getIncludeImagesVer());
3310 actionFormatIncludeImagesHor->setOn
3311 ( ((BranchObj*)selection)->getIncludeImagesHor());
3312 actionFormatHideLinkUnselected->setOn
3313 (selection->getHideLinkUnselected());
3315 if ( (typeid(*selection) == typeid(FloatImageObj)) )
3317 FloatObj *fo=(FloatImageObj*)selection;
3318 //FIXME do this in mainwindow standardFlagsDefault->setEnabled (false);
3320 actionEditOpenURL->setEnabled (false);
3321 actionEditOpenVymLink->setEnabled (false);
3322 actionEditDeleteVymLink->setEnabled (false);
3323 actionEditToggleHideExport->setEnabled (true);
3324 actionEditToggleHideExport->setOn (fo->hideInExport() );
3327 actionEditCopy->setEnabled (true);
3328 actionEditCut->setEnabled (true);
3329 actionEditPaste->setEnabled (false);
3330 for (a=actionListBranches.first();a;a=actionListBranches.next())
3331 a->setEnabled(false);
3332 actionEditDelete->setEnabled (true);
3333 actionFormatHideLinkUnselected->setOn
3334 ( selection->getHideLinkUnselected());
3335 actionEditMoveUp->setEnabled (false);
3336 actionEditMoveDown->setEnabled (false);
3341 actionEditCopy->setEnabled (false);
3342 actionEditCut->setEnabled (false);
3343 actionEditPaste->setEnabled (false);
3344 for (a=actionListBranches.first();a;a=actionListBranches.next())
3345 a->setEnabled(false);
3347 actionEditToggleScroll->setEnabled (false);
3348 actionEditOpenURL->setEnabled (false);
3349 actionEditOpenVymLink->setEnabled (false);
3350 actionEditDeleteVymLink->setEnabled (false);
3351 actionEditHeading2URL->setEnabled (false);
3352 actionEditDelete->setEnabled (false);
3353 actionEditMoveUp->setEnabled (false);
3354 actionEditMoveDown->setEnabled (false);
3355 actionEditToggleHideExport->setEnabled (false);
3359 ModMode Main::getModMode()
3361 if (actionModModeColor->isOn()) return ModModeColor;
3362 if (actionModModeCopy->isOn()) return ModModeCopy;
3363 if (actionModModeXLink->isOn()) return ModModeXLink;
3367 bool Main::autoEdit()
3369 return actionSettingsAutoEdit->isOn();
3372 bool Main::autoSelectHeading()
3374 return actionSettingsAutoSelectHeading->isOn();
3377 bool Main::useFlagGroups()
3379 return actionSettingsUseFlagGroups->isOn();
3382 void Main::windowShowNoteEditor()
3384 textEditor->setShowWithMain(true);
3386 actionViewToggleNoteEditor->setOn (true);
3389 void Main::windowHideNoteEditor()
3391 textEditor->setShowWithMain(false);
3393 actionViewToggleNoteEditor->setOn (false);
3396 void Main::windowNextEditor()
3398 if (tabWidget->currentPageIndex() < tabWidget->count())
3399 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3402 void Main::windowPreviousEditor()
3404 if (tabWidget->currentPageIndex() >0)
3405 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3408 void Main::standardFlagChanged()
3410 currentMapEditor()->toggleStandardFlag(sender()->name());
3413 void Main::testFunction()
3415 if (!currentMapEditor()) return;
3416 currentMapEditor()->testFunction();
3419 void Main::testCommand()
3421 if (!currentMapEditor()) return;
3423 QString com = QInputDialog::getText(
3424 __VYM, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3425 if (ok) currentMapEditor()->parseAtom(com);
3428 void Main::helpDoc()
3430 QString locale = QLocale::system().name();
3432 if (locale.left(2)=="es")
3433 docname="vym_es.pdf";
3437 #if defined(Q_OS_MACX)
3438 docdir.setPath("./vym.app/Contents");
3440 // default path in SUSE LINUX
3441 docdir.setPath("/usr/share/doc/packages/vym/doc");
3444 if (!docdir.exists() )
3446 // relative path for easy testing in tarball
3447 docdir.setPath("doc");
3448 if (!docdir.exists() )
3450 // relative path for testing while still writing vym.tex
3451 docdir.setPath("doc/tex/vym.pdf");
3452 if (!docdir.exists() )
3454 // Try yet another one for Knoppix
3455 docdir.setPath("/usr/share/doc/packages/vym");
3456 if (!docdir.exists() )
3458 QMessageBox::critical(0,
3459 tr("Critcal error"),
3460 tr("Couldn't find the documentation\n"
3461 "vym.pdf in various directories."));
3468 QString docpath=docdir.path()+"/"+docname;
3469 Process *pdfProc = new Process();
3470 pdfProc->clearArguments();
3471 pdfProc->addArgument( settings.value("/mainwindow/readerPDF").toString());
3472 pdfProc->addArgument( docpath);
3474 if ( !pdfProc->start() )
3477 QMessageBox::warning(0,
3479 tr("Couldn't find a viewer to open %1.\n").arg(docpath)+
3480 tr("Please use Settings->")+tr("Set application to open PDF files"));
3487 void Main::helpAbout()
3490 ad.setName ("aboutwindow");
3491 ad.setMinimumSize(500,500);
3492 ad.resize (QSize (500,500));
3496 void Main::helpAboutQT()
3498 QMessageBox::aboutQt( this, "Qt Application Example" );