Spanish doc is found, if LANG is set. Fixed wrong position of floatimages
1 #include "mainwindow.h"
5 #include <q3filedialog.h>
13 #include "aboutdialog.h"
14 #include "exportoofiledialog.h"
16 #include "exportxhtmldialog.h"
18 #include "flagrowobj.h"
19 #include "historywindow.h"
21 #include "mapeditor.h"
26 #include "texteditor.h"
29 extern TextEditor *textEditor;
30 extern Main *mainWindow;
31 extern QString tmpVymDir;
32 extern QString clipboardDir;
33 extern bool clipboardEmpty;
34 extern int statusbarTime;
35 extern FlagRowObj* standardFlagsDefault;
36 extern FlagRowObj* systemFlagsDefault;
38 QMenu* branchContextMenu;
39 QMenu* branchAddContextMenu;
40 QMenu* branchRemoveContextMenu;
41 QMenu* branchLinksContextMenu;
42 QMenu* branchXLinksContextMenuEdit;
43 QMenu* branchXLinksContextMenuFollow;
44 QMenu* floatimageContextMenu;
45 QMenu* canvasContextMenu;
46 QMenu* fileLastMapsMenu;
47 QMenu* fileImportMenu;
48 QMenu* fileExportMenu;
51 extern Settings settings;
52 extern Options options;
53 extern ImageIO imageIO;
55 extern QDir vymBaseDir;
56 extern QDir lastImageDir;
57 extern QDir lastFileDir;
58 extern QString iconPath;
59 extern QString flagsPath;
61 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
62 QMainWindow(parent,name,f)
66 setCaption ("VYM - View Your Mind");
68 // Load window settings
69 resize (settings.value( "/mainwindow/geometry/size",QSize (800,600)).toSize());
70 move (settings.value( "/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
73 // Sometimes we may need to remember old selections
77 currentColor=Qt::black;
79 // Create unique temporary directory
81 tmpVymDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
84 qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
88 // Create direcctory for clipboard
89 clipboardDir=tmpVymDir+"/clipboard";
91 d.mkdir (clipboardDir,true);
92 makeSubDirs (clipboardDir);
97 // FIXME not used currently
98 // Set random seed (random used for object IDs)
99 // QTime t = QTime::currentTime(); // set random seed
100 // srand( t.hour()*12+t.minute()*60+t.second()*60 );
103 // Initialize some settings, which are platform dependant
106 // application to open URLs
107 p="/mainwindow/readerURL";
108 #if defined(Q_OS_LINUX)
109 s=settings.value (p,"konqueror").toString();
111 #if defined(Q_OS_MACX)
112 s=settings.value (p,"/usr/bin/open").toString();
114 s=settings.value (p,"mozilla");
117 settings.setValue( p,s);
119 // application to open PDFs
120 p="/mainwindow/readerPDF";
121 #if defined(Q_OS_LINUX)
122 s=settings.value (p,"acroread").toString();
124 #if defined(Q_OS_MACX)
125 s=settings.value (p,"/usr/bin/open").toString();
127 s=settings.value (p,"acroread").toString();
130 settings.setValue( p,s);
135 // Create tab widget which holds the maps
136 tabWidget= new QTabWidget (this);
137 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
138 this, SLOT( editorChanged( QWidget * ) ) );
140 lineedit=new QLineEdit (this);
143 setCentralWidget(tabWidget);
147 setupFormatActions();
151 setupSettingsActions();
153 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
158 restoreState (settings.value("/mainwindow/state",0).toByteArray());
160 // Initialize Find window
161 findWindow=new FindWindow(NULL);
162 findWindow->move (x(),y()+70);
163 connect (findWindow, SIGNAL( findButton(QString) ),
164 this, SLOT(editFind(QString) ) );
165 connect (findWindow, SIGNAL( somethingChanged() ),
166 this, SLOT(editFindChanged() ) );
168 // Connect TextEditor, so that we can update flags if text changes
169 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
170 connect (textEditor, SIGNAL (textEditorClosed() ), this, SLOT (updateActions()));
178 settings.setValue ( "/mainwindow/geometry/size", size() );
179 settings.setValue ( "/mainwindow/geometry/pos", pos() );
181 settings.setValue ("/mainwindow/state",saveState(0));
183 settings.setValue( "/version/version", __VYM_VERSION );
184 settings.setValue( "/version/builddate", __BUILD_DATE );
186 settings.setValue( "/mapeditor/editmode/autoSelectHeading",actionSettingsAutoSelectHeading->isOn() );
187 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
188 settings.setValue( "/mapeditor/editmode/autoEdit",actionSettingsAutoEdit->isOn() );
189 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
190 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
191 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
194 int maps=lastMaps.count();
195 settings.setValue( "/lastMaps/number",maps );
196 for (int i=1;i<=maps;i++)
198 s=QString("/lastMaps/map-%1").arg(i);
199 if (!s.isEmpty() && i<=maxLastMaps)
200 settings.setValue (s, lastMaps.at(i-1));
204 // To make the texteditor save its settings, call the destructor
207 // Remove temporary directory
208 removeDir (QDir(tmpVymDir));
211 void Main::loadCmdLine()
213 /* TODO draw some kind of splashscreen while loading...
219 QStringList flist=options.getFileList();
220 QStringList::Iterator it=flist.begin();
222 while (it !=flist.end() )
224 fileLoad (*it, NewMap);
230 void Main::statusMessage(const QString &s)
232 statusBar()->message (s);
235 void Main::closeEvent (QCloseEvent* )
241 void Main::setupFileActions()
243 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
244 QToolBar *tb = addToolBar( tr ("&Map") );
245 tb->setObjectName ("mapTB");
248 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New...","File menu" ),this);
249 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
250 a->setShortcut ( Qt::CTRL + Qt::Key_N );
252 fileMenu->addAction (a);
253 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
255 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
256 a->setStatusTip (tr( "Open","Status tip File menu" ) );
257 a->setShortcut ( Qt::CTRL + Qt::Key_O );
259 fileMenu->addAction (a);
260 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
262 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
263 fileMenu->addSeparator();
265 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
266 a->setStatusTip ( tr( "Save","Status tip file menu" ));
267 a->setShortcut (Qt::CTRL + Qt::Key_S );
269 fileMenu->addAction (a);
270 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
273 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
274 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
275 fileMenu->addAction (a);
276 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
278 fileMenu->addSeparator();
280 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
282 a = new QAction(tr("KDE Bookmarks"), this);
283 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE bookmarks")));
284 a->addTo (fileImportMenu);
285 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) );
287 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
289 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
290 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
291 a->addTo (fileImportMenu);
292 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
295 a = new QAction("Mind Manager...",this);
296 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
297 fileImportMenu->addAction (a);
298 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
300 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
301 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
302 fileImportMenu->addAction (a);
303 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
305 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
307 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
308 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
309 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
310 fileExportMenu->addAction (a);
312 a = new QAction( "Open Office...", this);
313 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
314 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
315 fileExportMenu->addAction (a);
317 a = new QAction( "Webpage (XHTML)...",this );
318 a->setShortcut (Qt::ALT + Qt::Key_X);
319 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
320 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
321 fileExportMenu->addAction (a);
323 a = new QAction( "Text (ASCII)...", this);
324 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
325 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
326 fileExportMenu->addAction (a);
328 a = new QAction( tr("KDE Bookmarks","File menu"), this);
329 a->setStatusTip( tr( "Export as %1").arg(tr("KDE Bookmarks" )));
330 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
331 fileExportMenu->addAction (a);
333 a = new QAction( "Taskjuggler...", this );
334 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
335 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
336 fileExportMenu->addAction (a);
338 a = new QAction( "LaTeX...", this);
339 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
340 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
341 fileExportMenu->addAction (a);
343 a = new QAction( "XML..." , this );
344 a->setStatusTip (tr( "Export as %1").arg("XML"));
345 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
346 fileExportMenu->addAction (a);
348 fileMenu->addSeparator();
350 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
351 a->setStatusTip ( tr( "Print" ,"File menu") );
352 a->setShortcut (Qt::CTRL + Qt::Key_P );
354 fileMenu->addAction (a);
355 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
358 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
359 a->setStatusTip (tr( "Close Map" ) );
360 a->setShortcut (Qt::ALT + Qt::Key_C );
361 fileMenu->addAction (a);
362 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
364 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+__VYM, this);
365 a->setStatusTip ( tr( "Exit")+" "+__VYM );
366 a->setShortcut (Qt::CTRL + Qt::Key_Q );
367 fileMenu->addAction (a);
368 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
373 void Main::setupEditActions()
375 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
376 tb->setLabel( "Edit Actions" );
377 tb->setObjectName ("actionsTB");
378 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
382 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
383 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
384 a->setStatusTip (tr( "Undo" ) );
385 a->setShortcut ( Qt::CTRL + Qt::Key_Z );
386 a->setEnabled (false);
388 editMenu->addAction (a);
391 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
392 a->setStatusTip (tr( "Redo" ));
393 a->setShortcut (Qt::CTRL + Qt::Key_Y );
395 editMenu->addAction (a);
396 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
399 editMenu->addSeparator();
400 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
401 a->setStatusTip ( tr( "Copy" ) );
402 a->setShortcut (Qt::CTRL + Qt::Key_C );
403 a->setEnabled (false);
405 editMenu->addAction (a);
406 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
409 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
410 a->setStatusTip ( tr( "Cut" ) );
411 a->setShortcut (Qt::CTRL + Qt::Key_X );
412 a->setEnabled (false);
414 editMenu->addAction (a);
416 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
418 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
419 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
420 a->setStatusTip ( tr( "Paste" ) );
421 a->setShortcut ( Qt::CTRL + Qt::Key_V );
422 a->setEnabled (false);
424 editMenu->addAction (a);
427 // Shortcuts to modify heading:
428 a = new QAction(tr( "Edit heading","Edit menu" ),this);
429 a->setStatusTip ( tr( "edit Heading" ));
430 a->setShortcut ( Qt::Key_Enter);
431 // a->setShortcutContext (Qt::WindowShortcut);
433 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
434 actionListBranches.append(a);
435 a = new QAction( tr( "Edit heading","Edit menu" ), this);
436 a->setStatusTip (tr( "edit Heading" ));
437 a->setShortcut (Qt::Key_Return );
438 //a->setShortcutContext (Qt::WindowShortcut);
440 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
441 actionListBranches.append(a);
442 editMenu->addAction (a);
444 a = new QAction( tr( "Edit heading","Edit menu" ), this);
445 a->setStatusTip (tr( "edit Heading" ));
446 a->setShortcut ( Qt::Key_F2 );
447 a->setShortcutContext (Qt::WindowShortcut);
449 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
450 actionListBranches.append(a);
452 // Shortcut to delete selection
453 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
454 a->setStatusTip (tr( "Delete Selection" ));
455 a->setShortcut ( Qt::Key_Delete);
456 a->setShortcutContext (Qt::WindowShortcut);
458 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
461 // Shortcut to add branch
462 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
463 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
464 alt->setShortcut (Qt::Key_A);
465 alt->setShortcutContext (Qt::WindowShortcut);
467 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
468 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
469 a->setStatusTip ( tr( "Add a branch as child of selection" ));
470 a->setShortcut (Qt::Key_Insert);
471 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
472 actionListBranches.append(a);
473 #if defined (Q_OS_MACX)
474 // In OSX show different shortcut in menues, the keys work indepently always
475 actionEditAddBranch=alt;
477 actionEditAddBranch=a;
479 editMenu->addAction (actionEditAddBranch);
480 tb->addAction (actionEditAddBranch);
483 // Add branch by inserting it at selection
484 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
485 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
486 a->setShortcut (Qt::ALT + Qt::Key_Insert );
487 a->setShortcutContext (Qt::WindowShortcut);
489 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
490 a->setEnabled (false);
491 actionListBranches.append(a);
492 actionEditAddBranchBefore=a;
493 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
494 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
495 a->setShortcut ( Qt::ALT + Qt::Key_A );
496 a->setShortcutContext (Qt::WindowShortcut);
498 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
499 actionListBranches.append(a);
502 a = new QAction(tr( "Add branch above","Edit menu" ), this);
503 a->setStatusTip ( tr( "Add a branch above selection" ));
504 a->setShortcut (Qt::SHIFT+Qt::Key_Insert );
505 a->setShortcutContext (Qt::WindowShortcut);
507 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
508 a->setEnabled (false);
509 actionListBranches.append(a);
510 actionEditAddBranchAbove=a;
511 a = new QAction(tr( "Add branch above","Edit menu" ), this);
512 a->setStatusTip ( tr( "Add a branch above selection" ));
513 a->setShortcut (Qt::SHIFT+Qt::Key_A );
514 a->setShortcutContext (Qt::WindowShortcut);
516 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
517 actionListBranches.append(a);
520 a = new QAction(tr( "Add branch below","Edit menu" ), this);
521 a->setStatusTip ( tr( "Add a branch below selection" ));
522 a->setShortcut (Qt::CTRL +Qt::Key_Insert );
523 a->setShortcutContext (Qt::WindowShortcut);
525 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
526 a->setEnabled (false);
527 actionListBranches.append(a);
528 actionEditAddBranchBelow=a;
529 a = new QAction(tr( "Add branch below","Edit menu" ), this);
530 a->setStatusTip ( tr( "Add a branch below selection" ));
531 a->setShortcut (Qt::CTRL +Qt::Key_A );
532 a->setShortcutContext (Qt::WindowShortcut);
534 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
535 actionListBranches.append(a);
537 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
538 a->setStatusTip ( tr( "Move branch up" ) );
539 a->setShortcut (Qt::Key_PageUp );
540 a->setEnabled (false);
542 editMenu->addAction (a);
543 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
546 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
547 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
548 a->setStatusTip (tr( "Move branch down" ) );
549 a->setShortcut ( Qt::Key_PageDown );
550 a->setEnabled (false);
552 editMenu->addAction (a);
553 actionEditMoveDown=a;
556 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this);
557 a->setShortcut ( Qt::Key_ScrollLock );
558 a->setStatusTip (tr( "Scroll branch" ) );
559 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
561 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
562 alt->setShortcut ( Qt::Key_S );
563 alt->setStatusTip (tr( "Scroll branch" ));
564 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
565 #if defined(Q_OS_MACX)
566 actionEditToggleScroll=alt;
568 actionEditToggleScroll=a;
570 actionEditToggleScroll->setEnabled (false);
571 actionEditToggleScroll->setToggleAction(true);
572 tb->addAction (actionEditToggleScroll);
573 editMenu->addAction ( actionEditToggleScroll);
574 editMenu->addAction (actionEditToggleScroll);
577 actionListBranches.append(actionEditToggleScroll);
579 a = new QAction( tr( "Unscroll all scrolled branches","Edit menu" ), this);
580 a->setStatusTip (tr( "Unscroll all" ));
581 editMenu->addAction (a);
582 connect( a, SIGNAL( triggered() ), this, SLOT( editUnScrollAll() ) );
584 editMenu->addSeparator();
586 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
587 a->setStatusTip (tr( "Find" ) );
588 a->setShortcut (Qt::CTRL + Qt::Key_F );
589 editMenu->addAction (a);
590 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
592 editMenu->addSeparator();
594 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
595 a->setShortcut (Qt::CTRL + Qt::Key_U );
596 a->setShortcut (tr( "Open URL" ));
599 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
602 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
603 a->setStatusTip (tr( "Open URL in new tab" ));
604 a->setShortcut (Qt::CTRL+Qt::Key_U );
606 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
607 actionEditOpenURLTab=a;
609 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
610 a->setStatusTip (tr( "Open all URLs in subtree" ));
612 actionListBranches.append(a);
613 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
614 actionEditOpenMultipleURLTabs=a;
616 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
617 a->setStatusTip ( tr( "Edit URL" ) );
618 a->setShortcut (Qt::SHIFT + Qt::CTRL + Qt::Key_U );
619 //a->setShortcut ( Qt::Key_U );
620 a->setShortcutContext (Qt::WindowShortcut);
621 actionListBranches.append(a);
623 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
626 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
627 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
628 a->setEnabled (false);
629 actionListBranches.append(a);
630 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
631 actionEditHeading2URL=a;
633 a = new QAction(tr( "Create URL to Bugzilla","Edit menu" ), this);
634 a->setStatusTip ( tr( "Create URL to Bugzilla" ));
635 a->setEnabled (false);
636 actionListBranches.append(a);
637 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
638 actionEditBugzilla2URL=a;
640 a = new QAction(tr( "Create URL to FATE","Edit menu" ), this);
641 a->setStatusTip ( tr( "Create URL to FATE" ));
642 a->setEnabled (false);
643 actionListBranches.append(a);
644 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
645 actionEditFATE2URL=a;
647 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
648 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
650 a->setEnabled (false);
651 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
652 actionEditOpenVymLink=a;
654 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
655 a->setStatusTip ( tr( "Open all vym links in subtree" ));
656 a->setEnabled (false);
657 actionListBranches.append(a);
658 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
659 actionEditOpenMultipleVymLinks=a;
662 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
663 a->setEnabled (false);
664 a->setStatusTip ( tr( "Edit link to another vym map" ));
665 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
666 actionListBranches.append(a);
669 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
670 a->setStatusTip ( tr( "Delete link to another vym map" ));
671 a->setEnabled (false);
672 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
673 actionEditDeleteVymLink=a;
675 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
676 a->setStatusTip ( tr( "Hide object in exports" ) );
677 a->setShortcut (Qt::Key_H );
678 a->setToggleAction(true);
680 a->setEnabled (false);
681 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
682 actionEditToggleHideExport=a;
684 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
685 a->setStatusTip ( tr( "Edit Map Info" ));
686 a->setEnabled (true);
687 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
690 // Import at selection (adding to selection)
691 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
692 a->setStatusTip (tr( "Add map at selection" ));
693 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
694 a->setEnabled (false);
695 actionListBranches.append(a);
696 actionEditImportAdd=a;
698 // Import at selection (replacing selection)
699 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
700 a->setStatusTip (tr( "Replace selection with map" ));
701 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
702 a->setEnabled (false);
703 actionListBranches.append(a);
704 actionEditImportReplace=a;
707 a = new QAction( tr( "Save selection","Edit menu" ), this);
708 a->setStatusTip (tr( "Save selection" ));
709 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
710 a->setEnabled (false);
711 actionListBranches.append(a);
712 actionEditSaveBranch=a;
714 // Only remove branch, not its childs
715 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
716 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
717 a->setShortcut (Qt::ALT + Qt::Key_Delete );
718 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChilds() ) );
719 a->setEnabled (false);
721 actionListBranches.append(a);
722 actionEditDeleteKeepChilds=a;
724 // Only remove childs of a branch
725 a = new QAction( tr( "Remove childs","Edit menu" ), this);
726 a->setStatusTip (tr( "Remove childs of branch" ));
727 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
728 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChilds() ) );
729 a->setEnabled (false);
730 actionListBranches.append(a);
731 actionEditDeleteChilds=a;
733 // Shortcuts for navigating with cursor:
734 a = new QAction(tr( "Select upper branch","Edit menu" ), this);
735 a->setStatusTip ( tr( "Select upper branch" ));
736 a->setShortcut (Qt::Key_Up );
737 a->setShortcutContext (Qt::WindowShortcut);
739 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
740 a = new QAction( tr( "Select lower branch","Edit menu" ),this);
741 a->setStatusTip (tr( "Select lower branch" ));
742 a->setShortcut ( Qt::Key_Down );
743 a->setShortcutContext (Qt::WindowShortcut);
745 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
746 a = new QAction(tr( "Select left branch","Edit menu" ), this);
747 a->setStatusTip ( tr( "Select left branch" ));
748 a->setShortcut (Qt::Key_Left );
749 a->setShortcutContext (Qt::WindowShortcut);
751 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
752 a = new QAction( tr( "Select child branch","Edit menu" ), this);
753 a->setStatusTip (tr( "Select right branch" ));
754 a->setShortcut (Qt::Key_Right);
755 a->setShortcutContext (Qt::WindowShortcut);
757 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
758 a = new QAction( tr( "Select first branch","Edit menu" ), this);
759 a->setStatusTip (tr( "Select first branch" ));
760 a->setShortcut (Qt::Key_Home );
761 a->setShortcutContext (Qt::WindowShortcut);
763 a->setEnabled (false);
764 editMenu->addAction (a);
765 actionListBranches.append(a);
766 actionEditSelectFirst=a;
767 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
768 a = new QAction( tr( "Select last branch","Edit menu" ),this);
769 a->setStatusTip (tr( "Select last branch" ));
770 a->setShortcut ( Qt::Key_End );
771 a->setShortcutContext (Qt::WindowShortcut);
773 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
774 a->setEnabled (false);
775 editMenu->addAction (a);
776 actionListBranches.append(a);
777 actionEditSelectLast=a;
779 a = new QAction( tr( "Add Image...","Edit menu" ), this);
780 a->setStatusTip (tr( "Add Image" ));
781 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
782 actionEditLoadImage=a;
787 void Main::setupFormatActions()
789 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
791 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
792 tb->setObjectName ("formatTB");
795 pix.fill (Qt::black);
796 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
797 a->setStatusTip ( tr( "Set Color" ));
798 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
800 formatMenu->addAction (a);
802 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
803 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
804 a->setShortcut (Qt::CTRL + Qt::Key_K );
805 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
806 a->setEnabled (false);
808 formatMenu->addAction (a);
809 actionListBranches.append(a);
810 actionFormatPickColor=a;
812 a= new QAction(QPixmap(iconPath+"formatcoloritem.png"), tr( "Color &branch","Edit menu" ), this);
813 a->setStatusTip ( tr( "Color branch" ) );
814 a->setShortcut (Qt::CTRL + Qt::Key_I);
815 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorItem() ) );
816 a->setEnabled (false);
818 formatMenu->addAction (a);
819 actionListBranches.append(a);
820 actionFormatColorBranch=a;
822 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color sub&tree","Edit menu" ), this);
823 a->setStatusTip ( tr( "Color Subtree" ));
824 a->setShortcut (Qt::CTRL + Qt::Key_T);
825 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
826 a->setEnabled (false);
827 formatMenu->addAction (a);
829 actionListBranches.append(a);
830 actionFormatColorSubtree=a;
832 formatMenu->addSeparator();
833 actionGroupFormatLinkStyles=new QActionGroup ( this);
834 actionGroupFormatLinkStyles->setExclusive (true);
835 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
836 a->setStatusTip (tr( "Line" ));
837 a->setToggleAction(true);
838 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
839 formatMenu->addAction (a);
840 actionFormatLinkStyleLine=a;
841 a= new QAction( tr( "Linkstyle Parabel" ), actionGroupFormatLinkStyles);
842 a->setStatusTip (tr( "Line" ));
843 a->setToggleAction(true);
844 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
845 formatMenu->addAction (a);
846 actionFormatLinkStyleParabel=a;
847 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
848 a->setStatusTip (tr( "PolyLine" ));
849 a->setToggleAction(true);
850 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
851 formatMenu->addAction (a);
852 actionFormatLinkStylePolyLine=a;
853 a= new QAction( tr( "Linkstyle Thick Parabel" ), actionGroupFormatLinkStyles);
854 a->setStatusTip (tr( "PolyParabel" ) );
855 a->setToggleAction(true);
856 a->setChecked (true);
857 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
858 formatMenu->addAction (a);
859 actionFormatLinkStylePolyParabel=a;
861 actionGroupFormatFrameTypes=new QActionGroup ( this);
862 actionGroupFormatFrameTypes->setExclusive (true);
863 a = new QAction( tr( "No Frame","Branch attribute" ), actionGroupFormatFrameTypes );
864 a->setStatusTip (tr("No Frame"));
865 a->setToggleAction(true);
866 connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameNone() ) );
867 actionFormatFrameNone=a;
868 a = new QAction( tr( "Rectangle""Branch attribute" ), actionGroupFormatFrameTypes);
869 a->setStatusTip (tr( "Rectangle" ));
870 a->setToggleAction(true);
871 connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameRectangle() ) );
872 actionFormatFrameRectangle=a;
874 a = new QAction( tr( "Include images vertically","Branch attribute" ), this);
875 a->setStatusTip ( tr ("Include top and bottom position of images into branch"));
876 a->setToggleAction(true);
877 connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesVer() ) );
878 actionFormatIncludeImagesVer=a;
880 a = new QAction( tr( "Include images horizontally","Branch attribute" ), this);
881 a->setStatusTip ( tr ("Include left and right position of images into branch"));
882 a->setToggleAction(true);
883 connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesHor() ) );
884 actionFormatIncludeImagesHor=a;
886 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
887 a->setStatusTip (tr( "Hide link" ));
888 a->setToggleAction(true);
889 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
890 actionFormatHideLinkUnselected=a;
892 formatMenu->addSeparator();
893 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
894 a->setStatusTip (tr( "Use same color for links and headings" ));
895 a->setToggleAction(true);
896 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
897 formatMenu->addAction (a);
898 actionFormatLinkColorHint=a;
900 pix.fill (Qt::white);
901 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
902 a->setStatusTip (tr( "Set Link Color" ));
903 formatMenu->addAction (a);
904 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
905 actionFormatLinkColor=a;
907 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
908 a->setStatusTip (tr( "Set Background Color" ));
909 formatMenu->addAction (a);
910 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
911 actionFormatBackColor=a;
915 void Main::setupViewActions()
917 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
918 tb->setLabel( "View Actions" );
919 tb->setObjectName ("viewTB");
920 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
923 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
924 a->setStatusTip ( tr( "Zoom reset" ) );
925 a->setShortcut (Qt::CTRL + Qt::Key_0 );
927 viewMenu->addAction (a);
928 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
930 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
931 a->setStatusTip (tr( "Zoom in" ));
932 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
934 viewMenu->addAction (a);
935 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
937 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
938 a->setStatusTip (tr( "Zoom out" ));
939 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
941 viewMenu->addAction (a);
942 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
945 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
946 a->setStatusTip ( tr( "Show Note Editor" ));
947 a->setShortcut ( Qt::CTRL + Qt::Key_E );
948 a->setToggleAction(true);
949 if (textEditor->showWithMain())
954 viewMenu->addAction (a);
955 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
956 actionViewToggleNoteEditor=a;
958 a = new QAction( tr( "Show history window","View action" ),this );
959 a->setStatusTip ( tr( "Show history window" ));
960 a->setShortcut ( Qt::CTRL + Qt::Key_H );
961 a->setToggleAction(false);
962 viewMenu->addAction (a);
963 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
964 actionViewToggleHistoryWindow=a;
966 a = new QAction(tr( "Next Window","View action" ), this);
967 a->setStatusTip ( tr( "&Next Window" ) );
968 a->setShortcut (Qt::ALT + Qt::Key_N );
969 viewMenu->addAction (a);
970 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
972 a = new QAction (tr( "Previous Window","View action" ), this );
973 a->setStatusTip (tr( "&Previous Window" ));
974 a->setShortcut (Qt::ALT + Qt::Key_P );
975 viewMenu->addAction (a);
976 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
980 void Main::setupModeActions()
982 //QPopupMenu *menu = new QPopupMenu( this );
983 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
985 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
986 tb->setObjectName ("modesTB");
988 actionGroupModModes=new QActionGroup ( this);
989 actionGroupModModes->setExclusive (true);
990 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
991 a->setShortcut (Qt::Key_J);
992 a->setStatusTip ( tr( "Use modifier to color branches" ));
993 a->setToggleAction(true);
996 actionModModeColor=a;
998 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
999 a->setShortcut( Qt::Key_K);
1000 a->setStatusTip( tr( "Use modifier to copy" ));
1001 a->setToggleAction(true);
1003 actionModModeCopy=a;
1005 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1006 a->setShortcut (Qt::Key_L);
1007 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1008 a->setToggleAction(true);
1010 actionModModeXLink=a;
1014 void Main::setupFlagActions()
1016 // Create System Flags
1017 systemFlagsDefault = new FlagRowObj ();
1018 systemFlagsDefault->setVisibility (false);
1019 systemFlagsDefault->setName ("systemFlagsDef");
1021 FlagObj *fo = new FlagObj ();
1022 fo->load(QPixmap(flagsPath+"flag-note.png"));
1023 fo->setName("note");
1024 fo->setToolTip(tr("Note","Systemflag"));
1025 systemFlagsDefault->addFlag (fo); // makes deep copy
1027 fo->load(QPixmap(flagsPath+"flag-url.png"));
1029 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
1030 systemFlagsDefault->addFlag (fo);
1032 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1033 fo->setName("vymLink");
1034 fo->setToolTip(tr("Link to another vym map","Systemflag"));
1035 systemFlagsDefault->addFlag (fo);
1037 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1038 fo->setName("scrolledright");
1039 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
1040 systemFlagsDefault->addFlag (fo);
1042 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1043 fo->setName("tmpUnscrolledright");
1044 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
1045 systemFlagsDefault->addFlag (fo);
1047 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1048 fo->setName("hideInExport");
1049 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
1050 systemFlagsDefault->addFlag (fo);
1052 // Create Standard Flags
1053 QToolBar *tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1054 tb->setObjectName ("standardFlagTB");
1056 standardFlagsDefault = new FlagRowObj ();
1057 standardFlagsDefault->setVisibility (false);
1058 standardFlagsDefault->setName ("standardFlagsDef");
1059 standardFlagsDefault->setToolBar (tb);
1061 fo->load(QPixmap(flagsPath+"flag-exclamationmark.png"));
1062 fo->setName ("exclamationmark");
1063 fo->setGroup("standard-mark");
1064 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1067 a->setCheckable(true);
1068 a->setObjectName(fo->getName());
1069 a->setToolTip(tr("Take care!","Standardflag"));
1070 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1071 standardFlagsDefault->addFlag (fo); // makes deep copy
1073 fo->load(QPixmap(flagsPath+"flag-questionmark.png"));
1074 fo->setName("questionmark");
1075 fo->setGroup("standard-mark");
1076 a=new QAction (fo->getPixmap(),fo->getName(),this);
1079 a->setCheckable(true);
1080 a->setObjectName(fo->getName());
1081 a->setToolTip(tr("Really?","Standardflag"));
1082 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1083 standardFlagsDefault->addFlag (fo);
1085 fo->load(QPixmap(flagsPath+"flag-hook-green.png"));
1086 fo->setName("hook-green");
1087 fo->setGroup("standard-hook");
1088 a=new QAction (fo->getPixmap(),fo->getName(),this);
1091 a->setCheckable(true);
1092 a->setObjectName(fo->getName());
1093 a->setToolTip(tr("ok!","Standardflag"));
1094 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1095 standardFlagsDefault->addFlag (fo);
1097 fo->load(QPixmap(flagsPath+"flag-cross-red.png"));
1098 fo->setName("cross-red");
1099 fo->setGroup("standard-hook");
1100 a=new QAction (fo->getPixmap(),fo->getName(),this);
1103 a->setCheckable(true);
1104 a->setObjectName(fo->getName());
1105 a->setToolTip(tr("Not ok!","Standardflag"));
1106 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1107 standardFlagsDefault->addFlag (fo);
1109 fo->load(QPixmap(flagsPath+"flag-stopsign.png"));
1110 fo->setName("stopsign");
1111 a=new QAction (fo->getPixmap(),fo->getName(),this);
1114 a->setCheckable(true);
1115 a->setObjectName(fo->getName());
1116 a->setToolTip(tr("This won't work!","Standardflag"));
1117 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1118 standardFlagsDefault->addFlag (fo);
1120 fo->load(QPixmap(flagsPath+"flag-smiley-good.png"));
1121 fo->setName("smiley-good");
1122 fo->setGroup("standard-smiley");
1123 a=new QAction (fo->getPixmap(),fo->getName(),this);
1126 a->setCheckable(true);
1127 a->setObjectName(fo->getName());
1128 a->setToolTip(tr("Good","Standardflag"));
1129 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1130 standardFlagsDefault->addFlag (fo);
1132 fo->load(QPixmap(flagsPath+"flag-smiley-sad.png"));
1133 fo->setName("smiley-sad");
1134 fo->setGroup("standard-smiley");
1135 a=new QAction (fo->getPixmap(),fo->getName(),this);
1138 a->setCheckable(true);
1139 a->setObjectName(fo->getName());
1140 a->setToolTip(tr("Bad","Standardflag"));
1141 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1142 standardFlagsDefault->addFlag (fo);
1144 fo->load(QPixmap(flagsPath+"flag-smiley-omg.png"));
1145 // Original omg.png (in KDE emoticons)
1146 fo->setName("smiley-omg");
1147 fo->setGroup("standard-smiley");
1148 a=new QAction (fo->getPixmap(),fo->getName(),this);
1151 a->setCheckable(true);
1152 a->setObjectName(fo->getName());
1153 a->setToolTip(tr("Oh no!","Standardflag"));
1154 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1155 standardFlagsDefault->addFlag (fo);
1157 fo->load(QPixmap(flagsPath+"flag-kalarm.png"));
1158 fo->setName("clock");
1159 a=new QAction (fo->getPixmap(),fo->getName(),this);
1162 a->setCheckable(true);
1163 a->setObjectName(fo->getName());
1164 a->setToolTip(tr("Time critical","Standardflag"));
1165 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1166 standardFlagsDefault->addFlag (fo);
1168 fo->load(QPixmap(flagsPath+"flag-phone.png"));
1169 fo->setName("phone");
1170 a=new QAction (fo->getPixmap(),fo->getName(),this);
1173 a->setCheckable(true);
1174 a->setObjectName(fo->getName());
1175 a->setToolTip(tr("Call...","Standardflag"));
1176 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1177 standardFlagsDefault->addFlag (fo);
1179 fo->load(QPixmap(flagsPath+"flag-lamp.png"));
1180 fo->setName("lamp");
1181 a=new QAction (fo->getPixmap(),fo->getName(),this);
1184 a->setCheckable(true);
1185 a->setObjectName(fo->getName());
1186 a->setToolTip(tr("Idea!","Standardflag"));
1187 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1188 standardFlagsDefault->addFlag (fo);
1190 fo->load(QPixmap(flagsPath+"flag-arrow-up.png"));
1191 fo->setName("arrow-up");
1192 fo->setGroup("standard-arrow");
1193 a=new QAction (fo->getPixmap(),fo->getName(),this);
1196 a->setCheckable(true);
1197 a->setObjectName(fo->getName());
1198 a->setToolTip(tr("Important","Standardflag"));
1199 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1200 standardFlagsDefault->addFlag (fo);
1202 fo->load(QPixmap(flagsPath+"flag-arrow-down.png"));
1203 fo->setName("arrow-down");
1204 fo->setGroup("standard-arrow");
1205 a=new QAction (fo->getPixmap(),fo->getName(),this);
1208 a->setCheckable(true);
1209 a->setObjectName(fo->getName());
1210 a->setToolTip(tr("Unimportant","Standardflag"));
1211 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1212 standardFlagsDefault->addFlag (fo);
1214 fo->load(QPixmap(flagsPath+"flag-arrow-2up.png"));
1215 fo->setName("2arrow-up");
1216 fo->setGroup("standard-arrow");
1217 a=new QAction (fo->getPixmap(),fo->getName(),this);
1220 a->setCheckable(true);
1221 a->setObjectName(fo->getName());
1222 a->setToolTip(tr("Very important!","Standardflag"));
1223 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1224 standardFlagsDefault->addFlag (fo);
1226 fo->load(QPixmap(flagsPath+"flag-arrow-2down.png"));
1227 fo->setName("2arrow-down");
1228 fo->setGroup("standard-arrow");
1229 a=new QAction (fo->getPixmap(),fo->getName(),this);
1232 a->setCheckable(true);
1233 a->setObjectName(fo->getName());
1234 a->setToolTip(tr("Very unimportant!","Standardflag"));
1235 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1236 standardFlagsDefault->addFlag (fo);
1238 fo->load(QPixmap(flagsPath+"flag-thumb-up.png"));
1239 fo->setName("thumb-up");
1240 fo->setGroup("standard-thumb");
1241 a=new QAction (fo->getPixmap(),fo->getName(),this);
1244 a->setCheckable(true);
1245 a->setObjectName(fo->getName());
1246 a->setToolTip(tr("I like this","Standardflag"));
1247 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1248 standardFlagsDefault->addFlag (fo);
1250 fo->load(QPixmap(flagsPath+"flag-thumb-down.png"));
1251 fo->setName("thumb-down");
1252 fo->setGroup("standard-thumb");
1253 a=new QAction (fo->getPixmap(),fo->getName(),this);
1256 a->setCheckable(true);
1257 a->setObjectName(fo->getName());
1258 a->setToolTip(tr("I do not like this","Standardflag"));
1259 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1260 standardFlagsDefault->addFlag (fo);
1262 fo->load(QPixmap(flagsPath+"flag-rose.png"));
1263 fo->setName("rose");
1264 a=new QAction (fo->getPixmap(),fo->getName(),this);
1267 a->setCheckable(true);
1268 a->setObjectName(fo->getName());
1269 a->setToolTip(tr("Rose","Standardflag"));
1270 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1271 standardFlagsDefault->addFlag (fo);
1273 fo->load(QPixmap(flagsPath+"flag-heart.png"));
1274 fo->setName("heart");
1275 a=new QAction (fo->getPixmap(),fo->getName(),this);
1277 a->setCheckable(true);
1278 a->setObjectName(fo->getName());
1279 a->setToolTip(tr("I just love... ","Standardflag"));
1280 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1281 standardFlagsDefault->addFlag (fo);
1283 fo->load(QPixmap(flagsPath+"flag-present.png"));
1284 fo->setName("present");
1285 a=new QAction (fo->getPixmap(),fo->getName(),this);
1288 a->setCheckable(true);
1289 a->setObjectName(fo->getName());
1290 a->setToolTip(tr("Surprise!","Standardflag"));
1291 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1292 standardFlagsDefault->addFlag (fo);
1294 fo->load(QPixmap(flagsPath+"flag-flash.png"));
1295 fo->setName("flash");
1296 a=new QAction (fo->getPixmap(),fo->getName(),this);
1299 a->setCheckable(true);
1300 a->setObjectName(fo->getName());
1301 a->setToolTip(tr("Dangerous","Standardflag"));
1302 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1303 standardFlagsDefault->addFlag (fo);
1305 fo->load(QPixmap(flagsPath+"flag-info.png"));
1306 // Original: xsldbg_output.png
1307 fo->setName("info");
1308 a=new QAction (fo->getPixmap(),fo->getName(),this);
1311 a->setCheckable(true);
1312 a->setObjectName(fo->getName());
1313 a->setToolTip(tr("Info","Standardflag"));
1314 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1315 standardFlagsDefault->addFlag (fo);
1317 fo->load(QPixmap(flagsPath+"flag-lifebelt.png"));
1318 // Original khelpcenter.png
1319 fo->setName("lifebelt");
1320 a=new QAction (fo->getPixmap(),fo->getName(),this);
1323 a->setCheckable(true);
1324 a->setObjectName(fo->getName());
1325 a->setToolTip(tr("This will help","Standardflag"));
1326 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1327 standardFlagsDefault->addFlag (fo);
1333 void Main::setupSettingsActions()
1335 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1339 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1340 a->setStatusTip ( tr( "Set application to open pdf files"));
1341 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1342 settingsMenu->addAction (a);
1344 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1345 a->setStatusTip( tr( "Set application to open external links"));
1346 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1347 settingsMenu->addAction (a);
1349 settingsMenu->addSeparator();
1350 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1351 a->setStatusTip( tr( "Edit branch after adding it" ));
1352 a->setToggleAction(true);
1353 a->setOn ( settings.value ("/mapeditor/editmode/autoEdit",true).toBool());
1354 settingsMenu->addAction (a);
1355 actionSettingsAutoEdit=a;
1357 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1358 a->setStatusTip( tr( "Select branch after adding it" ));
1359 a->setToggleAction(true);
1360 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectHeading",false).toBool() );
1361 settingsMenu->addAction (a);
1362 actionSettingsAutoSelectHeading=a;
1364 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1365 a->setStatusTip( tr( "Select heading before editing" ));
1366 a->setToggleAction(true);
1367 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1368 settingsMenu->addAction (a);
1369 actionSettingsAutoSelectText=a;
1371 a= new QAction( tr( "Delete key","Settings action" ), this);
1372 a->setStatusTip( tr( "Delete key for deleting branches" ));
1373 a->setToggleAction(true);
1374 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",false).toBool() );
1375 settingsMenu->addAction (a);
1376 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1377 actionSettingsUseDelKey=a;
1379 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1380 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1381 a->setToggleAction(true);
1382 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1383 settingsMenu->addAction (a);
1384 actionSettingsUseFlagGroups=a;
1386 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1387 a->setStatusTip( tr( "Use hide flag during exports " ));
1388 a->setToggleAction(true);
1389 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1390 settingsMenu->addAction (a);
1391 actionSettingsUseHideExport=a;
1395 void Main::setupTestActions()
1397 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1400 a = new QAction( "Test function" , this);
1401 a->setStatusTip( "Call test function" );
1402 a->setShortcut (Qt::Key_F4 );
1403 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction() ) );
1404 testMenu->addAction (a);
1405 a = new QAction( "Command" , this);
1406 a->setStatusTip( "Enter command to call in editor" );
1407 a->setShortcut (Qt::Key_F5 );
1408 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1409 testMenu->addAction (a);
1413 void Main::setupHelpActions()
1415 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1418 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1419 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1420 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1421 helpMenu->addAction (a);
1423 a = new QAction( tr( "About VYM","Help action" ), this);
1424 a->setStatusTip( tr( "About VYM")+" "__VYM);
1425 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1426 helpMenu->addAction (a);
1428 a = new QAction( tr( "About QT","Help action" ), this);
1429 a->setStatusTip( tr( "Information about QT toolkit" ));
1430 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1431 helpMenu->addAction (a);
1435 void Main::setupContextMenus()
1439 // Context Menu for branch or mapcenter
1440 branchContextMenu =new QMenu (this);
1443 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1444 branchAddContextMenu->addAction (actionEditPaste );
1445 branchAddContextMenu->addAction ( actionEditAddBranch );
1446 branchAddContextMenu->addAction ( actionEditAddBranchBefore );
1447 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1448 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1449 branchAddContextMenu->addSeparator();
1450 branchAddContextMenu->addAction ( actionEditLoadImage);
1451 branchAddContextMenu->addSeparator();
1452 branchAddContextMenu->addAction ( actionEditImportAdd );
1453 branchAddContextMenu->addAction ( actionEditImportReplace );
1456 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1457 branchRemoveContextMenu->addAction (actionEditCut);
1458 branchRemoveContextMenu->addAction ( actionEditDelete );
1459 branchRemoveContextMenu->addAction ( actionEditDeleteKeepChilds );
1460 branchRemoveContextMenu->addAction ( actionEditDeleteChilds );
1463 actionEditSaveBranch->addTo( branchContextMenu );
1465 branchContextMenu->addSeparator();
1466 branchContextMenu->addAction ( actionFormatFrameNone );
1467 branchContextMenu->addAction ( actionFormatFrameRectangle);
1469 branchContextMenu->addSeparator();
1470 branchContextMenu->addAction ( actionFormatIncludeImagesVer );
1471 branchContextMenu->addAction ( actionFormatIncludeImagesHor );
1472 branchContextMenu->addAction ( actionFormatHideLinkUnselected );
1474 // Submenu for Links (URLs, vymLinks)
1475 branchLinksContextMenu =new QMenu (this);
1477 branchContextMenu->addSeparator();
1478 branchLinksContextMenu=branchContextMenu->addMenu(tr("URLs and vymLinks","Context menu name"));
1479 branchLinksContextMenu->addAction ( actionEditOpenURL );
1480 branchLinksContextMenu->addAction ( actionEditOpenURLTab );
1481 branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
1482 branchLinksContextMenu->addAction ( actionEditURL );
1483 branchLinksContextMenu->addAction ( actionEditHeading2URL );
1484 branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
1485 if (settings.value( "/mainwindow/showTestMenu",true).toBool() )
1487 branchLinksContextMenu->addAction ( actionEditFATE2URL );
1489 branchLinksContextMenu->addSeparator();
1490 branchLinksContextMenu->addAction ( actionEditOpenVymLink );
1491 branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
1492 branchLinksContextMenu->addAction ( actionEditVymLink );
1493 branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
1496 // Context Menu for XLinks in a branch menu
1497 // This will be populated "on demand" in MapEditor::updateActions
1498 branchContextMenu->addSeparator();
1499 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1500 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1501 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1502 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1505 // Context menu for floatimage
1506 floatimageContextMenu =new QMenu (this);
1507 a= new QAction (tr ("Save image","Context action"),this);
1508 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1509 floatimageContextMenu->addAction (a);
1511 floatimageContextMenu->addSeparator();
1512 actionEditCopy->addTo( floatimageContextMenu );
1513 actionEditCut->addTo( floatimageContextMenu );
1515 floatimageContextMenu->addSeparator();
1516 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1519 // Context menu for canvas
1520 canvasContextMenu =new QMenu (this);
1521 actionEditMapInfo->addTo( canvasContextMenu );
1522 canvasContextMenu->insertSeparator();
1523 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1524 canvasContextMenu->insertSeparator();
1525 actionFormatLinkColorHint->addTo( canvasContextMenu );
1526 actionFormatLinkColor->addTo( canvasContextMenu );
1527 actionFormatBackColor->addTo( canvasContextMenu );
1529 // Menu for last opened files
1530 // Read settings initially
1532 int j=settings.readNumEntry( "/lastMaps/number",0);
1533 for (int i=1;i<=j;i++)
1535 s=settings.value(QString("/lastMaps/map-%1").arg(i),"").toString();
1536 if (!s.isEmpty() && j<=maxLastMaps)
1539 setupLastMapsMenu();
1540 connect( fileLastMapsMenu, SIGNAL( triggered(QAction *) ), this, SLOT( fileLoadLast(QAction*) ) );
1543 void Main::setupLastMapsMenu()
1545 // Remove double entries
1546 QStringList::Iterator it=lastMaps.begin();
1547 QStringList::Iterator jt;
1548 while (it!=lastMaps.end() )
1552 while (jt!=lastMaps.end() )
1555 jt=lastMaps.remove(jt);
1562 // Limit length of list to maxLastMaps
1563 while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
1565 // build Menu from lastMaps string list
1566 fileLastMapsMenu->clear();
1567 for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1568 fileLastMapsMenu->addAction (*it );
1571 void Main::hideEvent (QHideEvent * )
1573 if (!textEditor->isMinimized() ) textEditor->hide();
1576 void Main::showEvent (QShowEvent * )
1578 if (textEditor->showWithMain()) textEditor->showNormal();
1581 bool Main::reallyWriteDirectory(const QString &dir)
1583 QStringList eList = QDir(dir).entryList();
1584 if (eList.first() ==".") eList.pop_front(); // remove "."
1585 if (eList.first() =="..") eList.pop_front(); // remove "."
1586 if (!eList.isEmpty())
1588 QMessageBox mb( __VYM,
1589 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?","write directory").arg(dir),
1590 QMessageBox::Warning,
1592 QMessageBox::Cancel | QMessageBox::Default,
1593 QMessageBox::QMessageBox::NoButton );
1595 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1596 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1599 case QMessageBox::Yes:
1602 case QMessageBox::Cancel:
1610 QString Main::browseDirectory (const QString &caption)
1612 Q3FileDialog fd(this,caption);
1613 fd.setMode (Q3FileDialog::DirectoryOnly);
1614 fd.setCaption(__VYM " - "+caption);
1617 if ( fd.exec() == QDialog::Accepted )
1618 return fd.selectedFile();
1623 MapEditor* Main::currentMapEditor() const
1625 if ( tabWidget->currentPage() &&
1626 tabWidget->currentPage()->inherits( "MapEditor" ) )
1627 return (MapEditor*)tabWidget->currentPage();
1631 //TODO not used now, maybe use this for overview window later
1632 void Main::newView()
1634 // Open a new view... have it delete when closed.
1635 Main *m = new Main(0, 0, Qt::WDestructiveClose);
1636 qApp->setMainWidget(m);
1638 qApp->setMainWidget(0);
1641 void Main::editorChanged(QWidget *)
1643 // Unselect all possibly selected objects
1644 // (Important to update note editor)
1647 for (i=0;i<=tabWidget->count() -1;i++)
1650 me=(MapEditor*)tabWidget->page(i);
1653 currentMapEditor()->reselect();
1655 // Update actions to in menus and toolbars according to editor
1656 currentMapEditor()->updateActions();
1659 void Main::fileNew()
1661 QString fn="unnamed";
1662 MapEditor* medit = new MapEditor ( NULL);
1663 tabWidget->addTab (medit,fn);
1664 tabWidget->showPage(medit);
1665 medit->viewport()->setFocus();
1666 // For the very first map we do not have flagrows yet...
1667 medit->select("mc:");
1670 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1672 ErrorCode err=success;
1674 // fn is usually the archive, mapfile the file after uncompressing
1677 // Make fn absolute (needed for unzip)
1678 fn=QDir (fn).absPath();
1684 // Check, if map is already loaded
1686 while (i<=tabWidget->count() -1)
1688 me=(MapEditor*)tabWidget->page(i);
1689 if (me->getFilePath() == fn)
1691 // Already there, ask for confirmation
1692 QMessageBox mb( __VYM,
1693 tr("The map %1\nis already opened."
1694 "Opening the same map in multiple editors may lead \n"
1695 "to confusion when finishing working with vym."
1696 "Do you want to").arg(fn),
1697 QMessageBox::Warning,
1698 QMessageBox::Yes | QMessageBox::Default,
1699 QMessageBox::Cancel | QMessageBox::Escape,
1700 QMessageBox::NoButton);
1701 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1702 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1705 case QMessageBox::Yes:
1707 i=tabWidget->count();
1709 case QMessageBox::Cancel:
1721 if ( !fn.isEmpty() )
1723 me = currentMapEditor();
1724 int tabIndex=tabWidget->currentPageIndex();
1725 // Check first, if mapeditor exists
1726 // If it is not default AND we want a new map,
1727 // create a new mapeditor in a new tab
1728 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1730 me= new MapEditor ( NULL);
1731 tabWidget->addTab (me,fn);
1732 tabIndex=tabWidget->indexOf (me);
1733 tabWidget->setCurrentPage (tabIndex);
1736 // Check, if file exists (important for creating new files
1737 // from command line
1738 if (!QFile(fn).exists() )
1740 QMessageBox mb( __VYM,
1741 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1742 QMessageBox::Question,
1744 QMessageBox::Cancel | QMessageBox::Default,
1745 QMessageBox::NoButton );
1747 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1748 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1751 case QMessageBox::Yes:
1753 currentMapEditor()->setFilePath(fn);
1754 tabWidget->setTabLabel (currentMapEditor(),
1755 currentMapEditor()->getFileName() );
1756 statusBar()->message( "Created " + fn , statusbarTime );
1759 case QMessageBox::Cancel:
1760 // don't create new map
1761 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1768 //tabWidget->currentPage() won't be NULL here, because of above...
1769 tabWidget->showPage(me);
1770 me->viewport()->setFocus();
1772 // Create temporary directory for packing
1774 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
1777 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1778 tr("Couldn't create temporary directory before load\n"));
1782 // Try to unzip file
1783 err=unzipDir (tmpMapDir,fn);
1787 me->setZipped(false);
1790 me->setZipped(true);
1792 // Look for mapname.xml
1793 mapfile= fn.left(fn.findRev(".",-1,true));
1794 mapfile=mapfile.section( '/', -1 );
1795 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1796 if (!file.exists() )
1798 // mapname.xml does not exist, well,
1799 // maybe some renamed the mapname.vym file...
1800 // Try to find any .xml in the toplevel
1801 // directory of the .vym file
1802 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1803 if (flist.count()==1)
1805 // Only one entry, take this one
1806 mapfile=tmpMapDir + "/"+flist.first();
1809 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1810 *it=tmpMapDir + "/" + *it;
1811 // TODO Multiple entries, load all (but only the first one into this ME)
1812 //mainWindow->fileLoadFromTmp (flist);
1813 //returnCode=1; // Silently forget this attempt to load
1814 qWarning ("MainWindow::load (fn) multimap found...");
1817 if (flist.isEmpty() )
1819 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1820 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1823 } //file doesn't exist
1825 mapfile=file.name();
1830 // Save existing filename in case we import
1831 QString fn_org=me->getFilePath();
1833 // Finally load map into mapEditor
1834 me->setFilePath (mapfile,fn);
1835 err=me->load(mapfile,lmode);
1837 // Restore old (maybe empty) filepath, if this is an import
1839 me->setFilePath (fn_org);
1842 // Finally check for errors and go home
1845 if (lmode==NewMap) fileCloseMap();
1846 statusBar()->message( "Could not load " + fn, statusbarTime );
1851 me->setFilePath (fn);
1852 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1853 if (fn.left(9)!="/tmp/vym-")
1855 // Only append to lastMaps if not loaded from a tmpDir
1856 // e.g. imported bookmarks are in a tmpDir
1857 lastMaps.prepend(me->getFilePath() );
1858 setupLastMapsMenu();
1860 actionFilePrint->setEnabled (true);
1862 statusBar()->message( "Loaded " + fn, statusbarTime );
1866 removeDir (QDir(tmpMapDir));
1872 void Main::fileLoad(const LoadMode &lmode)
1874 QStringList filters;
1875 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1876 QFileDialog *fd=new QFileDialog( this);
1877 fd->setDir (lastFileDir);
1878 fd->setFileMode (QFileDialog::ExistingFiles);
1879 fd->setFilters (filters);
1883 fd->setCaption(__VYM " - " +tr("Load vym map"));
1886 fd->setCaption(__VYM " - " +tr("Import: Add vym map to selection"));
1889 fd->setCaption(__VYM " - " +tr("Import: Replace selection with vym map"));
1895 if ( fd->exec() == QDialog::Accepted )
1897 lastFileDir=fd->directory().path();
1898 QStringList flist = fd->selectedFiles();
1899 QStringList::Iterator it = flist.begin();
1900 while( it != flist.end() )
1903 fileLoad(*it, lmode);
1910 void Main::fileLoad()
1915 void Main::fileLoadLast(QAction *a)
1917 fileLoad(lastMaps.at(fileLastMapsMenu->actions().indexOf(a)) ,NewMap);
1920 void Main::fileSave(const SaveMode &savemode)
1922 // tmp dir for zipping
1926 ErrorCode err=success;
1928 QString safeFilePath;
1930 bool saveZipped=currentMapEditor()->saveZipped();
1932 MapEditor * me=currentMapEditor();
1935 QString fn=me->getFilePath();
1936 // filename=unnamed, filepath="" in constructor...
1937 if ( !fn.isEmpty() )
1939 // We have a filepath, go on saving
1940 // First remove existing file, we
1941 // don't want to add to old zip archives
1945 QMessageBox::warning( 0, tr( "Save Error" ),
1946 fn+ tr("\ncould not be removed before saving"));
1948 // Look, if we should zip the data:
1951 QMessageBox mb( __VYM,
1952 tr("The map %1\ndid not use the compressed "
1953 "vym file format.\nWriting it uncompressed will also write images \n"
1954 "and flags and thus may overwrite files in the "
1955 "given directory\n\nDo you want to write the map").arg(fn),
1956 QMessageBox::Warning,
1957 QMessageBox::Yes | QMessageBox::Default,
1959 QMessageBox::Cancel | QMessageBox::Escape);
1960 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
1961 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
1962 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1965 case QMessageBox::Yes:
1966 // save compressed (default file format)
1969 case QMessageBox::No:
1970 // save uncompressed
1973 case QMessageBox::Cancel:
1982 // Create temporary directory for packing
1984 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
1987 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1988 tr("Couldn't create temporary directory before save\n"));
1992 safeFilePath=me->getFilePath();
1993 me->setFilePath (tmpMapDir+"/"+
1994 me->getMapName()+ ".xml",
1996 me->save (savemode);
1997 me->setFilePath (safeFilePath);
1999 zipDir (tmpMapDir,fn);
2004 safeFilePath=me->getFilePath();
2005 me->setFilePath (fn, safeFilePath);
2006 me->save (savemode);
2007 me->setFilePath (safeFilePath);
2009 } // filepath available
2012 // We have no filepath yet,
2013 // call fileSaveAs() now, this will call fileSave()
2015 fileSaveAs(savemode);
2019 if (saveZipped && !tmpMapDir.isEmpty())
2021 removeDir (QDir(tmpMapDir));
2025 statusBar()->message(
2026 tr("Saved %1").arg(me->getFilePath()),
2028 lastMaps.prepend(me->getFilePath() );
2029 setupLastMapsMenu();
2031 statusBar()->message(
2032 tr("Couldn't save ").arg(me->getFilePath()),
2036 void Main::fileSave()
2038 fileSave (CompleteMap);
2041 void Main::fileSaveAs(const SaveMode& savemode)
2045 if (currentMapEditor())
2047 if (savemode==CompleteMap)
2048 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2050 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2051 if ( !fn.isEmpty() )
2053 // Check for existing file
2054 if (QFile (fn).exists())
2056 QMessageBox mb( __VYM,
2057 tr("The file %1\nexists already. Do you want to").arg(fn),
2058 QMessageBox::Warning,
2059 QMessageBox::Yes | QMessageBox::Default,
2060 QMessageBox::Cancel | QMessageBox::Escape,
2061 QMessageBox::NoButton);
2062 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2063 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2066 case QMessageBox::Yes:
2069 case QMessageBox::Cancel:
2076 // New file, add extension to filename, if missing
2077 // This is always .vym or .vyp, depending on savemode
2078 if (savemode==CompleteMap)
2080 if (!fn.contains (".vym") && !fn.contains (".xml"))
2084 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2093 currentMapEditor()->setFilePath(fn);
2097 if (savemode==CompleteMap)
2098 tabWidget->setTabLabel (currentMapEditor(),
2099 currentMapEditor()->getFileName() );
2105 void Main::fileSaveAs()
2107 fileSaveAs (CompleteMap);
2110 void Main::fileImportKDEBookmarks()
2112 ImportKDEBookmarks im;
2114 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2115 currentMapEditor()->setFilePath ("");
2118 void Main::fileImportFirefoxBookmarks()
2120 Q3FileDialog *fd=new Q3FileDialog( this);
2121 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2122 fd->setMode (Q3FileDialog::ExistingFiles);
2123 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2124 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2127 if ( fd->exec() == QDialog::Accepted )
2129 ImportFirefoxBookmarks im;
2130 QStringList flist = fd->selectedFiles();
2131 QStringList::Iterator it = flist.begin();
2132 while( it != flist.end() )
2135 if (im.transform() &&
2136 success==fileLoad (im.getTransformedFile(),NewMap) &&
2137 currentMapEditor() )
2138 currentMapEditor()->setFilePath ("");
2145 void Main::fileImportMM()
2149 Q3FileDialog *fd=new Q3FileDialog( this);
2150 fd->setDir (lastFileDir);
2151 fd->setMode (Q3FileDialog::ExistingFiles);
2152 fd->addFilter ("Mind Manager (*.mmap)");
2153 fd->setCaption(tr("Import")+" "+"Mind Manager");
2156 if ( fd->exec() == QDialog::Accepted )
2158 lastFileDir=fd->dirPath();
2159 QStringList flist = fd->selectedFiles();
2160 QStringList::Iterator it = flist.begin();
2161 while( it != flist.end() )
2164 if (im.transform() &&
2165 success==fileLoad (im.getTransformedFile(),NewMap) &&
2166 currentMapEditor() )
2167 currentMapEditor()->setFilePath ("");
2176 void Main::fileImportDir()
2178 if (currentMapEditor())
2179 currentMapEditor()->importDir();
2182 void Main::fileExportXML()
2184 if (currentMapEditor())
2186 QString dir=browseDirectory(tr("Export XML to directory"));
2187 if (dir !="" && reallyWriteDirectory(dir) )
2188 currentMapEditor()->exportXML(dir);
2193 void Main::fileExportXHTML()
2195 MapEditor *me=currentMapEditor();
2199 ExportXHTMLDialog dia(this);
2200 dia.setFilePath (me->getFilePath() );
2201 dia.setMapName (me->getMapName() );
2204 if (dia.exec()==QDialog::Accepted)
2206 QString dir=dia.getDir();
2207 // Check, if warnings should be used before overwriting
2208 // the output directory
2211 ok=reallyWriteDirectory(dir);
2217 me->exportXML (dia.getDir() );
2218 dia.doExport(me->getMapName() );
2219 if (dia.hasChanged())
2226 void Main::fileExportImage()
2228 MapEditor *me=currentMapEditor();
2232 QFileDialog *fd=new QFileDialog (this);
2233 fd->setCaption (tr("Export map as image"));
2234 fd->setFileMode(QFileDialog::AnyFile);
2235 fd->setFilters (imageIO.getFilters() );
2236 fd->setDirectory (lastImageDir);
2239 fl=fd->selectedFiles();
2240 qWarning ("Selected "+fl.first()+" filter: "+fd->selectedFilter());
2241 me->exportImage (fl.first(), imageIO.getType (fd->selectedFilter() ) );
2246 void Main::fileExportASCII()
2248 MapEditor *me=currentMapEditor();
2252 ex.setMapCenter(me->getMapCenter());
2253 ex.addFilter ("TXT (*.txt)");
2254 ex.setCaption(__VYM " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
2255 if (ex.execDialog() )
2257 me->setExportMode(true);
2259 me->setExportMode(false);
2264 void Main::fileExportLaTeX()
2266 MapEditor *me=currentMapEditor();
2270 ex.setMapCenter(me->getMapCenter());
2271 ex.addFilter ("Tex (*.tex)");
2272 ex.setCaption(__VYM " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2273 if (ex.execDialog() )
2275 me->setExportMode(true);
2277 me->setExportMode(false);
2282 void Main::fileExportKDEBookmarks()
2284 ExportKDEBookmarks ex;
2285 MapEditor *me=currentMapEditor();
2288 ex.setMapCenter (me->getMapCenter() );
2293 void Main::fileExportTaskjuggler()
2295 ExportTaskjuggler ex;
2296 MapEditor *me=currentMapEditor();
2299 ex.setMapCenter (me->getMapCenter() );
2300 ex.setCaption ( __VYM " - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2301 ex.addFilter ("Taskjuggler (*.tjp)");
2302 if (ex.execDialog() )
2304 me->setExportMode(true);
2306 me->setExportMode(false);
2311 void Main::fileExportOOPresentation()
2313 ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to")+" Open Office");
2314 // TODO add preview in dialog
2315 //ImagePreview *p =new ImagePreview (fd);
2316 //fd->setContentsPreviewEnabled( TRUE );
2317 //fd->setContentsPreview( p, p );
2318 //fd->setPreviewMode( QFileDialog::Contents );
2319 fd->setCaption(__VYM " - " +tr("Export to")+" Open Office");
2320 fd->setDir (QDir().current());
2321 if (fd->foundConfig())
2325 if ( fd->exec() == QDialog::Accepted )
2327 QString fn=fd->selectedFile();
2328 if (!fn.contains (".odp"))
2331 //lastImageDir=fn.left(fn.findRev ("/"));
2332 if (currentMapEditor())
2333 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2337 QMessageBox::warning(0,
2339 tr("Couldn't find configuration for export to Open Office\n"));
2343 void Main::fileCloseMap()
2345 if (currentMapEditor())
2347 if (currentMapEditor()->hasChanged())
2349 QMessageBox mb( __VYM,
2350 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2351 QMessageBox::Warning,
2352 QMessageBox::Yes | QMessageBox::Default,
2354 QMessageBox::Cancel | QMessageBox::Escape );
2355 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2356 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2359 case QMessageBox::Yes:
2361 fileSave(CompleteMap);
2363 case QMessageBox::No:
2364 // close without saving
2366 case QMessageBox::Cancel:
2371 currentMapEditor()->closeMap();
2372 tabWidget->removePage(currentMapEditor());
2373 if (tabWidget->count()==0)
2374 actionFilePrint->setEnabled (false);
2378 void Main::filePrint()
2380 if (currentMapEditor())
2381 currentMapEditor()->print();
2384 void Main::fileExitVYM()
2386 // Check if one or more editors have changed
2389 for (i=0;i<=tabWidget->count() -1;i++)
2392 me=(MapEditor*)tabWidget->page(i);
2394 // If something changed, ask what to do
2395 if (me->isUnsaved())
2397 tabWidget->setCurrentPage(i);
2398 QMessageBox mb( __VYM,
2399 tr("This map is not saved yet. Do you want to"),
2400 QMessageBox::Warning,
2401 QMessageBox::Yes | QMessageBox::Default,
2403 QMessageBox::Cancel | QMessageBox::Escape );
2404 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2405 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2408 mb.setActiveWindow();
2409 switch( mb.exec() ) {
2410 case QMessageBox::Yes:
2411 // save (the changed editors) and exit
2412 fileSave(CompleteMap);
2414 case QMessageBox::No:
2415 // exit without saving
2417 case QMessageBox::Cancel:
2418 // don't save and don't exit
2422 } // loop over all MEs
2426 void Main::editUndo()
2428 if (currentMapEditor())
2429 currentMapEditor()->undo();
2432 void Main::editRedo()
2434 if (currentMapEditor())
2435 currentMapEditor()->redo();
2438 void Main::editCopy()
2440 if (currentMapEditor())
2441 currentMapEditor()->copy();
2444 void Main::editPaste()
2446 if (currentMapEditor())
2447 currentMapEditor()->paste();
2450 void Main::editCut()
2452 if (currentMapEditor())
2453 currentMapEditor()->cut();
2456 void Main::editOpenFindWindow()
2458 findWindow->popup();
2459 findWindow->raise();
2460 findWindow->setActiveWindow();
2463 void Main::editFind(QString s)
2466 BranchObj *bo=currentMapEditor()->findText(s, cs);
2469 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2472 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2473 tr("No matches found for \"%1\"").arg(s));
2477 void Main::editFindChanged()
2478 { // Notify editor, to abort the current find process
2479 currentMapEditor()->findReset();
2482 void Main::openTabs(QStringList urls)
2484 if (!urls.isEmpty())
2488 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2490 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2492 QString u=urls.takeFirst();
2493 procBrowser = new QProcess( this );
2495 procBrowser->start(browser,args);
2496 if ( !procBrowser->waitForStarted())
2498 // try to set path to browser
2499 QMessageBox::warning(0,
2501 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2502 tr("Please use Settings->")+tr("Set application to open an URL"));
2507 if (browser.contains("konqueror"))
2509 for (int i=0; i<urls.size(); i++)
2512 // Try to open new tab in existing konqueror started previously by vym
2513 p=new QProcess (this);
2515 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2516 "konqueror-mainwindow#1"<<
2519 p->start ("dcop",args);
2520 if ( !p->waitForStarted() ) success=false;
2523 QMessageBox::warning(0,
2525 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2527 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2529 for (int i=0; i<urls.size(); i++)
2531 // Try to open new tab in firefox
2532 p=new QProcess (this);
2533 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2534 p->start (browser,args);
2535 if ( !p->waitForStarted() ) success=false;
2538 QMessageBox::warning(0,
2540 tr("Couldn't start %1 to open a new tab").arg(browser));
2543 QMessageBox::warning(0,
2545 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2549 void Main::editOpenURL()
2552 if (currentMapEditor())
2554 QString url=currentMapEditor()->getURL();
2556 if (url=="") return;
2557 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2558 procBrowser = new QProcess( this );
2560 procBrowser->start(browser,args);
2561 if ( !procBrowser->waitForStarted())
2563 // try to set path to browser
2564 QMessageBox::warning(0,
2566 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2567 tr("Please use Settings->")+tr("Set application to open an URL"));
2572 void Main::editOpenURLTab()
2574 if (currentMapEditor())
2577 urls.append(currentMapEditor()->getURL());
2581 void Main::editOpenMultipleURLTabs()
2583 if (currentMapEditor())
2586 urls=currentMapEditor()->getURLs();
2592 void Main::editURL()
2594 if (currentMapEditor())
2595 currentMapEditor()->editURL();
2598 void Main::editHeading2URL()
2600 if (currentMapEditor())
2601 currentMapEditor()->editHeading2URL();
2604 void Main::editBugzilla2URL()
2606 if (currentMapEditor())
2607 currentMapEditor()->editBugzilla2URL();
2610 void Main::editFATE2URL()
2612 if (currentMapEditor())
2613 currentMapEditor()->editFATE2URL();
2616 void Main::editHeadingFinished()
2618 // only called from editHeading(), so there is a currentME
2619 MapEditor *me=currentMapEditor();
2621 #if defined(Q_OS_MACX)
2623 me->setHeading(lineedit->text());
2625 lineedit->releaseKeyboard();
2629 if (!prevSelection.isEmpty()) me->select(prevSelection);
2633 void Main::editHeading()
2635 if (currentMapEditor())
2637 MapEditor *me=currentMapEditor();
2638 QString oldSel=me->getSelectString();
2640 if (lineedit->isVisible())
2641 editHeadingFinished();
2646 QString s=currentMapEditor()->getHeading(ok,p);
2650 #if defined(Q_OS_MACX)
2651 p = currentMapEditor()->mapToGlobal( currentMapEditor()->worldMatrix().map( p));
2652 QDialog *d =new QDialog(NULL);
2653 QLineEdit *le=new QLineEdit (d);
2654 d->setWindowFlags (Qt::FramelessWindowHint);
2655 d->setGeometry(p.x(),p.y(),230,25);
2656 le->resize (d->width()-10,d->height());
2659 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2660 d->activateWindow();
2662 currentMapEditor()->setHeading (le->text());
2665 editHeadingFinished();
2667 p = currentMapEditor()->mapTo(this, currentMapEditor()->worldMatrix().map( p));
2668 lineedit->setGeometry(p.x(),p.y(),230,25);
2669 lineedit->setText(s);
2670 lineedit->setCursorPosition(1);
2671 lineedit->selectAll();
2673 lineedit->grabKeyboard();
2674 lineedit->setFocus();
2678 } // currentMapEditor()
2681 void Main::openVymLinks(const QStringList &vl)
2683 for (int j=0; j<vl.size(); j++)
2685 // compare path with already loaded maps
2689 for (i=0;i<=tabWidget->count() -1;i++)
2691 me=(MapEditor*)tabWidget->page(i);
2692 if (vl.at(j)==me->getFilePath() )
2701 if (!QFile(vl.at(j)).exists() )
2702 QMessageBox::critical( 0, tr( "Critical Error" ),
2703 tr("Couldn't open map %1").arg(vl.at(j)));
2706 fileLoad (vl.at(j), NewMap);
2707 tabWidget->setCurrentPage (tabWidget->count()-1);
2710 // Go to tab containing the map
2711 tabWidget->setCurrentPage (index);
2715 void Main::editOpenVymLink()
2717 if (currentMapEditor())
2720 vl.append(currentMapEditor()->getVymLink());
2725 void Main::editOpenMultipleVymLinks()
2727 QString currentVymLink;
2728 if (currentMapEditor())
2730 QStringList vl=currentMapEditor()->getVymLinks();
2735 void Main::editVymLink()
2737 if (currentMapEditor())
2738 currentMapEditor()->editVymLink();
2741 void Main::editDeleteVymLink()
2743 if (currentMapEditor())
2744 currentMapEditor()->deleteVymLink();
2747 void Main::editToggleHideExport()
2749 if (currentMapEditor())
2750 currentMapEditor()->toggleHideExport();
2753 void Main::editMapInfo()
2755 if (currentMapEditor())
2756 currentMapEditor()->editMapInfo();
2759 void Main::editMoveUp()
2761 if (currentMapEditor())
2762 currentMapEditor()->moveBranchUp();
2765 void Main::editMoveDown()
2767 if (currentMapEditor())
2768 currentMapEditor()->moveBranchDown();
2771 void Main::editToggleScroll()
2773 if (currentMapEditor())
2775 currentMapEditor()->toggleScroll();
2779 void Main::editUnScrollAll()
2781 if (currentMapEditor())
2782 currentMapEditor()->unScrollAll();
2785 void Main::editNewBranch()
2787 MapEditor *me=currentMapEditor();
2788 if (!lineedit->isVisible() && me)
2790 BranchObj *bo=(BranchObj*)me->getSelection();
2791 BranchObj *newbo=me->addNewBranch(0);
2794 me->select (newbo->getSelectString());
2798 if (actionSettingsAutoEdit->isOn())
2800 if (!actionSettingsAutoSelectHeading->isOn())
2801 prevSelection=bo->getSelectString();
2807 void Main::editNewBranchBefore()
2809 MapEditor *me=currentMapEditor();
2810 if (!lineedit->isVisible() && me)
2812 BranchObj *bo=(BranchObj*)me->getSelection();
2813 BranchObj *newbo=me->addNewBranchBefore();
2816 me->select (newbo->getSelectString());
2820 if (actionSettingsAutoEdit->isOn())
2822 if (!actionSettingsAutoSelectHeading->isOn())
2823 prevSelection=bo->getSelectString();
2829 void Main::editNewBranchAbove()
2831 MapEditor *me=currentMapEditor();
2832 if (!lineedit->isVisible() && me)
2834 BranchObj *bo=(BranchObj*)me->getSelection();
2835 BranchObj *newbo=me->addNewBranch (-1);
2838 me->select (newbo->getSelectString());
2842 if (actionSettingsAutoEdit->isOn())
2844 if (!actionSettingsAutoSelectHeading->isOn())
2845 prevSelection=bo->getSelectString();
2851 void Main::editNewBranchBelow()
2853 MapEditor *me=currentMapEditor();
2854 if (!lineedit->isVisible() && me)
2856 BranchObj *bo=(BranchObj*)me->getSelection();
2857 BranchObj *newbo=me->addNewBranch (1);
2860 me->select (newbo->getSelectString());
2864 if (actionSettingsAutoEdit->isOn())
2866 if (!actionSettingsAutoSelectHeading->isOn())
2867 prevSelection=bo->getSelectString();
2873 void Main::editImportAdd()
2875 fileLoad (ImportAdd);
2878 void Main::editImportReplace()
2880 fileLoad (ImportReplace);
2883 void Main::editSaveBranch()
2885 fileSaveAs (PartOfMap);
2888 void Main::editDeleteKeepChilds()
2890 if (currentMapEditor())
2891 currentMapEditor()->deleteKeepChilds();
2894 void Main::editDeleteChilds()
2896 if (currentMapEditor())
2897 currentMapEditor()->deleteChilds();
2900 void Main::editDeleteSelection()
2902 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2903 currentMapEditor()->deleteSelection();
2906 void Main::editUpperBranch()
2908 if (currentMapEditor())
2909 currentMapEditor()->selectUpperBranch();
2912 void Main::editLowerBranch()
2914 if (currentMapEditor())
2915 currentMapEditor()->selectLowerBranch();
2918 void Main::editLeftBranch()
2920 if (currentMapEditor())
2921 currentMapEditor()->selectLeftBranch();
2924 void Main::editRightBranch()
2926 if (currentMapEditor())
2927 currentMapEditor()->selectRightBranch();
2930 void Main::editFirstBranch()
2932 if (currentMapEditor())
2933 currentMapEditor()->selectFirstBranch();
2936 void Main::editLastBranch()
2938 if (currentMapEditor())
2939 currentMapEditor()->selectLastBranch();
2942 void Main::editLoadImage()
2944 if (currentMapEditor())
2945 currentMapEditor()->loadFloatImage();
2948 void Main::editSaveImage()
2950 if (currentMapEditor())
2951 currentMapEditor()->saveFloatImage();
2954 void Main::editFollowXLink(QAction *a)
2957 if (currentMapEditor())
2958 currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
2961 void Main::editEditXLink(QAction *a)
2963 if (currentMapEditor())
2964 currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
2967 void Main::formatSelectColor()
2969 if (currentMapEditor())
2971 QColor col = QColorDialog::getColor((currentColor ), this );
2972 if ( !col.isValid() ) return;
2973 colorChanged( col );
2977 void Main::formatPickColor()
2979 if (currentMapEditor())
2980 colorChanged( currentMapEditor()->getCurrentHeadingColor() );
2983 void Main::colorChanged(QColor c)
2985 QPixmap pix( 16, 16 );
2987 actionFormatColor->setIconSet( pix );
2991 void Main::formatColorItem()
2993 if (currentMapEditor())
2994 currentMapEditor()->colorItem(currentColor);
2997 void Main::formatColorBranch()
2999 if (currentMapEditor())
3000 currentMapEditor()->colorBranch(currentColor);
3003 void Main::formatLinkStyleLine()
3005 if (currentMapEditor())
3006 currentMapEditor()->setLinkStyle(StyleLine);
3009 void Main::formatLinkStyleParabel()
3011 if (currentMapEditor())
3012 currentMapEditor()->setLinkStyle(StyleParabel);
3015 void Main::formatLinkStylePolyLine()
3017 if (currentMapEditor())
3018 currentMapEditor()->setLinkStyle(StylePolyLine);
3021 void Main::formatLinkStylePolyParabel()
3023 if (currentMapEditor())
3024 currentMapEditor()->setLinkStyle(StylePolyParabel);
3027 void Main::formatSelectBackColor()
3029 if (currentMapEditor())
3030 currentMapEditor()->selectBackgroundColor();
3033 void Main::formatSelectLinkColor()
3035 if (currentMapEditor())
3036 currentMapEditor()->selectLinkColor();
3039 void Main::formatToggleLinkColorHint()
3041 currentMapEditor()->toggleLinkColorHint();
3044 void Main::formatFrameNone()
3046 if (currentMapEditor())
3047 currentMapEditor()->setFrame(NoFrame);
3050 void Main::formatFrameRectangle()
3052 if (currentMapEditor())
3053 currentMapEditor()->setFrame(Rectangle);
3056 void Main::formatIncludeImagesVer()
3058 if (currentMapEditor())
3059 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
3062 void Main::formatIncludeImagesHor()
3064 if (currentMapEditor())
3065 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
3068 void Main::formatHideLinkUnselected()
3070 if (currentMapEditor())
3071 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3074 void Main::viewZoomReset()
3076 if (currentMapEditor())
3080 currentMapEditor()->setWorldMatrix( m );
3081 currentMapEditor()->setViewCenter();
3082 currentMapEditor()->adjustCanvasSize();
3086 void Main::viewZoomIn()
3088 if (currentMapEditor())
3090 QMatrix m = currentMapEditor()->worldMatrix();
3091 m.scale( 1.25, 1.25 );
3092 currentMapEditor()->setWorldMatrix( m );
3093 currentMapEditor()->setViewCenter();
3094 currentMapEditor()->adjustCanvasSize();
3098 void Main::viewZoomOut()
3100 if (currentMapEditor())
3102 QMatrix m = currentMapEditor()->worldMatrix();
3103 m.scale( 0.8, 0.8 );
3104 currentMapEditor()->setWorldMatrix( m );
3105 currentMapEditor()->setViewCenter();
3106 currentMapEditor()->adjustCanvasSize();
3110 bool Main::settingsPDF()
3112 // Default browser is set in constructor
3114 QString text = QInputDialog::getText(
3115 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3116 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3118 settings.setValue ("/mainwindow/readerPDF",text);
3123 bool Main::settingsURL()
3125 // Default browser is set in constructor
3127 QString text = QInputDialog::getText(
3128 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3129 settings.value("/mainwindow/readerURL").toString()
3132 settings.setValue ("/mainwindow/readerURL",text);
3136 void Main::settingsToggleDelKey()
3138 if (actionSettingsUseDelKey->isOn())
3140 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3143 actionEditDelete->setAccel (QKeySequence (""));
3147 void Main::windowToggleNoteEditor()
3149 if (textEditor->showWithMain() )
3150 windowHideNoteEditor();
3152 windowShowNoteEditor();
3155 void Main::windowToggleHistory()
3157 if (currentMapEditor())
3158 currentMapEditor()->toggleHistoryWindow();
3161 void Main::updateNoteFlag()
3163 if (currentMapEditor())
3164 currentMapEditor()->updateNoteFlag();
3167 void Main::updateActions()
3169 MapEditor *me=currentMapEditor();
3172 // updateActions is also called when NoteEditor is closed
3173 actionViewToggleNoteEditor->setOn (textEditor->showWithMain());
3176 if (me->getLinkColorHint()==HeadingColor)
3177 actionFormatLinkColorHint->setOn(true);
3179 actionFormatLinkColorHint->setOn(false);
3181 switch (me->getLinkStyle())
3184 actionFormatLinkStyleLine->setOn(true);
3187 actionFormatLinkStyleParabel->setOn(true);
3190 actionFormatLinkStylePolyLine->setOn(true);
3192 case StylePolyParabel:
3193 actionFormatLinkStylePolyParabel->setOn(true);
3199 QPixmap pix( 16, 16 );
3200 pix.fill( me->getBackgroundColor() );
3201 actionFormatBackColor->setIconSet( pix );
3202 pix.fill( me->getDefLinkColor() );
3203 actionFormatLinkColor->setIconSet( pix );
3205 actionFileSave->setEnabled( me->isUnsaved() );
3206 if (me->isUndoAvailable())
3207 actionEditUndo->setEnabled( true);
3209 actionEditUndo->setEnabled( false);
3211 if (me->isRedoAvailable())
3212 actionEditRedo->setEnabled( true);
3214 actionEditRedo->setEnabled( false);
3216 LinkableMapObj *selection=me->getSelection();
3219 if ( (typeid(*selection) == typeid(BranchObj)) ||
3220 (typeid(*selection) == typeid(MapCenterObj)) )
3222 BranchObj *bo=(BranchObj*)selection;
3223 // Take care of links
3224 if (bo->countXLinks()==0)
3226 branchXLinksContextMenuEdit->clear();
3227 branchXLinksContextMenuFollow->clear();
3232 branchXLinksContextMenuEdit->clear();
3233 branchXLinksContextMenuFollow->clear();
3234 for (int i=0; i<=bo->countXLinks();i++)
3236 bot=bo->XLinkTargetAt(i);
3239 s=bot->getHeading();
3242 branchXLinksContextMenuFollow->addAction (s);
3243 branchXLinksContextMenuEdit->addAction (s);
3248 standardFlagsDefault->setEnabled (true);
3250 actionEditToggleScroll->setEnabled (true);
3251 if ( bo->isScrolled() )
3252 actionEditToggleScroll->setOn(true);
3254 actionEditToggleScroll->setOn(false);
3256 if ( bo->getURL().isEmpty() )
3258 actionEditOpenURL->setEnabled (false);
3259 actionEditOpenURLTab->setEnabled (false);
3263 actionEditOpenURL->setEnabled (true);
3264 actionEditOpenURLTab->setEnabled (true);
3266 if ( bo->getVymLink().isEmpty() )
3268 actionEditOpenVymLink->setEnabled (false);
3269 actionEditDeleteVymLink->setEnabled (false);
3272 actionEditOpenVymLink->setEnabled (true);
3273 actionEditDeleteVymLink->setEnabled (true);
3276 if (bo->canMoveBranchUp())
3277 actionEditMoveUp->setEnabled (true);
3279 actionEditMoveUp->setEnabled (false);
3280 if (bo->canMoveBranchDown())
3281 actionEditMoveDown->setEnabled (true);
3283 actionEditMoveDown->setEnabled (false);
3286 actionEditToggleHideExport->setEnabled (true);
3287 actionEditToggleHideExport->setOn (bo->hideInExport() );
3289 actionEditCopy->setEnabled (true);
3290 actionEditCut->setEnabled (true);
3291 if (!clipboardEmpty)
3292 actionEditPaste->setEnabled (true);
3294 actionEditPaste->setEnabled (false);
3295 for (a=actionListBranches.first();a;a=actionListBranches.next())
3296 a->setEnabled(true);
3297 actionEditDelete->setEnabled (true);
3298 switch (selection->getFrameType())
3301 actionFormatFrameNone->setOn(true);
3304 actionFormatFrameRectangle->setOn(true);
3309 actionFormatIncludeImagesVer->setOn
3310 ( ((BranchObj*)selection)->getIncludeImagesVer());
3311 actionFormatIncludeImagesHor->setOn
3312 ( ((BranchObj*)selection)->getIncludeImagesHor());
3313 actionFormatHideLinkUnselected->setOn
3314 (selection->getHideLinkUnselected());
3316 if ( (typeid(*selection) == typeid(FloatImageObj)) )
3318 FloatObj *fo=(FloatImageObj*)selection;
3319 //FIXME do this in mainwindow standardFlagsDefault->setEnabled (false);
3321 actionEditOpenURL->setEnabled (false);
3322 actionEditOpenVymLink->setEnabled (false);
3323 actionEditDeleteVymLink->setEnabled (false);
3324 actionEditToggleHideExport->setEnabled (true);
3325 actionEditToggleHideExport->setOn (fo->hideInExport() );
3328 actionEditCopy->setEnabled (true);
3329 actionEditCut->setEnabled (true);
3330 actionEditPaste->setEnabled (false);
3331 for (a=actionListBranches.first();a;a=actionListBranches.next())
3332 a->setEnabled(false);
3333 actionEditDelete->setEnabled (true);
3334 actionFormatHideLinkUnselected->setOn
3335 ( selection->getHideLinkUnselected());
3336 actionEditMoveUp->setEnabled (false);
3337 actionEditMoveDown->setEnabled (false);
3342 actionEditCopy->setEnabled (false);
3343 actionEditCut->setEnabled (false);
3344 actionEditPaste->setEnabled (false);
3345 for (a=actionListBranches.first();a;a=actionListBranches.next())
3346 a->setEnabled(false);
3348 actionEditToggleScroll->setEnabled (false);
3349 actionEditOpenURL->setEnabled (false);
3350 actionEditOpenVymLink->setEnabled (false);
3351 actionEditDeleteVymLink->setEnabled (false);
3352 actionEditHeading2URL->setEnabled (false);
3353 actionEditDelete->setEnabled (false);
3354 actionEditMoveUp->setEnabled (false);
3355 actionEditMoveDown->setEnabled (false);
3356 actionEditToggleHideExport->setEnabled (false);
3360 ModMode Main::getModMode()
3362 if (actionModModeColor->isOn()) return ModModeColor;
3363 if (actionModModeCopy->isOn()) return ModModeCopy;
3364 if (actionModModeXLink->isOn()) return ModModeXLink;
3368 bool Main::autoEdit()
3370 return actionSettingsAutoEdit->isOn();
3373 bool Main::autoSelectHeading()
3375 return actionSettingsAutoSelectHeading->isOn();
3378 bool Main::useFlagGroups()
3380 return actionSettingsUseFlagGroups->isOn();
3383 void Main::windowShowNoteEditor()
3385 textEditor->setShowWithMain(true);
3387 actionViewToggleNoteEditor->setOn (true);
3390 void Main::windowHideNoteEditor()
3392 textEditor->setShowWithMain(false);
3394 actionViewToggleNoteEditor->setOn (false);
3397 void Main::windowNextEditor()
3399 if (tabWidget->currentPageIndex() < tabWidget->count())
3400 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3403 void Main::windowPreviousEditor()
3405 if (tabWidget->currentPageIndex() >0)
3406 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3409 void Main::standardFlagChanged()
3411 currentMapEditor()->toggleStandardFlag(sender()->name());
3414 void Main::testFunction()
3416 if (!currentMapEditor()) return;
3417 currentMapEditor()->testFunction();
3421 void Main::testCommand()
3423 if (!currentMapEditor()) return;
3425 QString com = QInputDialog::getText(
3426 __VYM, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3427 if (ok) currentMapEditor()->parseAtom(com);
3430 void Main::helpDoc()
3432 QString locale = QLocale::system().name();
3434 if (locale.left(2)=="es")
3435 docname="vym_es.pdf";
3439 #if defined(Q_OS_MACX)
3440 docdir.setPath("./vym.app/Contents");
3442 // default path in SUSE LINUX
3443 docdir.setPath("/usr/share/doc/packages/vym/doc");
3446 if (!docdir.exists() )
3448 // relative path for easy testing in tarball
3449 docdir.setPath("doc");
3450 if (!docdir.exists() )
3452 // relative path for testing while still writing vym.tex
3453 docdir.setPath("doc/tex/vym.pdf");
3454 if (!docdir.exists() )
3456 // Try yet another one for Knoppix
3457 docdir.setPath("/usr/share/doc/packages/vym");
3458 if (!docdir.exists() )
3460 QMessageBox::critical(0,
3461 tr("Critcal error"),
3462 tr("Couldn't find the documentation\n"
3463 "vym.pdf in various directories."));
3470 QString docpath=docdir.path()+"/"+docname;
3471 Process *pdfProc = new Process();
3472 pdfProc->clearArguments();
3473 pdfProc->addArgument( settings.value("/mainwindow/readerPDF").toString());
3474 pdfProc->addArgument( docpath);
3476 if ( !pdfProc->start() )
3479 QMessageBox::warning(0,
3481 tr("Couldn't find a viewer to open %1.\n").arg(docpath)+
3482 tr("Please use Settings->")+tr("Set application to open PDF files"));
3489 void Main::helpAbout()
3492 ad.setName ("aboutwindow");
3493 ad.setMinimumSize(500,500);
3494 ad.resize (QSize (500,500));
3498 void Main::helpAboutQT()
3500 QMessageBox::aboutQt( this, "Qt Application Example" );