Removed more QT3 stuff. Drag & Drop not 100% functional at the moment
1 #include "mainwindow.h"
7 #include "aboutdialog.h"
8 #include "exportoofiledialog.h"
10 #include "exportxhtmldialog.h"
12 #include "flagrowobj.h"
13 #include "historywindow.h"
15 #include "mapeditor.h"
20 #include "texteditor.h"
22 extern TextEditor *textEditor;
23 extern Main *mainWindow;
24 extern QString tmpVymDir;
25 extern QString clipboardDir;
26 extern bool clipboardEmpty;
27 extern int statusbarTime;
28 extern FlagRowObj* standardFlagsDefault;
29 extern FlagRowObj* systemFlagsDefault;
30 extern QString vymName;
31 extern QString vymVersion;
32 extern QString vymBuildDate;
34 QMenu* branchContextMenu;
35 QMenu* branchAddContextMenu;
36 QMenu* branchRemoveContextMenu;
37 QMenu* branchLinksContextMenu;
38 QMenu* branchXLinksContextMenuEdit;
39 QMenu* branchXLinksContextMenuFollow;
40 QMenu* floatimageContextMenu;
41 QMenu* canvasContextMenu;
42 QMenu* fileLastMapsMenu;
43 QMenu* fileImportMenu;
44 QMenu* fileExportMenu;
47 extern Settings settings;
48 extern Options options;
49 extern ImageIO imageIO;
51 extern QDir vymBaseDir;
52 extern QDir lastImageDir;
53 extern QDir lastFileDir;
54 extern QString iconPath;
55 extern QString flagsPath;
57 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
58 QMainWindow(parent,name,f)
62 setCaption ("VYM - View Your Mind");
64 // Load window settings
65 resize (settings.value( "/mainwindow/geometry/size",QSize (800,600)).toSize());
66 move (settings.value( "/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
69 // Sometimes we may need to remember old selections
73 currentColor=Qt::black;
75 // Create unique temporary directory
77 tmpVymDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
80 qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
84 // Create direcctory for clipboard
85 clipboardDir=tmpVymDir+"/clipboard";
87 d.mkdir (clipboardDir,true);
88 makeSubDirs (clipboardDir);
93 // Initialize history window;
94 historyWindow=new HistoryWindow();
95 // FIXME historyWindow.setStepsTotal(stepsTotal);
97 // Initialize some settings, which are platform dependant
100 // application to open URLs
101 p="/mainwindow/readerURL";
102 #if defined(Q_OS_LINUX)
103 s=settings.value (p,"konqueror").toString();
105 #if defined(Q_OS_MACX)
106 s=settings.value (p,"/usr/bin/open").toString();
108 s=settings.value (p,"mozilla");
111 settings.setValue( p,s);
113 // application to open PDFs
114 p="/mainwindow/readerPDF";
115 #if defined(Q_OS_LINUX)
116 s=settings.value (p,"acroread").toString();
118 #if defined(Q_OS_MACX)
119 s=settings.value (p,"/usr/bin/open").toString();
121 s=settings.value (p,"acroread").toString();
124 settings.setValue( p,s);
127 // Create tab widget which holds the maps
128 tabWidget= new QTabWidget (this);
129 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
130 this, SLOT( editorChanged( QWidget * ) ) );
132 lineedit=new QLineEdit (this);
135 setCentralWidget(tabWidget);
139 setupFormatActions();
143 setupSettingsActions();
145 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
150 restoreState (settings.value("/mainwindow/state",0).toByteArray());
152 // Initialize Find window
153 findWindow=new FindWindow(NULL);
154 findWindow->move (x(),y()+70);
155 connect (findWindow, SIGNAL( findButton(QString) ),
156 this, SLOT(editFind(QString) ) );
157 connect (findWindow, SIGNAL( somethingChanged() ),
158 this, SLOT(editFindChanged() ) );
160 // Connect TextEditor, so that we can update flags if text changes
161 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
162 connect (textEditor, SIGNAL (textEditorClosed() ), this, SLOT (updateActions()));
170 settings.setValue ( "/mainwindow/geometry/size", size() );
171 settings.setValue ( "/mainwindow/geometry/pos", pos() );
173 settings.setValue ("/mainwindow/state",saveState(0));
175 settings.setValue( "/version/version", vymVersion );
176 settings.setValue( "/version/builddate", vymBuildDate );
178 settings.setValue( "/mapeditor/editmode/autoSelectHeading",actionSettingsAutoSelectHeading->isOn() );
179 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
180 settings.setValue( "/mapeditor/editmode/autoEdit",actionSettingsAutoEdit->isOn() );
181 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
182 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
183 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
185 // call the destructors
187 delete historyWindow;
189 // Remove temporary directory
190 removeDir (QDir(tmpVymDir));
193 void Main::loadCmdLine()
195 /* TODO draw some kind of splashscreen while loading...
201 QStringList flist=options.getFileList();
202 QStringList::Iterator it=flist.begin();
204 while (it !=flist.end() )
206 fileLoad (*it, NewMap);
212 void Main::statusMessage(const QString &s)
214 statusBar()->message (s);
217 void Main::closeEvent (QCloseEvent* )
223 void Main::setupFileActions()
225 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
226 QToolBar *tb = addToolBar( tr ("&Map") );
227 tb->setObjectName ("mapTB");
230 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New...","File menu" ),this);
231 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
232 a->setShortcut ( Qt::CTRL + Qt::Key_N );
234 fileMenu->addAction (a);
235 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
237 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
238 a->setStatusTip (tr( "Open","Status tip File menu" ) );
239 a->setShortcut ( Qt::CTRL + Qt::Key_O );
241 fileMenu->addAction (a);
242 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
244 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
245 fileMenu->addSeparator();
247 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
248 a->setStatusTip ( tr( "Save","Status tip file menu" ));
249 a->setShortcut (Qt::CTRL + Qt::Key_S );
251 fileMenu->addAction (a);
252 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
255 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
256 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
257 fileMenu->addAction (a);
258 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
260 fileMenu->addSeparator();
262 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
264 a = new QAction(tr("KDE Bookmarks"), this);
265 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE bookmarks")));
266 a->addTo (fileImportMenu);
267 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) );
269 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
271 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
272 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
273 a->addTo (fileImportMenu);
274 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
277 a = new QAction("Mind Manager...",this);
278 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
279 fileImportMenu->addAction (a);
280 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
282 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
283 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
284 fileImportMenu->addAction (a);
285 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
287 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
289 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
290 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
291 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
292 fileExportMenu->addAction (a);
294 a = new QAction( "Open Office...", this);
295 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
296 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
297 fileExportMenu->addAction (a);
299 a = new QAction( "Webpage (XHTML)...",this );
300 a->setShortcut (Qt::ALT + Qt::Key_X);
301 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
302 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
303 fileExportMenu->addAction (a);
305 a = new QAction( "Text (ASCII)...", this);
306 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
307 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
308 fileExportMenu->addAction (a);
310 a = new QAction( tr("KDE Bookmarks","File menu"), this);
311 a->setStatusTip( tr( "Export as %1").arg(tr("KDE Bookmarks" )));
312 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
313 fileExportMenu->addAction (a);
315 a = new QAction( "Taskjuggler...", this );
316 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
317 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
318 fileExportMenu->addAction (a);
320 a = new QAction( "LaTeX...", this);
321 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
322 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
323 fileExportMenu->addAction (a);
325 a = new QAction( "XML..." , this );
326 a->setStatusTip (tr( "Export as %1").arg("XML"));
327 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
328 fileExportMenu->addAction (a);
330 fileMenu->addSeparator();
332 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
333 a->setStatusTip ( tr( "Print" ,"File menu") );
334 a->setShortcut (Qt::CTRL + Qt::Key_P );
336 fileMenu->addAction (a);
337 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
340 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
341 a->setStatusTip (tr( "Close Map" ) );
342 a->setShortcut (Qt::ALT + Qt::Key_C );
343 fileMenu->addAction (a);
344 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
346 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
347 a->setStatusTip ( tr( "Exit")+" "+vymName );
348 a->setShortcut (Qt::CTRL + Qt::Key_Q );
349 fileMenu->addAction (a);
350 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
355 void Main::setupEditActions()
357 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
358 tb->setLabel( "Edit Actions" );
359 tb->setObjectName ("actionsTB");
360 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
364 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
365 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
366 a->setStatusTip (tr( "Undo" ) );
367 a->setShortcut ( Qt::CTRL + Qt::Key_Z );
368 a->setEnabled (false);
370 editMenu->addAction (a);
373 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
374 a->setStatusTip (tr( "Redo" ));
375 a->setShortcut (Qt::CTRL + Qt::Key_Y );
377 editMenu->addAction (a);
378 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
381 editMenu->addSeparator();
382 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
383 a->setStatusTip ( tr( "Copy" ) );
384 a->setShortcut (Qt::CTRL + Qt::Key_C );
385 a->setEnabled (false);
387 editMenu->addAction (a);
388 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
391 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
392 a->setStatusTip ( tr( "Cut" ) );
393 a->setShortcut (Qt::CTRL + Qt::Key_X );
394 a->setEnabled (false);
396 editMenu->addAction (a);
398 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
400 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
401 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
402 a->setStatusTip ( tr( "Paste" ) );
403 a->setShortcut ( Qt::CTRL + Qt::Key_V );
404 a->setEnabled (false);
406 editMenu->addAction (a);
409 // Shortcuts to modify heading:
410 a = new QAction(tr( "Edit heading","Edit menu" ),this);
411 a->setStatusTip ( tr( "edit Heading" ));
412 a->setShortcut ( Qt::Key_Enter);
413 // a->setShortcutContext (Qt::WindowShortcut);
415 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
416 actionListBranches.append(a);
417 a = new QAction( tr( "Edit heading","Edit menu" ), this);
418 a->setStatusTip (tr( "edit Heading" ));
419 a->setShortcut (Qt::Key_Return );
420 //a->setShortcutContext (Qt::WindowShortcut);
422 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
423 actionListBranches.append(a);
424 editMenu->addAction (a);
426 a = new QAction( tr( "Edit heading","Edit menu" ), this);
427 a->setStatusTip (tr( "edit Heading" ));
428 a->setShortcut ( Qt::Key_F2 );
429 a->setShortcutContext (Qt::WindowShortcut);
431 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
432 actionListBranches.append(a);
434 // Shortcut to delete selection
435 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
436 a->setStatusTip (tr( "Delete Selection" ));
437 a->setShortcut ( Qt::Key_Delete);
438 a->setShortcutContext (Qt::WindowShortcut);
440 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
443 // Shortcut to add branch
444 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
445 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
446 alt->setShortcut (Qt::Key_A);
447 alt->setShortcutContext (Qt::WindowShortcut);
449 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
450 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
451 a->setStatusTip ( tr( "Add a branch as child of selection" ));
452 a->setShortcut (Qt::Key_Insert);
453 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
454 actionListBranches.append(a);
455 #if defined (Q_OS_MACX)
456 // In OSX show different shortcut in menues, the keys work indepently always
457 actionEditAddBranch=alt;
459 actionEditAddBranch=a;
461 editMenu->addAction (actionEditAddBranch);
462 tb->addAction (actionEditAddBranch);
465 // Add branch by inserting it at selection
466 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
467 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
468 a->setShortcut (Qt::ALT + Qt::Key_Insert );
469 a->setShortcutContext (Qt::WindowShortcut);
471 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
472 a->setEnabled (false);
473 actionListBranches.append(a);
474 actionEditAddBranchBefore=a;
475 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
476 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
477 a->setShortcut ( Qt::ALT + Qt::Key_A );
478 a->setShortcutContext (Qt::WindowShortcut);
480 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
481 actionListBranches.append(a);
484 a = new QAction(tr( "Add branch above","Edit menu" ), this);
485 a->setStatusTip ( tr( "Add a branch above selection" ));
486 a->setShortcut (Qt::SHIFT+Qt::Key_Insert );
487 a->setShortcutContext (Qt::WindowShortcut);
489 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
490 a->setEnabled (false);
491 actionListBranches.append(a);
492 actionEditAddBranchAbove=a;
493 a = new QAction(tr( "Add branch above","Edit menu" ), this);
494 a->setStatusTip ( tr( "Add a branch above selection" ));
495 a->setShortcut (Qt::SHIFT+Qt::Key_A );
496 a->setShortcutContext (Qt::WindowShortcut);
498 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
499 actionListBranches.append(a);
502 a = new QAction(tr( "Add branch below","Edit menu" ), this);
503 a->setStatusTip ( tr( "Add a branch below selection" ));
504 a->setShortcut (Qt::CTRL +Qt::Key_Insert );
505 a->setShortcutContext (Qt::WindowShortcut);
507 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
508 a->setEnabled (false);
509 actionListBranches.append(a);
510 actionEditAddBranchBelow=a;
511 a = new QAction(tr( "Add branch below","Edit menu" ), this);
512 a->setStatusTip ( tr( "Add a branch below selection" ));
513 a->setShortcut (Qt::CTRL +Qt::Key_A );
514 a->setShortcutContext (Qt::WindowShortcut);
516 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
517 actionListBranches.append(a);
519 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
520 a->setStatusTip ( tr( "Move branch up" ) );
521 a->setShortcut (Qt::Key_PageUp );
522 a->setEnabled (false);
524 editMenu->addAction (a);
525 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
528 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
529 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
530 a->setStatusTip (tr( "Move branch down" ) );
531 a->setShortcut ( Qt::Key_PageDown );
532 a->setEnabled (false);
534 editMenu->addAction (a);
535 actionEditMoveDown=a;
538 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this);
539 a->setShortcut ( Qt::Key_ScrollLock );
540 a->setStatusTip (tr( "Scroll branch" ) );
541 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
543 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
544 alt->setShortcut ( Qt::Key_S );
545 alt->setStatusTip (tr( "Scroll branch" ));
546 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
547 #if defined(Q_OS_MACX)
548 actionEditToggleScroll=alt;
550 actionEditToggleScroll=a;
552 actionEditToggleScroll->setEnabled (false);
553 actionEditToggleScroll->setToggleAction(true);
554 tb->addAction (actionEditToggleScroll);
555 editMenu->addAction ( actionEditToggleScroll);
556 editMenu->addAction (actionEditToggleScroll);
559 actionListBranches.append(actionEditToggleScroll);
561 a = new QAction( tr( "Unscroll all scrolled branches","Edit menu" ), this);
562 a->setStatusTip (tr( "Unscroll all" ));
563 editMenu->addAction (a);
564 connect( a, SIGNAL( triggered() ), this, SLOT( editUnScrollAll() ) );
566 editMenu->addSeparator();
568 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
569 a->setStatusTip (tr( "Find" ) );
570 a->setShortcut (Qt::CTRL + Qt::Key_F );
571 editMenu->addAction (a);
572 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
574 editMenu->addSeparator();
576 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
577 a->setShortcut (Qt::CTRL + Qt::Key_U );
578 a->setShortcut (tr( "Open URL" ));
581 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
584 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
585 a->setStatusTip (tr( "Open URL in new tab" ));
586 a->setShortcut (Qt::CTRL+Qt::Key_U );
588 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
589 actionEditOpenURLTab=a;
591 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
592 a->setStatusTip (tr( "Open all URLs in subtree" ));
594 actionListBranches.append(a);
595 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
596 actionEditOpenMultipleURLTabs=a;
598 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
599 a->setStatusTip ( tr( "Edit URL" ) );
600 a->setShortcut (Qt::SHIFT + Qt::CTRL + Qt::Key_U );
601 //a->setShortcut ( Qt::Key_U );
602 a->setShortcutContext (Qt::WindowShortcut);
603 actionListBranches.append(a);
605 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
608 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
609 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
610 a->setEnabled (false);
611 actionListBranches.append(a);
612 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
613 actionEditHeading2URL=a;
615 a = new QAction(tr( "Create URL to Bugzilla","Edit menu" ), this);
616 a->setStatusTip ( tr( "Create URL to Bugzilla" ));
617 a->setEnabled (false);
618 actionListBranches.append(a);
619 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
620 actionEditBugzilla2URL=a;
622 a = new QAction(tr( "Create URL to FATE","Edit menu" ), this);
623 a->setStatusTip ( tr( "Create URL to FATE" ));
624 a->setEnabled (false);
625 actionListBranches.append(a);
626 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
627 actionEditFATE2URL=a;
629 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
630 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
632 a->setEnabled (false);
633 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
634 actionEditOpenVymLink=a;
636 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
637 a->setStatusTip ( tr( "Open all vym links in subtree" ));
638 a->setEnabled (false);
639 actionListBranches.append(a);
640 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
641 actionEditOpenMultipleVymLinks=a;
644 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
645 a->setEnabled (false);
646 a->setStatusTip ( tr( "Edit link to another vym map" ));
647 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
648 actionListBranches.append(a);
651 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
652 a->setStatusTip ( tr( "Delete link to another vym map" ));
653 a->setEnabled (false);
654 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
655 actionEditDeleteVymLink=a;
657 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
658 a->setStatusTip ( tr( "Hide object in exports" ) );
659 a->setShortcut (Qt::Key_H );
660 a->setToggleAction(true);
662 a->setEnabled (false);
663 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
664 actionEditToggleHideExport=a;
666 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
667 a->setStatusTip ( tr( "Edit Map Info" ));
668 a->setEnabled (true);
669 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
672 // Import at selection (adding to selection)
673 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
674 a->setStatusTip (tr( "Add map at selection" ));
675 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
676 a->setEnabled (false);
677 actionListBranches.append(a);
678 actionEditImportAdd=a;
680 // Import at selection (replacing selection)
681 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
682 a->setStatusTip (tr( "Replace selection with map" ));
683 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
684 a->setEnabled (false);
685 actionListBranches.append(a);
686 actionEditImportReplace=a;
689 a = new QAction( tr( "Save selection","Edit menu" ), this);
690 a->setStatusTip (tr( "Save selection" ));
691 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
692 a->setEnabled (false);
693 actionListBranches.append(a);
694 actionEditSaveBranch=a;
696 // Only remove branch, not its childs
697 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
698 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
699 a->setShortcut (Qt::ALT + Qt::Key_Delete );
700 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChilds() ) );
701 a->setEnabled (false);
703 actionListBranches.append(a);
704 actionEditDeleteKeepChilds=a;
706 // Only remove childs of a branch
707 a = new QAction( tr( "Remove childs","Edit menu" ), this);
708 a->setStatusTip (tr( "Remove childs of branch" ));
709 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
710 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChilds() ) );
711 a->setEnabled (false);
712 actionListBranches.append(a);
713 actionEditDeleteChilds=a;
715 // Shortcuts for navigating with cursor:
716 a = new QAction(tr( "Select upper branch","Edit menu" ), this);
717 a->setStatusTip ( tr( "Select upper branch" ));
718 a->setShortcut (Qt::Key_Up );
719 a->setShortcutContext (Qt::WindowShortcut);
721 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
722 a = new QAction( tr( "Select lower branch","Edit menu" ),this);
723 a->setStatusTip (tr( "Select lower branch" ));
724 a->setShortcut ( Qt::Key_Down );
725 a->setShortcutContext (Qt::WindowShortcut);
727 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
728 a = new QAction(tr( "Select left branch","Edit menu" ), this);
729 a->setStatusTip ( tr( "Select left branch" ));
730 a->setShortcut (Qt::Key_Left );
731 a->setShortcutContext (Qt::WindowShortcut);
733 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
734 a = new QAction( tr( "Select child branch","Edit menu" ), this);
735 a->setStatusTip (tr( "Select right branch" ));
736 a->setShortcut (Qt::Key_Right);
737 a->setShortcutContext (Qt::WindowShortcut);
739 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
740 a = new QAction( tr( "Select first branch","Edit menu" ), this);
741 a->setStatusTip (tr( "Select first branch" ));
742 a->setShortcut (Qt::Key_Home );
743 a->setShortcutContext (Qt::WindowShortcut);
745 a->setEnabled (false);
746 editMenu->addAction (a);
747 actionListBranches.append(a);
748 actionEditSelectFirst=a;
749 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
750 a = new QAction( tr( "Select last branch","Edit menu" ),this);
751 a->setStatusTip (tr( "Select last branch" ));
752 a->setShortcut ( Qt::Key_End );
753 a->setShortcutContext (Qt::WindowShortcut);
755 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
756 a->setEnabled (false);
757 editMenu->addAction (a);
758 actionListBranches.append(a);
759 actionEditSelectLast=a;
761 a = new QAction( tr( "Add Image...","Edit menu" ), this);
762 a->setStatusTip (tr( "Add Image" ));
763 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
764 actionEditLoadImage=a;
769 void Main::setupFormatActions()
771 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
773 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
774 tb->setObjectName ("formatTB");
777 pix.fill (Qt::black);
778 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
779 a->setStatusTip ( tr( "Set Color" ));
780 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
782 formatMenu->addAction (a);
784 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
785 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
786 a->setShortcut (Qt::CTRL + Qt::Key_K );
787 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
788 a->setEnabled (false);
790 formatMenu->addAction (a);
791 actionListBranches.append(a);
792 actionFormatPickColor=a;
794 a= new QAction(QPixmap(iconPath+"formatcoloritem.png"), tr( "Color &branch","Edit menu" ), this);
795 a->setStatusTip ( tr( "Color branch" ) );
796 a->setShortcut (Qt::CTRL + Qt::Key_I);
797 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorItem() ) );
798 a->setEnabled (false);
800 formatMenu->addAction (a);
801 actionListBranches.append(a);
802 actionFormatColorBranch=a;
804 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color sub&tree","Edit menu" ), this);
805 a->setStatusTip ( tr( "Color Subtree" ));
806 a->setShortcut (Qt::CTRL + Qt::Key_T);
807 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
808 a->setEnabled (false);
809 formatMenu->addAction (a);
811 actionListBranches.append(a);
812 actionFormatColorSubtree=a;
814 formatMenu->addSeparator();
815 actionGroupFormatLinkStyles=new QActionGroup ( this);
816 actionGroupFormatLinkStyles->setExclusive (true);
817 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
818 a->setStatusTip (tr( "Line" ));
819 a->setToggleAction(true);
820 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
821 formatMenu->addAction (a);
822 actionFormatLinkStyleLine=a;
823 a= new QAction( tr( "Linkstyle Parabel" ), actionGroupFormatLinkStyles);
824 a->setStatusTip (tr( "Line" ));
825 a->setToggleAction(true);
826 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
827 formatMenu->addAction (a);
828 actionFormatLinkStyleParabel=a;
829 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
830 a->setStatusTip (tr( "PolyLine" ));
831 a->setToggleAction(true);
832 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
833 formatMenu->addAction (a);
834 actionFormatLinkStylePolyLine=a;
835 a= new QAction( tr( "Linkstyle Thick Parabel" ), actionGroupFormatLinkStyles);
836 a->setStatusTip (tr( "PolyParabel" ) );
837 a->setToggleAction(true);
838 a->setChecked (true);
839 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
840 formatMenu->addAction (a);
841 actionFormatLinkStylePolyParabel=a;
843 actionGroupFormatFrameTypes=new QActionGroup ( this);
844 actionGroupFormatFrameTypes->setExclusive (true);
845 a = new QAction( tr( "No Frame","Branch attribute" ), actionGroupFormatFrameTypes );
846 a->setStatusTip (tr("No Frame"));
847 a->setToggleAction(true);
848 connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameNone() ) );
849 actionFormatFrameNone=a;
850 a = new QAction( tr( "Rectangle""Branch attribute" ), actionGroupFormatFrameTypes);
851 a->setStatusTip (tr( "Rectangle" ));
852 a->setToggleAction(true);
853 connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameRectangle() ) );
854 actionFormatFrameRectangle=a;
856 a = new QAction( tr( "Include images vertically","Branch attribute" ), this);
857 a->setStatusTip ( tr ("Include top and bottom position of images into branch"));
858 a->setToggleAction(true);
859 connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesVer() ) );
860 actionFormatIncludeImagesVer=a;
862 a = new QAction( tr( "Include images horizontally","Branch attribute" ), this);
863 a->setStatusTip ( tr ("Include left and right position of images into branch"));
864 a->setToggleAction(true);
865 connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesHor() ) );
866 actionFormatIncludeImagesHor=a;
868 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
869 a->setStatusTip (tr( "Hide link" ));
870 a->setToggleAction(true);
871 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
872 actionFormatHideLinkUnselected=a;
874 formatMenu->addSeparator();
875 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
876 a->setStatusTip (tr( "Use same color for links and headings" ));
877 a->setToggleAction(true);
878 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
879 formatMenu->addAction (a);
880 actionFormatLinkColorHint=a;
882 pix.fill (Qt::white);
883 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
884 a->setStatusTip (tr( "Set Link Color" ));
885 formatMenu->addAction (a);
886 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
887 actionFormatLinkColor=a;
889 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
890 a->setStatusTip (tr( "Set Background Color" ));
891 formatMenu->addAction (a);
892 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
893 actionFormatBackColor=a;
897 void Main::setupViewActions()
899 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
900 tb->setLabel( "View Actions" );
901 tb->setObjectName ("viewTB");
902 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
905 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
906 a->setStatusTip ( tr( "Zoom reset" ) );
907 a->setShortcut (Qt::CTRL + Qt::Key_0 );
909 viewMenu->addAction (a);
910 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
912 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
913 a->setStatusTip (tr( "Zoom in" ));
914 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
916 viewMenu->addAction (a);
917 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
919 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
920 a->setStatusTip (tr( "Zoom out" ));
921 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
923 viewMenu->addAction (a);
924 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
927 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
928 a->setStatusTip ( tr( "Show Note Editor" ));
929 a->setShortcut ( Qt::CTRL + Qt::Key_E );
930 a->setToggleAction(true);
931 if (textEditor->showWithMain())
936 viewMenu->addAction (a);
937 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
938 actionViewToggleNoteEditor=a;
940 a = new QAction(QPixmap(iconPath+"history.png"), tr( "Show history window","View action" ),this );
941 a->setStatusTip ( tr( "Show history window" ));
942 a->setShortcut ( Qt::CTRL + Qt::Key_H );
943 a->setToggleAction(false);
945 viewMenu->addAction (a);
946 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
947 actionViewToggleHistoryWindow=a;
949 a = new QAction(tr( "Next Window","View action" ), this);
950 a->setStatusTip ( tr( "&Next Window" ) );
951 a->setShortcut (Qt::ALT + Qt::Key_N );
952 viewMenu->addAction (a);
953 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
955 a = new QAction (tr( "Previous Window","View action" ), this );
956 a->setStatusTip (tr( "&Previous Window" ));
957 a->setShortcut (Qt::ALT + Qt::Key_P );
958 viewMenu->addAction (a);
959 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
963 void Main::setupModeActions()
965 //QPopupMenu *menu = new QPopupMenu( this );
966 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
968 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
969 tb->setObjectName ("modesTB");
971 actionGroupModModes=new QActionGroup ( this);
972 actionGroupModModes->setExclusive (true);
973 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
974 a->setShortcut (Qt::Key_J);
975 a->setStatusTip ( tr( "Use modifier to color branches" ));
976 a->setToggleAction(true);
979 actionModModeColor=a;
981 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
982 a->setShortcut( Qt::Key_K);
983 a->setStatusTip( tr( "Use modifier to copy" ));
984 a->setToggleAction(true);
988 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
989 a->setShortcut (Qt::Key_L);
990 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
991 a->setToggleAction(true);
993 actionModModeXLink=a;
997 void Main::setupFlagActions()
999 // Create System Flags
1000 systemFlagsDefault = new FlagRowObj ();
1001 systemFlagsDefault->setVisibility (false);
1002 systemFlagsDefault->setName ("systemFlagsDef");
1004 FlagObj *fo = new FlagObj ();
1005 fo->load(QPixmap(flagsPath+"flag-note.png"));
1006 fo->setName("note");
1007 fo->setToolTip(tr("Note","Systemflag"));
1008 systemFlagsDefault->addFlag (fo); // makes deep copy
1010 fo->load(QPixmap(flagsPath+"flag-url.png"));
1012 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
1013 systemFlagsDefault->addFlag (fo);
1015 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1016 fo->setName("vymLink");
1017 fo->setToolTip(tr("Link to another vym map","Systemflag"));
1018 systemFlagsDefault->addFlag (fo);
1020 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1021 fo->setName("scrolledright");
1022 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
1023 systemFlagsDefault->addFlag (fo);
1025 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1026 fo->setName("tmpUnscrolledright");
1027 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
1028 systemFlagsDefault->addFlag (fo);
1030 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1031 fo->setName("hideInExport");
1032 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
1033 systemFlagsDefault->addFlag (fo);
1035 // Create Standard Flags
1036 QToolBar *tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1037 tb->setObjectName ("standardFlagTB");
1039 standardFlagsDefault = new FlagRowObj ();
1040 standardFlagsDefault->setVisibility (false);
1041 standardFlagsDefault->setName ("standardFlagsDef");
1042 standardFlagsDefault->setToolBar (tb);
1044 fo->load(QPixmap(flagsPath+"flag-exclamationmark.png"));
1045 fo->setName ("exclamationmark");
1046 fo->setGroup("standard-mark");
1047 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1050 a->setCheckable(true);
1051 a->setObjectName(fo->getName());
1052 a->setToolTip(tr("Take care!","Standardflag"));
1053 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1054 standardFlagsDefault->addFlag (fo); // makes deep copy
1056 fo->load(QPixmap(flagsPath+"flag-questionmark.png"));
1057 fo->setName("questionmark");
1058 fo->setGroup("standard-mark");
1059 a=new QAction (fo->getPixmap(),fo->getName(),this);
1062 a->setCheckable(true);
1063 a->setObjectName(fo->getName());
1064 a->setToolTip(tr("Really?","Standardflag"));
1065 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1066 standardFlagsDefault->addFlag (fo);
1068 fo->load(QPixmap(flagsPath+"flag-hook-green.png"));
1069 fo->setName("hook-green");
1070 fo->setGroup("standard-hook");
1071 a=new QAction (fo->getPixmap(),fo->getName(),this);
1074 a->setCheckable(true);
1075 a->setObjectName(fo->getName());
1076 a->setToolTip(tr("ok!","Standardflag"));
1077 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1078 standardFlagsDefault->addFlag (fo);
1080 fo->load(QPixmap(flagsPath+"flag-cross-red.png"));
1081 fo->setName("cross-red");
1082 fo->setGroup("standard-hook");
1083 a=new QAction (fo->getPixmap(),fo->getName(),this);
1086 a->setCheckable(true);
1087 a->setObjectName(fo->getName());
1088 a->setToolTip(tr("Not ok!","Standardflag"));
1089 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1090 standardFlagsDefault->addFlag (fo);
1092 fo->load(QPixmap(flagsPath+"flag-stopsign.png"));
1093 fo->setName("stopsign");
1094 a=new QAction (fo->getPixmap(),fo->getName(),this);
1097 a->setCheckable(true);
1098 a->setObjectName(fo->getName());
1099 a->setToolTip(tr("This won't work!","Standardflag"));
1100 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1101 standardFlagsDefault->addFlag (fo);
1103 fo->load(QPixmap(flagsPath+"flag-smiley-good.png"));
1104 fo->setName("smiley-good");
1105 fo->setGroup("standard-smiley");
1106 a=new QAction (fo->getPixmap(),fo->getName(),this);
1109 a->setCheckable(true);
1110 a->setObjectName(fo->getName());
1111 a->setToolTip(tr("Good","Standardflag"));
1112 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1113 standardFlagsDefault->addFlag (fo);
1115 fo->load(QPixmap(flagsPath+"flag-smiley-sad.png"));
1116 fo->setName("smiley-sad");
1117 fo->setGroup("standard-smiley");
1118 a=new QAction (fo->getPixmap(),fo->getName(),this);
1121 a->setCheckable(true);
1122 a->setObjectName(fo->getName());
1123 a->setToolTip(tr("Bad","Standardflag"));
1124 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1125 standardFlagsDefault->addFlag (fo);
1127 fo->load(QPixmap(flagsPath+"flag-smiley-omg.png"));
1128 // Original omg.png (in KDE emoticons)
1129 fo->setName("smiley-omg");
1130 fo->setGroup("standard-smiley");
1131 a=new QAction (fo->getPixmap(),fo->getName(),this);
1134 a->setCheckable(true);
1135 a->setObjectName(fo->getName());
1136 a->setToolTip(tr("Oh no!","Standardflag"));
1137 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1138 standardFlagsDefault->addFlag (fo);
1140 fo->load(QPixmap(flagsPath+"flag-kalarm.png"));
1141 fo->setName("clock");
1142 a=new QAction (fo->getPixmap(),fo->getName(),this);
1145 a->setCheckable(true);
1146 a->setObjectName(fo->getName());
1147 a->setToolTip(tr("Time critical","Standardflag"));
1148 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1149 standardFlagsDefault->addFlag (fo);
1151 fo->load(QPixmap(flagsPath+"flag-phone.png"));
1152 fo->setName("phone");
1153 a=new QAction (fo->getPixmap(),fo->getName(),this);
1156 a->setCheckable(true);
1157 a->setObjectName(fo->getName());
1158 a->setToolTip(tr("Call...","Standardflag"));
1159 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1160 standardFlagsDefault->addFlag (fo);
1162 fo->load(QPixmap(flagsPath+"flag-lamp.png"));
1163 fo->setName("lamp");
1164 a=new QAction (fo->getPixmap(),fo->getName(),this);
1167 a->setCheckable(true);
1168 a->setObjectName(fo->getName());
1169 a->setToolTip(tr("Idea!","Standardflag"));
1170 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1171 standardFlagsDefault->addFlag (fo);
1173 fo->load(QPixmap(flagsPath+"flag-arrow-up.png"));
1174 fo->setName("arrow-up");
1175 fo->setGroup("standard-arrow");
1176 a=new QAction (fo->getPixmap(),fo->getName(),this);
1179 a->setCheckable(true);
1180 a->setObjectName(fo->getName());
1181 a->setToolTip(tr("Important","Standardflag"));
1182 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1183 standardFlagsDefault->addFlag (fo);
1185 fo->load(QPixmap(flagsPath+"flag-arrow-down.png"));
1186 fo->setName("arrow-down");
1187 fo->setGroup("standard-arrow");
1188 a=new QAction (fo->getPixmap(),fo->getName(),this);
1191 a->setCheckable(true);
1192 a->setObjectName(fo->getName());
1193 a->setToolTip(tr("Unimportant","Standardflag"));
1194 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1195 standardFlagsDefault->addFlag (fo);
1197 fo->load(QPixmap(flagsPath+"flag-arrow-2up.png"));
1198 fo->setName("2arrow-up");
1199 fo->setGroup("standard-arrow");
1200 a=new QAction (fo->getPixmap(),fo->getName(),this);
1203 a->setCheckable(true);
1204 a->setObjectName(fo->getName());
1205 a->setToolTip(tr("Very important!","Standardflag"));
1206 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1207 standardFlagsDefault->addFlag (fo);
1209 fo->load(QPixmap(flagsPath+"flag-arrow-2down.png"));
1210 fo->setName("2arrow-down");
1211 fo->setGroup("standard-arrow");
1212 a=new QAction (fo->getPixmap(),fo->getName(),this);
1215 a->setCheckable(true);
1216 a->setObjectName(fo->getName());
1217 a->setToolTip(tr("Very unimportant!","Standardflag"));
1218 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1219 standardFlagsDefault->addFlag (fo);
1221 fo->load(QPixmap(flagsPath+"flag-thumb-up.png"));
1222 fo->setName("thumb-up");
1223 fo->setGroup("standard-thumb");
1224 a=new QAction (fo->getPixmap(),fo->getName(),this);
1227 a->setCheckable(true);
1228 a->setObjectName(fo->getName());
1229 a->setToolTip(tr("I like this","Standardflag"));
1230 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1231 standardFlagsDefault->addFlag (fo);
1233 fo->load(QPixmap(flagsPath+"flag-thumb-down.png"));
1234 fo->setName("thumb-down");
1235 fo->setGroup("standard-thumb");
1236 a=new QAction (fo->getPixmap(),fo->getName(),this);
1239 a->setCheckable(true);
1240 a->setObjectName(fo->getName());
1241 a->setToolTip(tr("I do not like this","Standardflag"));
1242 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1243 standardFlagsDefault->addFlag (fo);
1245 fo->load(QPixmap(flagsPath+"flag-rose.png"));
1246 fo->setName("rose");
1247 a=new QAction (fo->getPixmap(),fo->getName(),this);
1250 a->setCheckable(true);
1251 a->setObjectName(fo->getName());
1252 a->setToolTip(tr("Rose","Standardflag"));
1253 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1254 standardFlagsDefault->addFlag (fo);
1256 fo->load(QPixmap(flagsPath+"flag-heart.png"));
1257 fo->setName("heart");
1258 a=new QAction (fo->getPixmap(),fo->getName(),this);
1260 a->setCheckable(true);
1261 a->setObjectName(fo->getName());
1262 a->setToolTip(tr("I just love... ","Standardflag"));
1263 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1264 standardFlagsDefault->addFlag (fo);
1266 fo->load(QPixmap(flagsPath+"flag-present.png"));
1267 fo->setName("present");
1268 a=new QAction (fo->getPixmap(),fo->getName(),this);
1271 a->setCheckable(true);
1272 a->setObjectName(fo->getName());
1273 a->setToolTip(tr("Surprise!","Standardflag"));
1274 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1275 standardFlagsDefault->addFlag (fo);
1277 fo->load(QPixmap(flagsPath+"flag-flash.png"));
1278 fo->setName("flash");
1279 a=new QAction (fo->getPixmap(),fo->getName(),this);
1282 a->setCheckable(true);
1283 a->setObjectName(fo->getName());
1284 a->setToolTip(tr("Dangerous","Standardflag"));
1285 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1286 standardFlagsDefault->addFlag (fo);
1288 fo->load(QPixmap(flagsPath+"flag-info.png"));
1289 // Original: xsldbg_output.png
1290 fo->setName("info");
1291 a=new QAction (fo->getPixmap(),fo->getName(),this);
1294 a->setCheckable(true);
1295 a->setObjectName(fo->getName());
1296 a->setToolTip(tr("Info","Standardflag"));
1297 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1298 standardFlagsDefault->addFlag (fo);
1300 fo->load(QPixmap(flagsPath+"flag-lifebelt.png"));
1301 // Original khelpcenter.png
1302 fo->setName("lifebelt");
1303 a=new QAction (fo->getPixmap(),fo->getName(),this);
1306 a->setCheckable(true);
1307 a->setObjectName(fo->getName());
1308 a->setToolTip(tr("This will help","Standardflag"));
1309 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1310 standardFlagsDefault->addFlag (fo);
1316 void Main::setupSettingsActions()
1318 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1322 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1323 a->setStatusTip ( tr( "Set application to open pdf files"));
1324 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1325 settingsMenu->addAction (a);
1327 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1328 a->setStatusTip( tr( "Set application to open external links"));
1329 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1330 settingsMenu->addAction (a);
1332 settingsMenu->addSeparator();
1333 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1334 a->setStatusTip( tr( "Edit branch after adding it" ));
1335 a->setToggleAction(true);
1336 a->setOn ( settings.value ("/mapeditor/editmode/autoEdit",true).toBool());
1337 settingsMenu->addAction (a);
1338 actionSettingsAutoEdit=a;
1340 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1341 a->setStatusTip( tr( "Select branch after adding it" ));
1342 a->setToggleAction(true);
1343 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectHeading",false).toBool() );
1344 settingsMenu->addAction (a);
1345 actionSettingsAutoSelectHeading=a;
1347 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1348 a->setStatusTip( tr( "Select heading before editing" ));
1349 a->setToggleAction(true);
1350 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1351 settingsMenu->addAction (a);
1352 actionSettingsAutoSelectText=a;
1354 a= new QAction( tr( "Delete key","Settings action" ), this);
1355 a->setStatusTip( tr( "Delete key for deleting branches" ));
1356 a->setToggleAction(true);
1357 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",false).toBool() );
1358 settingsMenu->addAction (a);
1359 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1360 actionSettingsUseDelKey=a;
1362 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1363 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1364 a->setToggleAction(true);
1365 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1366 settingsMenu->addAction (a);
1367 actionSettingsUseFlagGroups=a;
1369 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1370 a->setStatusTip( tr( "Use hide flag during exports " ));
1371 a->setToggleAction(true);
1372 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1373 settingsMenu->addAction (a);
1374 actionSettingsUseHideExport=a;
1378 void Main::setupTestActions()
1380 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1383 a = new QAction( "Test function" , this);
1384 a->setStatusTip( "Call test function" );
1385 a->setShortcut (Qt::Key_F4 );
1386 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction() ) );
1387 testMenu->addAction (a);
1388 a = new QAction( "Command" , this);
1389 a->setStatusTip( "Enter command to call in editor" );
1390 a->setShortcut (Qt::Key_F5 );
1391 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1392 testMenu->addAction (a);
1396 void Main::setupHelpActions()
1398 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1401 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1402 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1403 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1404 helpMenu->addAction (a);
1406 a = new QAction( tr( "About VYM","Help action" ), this);
1407 a->setStatusTip( tr( "About VYM")+vymName);
1408 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1409 helpMenu->addAction (a);
1411 a = new QAction( tr( "About QT","Help action" ), this);
1412 a->setStatusTip( tr( "Information about QT toolkit" ));
1413 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1414 helpMenu->addAction (a);
1418 void Main::setupContextMenus()
1422 // Context Menu for branch or mapcenter
1423 branchContextMenu =new QMenu (this);
1426 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1427 branchAddContextMenu->addAction (actionEditPaste );
1428 branchAddContextMenu->addAction ( actionEditAddBranch );
1429 branchAddContextMenu->addAction ( actionEditAddBranchBefore );
1430 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1431 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1432 branchAddContextMenu->addSeparator();
1433 branchAddContextMenu->addAction ( actionEditImportAdd );
1434 branchAddContextMenu->addAction ( actionEditImportReplace );
1437 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1438 branchRemoveContextMenu->addAction (actionEditCut);
1439 branchRemoveContextMenu->addAction ( actionEditDelete );
1440 branchRemoveContextMenu->addAction ( actionEditDeleteKeepChilds );
1441 branchRemoveContextMenu->addAction ( actionEditDeleteChilds );
1444 actionEditSaveBranch->addTo( branchContextMenu );
1446 branchContextMenu->addSeparator();
1447 branchContextMenu->addAction ( actionFormatFrameNone );
1448 branchContextMenu->addAction ( actionFormatFrameRectangle);
1449 branchContextMenu->addAction ( actionFormatHideLinkUnselected );
1451 branchContextMenu->addSeparator();
1452 branchContextMenu->addAction ( actionEditLoadImage);
1453 branchContextMenu->addAction ( actionFormatIncludeImagesVer );
1454 branchContextMenu->addAction ( actionFormatIncludeImagesHor );
1456 // Submenu for Links (URLs, vymLinks)
1457 branchLinksContextMenu =new QMenu (this);
1459 branchContextMenu->addSeparator();
1460 branchLinksContextMenu=branchContextMenu->addMenu(tr("URLs and vymLinks","Context menu name"));
1461 branchLinksContextMenu->addAction ( actionEditOpenURL );
1462 branchLinksContextMenu->addAction ( actionEditOpenURLTab );
1463 branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
1464 branchLinksContextMenu->addAction ( actionEditURL );
1465 branchLinksContextMenu->addAction ( actionEditHeading2URL );
1466 branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
1467 if (settings.value( "/mainwindow/showTestMenu",true).toBool() )
1469 branchLinksContextMenu->addAction ( actionEditFATE2URL );
1471 branchLinksContextMenu->addSeparator();
1472 branchLinksContextMenu->addAction ( actionEditOpenVymLink );
1473 branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
1474 branchLinksContextMenu->addAction ( actionEditVymLink );
1475 branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
1478 // Context Menu for XLinks in a branch menu
1479 // This will be populated "on demand" in MapEditor::updateActions
1480 branchContextMenu->addSeparator();
1481 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1482 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1483 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1484 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1487 // Context menu for floatimage
1488 floatimageContextMenu =new QMenu (this);
1489 a= new QAction (tr ("Save image","Context action"),this);
1490 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1491 floatimageContextMenu->addAction (a);
1493 floatimageContextMenu->addSeparator();
1494 actionEditCopy->addTo( floatimageContextMenu );
1495 actionEditCut->addTo( floatimageContextMenu );
1497 floatimageContextMenu->addSeparator();
1498 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1501 // Context menu for canvas
1502 canvasContextMenu =new QMenu (this);
1503 actionEditMapInfo->addTo( canvasContextMenu );
1504 canvasContextMenu->insertSeparator();
1505 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1506 canvasContextMenu->insertSeparator();
1507 actionFormatLinkColorHint->addTo( canvasContextMenu );
1508 actionFormatLinkColor->addTo( canvasContextMenu );
1509 actionFormatBackColor->addTo( canvasContextMenu );
1511 // Menu for last opened files
1513 for (int i = 0; i < MaxRecentFiles; ++i)
1515 recentFileActs[i] = new QAction(this);
1516 recentFileActs[i]->setVisible(false);
1517 fileLastMapsMenu->addAction(recentFileActs[i]);
1518 connect(recentFileActs[i], SIGNAL(triggered()),
1519 this, SLOT(fileLoadRecent()));
1521 setupRecentMapsMenu();
1524 void Main::setupRecentMapsMenu()
1526 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1528 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1530 for (int i = 0; i < numRecentFiles; ++i) {
1531 //QString text = tr("&%1 %2").arg(i + 1).arg(strippedName(files[i]));
1532 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1533 recentFileActs[i]->setText(text);
1534 recentFileActs[i]->setData(files[i]);
1535 recentFileActs[i]->setVisible(true);
1537 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1538 recentFileActs[j]->setVisible(false);
1541 void Main::hideEvent (QHideEvent * )
1543 if (!textEditor->isMinimized() ) textEditor->hide();
1546 void Main::showEvent (QShowEvent * )
1548 if (textEditor->showWithMain()) textEditor->showNormal();
1551 bool Main::reallyWriteDirectory(const QString &dir)
1553 QStringList eList = QDir(dir).entryList();
1554 if (eList.first() ==".") eList.pop_front(); // remove "."
1555 if (eList.first() =="..") eList.pop_front(); // remove "."
1556 if (!eList.isEmpty())
1558 QMessageBox mb( vymName,
1559 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?","write directory").arg(dir),
1560 QMessageBox::Warning,
1562 QMessageBox::Cancel | QMessageBox::Default,
1563 QMessageBox::QMessageBox::NoButton );
1565 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1566 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1569 case QMessageBox::Yes:
1572 case QMessageBox::Cancel:
1580 QString Main::browseDirectory (const QString &caption)
1582 QFileDialog fd(this,caption);
1583 fd.setMode (QFileDialog::DirectoryOnly);
1584 fd.setCaption(vymName+ " - "+caption);
1587 if ( fd.exec() == QDialog::Accepted )
1588 return fd.selectedFile();
1593 MapEditor* Main::currentMapEditor() const
1595 if ( tabWidget->currentPage() &&
1596 tabWidget->currentPage()->inherits( "MapEditor" ) )
1597 return (MapEditor*)tabWidget->currentPage();
1602 void Main::editorChanged(QWidget *)
1604 // Unselect all possibly selected objects
1605 // (Important to update note editor)
1608 for (i=0;i<=tabWidget->count() -1;i++)
1611 me=(MapEditor*)tabWidget->page(i);
1614 currentMapEditor()->reselect();
1616 // Update actions to in menus and toolbars according to editor
1617 currentMapEditor()->updateActions();
1620 void Main::fileNew()
1622 QString fn="unnamed";
1623 MapEditor* medit = new MapEditor ( NULL);
1624 tabWidget->addTab (medit,fn);
1625 tabWidget->showPage(medit);
1626 medit->viewport()->setFocus();
1627 // For the very first map we do not have flagrows yet...
1628 medit->select("mc:");
1631 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1633 ErrorCode err=success;
1635 // fn is usually the archive, mapfile the file after uncompressing
1638 // Make fn absolute (needed for unzip)
1639 fn=QDir (fn).absPath();
1645 // Check, if map is already loaded
1647 while (i<=tabWidget->count() -1)
1649 me=(MapEditor*)tabWidget->page(i);
1650 if (me->getFilePath() == fn)
1652 // Already there, ask for confirmation
1653 QMessageBox mb( vymName,
1654 tr("The map %1\nis already opened."
1655 "Opening the same map in multiple editors may lead \n"
1656 "to confusion when finishing working with vym."
1657 "Do you want to").arg(fn),
1658 QMessageBox::Warning,
1659 QMessageBox::Yes | QMessageBox::Default,
1660 QMessageBox::Cancel | QMessageBox::Escape,
1661 QMessageBox::NoButton);
1662 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1663 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1666 case QMessageBox::Yes:
1668 i=tabWidget->count();
1670 case QMessageBox::Cancel:
1682 if ( !fn.isEmpty() )
1684 me = currentMapEditor();
1685 int tabIndex=tabWidget->currentPageIndex();
1686 // Check first, if mapeditor exists
1687 // If it is not default AND we want a new map,
1688 // create a new mapeditor in a new tab
1689 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1691 me= new MapEditor ( NULL);
1692 tabWidget->addTab (me,fn);
1693 tabIndex=tabWidget->indexOf (me);
1694 tabWidget->setCurrentPage (tabIndex);
1697 // Check, if file exists (important for creating new files
1698 // from command line
1699 if (!QFile(fn).exists() )
1701 QMessageBox mb( vymName,
1702 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1703 QMessageBox::Question,
1705 QMessageBox::Cancel | QMessageBox::Default,
1706 QMessageBox::NoButton );
1708 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1709 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1712 case QMessageBox::Yes:
1714 currentMapEditor()->setFilePath(fn);
1715 tabWidget->setTabLabel (currentMapEditor(),
1716 currentMapEditor()->getFileName() );
1717 statusBar()->message( "Created " + fn , statusbarTime );
1720 case QMessageBox::Cancel:
1721 // don't create new map
1722 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1729 //tabWidget->currentPage() won't be NULL here, because of above...
1730 tabWidget->showPage(me);
1731 me->viewport()->setFocus();
1733 // Create temporary directory for packing
1735 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
1738 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1739 tr("Couldn't create temporary directory before load\n"));
1743 // Try to unzip file
1744 err=unzipDir (tmpMapDir,fn);
1748 me->setZipped(false);
1751 me->setZipped(true);
1753 // Look for mapname.xml
1754 mapfile= fn.left(fn.findRev(".",-1,true));
1755 mapfile=mapfile.section( '/', -1 );
1756 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1757 if (!file.exists() )
1759 // mapname.xml does not exist, well,
1760 // maybe some renamed the mapname.vym file...
1761 // Try to find any .xml in the toplevel
1762 // directory of the .vym file
1763 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1764 if (flist.count()==1)
1766 // Only one entry, take this one
1767 mapfile=tmpMapDir + "/"+flist.first();
1770 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1771 *it=tmpMapDir + "/" + *it;
1772 // TODO Multiple entries, load all (but only the first one into this ME)
1773 //mainWindow->fileLoadFromTmp (flist);
1774 //returnCode=1; // Silently forget this attempt to load
1775 qWarning ("MainWindow::load (fn) multimap found...");
1778 if (flist.isEmpty() )
1780 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1781 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1784 } //file doesn't exist
1786 mapfile=file.name();
1791 // Save existing filename in case we import
1792 QString fn_org=me->getFilePath();
1794 // Finally load map into mapEditor
1795 me->setFilePath (mapfile,fn);
1796 err=me->load(mapfile,lmode);
1798 // Restore old (maybe empty) filepath, if this is an import
1800 me->setFilePath (fn_org);
1803 // Finally check for errors and go home
1806 if (lmode==NewMap) fileCloseMap();
1807 statusBar()->message( "Could not load " + fn, statusbarTime );
1812 me->setFilePath (fn);
1813 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1814 if (fn.left(9)!="/tmp/vym-")
1816 // Only append to lastMaps if not loaded from a tmpDir
1817 // e.g. imported bookmarks are in a tmpDir
1818 addRecentMap(me->getFilePath() );
1820 actionFilePrint->setEnabled (true);
1822 statusBar()->message( "Loaded " + fn, statusbarTime );
1826 removeDir (QDir(tmpMapDir));
1832 void Main::fileLoad(const LoadMode &lmode)
1834 QStringList filters;
1835 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1836 QFileDialog *fd=new QFileDialog( this);
1837 fd->setDir (lastFileDir);
1838 fd->setFileMode (QFileDialog::ExistingFiles);
1839 fd->setFilters (filters);
1843 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1846 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1849 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1855 if ( fd->exec() == QDialog::Accepted )
1857 lastFileDir=fd->directory().path();
1858 QStringList flist = fd->selectedFiles();
1859 QStringList::Iterator it = flist.begin();
1860 while( it != flist.end() )
1863 fileLoad(*it, lmode);
1870 void Main::fileLoad()
1875 void Main::fileLoadRecent()
1877 QAction *action = qobject_cast<QAction *>(sender());
1879 fileLoad (action->data().toString(), NewMap);
1882 void Main::addRecentMap (const QString &fileName)
1885 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1886 files.removeAll(fileName);
1887 files.prepend(fileName);
1888 while (files.size() > MaxRecentFiles)
1891 settings.setValue("/mainwindow/recentFileList", files);
1893 setupRecentMapsMenu();
1896 void Main::fileSave(const SaveMode &savemode)
1898 // tmp dir for zipping
1902 ErrorCode err=success;
1904 QString safeFilePath;
1906 bool saveZipped=currentMapEditor()->saveZipped();
1908 MapEditor * me=currentMapEditor();
1911 QString fn=me->getFilePath();
1912 // filename=unnamed, filepath="" in constructor...
1913 if ( !fn.isEmpty() )
1915 // We have a filepath, go on saving
1916 // First remove existing file, we
1917 // don't want to add to old zip archives
1921 QMessageBox::warning( 0, tr( "Save Error" ),
1922 fn+ tr("\ncould not be removed before saving"));
1924 // Look, if we should zip the data:
1927 QMessageBox mb( vymName,
1928 tr("The map %1\ndid not use the compressed "
1929 "vym file format.\nWriting it uncompressed will also write images \n"
1930 "and flags and thus may overwrite files in the "
1931 "given directory\n\nDo you want to write the map").arg(fn),
1932 QMessageBox::Warning,
1933 QMessageBox::Yes | QMessageBox::Default,
1935 QMessageBox::Cancel | QMessageBox::Escape);
1936 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
1937 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
1938 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1941 case QMessageBox::Yes:
1942 // save compressed (default file format)
1945 case QMessageBox::No:
1946 // save uncompressed
1949 case QMessageBox::Cancel:
1958 // Create temporary directory for packing
1960 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
1963 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1964 tr("Couldn't create temporary directory before save\n"));
1968 safeFilePath=me->getFilePath();
1969 me->setFilePath (tmpMapDir+"/"+
1970 me->getMapName()+ ".xml",
1972 me->save (savemode);
1973 me->setFilePath (safeFilePath);
1975 zipDir (tmpMapDir,fn);
1980 safeFilePath=me->getFilePath();
1981 me->setFilePath (fn, safeFilePath);
1982 me->save (savemode);
1983 me->setFilePath (safeFilePath);
1985 } // filepath available
1988 // We have no filepath yet,
1989 // call fileSaveAs() now, this will call fileSave()
1991 fileSaveAs(savemode);
1995 if (saveZipped && !tmpMapDir.isEmpty())
1997 removeDir (QDir(tmpMapDir));
2001 statusBar()->message(
2002 tr("Saved %1").arg(me->getFilePath()),
2004 addRecentMap (me->getFilePath() );
2006 statusBar()->message(
2007 tr("Couldn't save ").arg(me->getFilePath()),
2011 void Main::fileSave()
2013 fileSave (CompleteMap);
2016 void Main::fileSaveAs(const SaveMode& savemode)
2020 if (currentMapEditor())
2022 if (savemode==CompleteMap)
2023 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2025 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2026 if ( !fn.isEmpty() )
2028 // Check for existing file
2029 if (QFile (fn).exists())
2031 QMessageBox mb( vymName,
2032 tr("The file %1\nexists already. Do you want to").arg(fn),
2033 QMessageBox::Warning,
2034 QMessageBox::Yes | QMessageBox::Default,
2035 QMessageBox::Cancel | QMessageBox::Escape,
2036 QMessageBox::NoButton);
2037 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2038 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2041 case QMessageBox::Yes:
2044 case QMessageBox::Cancel:
2051 // New file, add extension to filename, if missing
2052 // This is always .vym or .vyp, depending on savemode
2053 if (savemode==CompleteMap)
2055 if (!fn.contains (".vym") && !fn.contains (".xml"))
2059 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2068 currentMapEditor()->setFilePath(fn);
2072 if (savemode==CompleteMap)
2073 tabWidget->setTabLabel (currentMapEditor(),
2074 currentMapEditor()->getFileName() );
2080 void Main::fileSaveAs()
2082 fileSaveAs (CompleteMap);
2085 void Main::fileImportKDEBookmarks()
2087 ImportKDEBookmarks im;
2089 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2090 currentMapEditor()->setFilePath ("");
2093 void Main::fileImportFirefoxBookmarks()
2095 Q3FileDialog *fd=new Q3FileDialog( this);
2096 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2097 fd->setMode (Q3FileDialog::ExistingFiles);
2098 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2099 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2102 if ( fd->exec() == QDialog::Accepted )
2104 ImportFirefoxBookmarks im;
2105 QStringList flist = fd->selectedFiles();
2106 QStringList::Iterator it = flist.begin();
2107 while( it != flist.end() )
2110 if (im.transform() &&
2111 success==fileLoad (im.getTransformedFile(),NewMap) &&
2112 currentMapEditor() )
2113 currentMapEditor()->setFilePath ("");
2120 void Main::fileImportMM()
2124 Q3FileDialog *fd=new Q3FileDialog( this);
2125 fd->setDir (lastFileDir);
2126 fd->setMode (Q3FileDialog::ExistingFiles);
2127 fd->addFilter ("Mind Manager (*.mmap)");
2128 fd->setCaption(tr("Import")+" "+"Mind Manager");
2131 if ( fd->exec() == QDialog::Accepted )
2133 lastFileDir=fd->dirPath();
2134 QStringList flist = fd->selectedFiles();
2135 QStringList::Iterator it = flist.begin();
2136 while( it != flist.end() )
2139 if (im.transform() &&
2140 success==fileLoad (im.getTransformedFile(),NewMap) &&
2141 currentMapEditor() )
2142 currentMapEditor()->setFilePath ("");
2151 void Main::fileImportDir()
2153 if (currentMapEditor())
2154 currentMapEditor()->importDir();
2157 void Main::fileExportXML()
2159 if (currentMapEditor())
2161 QString dir=browseDirectory(tr("Export XML to directory"));
2162 if (dir !="" && reallyWriteDirectory(dir) )
2163 currentMapEditor()->exportXML(dir);
2168 void Main::fileExportXHTML()
2170 MapEditor *me=currentMapEditor();
2174 ExportXHTMLDialog dia(this);
2175 dia.setFilePath (me->getFilePath() );
2176 dia.setMapName (me->getMapName() );
2179 if (dia.exec()==QDialog::Accepted)
2181 QString dir=dia.getDir();
2182 // Check, if warnings should be used before overwriting
2183 // the output directory
2186 ok=reallyWriteDirectory(dir);
2192 me->exportXML (dia.getDir() );
2193 dia.doExport(me->getMapName() );
2194 if (dia.hasChanged())
2201 void Main::fileExportImage()
2203 MapEditor *me=currentMapEditor();
2207 QFileDialog *fd=new QFileDialog (this);
2208 fd->setCaption (tr("Export map as image"));
2209 fd->setFileMode(QFileDialog::AnyFile);
2210 fd->setFilters (imageIO.getFilters() );
2211 fd->setDirectory (lastImageDir);
2214 fl=fd->selectedFiles();
2215 qWarning ("Selected "+fl.first()+" filter: "+fd->selectedFilter());
2216 me->exportImage (fl.first(), imageIO.getType (fd->selectedFilter() ) );
2221 void Main::fileExportASCII()
2223 MapEditor *me=currentMapEditor();
2227 ex.setMapCenter(me->getMapCenter());
2228 ex.addFilter ("TXT (*.txt)");
2229 ex.setCaption(vymName+ " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
2230 if (ex.execDialog() )
2232 me->setExportMode(true);
2234 me->setExportMode(false);
2239 void Main::fileExportLaTeX()
2241 MapEditor *me=currentMapEditor();
2245 ex.setMapCenter(me->getMapCenter());
2246 ex.addFilter ("Tex (*.tex)");
2247 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2248 if (ex.execDialog() )
2250 me->setExportMode(true);
2252 me->setExportMode(false);
2257 void Main::fileExportKDEBookmarks()
2259 ExportKDEBookmarks ex;
2260 MapEditor *me=currentMapEditor();
2263 ex.setMapCenter (me->getMapCenter() );
2268 void Main::fileExportTaskjuggler()
2270 ExportTaskjuggler ex;
2271 MapEditor *me=currentMapEditor();
2274 ex.setMapCenter (me->getMapCenter() );
2275 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2276 ex.addFilter ("Taskjuggler (*.tjp)");
2277 if (ex.execDialog() )
2279 me->setExportMode(true);
2281 me->setExportMode(false);
2286 void Main::fileExportOOPresentation()
2288 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2289 // TODO add preview in dialog
2290 //ImagePreview *p =new ImagePreview (fd);
2291 //fd->setContentsPreviewEnabled( TRUE );
2292 //fd->setContentsPreview( p, p );
2293 //fd->setPreviewMode( QFileDialog::Contents );
2294 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2295 fd->setDir (QDir().current());
2296 if (fd->foundConfig())
2300 if ( fd->exec() == QDialog::Accepted )
2302 QString fn=fd->selectedFile();
2303 if (!fn.contains (".odp"))
2306 //lastImageDir=fn.left(fn.findRev ("/"));
2307 if (currentMapEditor())
2308 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2312 QMessageBox::warning(0,
2314 tr("Couldn't find configuration for export to Open Office\n"));
2318 void Main::fileCloseMap()
2320 if (currentMapEditor())
2322 if (currentMapEditor()->hasChanged())
2324 QMessageBox mb( vymName,
2325 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2326 QMessageBox::Warning,
2327 QMessageBox::Yes | QMessageBox::Default,
2329 QMessageBox::Cancel | QMessageBox::Escape );
2330 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2331 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2334 case QMessageBox::Yes:
2336 fileSave(CompleteMap);
2338 case QMessageBox::No:
2339 // close without saving
2341 case QMessageBox::Cancel:
2346 currentMapEditor()->closeMap();
2347 tabWidget->removePage(currentMapEditor());
2348 if (tabWidget->count()==0)
2349 actionFilePrint->setEnabled (false);
2353 void Main::filePrint()
2355 if (currentMapEditor())
2356 currentMapEditor()->print();
2359 void Main::fileExitVYM()
2361 // Check if one or more editors have changed
2364 for (i=0;i<=tabWidget->count() -1;i++)
2367 me=(MapEditor*)tabWidget->page(i);
2369 // If something changed, ask what to do
2370 if (me->isUnsaved())
2372 tabWidget->setCurrentPage(i);
2373 QMessageBox mb( vymName,
2374 tr("This map is not saved yet. Do you want to"),
2375 QMessageBox::Warning,
2376 QMessageBox::Yes | QMessageBox::Default,
2378 QMessageBox::Cancel | QMessageBox::Escape );
2379 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2380 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2383 mb.setActiveWindow();
2384 switch( mb.exec() ) {
2385 case QMessageBox::Yes:
2386 // save (the changed editors) and exit
2387 fileSave(CompleteMap);
2389 case QMessageBox::No:
2390 // exit without saving
2392 case QMessageBox::Cancel:
2393 // don't save and don't exit
2397 } // loop over all MEs
2401 void Main::editUndo()
2403 if (currentMapEditor())
2404 currentMapEditor()->undo();
2407 void Main::editRedo()
2409 if (currentMapEditor())
2410 currentMapEditor()->redo();
2413 void Main::gotoHistoryStep (int i)
2415 if (currentMapEditor())
2416 currentMapEditor()->gotoHistoryStep (i);
2419 void Main::editCopy()
2421 if (currentMapEditor())
2422 currentMapEditor()->copy();
2425 void Main::editPaste()
2427 if (currentMapEditor())
2428 currentMapEditor()->paste();
2431 void Main::editCut()
2433 if (currentMapEditor())
2434 currentMapEditor()->cut();
2437 void Main::editOpenFindWindow()
2439 findWindow->popup();
2440 findWindow->raise();
2441 findWindow->setActiveWindow();
2444 void Main::editFind(QString s)
2447 BranchObj *bo=currentMapEditor()->findText(s, cs);
2450 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2453 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2454 tr("No matches found for \"%1\"").arg(s));
2458 void Main::editFindChanged()
2459 { // Notify editor, to abort the current find process
2460 currentMapEditor()->findReset();
2463 void Main::openTabs(QStringList urls)
2465 if (!urls.isEmpty())
2469 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2471 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2473 QString u=urls.takeFirst();
2474 procBrowser = new QProcess( this );
2476 procBrowser->start(browser,args);
2477 if ( !procBrowser->waitForStarted())
2479 // try to set path to browser
2480 QMessageBox::warning(0,
2482 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2483 tr("Please use Settings->")+tr("Set application to open an URL"));
2488 if (browser.contains("konqueror"))
2490 for (int i=0; i<urls.size(); i++)
2493 // Try to open new tab in existing konqueror started previously by vym
2494 p=new QProcess (this);
2496 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2497 "konqueror-mainwindow#1"<<
2500 p->start ("dcop",args);
2501 if ( !p->waitForStarted() ) success=false;
2504 QMessageBox::warning(0,
2506 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2508 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2510 for (int i=0; i<urls.size(); i++)
2512 // Try to open new tab in firefox
2513 p=new QProcess (this);
2514 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2515 p->start (browser,args);
2516 if ( !p->waitForStarted() ) success=false;
2519 QMessageBox::warning(0,
2521 tr("Couldn't start %1 to open a new tab").arg(browser));
2524 QMessageBox::warning(0,
2526 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2530 void Main::editOpenURL()
2533 if (currentMapEditor())
2535 QString url=currentMapEditor()->getURL();
2537 if (url=="") return;
2538 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2539 procBrowser = new QProcess( this );
2541 procBrowser->start(browser,args);
2542 if ( !procBrowser->waitForStarted())
2544 // try to set path to browser
2545 QMessageBox::warning(0,
2547 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2548 tr("Please use Settings->")+tr("Set application to open an URL"));
2553 void Main::editOpenURLTab()
2555 if (currentMapEditor())
2558 urls.append(currentMapEditor()->getURL());
2562 void Main::editOpenMultipleURLTabs()
2564 if (currentMapEditor())
2567 urls=currentMapEditor()->getURLs();
2573 void Main::editURL()
2575 if (currentMapEditor())
2576 currentMapEditor()->editURL();
2579 void Main::editHeading2URL()
2581 if (currentMapEditor())
2582 currentMapEditor()->editHeading2URL();
2585 void Main::editBugzilla2URL()
2587 if (currentMapEditor())
2588 currentMapEditor()->editBugzilla2URL();
2591 void Main::editFATE2URL()
2593 if (currentMapEditor())
2594 currentMapEditor()->editFATE2URL();
2597 void Main::editHeadingFinished()
2599 // only called from editHeading(), so there is a currentME
2600 MapEditor *me=currentMapEditor();
2602 #if defined(Q_OS_MACX)
2604 me->setHeading(lineedit->text());
2606 lineedit->releaseKeyboard();
2610 if (!prevSelection.isEmpty()) me->select(prevSelection);
2614 void Main::editHeading()
2616 if (currentMapEditor())
2618 MapEditor *me=currentMapEditor();
2619 QString oldSel=me->getSelectString();
2621 if (lineedit->isVisible())
2622 editHeadingFinished();
2627 QString s=currentMapEditor()->getHeading(ok,p);
2631 #if defined(Q_OS_MACX)
2632 p = currentMapEditor()->mapToGlobal( currentMapEditor()->worldMatrix().map( p));
2633 QDialog *d =new QDialog(NULL);
2634 QLineEdit *le=new QLineEdit (d);
2635 d->setWindowFlags (Qt::FramelessWindowHint);
2636 d->setGeometry(p.x(),p.y(),230,25);
2637 le->resize (d->width()-10,d->height());
2640 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2641 d->activateWindow();
2643 currentMapEditor()->setHeading (le->text());
2646 editHeadingFinished();
2648 p = currentMapEditor()->mapTo(this, currentMapEditor()->worldMatrix().map( p));
2649 lineedit->setGeometry(p.x(),p.y(),230,25);
2650 lineedit->setText(s);
2651 lineedit->setCursorPosition(1);
2652 lineedit->selectAll();
2654 lineedit->grabKeyboard();
2655 lineedit->setFocus();
2659 } // currentMapEditor()
2662 void Main::openVymLinks(const QStringList &vl)
2664 for (int j=0; j<vl.size(); j++)
2666 // compare path with already loaded maps
2670 for (i=0;i<=tabWidget->count() -1;i++)
2672 me=(MapEditor*)tabWidget->page(i);
2673 if (vl.at(j)==me->getFilePath() )
2682 if (!QFile(vl.at(j)).exists() )
2683 QMessageBox::critical( 0, tr( "Critical Error" ),
2684 tr("Couldn't open map %1").arg(vl.at(j)));
2687 fileLoad (vl.at(j), NewMap);
2688 tabWidget->setCurrentPage (tabWidget->count()-1);
2691 // Go to tab containing the map
2692 tabWidget->setCurrentPage (index);
2696 void Main::editOpenVymLink()
2698 if (currentMapEditor())
2701 vl.append(currentMapEditor()->getVymLink());
2706 void Main::editOpenMultipleVymLinks()
2708 QString currentVymLink;
2709 if (currentMapEditor())
2711 QStringList vl=currentMapEditor()->getVymLinks();
2716 void Main::editVymLink()
2718 if (currentMapEditor())
2719 currentMapEditor()->editVymLink();
2722 void Main::editDeleteVymLink()
2724 if (currentMapEditor())
2725 currentMapEditor()->deleteVymLink();
2728 void Main::editToggleHideExport()
2730 if (currentMapEditor())
2731 currentMapEditor()->toggleHideExport();
2734 void Main::editMapInfo()
2736 if (currentMapEditor())
2737 currentMapEditor()->editMapInfo();
2740 void Main::editMoveUp()
2742 if (currentMapEditor())
2743 currentMapEditor()->moveBranchUp();
2746 void Main::editMoveDown()
2748 if (currentMapEditor())
2749 currentMapEditor()->moveBranchDown();
2752 void Main::editToggleScroll()
2754 if (currentMapEditor())
2756 currentMapEditor()->toggleScroll();
2760 void Main::editUnScrollAll()
2762 if (currentMapEditor())
2763 currentMapEditor()->unScrollAll();
2766 void Main::editNewBranch()
2768 MapEditor *me=currentMapEditor();
2769 if (!lineedit->isVisible() && me)
2771 BranchObj *bo=(BranchObj*)me->getSelection();
2772 BranchObj *newbo=me->addNewBranch(0);
2775 me->select (newbo->getSelectString());
2779 if (actionSettingsAutoEdit->isOn())
2781 if (!actionSettingsAutoSelectHeading->isOn())
2782 prevSelection=bo->getSelectString();
2788 void Main::editNewBranchBefore()
2790 MapEditor *me=currentMapEditor();
2791 if (!lineedit->isVisible() && me)
2793 BranchObj *bo=(BranchObj*)me->getSelection();
2794 BranchObj *newbo=me->addNewBranchBefore();
2797 me->select (newbo->getSelectString());
2801 if (actionSettingsAutoEdit->isOn())
2803 if (!actionSettingsAutoSelectHeading->isOn())
2804 prevSelection=bo->getSelectString();
2810 void Main::editNewBranchAbove()
2812 MapEditor *me=currentMapEditor();
2813 if (!lineedit->isVisible() && me)
2815 BranchObj *bo=(BranchObj*)me->getSelection();
2816 BranchObj *newbo=me->addNewBranch (-1);
2819 me->select (newbo->getSelectString());
2823 if (actionSettingsAutoEdit->isOn())
2825 if (!actionSettingsAutoSelectHeading->isOn())
2826 prevSelection=bo->getSelectString();
2832 void Main::editNewBranchBelow()
2834 MapEditor *me=currentMapEditor();
2835 if (!lineedit->isVisible() && me)
2837 BranchObj *bo=(BranchObj*)me->getSelection();
2838 BranchObj *newbo=me->addNewBranch (1);
2841 me->select (newbo->getSelectString());
2845 if (actionSettingsAutoEdit->isOn())
2847 if (!actionSettingsAutoSelectHeading->isOn())
2848 prevSelection=bo->getSelectString();
2854 void Main::editImportAdd()
2856 fileLoad (ImportAdd);
2859 void Main::editImportReplace()
2861 fileLoad (ImportReplace);
2864 void Main::editSaveBranch()
2866 fileSaveAs (PartOfMap);
2869 void Main::editDeleteKeepChilds()
2871 if (currentMapEditor())
2872 currentMapEditor()->deleteKeepChilds();
2875 void Main::editDeleteChilds()
2877 if (currentMapEditor())
2878 currentMapEditor()->deleteChilds();
2881 void Main::editDeleteSelection()
2883 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2884 currentMapEditor()->deleteSelection();
2887 void Main::editUpperBranch()
2889 if (currentMapEditor())
2890 currentMapEditor()->selectUpperBranch();
2893 void Main::editLowerBranch()
2895 if (currentMapEditor())
2896 currentMapEditor()->selectLowerBranch();
2899 void Main::editLeftBranch()
2901 if (currentMapEditor())
2902 currentMapEditor()->selectLeftBranch();
2905 void Main::editRightBranch()
2907 if (currentMapEditor())
2908 currentMapEditor()->selectRightBranch();
2911 void Main::editFirstBranch()
2913 if (currentMapEditor())
2914 currentMapEditor()->selectFirstBranch();
2917 void Main::editLastBranch()
2919 if (currentMapEditor())
2920 currentMapEditor()->selectLastBranch();
2923 void Main::editLoadImage()
2925 if (currentMapEditor())
2926 currentMapEditor()->loadFloatImage();
2929 void Main::editSaveImage()
2931 if (currentMapEditor())
2932 currentMapEditor()->saveFloatImage();
2935 void Main::editFollowXLink(QAction *a)
2938 if (currentMapEditor())
2939 currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
2942 void Main::editEditXLink(QAction *a)
2944 if (currentMapEditor())
2945 currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
2948 void Main::formatSelectColor()
2950 if (currentMapEditor())
2952 QColor col = QColorDialog::getColor((currentColor ), this );
2953 if ( !col.isValid() ) return;
2954 colorChanged( col );
2958 void Main::formatPickColor()
2960 if (currentMapEditor())
2961 colorChanged( currentMapEditor()->getCurrentHeadingColor() );
2964 void Main::colorChanged(QColor c)
2966 QPixmap pix( 16, 16 );
2968 actionFormatColor->setIconSet( pix );
2972 void Main::formatColorItem()
2974 if (currentMapEditor())
2975 currentMapEditor()->colorItem(currentColor);
2978 void Main::formatColorBranch()
2980 if (currentMapEditor())
2981 currentMapEditor()->colorBranch(currentColor);
2984 void Main::formatLinkStyleLine()
2986 if (currentMapEditor())
2987 currentMapEditor()->setMapLinkStyle("StyleLine");
2990 void Main::formatLinkStyleParabel()
2992 if (currentMapEditor())
2993 currentMapEditor()->setMapLinkStyle("StyleParabel");
2996 void Main::formatLinkStylePolyLine()
2998 if (currentMapEditor())
2999 currentMapEditor()->setMapLinkStyle("StylePolyLine");
3002 void Main::formatLinkStylePolyParabel()
3004 if (currentMapEditor())
3005 currentMapEditor()->setMapLinkStyle("StylePolyParabel");
3008 void Main::formatSelectBackColor()
3010 if (currentMapEditor())
3011 currentMapEditor()->selectMapBackgroundColor();
3014 void Main::formatSelectLinkColor()
3016 if (currentMapEditor())
3017 currentMapEditor()->selectMapLinkColor();
3020 void Main::formatToggleLinkColorHint()
3022 currentMapEditor()->toggleMapLinkColorHint();
3025 void Main::formatFrameNone()
3027 if (currentMapEditor())
3028 currentMapEditor()->setFrame(NoFrame);
3031 void Main::formatFrameRectangle()
3033 if (currentMapEditor())
3034 currentMapEditor()->setFrame(Rectangle);
3037 void Main::formatIncludeImagesVer()
3039 if (currentMapEditor())
3040 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
3043 void Main::formatIncludeImagesHor()
3045 if (currentMapEditor())
3046 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
3049 void Main::formatHideLinkUnselected()
3051 if (currentMapEditor())
3052 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3055 void Main::viewZoomReset()
3057 if (currentMapEditor())
3061 currentMapEditor()->setWorldMatrix( m );
3062 currentMapEditor()->setViewCenter();
3063 currentMapEditor()->adjustCanvasSize();
3067 void Main::viewZoomIn()
3069 if (currentMapEditor())
3071 QMatrix m = currentMapEditor()->worldMatrix();
3072 m.scale( 1.25, 1.25 );
3073 currentMapEditor()->setWorldMatrix( m );
3074 currentMapEditor()->setViewCenter();
3075 currentMapEditor()->adjustCanvasSize();
3079 void Main::viewZoomOut()
3081 if (currentMapEditor())
3083 QMatrix m = currentMapEditor()->worldMatrix();
3084 m.scale( 0.8, 0.8 );
3085 currentMapEditor()->setWorldMatrix( m );
3086 currentMapEditor()->setViewCenter();
3087 currentMapEditor()->adjustCanvasSize();
3091 bool Main::settingsPDF()
3093 // Default browser is set in constructor
3095 QString text = QInputDialog::getText(
3096 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3097 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3099 settings.setValue ("/mainwindow/readerPDF",text);
3104 bool Main::settingsURL()
3106 // Default browser is set in constructor
3108 QString text = QInputDialog::getText(
3109 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3110 settings.value("/mainwindow/readerURL").toString()
3113 settings.setValue ("/mainwindow/readerURL",text);
3117 void Main::settingsToggleDelKey()
3119 if (actionSettingsUseDelKey->isOn())
3121 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3124 actionEditDelete->setAccel (QKeySequence (""));
3128 void Main::windowToggleNoteEditor()
3130 if (textEditor->showWithMain() )
3131 windowHideNoteEditor();
3133 windowShowNoteEditor();
3136 void Main::windowToggleHistory()
3138 if (historyWindow->isVisible())
3139 historyWindow->hide();
3141 historyWindow->show();
3145 void Main::updateHistory(SimpleSettings &undoSet)
3147 historyWindow->update (undoSet);
3150 void Main::updateNoteFlag()
3152 if (currentMapEditor())
3153 currentMapEditor()->updateNoteFlag();
3156 void Main::updateActions()
3158 MapEditor *me=currentMapEditor();
3161 // updateActions is also called when NoteEditor is closed
3162 actionViewToggleNoteEditor->setOn (textEditor->showWithMain());
3164 if (me->getMapLinkColorHint()==HeadingColor)
3165 actionFormatLinkColorHint->setOn(true);
3167 actionFormatLinkColorHint->setOn(false);
3169 switch (me->getMapLinkStyle())
3172 actionFormatLinkStyleLine->setOn(true);
3175 actionFormatLinkStyleParabel->setOn(true);
3178 actionFormatLinkStylePolyLine->setOn(true);
3180 case StylePolyParabel:
3181 actionFormatLinkStylePolyParabel->setOn(true);
3187 QPixmap pix( 16, 16 );
3188 pix.fill( me->getMapBackgroundColor() );
3189 actionFormatBackColor->setIconSet( pix );
3190 pix.fill( me->getMapDefLinkColor() );
3191 actionFormatLinkColor->setIconSet( pix );
3193 actionFileSave->setEnabled( me->isUnsaved() );
3194 if (me->isUndoAvailable())
3195 actionEditUndo->setEnabled( true);
3197 actionEditUndo->setEnabled( false);
3199 if (me->isRedoAvailable())
3200 actionEditRedo->setEnabled( true);
3202 actionEditRedo->setEnabled( false);
3204 LinkableMapObj *selection=me->getSelection();
3207 if ( (typeid(*selection) == typeid(BranchObj)) ||
3208 (typeid(*selection) == typeid(MapCenterObj)) )
3210 BranchObj *bo=(BranchObj*)selection;
3211 // Take care of links
3212 if (bo->countXLinks()==0)
3214 branchXLinksContextMenuEdit->clear();
3215 branchXLinksContextMenuFollow->clear();
3220 branchXLinksContextMenuEdit->clear();
3221 branchXLinksContextMenuFollow->clear();
3222 for (int i=0; i<=bo->countXLinks();i++)
3224 bot=bo->XLinkTargetAt(i);
3227 s=bot->getHeading();
3230 branchXLinksContextMenuFollow->addAction (s);
3231 branchXLinksContextMenuEdit->addAction (s);
3236 standardFlagsDefault->setEnabled (true);
3238 actionEditToggleScroll->setEnabled (true);
3239 if ( bo->isScrolled() )
3240 actionEditToggleScroll->setOn(true);
3242 actionEditToggleScroll->setOn(false);
3244 if ( bo->getURL().isEmpty() )
3246 actionEditOpenURL->setEnabled (false);
3247 actionEditOpenURLTab->setEnabled (false);
3251 actionEditOpenURL->setEnabled (true);
3252 actionEditOpenURLTab->setEnabled (true);
3254 if ( bo->getVymLink().isEmpty() )
3256 actionEditOpenVymLink->setEnabled (false);
3257 actionEditDeleteVymLink->setEnabled (false);
3260 actionEditOpenVymLink->setEnabled (true);
3261 actionEditDeleteVymLink->setEnabled (true);
3264 if (bo->canMoveBranchUp())
3265 actionEditMoveUp->setEnabled (true);
3267 actionEditMoveUp->setEnabled (false);
3268 if (bo->canMoveBranchDown())
3269 actionEditMoveDown->setEnabled (true);
3271 actionEditMoveDown->setEnabled (false);
3274 actionEditToggleHideExport->setEnabled (true);
3275 actionEditToggleHideExport->setOn (bo->hideInExport() );
3277 actionEditCopy->setEnabled (true);
3278 actionEditCut->setEnabled (true);
3279 if (!clipboardEmpty)
3280 actionEditPaste->setEnabled (true);
3282 actionEditPaste->setEnabled (false);
3283 for (int i=0; i<actionListBranches.size(); ++i)
3284 actionListBranches.at(i)->setEnabled(true);
3285 actionEditDelete->setEnabled (true);
3286 switch (selection->getFrameType())
3289 actionFormatFrameNone->setOn(true);
3292 actionFormatFrameRectangle->setOn(true);
3297 actionFormatIncludeImagesVer->setOn
3298 ( ((BranchObj*)selection)->getIncludeImagesVer());
3299 actionFormatIncludeImagesHor->setOn
3300 ( ((BranchObj*)selection)->getIncludeImagesHor());
3301 actionFormatHideLinkUnselected->setOn
3302 (selection->getHideLinkUnselected());
3304 if ( (typeid(*selection) == typeid(FloatImageObj)) )
3306 FloatObj *fo=(FloatImageObj*)selection;
3307 //FIXME do this in mainwindow standardFlagsDefault->setEnabled (false);
3309 actionEditOpenURL->setEnabled (false);
3310 actionEditOpenVymLink->setEnabled (false);
3311 actionEditDeleteVymLink->setEnabled (false);
3312 actionEditToggleHideExport->setEnabled (true);
3313 actionEditToggleHideExport->setOn (fo->hideInExport() );
3316 actionEditCopy->setEnabled (true);
3317 actionEditCut->setEnabled (true);
3318 actionEditPaste->setEnabled (false);
3319 for (int i=0; i<actionListBranches.size(); ++i)
3320 actionListBranches.at(i)->setEnabled(false);
3321 actionEditDelete->setEnabled (true);
3322 actionFormatHideLinkUnselected->setOn
3323 ( selection->getHideLinkUnselected());
3324 actionEditMoveUp->setEnabled (false);
3325 actionEditMoveDown->setEnabled (false);
3330 actionEditCopy->setEnabled (false);
3331 actionEditCut->setEnabled (false);
3332 actionEditPaste->setEnabled (false);
3333 for (int i=0; i<actionListBranches.size(); ++i)
3334 actionListBranches.at(i)->setEnabled(false);
3336 actionEditToggleScroll->setEnabled (false);
3337 actionEditOpenURL->setEnabled (false);
3338 actionEditOpenVymLink->setEnabled (false);
3339 actionEditDeleteVymLink->setEnabled (false);
3340 actionEditHeading2URL->setEnabled (false);
3341 actionEditDelete->setEnabled (false);
3342 actionEditMoveUp->setEnabled (false);
3343 actionEditMoveDown->setEnabled (false);
3344 actionEditToggleHideExport->setEnabled (false);
3348 ModMode Main::getModMode()
3350 if (actionModModeColor->isOn()) return ModModeColor;
3351 if (actionModModeCopy->isOn()) return ModModeCopy;
3352 if (actionModModeXLink->isOn()) return ModModeXLink;
3356 bool Main::autoEdit()
3358 return actionSettingsAutoEdit->isOn();
3361 bool Main::autoSelectHeading()
3363 return actionSettingsAutoSelectHeading->isOn();
3366 bool Main::useFlagGroups()
3368 return actionSettingsUseFlagGroups->isOn();
3371 void Main::windowShowNoteEditor()
3373 textEditor->setShowWithMain(true);
3375 actionViewToggleNoteEditor->setOn (true);
3378 void Main::windowHideNoteEditor()
3380 textEditor->setShowWithMain(false);
3382 actionViewToggleNoteEditor->setOn (false);
3385 void Main::windowNextEditor()
3387 if (tabWidget->currentPageIndex() < tabWidget->count())
3388 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3391 void Main::windowPreviousEditor()
3393 if (tabWidget->currentPageIndex() >0)
3394 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3397 void Main::standardFlagChanged()
3399 currentMapEditor()->toggleStandardFlag(sender()->name());
3402 void Main::testFunction()
3404 if (!currentMapEditor()) return;
3405 currentMapEditor()->testFunction();
3408 void Main::testCommand()
3410 if (!currentMapEditor()) return;
3412 QString com = QInputDialog::getText(
3413 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3414 if (ok) currentMapEditor()->parseAtom(com);
3417 void Main::helpDoc()
3419 QString locale = QLocale::system().name();
3421 if (locale.left(2)=="es")
3422 docname="vym_es.pdf";
3426 #if defined(Q_OS_MACX)
3427 docdir.setPath("./vym.app/Contents");
3429 // default path in SUSE LINUX
3430 docdir.setPath("/usr/share/doc/packages/vym/doc");
3433 if (!docdir.exists() )
3435 // relative path for easy testing in tarball
3436 docdir.setPath("doc");
3437 if (!docdir.exists() )
3439 // relative path for testing while still writing vym.tex
3440 docdir.setPath("doc/tex/vym.pdf");
3441 if (!docdir.exists() )
3443 // Try yet another one for Knoppix
3444 docdir.setPath("/usr/share/doc/packages/vym");
3445 if (!docdir.exists() )
3447 QMessageBox::critical(0,
3448 tr("Critcal error"),
3449 tr("Couldn't find the documentation\n"
3450 "vym.pdf in various directories."));
3457 QString docpath=docdir.path()+"/"+docname;
3458 Process *pdfProc = new Process();
3459 pdfProc->clearArguments();
3460 pdfProc->addArgument( settings.value("/mainwindow/readerPDF").toString());
3461 pdfProc->addArgument( docpath);
3463 if ( !pdfProc->start() )
3466 QMessageBox::warning(0,
3468 tr("Couldn't find a viewer to open %1.\n").arg(docpath)+
3469 tr("Please use Settings->")+tr("Set application to open PDF files"));
3476 void Main::helpAbout()
3479 ad.setName ("aboutwindow");
3480 ad.setMinimumSize(500,500);
3481 ad.resize (QSize (500,500));
3485 void Main::helpAboutQT()
3487 QMessageBox::aboutQt( this, "Qt Application Example" );