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() );
172 settings.setValue ("/mainwindow/state",saveState(0));
174 settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
175 settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
176 settings.setValue( "/version/version", vymVersion );
177 settings.setValue( "/version/builddate", vymBuildDate );
179 settings.setValue( "/mapeditor/editmode/autoSelectHeading",actionSettingsAutoSelectHeading->isOn() );
180 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
181 settings.setValue( "/mapeditor/editmode/autoEdit",actionSettingsAutoEdit->isOn() );
182 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
183 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
184 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
186 // call the destructors
188 delete historyWindow;
190 // Remove temporary directory
191 removeDir (QDir(tmpVymDir));
194 void Main::loadCmdLine()
196 /* TODO draw some kind of splashscreen while loading...
202 QStringList flist=options.getFileList();
203 QStringList::Iterator it=flist.begin();
205 while (it !=flist.end() )
207 fileLoad (*it, NewMap);
213 void Main::statusMessage(const QString &s)
215 statusBar()->message (s);
218 void Main::closeEvent (QCloseEvent* )
224 void Main::setupFileActions()
226 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
227 QToolBar *tb = addToolBar( tr ("&Map") );
228 tb->setObjectName ("mapTB");
231 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New...","File menu" ),this);
232 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
233 a->setShortcut ( Qt::CTRL + Qt::Key_N );
235 fileMenu->addAction (a);
236 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
238 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
239 a->setStatusTip (tr( "Open","Status tip File menu" ) );
240 a->setShortcut ( Qt::CTRL + Qt::Key_O );
242 fileMenu->addAction (a);
243 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
245 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
246 fileMenu->addSeparator();
248 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
249 a->setStatusTip ( tr( "Save","Status tip file menu" ));
250 a->setShortcut (Qt::CTRL + Qt::Key_S );
252 fileMenu->addAction (a);
253 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
256 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
257 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
258 fileMenu->addAction (a);
259 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
261 fileMenu->addSeparator();
263 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
265 a = new QAction(tr("KDE Bookmarks"), this);
266 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE bookmarks")));
267 a->addTo (fileImportMenu);
268 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) );
270 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
272 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
273 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
274 a->addTo (fileImportMenu);
275 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
278 a = new QAction("Mind Manager...",this);
279 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
280 fileImportMenu->addAction (a);
281 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
283 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
284 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
285 fileImportMenu->addAction (a);
286 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
288 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
290 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
291 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
292 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
293 fileExportMenu->addAction (a);
295 a = new QAction( "Open Office...", this);
296 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
297 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
298 fileExportMenu->addAction (a);
300 a = new QAction( "Webpage (XHTML)...",this );
301 a->setShortcut (Qt::ALT + Qt::Key_X);
302 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
303 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
304 fileExportMenu->addAction (a);
306 a = new QAction( "Text (ASCII)...", this);
307 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
308 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
309 fileExportMenu->addAction (a);
311 a = new QAction( tr("KDE Bookmarks","File menu"), this);
312 a->setStatusTip( tr( "Export as %1").arg(tr("KDE Bookmarks" )));
313 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
314 fileExportMenu->addAction (a);
316 a = new QAction( "Taskjuggler...", this );
317 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
318 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
319 fileExportMenu->addAction (a);
321 a = new QAction( "LaTeX...", this);
322 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
323 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
324 fileExportMenu->addAction (a);
326 a = new QAction( "XML..." , this );
327 a->setStatusTip (tr( "Export as %1").arg("XML"));
328 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
329 fileExportMenu->addAction (a);
331 fileMenu->addSeparator();
333 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
334 a->setStatusTip ( tr( "Print" ,"File menu") );
335 a->setShortcut (Qt::CTRL + Qt::Key_P );
337 fileMenu->addAction (a);
338 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
341 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
342 a->setStatusTip (tr( "Close Map" ) );
343 a->setShortcut (Qt::ALT + Qt::Key_C );
344 fileMenu->addAction (a);
345 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
347 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
348 a->setStatusTip ( tr( "Exit")+" "+vymName );
349 a->setShortcut (Qt::CTRL + Qt::Key_Q );
350 fileMenu->addAction (a);
351 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
356 void Main::setupEditActions()
358 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
359 tb->setLabel( "Edit Actions" );
360 tb->setObjectName ("actionsTB");
361 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
365 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
366 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
367 a->setStatusTip (tr( "Undo" ) );
368 a->setShortcut ( Qt::CTRL + Qt::Key_Z );
369 a->setEnabled (false);
371 editMenu->addAction (a);
374 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
375 a->setStatusTip (tr( "Redo" ));
376 a->setShortcut (Qt::CTRL + Qt::Key_Y );
378 editMenu->addAction (a);
379 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
382 editMenu->addSeparator();
383 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
384 a->setStatusTip ( tr( "Copy" ) );
385 a->setShortcut (Qt::CTRL + Qt::Key_C );
386 a->setEnabled (false);
388 editMenu->addAction (a);
389 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
392 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
393 a->setStatusTip ( tr( "Cut" ) );
394 a->setShortcut (Qt::CTRL + Qt::Key_X );
395 a->setEnabled (false);
397 editMenu->addAction (a);
399 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
401 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
402 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
403 a->setStatusTip ( tr( "Paste" ) );
404 a->setShortcut ( Qt::CTRL + Qt::Key_V );
405 a->setEnabled (false);
407 editMenu->addAction (a);
410 // Shortcuts to modify heading:
411 a = new QAction(tr( "Edit heading","Edit menu" ),this);
412 a->setStatusTip ( tr( "edit Heading" ));
413 a->setShortcut ( Qt::Key_Enter);
414 // a->setShortcutContext (Qt::WindowShortcut);
416 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
417 actionListBranches.append(a);
418 a = new QAction( tr( "Edit heading","Edit menu" ), this);
419 a->setStatusTip (tr( "edit Heading" ));
420 a->setShortcut (Qt::Key_Return );
421 //a->setShortcutContext (Qt::WindowShortcut);
423 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
424 actionListBranches.append(a);
425 editMenu->addAction (a);
427 a = new QAction( tr( "Edit heading","Edit menu" ), this);
428 a->setStatusTip (tr( "edit Heading" ));
429 a->setShortcut ( Qt::Key_F2 );
430 a->setShortcutContext (Qt::WindowShortcut);
432 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
433 actionListBranches.append(a);
435 // Shortcut to delete selection
436 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
437 a->setStatusTip (tr( "Delete Selection" ));
438 a->setShortcut ( Qt::Key_Delete);
439 a->setShortcutContext (Qt::WindowShortcut);
441 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
444 // Shortcut to add branch
445 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
446 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
447 alt->setShortcut (Qt::Key_A);
448 alt->setShortcutContext (Qt::WindowShortcut);
450 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
451 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
452 a->setStatusTip ( tr( "Add a branch as child of selection" ));
453 a->setShortcut (Qt::Key_Insert);
454 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
455 actionListBranches.append(a);
456 #if defined (Q_OS_MACX)
457 // In OSX show different shortcut in menues, the keys work indepently always
458 actionEditAddBranch=alt;
460 actionEditAddBranch=a;
462 editMenu->addAction (actionEditAddBranch);
463 tb->addAction (actionEditAddBranch);
466 // Add branch by inserting it at selection
467 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
468 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
469 a->setShortcut (Qt::ALT + Qt::Key_Insert );
470 a->setShortcutContext (Qt::WindowShortcut);
472 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
473 a->setEnabled (false);
474 actionListBranches.append(a);
475 actionEditAddBranchBefore=a;
476 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
477 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
478 a->setShortcut ( Qt::ALT + Qt::Key_A );
479 a->setShortcutContext (Qt::WindowShortcut);
481 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
482 actionListBranches.append(a);
485 a = new QAction(tr( "Add branch above","Edit menu" ), this);
486 a->setStatusTip ( tr( "Add a branch above selection" ));
487 a->setShortcut (Qt::SHIFT+Qt::Key_Insert );
488 a->setShortcutContext (Qt::WindowShortcut);
490 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
491 a->setEnabled (false);
492 actionListBranches.append(a);
493 actionEditAddBranchAbove=a;
494 a = new QAction(tr( "Add branch above","Edit menu" ), this);
495 a->setStatusTip ( tr( "Add a branch above selection" ));
496 a->setShortcut (Qt::SHIFT+Qt::Key_A );
497 a->setShortcutContext (Qt::WindowShortcut);
499 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
500 actionListBranches.append(a);
503 a = new QAction(tr( "Add branch below","Edit menu" ), this);
504 a->setStatusTip ( tr( "Add a branch below selection" ));
505 a->setShortcut (Qt::CTRL +Qt::Key_Insert );
506 a->setShortcutContext (Qt::WindowShortcut);
508 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
509 a->setEnabled (false);
510 actionListBranches.append(a);
511 actionEditAddBranchBelow=a;
512 a = new QAction(tr( "Add branch below","Edit menu" ), this);
513 a->setStatusTip ( tr( "Add a branch below selection" ));
514 a->setShortcut (Qt::CTRL +Qt::Key_A );
515 a->setShortcutContext (Qt::WindowShortcut);
517 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
518 actionListBranches.append(a);
520 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
521 a->setStatusTip ( tr( "Move branch up" ) );
522 a->setShortcut (Qt::Key_PageUp );
523 a->setEnabled (false);
525 editMenu->addAction (a);
526 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
529 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
530 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
531 a->setStatusTip (tr( "Move branch down" ) );
532 a->setShortcut ( Qt::Key_PageDown );
533 a->setEnabled (false);
535 editMenu->addAction (a);
536 actionEditMoveDown=a;
539 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this);
540 a->setShortcut ( Qt::Key_ScrollLock );
541 a->setStatusTip (tr( "Scroll branch" ) );
542 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
544 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
545 alt->setShortcut ( Qt::Key_S );
546 alt->setStatusTip (tr( "Scroll branch" ));
547 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
548 #if defined(Q_OS_MACX)
549 actionEditToggleScroll=alt;
551 actionEditToggleScroll=a;
553 actionEditToggleScroll->setEnabled (false);
554 actionEditToggleScroll->setToggleAction(true);
555 tb->addAction (actionEditToggleScroll);
556 editMenu->addAction ( actionEditToggleScroll);
557 editMenu->addAction (actionEditToggleScroll);
560 actionListBranches.append(actionEditToggleScroll);
562 a = new QAction( tr( "Unscroll all scrolled branches","Edit menu" ), this);
563 a->setStatusTip (tr( "Unscroll all" ));
564 editMenu->addAction (a);
565 connect( a, SIGNAL( triggered() ), this, SLOT( editUnScrollAll() ) );
567 editMenu->addSeparator();
569 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
570 a->setStatusTip (tr( "Find" ) );
571 a->setShortcut (Qt::CTRL + Qt::Key_F );
572 editMenu->addAction (a);
573 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
575 editMenu->addSeparator();
577 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
578 a->setShortcut (Qt::CTRL + Qt::Key_U );
579 a->setShortcut (tr( "Open URL" ));
582 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
585 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
586 a->setStatusTip (tr( "Open URL in new tab" ));
587 a->setShortcut (Qt::CTRL+Qt::Key_U );
589 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
590 actionEditOpenURLTab=a;
592 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
593 a->setStatusTip (tr( "Open all URLs in subtree" ));
595 actionListBranches.append(a);
596 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
597 actionEditOpenMultipleURLTabs=a;
599 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
600 a->setStatusTip ( tr( "Edit URL" ) );
601 a->setShortcut (Qt::SHIFT + Qt::CTRL + Qt::Key_U );
602 //a->setShortcut ( Qt::Key_U );
603 a->setShortcutContext (Qt::WindowShortcut);
604 actionListBranches.append(a);
606 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
609 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
610 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
611 a->setEnabled (false);
612 actionListBranches.append(a);
613 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
614 actionEditHeading2URL=a;
616 a = new QAction(tr( "Create URL to Bugzilla","Edit menu" ), this);
617 a->setStatusTip ( tr( "Create URL to Bugzilla" ));
618 a->setEnabled (false);
619 actionListBranches.append(a);
620 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
621 actionEditBugzilla2URL=a;
623 a = new QAction(tr( "Create URL to FATE","Edit menu" ), this);
624 a->setStatusTip ( tr( "Create URL to FATE" ));
625 a->setEnabled (false);
626 actionListBranches.append(a);
627 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
628 actionEditFATE2URL=a;
630 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
631 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
633 a->setEnabled (false);
634 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
635 actionEditOpenVymLink=a;
637 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
638 a->setStatusTip ( tr( "Open all vym links in subtree" ));
639 a->setEnabled (false);
640 actionListBranches.append(a);
641 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
642 actionEditOpenMultipleVymLinks=a;
645 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
646 a->setEnabled (false);
647 a->setStatusTip ( tr( "Edit link to another vym map" ));
648 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
649 actionListBranches.append(a);
652 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
653 a->setStatusTip ( tr( "Delete link to another vym map" ));
654 a->setEnabled (false);
655 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
656 actionEditDeleteVymLink=a;
658 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
659 a->setStatusTip ( tr( "Hide object in exports" ) );
660 a->setShortcut (Qt::Key_H );
661 a->setToggleAction(true);
663 a->setEnabled (false);
664 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
665 actionEditToggleHideExport=a;
667 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
668 a->setStatusTip ( tr( "Edit Map Info" ));
669 a->setEnabled (true);
670 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
673 // Import at selection (adding to selection)
674 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
675 a->setStatusTip (tr( "Add map at selection" ));
676 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
677 a->setEnabled (false);
678 actionListBranches.append(a);
679 actionEditImportAdd=a;
681 // Import at selection (replacing selection)
682 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
683 a->setStatusTip (tr( "Replace selection with map" ));
684 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
685 a->setEnabled (false);
686 actionListBranches.append(a);
687 actionEditImportReplace=a;
690 a = new QAction( tr( "Save selection","Edit menu" ), this);
691 a->setStatusTip (tr( "Save selection" ));
692 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
693 a->setEnabled (false);
694 actionListBranches.append(a);
695 actionEditSaveBranch=a;
697 // Only remove branch, not its childs
698 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
699 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
700 a->setShortcut (Qt::ALT + Qt::Key_Delete );
701 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChilds() ) );
702 a->setEnabled (false);
704 actionListBranches.append(a);
705 actionEditDeleteKeepChilds=a;
707 // Only remove childs of a branch
708 a = new QAction( tr( "Remove childs","Edit menu" ), this);
709 a->setStatusTip (tr( "Remove childs of branch" ));
710 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
711 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChilds() ) );
712 a->setEnabled (false);
713 actionListBranches.append(a);
714 actionEditDeleteChilds=a;
716 // Shortcuts for navigating with cursor:
717 a = new QAction(tr( "Select upper branch","Edit menu" ), this);
718 a->setStatusTip ( tr( "Select upper branch" ));
719 a->setShortcut (Qt::Key_Up );
720 a->setShortcutContext (Qt::WindowShortcut);
722 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
723 a = new QAction( tr( "Select lower branch","Edit menu" ),this);
724 a->setStatusTip (tr( "Select lower branch" ));
725 a->setShortcut ( Qt::Key_Down );
726 a->setShortcutContext (Qt::WindowShortcut);
728 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
729 a = new QAction(tr( "Select left branch","Edit menu" ), this);
730 a->setStatusTip ( tr( "Select left branch" ));
731 a->setShortcut (Qt::Key_Left );
732 a->setShortcutContext (Qt::WindowShortcut);
734 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
735 a = new QAction( tr( "Select child branch","Edit menu" ), this);
736 a->setStatusTip (tr( "Select right branch" ));
737 a->setShortcut (Qt::Key_Right);
738 a->setShortcutContext (Qt::WindowShortcut);
740 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
741 a = new QAction( tr( "Select first branch","Edit menu" ), this);
742 a->setStatusTip (tr( "Select first branch" ));
743 a->setShortcut (Qt::Key_Home );
744 a->setShortcutContext (Qt::WindowShortcut);
746 a->setEnabled (false);
747 editMenu->addAction (a);
748 actionListBranches.append(a);
749 actionEditSelectFirst=a;
750 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
751 a = new QAction( tr( "Select last branch","Edit menu" ),this);
752 a->setStatusTip (tr( "Select last branch" ));
753 a->setShortcut ( Qt::Key_End );
754 a->setShortcutContext (Qt::WindowShortcut);
756 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
757 a->setEnabled (false);
758 editMenu->addAction (a);
759 actionListBranches.append(a);
760 actionEditSelectLast=a;
762 a = new QAction( tr( "Add Image...","Edit menu" ), this);
763 a->setStatusTip (tr( "Add Image" ));
764 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
765 actionEditLoadImage=a;
770 void Main::setupFormatActions()
772 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
774 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
775 tb->setObjectName ("formatTB");
778 pix.fill (Qt::black);
779 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
780 a->setStatusTip ( tr( "Set Color" ));
781 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
783 formatMenu->addAction (a);
785 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
786 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
787 a->setShortcut (Qt::CTRL + Qt::Key_K );
788 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
789 a->setEnabled (false);
791 formatMenu->addAction (a);
792 actionListBranches.append(a);
793 actionFormatPickColor=a;
795 a= new QAction(QPixmap(iconPath+"formatcoloritem.png"), tr( "Color &branch","Edit menu" ), this);
796 a->setStatusTip ( tr( "Color branch" ) );
797 a->setShortcut (Qt::CTRL + Qt::Key_I);
798 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorItem() ) );
799 a->setEnabled (false);
801 formatMenu->addAction (a);
802 actionListBranches.append(a);
803 actionFormatColorBranch=a;
805 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color sub&tree","Edit menu" ), this);
806 a->setStatusTip ( tr( "Color Subtree" ));
807 a->setShortcut (Qt::CTRL + Qt::Key_T);
808 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
809 a->setEnabled (false);
810 formatMenu->addAction (a);
812 actionListBranches.append(a);
813 actionFormatColorSubtree=a;
815 formatMenu->addSeparator();
816 actionGroupFormatLinkStyles=new QActionGroup ( this);
817 actionGroupFormatLinkStyles->setExclusive (true);
818 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
819 a->setStatusTip (tr( "Line" ));
820 a->setToggleAction(true);
821 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
822 formatMenu->addAction (a);
823 actionFormatLinkStyleLine=a;
824 a= new QAction( tr( "Linkstyle Parabel" ), actionGroupFormatLinkStyles);
825 a->setStatusTip (tr( "Line" ));
826 a->setToggleAction(true);
827 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
828 formatMenu->addAction (a);
829 actionFormatLinkStyleParabel=a;
830 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
831 a->setStatusTip (tr( "PolyLine" ));
832 a->setToggleAction(true);
833 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
834 formatMenu->addAction (a);
835 actionFormatLinkStylePolyLine=a;
836 a= new QAction( tr( "Linkstyle Thick Parabel" ), actionGroupFormatLinkStyles);
837 a->setStatusTip (tr( "PolyParabel" ) );
838 a->setToggleAction(true);
839 a->setChecked (true);
840 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
841 formatMenu->addAction (a);
842 actionFormatLinkStylePolyParabel=a;
844 actionGroupFormatFrameTypes=new QActionGroup ( this);
845 actionGroupFormatFrameTypes->setExclusive (true);
846 a = new QAction( tr( "No Frame","Branch attribute" ), actionGroupFormatFrameTypes );
847 a->setStatusTip (tr("No Frame"));
848 a->setToggleAction(true);
849 connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameNone() ) );
850 actionFormatFrameNone=a;
851 a = new QAction( tr( "Rectangle""Branch attribute" ), actionGroupFormatFrameTypes);
852 a->setStatusTip (tr( "Rectangle" ));
853 a->setToggleAction(true);
854 connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameRectangle() ) );
855 actionFormatFrameRectangle=a;
857 a = new QAction( tr( "Include images vertically","Branch attribute" ), this);
858 a->setStatusTip ( tr ("Include top and bottom position of images into branch"));
859 a->setToggleAction(true);
860 connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesVer() ) );
861 actionFormatIncludeImagesVer=a;
863 a = new QAction( tr( "Include images horizontally","Branch attribute" ), this);
864 a->setStatusTip ( tr ("Include left and right position of images into branch"));
865 a->setToggleAction(true);
866 connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesHor() ) );
867 actionFormatIncludeImagesHor=a;
869 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
870 a->setStatusTip (tr( "Hide link" ));
871 a->setToggleAction(true);
872 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
873 actionFormatHideLinkUnselected=a;
875 formatMenu->addSeparator();
876 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
877 a->setStatusTip (tr( "Use same color for links and headings" ));
878 a->setToggleAction(true);
879 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
880 formatMenu->addAction (a);
881 actionFormatLinkColorHint=a;
883 pix.fill (Qt::white);
884 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
885 a->setStatusTip (tr( "Set Link Color" ));
886 formatMenu->addAction (a);
887 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
888 actionFormatLinkColor=a;
890 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
891 a->setStatusTip (tr( "Set Background Color" ));
892 formatMenu->addAction (a);
893 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
894 actionFormatBackColor=a;
896 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
897 a->setStatusTip (tr( "Set Background image" ));
898 formatMenu->addAction (a);
899 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
900 actionFormatBackImage=a;
904 void Main::setupViewActions()
906 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
907 tb->setLabel( "View Actions" );
908 tb->setObjectName ("viewTB");
909 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
912 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
913 a->setStatusTip ( tr( "Zoom reset" ) );
914 a->setShortcut (Qt::CTRL + Qt::Key_0 );
916 viewMenu->addAction (a);
917 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
919 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
920 a->setStatusTip (tr( "Zoom in" ));
921 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
923 viewMenu->addAction (a);
924 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
926 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
927 a->setStatusTip (tr( "Zoom out" ));
928 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
930 viewMenu->addAction (a);
931 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
934 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
935 a->setStatusTip ( tr( "Show Note Editor" ));
936 a->setShortcut ( Qt::CTRL + Qt::Key_E );
937 a->setToggleAction(true);
938 if (textEditor->showWithMain())
943 viewMenu->addAction (a);
944 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
945 actionViewToggleNoteEditor=a;
947 a = new QAction(QPixmap(iconPath+"history.png"), tr( "Show history window","View action" ),this );
948 a->setStatusTip ( tr( "Show history window" ));
949 a->setShortcut ( Qt::CTRL + Qt::Key_H );
950 a->setToggleAction(true);
952 viewMenu->addAction (a);
953 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
954 actionViewToggleHistoryWindow=a;
956 a = new QAction(tr( "Antialiasing","View action" ),this );
957 a->setStatusTip ( tr( "Antialiasing" ));
958 a->setToggleAction(true);
959 a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
960 viewMenu->addAction (a);
961 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
962 actionViewToggleAntiAlias=a;
964 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
965 a->setStatusTip (a->text());
966 a->setToggleAction(true);
967 a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
968 viewMenu->addAction (a);
969 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
970 actionViewToggleSmoothPixmapTransform=a;
972 a = new QAction(tr( "Next Window","View action" ), this);
973 a->setStatusTip (a->text());
974 a->setShortcut (Qt::ALT + Qt::Key_N );
975 viewMenu->addAction (a);
976 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
978 a = new QAction (tr( "Previous Window","View action" ), this );
979 a->setStatusTip (a->text());
980 a->setShortcut (Qt::ALT + Qt::Key_P );
981 viewMenu->addAction (a);
982 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
986 void Main::setupModeActions()
988 //QPopupMenu *menu = new QPopupMenu( this );
989 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
991 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
992 tb->setObjectName ("modesTB");
994 actionGroupModModes=new QActionGroup ( this);
995 actionGroupModModes->setExclusive (true);
996 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
997 a->setShortcut (Qt::Key_J);
998 a->setStatusTip ( tr( "Use modifier to color branches" ));
999 a->setToggleAction(true);
1002 actionModModeColor=a;
1004 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1005 a->setShortcut( Qt::Key_K);
1006 a->setStatusTip( tr( "Use modifier to copy" ));
1007 a->setToggleAction(true);
1009 actionModModeCopy=a;
1011 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1012 a->setShortcut (Qt::Key_L);
1013 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1014 a->setToggleAction(true);
1016 actionModModeXLink=a;
1020 void Main::setupFlagActions()
1022 // Create System Flags
1023 systemFlagsDefault = new FlagRowObj ();
1024 systemFlagsDefault->setVisibility (false);
1025 systemFlagsDefault->setName ("systemFlagsDef");
1027 FlagObj *fo = new FlagObj ();
1028 fo->load(QPixmap(flagsPath+"flag-note.png"));
1029 fo->setName("note");
1030 fo->setToolTip(tr("Note","Systemflag"));
1031 systemFlagsDefault->addFlag (fo); // makes deep copy
1033 fo->load(QPixmap(flagsPath+"flag-url.png"));
1035 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
1036 systemFlagsDefault->addFlag (fo);
1038 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1039 fo->setName("vymLink");
1040 fo->setToolTip(tr("Link to another vym map","Systemflag"));
1041 systemFlagsDefault->addFlag (fo);
1043 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1044 fo->setName("scrolledright");
1045 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
1046 systemFlagsDefault->addFlag (fo);
1048 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1049 fo->setName("tmpUnscrolledright");
1050 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
1051 systemFlagsDefault->addFlag (fo);
1053 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1054 fo->setName("hideInExport");
1055 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
1056 systemFlagsDefault->addFlag (fo);
1058 // Create Standard Flags
1059 QToolBar *tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1060 tb->setObjectName ("standardFlagTB");
1062 standardFlagsDefault = new FlagRowObj ();
1063 standardFlagsDefault->setVisibility (false);
1064 standardFlagsDefault->setName ("standardFlagsDef");
1065 standardFlagsDefault->setToolBar (tb);
1067 fo->load(flagsPath+"flag-exclamationmark.png");
1068 fo->setName ("exclamationmark");
1069 fo->setGroup("standard-mark");
1070 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1073 a->setCheckable(true);
1074 a->setObjectName(fo->getName());
1075 a->setToolTip(tr("Take care!","Standardflag"));
1076 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1077 standardFlagsDefault->addFlag (fo); // makes deep copy
1079 fo->load(flagsPath+"flag-questionmark.png");
1080 fo->setName("questionmark");
1081 fo->setGroup("standard-mark");
1082 a=new QAction (fo->getPixmap(),fo->getName(),this);
1085 a->setCheckable(true);
1086 a->setObjectName(fo->getName());
1087 a->setToolTip(tr("Really?","Standardflag"));
1088 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1089 standardFlagsDefault->addFlag (fo);
1091 fo->load(flagsPath+"flag-hook-green.png");
1092 fo->setName("hook-green");
1093 fo->setGroup("standard-hook");
1094 a=new QAction (fo->getPixmap(),fo->getName(),this);
1097 a->setCheckable(true);
1098 a->setObjectName(fo->getName());
1099 a->setToolTip(tr("ok!","Standardflag"));
1100 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1101 standardFlagsDefault->addFlag (fo);
1103 fo->load(flagsPath+"flag-cross-red.png");
1104 fo->setName("cross-red");
1105 fo->setGroup("standard-hook");
1106 a=new QAction (fo->getPixmap(),fo->getName(),this);
1109 a->setCheckable(true);
1110 a->setObjectName(fo->getName());
1111 a->setToolTip(tr("Not ok!","Standardflag"));
1112 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1113 standardFlagsDefault->addFlag (fo);
1115 fo->load(flagsPath+"flag-stopsign.png");
1116 fo->setName("stopsign");
1117 a=new QAction (fo->getPixmap(),fo->getName(),this);
1120 a->setCheckable(true);
1121 a->setObjectName(fo->getName());
1122 a->setToolTip(tr("This won't work!","Standardflag"));
1123 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1124 standardFlagsDefault->addFlag (fo);
1126 fo->load(flagsPath+"flag-smiley-good.png");
1127 fo->setName("smiley-good");
1128 fo->setGroup("standard-smiley");
1129 a=new QAction (fo->getPixmap(),fo->getName(),this);
1132 a->setCheckable(true);
1133 a->setObjectName(fo->getName());
1134 a->setToolTip(tr("Good","Standardflag"));
1135 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1136 standardFlagsDefault->addFlag (fo);
1138 fo->load(flagsPath+"flag-smiley-sad.png");
1139 fo->setName("smiley-sad");
1140 fo->setGroup("standard-smiley");
1141 a=new QAction (fo->getPixmap(),fo->getName(),this);
1144 a->setCheckable(true);
1145 a->setObjectName(fo->getName());
1146 a->setToolTip(tr("Bad","Standardflag"));
1147 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1148 standardFlagsDefault->addFlag (fo);
1150 fo->load(flagsPath+"flag-smiley-omg.png");
1151 // Original omg.png (in KDE emoticons)
1152 fo->setName("smiley-omg");
1153 fo->setGroup("standard-smiley");
1154 a=new QAction (fo->getPixmap(),fo->getName(),this);
1157 a->setCheckable(true);
1158 a->setObjectName(fo->getName());
1159 a->setToolTip(tr("Oh no!","Standardflag"));
1160 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1161 standardFlagsDefault->addFlag (fo);
1163 fo->load(flagsPath+"flag-kalarm.png");
1164 fo->setName("clock");
1165 a=new QAction (fo->getPixmap(),fo->getName(),this);
1168 a->setCheckable(true);
1169 a->setObjectName(fo->getName());
1170 a->setToolTip(tr("Time critical","Standardflag"));
1171 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1172 standardFlagsDefault->addFlag (fo);
1174 fo->load(flagsPath+"flag-phone.png");
1175 fo->setName("phone");
1176 a=new QAction (fo->getPixmap(),fo->getName(),this);
1179 a->setCheckable(true);
1180 a->setObjectName(fo->getName());
1181 a->setToolTip(tr("Call...","Standardflag"));
1182 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1183 standardFlagsDefault->addFlag (fo);
1185 fo->load(flagsPath+"flag-lamp.png");
1186 fo->setName("lamp");
1187 a=new QAction (fo->getPixmap(),fo->getName(),this);
1190 a->setCheckable(true);
1191 a->setObjectName(fo->getName());
1192 a->setToolTip(tr("Idea!","Standardflag"));
1193 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1194 standardFlagsDefault->addFlag (fo);
1196 fo->load(flagsPath+"flag-arrow-up.png");
1197 fo->setName("arrow-up");
1198 fo->setGroup("standard-arrow");
1199 a=new QAction (fo->getPixmap(),fo->getName(),this);
1202 a->setCheckable(true);
1203 a->setObjectName(fo->getName());
1204 a->setToolTip(tr("Important","Standardflag"));
1205 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1206 standardFlagsDefault->addFlag (fo);
1208 fo->load(flagsPath+"flag-arrow-down.png");
1209 fo->setName("arrow-down");
1210 fo->setGroup("standard-arrow");
1211 a=new QAction (fo->getPixmap(),fo->getName(),this);
1214 a->setCheckable(true);
1215 a->setObjectName(fo->getName());
1216 a->setToolTip(tr("Unimportant","Standardflag"));
1217 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1218 standardFlagsDefault->addFlag (fo);
1220 fo->load(flagsPath+"flag-arrow-2up.png");
1221 fo->setName("2arrow-up");
1222 fo->setGroup("standard-arrow");
1223 a=new QAction (fo->getPixmap(),fo->getName(),this);
1226 a->setCheckable(true);
1227 a->setObjectName(fo->getName());
1228 a->setToolTip(tr("Very important!","Standardflag"));
1229 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1230 standardFlagsDefault->addFlag (fo);
1232 fo->load(flagsPath+"flag-arrow-2down.png");
1233 fo->setName("2arrow-down");
1234 fo->setGroup("standard-arrow");
1235 a=new QAction (fo->getPixmap(),fo->getName(),this);
1238 a->setCheckable(true);
1239 a->setObjectName(fo->getName());
1240 a->setToolTip(tr("Very unimportant!","Standardflag"));
1241 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1242 standardFlagsDefault->addFlag (fo);
1244 fo->load(flagsPath+"flag-thumb-up.png");
1245 fo->setName("thumb-up");
1246 fo->setGroup("standard-thumb");
1247 a=new QAction (fo->getPixmap(),fo->getName(),this);
1250 a->setCheckable(true);
1251 a->setObjectName(fo->getName());
1252 a->setToolTip(tr("I like this","Standardflag"));
1253 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1254 standardFlagsDefault->addFlag (fo);
1256 fo->load(flagsPath+"flag-thumb-down.png");
1257 fo->setName("thumb-down");
1258 fo->setGroup("standard-thumb");
1259 a=new QAction (fo->getPixmap(),fo->getName(),this);
1262 a->setCheckable(true);
1263 a->setObjectName(fo->getName());
1264 a->setToolTip(tr("I do not like this","Standardflag"));
1265 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1266 standardFlagsDefault->addFlag (fo);
1268 fo->load(flagsPath+"flag-rose.png");
1269 fo->setName("rose");
1270 a=new QAction (fo->getPixmap(),fo->getName(),this);
1273 a->setCheckable(true);
1274 a->setObjectName(fo->getName());
1275 a->setToolTip(tr("Rose","Standardflag"));
1276 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1277 standardFlagsDefault->addFlag (fo);
1279 fo->load(flagsPath+"flag-heart.png");
1280 fo->setName("heart");
1281 a=new QAction (fo->getPixmap(),fo->getName(),this);
1283 a->setCheckable(true);
1284 a->setObjectName(fo->getName());
1285 a->setToolTip(tr("I just love... ","Standardflag"));
1286 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1287 standardFlagsDefault->addFlag (fo);
1289 fo->load(flagsPath+"flag-present.png");
1290 fo->setName("present");
1291 a=new QAction (fo->getPixmap(),fo->getName(),this);
1294 a->setCheckable(true);
1295 a->setObjectName(fo->getName());
1296 a->setToolTip(tr("Surprise!","Standardflag"));
1297 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1298 standardFlagsDefault->addFlag (fo);
1300 fo->load(flagsPath+"flag-flash.png");
1301 fo->setName("flash");
1302 a=new QAction (fo->getPixmap(),fo->getName(),this);
1305 a->setCheckable(true);
1306 a->setObjectName(fo->getName());
1307 a->setToolTip(tr("Dangerous","Standardflag"));
1308 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1309 standardFlagsDefault->addFlag (fo);
1311 fo->load(flagsPath+"flag-info.png");
1312 // Original: xsldbg_output.png
1313 fo->setName("info");
1314 a=new QAction (fo->getPixmap(),fo->getName(),this);
1317 a->setCheckable(true);
1318 a->setObjectName(fo->getName());
1319 a->setToolTip(tr("Info","Standardflag"));
1320 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1321 standardFlagsDefault->addFlag (fo);
1323 fo->load(flagsPath+"flag-lifebelt.png");
1324 // Original khelpcenter.png
1325 fo->setName("lifebelt");
1326 a=new QAction (fo->getPixmap(),fo->getName(),this);
1329 a->setCheckable(true);
1330 a->setObjectName(fo->getName());
1331 a->setToolTip(tr("This will help","Standardflag"));
1332 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1333 standardFlagsDefault->addFlag (fo);
1339 void Main::setupSettingsActions()
1341 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1345 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1346 a->setStatusTip ( tr( "Set application to open pdf files"));
1347 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1348 settingsMenu->addAction (a);
1350 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1351 a->setStatusTip( tr( "Set application to open external links"));
1352 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1353 settingsMenu->addAction (a);
1355 settingsMenu->addSeparator();
1356 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1357 a->setStatusTip( tr( "Edit branch after adding it" ));
1358 a->setToggleAction(true);
1359 a->setOn ( settings.value ("/mapeditor/editmode/autoEdit",true).toBool());
1360 settingsMenu->addAction (a);
1361 actionSettingsAutoEdit=a;
1363 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1364 a->setStatusTip( tr( "Select branch after adding it" ));
1365 a->setToggleAction(true);
1366 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectHeading",false).toBool() );
1367 settingsMenu->addAction (a);
1368 actionSettingsAutoSelectHeading=a;
1370 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1371 a->setStatusTip( tr( "Select heading before editing" ));
1372 a->setToggleAction(true);
1373 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1374 settingsMenu->addAction (a);
1375 actionSettingsAutoSelectText=a;
1377 a= new QAction( tr( "Delete key","Settings action" ), this);
1378 a->setStatusTip( tr( "Delete key for deleting branches" ));
1379 a->setToggleAction(true);
1380 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",false).toBool() );
1381 settingsMenu->addAction (a);
1382 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1383 actionSettingsUseDelKey=a;
1385 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1386 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1387 a->setToggleAction(true);
1388 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1389 settingsMenu->addAction (a);
1390 actionSettingsUseFlagGroups=a;
1392 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1393 a->setStatusTip( tr( "Use hide flag during exports " ));
1394 a->setToggleAction(true);
1395 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1396 settingsMenu->addAction (a);
1397 actionSettingsUseHideExport=a;
1401 void Main::setupTestActions()
1403 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1406 a = new QAction( "Test function" , this);
1407 a->setStatusTip( "Call test function" );
1408 a->setShortcut (Qt::Key_F4 );
1409 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction() ) );
1410 testMenu->addAction (a);
1411 a = new QAction( "Command" , this);
1412 a->setStatusTip( "Enter command to call in editor" );
1413 a->setShortcut (Qt::Key_F5 );
1414 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1415 testMenu->addAction (a);
1419 void Main::setupHelpActions()
1421 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1424 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1425 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1426 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1427 helpMenu->addAction (a);
1429 a = new QAction( tr( "About VYM","Help action" ), this);
1430 a->setStatusTip( tr( "About VYM")+vymName);
1431 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1432 helpMenu->addAction (a);
1434 a = new QAction( tr( "About QT","Help action" ), this);
1435 a->setStatusTip( tr( "Information about QT toolkit" ));
1436 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1437 helpMenu->addAction (a);
1441 void Main::setupContextMenus()
1445 // Context Menu for branch or mapcenter
1446 branchContextMenu =new QMenu (this);
1449 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1450 branchAddContextMenu->addAction (actionEditPaste );
1451 branchAddContextMenu->addAction ( actionEditAddBranch );
1452 branchAddContextMenu->addAction ( actionEditAddBranchBefore );
1453 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1454 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1455 branchAddContextMenu->addSeparator();
1456 branchAddContextMenu->addAction ( actionEditImportAdd );
1457 branchAddContextMenu->addAction ( actionEditImportReplace );
1460 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1461 branchRemoveContextMenu->addAction (actionEditCut);
1462 branchRemoveContextMenu->addAction ( actionEditDelete );
1463 branchRemoveContextMenu->addAction ( actionEditDeleteKeepChilds );
1464 branchRemoveContextMenu->addAction ( actionEditDeleteChilds );
1467 actionEditSaveBranch->addTo( branchContextMenu );
1469 branchContextMenu->addSeparator();
1470 branchContextMenu->addAction ( actionFormatFrameNone );
1471 branchContextMenu->addAction ( actionFormatFrameRectangle);
1472 branchContextMenu->addAction ( actionFormatHideLinkUnselected );
1474 branchContextMenu->addSeparator();
1475 branchContextMenu->addAction ( actionEditLoadImage);
1476 branchContextMenu->addAction ( actionFormatIncludeImagesVer );
1477 branchContextMenu->addAction ( actionFormatIncludeImagesHor );
1479 // Submenu for Links (URLs, vymLinks)
1480 branchLinksContextMenu =new QMenu (this);
1482 branchContextMenu->addSeparator();
1483 branchLinksContextMenu=branchContextMenu->addMenu(tr("URLs and vymLinks","Context menu name"));
1484 branchLinksContextMenu->addAction ( actionEditOpenURL );
1485 branchLinksContextMenu->addAction ( actionEditOpenURLTab );
1486 branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
1487 branchLinksContextMenu->addAction ( actionEditURL );
1488 branchLinksContextMenu->addAction ( actionEditHeading2URL );
1489 branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
1490 if (settings.value( "/mainwindow/showTestMenu",true).toBool() )
1492 branchLinksContextMenu->addAction ( actionEditFATE2URL );
1494 branchLinksContextMenu->addSeparator();
1495 branchLinksContextMenu->addAction ( actionEditOpenVymLink );
1496 branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
1497 branchLinksContextMenu->addAction ( actionEditVymLink );
1498 branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
1501 // Context Menu for XLinks in a branch menu
1502 // This will be populated "on demand" in MapEditor::updateActions
1503 branchContextMenu->addSeparator();
1504 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1505 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1506 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1507 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1510 // Context menu for floatimage
1511 floatimageContextMenu =new QMenu (this);
1512 a= new QAction (tr ("Save image","Context action"),this);
1513 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1514 floatimageContextMenu->addAction (a);
1516 floatimageContextMenu->addSeparator();
1517 actionEditCopy->addTo( floatimageContextMenu );
1518 actionEditCut->addTo( floatimageContextMenu );
1520 floatimageContextMenu->addSeparator();
1521 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1524 // Context menu for canvas
1525 canvasContextMenu =new QMenu (this);
1526 actionEditMapInfo->addTo( canvasContextMenu );
1527 canvasContextMenu->insertSeparator();
1528 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1529 canvasContextMenu->insertSeparator();
1530 actionFormatLinkColorHint->addTo( canvasContextMenu );
1531 actionFormatLinkColor->addTo( canvasContextMenu );
1532 actionFormatBackColor->addTo( canvasContextMenu );
1533 actionFormatBackImage->addTo( canvasContextMenu );
1535 // Menu for last opened files
1537 for (int i = 0; i < MaxRecentFiles; ++i)
1539 recentFileActs[i] = new QAction(this);
1540 recentFileActs[i]->setVisible(false);
1541 fileLastMapsMenu->addAction(recentFileActs[i]);
1542 connect(recentFileActs[i], SIGNAL(triggered()),
1543 this, SLOT(fileLoadRecent()));
1545 setupRecentMapsMenu();
1548 void Main::setupRecentMapsMenu()
1550 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1552 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1554 for (int i = 0; i < numRecentFiles; ++i) {
1555 //QString text = tr("&%1 %2").arg(i + 1).arg(strippedName(files[i]));
1556 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1557 recentFileActs[i]->setText(text);
1558 recentFileActs[i]->setData(files[i]);
1559 recentFileActs[i]->setVisible(true);
1561 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1562 recentFileActs[j]->setVisible(false);
1565 void Main::hideEvent (QHideEvent * )
1567 if (!textEditor->isMinimized() ) textEditor->hide();
1570 void Main::showEvent (QShowEvent * )
1572 if (textEditor->showWithMain()) textEditor->showNormal();
1575 bool Main::reallyWriteDirectory(const QString &dir)
1577 QStringList eList = QDir(dir).entryList();
1578 if (eList.first() ==".") eList.pop_front(); // remove "."
1579 if (eList.first() =="..") eList.pop_front(); // remove "."
1580 if (!eList.isEmpty())
1582 QMessageBox mb( vymName,
1583 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?","write directory").arg(dir),
1584 QMessageBox::Warning,
1586 QMessageBox::Cancel | QMessageBox::Default,
1587 QMessageBox::QMessageBox::NoButton );
1589 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1590 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1593 case QMessageBox::Yes:
1596 case QMessageBox::Cancel:
1604 QString Main::browseDirectory (const QString &caption)
1606 QFileDialog fd(this,caption);
1607 fd.setMode (QFileDialog::DirectoryOnly);
1608 fd.setCaption(vymName+ " - "+caption);
1611 if ( fd.exec() == QDialog::Accepted )
1612 return fd.selectedFile();
1617 MapEditor* Main::currentMapEditor() const
1619 if ( tabWidget->currentPage() &&
1620 tabWidget->currentPage()->inherits( "MapEditor" ) )
1621 return (MapEditor*)tabWidget->currentPage();
1626 void Main::editorChanged(QWidget *)
1628 // Unselect all possibly selected objects
1629 // (Important to update note editor)
1632 for (i=0;i<=tabWidget->count() -1;i++)
1635 me=(MapEditor*)tabWidget->page(i);
1638 currentMapEditor()->reselect();
1640 // Update actions to in menus and toolbars according to editor
1644 void Main::fileNew()
1646 QString fn="unnamed";
1647 MapEditor* me = new MapEditor ( NULL);
1648 tabWidget->addTab (me,fn);
1649 tabWidget->showPage(me);
1650 me->viewport()->setFocus();
1651 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1652 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1654 // For the very first map we do not have flagrows yet...
1658 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1660 ErrorCode err=success;
1662 // fn is usually the archive, mapfile the file after uncompressing
1665 // Make fn absolute (needed for unzip)
1666 fn=QDir (fn).absPath();
1672 // Check, if map is already loaded
1674 while (i<=tabWidget->count() -1)
1676 me=(MapEditor*)tabWidget->page(i);
1677 if (me->getFilePath() == fn)
1679 // Already there, ask for confirmation
1680 QMessageBox mb( vymName,
1681 tr("The map %1\nis already opened."
1682 "Opening the same map in multiple editors may lead \n"
1683 "to confusion when finishing working with vym."
1684 "Do you want to").arg(fn),
1685 QMessageBox::Warning,
1686 QMessageBox::Yes | QMessageBox::Default,
1687 QMessageBox::Cancel | QMessageBox::Escape,
1688 QMessageBox::NoButton);
1689 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1690 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1693 case QMessageBox::Yes:
1695 i=tabWidget->count();
1697 case QMessageBox::Cancel:
1709 if ( !fn.isEmpty() )
1711 me = currentMapEditor();
1712 int tabIndex=tabWidget->currentPageIndex();
1713 // Check first, if mapeditor exists
1714 // If it is not default AND we want a new map,
1715 // create a new mapeditor in a new tab
1716 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1718 me= new MapEditor ( NULL);
1719 tabWidget->addTab (me,fn);
1720 tabIndex=tabWidget->indexOf (me);
1721 tabWidget->setCurrentPage (tabIndex);
1722 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1723 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1726 // Check, if file exists (important for creating new files
1727 // from command line
1728 if (!QFile(fn).exists() )
1730 QMessageBox mb( vymName,
1731 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1732 QMessageBox::Question,
1734 QMessageBox::Cancel | QMessageBox::Default,
1735 QMessageBox::NoButton );
1737 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1738 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1741 case QMessageBox::Yes:
1743 currentMapEditor()->setFilePath(fn);
1744 tabWidget->setTabLabel (currentMapEditor(),
1745 currentMapEditor()->getFileName() );
1746 statusBar()->message( "Created " + fn , statusbarTime );
1749 case QMessageBox::Cancel:
1750 // don't create new map
1751 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1758 //tabWidget->currentPage() won't be NULL here, because of above...
1759 tabWidget->showPage(me);
1760 me->viewport()->setFocus();
1762 // Create temporary directory for packing
1764 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
1767 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1768 tr("Couldn't create temporary directory before load\n"));
1772 // Try to unzip file
1773 err=unzipDir (tmpMapDir,fn);
1777 me->setZipped(false);
1780 me->setZipped(true);
1782 // Look for mapname.xml
1783 mapfile= fn.left(fn.findRev(".",-1,true));
1784 mapfile=mapfile.section( '/', -1 );
1785 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1786 if (!file.exists() )
1788 // mapname.xml does not exist, well,
1789 // maybe some renamed the mapname.vym file...
1790 // Try to find any .xml in the toplevel
1791 // directory of the .vym file
1792 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1793 if (flist.count()==1)
1795 // Only one entry, take this one
1796 mapfile=tmpMapDir + "/"+flist.first();
1799 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1800 *it=tmpMapDir + "/" + *it;
1801 // TODO Multiple entries, load all (but only the first one into this ME)
1802 //mainWindow->fileLoadFromTmp (flist);
1803 //returnCode=1; // Silently forget this attempt to load
1804 qWarning ("MainWindow::load (fn) multimap found...");
1807 if (flist.isEmpty() )
1809 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1810 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1813 } //file doesn't exist
1815 mapfile=file.name();
1820 // Save existing filename in case we import
1821 QString fn_org=me->getFilePath();
1823 // Finally load map into mapEditor
1824 me->setFilePath (mapfile,fn);
1825 err=me->load(mapfile,lmode);
1827 // Restore old (maybe empty) filepath, if this is an import
1829 me->setFilePath (fn_org);
1832 // Finally check for errors and go home
1835 if (lmode==NewMap) fileCloseMap();
1836 statusBar()->message( "Could not load " + fn, statusbarTime );
1841 me->setFilePath (fn);
1842 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1843 if (fn.left(9)!="/tmp/vym-")
1845 // Only append to lastMaps if not loaded from a tmpDir
1846 // e.g. imported bookmarks are in a tmpDir
1847 addRecentMap(me->getFilePath() );
1849 actionFilePrint->setEnabled (true);
1851 statusBar()->message( "Loaded " + fn, statusbarTime );
1855 removeDir (QDir(tmpMapDir));
1861 void Main::fileLoad(const LoadMode &lmode)
1863 QStringList filters;
1864 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1865 QFileDialog *fd=new QFileDialog( this);
1866 fd->setDir (lastFileDir);
1867 fd->setFileMode (QFileDialog::ExistingFiles);
1868 fd->setFilters (filters);
1872 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1875 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1878 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1884 if ( fd->exec() == QDialog::Accepted )
1886 lastFileDir=fd->directory().path();
1887 QStringList flist = fd->selectedFiles();
1888 QStringList::Iterator it = flist.begin();
1889 while( it != flist.end() )
1892 fileLoad(*it, lmode);
1899 void Main::fileLoad()
1904 void Main::fileLoadRecent()
1906 QAction *action = qobject_cast<QAction *>(sender());
1908 fileLoad (action->data().toString(), NewMap);
1911 void Main::addRecentMap (const QString &fileName)
1914 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1915 files.removeAll(fileName);
1916 files.prepend(fileName);
1917 while (files.size() > MaxRecentFiles)
1920 settings.setValue("/mainwindow/recentFileList", files);
1922 setupRecentMapsMenu();
1925 void Main::fileSave(const SaveMode &savemode)
1927 // tmp dir for zipping
1931 ErrorCode err=success;
1933 QString safeFilePath;
1935 bool saveZipped=currentMapEditor()->saveZipped();
1937 MapEditor * me=currentMapEditor();
1940 QString fn=me->getFilePath();
1941 // filename=unnamed, filepath="" in constructor...
1942 if ( !fn.isEmpty() )
1944 // We have a filepath, go on saving
1945 // First remove existing file, we
1946 // don't want to add to old zip archives
1950 QMessageBox::warning( 0, tr( "Save Error" ),
1951 fn+ tr("\ncould not be removed before saving"));
1953 // Look, if we should zip the data:
1956 QMessageBox mb( vymName,
1957 tr("The map %1\ndid not use the compressed "
1958 "vym file format.\nWriting it uncompressed will also write images \n"
1959 "and flags and thus may overwrite files in the "
1960 "given directory\n\nDo you want to write the map").arg(fn),
1961 QMessageBox::Warning,
1962 QMessageBox::Yes | QMessageBox::Default,
1964 QMessageBox::Cancel | QMessageBox::Escape);
1965 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
1966 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
1967 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1970 case QMessageBox::Yes:
1971 // save compressed (default file format)
1974 case QMessageBox::No:
1975 // save uncompressed
1978 case QMessageBox::Cancel:
1987 // Create temporary directory for packing
1989 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
1992 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1993 tr("Couldn't create temporary directory before save\n"));
1997 safeFilePath=me->getFilePath();
1998 me->setFilePath (tmpMapDir+"/"+
1999 me->getMapName()+ ".xml",
2001 me->save (savemode);
2002 me->setFilePath (safeFilePath);
2004 zipDir (tmpMapDir,fn);
2009 safeFilePath=me->getFilePath();
2010 me->setFilePath (fn, safeFilePath);
2011 me->save (savemode);
2012 me->setFilePath (safeFilePath);
2014 } // filepath available
2017 // We have no filepath yet,
2018 // call fileSaveAs() now, this will call fileSave()
2020 fileSaveAs(savemode);
2024 if (saveZipped && !tmpMapDir.isEmpty())
2026 removeDir (QDir(tmpMapDir));
2030 statusBar()->message(
2031 tr("Saved %1").arg(me->getFilePath()),
2033 addRecentMap (me->getFilePath() );
2035 statusBar()->message(
2036 tr("Couldn't save ").arg(me->getFilePath()),
2040 void Main::fileSave()
2042 fileSave (CompleteMap);
2045 void Main::fileSaveAs(const SaveMode& savemode)
2049 if (currentMapEditor())
2051 if (savemode==CompleteMap)
2052 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2054 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2055 if ( !fn.isEmpty() )
2057 // Check for existing file
2058 if (QFile (fn).exists())
2060 QMessageBox mb( vymName,
2061 tr("The file %1\nexists already. Do you want to").arg(fn),
2062 QMessageBox::Warning,
2063 QMessageBox::Yes | QMessageBox::Default,
2064 QMessageBox::Cancel | QMessageBox::Escape,
2065 QMessageBox::NoButton);
2066 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2067 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2070 case QMessageBox::Yes:
2073 case QMessageBox::Cancel:
2080 // New file, add extension to filename, if missing
2081 // This is always .vym or .vyp, depending on savemode
2082 if (savemode==CompleteMap)
2084 if (!fn.contains (".vym") && !fn.contains (".xml"))
2088 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2097 currentMapEditor()->setFilePath(fn);
2101 if (savemode==CompleteMap)
2102 tabWidget->setTabLabel (currentMapEditor(),
2103 currentMapEditor()->getFileName() );
2109 void Main::fileSaveAs()
2111 fileSaveAs (CompleteMap);
2114 void Main::fileImportKDEBookmarks()
2116 ImportKDEBookmarks im;
2118 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2119 currentMapEditor()->setFilePath ("");
2122 void Main::fileImportFirefoxBookmarks()
2124 Q3FileDialog *fd=new Q3FileDialog( this);
2125 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2126 fd->setMode (Q3FileDialog::ExistingFiles);
2127 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2128 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2131 if ( fd->exec() == QDialog::Accepted )
2133 ImportFirefoxBookmarks im;
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 ("");
2149 void Main::fileImportMM()
2153 Q3FileDialog *fd=new Q3FileDialog( this);
2154 fd->setDir (lastFileDir);
2155 fd->setMode (Q3FileDialog::ExistingFiles);
2156 fd->addFilter ("Mind Manager (*.mmap)");
2157 fd->setCaption(tr("Import")+" "+"Mind Manager");
2160 if ( fd->exec() == QDialog::Accepted )
2162 lastFileDir=fd->dirPath();
2163 QStringList flist = fd->selectedFiles();
2164 QStringList::Iterator it = flist.begin();
2165 while( it != flist.end() )
2168 if (im.transform() &&
2169 success==fileLoad (im.getTransformedFile(),NewMap) &&
2170 currentMapEditor() )
2171 currentMapEditor()->setFilePath ("");
2180 void Main::fileImportDir()
2182 if (currentMapEditor())
2183 currentMapEditor()->importDir();
2186 void Main::fileExportXML()
2188 if (currentMapEditor())
2190 QString dir=browseDirectory(tr("Export XML to directory"));
2191 if (dir !="" && reallyWriteDirectory(dir) )
2192 currentMapEditor()->exportXML(dir);
2197 void Main::fileExportXHTML()
2199 MapEditor *me=currentMapEditor();
2203 ExportXHTMLDialog dia(this);
2204 dia.setFilePath (me->getFilePath() );
2205 dia.setMapName (me->getMapName() );
2208 if (dia.exec()==QDialog::Accepted)
2210 QString dir=dia.getDir();
2211 // Check, if warnings should be used before overwriting
2212 // the output directory
2215 ok=reallyWriteDirectory(dir);
2221 me->exportXML (dia.getDir() );
2222 dia.doExport(me->getMapName() );
2223 if (dia.hasChanged())
2230 void Main::fileExportImage()
2232 MapEditor *me=currentMapEditor();
2236 QFileDialog *fd=new QFileDialog (this);
2237 fd->setCaption (tr("Export map as image"));
2238 fd->setFileMode(QFileDialog::AnyFile);
2239 fd->setFilters (imageIO.getFilters() );
2240 fd->setDirectory (lastImageDir);
2243 fl=fd->selectedFiles();
2244 qWarning ("Selected "+fl.first()+" filter: "+fd->selectedFilter());
2245 me->exportImage (fl.first(), imageIO.getType (fd->selectedFilter() ) );
2250 void Main::fileExportASCII()
2252 MapEditor *me=currentMapEditor();
2256 ex.setMapCenter(me->getMapCenter());
2257 ex.addFilter ("TXT (*.txt)");
2258 ex.setCaption(vymName+ " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
2259 if (ex.execDialog() )
2261 me->setExportMode(true);
2263 me->setExportMode(false);
2268 void Main::fileExportLaTeX()
2270 MapEditor *me=currentMapEditor();
2274 ex.setMapCenter(me->getMapCenter());
2275 ex.addFilter ("Tex (*.tex)");
2276 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2277 if (ex.execDialog() )
2279 me->setExportMode(true);
2281 me->setExportMode(false);
2286 void Main::fileExportKDEBookmarks()
2288 ExportKDEBookmarks ex;
2289 MapEditor *me=currentMapEditor();
2292 ex.setMapCenter (me->getMapCenter() );
2297 void Main::fileExportTaskjuggler()
2299 ExportTaskjuggler ex;
2300 MapEditor *me=currentMapEditor();
2303 ex.setMapCenter (me->getMapCenter() );
2304 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2305 ex.addFilter ("Taskjuggler (*.tjp)");
2306 if (ex.execDialog() )
2308 me->setExportMode(true);
2310 me->setExportMode(false);
2315 void Main::fileExportOOPresentation()
2317 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2318 // TODO add preview in dialog
2319 //ImagePreview *p =new ImagePreview (fd);
2320 //fd->setContentsPreviewEnabled( TRUE );
2321 //fd->setContentsPreview( p, p );
2322 //fd->setPreviewMode( QFileDialog::Contents );
2323 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2324 fd->setDir (QDir().current());
2325 if (fd->foundConfig())
2329 if ( fd->exec() == QDialog::Accepted )
2331 QString fn=fd->selectedFile();
2332 if (!fn.contains (".odp"))
2335 //lastImageDir=fn.left(fn.findRev ("/"));
2336 if (currentMapEditor())
2337 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2341 QMessageBox::warning(0,
2343 tr("Couldn't find configuration for export to Open Office\n"));
2347 void Main::fileCloseMap()
2349 if (currentMapEditor())
2351 if (currentMapEditor()->hasChanged())
2353 QMessageBox mb( vymName,
2354 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2355 QMessageBox::Warning,
2356 QMessageBox::Yes | QMessageBox::Default,
2358 QMessageBox::Cancel | QMessageBox::Escape );
2359 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2360 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2363 case QMessageBox::Yes:
2365 fileSave(CompleteMap);
2367 case QMessageBox::No:
2368 // close without saving
2370 case QMessageBox::Cancel:
2375 currentMapEditor()->closeMap();
2376 tabWidget->removePage(currentMapEditor());
2377 if (tabWidget->count()==0)
2378 actionFilePrint->setEnabled (false);
2382 void Main::filePrint()
2384 if (currentMapEditor())
2385 currentMapEditor()->print();
2388 void Main::fileExitVYM()
2390 // Check if one or more editors have changed
2393 for (i=0;i<=tabWidget->count() -1;i++)
2396 me=(MapEditor*)tabWidget->page(i);
2398 // If something changed, ask what to do
2399 if (me->isUnsaved())
2401 tabWidget->setCurrentPage(i);
2402 QMessageBox mb( vymName,
2403 tr("This map is not saved yet. Do you want to"),
2404 QMessageBox::Warning,
2405 QMessageBox::Yes | QMessageBox::Default,
2407 QMessageBox::Cancel | QMessageBox::Escape );
2408 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2409 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2412 mb.setActiveWindow();
2413 switch( mb.exec() ) {
2414 case QMessageBox::Yes:
2415 // save (the changed editors) and exit
2416 fileSave(CompleteMap);
2418 case QMessageBox::No:
2419 // exit without saving
2421 case QMessageBox::Cancel:
2422 // don't save and don't exit
2426 } // loop over all MEs
2430 void Main::editUndo()
2432 if (currentMapEditor())
2433 currentMapEditor()->undo();
2436 void Main::editRedo()
2438 if (currentMapEditor())
2439 currentMapEditor()->redo();
2442 void Main::gotoHistoryStep (int i)
2444 if (currentMapEditor())
2445 currentMapEditor()->gotoHistoryStep (i);
2448 void Main::editCopy()
2450 if (currentMapEditor())
2451 currentMapEditor()->copy();
2454 void Main::editPaste()
2456 if (currentMapEditor())
2457 currentMapEditor()->paste();
2460 void Main::editCut()
2462 if (currentMapEditor())
2463 currentMapEditor()->cut();
2466 void Main::editOpenFindWindow()
2468 findWindow->popup();
2469 findWindow->raise();
2470 findWindow->setActiveWindow();
2473 void Main::editFind(QString s)
2476 BranchObj *bo=currentMapEditor()->findText(s, cs);
2479 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2482 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2483 tr("No matches found for \"%1\"").arg(s));
2487 void Main::editFindChanged()
2488 { // Notify editor, to abort the current find process
2489 currentMapEditor()->findReset();
2492 void Main::openTabs(QStringList urls)
2494 if (!urls.isEmpty())
2498 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2500 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2502 QString u=urls.takeFirst();
2503 procBrowser = new QProcess( this );
2505 procBrowser->start(browser,args);
2506 if ( !procBrowser->waitForStarted())
2508 // try to set path to browser
2509 QMessageBox::warning(0,
2511 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2512 tr("Please use Settings->")+tr("Set application to open an URL"));
2517 if (browser.contains("konqueror"))
2519 for (int i=0; i<urls.size(); i++)
2522 // Try to open new tab in existing konqueror started previously by vym
2523 p=new QProcess (this);
2525 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2526 "konqueror-mainwindow#1"<<
2529 p->start ("dcop",args);
2530 if ( !p->waitForStarted() ) success=false;
2533 QMessageBox::warning(0,
2535 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2537 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2539 for (int i=0; i<urls.size(); i++)
2541 // Try to open new tab in firefox
2542 p=new QProcess (this);
2543 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2544 p->start (browser,args);
2545 if ( !p->waitForStarted() ) success=false;
2548 QMessageBox::warning(0,
2550 tr("Couldn't start %1 to open a new tab").arg(browser));
2553 QMessageBox::warning(0,
2555 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2559 void Main::editOpenURL()
2562 if (currentMapEditor())
2564 QString url=currentMapEditor()->getURL();
2566 if (url=="") return;
2567 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2568 procBrowser = new QProcess( this );
2570 procBrowser->start(browser,args);
2571 if ( !procBrowser->waitForStarted())
2573 // try to set path to browser
2574 QMessageBox::warning(0,
2576 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2577 tr("Please use Settings->")+tr("Set application to open an URL"));
2582 void Main::editOpenURLTab()
2584 if (currentMapEditor())
2587 urls.append(currentMapEditor()->getURL());
2591 void Main::editOpenMultipleURLTabs()
2593 if (currentMapEditor())
2596 urls=currentMapEditor()->getURLs();
2602 void Main::editURL()
2604 if (currentMapEditor())
2605 currentMapEditor()->editURL();
2608 void Main::editHeading2URL()
2610 if (currentMapEditor())
2611 currentMapEditor()->editHeading2URL();
2614 void Main::editBugzilla2URL()
2616 if (currentMapEditor())
2617 currentMapEditor()->editBugzilla2URL();
2620 void Main::editFATE2URL()
2622 if (currentMapEditor())
2623 currentMapEditor()->editFATE2URL();
2626 void Main::editHeadingFinished()
2628 // only called from editHeading(), so there is a currentME
2629 MapEditor *me=currentMapEditor();
2631 #if defined(Q_OS_MACX)
2633 me->setHeading(lineedit->text());
2635 lineedit->releaseKeyboard();
2639 if (!prevSelection.isEmpty()) me->select(prevSelection);
2643 void Main::editHeading()
2645 if (currentMapEditor())
2647 MapEditor *me=currentMapEditor();
2648 QString oldSel=me->getSelectString();
2650 if (lineedit->isVisible())
2651 editHeadingFinished();
2656 QString s=currentMapEditor()->getHeading(ok,p);
2660 #if defined(Q_OS_MACX)
2661 p=currentMapEditor()->mapTo (this,p);
2662 QDialog *d =new QDialog(NULL);
2663 QLineEdit *le=new QLineEdit (d);
2664 d->setWindowFlags (Qt::FramelessWindowHint);
2665 d->setGeometry(p.x(),p.y(),230,25);
2666 le->resize (d->width()-10,d->height());
2669 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2670 d->activateWindow();
2672 currentMapEditor()->setHeading (le->text());
2675 editHeadingFinished();
2677 p=currentMapEditor()->mapTo (this,p);
2678 lineedit->setGeometry(p.x(),p.y(),230,25);
2679 lineedit->setText(s);
2680 lineedit->setCursorPosition(1);
2681 lineedit->selectAll();
2683 lineedit->grabKeyboard();
2684 lineedit->setFocus();
2688 } // currentMapEditor()
2691 void Main::openVymLinks(const QStringList &vl)
2693 for (int j=0; j<vl.size(); j++)
2695 // compare path with already loaded maps
2699 for (i=0;i<=tabWidget->count() -1;i++)
2701 me=(MapEditor*)tabWidget->page(i);
2702 if (vl.at(j)==me->getFilePath() )
2711 if (!QFile(vl.at(j)).exists() )
2712 QMessageBox::critical( 0, tr( "Critical Error" ),
2713 tr("Couldn't open map %1").arg(vl.at(j)));
2716 fileLoad (vl.at(j), NewMap);
2717 tabWidget->setCurrentPage (tabWidget->count()-1);
2720 // Go to tab containing the map
2721 tabWidget->setCurrentPage (index);
2725 void Main::editOpenVymLink()
2727 if (currentMapEditor())
2730 vl.append(currentMapEditor()->getVymLink());
2735 void Main::editOpenMultipleVymLinks()
2737 QString currentVymLink;
2738 if (currentMapEditor())
2740 QStringList vl=currentMapEditor()->getVymLinks();
2745 void Main::editVymLink()
2747 if (currentMapEditor())
2748 currentMapEditor()->editVymLink();
2751 void Main::editDeleteVymLink()
2753 if (currentMapEditor())
2754 currentMapEditor()->deleteVymLink();
2757 void Main::editToggleHideExport()
2759 if (currentMapEditor())
2760 currentMapEditor()->toggleHideExport();
2763 void Main::editMapInfo()
2765 if (currentMapEditor())
2766 currentMapEditor()->editMapInfo();
2769 void Main::editMoveUp()
2771 if (currentMapEditor())
2772 currentMapEditor()->moveBranchUp();
2775 void Main::editMoveDown()
2777 if (currentMapEditor())
2778 currentMapEditor()->moveBranchDown();
2781 void Main::editToggleScroll()
2783 if (currentMapEditor())
2785 currentMapEditor()->toggleScroll();
2789 void Main::editUnScrollAll()
2791 if (currentMapEditor())
2792 currentMapEditor()->unScrollAll();
2795 void Main::editNewBranch()
2797 MapEditor *me=currentMapEditor();
2798 if (!lineedit->isVisible() && me)
2800 BranchObj *bo=(BranchObj*)me->getSelection();
2801 BranchObj *newbo=me->addNewBranch(0);
2804 me->select (newbo->getSelectString());
2808 if (actionSettingsAutoEdit->isOn())
2810 if (!actionSettingsAutoSelectHeading->isOn())
2811 prevSelection=bo->getSelectString();
2817 void Main::editNewBranchBefore()
2819 MapEditor *me=currentMapEditor();
2820 if (!lineedit->isVisible() && me)
2822 BranchObj *bo=(BranchObj*)me->getSelection();
2823 BranchObj *newbo=me->addNewBranchBefore();
2826 me->select (newbo->getSelectString());
2830 if (actionSettingsAutoEdit->isOn())
2832 if (!actionSettingsAutoSelectHeading->isOn())
2833 prevSelection=bo->getSelectString();
2839 void Main::editNewBranchAbove()
2841 MapEditor *me=currentMapEditor();
2842 if (!lineedit->isVisible() && me)
2844 BranchObj *bo=(BranchObj*)me->getSelection();
2845 BranchObj *newbo=me->addNewBranch (-1);
2848 me->select (newbo->getSelectString());
2852 if (actionSettingsAutoEdit->isOn())
2854 if (!actionSettingsAutoSelectHeading->isOn())
2855 prevSelection=bo->getSelectString();
2861 void Main::editNewBranchBelow()
2863 MapEditor *me=currentMapEditor();
2864 if (!lineedit->isVisible() && me)
2866 BranchObj *bo=(BranchObj*)me->getSelection();
2867 BranchObj *newbo=me->addNewBranch (1);
2870 me->select (newbo->getSelectString());
2874 if (actionSettingsAutoEdit->isOn())
2876 if (!actionSettingsAutoSelectHeading->isOn())
2877 prevSelection=bo->getSelectString();
2883 void Main::editImportAdd()
2885 fileLoad (ImportAdd);
2888 void Main::editImportReplace()
2890 fileLoad (ImportReplace);
2893 void Main::editSaveBranch()
2895 fileSaveAs (PartOfMap);
2898 void Main::editDeleteKeepChilds()
2900 if (currentMapEditor())
2901 currentMapEditor()->deleteKeepChilds();
2904 void Main::editDeleteChilds()
2906 if (currentMapEditor())
2907 currentMapEditor()->deleteChilds();
2910 void Main::editDeleteSelection()
2912 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2913 currentMapEditor()->deleteSelection();
2916 void Main::editUpperBranch()
2918 if (currentMapEditor())
2919 currentMapEditor()->selectUpperBranch();
2922 void Main::editLowerBranch()
2924 if (currentMapEditor())
2925 currentMapEditor()->selectLowerBranch();
2928 void Main::editLeftBranch()
2930 if (currentMapEditor())
2931 currentMapEditor()->selectLeftBranch();
2934 void Main::editRightBranch()
2936 if (currentMapEditor())
2937 currentMapEditor()->selectRightBranch();
2940 void Main::editFirstBranch()
2942 if (currentMapEditor())
2943 currentMapEditor()->selectFirstBranch();
2946 void Main::editLastBranch()
2948 if (currentMapEditor())
2949 currentMapEditor()->selectLastBranch();
2952 void Main::editLoadImage()
2954 if (currentMapEditor())
2955 currentMapEditor()->loadFloatImage();
2958 void Main::editSaveImage()
2960 if (currentMapEditor())
2961 currentMapEditor()->saveFloatImage();
2964 void Main::editFollowXLink(QAction *a)
2967 if (currentMapEditor())
2968 currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
2971 void Main::editEditXLink(QAction *a)
2973 if (currentMapEditor())
2974 currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
2977 void Main::formatSelectColor()
2979 if (currentMapEditor())
2981 QColor col = QColorDialog::getColor((currentColor ), this );
2982 if ( !col.isValid() ) return;
2983 colorChanged( col );
2987 void Main::formatPickColor()
2989 if (currentMapEditor())
2990 colorChanged( currentMapEditor()->getCurrentHeadingColor() );
2993 void Main::colorChanged(QColor c)
2995 QPixmap pix( 16, 16 );
2997 actionFormatColor->setIconSet( pix );
3001 void Main::formatColorItem()
3003 if (currentMapEditor())
3004 currentMapEditor()->colorItem(currentColor);
3007 void Main::formatColorBranch()
3009 if (currentMapEditor())
3010 currentMapEditor()->colorBranch(currentColor);
3013 void Main::formatLinkStyleLine()
3015 if (currentMapEditor())
3016 currentMapEditor()->setMapLinkStyle("StyleLine");
3019 void Main::formatLinkStyleParabel()
3021 if (currentMapEditor())
3022 currentMapEditor()->setMapLinkStyle("StyleParabel");
3025 void Main::formatLinkStylePolyLine()
3027 if (currentMapEditor())
3028 currentMapEditor()->setMapLinkStyle("StylePolyLine");
3031 void Main::formatLinkStylePolyParabel()
3033 if (currentMapEditor())
3034 currentMapEditor()->setMapLinkStyle("StylePolyParabel");
3037 void Main::formatSelectBackColor()
3039 if (currentMapEditor())
3040 currentMapEditor()->selectMapBackgroundColor();
3043 void Main::formatSelectBackImage()
3045 if (currentMapEditor())
3046 currentMapEditor()->selectMapBackgroundImage();
3049 void Main::formatSelectLinkColor()
3051 if (currentMapEditor())
3052 currentMapEditor()->selectMapLinkColor();
3055 void Main::formatToggleLinkColorHint()
3057 currentMapEditor()->toggleMapLinkColorHint();
3060 void Main::formatFrameNone()
3062 if (currentMapEditor())
3063 currentMapEditor()->setFrame(NoFrame);
3066 void Main::formatFrameRectangle()
3068 if (currentMapEditor())
3069 currentMapEditor()->setFrame(Rectangle);
3072 void Main::formatIncludeImagesVer()
3074 if (currentMapEditor())
3075 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
3078 void Main::formatIncludeImagesHor()
3080 if (currentMapEditor())
3081 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
3084 void Main::formatHideLinkUnselected()
3086 if (currentMapEditor())
3087 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3090 void Main::viewZoomReset()
3092 if (currentMapEditor())
3096 currentMapEditor()->setMatrix( m );
3097 currentMapEditor()->setViewCenter();
3098 currentMapEditor()->adjustCanvasSize();
3102 void Main::viewZoomIn()
3104 if (currentMapEditor())
3106 QMatrix m = currentMapEditor()->matrix();
3107 m.scale( 1.25, 1.25 );
3108 currentMapEditor()->setMatrix( m );
3109 currentMapEditor()->setViewCenter();
3110 currentMapEditor()->adjustCanvasSize();
3114 void Main::viewZoomOut()
3116 if (currentMapEditor())
3118 QMatrix m = currentMapEditor()->matrix();
3119 m.scale( 0.8, 0.8 );
3120 currentMapEditor()->setMatrix( m );
3121 currentMapEditor()->setViewCenter();
3122 currentMapEditor()->adjustCanvasSize();
3126 bool Main::settingsPDF()
3128 // Default browser is set in constructor
3130 QString text = QInputDialog::getText(
3131 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3132 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3134 settings.setValue ("/mainwindow/readerPDF",text);
3139 bool Main::settingsURL()
3141 // Default browser is set in constructor
3143 QString text = QInputDialog::getText(
3144 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3145 settings.value("/mainwindow/readerURL").toString()
3148 settings.setValue ("/mainwindow/readerURL",text);
3152 void Main::settingsToggleDelKey()
3154 if (actionSettingsUseDelKey->isOn())
3156 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3159 actionEditDelete->setAccel (QKeySequence (""));
3163 void Main::windowToggleNoteEditor()
3165 if (textEditor->showWithMain() )
3166 windowHideNoteEditor();
3168 windowShowNoteEditor();
3171 void Main::windowToggleHistory()
3173 if (historyWindow->isVisible())
3174 historyWindow->hide();
3176 historyWindow->show();
3180 void Main::windowToggleAntiAlias()
3182 bool b=actionViewToggleAntiAlias->isOn();
3184 for (int i=0;i<tabWidget->count();i++)
3187 me=(MapEditor*)tabWidget->page(i);
3188 me->setAntiAlias(b);
3193 void Main::windowToggleSmoothPixmap()
3195 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3197 for (int i=0;i<tabWidget->count();i++)
3200 me=(MapEditor*)tabWidget->page(i);
3201 me->setSmoothPixmap(b);
3205 void Main::updateHistory(SimpleSettings &undoSet)
3207 historyWindow->update (undoSet);
3210 void Main::updateNoteFlag()
3212 if (currentMapEditor())
3213 currentMapEditor()->updateNoteFlag();
3216 void Main::updateActions()
3218 MapEditor *me=currentMapEditor();
3221 historyWindow->setCaption (tr("History for %1").arg(currentMapEditor()->getFileName()));
3223 // updateActions is also called when NoteEditor is closed
3224 actionViewToggleNoteEditor->setOn (textEditor->showWithMain());
3226 if (me->getMapLinkColorHint()==HeadingColor)
3227 actionFormatLinkColorHint->setOn(true);
3229 actionFormatLinkColorHint->setOn(false);
3231 switch (me->getMapLinkStyle())
3234 actionFormatLinkStyleLine->setOn(true);
3237 actionFormatLinkStyleParabel->setOn(true);
3240 actionFormatLinkStylePolyLine->setOn(true);
3242 case StylePolyParabel:
3243 actionFormatLinkStylePolyParabel->setOn(true);
3249 QPixmap pix( 16, 16 );
3250 pix.fill( me->getMapBackgroundColor() );
3251 actionFormatBackColor->setIconSet( pix );
3252 pix.fill( me->getMapDefLinkColor() );
3253 actionFormatLinkColor->setIconSet( pix );
3255 actionFileSave->setEnabled( me->isUnsaved() );
3256 if (me->isUndoAvailable())
3257 actionEditUndo->setEnabled( true);
3259 actionEditUndo->setEnabled( false);
3261 if (me->isRedoAvailable())
3262 actionEditRedo->setEnabled( true);
3264 actionEditRedo->setEnabled( false);
3266 LinkableMapObj *selection=me->getSelection();
3269 if ( (typeid(*selection) == typeid(BranchObj)) ||
3270 (typeid(*selection) == typeid(MapCenterObj)) )
3272 BranchObj *bo=(BranchObj*)selection;
3273 // Take care of links
3274 if (bo->countXLinks()==0)
3276 branchXLinksContextMenuEdit->clear();
3277 branchXLinksContextMenuFollow->clear();
3282 branchXLinksContextMenuEdit->clear();
3283 branchXLinksContextMenuFollow->clear();
3284 for (int i=0; i<=bo->countXLinks();i++)
3286 bot=bo->XLinkTargetAt(i);
3289 s=bot->getHeading();
3292 branchXLinksContextMenuFollow->addAction (s);
3293 branchXLinksContextMenuEdit->addAction (s);
3298 standardFlagsDefault->setEnabled (true);
3300 actionEditToggleScroll->setEnabled (true);
3301 if ( bo->isScrolled() )
3302 actionEditToggleScroll->setOn(true);
3304 actionEditToggleScroll->setOn(false);
3306 if ( bo->getURL().isEmpty() )
3308 actionEditOpenURL->setEnabled (false);
3309 actionEditOpenURLTab->setEnabled (false);
3313 actionEditOpenURL->setEnabled (true);
3314 actionEditOpenURLTab->setEnabled (true);
3316 if ( bo->getVymLink().isEmpty() )
3318 actionEditOpenVymLink->setEnabled (false);
3319 actionEditDeleteVymLink->setEnabled (false);
3322 actionEditOpenVymLink->setEnabled (true);
3323 actionEditDeleteVymLink->setEnabled (true);
3326 if (bo->canMoveBranchUp())
3327 actionEditMoveUp->setEnabled (true);
3329 actionEditMoveUp->setEnabled (false);
3330 if (bo->canMoveBranchDown())
3331 actionEditMoveDown->setEnabled (true);
3333 actionEditMoveDown->setEnabled (false);
3336 actionEditToggleHideExport->setEnabled (true);
3337 actionEditToggleHideExport->setOn (bo->hideInExport() );
3339 actionEditCopy->setEnabled (true);
3340 actionEditCut->setEnabled (true);
3341 if (!clipboardEmpty)
3342 actionEditPaste->setEnabled (true);
3344 actionEditPaste->setEnabled (false);
3345 for (int i=0; i<actionListBranches.size(); ++i)
3346 actionListBranches.at(i)->setEnabled(true);
3347 actionEditDelete->setEnabled (true);
3348 switch (selection->getFrameType())
3351 actionFormatFrameNone->setOn(true);
3354 actionFormatFrameRectangle->setOn(true);
3359 actionFormatIncludeImagesVer->setOn
3360 ( ((BranchObj*)selection)->getIncludeImagesVer());
3361 actionFormatIncludeImagesHor->setOn
3362 ( ((BranchObj*)selection)->getIncludeImagesHor());
3363 actionFormatHideLinkUnselected->setOn
3364 (selection->getHideLinkUnselected());
3366 if ( (typeid(*selection) == typeid(FloatImageObj)) )
3368 FloatObj *fo=(FloatImageObj*)selection;
3369 //FIXME do this in mainwindow standardFlagsDefault->setEnabled (false);
3371 actionEditOpenURL->setEnabled (false);
3372 actionEditOpenVymLink->setEnabled (false);
3373 actionEditDeleteVymLink->setEnabled (false);
3374 actionEditToggleHideExport->setEnabled (true);
3375 actionEditToggleHideExport->setOn (fo->hideInExport() );
3378 actionEditCopy->setEnabled (true);
3379 actionEditCut->setEnabled (true);
3380 actionEditPaste->setEnabled (false);
3381 for (int i=0; i<actionListBranches.size(); ++i)
3382 actionListBranches.at(i)->setEnabled(false);
3383 actionEditDelete->setEnabled (true);
3384 actionFormatHideLinkUnselected->setOn
3385 ( selection->getHideLinkUnselected());
3386 actionEditMoveUp->setEnabled (false);
3387 actionEditMoveDown->setEnabled (false);
3392 actionEditCopy->setEnabled (false);
3393 actionEditCut->setEnabled (false);
3394 actionEditPaste->setEnabled (false);
3395 for (int i=0; i<actionListBranches.size(); ++i)
3396 actionListBranches.at(i)->setEnabled(false);
3398 actionEditToggleScroll->setEnabled (false);
3399 actionEditOpenURL->setEnabled (false);
3400 actionEditOpenVymLink->setEnabled (false);
3401 actionEditDeleteVymLink->setEnabled (false);
3402 actionEditHeading2URL->setEnabled (false);
3403 actionEditDelete->setEnabled (false);
3404 actionEditMoveUp->setEnabled (false);
3405 actionEditMoveDown->setEnabled (false);
3406 actionEditToggleHideExport->setEnabled (false);
3410 ModMode Main::getModMode()
3412 if (actionModModeColor->isOn()) return ModModeColor;
3413 if (actionModModeCopy->isOn()) return ModModeCopy;
3414 if (actionModModeXLink->isOn()) return ModModeXLink;
3418 bool Main::autoEdit()
3420 return actionSettingsAutoEdit->isOn();
3423 bool Main::autoSelectHeading()
3425 return actionSettingsAutoSelectHeading->isOn();
3428 bool Main::useFlagGroups()
3430 return actionSettingsUseFlagGroups->isOn();
3433 void Main::windowShowNoteEditor()
3435 textEditor->setShowWithMain(true);
3437 actionViewToggleNoteEditor->setOn (true);
3440 void Main::windowHideNoteEditor()
3442 textEditor->setShowWithMain(false);
3444 actionViewToggleNoteEditor->setOn (false);
3447 void Main::windowNextEditor()
3449 if (tabWidget->currentPageIndex() < tabWidget->count())
3450 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3453 void Main::windowPreviousEditor()
3455 if (tabWidget->currentPageIndex() >0)
3456 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3459 void Main::standardFlagChanged()
3461 currentMapEditor()->toggleStandardFlag(sender()->name());
3464 void Main::testFunction()
3466 if (!currentMapEditor()) return;
3467 currentMapEditor()->testFunction();
3470 void Main::testCommand()
3472 if (!currentMapEditor()) return;
3474 QString com = QInputDialog::getText(
3475 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3476 if (ok) currentMapEditor()->parseAtom(com);
3479 void Main::helpDoc()
3481 QString locale = QLocale::system().name();
3483 if (locale.left(2)=="es")
3484 docname="vym_es.pdf";
3488 #if defined(Q_OS_MACX)
3489 docdir.setPath("./vym.app/Contents");
3491 // default path in SUSE LINUX
3492 docdir.setPath("/usr/share/doc/packages/vym/doc");
3495 if (!docdir.exists() )
3497 // relative path for easy testing in tarball
3498 docdir.setPath("doc");
3499 if (!docdir.exists() )
3501 // relative path for testing while still writing vym.tex
3502 docdir.setPath("doc/tex/vym.pdf");
3503 if (!docdir.exists() )
3505 // Try yet another one for Knoppix
3506 docdir.setPath("/usr/share/doc/packages/vym");
3507 if (!docdir.exists() )
3509 QMessageBox::critical(0,
3510 tr("Critcal error"),
3511 tr("Couldn't find the documentation\n"
3512 "vym.pdf in various directories."));
3519 QString docpath=docdir.path()+"/"+docname;
3521 Process *pdfProc = new Process();
3524 pdfProc->start( settings.value("/mainwindow/readerPDF").toString());
3525 if ( !pdfProc->waitForStarted() )
3528 QMessageBox::warning(0,
3530 tr("Couldn't find a viewer to open %1.\n").arg(docpath)+
3531 tr("Please use Settings->")+tr("Set application to open PDF files"));
3538 void Main::helpAbout()
3541 ad.setName ("aboutwindow");
3542 ad.setMinimumSize(500,500);
3543 ad.resize (QSize (500,500));
3547 void Main::helpAboutQT()
3549 QMessageBox::aboutQt( this, "Qt Application Example" );