Removed some FIXMEs. Added translations
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();
96 // Initialize some settings, which are platform dependant
99 // application to open URLs
100 p="/mainwindow/readerURL";
101 #if defined(Q_OS_LINUX)
102 s=settings.value (p,"konqueror").toString();
104 #if defined(Q_OS_MACX)
105 s=settings.value (p,"/usr/bin/open").toString();
107 s=settings.value (p,"mozilla");
110 settings.setValue( p,s);
112 // application to open PDFs
113 p="/mainwindow/readerPDF";
114 #if defined(Q_OS_LINUX)
115 s=settings.value (p,"acroread").toString();
117 #if defined(Q_OS_MACX)
118 s=settings.value (p,"/usr/bin/open").toString();
120 s=settings.value (p,"acroread").toString();
123 settings.setValue( p,s);
126 // Create tab widget which holds the maps
127 tabWidget= new QTabWidget (this);
128 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
129 this, SLOT( editorChanged( QWidget * ) ) );
131 lineedit=new QLineEdit (this);
134 setCentralWidget(tabWidget);
138 setupFormatActions();
142 setupSettingsActions();
144 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
149 restoreState (settings.value("/mainwindow/state",0).toByteArray());
151 // Initialize Find window
152 findWindow=new FindWindow(NULL);
153 findWindow->move (x(),y()+70);
154 connect (findWindow, SIGNAL( findButton(QString) ),
155 this, SLOT(editFind(QString) ) );
156 connect (findWindow, SIGNAL( somethingChanged() ),
157 this, SLOT(editFindChanged() ) );
159 // Connect TextEditor, so that we can update flags if text changes
160 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
161 connect (textEditor, SIGNAL (textEditorClosed() ), this, SLOT (updateActions()));
169 settings.setValue ( "/mainwindow/geometry/size", size() );
170 settings.setValue ( "/mainwindow/geometry/pos", pos() );
171 settings.setValue ("/mainwindow/state",saveState(0));
173 settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
174 settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
175 settings.setValue( "/version/version", vymVersion );
176 settings.setValue( "/version/builddate", vymBuildDate );
178 settings.setValue( "/mapeditor/editmode/autoSelectHeading",actionSettingsAutoSelectHeading->isOn() );
179 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
180 settings.setValue( "/mapeditor/editmode/autoEdit",actionSettingsAutoEdit->isOn() );
181 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
182 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
183 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
185 // call the destructors
187 delete historyWindow;
189 // Remove temporary directory
190 removeDir (QDir(tmpVymDir));
193 void Main::loadCmdLine()
195 /* TODO draw some kind of splashscreen while loading...
201 QStringList flist=options.getFileList();
202 QStringList::Iterator it=flist.begin();
204 while (it !=flist.end() )
206 fileLoad (*it, NewMap);
212 void Main::statusMessage(const QString &s)
214 statusBar()->message (s);
217 void Main::closeEvent (QCloseEvent* )
223 void Main::setupFileActions()
225 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
226 QToolBar *tb = addToolBar( tr ("&Map") );
227 tb->setObjectName ("mapTB");
230 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New...","File menu" ),this);
231 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
232 a->setShortcut ( Qt::CTRL + Qt::Key_N );
234 fileMenu->addAction (a);
235 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
237 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
238 a->setStatusTip (tr( "Open","Status tip File menu" ) );
239 a->setShortcut ( Qt::CTRL + Qt::Key_O );
241 fileMenu->addAction (a);
242 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
244 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
245 fileMenu->addSeparator();
247 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
248 a->setStatusTip ( tr( "Save","Status tip file menu" ));
249 a->setShortcut (Qt::CTRL + Qt::Key_S );
251 fileMenu->addAction (a);
252 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
255 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
256 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
257 fileMenu->addAction (a);
258 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
260 fileMenu->addSeparator();
262 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
264 a = new QAction(tr("KDE Bookmarks"), this);
265 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE bookmarks")));
266 a->addTo (fileImportMenu);
267 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) );
269 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
271 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
272 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
273 a->addTo (fileImportMenu);
274 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
277 a = new QAction("Mind Manager...",this);
278 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
279 fileImportMenu->addAction (a);
280 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
282 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
283 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
284 fileImportMenu->addAction (a);
285 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
287 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
289 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
290 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
291 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
292 fileExportMenu->addAction (a);
294 a = new QAction( "Open Office...", this);
295 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
296 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
297 fileExportMenu->addAction (a);
299 a = new QAction( "Webpage (XHTML)...",this );
300 a->setShortcut (Qt::ALT + Qt::Key_X);
301 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
302 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
303 fileExportMenu->addAction (a);
305 a = new QAction( "Text (ASCII)...", this);
306 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
307 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
308 fileExportMenu->addAction (a);
310 a = new QAction( tr("KDE Bookmarks","File menu"), this);
311 a->setStatusTip( tr( "Export as %1").arg(tr("KDE Bookmarks" )));
312 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
313 fileExportMenu->addAction (a);
315 a = new QAction( "Taskjuggler...", this );
316 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
317 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
318 fileExportMenu->addAction (a);
320 a = new QAction( "LaTeX...", this);
321 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
322 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
323 fileExportMenu->addAction (a);
325 a = new QAction( "XML..." , this );
326 a->setStatusTip (tr( "Export as %1").arg("XML"));
327 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
328 fileExportMenu->addAction (a);
330 fileMenu->addSeparator();
332 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
333 a->setStatusTip ( tr( "Print" ,"File menu") );
334 a->setShortcut (Qt::CTRL + Qt::Key_P );
336 fileMenu->addAction (a);
337 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
340 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
341 a->setStatusTip (tr( "Close Map" ) );
342 a->setShortcut (Qt::ALT + Qt::Key_C );
343 fileMenu->addAction (a);
344 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
346 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
347 a->setStatusTip ( tr( "Exit")+" "+vymName );
348 a->setShortcut (Qt::CTRL + Qt::Key_Q );
349 fileMenu->addAction (a);
350 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
355 void Main::setupEditActions()
357 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
358 tb->setLabel( "Edit Actions" );
359 tb->setObjectName ("actionsTB");
360 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
364 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
365 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
366 a->setStatusTip (tr( "Undo" ) );
367 a->setShortcut ( Qt::CTRL + Qt::Key_Z );
368 a->setEnabled (false);
370 editMenu->addAction (a);
373 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
374 a->setStatusTip (tr( "Redo" ));
375 a->setShortcut (Qt::CTRL + Qt::Key_Y );
377 editMenu->addAction (a);
378 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
381 editMenu->addSeparator();
382 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
383 a->setStatusTip ( tr( "Copy" ) );
384 a->setShortcut (Qt::CTRL + Qt::Key_C );
385 a->setEnabled (false);
387 editMenu->addAction (a);
388 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
391 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
392 a->setStatusTip ( tr( "Cut" ) );
393 a->setShortcut (Qt::CTRL + Qt::Key_X );
394 a->setEnabled (false);
396 editMenu->addAction (a);
398 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
400 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
401 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
402 a->setStatusTip ( tr( "Paste" ) );
403 a->setShortcut ( Qt::CTRL + Qt::Key_V );
404 a->setEnabled (false);
406 editMenu->addAction (a);
409 // Shortcuts to modify heading:
410 a = new QAction(tr( "Edit heading","Edit menu" ),this);
411 a->setStatusTip ( tr( "edit Heading" ));
412 a->setShortcut ( Qt::Key_Enter);
413 // a->setShortcutContext (Qt::WindowShortcut);
415 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
416 actionListBranches.append(a);
417 a = new QAction( tr( "Edit heading","Edit menu" ), this);
418 a->setStatusTip (tr( "edit Heading" ));
419 a->setShortcut (Qt::Key_Return );
420 //a->setShortcutContext (Qt::WindowShortcut);
422 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
423 actionListBranches.append(a);
424 editMenu->addAction (a);
426 a = new QAction( tr( "Edit heading","Edit menu" ), this);
427 a->setStatusTip (tr( "edit Heading" ));
428 a->setShortcut ( Qt::Key_F2 );
429 a->setShortcutContext (Qt::WindowShortcut);
431 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
432 actionListBranches.append(a);
434 // Shortcut to delete selection
435 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
436 a->setStatusTip (tr( "Delete Selection" ));
437 a->setShortcut ( Qt::Key_Delete);
438 a->setShortcutContext (Qt::WindowShortcut);
440 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
443 // Shortcut to add branch
444 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
445 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
446 alt->setShortcut (Qt::Key_A);
447 alt->setShortcutContext (Qt::WindowShortcut);
449 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
450 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
451 a->setStatusTip ( tr( "Add a branch as child of selection" ));
452 a->setShortcut (Qt::Key_Insert);
453 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
454 actionListBranches.append(a);
455 #if defined (Q_OS_MACX)
456 // In OSX show different shortcut in menues, the keys work indepently always
457 actionEditAddBranch=alt;
459 actionEditAddBranch=a;
461 editMenu->addAction (actionEditAddBranch);
462 tb->addAction (actionEditAddBranch);
465 // Add branch by inserting it at selection
466 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
467 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
468 a->setShortcut (Qt::ALT + Qt::Key_Insert );
469 a->setShortcutContext (Qt::WindowShortcut);
471 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
472 a->setEnabled (false);
473 actionListBranches.append(a);
474 actionEditAddBranchBefore=a;
475 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
476 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
477 a->setShortcut ( Qt::ALT + Qt::Key_A );
478 a->setShortcutContext (Qt::WindowShortcut);
480 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
481 actionListBranches.append(a);
484 a = new QAction(tr( "Add branch above","Edit menu" ), this);
485 a->setStatusTip ( tr( "Add a branch above selection" ));
486 a->setShortcut (Qt::SHIFT+Qt::Key_Insert );
487 a->setShortcutContext (Qt::WindowShortcut);
489 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
490 a->setEnabled (false);
491 actionListBranches.append(a);
492 actionEditAddBranchAbove=a;
493 a = new QAction(tr( "Add branch above","Edit menu" ), this);
494 a->setStatusTip ( tr( "Add a branch above selection" ));
495 a->setShortcut (Qt::SHIFT+Qt::Key_A );
496 a->setShortcutContext (Qt::WindowShortcut);
498 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
499 actionListBranches.append(a);
502 a = new QAction(tr( "Add branch below","Edit menu" ), this);
503 a->setStatusTip ( tr( "Add a branch below selection" ));
504 a->setShortcut (Qt::CTRL +Qt::Key_Insert );
505 a->setShortcutContext (Qt::WindowShortcut);
507 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
508 a->setEnabled (false);
509 actionListBranches.append(a);
510 actionEditAddBranchBelow=a;
511 a = new QAction(tr( "Add branch below","Edit menu" ), this);
512 a->setStatusTip ( tr( "Add a branch below selection" ));
513 a->setShortcut (Qt::CTRL +Qt::Key_A );
514 a->setShortcutContext (Qt::WindowShortcut);
516 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
517 actionListBranches.append(a);
519 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
520 a->setStatusTip ( tr( "Move branch up" ) );
521 a->setShortcut (Qt::Key_PageUp );
522 a->setEnabled (false);
524 editMenu->addAction (a);
525 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
528 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
529 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
530 a->setStatusTip (tr( "Move branch down" ) );
531 a->setShortcut ( Qt::Key_PageDown );
532 a->setEnabled (false);
534 editMenu->addAction (a);
535 actionEditMoveDown=a;
538 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this);
539 a->setShortcut ( Qt::Key_ScrollLock );
540 a->setStatusTip (tr( "Scroll branch" ) );
541 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
543 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
544 alt->setShortcut ( Qt::Key_S );
545 alt->setStatusTip (tr( "Scroll branch" ));
546 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
547 #if defined(Q_OS_MACX)
548 actionEditToggleScroll=alt;
550 actionEditToggleScroll=a;
552 actionEditToggleScroll->setEnabled (false);
553 actionEditToggleScroll->setToggleAction(true);
554 tb->addAction (actionEditToggleScroll);
555 editMenu->addAction ( actionEditToggleScroll);
556 editMenu->addAction (actionEditToggleScroll);
559 actionListBranches.append(actionEditToggleScroll);
561 a = new QAction( tr( "Unscroll all scrolled branches","Edit menu" ), this);
562 a->setStatusTip (tr( "Unscroll all" ));
563 editMenu->addAction (a);
564 connect( a, SIGNAL( triggered() ), this, SLOT( editUnScrollAll() ) );
566 editMenu->addSeparator();
568 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
569 a->setStatusTip (tr( "Find" ) );
570 a->setShortcut (Qt::CTRL + Qt::Key_F );
571 editMenu->addAction (a);
572 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
574 editMenu->addSeparator();
576 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
577 a->setShortcut (Qt::CTRL + Qt::Key_U );
578 a->setShortcut (tr( "Open URL" ));
581 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
584 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
585 a->setStatusTip (tr( "Open URL in new tab" ));
586 a->setShortcut (Qt::CTRL+Qt::Key_U );
588 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
589 actionEditOpenURLTab=a;
591 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
592 a->setStatusTip (tr( "Open all URLs in subtree" ));
594 actionListBranches.append(a);
595 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
596 actionEditOpenMultipleURLTabs=a;
598 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
599 a->setStatusTip ( tr( "Edit URL" ) );
600 a->setShortcut (Qt::SHIFT + Qt::CTRL + Qt::Key_U );
601 //a->setShortcut ( Qt::Key_U );
602 a->setShortcutContext (Qt::WindowShortcut);
603 actionListBranches.append(a);
605 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
608 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
609 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
610 a->setEnabled (false);
611 actionListBranches.append(a);
612 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
613 actionEditHeading2URL=a;
615 a = new QAction(tr( "Create URL to Bugzilla","Edit menu" ), this);
616 a->setStatusTip ( tr( "Create URL to Bugzilla" ));
617 a->setEnabled (false);
618 actionListBranches.append(a);
619 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
620 actionEditBugzilla2URL=a;
622 a = new QAction(tr( "Create URL to FATE","Edit menu" ), this);
623 a->setStatusTip ( tr( "Create URL to FATE" ));
624 a->setEnabled (false);
625 actionListBranches.append(a);
626 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
627 actionEditFATE2URL=a;
629 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
630 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
632 a->setEnabled (false);
633 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
634 actionEditOpenVymLink=a;
636 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
637 a->setStatusTip ( tr( "Open all vym links in subtree" ));
638 a->setEnabled (false);
639 actionListBranches.append(a);
640 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
641 actionEditOpenMultipleVymLinks=a;
644 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
645 a->setEnabled (false);
646 a->setStatusTip ( tr( "Edit link to another vym map" ));
647 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
648 actionListBranches.append(a);
651 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
652 a->setStatusTip ( tr( "Delete link to another vym map" ));
653 a->setEnabled (false);
654 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
655 actionEditDeleteVymLink=a;
657 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
658 a->setStatusTip ( tr( "Hide object in exports" ) );
659 a->setShortcut (Qt::Key_H );
660 a->setToggleAction(true);
662 a->setEnabled (false);
663 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
664 actionEditToggleHideExport=a;
666 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
667 a->setStatusTip ( tr( "Edit Map Info" ));
668 a->setEnabled (true);
669 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
672 // Import at selection (adding to selection)
673 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
674 a->setStatusTip (tr( "Add map at selection" ));
675 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
676 a->setEnabled (false);
677 actionListBranches.append(a);
678 actionEditImportAdd=a;
680 // Import at selection (replacing selection)
681 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
682 a->setStatusTip (tr( "Replace selection with map" ));
683 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
684 a->setEnabled (false);
685 actionListBranches.append(a);
686 actionEditImportReplace=a;
689 a = new QAction( tr( "Save selection","Edit menu" ), this);
690 a->setStatusTip (tr( "Save selection" ));
691 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
692 a->setEnabled (false);
693 actionListBranches.append(a);
694 actionEditSaveBranch=a;
696 // Only remove branch, not its childs
697 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
698 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
699 a->setShortcut (Qt::ALT + Qt::Key_Delete );
700 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChilds() ) );
701 a->setEnabled (false);
703 actionListBranches.append(a);
704 actionEditDeleteKeepChilds=a;
706 // Only remove childs of a branch
707 a = new QAction( tr( "Remove childs","Edit menu" ), this);
708 a->setStatusTip (tr( "Remove childs of branch" ));
709 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
710 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChilds() ) );
711 a->setEnabled (false);
712 actionListBranches.append(a);
713 actionEditDeleteChilds=a;
715 // Shortcuts for navigating with cursor:
716 a = new QAction(tr( "Select upper branch","Edit menu" ), this);
717 a->setStatusTip ( tr( "Select upper branch" ));
718 a->setShortcut (Qt::Key_Up );
719 a->setShortcutContext (Qt::WindowShortcut);
721 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
722 a = new QAction( tr( "Select lower branch","Edit menu" ),this);
723 a->setStatusTip (tr( "Select lower branch" ));
724 a->setShortcut ( Qt::Key_Down );
725 a->setShortcutContext (Qt::WindowShortcut);
727 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
728 a = new QAction(tr( "Select left branch","Edit menu" ), this);
729 a->setStatusTip ( tr( "Select left branch" ));
730 a->setShortcut (Qt::Key_Left );
731 a->setShortcutContext (Qt::WindowShortcut);
733 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
734 a = new QAction( tr( "Select child branch","Edit menu" ), this);
735 a->setStatusTip (tr( "Select right branch" ));
736 a->setShortcut (Qt::Key_Right);
737 a->setShortcutContext (Qt::WindowShortcut);
739 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
740 a = new QAction( tr( "Select first branch","Edit menu" ), this);
741 a->setStatusTip (tr( "Select first branch" ));
742 a->setShortcut (Qt::Key_Home );
743 a->setShortcutContext (Qt::WindowShortcut);
745 a->setEnabled (false);
746 editMenu->addAction (a);
747 actionListBranches.append(a);
748 actionEditSelectFirst=a;
749 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
750 a = new QAction( tr( "Select last branch","Edit menu" ),this);
751 a->setStatusTip (tr( "Select last branch" ));
752 a->setShortcut ( Qt::Key_End );
753 a->setShortcutContext (Qt::WindowShortcut);
755 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
756 a->setEnabled (false);
757 editMenu->addAction (a);
758 actionListBranches.append(a);
759 actionEditSelectLast=a;
761 a = new QAction( tr( "Add Image...","Edit menu" ), this);
762 a->setStatusTip (tr( "Add Image" ));
763 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
764 actionEditLoadImage=a;
769 void Main::setupFormatActions()
771 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
773 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
774 tb->setObjectName ("formatTB");
777 pix.fill (Qt::black);
778 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
779 a->setStatusTip ( tr( "Set Color" ));
780 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
782 formatMenu->addAction (a);
784 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
785 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
786 a->setShortcut (Qt::CTRL + Qt::Key_K );
787 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
788 a->setEnabled (false);
790 formatMenu->addAction (a);
791 actionListBranches.append(a);
792 actionFormatPickColor=a;
794 a= new QAction(QPixmap(iconPath+"formatcoloritem.png"), tr( "Color &branch","Edit menu" ), this);
795 a->setStatusTip ( tr( "Color branch" ) );
796 a->setShortcut (Qt::CTRL + Qt::Key_I);
797 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorItem() ) );
798 a->setEnabled (false);
800 formatMenu->addAction (a);
801 actionListBranches.append(a);
802 actionFormatColorBranch=a;
804 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color sub&tree","Edit menu" ), this);
805 a->setStatusTip ( tr( "Color Subtree" ));
806 a->setShortcut (Qt::CTRL + Qt::Key_T);
807 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
808 a->setEnabled (false);
809 formatMenu->addAction (a);
811 actionListBranches.append(a);
812 actionFormatColorSubtree=a;
814 formatMenu->addSeparator();
815 actionGroupFormatLinkStyles=new QActionGroup ( this);
816 actionGroupFormatLinkStyles->setExclusive (true);
817 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
818 a->setStatusTip (tr( "Line" ));
819 a->setToggleAction(true);
820 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
821 formatMenu->addAction (a);
822 actionFormatLinkStyleLine=a;
823 a= new QAction( tr( "Linkstyle Parabel" ), actionGroupFormatLinkStyles);
824 a->setStatusTip (tr( "Line" ));
825 a->setToggleAction(true);
826 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
827 formatMenu->addAction (a);
828 actionFormatLinkStyleParabel=a;
829 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
830 a->setStatusTip (tr( "PolyLine" ));
831 a->setToggleAction(true);
832 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
833 formatMenu->addAction (a);
834 actionFormatLinkStylePolyLine=a;
835 a= new QAction( tr( "Linkstyle Thick Parabel" ), actionGroupFormatLinkStyles);
836 a->setStatusTip (tr( "PolyParabel" ) );
837 a->setToggleAction(true);
838 a->setChecked (true);
839 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
840 formatMenu->addAction (a);
841 actionFormatLinkStylePolyParabel=a;
843 actionGroupFormatFrameTypes=new QActionGroup ( this);
844 actionGroupFormatFrameTypes->setExclusive (true);
845 a = new QAction( tr( "No Frame","Branch attribute" ), actionGroupFormatFrameTypes );
846 a->setStatusTip (tr("No Frame"));
847 a->setToggleAction(true);
848 connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameNone() ) );
849 actionFormatFrameNone=a;
850 a = new QAction( tr( "Rectangle""Branch attribute" ), actionGroupFormatFrameTypes);
851 a->setStatusTip (tr( "Rectangle" ));
852 a->setToggleAction(true);
853 connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameRectangle() ) );
854 actionFormatFrameRectangle=a;
856 a = new QAction( tr( "Include images vertically","Branch attribute" ), this);
857 a->setStatusTip ( tr ("Include top and bottom position of images into branch"));
858 a->setToggleAction(true);
859 connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesVer() ) );
860 actionFormatIncludeImagesVer=a;
862 a = new QAction( tr( "Include images horizontally","Branch attribute" ), this);
863 a->setStatusTip ( tr ("Include left and right position of images into branch"));
864 a->setToggleAction(true);
865 connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesHor() ) );
866 actionFormatIncludeImagesHor=a;
868 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
869 a->setStatusTip (tr( "Hide link" ));
870 a->setToggleAction(true);
871 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
872 actionFormatHideLinkUnselected=a;
874 formatMenu->addSeparator();
875 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
876 a->setStatusTip (tr( "Use same color for links and headings" ));
877 a->setToggleAction(true);
878 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
879 formatMenu->addAction (a);
880 actionFormatLinkColorHint=a;
882 pix.fill (Qt::white);
883 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
884 a->setStatusTip (tr( "Set Link Color" ));
885 formatMenu->addAction (a);
886 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
887 actionFormatLinkColor=a;
889 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
890 a->setStatusTip (tr( "Set Background Color" ));
891 formatMenu->addAction (a);
892 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
893 actionFormatBackColor=a;
895 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
896 a->setStatusTip (tr( "Set Background image" ));
897 formatMenu->addAction (a);
898 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
899 actionFormatBackImage=a;
903 void Main::setupViewActions()
905 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
906 tb->setLabel( "View Actions" );
907 tb->setObjectName ("viewTB");
908 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
911 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
912 a->setStatusTip ( tr( "Zoom reset" ) );
913 a->setShortcut (Qt::CTRL + Qt::Key_0 );
915 viewMenu->addAction (a);
916 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
918 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
919 a->setStatusTip (tr( "Zoom in" ));
920 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
922 viewMenu->addAction (a);
923 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
925 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
926 a->setStatusTip (tr( "Zoom out" ));
927 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
929 viewMenu->addAction (a);
930 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
933 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
934 a->setStatusTip ( tr( "Show Note Editor" ));
935 a->setShortcut ( Qt::CTRL + Qt::Key_E );
936 a->setToggleAction(true);
937 if (textEditor->showWithMain())
942 viewMenu->addAction (a);
943 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
944 actionViewToggleNoteEditor=a;
946 a = new QAction(QPixmap(iconPath+"history.png"), tr( "Show history window","View action" ),this );
947 a->setStatusTip ( tr( "Show history window" ));
948 a->setShortcut ( Qt::CTRL + Qt::Key_H );
949 a->setToggleAction(true);
951 viewMenu->addAction (a);
952 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
953 actionViewToggleHistoryWindow=a;
955 a = new QAction(tr( "Antialiasing","View action" ),this );
956 a->setStatusTip ( tr( "Antialiasing" ));
957 a->setToggleAction(true);
958 a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
959 viewMenu->addAction (a);
960 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
961 actionViewToggleAntiAlias=a;
963 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
964 a->setStatusTip (a->text());
965 a->setToggleAction(true);
966 a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
967 viewMenu->addAction (a);
968 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
969 actionViewToggleSmoothPixmapTransform=a;
971 a = new QAction(tr( "Next Window","View action" ), this);
972 a->setStatusTip (a->text());
973 a->setShortcut (Qt::ALT + Qt::Key_N );
974 viewMenu->addAction (a);
975 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
977 a = new QAction (tr( "Previous Window","View action" ), this );
978 a->setStatusTip (a->text());
979 a->setShortcut (Qt::ALT + Qt::Key_P );
980 viewMenu->addAction (a);
981 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
985 void Main::setupModeActions()
987 //QPopupMenu *menu = new QPopupMenu( this );
988 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
990 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
991 tb->setObjectName ("modesTB");
993 actionGroupModModes=new QActionGroup ( this);
994 actionGroupModModes->setExclusive (true);
995 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
996 a->setShortcut (Qt::Key_J);
997 a->setStatusTip ( tr( "Use modifier to color branches" ));
998 a->setToggleAction(true);
1001 actionModModeColor=a;
1003 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1004 a->setShortcut( Qt::Key_K);
1005 a->setStatusTip( tr( "Use modifier to copy" ));
1006 a->setToggleAction(true);
1008 actionModModeCopy=a;
1010 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1011 a->setShortcut (Qt::Key_L);
1012 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1013 a->setToggleAction(true);
1015 actionModModeXLink=a;
1019 void Main::setupFlagActions()
1021 // Create System Flags
1022 systemFlagsDefault = new FlagRowObj ();
1023 systemFlagsDefault->setVisibility (false);
1024 systemFlagsDefault->setName ("systemFlagsDef");
1026 FlagObj *fo = new FlagObj ();
1027 fo->load(QPixmap(flagsPath+"flag-note.png"));
1028 fo->setName("note");
1029 fo->setToolTip(tr("Note","Systemflag"));
1030 systemFlagsDefault->addFlag (fo); // makes deep copy
1032 fo->load(QPixmap(flagsPath+"flag-url.png"));
1034 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
1035 systemFlagsDefault->addFlag (fo);
1037 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1038 fo->setName("vymLink");
1039 fo->setToolTip(tr("Link to another vym map","Systemflag"));
1040 systemFlagsDefault->addFlag (fo);
1042 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1043 fo->setName("scrolledright");
1044 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
1045 systemFlagsDefault->addFlag (fo);
1047 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1048 fo->setName("tmpUnscrolledright");
1049 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
1050 systemFlagsDefault->addFlag (fo);
1052 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1053 fo->setName("hideInExport");
1054 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
1055 systemFlagsDefault->addFlag (fo);
1057 // Create Standard Flags
1058 QToolBar *tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1059 tb->setObjectName ("standardFlagTB");
1061 standardFlagsDefault = new FlagRowObj ();
1062 standardFlagsDefault->setVisibility (false);
1063 standardFlagsDefault->setName ("standardFlagsDef");
1064 standardFlagsDefault->setToolBar (tb);
1066 fo->load(flagsPath+"flag-exclamationmark.png");
1067 fo->setName ("exclamationmark");
1068 fo->setGroup("standard-mark");
1069 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1072 a->setCheckable(true);
1073 a->setObjectName(fo->getName());
1074 a->setToolTip(tr("Take care!","Standardflag"));
1075 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1076 standardFlagsDefault->addFlag (fo); // makes deep copy
1078 fo->load(flagsPath+"flag-questionmark.png");
1079 fo->setName("questionmark");
1080 fo->setGroup("standard-mark");
1081 a=new QAction (fo->getPixmap(),fo->getName(),this);
1084 a->setCheckable(true);
1085 a->setObjectName(fo->getName());
1086 a->setToolTip(tr("Really?","Standardflag"));
1087 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1088 standardFlagsDefault->addFlag (fo);
1090 fo->load(flagsPath+"flag-hook-green.png");
1091 fo->setName("hook-green");
1092 fo->setGroup("standard-hook");
1093 a=new QAction (fo->getPixmap(),fo->getName(),this);
1096 a->setCheckable(true);
1097 a->setObjectName(fo->getName());
1098 a->setToolTip(tr("ok!","Standardflag"));
1099 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1100 standardFlagsDefault->addFlag (fo);
1102 fo->load(flagsPath+"flag-cross-red.png");
1103 fo->setName("cross-red");
1104 fo->setGroup("standard-hook");
1105 a=new QAction (fo->getPixmap(),fo->getName(),this);
1108 a->setCheckable(true);
1109 a->setObjectName(fo->getName());
1110 a->setToolTip(tr("Not ok!","Standardflag"));
1111 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1112 standardFlagsDefault->addFlag (fo);
1114 fo->load(flagsPath+"flag-stopsign.png");
1115 fo->setName("stopsign");
1116 a=new QAction (fo->getPixmap(),fo->getName(),this);
1119 a->setCheckable(true);
1120 a->setObjectName(fo->getName());
1121 a->setToolTip(tr("This won't work!","Standardflag"));
1122 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1123 standardFlagsDefault->addFlag (fo);
1125 fo->load(flagsPath+"flag-smiley-good.png");
1126 fo->setName("smiley-good");
1127 fo->setGroup("standard-smiley");
1128 a=new QAction (fo->getPixmap(),fo->getName(),this);
1131 a->setCheckable(true);
1132 a->setObjectName(fo->getName());
1133 a->setToolTip(tr("Good","Standardflag"));
1134 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1135 standardFlagsDefault->addFlag (fo);
1137 fo->load(flagsPath+"flag-smiley-sad.png");
1138 fo->setName("smiley-sad");
1139 fo->setGroup("standard-smiley");
1140 a=new QAction (fo->getPixmap(),fo->getName(),this);
1143 a->setCheckable(true);
1144 a->setObjectName(fo->getName());
1145 a->setToolTip(tr("Bad","Standardflag"));
1146 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1147 standardFlagsDefault->addFlag (fo);
1149 fo->load(flagsPath+"flag-smiley-omg.png");
1150 // Original omg.png (in KDE emoticons)
1151 fo->setName("smiley-omg");
1152 fo->setGroup("standard-smiley");
1153 a=new QAction (fo->getPixmap(),fo->getName(),this);
1156 a->setCheckable(true);
1157 a->setObjectName(fo->getName());
1158 a->setToolTip(tr("Oh no!","Standardflag"));
1159 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1160 standardFlagsDefault->addFlag (fo);
1162 fo->load(flagsPath+"flag-kalarm.png");
1163 fo->setName("clock");
1164 a=new QAction (fo->getPixmap(),fo->getName(),this);
1167 a->setCheckable(true);
1168 a->setObjectName(fo->getName());
1169 a->setToolTip(tr("Time critical","Standardflag"));
1170 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1171 standardFlagsDefault->addFlag (fo);
1173 fo->load(flagsPath+"flag-phone.png");
1174 fo->setName("phone");
1175 a=new QAction (fo->getPixmap(),fo->getName(),this);
1178 a->setCheckable(true);
1179 a->setObjectName(fo->getName());
1180 a->setToolTip(tr("Call...","Standardflag"));
1181 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1182 standardFlagsDefault->addFlag (fo);
1184 fo->load(flagsPath+"flag-lamp.png");
1185 fo->setName("lamp");
1186 a=new QAction (fo->getPixmap(),fo->getName(),this);
1189 a->setCheckable(true);
1190 a->setObjectName(fo->getName());
1191 a->setToolTip(tr("Idea!","Standardflag"));
1192 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1193 standardFlagsDefault->addFlag (fo);
1195 fo->load(flagsPath+"flag-arrow-up.png");
1196 fo->setName("arrow-up");
1197 fo->setGroup("standard-arrow");
1198 a=new QAction (fo->getPixmap(),fo->getName(),this);
1201 a->setCheckable(true);
1202 a->setObjectName(fo->getName());
1203 a->setToolTip(tr("Important","Standardflag"));
1204 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1205 standardFlagsDefault->addFlag (fo);
1207 fo->load(flagsPath+"flag-arrow-down.png");
1208 fo->setName("arrow-down");
1209 fo->setGroup("standard-arrow");
1210 a=new QAction (fo->getPixmap(),fo->getName(),this);
1213 a->setCheckable(true);
1214 a->setObjectName(fo->getName());
1215 a->setToolTip(tr("Unimportant","Standardflag"));
1216 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1217 standardFlagsDefault->addFlag (fo);
1219 fo->load(flagsPath+"flag-arrow-2up.png");
1220 fo->setName("2arrow-up");
1221 fo->setGroup("standard-arrow");
1222 a=new QAction (fo->getPixmap(),fo->getName(),this);
1225 a->setCheckable(true);
1226 a->setObjectName(fo->getName());
1227 a->setToolTip(tr("Very important!","Standardflag"));
1228 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1229 standardFlagsDefault->addFlag (fo);
1231 fo->load(flagsPath+"flag-arrow-2down.png");
1232 fo->setName("2arrow-down");
1233 fo->setGroup("standard-arrow");
1234 a=new QAction (fo->getPixmap(),fo->getName(),this);
1237 a->setCheckable(true);
1238 a->setObjectName(fo->getName());
1239 a->setToolTip(tr("Very unimportant!","Standardflag"));
1240 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1241 standardFlagsDefault->addFlag (fo);
1243 fo->load(flagsPath+"flag-thumb-up.png");
1244 fo->setName("thumb-up");
1245 fo->setGroup("standard-thumb");
1246 a=new QAction (fo->getPixmap(),fo->getName(),this);
1249 a->setCheckable(true);
1250 a->setObjectName(fo->getName());
1251 a->setToolTip(tr("I like this","Standardflag"));
1252 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1253 standardFlagsDefault->addFlag (fo);
1255 fo->load(flagsPath+"flag-thumb-down.png");
1256 fo->setName("thumb-down");
1257 fo->setGroup("standard-thumb");
1258 a=new QAction (fo->getPixmap(),fo->getName(),this);
1261 a->setCheckable(true);
1262 a->setObjectName(fo->getName());
1263 a->setToolTip(tr("I do not like this","Standardflag"));
1264 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1265 standardFlagsDefault->addFlag (fo);
1267 fo->load(flagsPath+"flag-rose.png");
1268 fo->setName("rose");
1269 a=new QAction (fo->getPixmap(),fo->getName(),this);
1272 a->setCheckable(true);
1273 a->setObjectName(fo->getName());
1274 a->setToolTip(tr("Rose","Standardflag"));
1275 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1276 standardFlagsDefault->addFlag (fo);
1278 fo->load(flagsPath+"flag-heart.png");
1279 fo->setName("heart");
1280 a=new QAction (fo->getPixmap(),fo->getName(),this);
1282 a->setCheckable(true);
1283 a->setObjectName(fo->getName());
1284 a->setToolTip(tr("I just love... ","Standardflag"));
1285 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1286 standardFlagsDefault->addFlag (fo);
1288 fo->load(flagsPath+"flag-present.png");
1289 fo->setName("present");
1290 a=new QAction (fo->getPixmap(),fo->getName(),this);
1293 a->setCheckable(true);
1294 a->setObjectName(fo->getName());
1295 a->setToolTip(tr("Surprise!","Standardflag"));
1296 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1297 standardFlagsDefault->addFlag (fo);
1299 fo->load(flagsPath+"flag-flash.png");
1300 fo->setName("flash");
1301 a=new QAction (fo->getPixmap(),fo->getName(),this);
1304 a->setCheckable(true);
1305 a->setObjectName(fo->getName());
1306 a->setToolTip(tr("Dangerous","Standardflag"));
1307 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1308 standardFlagsDefault->addFlag (fo);
1310 fo->load(flagsPath+"flag-info.png");
1311 // Original: xsldbg_output.png
1312 fo->setName("info");
1313 a=new QAction (fo->getPixmap(),fo->getName(),this);
1316 a->setCheckable(true);
1317 a->setObjectName(fo->getName());
1318 a->setToolTip(tr("Info","Standardflag"));
1319 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1320 standardFlagsDefault->addFlag (fo);
1322 fo->load(flagsPath+"flag-lifebelt.png");
1323 // Original khelpcenter.png
1324 fo->setName("lifebelt");
1325 a=new QAction (fo->getPixmap(),fo->getName(),this);
1328 a->setCheckable(true);
1329 a->setObjectName(fo->getName());
1330 a->setToolTip(tr("This will help","Standardflag"));
1331 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1332 standardFlagsDefault->addFlag (fo);
1338 void Main::setupSettingsActions()
1340 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1344 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1345 a->setStatusTip ( tr( "Set application to open pdf files"));
1346 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1347 settingsMenu->addAction (a);
1349 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1350 a->setStatusTip( tr( "Set application to open external links"));
1351 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1352 settingsMenu->addAction (a);
1354 settingsMenu->addSeparator();
1355 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1356 a->setStatusTip( tr( "Edit branch after adding it" ));
1357 a->setToggleAction(true);
1358 a->setOn ( settings.value ("/mapeditor/editmode/autoEdit",true).toBool());
1359 settingsMenu->addAction (a);
1360 actionSettingsAutoEdit=a;
1362 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1363 a->setStatusTip( tr( "Select branch after adding it" ));
1364 a->setToggleAction(true);
1365 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectHeading",false).toBool() );
1366 settingsMenu->addAction (a);
1367 actionSettingsAutoSelectHeading=a;
1369 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1370 a->setStatusTip( tr( "Select heading before editing" ));
1371 a->setToggleAction(true);
1372 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1373 settingsMenu->addAction (a);
1374 actionSettingsAutoSelectText=a;
1376 a= new QAction( tr( "Delete key","Settings action" ), this);
1377 a->setStatusTip( tr( "Delete key for deleting branches" ));
1378 a->setToggleAction(true);
1379 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",false).toBool() );
1380 settingsMenu->addAction (a);
1381 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1382 actionSettingsUseDelKey=a;
1384 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1385 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1386 a->setToggleAction(true);
1387 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1388 settingsMenu->addAction (a);
1389 actionSettingsUseFlagGroups=a;
1391 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1392 a->setStatusTip( tr( "Use hide flag during exports " ));
1393 a->setToggleAction(true);
1394 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1395 settingsMenu->addAction (a);
1396 actionSettingsUseHideExport=a;
1400 void Main::setupTestActions()
1402 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1405 a = new QAction( "Test function" , this);
1406 a->setStatusTip( "Call test function" );
1407 a->setShortcut (Qt::Key_F4 );
1408 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction() ) );
1409 testMenu->addAction (a);
1410 a = new QAction( "Command" , this);
1411 a->setStatusTip( "Enter command to call in editor" );
1412 a->setShortcut (Qt::Key_F5 );
1413 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1414 testMenu->addAction (a);
1418 void Main::setupHelpActions()
1420 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1423 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1424 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1425 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1426 helpMenu->addAction (a);
1428 a = new QAction( tr( "About VYM","Help action" ), this);
1429 a->setStatusTip( tr( "About VYM")+vymName);
1430 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1431 helpMenu->addAction (a);
1433 a = new QAction( tr( "About QT","Help action" ), this);
1434 a->setStatusTip( tr( "Information about QT toolkit" ));
1435 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1436 helpMenu->addAction (a);
1440 void Main::setupContextMenus()
1444 // Context Menu for branch or mapcenter
1445 branchContextMenu =new QMenu (this);
1448 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1449 branchAddContextMenu->addAction (actionEditPaste );
1450 branchAddContextMenu->addAction ( actionEditAddBranch );
1451 branchAddContextMenu->addAction ( actionEditAddBranchBefore );
1452 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1453 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1454 branchAddContextMenu->addSeparator();
1455 branchAddContextMenu->addAction ( actionEditImportAdd );
1456 branchAddContextMenu->addAction ( actionEditImportReplace );
1459 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1460 branchRemoveContextMenu->addAction (actionEditCut);
1461 branchRemoveContextMenu->addAction ( actionEditDelete );
1462 branchRemoveContextMenu->addAction ( actionEditDeleteKeepChilds );
1463 branchRemoveContextMenu->addAction ( actionEditDeleteChilds );
1466 actionEditSaveBranch->addTo( branchContextMenu );
1468 branchContextMenu->addSeparator();
1469 branchContextMenu->addAction ( actionFormatFrameNone );
1470 branchContextMenu->addAction ( actionFormatFrameRectangle);
1471 branchContextMenu->addAction ( actionFormatHideLinkUnselected );
1473 branchContextMenu->addSeparator();
1474 branchContextMenu->addAction ( actionEditLoadImage);
1475 branchContextMenu->addAction ( actionFormatIncludeImagesVer );
1476 branchContextMenu->addAction ( actionFormatIncludeImagesHor );
1478 // Submenu for Links (URLs, vymLinks)
1479 branchLinksContextMenu =new QMenu (this);
1481 branchContextMenu->addSeparator();
1482 branchLinksContextMenu=branchContextMenu->addMenu(tr("URLs and vymLinks","Context menu name"));
1483 branchLinksContextMenu->addAction ( actionEditOpenURL );
1484 branchLinksContextMenu->addAction ( actionEditOpenURLTab );
1485 branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
1486 branchLinksContextMenu->addAction ( actionEditURL );
1487 branchLinksContextMenu->addAction ( actionEditHeading2URL );
1488 branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
1489 if (settings.value( "/mainwindow/showTestMenu",true).toBool() )
1491 branchLinksContextMenu->addAction ( actionEditFATE2URL );
1493 branchLinksContextMenu->addSeparator();
1494 branchLinksContextMenu->addAction ( actionEditOpenVymLink );
1495 branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
1496 branchLinksContextMenu->addAction ( actionEditVymLink );
1497 branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
1500 // Context Menu for XLinks in a branch menu
1501 // This will be populated "on demand" in MapEditor::updateActions
1502 branchContextMenu->addSeparator();
1503 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1504 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1505 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1506 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1509 // Context menu for floatimage
1510 floatimageContextMenu =new QMenu (this);
1511 a= new QAction (tr ("Save image","Context action"),this);
1512 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1513 floatimageContextMenu->addAction (a);
1515 floatimageContextMenu->addSeparator();
1516 actionEditCopy->addTo( floatimageContextMenu );
1517 actionEditCut->addTo( floatimageContextMenu );
1519 floatimageContextMenu->addSeparator();
1520 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1523 // Context menu for canvas
1524 canvasContextMenu =new QMenu (this);
1525 actionEditMapInfo->addTo( canvasContextMenu );
1526 canvasContextMenu->insertSeparator();
1527 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1528 canvasContextMenu->insertSeparator();
1529 actionFormatLinkColorHint->addTo( canvasContextMenu );
1530 actionFormatLinkColor->addTo( canvasContextMenu );
1531 actionFormatBackColor->addTo( canvasContextMenu );
1532 actionFormatBackImage->addTo( canvasContextMenu );
1534 // Menu for last opened files
1536 for (int i = 0; i < MaxRecentFiles; ++i)
1538 recentFileActs[i] = new QAction(this);
1539 recentFileActs[i]->setVisible(false);
1540 fileLastMapsMenu->addAction(recentFileActs[i]);
1541 connect(recentFileActs[i], SIGNAL(triggered()),
1542 this, SLOT(fileLoadRecent()));
1544 setupRecentMapsMenu();
1547 void Main::setupRecentMapsMenu()
1549 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1551 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1553 for (int i = 0; i < numRecentFiles; ++i) {
1554 //QString text = tr("&%1 %2").arg(i + 1).arg(strippedName(files[i]));
1555 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1556 recentFileActs[i]->setText(text);
1557 recentFileActs[i]->setData(files[i]);
1558 recentFileActs[i]->setVisible(true);
1560 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1561 recentFileActs[j]->setVisible(false);
1564 void Main::hideEvent (QHideEvent * )
1566 if (!textEditor->isMinimized() ) textEditor->hide();
1569 void Main::showEvent (QShowEvent * )
1571 if (textEditor->showWithMain()) textEditor->showNormal();
1574 bool Main::reallyWriteDirectory(const QString &dir)
1576 QStringList eList = QDir(dir).entryList();
1577 if (eList.first() ==".") eList.pop_front(); // remove "."
1578 if (eList.first() =="..") eList.pop_front(); // remove "."
1579 if (!eList.isEmpty())
1581 QMessageBox mb( vymName,
1582 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?","write directory").arg(dir),
1583 QMessageBox::Warning,
1585 QMessageBox::Cancel | QMessageBox::Default,
1586 QMessageBox::QMessageBox::NoButton );
1588 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1589 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1592 case QMessageBox::Yes:
1595 case QMessageBox::Cancel:
1603 QString Main::browseDirectory (const QString &caption)
1605 QFileDialog fd(this,caption);
1606 fd.setMode (QFileDialog::DirectoryOnly);
1607 fd.setCaption(vymName+ " - "+caption);
1610 if ( fd.exec() == QDialog::Accepted )
1611 return fd.selectedFile();
1616 MapEditor* Main::currentMapEditor() const
1618 if ( tabWidget->currentPage() &&
1619 tabWidget->currentPage()->inherits( "MapEditor" ) )
1620 return (MapEditor*)tabWidget->currentPage();
1625 void Main::editorChanged(QWidget *)
1627 // Unselect all possibly selected objects
1628 // (Important to update note editor)
1631 for (i=0;i<=tabWidget->count() -1;i++)
1634 me=(MapEditor*)tabWidget->page(i);
1637 currentMapEditor()->reselect();
1639 // Update actions to in menus and toolbars according to editor
1643 void Main::fileNew()
1645 QString fn="unnamed";
1646 MapEditor* me = new MapEditor ( NULL);
1647 tabWidget->addTab (me,fn);
1648 tabWidget->showPage(me);
1649 me->viewport()->setFocus();
1650 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1651 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1653 // For the very first map we do not have flagrows yet...
1657 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1659 ErrorCode err=success;
1661 // fn is usually the archive, mapfile the file after uncompressing
1664 // Make fn absolute (needed for unzip)
1665 fn=QDir (fn).absPath();
1671 // Check, if map is already loaded
1673 while (i<=tabWidget->count() -1)
1675 me=(MapEditor*)tabWidget->page(i);
1676 if (me->getFilePath() == fn)
1678 // Already there, ask for confirmation
1679 QMessageBox mb( vymName,
1680 tr("The map %1\nis already opened."
1681 "Opening the same map in multiple editors may lead \n"
1682 "to confusion when finishing working with vym."
1683 "Do you want to").arg(fn),
1684 QMessageBox::Warning,
1685 QMessageBox::Yes | QMessageBox::Default,
1686 QMessageBox::Cancel | QMessageBox::Escape,
1687 QMessageBox::NoButton);
1688 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1689 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1692 case QMessageBox::Yes:
1694 i=tabWidget->count();
1696 case QMessageBox::Cancel:
1708 if ( !fn.isEmpty() )
1710 me = currentMapEditor();
1711 int tabIndex=tabWidget->currentPageIndex();
1712 // Check first, if mapeditor exists
1713 // If it is not default AND we want a new map,
1714 // create a new mapeditor in a new tab
1715 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1717 me= new MapEditor ( NULL);
1718 tabWidget->addTab (me,fn);
1719 tabIndex=tabWidget->indexOf (me);
1720 tabWidget->setCurrentPage (tabIndex);
1721 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1722 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1725 // Check, if file exists (important for creating new files
1726 // from command line
1727 if (!QFile(fn).exists() )
1729 QMessageBox mb( vymName,
1730 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1731 QMessageBox::Question,
1733 QMessageBox::Cancel | QMessageBox::Default,
1734 QMessageBox::NoButton );
1736 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1737 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1740 case QMessageBox::Yes:
1742 currentMapEditor()->setFilePath(fn);
1743 tabWidget->setTabLabel (currentMapEditor(),
1744 currentMapEditor()->getFileName() );
1745 statusBar()->message( "Created " + fn , statusbarTime );
1748 case QMessageBox::Cancel:
1749 // don't create new map
1750 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1757 //tabWidget->currentPage() won't be NULL here, because of above...
1758 tabWidget->showPage(me);
1759 me->viewport()->setFocus();
1761 // Create temporary directory for packing
1763 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
1766 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1767 tr("Couldn't create temporary directory before load\n"));
1771 // Try to unzip file
1772 err=unzipDir (tmpMapDir,fn);
1776 me->setZipped(false);
1779 me->setZipped(true);
1781 // Look for mapname.xml
1782 mapfile= fn.left(fn.findRev(".",-1,true));
1783 mapfile=mapfile.section( '/', -1 );
1784 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1785 if (!file.exists() )
1787 // mapname.xml does not exist, well,
1788 // maybe some renamed the mapname.vym file...
1789 // Try to find any .xml in the toplevel
1790 // directory of the .vym file
1791 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1792 if (flist.count()==1)
1794 // Only one entry, take this one
1795 mapfile=tmpMapDir + "/"+flist.first();
1798 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1799 *it=tmpMapDir + "/" + *it;
1800 // TODO Multiple entries, load all (but only the first one into this ME)
1801 //mainWindow->fileLoadFromTmp (flist);
1802 //returnCode=1; // Silently forget this attempt to load
1803 qWarning ("MainWindow::load (fn) multimap found...");
1806 if (flist.isEmpty() )
1808 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1809 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1812 } //file doesn't exist
1814 mapfile=file.name();
1819 // Save existing filename in case we import
1820 QString fn_org=me->getFilePath();
1822 // Finally load map into mapEditor
1823 me->setFilePath (mapfile,fn);
1824 err=me->load(mapfile,lmode);
1826 // Restore old (maybe empty) filepath, if this is an import
1828 me->setFilePath (fn_org);
1831 // Finally check for errors and go home
1834 if (lmode==NewMap) fileCloseMap();
1835 statusBar()->message( "Could not load " + fn, statusbarTime );
1840 me->setFilePath (fn);
1841 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1842 if (fn.left(9)!="/tmp/vym-")
1844 // Only append to lastMaps if not loaded from a tmpDir
1845 // e.g. imported bookmarks are in a tmpDir
1846 addRecentMap(me->getFilePath() );
1848 actionFilePrint->setEnabled (true);
1850 statusBar()->message( "Loaded " + fn, statusbarTime );
1854 removeDir (QDir(tmpMapDir));
1860 void Main::fileLoad(const LoadMode &lmode)
1862 QStringList filters;
1863 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1864 QFileDialog *fd=new QFileDialog( this);
1865 fd->setDir (lastFileDir);
1866 fd->setFileMode (QFileDialog::ExistingFiles);
1867 fd->setFilters (filters);
1871 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1874 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1877 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1883 if ( fd->exec() == QDialog::Accepted )
1885 lastFileDir=fd->directory().path();
1886 QStringList flist = fd->selectedFiles();
1887 QStringList::Iterator it = flist.begin();
1888 while( it != flist.end() )
1891 fileLoad(*it, lmode);
1898 void Main::fileLoad()
1903 void Main::fileLoadRecent()
1905 QAction *action = qobject_cast<QAction *>(sender());
1907 fileLoad (action->data().toString(), NewMap);
1910 void Main::addRecentMap (const QString &fileName)
1913 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1914 files.removeAll(fileName);
1915 files.prepend(fileName);
1916 while (files.size() > MaxRecentFiles)
1919 settings.setValue("/mainwindow/recentFileList", files);
1921 setupRecentMapsMenu();
1924 void Main::fileSave(const SaveMode &savemode)
1926 // tmp dir for zipping
1930 ErrorCode err=success;
1932 QString safeFilePath;
1934 bool saveZipped=currentMapEditor()->saveZipped();
1936 MapEditor * me=currentMapEditor();
1939 QString fn=me->getFilePath();
1940 // filename=unnamed, filepath="" in constructor...
1941 if ( !fn.isEmpty() )
1943 // We have a filepath, go on saving
1944 // First remove existing file, we
1945 // don't want to add to old zip archives
1949 QMessageBox::warning( 0, tr( "Save Error" ),
1950 fn+ tr("\ncould not be removed before saving"));
1952 // Look, if we should zip the data:
1955 QMessageBox mb( vymName,
1956 tr("The map %1\ndid not use the compressed "
1957 "vym file format.\nWriting it uncompressed will also write images \n"
1958 "and flags and thus may overwrite files in the "
1959 "given directory\n\nDo you want to write the map").arg(fn),
1960 QMessageBox::Warning,
1961 QMessageBox::Yes | QMessageBox::Default,
1963 QMessageBox::Cancel | QMessageBox::Escape);
1964 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
1965 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
1966 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1969 case QMessageBox::Yes:
1970 // save compressed (default file format)
1973 case QMessageBox::No:
1974 // save uncompressed
1977 case QMessageBox::Cancel:
1986 // Create temporary directory for packing
1988 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
1991 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1992 tr("Couldn't create temporary directory before save\n"));
1996 safeFilePath=me->getFilePath();
1997 me->setFilePath (tmpMapDir+"/"+
1998 me->getMapName()+ ".xml",
2000 me->save (savemode);
2001 me->setFilePath (safeFilePath);
2003 zipDir (tmpMapDir,fn);
2008 safeFilePath=me->getFilePath();
2009 me->setFilePath (fn, safeFilePath);
2010 me->save (savemode);
2011 me->setFilePath (safeFilePath);
2013 } // filepath available
2016 // We have no filepath yet,
2017 // call fileSaveAs() now, this will call fileSave()
2019 fileSaveAs(savemode);
2023 if (saveZipped && !tmpMapDir.isEmpty())
2025 removeDir (QDir(tmpMapDir));
2029 statusBar()->message(
2030 tr("Saved %1").arg(me->getFilePath()),
2032 addRecentMap (me->getFilePath() );
2034 statusBar()->message(
2035 tr("Couldn't save ").arg(me->getFilePath()),
2039 void Main::fileSave()
2041 fileSave (CompleteMap);
2044 void Main::fileSaveAs(const SaveMode& savemode)
2048 if (currentMapEditor())
2050 if (savemode==CompleteMap)
2051 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2053 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2054 if ( !fn.isEmpty() )
2056 // Check for existing file
2057 if (QFile (fn).exists())
2059 QMessageBox mb( vymName,
2060 tr("The file %1\nexists already. Do you want to").arg(fn),
2061 QMessageBox::Warning,
2062 QMessageBox::Yes | QMessageBox::Default,
2063 QMessageBox::Cancel | QMessageBox::Escape,
2064 QMessageBox::NoButton);
2065 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2066 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2069 case QMessageBox::Yes:
2072 case QMessageBox::Cancel:
2079 // New file, add extension to filename, if missing
2080 // This is always .vym or .vyp, depending on savemode
2081 if (savemode==CompleteMap)
2083 if (!fn.contains (".vym") && !fn.contains (".xml"))
2087 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2096 currentMapEditor()->setFilePath(fn);
2100 if (savemode==CompleteMap)
2101 tabWidget->setTabLabel (currentMapEditor(),
2102 currentMapEditor()->getFileName() );
2108 void Main::fileSaveAs()
2110 fileSaveAs (CompleteMap);
2113 void Main::fileImportKDEBookmarks()
2115 ImportKDEBookmarks im;
2117 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2118 currentMapEditor()->setFilePath ("");
2121 void Main::fileImportFirefoxBookmarks()
2123 Q3FileDialog *fd=new Q3FileDialog( this);
2124 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2125 fd->setMode (Q3FileDialog::ExistingFiles);
2126 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2127 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2130 if ( fd->exec() == QDialog::Accepted )
2132 ImportFirefoxBookmarks im;
2133 QStringList flist = fd->selectedFiles();
2134 QStringList::Iterator it = flist.begin();
2135 while( it != flist.end() )
2138 if (im.transform() &&
2139 success==fileLoad (im.getTransformedFile(),NewMap) &&
2140 currentMapEditor() )
2141 currentMapEditor()->setFilePath ("");
2148 void Main::fileImportMM()
2152 Q3FileDialog *fd=new Q3FileDialog( this);
2153 fd->setDir (lastFileDir);
2154 fd->setMode (Q3FileDialog::ExistingFiles);
2155 fd->addFilter ("Mind Manager (*.mmap)");
2156 fd->setCaption(tr("Import")+" "+"Mind Manager");
2159 if ( fd->exec() == QDialog::Accepted )
2161 lastFileDir=fd->dirPath();
2162 QStringList flist = fd->selectedFiles();
2163 QStringList::Iterator it = flist.begin();
2164 while( it != flist.end() )
2167 if (im.transform() &&
2168 success==fileLoad (im.getTransformedFile(),NewMap) &&
2169 currentMapEditor() )
2170 currentMapEditor()->setFilePath ("");
2179 void Main::fileImportDir()
2181 if (currentMapEditor())
2182 currentMapEditor()->importDir();
2185 void Main::fileExportXML()
2187 if (currentMapEditor())
2189 QString dir=browseDirectory(tr("Export XML to directory"));
2190 if (dir !="" && reallyWriteDirectory(dir) )
2191 currentMapEditor()->exportXML(dir);
2196 void Main::fileExportXHTML()
2198 MapEditor *me=currentMapEditor();
2202 ExportXHTMLDialog dia(this);
2203 dia.setFilePath (me->getFilePath() );
2204 dia.setMapName (me->getMapName() );
2207 if (dia.exec()==QDialog::Accepted)
2209 QString dir=dia.getDir();
2210 // Check, if warnings should be used before overwriting
2211 // the output directory
2214 ok=reallyWriteDirectory(dir);
2220 me->exportXML (dia.getDir() );
2221 dia.doExport(me->getMapName() );
2222 if (dia.hasChanged())
2229 void Main::fileExportImage()
2231 MapEditor *me=currentMapEditor();
2235 QFileDialog *fd=new QFileDialog (this);
2236 fd->setCaption (tr("Export map as image"));
2237 fd->setFileMode(QFileDialog::AnyFile);
2238 fd->setFilters (imageIO.getFilters() );
2239 fd->setDirectory (lastImageDir);
2242 fl=fd->selectedFiles();
2243 qWarning ("Selected "+fl.first()+" filter: "+fd->selectedFilter());
2244 me->exportImage (fl.first(), imageIO.getType (fd->selectedFilter() ) );
2249 void Main::fileExportASCII()
2251 MapEditor *me=currentMapEditor();
2255 ex.setMapCenter(me->getMapCenter());
2256 ex.addFilter ("TXT (*.txt)");
2257 ex.setCaption(vymName+ " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
2258 if (ex.execDialog() )
2260 me->setExportMode(true);
2262 me->setExportMode(false);
2267 void Main::fileExportLaTeX()
2269 MapEditor *me=currentMapEditor();
2273 ex.setMapCenter(me->getMapCenter());
2274 ex.addFilter ("Tex (*.tex)");
2275 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2276 if (ex.execDialog() )
2278 me->setExportMode(true);
2280 me->setExportMode(false);
2285 void Main::fileExportKDEBookmarks()
2287 ExportKDEBookmarks ex;
2288 MapEditor *me=currentMapEditor();
2291 ex.setMapCenter (me->getMapCenter() );
2296 void Main::fileExportTaskjuggler()
2298 ExportTaskjuggler ex;
2299 MapEditor *me=currentMapEditor();
2302 ex.setMapCenter (me->getMapCenter() );
2303 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2304 ex.addFilter ("Taskjuggler (*.tjp)");
2305 if (ex.execDialog() )
2307 me->setExportMode(true);
2309 me->setExportMode(false);
2314 void Main::fileExportOOPresentation()
2316 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2317 // TODO add preview in dialog
2318 //ImagePreview *p =new ImagePreview (fd);
2319 //fd->setContentsPreviewEnabled( TRUE );
2320 //fd->setContentsPreview( p, p );
2321 //fd->setPreviewMode( QFileDialog::Contents );
2322 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2323 fd->setDir (QDir().current());
2324 if (fd->foundConfig())
2328 if ( fd->exec() == QDialog::Accepted )
2330 QString fn=fd->selectedFile();
2331 if (!fn.contains (".odp"))
2334 //lastImageDir=fn.left(fn.findRev ("/"));
2335 if (currentMapEditor())
2336 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2340 QMessageBox::warning(0,
2342 tr("Couldn't find configuration for export to Open Office\n"));
2346 void Main::fileCloseMap()
2348 if (currentMapEditor())
2350 if (currentMapEditor()->hasChanged())
2352 QMessageBox mb( vymName,
2353 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2354 QMessageBox::Warning,
2355 QMessageBox::Yes | QMessageBox::Default,
2357 QMessageBox::Cancel | QMessageBox::Escape );
2358 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2359 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2362 case QMessageBox::Yes:
2364 fileSave(CompleteMap);
2366 case QMessageBox::No:
2367 // close without saving
2369 case QMessageBox::Cancel:
2374 currentMapEditor()->closeMap();
2375 tabWidget->removePage(currentMapEditor());
2376 if (tabWidget->count()==0)
2377 actionFilePrint->setEnabled (false);
2381 void Main::filePrint()
2383 if (currentMapEditor())
2384 currentMapEditor()->print();
2387 void Main::fileExitVYM()
2389 // Check if one or more editors have changed
2392 for (i=0;i<=tabWidget->count() -1;i++)
2395 me=(MapEditor*)tabWidget->page(i);
2397 // If something changed, ask what to do
2398 if (me->isUnsaved())
2400 tabWidget->setCurrentPage(i);
2401 QMessageBox mb( vymName,
2402 tr("This map is not saved yet. Do you want to"),
2403 QMessageBox::Warning,
2404 QMessageBox::Yes | QMessageBox::Default,
2406 QMessageBox::Cancel | QMessageBox::Escape );
2407 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2408 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2411 mb.setActiveWindow();
2412 switch( mb.exec() ) {
2413 case QMessageBox::Yes:
2414 // save (the changed editors) and exit
2415 fileSave(CompleteMap);
2417 case QMessageBox::No:
2418 // exit without saving
2420 case QMessageBox::Cancel:
2421 // don't save and don't exit
2425 } // loop over all MEs
2429 void Main::editUndo()
2431 if (currentMapEditor())
2432 currentMapEditor()->undo();
2435 void Main::editRedo()
2437 if (currentMapEditor())
2438 currentMapEditor()->redo();
2441 void Main::gotoHistoryStep (int i)
2443 if (currentMapEditor())
2444 currentMapEditor()->gotoHistoryStep (i);
2447 void Main::editCopy()
2449 if (currentMapEditor())
2450 currentMapEditor()->copy();
2453 void Main::editPaste()
2455 if (currentMapEditor())
2456 currentMapEditor()->paste();
2459 void Main::editCut()
2461 if (currentMapEditor())
2462 currentMapEditor()->cut();
2465 void Main::editOpenFindWindow()
2467 findWindow->popup();
2468 findWindow->raise();
2469 findWindow->setActiveWindow();
2472 void Main::editFind(QString s)
2475 BranchObj *bo=currentMapEditor()->findText(s, cs);
2478 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2481 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2482 tr("No matches found for \"%1\"").arg(s));
2486 void Main::editFindChanged()
2487 { // Notify editor, to abort the current find process
2488 currentMapEditor()->findReset();
2491 void Main::openTabs(QStringList urls)
2493 if (!urls.isEmpty())
2497 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2499 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2501 QString u=urls.takeFirst();
2502 procBrowser = new QProcess( this );
2504 procBrowser->start(browser,args);
2505 if ( !procBrowser->waitForStarted())
2507 // try to set path to browser
2508 QMessageBox::warning(0,
2510 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2511 tr("Please use Settings->")+tr("Set application to open an URL"));
2516 if (browser.contains("konqueror"))
2518 for (int i=0; i<urls.size(); i++)
2521 // Try to open new tab in existing konqueror started previously by vym
2522 p=new QProcess (this);
2524 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2525 "konqueror-mainwindow#1"<<
2528 p->start ("dcop",args);
2529 if ( !p->waitForStarted() ) success=false;
2532 QMessageBox::warning(0,
2534 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2536 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2538 for (int i=0; i<urls.size(); i++)
2540 // Try to open new tab in firefox
2541 p=new QProcess (this);
2542 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2543 p->start (browser,args);
2544 if ( !p->waitForStarted() ) success=false;
2547 QMessageBox::warning(0,
2549 tr("Couldn't start %1 to open a new tab").arg(browser));
2552 QMessageBox::warning(0,
2554 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2558 void Main::editOpenURL()
2561 if (currentMapEditor())
2563 QString url=currentMapEditor()->getURL();
2565 if (url=="") return;
2566 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2567 procBrowser = new QProcess( this );
2569 procBrowser->start(browser,args);
2570 if ( !procBrowser->waitForStarted())
2572 // try to set path to browser
2573 QMessageBox::warning(0,
2575 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2576 tr("Please use Settings->")+tr("Set application to open an URL"));
2581 void Main::editOpenURLTab()
2583 if (currentMapEditor())
2586 urls.append(currentMapEditor()->getURL());
2590 void Main::editOpenMultipleURLTabs()
2592 if (currentMapEditor())
2595 urls=currentMapEditor()->getURLs();
2601 void Main::editURL()
2603 if (currentMapEditor())
2604 currentMapEditor()->editURL();
2607 void Main::editHeading2URL()
2609 if (currentMapEditor())
2610 currentMapEditor()->editHeading2URL();
2613 void Main::editBugzilla2URL()
2615 if (currentMapEditor())
2616 currentMapEditor()->editBugzilla2URL();
2619 void Main::editFATE2URL()
2621 if (currentMapEditor())
2622 currentMapEditor()->editFATE2URL();
2625 void Main::editHeadingFinished()
2627 // only called from editHeading(), so there is a currentME
2628 MapEditor *me=currentMapEditor();
2630 #if defined(Q_OS_MACX)
2632 me->setHeading(lineedit->text());
2634 lineedit->releaseKeyboard();
2638 if (!prevSelection.isEmpty()) me->select(prevSelection);
2642 void Main::editHeading()
2644 if (currentMapEditor())
2646 MapEditor *me=currentMapEditor();
2647 QString oldSel=me->getSelectString();
2649 if (lineedit->isVisible())
2650 editHeadingFinished();
2655 QString s=currentMapEditor()->getHeading(ok,p);
2659 #if defined(Q_OS_MACX)
2660 p=currentMapEditor()->mapTo (this,p);
2661 QDialog *d =new QDialog(NULL);
2662 QLineEdit *le=new QLineEdit (d);
2663 d->setWindowFlags (Qt::FramelessWindowHint);
2664 d->setGeometry(p.x(),p.y(),230,25);
2665 le->resize (d->width()-10,d->height());
2668 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2669 d->activateWindow();
2671 currentMapEditor()->setHeading (le->text());
2674 editHeadingFinished();
2676 p=currentMapEditor()->mapTo (this,p);
2677 lineedit->setGeometry(p.x(),p.y(),230,25);
2678 lineedit->setText(s);
2679 lineedit->setCursorPosition(1);
2680 lineedit->selectAll();
2682 lineedit->grabKeyboard();
2683 lineedit->setFocus();
2687 } // currentMapEditor()
2690 void Main::openVymLinks(const QStringList &vl)
2692 for (int j=0; j<vl.size(); j++)
2694 // compare path with already loaded maps
2698 for (i=0;i<=tabWidget->count() -1;i++)
2700 me=(MapEditor*)tabWidget->page(i);
2701 if (vl.at(j)==me->getFilePath() )
2710 if (!QFile(vl.at(j)).exists() )
2711 QMessageBox::critical( 0, tr( "Critical Error" ),
2712 tr("Couldn't open map %1").arg(vl.at(j)));
2715 fileLoad (vl.at(j), NewMap);
2716 tabWidget->setCurrentPage (tabWidget->count()-1);
2719 // Go to tab containing the map
2720 tabWidget->setCurrentPage (index);
2724 void Main::editOpenVymLink()
2726 if (currentMapEditor())
2729 vl.append(currentMapEditor()->getVymLink());
2734 void Main::editOpenMultipleVymLinks()
2736 QString currentVymLink;
2737 if (currentMapEditor())
2739 QStringList vl=currentMapEditor()->getVymLinks();
2744 void Main::editVymLink()
2746 if (currentMapEditor())
2747 currentMapEditor()->editVymLink();
2750 void Main::editDeleteVymLink()
2752 if (currentMapEditor())
2753 currentMapEditor()->deleteVymLink();
2756 void Main::editToggleHideExport()
2758 if (currentMapEditor())
2759 currentMapEditor()->toggleHideExport();
2762 void Main::editMapInfo()
2764 if (currentMapEditor())
2765 currentMapEditor()->editMapInfo();
2768 void Main::editMoveUp()
2770 if (currentMapEditor())
2771 currentMapEditor()->moveBranchUp();
2774 void Main::editMoveDown()
2776 if (currentMapEditor())
2777 currentMapEditor()->moveBranchDown();
2780 void Main::editToggleScroll()
2782 if (currentMapEditor())
2784 currentMapEditor()->toggleScroll();
2788 void Main::editUnScrollAll()
2790 if (currentMapEditor())
2791 currentMapEditor()->unScrollAll();
2794 void Main::editNewBranch()
2796 MapEditor *me=currentMapEditor();
2797 if (!lineedit->isVisible() && me)
2799 BranchObj *bo=(BranchObj*)me->getSelection();
2800 BranchObj *newbo=me->addNewBranch(0);
2803 me->select (newbo->getSelectString());
2807 if (actionSettingsAutoEdit->isOn())
2809 if (!actionSettingsAutoSelectHeading->isOn())
2810 prevSelection=bo->getSelectString();
2816 void Main::editNewBranchBefore()
2818 MapEditor *me=currentMapEditor();
2819 if (!lineedit->isVisible() && me)
2821 BranchObj *bo=(BranchObj*)me->getSelection();
2822 BranchObj *newbo=me->addNewBranchBefore();
2825 me->select (newbo->getSelectString());
2829 if (actionSettingsAutoEdit->isOn())
2831 if (!actionSettingsAutoSelectHeading->isOn())
2832 prevSelection=bo->getSelectString();
2838 void Main::editNewBranchAbove()
2840 MapEditor *me=currentMapEditor();
2841 if (!lineedit->isVisible() && me)
2843 BranchObj *bo=(BranchObj*)me->getSelection();
2844 BranchObj *newbo=me->addNewBranch (-1);
2847 me->select (newbo->getSelectString());
2851 if (actionSettingsAutoEdit->isOn())
2853 if (!actionSettingsAutoSelectHeading->isOn())
2854 prevSelection=bo->getSelectString();
2860 void Main::editNewBranchBelow()
2862 MapEditor *me=currentMapEditor();
2863 if (!lineedit->isVisible() && me)
2865 BranchObj *bo=(BranchObj*)me->getSelection();
2866 BranchObj *newbo=me->addNewBranch (1);
2869 me->select (newbo->getSelectString());
2873 if (actionSettingsAutoEdit->isOn())
2875 if (!actionSettingsAutoSelectHeading->isOn())
2876 prevSelection=bo->getSelectString();
2882 void Main::editImportAdd()
2884 fileLoad (ImportAdd);
2887 void Main::editImportReplace()
2889 fileLoad (ImportReplace);
2892 void Main::editSaveBranch()
2894 fileSaveAs (PartOfMap);
2897 void Main::editDeleteKeepChilds()
2899 if (currentMapEditor())
2900 currentMapEditor()->deleteKeepChilds();
2903 void Main::editDeleteChilds()
2905 if (currentMapEditor())
2906 currentMapEditor()->deleteChilds();
2909 void Main::editDeleteSelection()
2911 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2912 currentMapEditor()->deleteSelection();
2915 void Main::editUpperBranch()
2917 if (currentMapEditor())
2918 currentMapEditor()->selectUpperBranch();
2921 void Main::editLowerBranch()
2923 if (currentMapEditor())
2924 currentMapEditor()->selectLowerBranch();
2927 void Main::editLeftBranch()
2929 if (currentMapEditor())
2930 currentMapEditor()->selectLeftBranch();
2933 void Main::editRightBranch()
2935 if (currentMapEditor())
2936 currentMapEditor()->selectRightBranch();
2939 void Main::editFirstBranch()
2941 if (currentMapEditor())
2942 currentMapEditor()->selectFirstBranch();
2945 void Main::editLastBranch()
2947 if (currentMapEditor())
2948 currentMapEditor()->selectLastBranch();
2951 void Main::editLoadImage()
2953 if (currentMapEditor())
2954 currentMapEditor()->loadFloatImage();
2957 void Main::editSaveImage()
2959 if (currentMapEditor())
2960 currentMapEditor()->saveFloatImage();
2963 void Main::editFollowXLink(QAction *a)
2966 if (currentMapEditor())
2967 currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
2970 void Main::editEditXLink(QAction *a)
2972 if (currentMapEditor())
2973 currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
2976 void Main::formatSelectColor()
2978 if (currentMapEditor())
2980 QColor col = QColorDialog::getColor((currentColor ), this );
2981 if ( !col.isValid() ) return;
2982 colorChanged( col );
2986 void Main::formatPickColor()
2988 if (currentMapEditor())
2989 colorChanged( currentMapEditor()->getCurrentHeadingColor() );
2992 void Main::colorChanged(QColor c)
2994 QPixmap pix( 16, 16 );
2996 actionFormatColor->setIconSet( pix );
3000 void Main::formatColorItem()
3002 if (currentMapEditor())
3003 currentMapEditor()->colorItem(currentColor);
3006 void Main::formatColorBranch()
3008 if (currentMapEditor())
3009 currentMapEditor()->colorBranch(currentColor);
3012 void Main::formatLinkStyleLine()
3014 if (currentMapEditor())
3015 currentMapEditor()->setMapLinkStyle("StyleLine");
3018 void Main::formatLinkStyleParabel()
3020 if (currentMapEditor())
3021 currentMapEditor()->setMapLinkStyle("StyleParabel");
3024 void Main::formatLinkStylePolyLine()
3026 if (currentMapEditor())
3027 currentMapEditor()->setMapLinkStyle("StylePolyLine");
3030 void Main::formatLinkStylePolyParabel()
3032 if (currentMapEditor())
3033 currentMapEditor()->setMapLinkStyle("StylePolyParabel");
3036 void Main::formatSelectBackColor()
3038 if (currentMapEditor())
3039 currentMapEditor()->selectMapBackgroundColor();
3042 void Main::formatSelectBackImage()
3044 if (currentMapEditor())
3045 currentMapEditor()->selectMapBackgroundImage();
3048 void Main::formatSelectLinkColor()
3050 if (currentMapEditor())
3051 currentMapEditor()->selectMapLinkColor();
3054 void Main::formatToggleLinkColorHint()
3056 currentMapEditor()->toggleMapLinkColorHint();
3059 void Main::formatFrameNone()
3061 if (currentMapEditor())
3062 currentMapEditor()->setFrame(NoFrame);
3065 void Main::formatFrameRectangle()
3067 if (currentMapEditor())
3068 currentMapEditor()->setFrame(Rectangle);
3071 void Main::formatIncludeImagesVer()
3073 if (currentMapEditor())
3074 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
3077 void Main::formatIncludeImagesHor()
3079 if (currentMapEditor())
3080 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
3083 void Main::formatHideLinkUnselected()
3085 if (currentMapEditor())
3086 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3089 void Main::viewZoomReset()
3091 if (currentMapEditor())
3095 currentMapEditor()->setMatrix( m );
3096 currentMapEditor()->setViewCenter();
3100 void Main::viewZoomIn()
3102 if (currentMapEditor())
3104 QMatrix m = currentMapEditor()->matrix();
3105 m.scale( 1.25, 1.25 );
3106 currentMapEditor()->setMatrix( m );
3107 currentMapEditor()->setViewCenter();
3111 void Main::viewZoomOut()
3113 if (currentMapEditor())
3115 QMatrix m = currentMapEditor()->matrix();
3116 m.scale( 0.8, 0.8 );
3117 currentMapEditor()->setMatrix( m );
3118 currentMapEditor()->setViewCenter();
3122 bool Main::settingsPDF()
3124 // Default browser is set in constructor
3126 QString text = QInputDialog::getText(
3127 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3128 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3130 settings.setValue ("/mainwindow/readerPDF",text);
3135 bool Main::settingsURL()
3137 // Default browser is set in constructor
3139 QString text = QInputDialog::getText(
3140 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3141 settings.value("/mainwindow/readerURL").toString()
3144 settings.setValue ("/mainwindow/readerURL",text);
3148 void Main::settingsToggleDelKey()
3150 if (actionSettingsUseDelKey->isOn())
3152 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3155 actionEditDelete->setAccel (QKeySequence (""));
3159 void Main::windowToggleNoteEditor()
3161 if (textEditor->showWithMain() )
3162 windowHideNoteEditor();
3164 windowShowNoteEditor();
3167 void Main::windowToggleHistory()
3169 if (historyWindow->isVisible())
3170 historyWindow->hide();
3172 historyWindow->show();
3176 void Main::windowToggleAntiAlias()
3178 bool b=actionViewToggleAntiAlias->isOn();
3180 for (int i=0;i<tabWidget->count();i++)
3183 me=(MapEditor*)tabWidget->page(i);
3184 me->setAntiAlias(b);
3189 void Main::windowToggleSmoothPixmap()
3191 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3193 for (int i=0;i<tabWidget->count();i++)
3196 me=(MapEditor*)tabWidget->page(i);
3197 me->setSmoothPixmap(b);
3201 void Main::updateHistory(SimpleSettings &undoSet)
3203 historyWindow->update (undoSet);
3206 void Main::updateNoteFlag()
3208 if (currentMapEditor())
3209 currentMapEditor()->updateNoteFlag();
3212 void Main::updateActions()
3214 MapEditor *me=currentMapEditor();
3217 historyWindow->setCaption (tr("History for %1").arg(currentMapEditor()->getFileName()));
3219 // updateActions is also called when NoteEditor is closed
3220 actionViewToggleNoteEditor->setOn (textEditor->showWithMain());
3222 if (me->getMapLinkColorHint()==HeadingColor)
3223 actionFormatLinkColorHint->setOn(true);
3225 actionFormatLinkColorHint->setOn(false);
3227 switch (me->getMapLinkStyle())
3230 actionFormatLinkStyleLine->setOn(true);
3233 actionFormatLinkStyleParabel->setOn(true);
3236 actionFormatLinkStylePolyLine->setOn(true);
3238 case StylePolyParabel:
3239 actionFormatLinkStylePolyParabel->setOn(true);
3245 QPixmap pix( 16, 16 );
3246 pix.fill( me->getMapBackgroundColor() );
3247 actionFormatBackColor->setIconSet( pix );
3248 pix.fill( me->getMapDefLinkColor() );
3249 actionFormatLinkColor->setIconSet( pix );
3251 actionFileSave->setEnabled( me->isUnsaved() );
3252 if (me->isUndoAvailable())
3253 actionEditUndo->setEnabled( true);
3255 actionEditUndo->setEnabled( false);
3257 if (me->isRedoAvailable())
3258 actionEditRedo->setEnabled( true);
3260 actionEditRedo->setEnabled( false);
3262 LinkableMapObj *selection=me->getSelection();
3265 if ( (typeid(*selection) == typeid(BranchObj)) ||
3266 (typeid(*selection) == typeid(MapCenterObj)) )
3268 BranchObj *bo=(BranchObj*)selection;
3269 // Take care of links
3270 if (bo->countXLinks()==0)
3272 branchXLinksContextMenuEdit->clear();
3273 branchXLinksContextMenuFollow->clear();
3278 branchXLinksContextMenuEdit->clear();
3279 branchXLinksContextMenuFollow->clear();
3280 for (int i=0; i<=bo->countXLinks();i++)
3282 bot=bo->XLinkTargetAt(i);
3285 s=bot->getHeading();
3288 branchXLinksContextMenuFollow->addAction (s);
3289 branchXLinksContextMenuEdit->addAction (s);
3294 standardFlagsDefault->setEnabled (true);
3296 actionEditToggleScroll->setEnabled (true);
3297 if ( bo->isScrolled() )
3298 actionEditToggleScroll->setOn(true);
3300 actionEditToggleScroll->setOn(false);
3302 if ( bo->getURL().isEmpty() )
3304 actionEditOpenURL->setEnabled (false);
3305 actionEditOpenURLTab->setEnabled (false);
3309 actionEditOpenURL->setEnabled (true);
3310 actionEditOpenURLTab->setEnabled (true);
3312 if ( bo->getVymLink().isEmpty() )
3314 actionEditOpenVymLink->setEnabled (false);
3315 actionEditDeleteVymLink->setEnabled (false);
3318 actionEditOpenVymLink->setEnabled (true);
3319 actionEditDeleteVymLink->setEnabled (true);
3322 if (bo->canMoveBranchUp())
3323 actionEditMoveUp->setEnabled (true);
3325 actionEditMoveUp->setEnabled (false);
3326 if (bo->canMoveBranchDown())
3327 actionEditMoveDown->setEnabled (true);
3329 actionEditMoveDown->setEnabled (false);
3332 actionEditToggleHideExport->setEnabled (true);
3333 actionEditToggleHideExport->setOn (bo->hideInExport() );
3335 actionEditCopy->setEnabled (true);
3336 actionEditCut->setEnabled (true);
3337 if (!clipboardEmpty)
3338 actionEditPaste->setEnabled (true);
3340 actionEditPaste->setEnabled (false);
3341 for (int i=0; i<actionListBranches.size(); ++i)
3342 actionListBranches.at(i)->setEnabled(true);
3343 actionEditDelete->setEnabled (true);
3344 switch (selection->getFrameType())
3347 actionFormatFrameNone->setOn(true);
3350 actionFormatFrameRectangle->setOn(true);
3355 actionFormatIncludeImagesVer->setOn
3356 ( ((BranchObj*)selection)->getIncludeImagesVer());
3357 actionFormatIncludeImagesHor->setOn
3358 ( ((BranchObj*)selection)->getIncludeImagesHor());
3359 actionFormatHideLinkUnselected->setOn
3360 (selection->getHideLinkUnselected());
3362 if ( (typeid(*selection) == typeid(FloatImageObj)) )
3364 FloatObj *fo=(FloatImageObj*)selection;
3366 actionEditOpenURL->setEnabled (false);
3367 actionEditOpenVymLink->setEnabled (false);
3368 actionEditDeleteVymLink->setEnabled (false);
3369 actionEditToggleHideExport->setEnabled (true);
3370 actionEditToggleHideExport->setOn (fo->hideInExport() );
3373 actionEditCopy->setEnabled (true);
3374 actionEditCut->setEnabled (true);
3375 actionEditPaste->setEnabled (false);
3376 for (int i=0; i<actionListBranches.size(); ++i)
3377 actionListBranches.at(i)->setEnabled(false);
3378 actionEditDelete->setEnabled (true);
3379 actionFormatHideLinkUnselected->setOn
3380 ( selection->getHideLinkUnselected());
3381 actionEditMoveUp->setEnabled (false);
3382 actionEditMoveDown->setEnabled (false);
3387 actionEditCopy->setEnabled (false);
3388 actionEditCut->setEnabled (false);
3389 actionEditPaste->setEnabled (false);
3390 for (int i=0; i<actionListBranches.size(); ++i)
3391 actionListBranches.at(i)->setEnabled(false);
3393 actionEditToggleScroll->setEnabled (false);
3394 actionEditOpenURL->setEnabled (false);
3395 actionEditOpenVymLink->setEnabled (false);
3396 actionEditDeleteVymLink->setEnabled (false);
3397 actionEditHeading2URL->setEnabled (false);
3398 actionEditDelete->setEnabled (false);
3399 actionEditMoveUp->setEnabled (false);
3400 actionEditMoveDown->setEnabled (false);
3401 actionEditToggleHideExport->setEnabled (false);
3405 ModMode Main::getModMode()
3407 if (actionModModeColor->isOn()) return ModModeColor;
3408 if (actionModModeCopy->isOn()) return ModModeCopy;
3409 if (actionModModeXLink->isOn()) return ModModeXLink;
3413 bool Main::autoEdit()
3415 return actionSettingsAutoEdit->isOn();
3418 bool Main::autoSelectHeading()
3420 return actionSettingsAutoSelectHeading->isOn();
3423 bool Main::useFlagGroups()
3425 return actionSettingsUseFlagGroups->isOn();
3428 void Main::windowShowNoteEditor()
3430 textEditor->setShowWithMain(true);
3432 actionViewToggleNoteEditor->setOn (true);
3435 void Main::windowHideNoteEditor()
3437 textEditor->setShowWithMain(false);
3439 actionViewToggleNoteEditor->setOn (false);
3442 void Main::windowNextEditor()
3444 if (tabWidget->currentPageIndex() < tabWidget->count())
3445 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3448 void Main::windowPreviousEditor()
3450 if (tabWidget->currentPageIndex() >0)
3451 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3454 void Main::standardFlagChanged()
3456 currentMapEditor()->toggleStandardFlag(sender()->name());
3459 void Main::testFunction()
3461 if (!currentMapEditor()) return;
3462 currentMapEditor()->testFunction();
3465 void Main::testCommand()
3467 if (!currentMapEditor()) return;
3469 QString com = QInputDialog::getText(
3470 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3471 if (ok) currentMapEditor()->parseAtom(com);
3474 void Main::helpDoc()
3476 QString locale = QLocale::system().name();
3478 if (locale.left(2)=="es")
3479 docname="vym_es.pdf";
3483 #if defined(Q_OS_MACX)
3484 docdir.setPath("./vym.app/Contents");
3486 // default path in SUSE LINUX
3487 docdir.setPath("/usr/share/doc/packages/vym/doc");
3490 if (!docdir.exists() )
3492 // relative path for easy testing in tarball
3493 docdir.setPath("doc");
3494 if (!docdir.exists() )
3496 // relative path for testing while still writing vym.tex
3497 docdir.setPath("doc/tex/vym.pdf");
3498 if (!docdir.exists() )
3500 // Try yet another one for Knoppix
3501 docdir.setPath("/usr/share/doc/packages/vym");
3502 if (!docdir.exists() )
3504 QMessageBox::critical(0,
3505 tr("Critcal error"),
3506 tr("Couldn't find the documentation\n"
3507 "vym.pdf in various directories."));
3514 QString docpath=docdir.path()+"/"+docname;
3516 Process *pdfProc = new Process();
3519 pdfProc->start( settings.value("/mainwindow/readerPDF").toString());
3520 if ( !pdfProc->waitForStarted() )
3523 QMessageBox::warning(0,
3525 tr("Couldn't find a viewer to open %1.\n").arg(docpath)+
3526 tr("Please use Settings->")+tr("Set application to open PDF files"));
3533 void Main::helpAbout()
3536 ad.setName ("aboutwindow");
3537 ad.setMinimumSize(500,500);
3538 ad.resize (QSize (500,500));
3542 void Main::helpAboutQT()
3544 QMessageBox::aboutQt( this, "Qt Application Example" );