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);
133 // Create tab widget which holds the maps
134 tabWidget= new QTabWidget (this);
135 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
136 this, SLOT( editorChanged( QWidget * ) ) );
138 lineedit=new QLineEdit (this);
141 setCentralWidget(tabWidget);
145 setupFormatActions();
149 setupSettingsActions();
151 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
156 restoreState (settings.value("/mainwindow/state",0).toByteArray());
158 // Initialize Find window
159 findWindow=new FindWindow(NULL);
160 findWindow->move (x(),y()+70);
161 connect (findWindow, SIGNAL( findButton(QString) ),
162 this, SLOT(editFind(QString) ) );
163 connect (findWindow, SIGNAL( somethingChanged() ),
164 this, SLOT(editFindChanged() ) );
166 // Connect TextEditor, so that we can update flags if text changes
167 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
168 connect (textEditor, SIGNAL (textEditorClosed() ), this, SLOT (updateActions()));
176 settings.setValue ( "/mainwindow/geometry/size", size() );
177 settings.setValue ( "/mainwindow/geometry/pos", pos() );
179 settings.setValue ("/mainwindow/state",saveState(0));
181 settings.setValue( "/version/version", __VYM_VERSION );
182 settings.setValue( "/version/builddate", __BUILD_DATE );
184 settings.setValue( "/mapeditor/editmode/autoSelectHeading",actionSettingsAutoSelectHeading->isOn() );
185 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
186 settings.setValue( "/mapeditor/editmode/autoEdit",actionSettingsAutoEdit->isOn() );
187 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
188 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
189 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
191 // To make the texteditor save its settings, call the destructor
194 // Remove temporary directory
195 removeDir (QDir(tmpVymDir));
198 void Main::loadCmdLine()
200 /* TODO draw some kind of splashscreen while loading...
206 QStringList flist=options.getFileList();
207 QStringList::Iterator it=flist.begin();
209 while (it !=flist.end() )
211 fileLoad (*it, NewMap);
217 void Main::statusMessage(const QString &s)
219 statusBar()->message (s);
222 void Main::closeEvent (QCloseEvent* )
228 void Main::setupFileActions()
230 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
231 QToolBar *tb = addToolBar( tr ("&Map") );
232 tb->setObjectName ("mapTB");
235 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New...","File menu" ),this);
236 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
237 a->setShortcut ( Qt::CTRL + Qt::Key_N );
239 fileMenu->addAction (a);
240 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
242 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
243 a->setStatusTip (tr( "Open","Status tip File menu" ) );
244 a->setShortcut ( Qt::CTRL + Qt::Key_O );
246 fileMenu->addAction (a);
247 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
249 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
250 fileMenu->addSeparator();
252 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
253 a->setStatusTip ( tr( "Save","Status tip file menu" ));
254 a->setShortcut (Qt::CTRL + Qt::Key_S );
256 fileMenu->addAction (a);
257 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
260 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
261 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
262 fileMenu->addAction (a);
263 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
265 fileMenu->addSeparator();
267 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
269 a = new QAction(tr("KDE Bookmarks"), this);
270 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE bookmarks")));
271 a->addTo (fileImportMenu);
272 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) );
274 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
276 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
277 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
278 a->addTo (fileImportMenu);
279 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
282 a = new QAction("Mind Manager...",this);
283 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
284 fileImportMenu->addAction (a);
285 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
287 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
288 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
289 fileImportMenu->addAction (a);
290 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
292 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
294 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
295 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
296 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
297 fileExportMenu->addAction (a);
299 a = new QAction( "Open Office...", this);
300 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
301 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
302 fileExportMenu->addAction (a);
304 a = new QAction( "Webpage (XHTML)...",this );
305 a->setShortcut (Qt::ALT + Qt::Key_X);
306 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
307 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
308 fileExportMenu->addAction (a);
310 a = new QAction( "Text (ASCII)...", this);
311 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
312 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
313 fileExportMenu->addAction (a);
315 a = new QAction( tr("KDE Bookmarks","File menu"), this);
316 a->setStatusTip( tr( "Export as %1").arg(tr("KDE Bookmarks" )));
317 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
318 fileExportMenu->addAction (a);
320 a = new QAction( "Taskjuggler...", this );
321 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
322 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
323 fileExportMenu->addAction (a);
325 a = new QAction( "LaTeX...", this);
326 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
327 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
328 fileExportMenu->addAction (a);
330 a = new QAction( "XML..." , this );
331 a->setStatusTip (tr( "Export as %1").arg("XML"));
332 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
333 fileExportMenu->addAction (a);
335 fileMenu->addSeparator();
337 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
338 a->setStatusTip ( tr( "Print" ,"File menu") );
339 a->setShortcut (Qt::CTRL + Qt::Key_P );
341 fileMenu->addAction (a);
342 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
345 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
346 a->setStatusTip (tr( "Close Map" ) );
347 a->setShortcut (Qt::ALT + Qt::Key_C );
348 fileMenu->addAction (a);
349 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
351 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+__VYM, this);
352 a->setStatusTip ( tr( "Exit")+" "+__VYM );
353 a->setShortcut (Qt::CTRL + Qt::Key_Q );
354 fileMenu->addAction (a);
355 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
360 void Main::setupEditActions()
362 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
363 tb->setLabel( "Edit Actions" );
364 tb->setObjectName ("actionsTB");
365 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
369 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
370 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
371 a->setStatusTip (tr( "Undo" ) );
372 a->setShortcut ( Qt::CTRL + Qt::Key_Z );
373 a->setEnabled (false);
375 editMenu->addAction (a);
378 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
379 a->setStatusTip (tr( "Redo" ));
380 a->setShortcut (Qt::CTRL + Qt::Key_Y );
382 editMenu->addAction (a);
383 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
386 editMenu->addSeparator();
387 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
388 a->setStatusTip ( tr( "Copy" ) );
389 a->setShortcut (Qt::CTRL + Qt::Key_C );
390 a->setEnabled (false);
392 editMenu->addAction (a);
393 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
396 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
397 a->setStatusTip ( tr( "Cut" ) );
398 a->setShortcut (Qt::CTRL + Qt::Key_X );
399 a->setEnabled (false);
401 editMenu->addAction (a);
403 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
405 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
406 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
407 a->setStatusTip ( tr( "Paste" ) );
408 a->setShortcut ( Qt::CTRL + Qt::Key_V );
409 a->setEnabled (false);
411 editMenu->addAction (a);
414 // Shortcuts to modify heading:
415 a = new QAction(tr( "Edit heading","Edit menu" ),this);
416 a->setStatusTip ( tr( "edit Heading" ));
417 a->setShortcut ( Qt::Key_Enter);
418 // a->setShortcutContext (Qt::WindowShortcut);
420 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
421 actionListBranches.append(a);
422 a = new QAction( tr( "Edit heading","Edit menu" ), this);
423 a->setStatusTip (tr( "edit Heading" ));
424 a->setShortcut (Qt::Key_Return );
425 //a->setShortcutContext (Qt::WindowShortcut);
427 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
428 actionListBranches.append(a);
429 editMenu->addAction (a);
431 a = new QAction( tr( "Edit heading","Edit menu" ), this);
432 a->setStatusTip (tr( "edit Heading" ));
433 a->setShortcut ( Qt::Key_F2 );
434 a->setShortcutContext (Qt::WindowShortcut);
436 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
437 actionListBranches.append(a);
439 // Shortcut to delete selection
440 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
441 a->setStatusTip (tr( "Delete Selection" ));
442 a->setShortcut ( Qt::Key_Delete);
443 a->setShortcutContext (Qt::WindowShortcut);
445 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
448 // Shortcut to add branch
449 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
450 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
451 alt->setShortcut (Qt::Key_A);
452 alt->setShortcutContext (Qt::WindowShortcut);
454 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
455 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
456 a->setStatusTip ( tr( "Add a branch as child of selection" ));
457 a->setShortcut (Qt::Key_Insert);
458 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
459 actionListBranches.append(a);
460 #if defined (Q_OS_MACX)
461 // In OSX show different shortcut in menues, the keys work indepently always
462 actionEditAddBranch=alt;
464 actionEditAddBranch=a;
466 editMenu->addAction (actionEditAddBranch);
467 tb->addAction (actionEditAddBranch);
470 // Add branch by inserting it at selection
471 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
472 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
473 a->setShortcut (Qt::ALT + Qt::Key_Insert );
474 a->setShortcutContext (Qt::WindowShortcut);
476 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
477 a->setEnabled (false);
478 actionListBranches.append(a);
479 actionEditAddBranchBefore=a;
480 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
481 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
482 a->setShortcut ( Qt::ALT + Qt::Key_A );
483 a->setShortcutContext (Qt::WindowShortcut);
485 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
486 actionListBranches.append(a);
489 a = new QAction(tr( "Add branch above","Edit menu" ), this);
490 a->setStatusTip ( tr( "Add a branch above selection" ));
491 a->setShortcut (Qt::SHIFT+Qt::Key_Insert );
492 a->setShortcutContext (Qt::WindowShortcut);
494 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
495 a->setEnabled (false);
496 actionListBranches.append(a);
497 actionEditAddBranchAbove=a;
498 a = new QAction(tr( "Add branch above","Edit menu" ), this);
499 a->setStatusTip ( tr( "Add a branch above selection" ));
500 a->setShortcut (Qt::SHIFT+Qt::Key_A );
501 a->setShortcutContext (Qt::WindowShortcut);
503 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
504 actionListBranches.append(a);
507 a = new QAction(tr( "Add branch below","Edit menu" ), this);
508 a->setStatusTip ( tr( "Add a branch below selection" ));
509 a->setShortcut (Qt::CTRL +Qt::Key_Insert );
510 a->setShortcutContext (Qt::WindowShortcut);
512 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
513 a->setEnabled (false);
514 actionListBranches.append(a);
515 actionEditAddBranchBelow=a;
516 a = new QAction(tr( "Add branch below","Edit menu" ), this);
517 a->setStatusTip ( tr( "Add a branch below selection" ));
518 a->setShortcut (Qt::CTRL +Qt::Key_A );
519 a->setShortcutContext (Qt::WindowShortcut);
521 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
522 actionListBranches.append(a);
524 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
525 a->setStatusTip ( tr( "Move branch up" ) );
526 a->setShortcut (Qt::Key_PageUp );
527 a->setEnabled (false);
529 editMenu->addAction (a);
530 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
533 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
534 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
535 a->setStatusTip (tr( "Move branch down" ) );
536 a->setShortcut ( Qt::Key_PageDown );
537 a->setEnabled (false);
539 editMenu->addAction (a);
540 actionEditMoveDown=a;
543 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this);
544 a->setShortcut ( Qt::Key_ScrollLock );
545 a->setStatusTip (tr( "Scroll branch" ) );
546 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
548 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
549 alt->setShortcut ( Qt::Key_S );
550 alt->setStatusTip (tr( "Scroll branch" ));
551 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
552 #if defined(Q_OS_MACX)
553 actionEditToggleScroll=alt;
555 actionEditToggleScroll=a;
557 actionEditToggleScroll->setEnabled (false);
558 actionEditToggleScroll->setToggleAction(true);
559 tb->addAction (actionEditToggleScroll);
560 editMenu->addAction ( actionEditToggleScroll);
561 editMenu->addAction (actionEditToggleScroll);
564 actionListBranches.append(actionEditToggleScroll);
566 a = new QAction( tr( "Unscroll all scrolled branches","Edit menu" ), this);
567 a->setStatusTip (tr( "Unscroll all" ));
568 editMenu->addAction (a);
569 connect( a, SIGNAL( triggered() ), this, SLOT( editUnScrollAll() ) );
571 editMenu->addSeparator();
573 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
574 a->setStatusTip (tr( "Find" ) );
575 a->setShortcut (Qt::CTRL + Qt::Key_F );
576 editMenu->addAction (a);
577 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
579 editMenu->addSeparator();
581 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
582 a->setShortcut (Qt::CTRL + Qt::Key_U );
583 a->setShortcut (tr( "Open URL" ));
586 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
589 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
590 a->setStatusTip (tr( "Open URL in new tab" ));
591 a->setShortcut (Qt::CTRL+Qt::Key_U );
593 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
594 actionEditOpenURLTab=a;
596 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
597 a->setStatusTip (tr( "Open all URLs in subtree" ));
599 actionListBranches.append(a);
600 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
601 actionEditOpenMultipleURLTabs=a;
603 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
604 a->setStatusTip ( tr( "Edit URL" ) );
605 a->setShortcut (Qt::SHIFT + Qt::CTRL + Qt::Key_U );
606 //a->setShortcut ( Qt::Key_U );
607 a->setShortcutContext (Qt::WindowShortcut);
608 actionListBranches.append(a);
610 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
613 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
614 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
615 a->setEnabled (false);
616 actionListBranches.append(a);
617 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
618 actionEditHeading2URL=a;
620 a = new QAction(tr( "Create URL to Bugzilla","Edit menu" ), this);
621 a->setStatusTip ( tr( "Create URL to Bugzilla" ));
622 a->setEnabled (false);
623 actionListBranches.append(a);
624 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
625 actionEditBugzilla2URL=a;
627 a = new QAction(tr( "Create URL to FATE","Edit menu" ), this);
628 a->setStatusTip ( tr( "Create URL to FATE" ));
629 a->setEnabled (false);
630 actionListBranches.append(a);
631 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
632 actionEditFATE2URL=a;
634 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
635 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
637 a->setEnabled (false);
638 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
639 actionEditOpenVymLink=a;
641 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
642 a->setStatusTip ( tr( "Open all vym links in subtree" ));
643 a->setEnabled (false);
644 actionListBranches.append(a);
645 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
646 actionEditOpenMultipleVymLinks=a;
649 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
650 a->setEnabled (false);
651 a->setStatusTip ( tr( "Edit link to another vym map" ));
652 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
653 actionListBranches.append(a);
656 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
657 a->setStatusTip ( tr( "Delete link to another vym map" ));
658 a->setEnabled (false);
659 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
660 actionEditDeleteVymLink=a;
662 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
663 a->setStatusTip ( tr( "Hide object in exports" ) );
664 a->setShortcut (Qt::Key_H );
665 a->setToggleAction(true);
667 a->setEnabled (false);
668 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
669 actionEditToggleHideExport=a;
671 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
672 a->setStatusTip ( tr( "Edit Map Info" ));
673 a->setEnabled (true);
674 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
677 // Import at selection (adding to selection)
678 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
679 a->setStatusTip (tr( "Add map at selection" ));
680 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
681 a->setEnabled (false);
682 actionListBranches.append(a);
683 actionEditImportAdd=a;
685 // Import at selection (replacing selection)
686 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
687 a->setStatusTip (tr( "Replace selection with map" ));
688 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
689 a->setEnabled (false);
690 actionListBranches.append(a);
691 actionEditImportReplace=a;
694 a = new QAction( tr( "Save selection","Edit menu" ), this);
695 a->setStatusTip (tr( "Save selection" ));
696 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
697 a->setEnabled (false);
698 actionListBranches.append(a);
699 actionEditSaveBranch=a;
701 // Only remove branch, not its childs
702 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
703 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
704 a->setShortcut (Qt::ALT + Qt::Key_Delete );
705 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChilds() ) );
706 a->setEnabled (false);
708 actionListBranches.append(a);
709 actionEditDeleteKeepChilds=a;
711 // Only remove childs of a branch
712 a = new QAction( tr( "Remove childs","Edit menu" ), this);
713 a->setStatusTip (tr( "Remove childs of branch" ));
714 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
715 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChilds() ) );
716 a->setEnabled (false);
717 actionListBranches.append(a);
718 actionEditDeleteChilds=a;
720 // Shortcuts for navigating with cursor:
721 a = new QAction(tr( "Select upper branch","Edit menu" ), this);
722 a->setStatusTip ( tr( "Select upper branch" ));
723 a->setShortcut (Qt::Key_Up );
724 a->setShortcutContext (Qt::WindowShortcut);
726 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
727 a = new QAction( tr( "Select lower branch","Edit menu" ),this);
728 a->setStatusTip (tr( "Select lower branch" ));
729 a->setShortcut ( Qt::Key_Down );
730 a->setShortcutContext (Qt::WindowShortcut);
732 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
733 a = new QAction(tr( "Select left branch","Edit menu" ), this);
734 a->setStatusTip ( tr( "Select left branch" ));
735 a->setShortcut (Qt::Key_Left );
736 a->setShortcutContext (Qt::WindowShortcut);
738 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
739 a = new QAction( tr( "Select child branch","Edit menu" ), this);
740 a->setStatusTip (tr( "Select right branch" ));
741 a->setShortcut (Qt::Key_Right);
742 a->setShortcutContext (Qt::WindowShortcut);
744 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
745 a = new QAction( tr( "Select first branch","Edit menu" ), this);
746 a->setStatusTip (tr( "Select first branch" ));
747 a->setShortcut (Qt::Key_Home );
748 a->setShortcutContext (Qt::WindowShortcut);
750 a->setEnabled (false);
751 editMenu->addAction (a);
752 actionListBranches.append(a);
753 actionEditSelectFirst=a;
754 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
755 a = new QAction( tr( "Select last branch","Edit menu" ),this);
756 a->setStatusTip (tr( "Select last branch" ));
757 a->setShortcut ( Qt::Key_End );
758 a->setShortcutContext (Qt::WindowShortcut);
760 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
761 a->setEnabled (false);
762 editMenu->addAction (a);
763 actionListBranches.append(a);
764 actionEditSelectLast=a;
766 a = new QAction( tr( "Add Image...","Edit menu" ), this);
767 a->setStatusTip (tr( "Add Image" ));
768 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
769 actionEditLoadImage=a;
774 void Main::setupFormatActions()
776 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
778 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
779 tb->setObjectName ("formatTB");
782 pix.fill (Qt::black);
783 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
784 a->setStatusTip ( tr( "Set Color" ));
785 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
787 formatMenu->addAction (a);
789 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
790 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
791 a->setShortcut (Qt::CTRL + Qt::Key_K );
792 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
793 a->setEnabled (false);
795 formatMenu->addAction (a);
796 actionListBranches.append(a);
797 actionFormatPickColor=a;
799 a= new QAction(QPixmap(iconPath+"formatcoloritem.png"), tr( "Color &branch","Edit menu" ), this);
800 a->setStatusTip ( tr( "Color branch" ) );
801 a->setShortcut (Qt::CTRL + Qt::Key_I);
802 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorItem() ) );
803 a->setEnabled (false);
805 formatMenu->addAction (a);
806 actionListBranches.append(a);
807 actionFormatColorBranch=a;
809 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color sub&tree","Edit menu" ), this);
810 a->setStatusTip ( tr( "Color Subtree" ));
811 a->setShortcut (Qt::CTRL + Qt::Key_T);
812 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
813 a->setEnabled (false);
814 formatMenu->addAction (a);
816 actionListBranches.append(a);
817 actionFormatColorSubtree=a;
819 formatMenu->addSeparator();
820 actionGroupFormatLinkStyles=new QActionGroup ( this);
821 actionGroupFormatLinkStyles->setExclusive (true);
822 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
823 a->setStatusTip (tr( "Line" ));
824 a->setToggleAction(true);
825 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
826 formatMenu->addAction (a);
827 actionFormatLinkStyleLine=a;
828 a= new QAction( tr( "Linkstyle Parabel" ), actionGroupFormatLinkStyles);
829 a->setStatusTip (tr( "Line" ));
830 a->setToggleAction(true);
831 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
832 formatMenu->addAction (a);
833 actionFormatLinkStyleParabel=a;
834 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
835 a->setStatusTip (tr( "PolyLine" ));
836 a->setToggleAction(true);
837 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
838 formatMenu->addAction (a);
839 actionFormatLinkStylePolyLine=a;
840 a= new QAction( tr( "Linkstyle Thick Parabel" ), actionGroupFormatLinkStyles);
841 a->setStatusTip (tr( "PolyParabel" ) );
842 a->setToggleAction(true);
843 a->setChecked (true);
844 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
845 formatMenu->addAction (a);
846 actionFormatLinkStylePolyParabel=a;
848 actionGroupFormatFrameTypes=new QActionGroup ( this);
849 actionGroupFormatFrameTypes->setExclusive (true);
850 a = new QAction( tr( "No Frame","Branch attribute" ), actionGroupFormatFrameTypes );
851 a->setStatusTip (tr("No Frame"));
852 a->setToggleAction(true);
853 connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameNone() ) );
854 actionFormatFrameNone=a;
855 a = new QAction( tr( "Rectangle""Branch attribute" ), actionGroupFormatFrameTypes);
856 a->setStatusTip (tr( "Rectangle" ));
857 a->setToggleAction(true);
858 connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameRectangle() ) );
859 actionFormatFrameRectangle=a;
861 a = new QAction( tr( "Include images vertically","Branch attribute" ), this);
862 a->setStatusTip ( tr ("Include top and bottom position of images into branch"));
863 a->setToggleAction(true);
864 connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesVer() ) );
865 actionFormatIncludeImagesVer=a;
867 a = new QAction( tr( "Include images horizontally","Branch attribute" ), this);
868 a->setStatusTip ( tr ("Include left and right position of images into branch"));
869 a->setToggleAction(true);
870 connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesHor() ) );
871 actionFormatIncludeImagesHor=a;
873 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
874 a->setStatusTip (tr( "Hide link" ));
875 a->setToggleAction(true);
876 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
877 actionFormatHideLinkUnselected=a;
879 formatMenu->addSeparator();
880 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
881 a->setStatusTip (tr( "Use same color for links and headings" ));
882 a->setToggleAction(true);
883 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
884 formatMenu->addAction (a);
885 actionFormatLinkColorHint=a;
887 pix.fill (Qt::white);
888 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
889 a->setStatusTip (tr( "Set Link Color" ));
890 formatMenu->addAction (a);
891 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
892 actionFormatLinkColor=a;
894 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
895 a->setStatusTip (tr( "Set Background Color" ));
896 formatMenu->addAction (a);
897 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
898 actionFormatBackColor=a;
902 void Main::setupViewActions()
904 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
905 tb->setLabel( "View Actions" );
906 tb->setObjectName ("viewTB");
907 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
910 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
911 a->setStatusTip ( tr( "Zoom reset" ) );
912 a->setShortcut (Qt::CTRL + Qt::Key_0 );
914 viewMenu->addAction (a);
915 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
917 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
918 a->setStatusTip (tr( "Zoom in" ));
919 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
921 viewMenu->addAction (a);
922 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
924 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
925 a->setStatusTip (tr( "Zoom out" ));
926 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
928 viewMenu->addAction (a);
929 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
932 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
933 a->setStatusTip ( tr( "Show Note Editor" ));
934 a->setShortcut ( Qt::CTRL + Qt::Key_E );
935 a->setToggleAction(true);
936 if (textEditor->showWithMain())
941 viewMenu->addAction (a);
942 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
943 actionViewToggleNoteEditor=a;
945 a = new QAction( tr( "Show history window","View action" ),this );
946 a->setStatusTip ( tr( "Show history window" ));
947 a->setShortcut ( Qt::CTRL + Qt::Key_H );
948 a->setToggleAction(false);
949 viewMenu->addAction (a);
950 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
951 actionViewToggleHistoryWindow=a;
953 a = new QAction(tr( "Next Window","View action" ), this);
954 a->setStatusTip ( tr( "&Next Window" ) );
955 a->setShortcut (Qt::ALT + Qt::Key_N );
956 viewMenu->addAction (a);
957 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
959 a = new QAction (tr( "Previous Window","View action" ), this );
960 a->setStatusTip (tr( "&Previous Window" ));
961 a->setShortcut (Qt::ALT + Qt::Key_P );
962 viewMenu->addAction (a);
963 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
967 void Main::setupModeActions()
969 //QPopupMenu *menu = new QPopupMenu( this );
970 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
972 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
973 tb->setObjectName ("modesTB");
975 actionGroupModModes=new QActionGroup ( this);
976 actionGroupModModes->setExclusive (true);
977 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
978 a->setShortcut (Qt::Key_J);
979 a->setStatusTip ( tr( "Use modifier to color branches" ));
980 a->setToggleAction(true);
983 actionModModeColor=a;
985 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
986 a->setShortcut( Qt::Key_K);
987 a->setStatusTip( tr( "Use modifier to copy" ));
988 a->setToggleAction(true);
992 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
993 a->setShortcut (Qt::Key_L);
994 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
995 a->setToggleAction(true);
997 actionModModeXLink=a;
1001 void Main::setupFlagActions()
1003 // Create System Flags
1004 systemFlagsDefault = new FlagRowObj ();
1005 systemFlagsDefault->setVisibility (false);
1006 systemFlagsDefault->setName ("systemFlagsDef");
1008 FlagObj *fo = new FlagObj ();
1009 fo->load(QPixmap(flagsPath+"flag-note.png"));
1010 fo->setName("note");
1011 fo->setToolTip(tr("Note","Systemflag"));
1012 systemFlagsDefault->addFlag (fo); // makes deep copy
1014 fo->load(QPixmap(flagsPath+"flag-url.png"));
1016 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
1017 systemFlagsDefault->addFlag (fo);
1019 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1020 fo->setName("vymLink");
1021 fo->setToolTip(tr("Link to another vym map","Systemflag"));
1022 systemFlagsDefault->addFlag (fo);
1024 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1025 fo->setName("scrolledright");
1026 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
1027 systemFlagsDefault->addFlag (fo);
1029 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1030 fo->setName("tmpUnscrolledright");
1031 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
1032 systemFlagsDefault->addFlag (fo);
1034 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1035 fo->setName("hideInExport");
1036 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
1037 systemFlagsDefault->addFlag (fo);
1039 // Create Standard Flags
1040 QToolBar *tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1041 tb->setObjectName ("standardFlagTB");
1043 standardFlagsDefault = new FlagRowObj ();
1044 standardFlagsDefault->setVisibility (false);
1045 standardFlagsDefault->setName ("standardFlagsDef");
1046 standardFlagsDefault->setToolBar (tb);
1048 fo->load(QPixmap(flagsPath+"flag-exclamationmark.png"));
1049 fo->setName ("exclamationmark");
1050 fo->setGroup("standard-mark");
1051 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1054 a->setCheckable(true);
1055 a->setObjectName(fo->getName());
1056 a->setToolTip(tr("Take care!","Standardflag"));
1057 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1058 standardFlagsDefault->addFlag (fo); // makes deep copy
1060 fo->load(QPixmap(flagsPath+"flag-questionmark.png"));
1061 fo->setName("questionmark");
1062 fo->setGroup("standard-mark");
1063 a=new QAction (fo->getPixmap(),fo->getName(),this);
1066 a->setCheckable(true);
1067 a->setObjectName(fo->getName());
1068 a->setToolTip(tr("Really?","Standardflag"));
1069 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1070 standardFlagsDefault->addFlag (fo);
1072 fo->load(QPixmap(flagsPath+"flag-hook-green.png"));
1073 fo->setName("hook-green");
1074 fo->setGroup("standard-hook");
1075 a=new QAction (fo->getPixmap(),fo->getName(),this);
1078 a->setCheckable(true);
1079 a->setObjectName(fo->getName());
1080 a->setToolTip(tr("ok!","Standardflag"));
1081 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1082 standardFlagsDefault->addFlag (fo);
1084 fo->load(QPixmap(flagsPath+"flag-cross-red.png"));
1085 fo->setName("cross-red");
1086 fo->setGroup("standard-hook");
1087 a=new QAction (fo->getPixmap(),fo->getName(),this);
1090 a->setCheckable(true);
1091 a->setObjectName(fo->getName());
1092 a->setToolTip(tr("Not ok!","Standardflag"));
1093 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1094 standardFlagsDefault->addFlag (fo);
1096 fo->load(QPixmap(flagsPath+"flag-stopsign.png"));
1097 fo->setName("stopsign");
1098 a=new QAction (fo->getPixmap(),fo->getName(),this);
1101 a->setCheckable(true);
1102 a->setObjectName(fo->getName());
1103 a->setToolTip(tr("This won't work!","Standardflag"));
1104 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1105 standardFlagsDefault->addFlag (fo);
1107 fo->load(QPixmap(flagsPath+"flag-smiley-good.png"));
1108 fo->setName("smiley-good");
1109 fo->setGroup("standard-smiley");
1110 a=new QAction (fo->getPixmap(),fo->getName(),this);
1113 a->setCheckable(true);
1114 a->setObjectName(fo->getName());
1115 a->setToolTip(tr("Good","Standardflag"));
1116 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1117 standardFlagsDefault->addFlag (fo);
1119 fo->load(QPixmap(flagsPath+"flag-smiley-sad.png"));
1120 fo->setName("smiley-sad");
1121 fo->setGroup("standard-smiley");
1122 a=new QAction (fo->getPixmap(),fo->getName(),this);
1125 a->setCheckable(true);
1126 a->setObjectName(fo->getName());
1127 a->setToolTip(tr("Bad","Standardflag"));
1128 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1129 standardFlagsDefault->addFlag (fo);
1131 fo->load(QPixmap(flagsPath+"flag-smiley-omg.png"));
1132 // Original omg.png (in KDE emoticons)
1133 fo->setName("smiley-omg");
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("Oh no!","Standardflag"));
1141 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1142 standardFlagsDefault->addFlag (fo);
1144 fo->load(QPixmap(flagsPath+"flag-kalarm.png"));
1145 fo->setName("clock");
1146 a=new QAction (fo->getPixmap(),fo->getName(),this);
1149 a->setCheckable(true);
1150 a->setObjectName(fo->getName());
1151 a->setToolTip(tr("Time critical","Standardflag"));
1152 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1153 standardFlagsDefault->addFlag (fo);
1155 fo->load(QPixmap(flagsPath+"flag-phone.png"));
1156 fo->setName("phone");
1157 a=new QAction (fo->getPixmap(),fo->getName(),this);
1160 a->setCheckable(true);
1161 a->setObjectName(fo->getName());
1162 a->setToolTip(tr("Call...","Standardflag"));
1163 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1164 standardFlagsDefault->addFlag (fo);
1166 fo->load(QPixmap(flagsPath+"flag-lamp.png"));
1167 fo->setName("lamp");
1168 a=new QAction (fo->getPixmap(),fo->getName(),this);
1171 a->setCheckable(true);
1172 a->setObjectName(fo->getName());
1173 a->setToolTip(tr("Idea!","Standardflag"));
1174 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1175 standardFlagsDefault->addFlag (fo);
1177 fo->load(QPixmap(flagsPath+"flag-arrow-up.png"));
1178 fo->setName("arrow-up");
1179 fo->setGroup("standard-arrow");
1180 a=new QAction (fo->getPixmap(),fo->getName(),this);
1183 a->setCheckable(true);
1184 a->setObjectName(fo->getName());
1185 a->setToolTip(tr("Important","Standardflag"));
1186 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1187 standardFlagsDefault->addFlag (fo);
1189 fo->load(QPixmap(flagsPath+"flag-arrow-down.png"));
1190 fo->setName("arrow-down");
1191 fo->setGroup("standard-arrow");
1192 a=new QAction (fo->getPixmap(),fo->getName(),this);
1195 a->setCheckable(true);
1196 a->setObjectName(fo->getName());
1197 a->setToolTip(tr("Unimportant","Standardflag"));
1198 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1199 standardFlagsDefault->addFlag (fo);
1201 fo->load(QPixmap(flagsPath+"flag-arrow-2up.png"));
1202 fo->setName("2arrow-up");
1203 fo->setGroup("standard-arrow");
1204 a=new QAction (fo->getPixmap(),fo->getName(),this);
1207 a->setCheckable(true);
1208 a->setObjectName(fo->getName());
1209 a->setToolTip(tr("Very important!","Standardflag"));
1210 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1211 standardFlagsDefault->addFlag (fo);
1213 fo->load(QPixmap(flagsPath+"flag-arrow-2down.png"));
1214 fo->setName("2arrow-down");
1215 fo->setGroup("standard-arrow");
1216 a=new QAction (fo->getPixmap(),fo->getName(),this);
1219 a->setCheckable(true);
1220 a->setObjectName(fo->getName());
1221 a->setToolTip(tr("Very unimportant!","Standardflag"));
1222 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1223 standardFlagsDefault->addFlag (fo);
1225 fo->load(QPixmap(flagsPath+"flag-thumb-up.png"));
1226 fo->setName("thumb-up");
1227 fo->setGroup("standard-thumb");
1228 a=new QAction (fo->getPixmap(),fo->getName(),this);
1231 a->setCheckable(true);
1232 a->setObjectName(fo->getName());
1233 a->setToolTip(tr("I like this","Standardflag"));
1234 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1235 standardFlagsDefault->addFlag (fo);
1237 fo->load(QPixmap(flagsPath+"flag-thumb-down.png"));
1238 fo->setName("thumb-down");
1239 fo->setGroup("standard-thumb");
1240 a=new QAction (fo->getPixmap(),fo->getName(),this);
1243 a->setCheckable(true);
1244 a->setObjectName(fo->getName());
1245 a->setToolTip(tr("I do not like this","Standardflag"));
1246 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1247 standardFlagsDefault->addFlag (fo);
1249 fo->load(QPixmap(flagsPath+"flag-rose.png"));
1250 fo->setName("rose");
1251 a=new QAction (fo->getPixmap(),fo->getName(),this);
1254 a->setCheckable(true);
1255 a->setObjectName(fo->getName());
1256 a->setToolTip(tr("Rose","Standardflag"));
1257 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1258 standardFlagsDefault->addFlag (fo);
1260 fo->load(QPixmap(flagsPath+"flag-heart.png"));
1261 fo->setName("heart");
1262 a=new QAction (fo->getPixmap(),fo->getName(),this);
1264 a->setCheckable(true);
1265 a->setObjectName(fo->getName());
1266 a->setToolTip(tr("I just love... ","Standardflag"));
1267 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1268 standardFlagsDefault->addFlag (fo);
1270 fo->load(QPixmap(flagsPath+"flag-present.png"));
1271 fo->setName("present");
1272 a=new QAction (fo->getPixmap(),fo->getName(),this);
1275 a->setCheckable(true);
1276 a->setObjectName(fo->getName());
1277 a->setToolTip(tr("Surprise!","Standardflag"));
1278 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1279 standardFlagsDefault->addFlag (fo);
1281 fo->load(QPixmap(flagsPath+"flag-flash.png"));
1282 fo->setName("flash");
1283 a=new QAction (fo->getPixmap(),fo->getName(),this);
1286 a->setCheckable(true);
1287 a->setObjectName(fo->getName());
1288 a->setToolTip(tr("Dangerous","Standardflag"));
1289 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1290 standardFlagsDefault->addFlag (fo);
1292 fo->load(QPixmap(flagsPath+"flag-info.png"));
1293 // Original: xsldbg_output.png
1294 fo->setName("info");
1295 a=new QAction (fo->getPixmap(),fo->getName(),this);
1298 a->setCheckable(true);
1299 a->setObjectName(fo->getName());
1300 a->setToolTip(tr("Info","Standardflag"));
1301 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1302 standardFlagsDefault->addFlag (fo);
1304 fo->load(QPixmap(flagsPath+"flag-lifebelt.png"));
1305 // Original khelpcenter.png
1306 fo->setName("lifebelt");
1307 a=new QAction (fo->getPixmap(),fo->getName(),this);
1310 a->setCheckable(true);
1311 a->setObjectName(fo->getName());
1312 a->setToolTip(tr("This will help","Standardflag"));
1313 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1314 standardFlagsDefault->addFlag (fo);
1320 void Main::setupSettingsActions()
1322 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1326 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1327 a->setStatusTip ( tr( "Set application to open pdf files"));
1328 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1329 settingsMenu->addAction (a);
1331 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1332 a->setStatusTip( tr( "Set application to open external links"));
1333 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1334 settingsMenu->addAction (a);
1336 settingsMenu->addSeparator();
1337 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1338 a->setStatusTip( tr( "Edit branch after adding it" ));
1339 a->setToggleAction(true);
1340 a->setOn ( settings.value ("/mapeditor/editmode/autoEdit",true).toBool());
1341 settingsMenu->addAction (a);
1342 actionSettingsAutoEdit=a;
1344 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1345 a->setStatusTip( tr( "Select branch after adding it" ));
1346 a->setToggleAction(true);
1347 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectHeading",false).toBool() );
1348 settingsMenu->addAction (a);
1349 actionSettingsAutoSelectHeading=a;
1351 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1352 a->setStatusTip( tr( "Select heading before editing" ));
1353 a->setToggleAction(true);
1354 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1355 settingsMenu->addAction (a);
1356 actionSettingsAutoSelectText=a;
1358 a= new QAction( tr( "Delete key","Settings action" ), this);
1359 a->setStatusTip( tr( "Delete key for deleting branches" ));
1360 a->setToggleAction(true);
1361 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",false).toBool() );
1362 settingsMenu->addAction (a);
1363 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1364 actionSettingsUseDelKey=a;
1366 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1367 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1368 a->setToggleAction(true);
1369 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1370 settingsMenu->addAction (a);
1371 actionSettingsUseFlagGroups=a;
1373 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1374 a->setStatusTip( tr( "Use hide flag during exports " ));
1375 a->setToggleAction(true);
1376 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1377 settingsMenu->addAction (a);
1378 actionSettingsUseHideExport=a;
1382 void Main::setupTestActions()
1384 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1387 a = new QAction( "Test function" , this);
1388 a->setStatusTip( "Call test function" );
1389 a->setShortcut (Qt::Key_F4 );
1390 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction() ) );
1391 testMenu->addAction (a);
1392 a = new QAction( "Command" , this);
1393 a->setStatusTip( "Enter command to call in editor" );
1394 a->setShortcut (Qt::Key_F5 );
1395 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1396 testMenu->addAction (a);
1400 void Main::setupHelpActions()
1402 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1405 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1406 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1407 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1408 helpMenu->addAction (a);
1410 a = new QAction( tr( "About VYM","Help action" ), this);
1411 a->setStatusTip( tr( "About VYM")+" "__VYM);
1412 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1413 helpMenu->addAction (a);
1415 a = new QAction( tr( "About QT","Help action" ), this);
1416 a->setStatusTip( tr( "Information about QT toolkit" ));
1417 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1418 helpMenu->addAction (a);
1422 void Main::setupContextMenus()
1426 // Context Menu for branch or mapcenter
1427 branchContextMenu =new QMenu (this);
1430 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1431 branchAddContextMenu->addAction (actionEditPaste );
1432 branchAddContextMenu->addAction ( actionEditAddBranch );
1433 branchAddContextMenu->addAction ( actionEditAddBranchBefore );
1434 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1435 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1436 branchAddContextMenu->addSeparator();
1437 branchAddContextMenu->addAction ( actionEditImportAdd );
1438 branchAddContextMenu->addAction ( actionEditImportReplace );
1441 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1442 branchRemoveContextMenu->addAction (actionEditCut);
1443 branchRemoveContextMenu->addAction ( actionEditDelete );
1444 branchRemoveContextMenu->addAction ( actionEditDeleteKeepChilds );
1445 branchRemoveContextMenu->addAction ( actionEditDeleteChilds );
1448 actionEditSaveBranch->addTo( branchContextMenu );
1450 branchContextMenu->addSeparator();
1451 branchContextMenu->addAction ( actionFormatFrameNone );
1452 branchContextMenu->addAction ( actionFormatFrameRectangle);
1453 branchContextMenu->addAction ( actionFormatHideLinkUnselected );
1455 branchContextMenu->addSeparator();
1456 branchContextMenu->addAction ( actionEditLoadImage);
1457 branchContextMenu->addAction ( actionFormatIncludeImagesVer );
1458 branchContextMenu->addAction ( actionFormatIncludeImagesHor );
1460 // Submenu for Links (URLs, vymLinks)
1461 branchLinksContextMenu =new QMenu (this);
1463 branchContextMenu->addSeparator();
1464 branchLinksContextMenu=branchContextMenu->addMenu(tr("URLs and vymLinks","Context menu name"));
1465 branchLinksContextMenu->addAction ( actionEditOpenURL );
1466 branchLinksContextMenu->addAction ( actionEditOpenURLTab );
1467 branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
1468 branchLinksContextMenu->addAction ( actionEditURL );
1469 branchLinksContextMenu->addAction ( actionEditHeading2URL );
1470 branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
1471 if (settings.value( "/mainwindow/showTestMenu",true).toBool() )
1473 branchLinksContextMenu->addAction ( actionEditFATE2URL );
1475 branchLinksContextMenu->addSeparator();
1476 branchLinksContextMenu->addAction ( actionEditOpenVymLink );
1477 branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
1478 branchLinksContextMenu->addAction ( actionEditVymLink );
1479 branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
1482 // Context Menu for XLinks in a branch menu
1483 // This will be populated "on demand" in MapEditor::updateActions
1484 branchContextMenu->addSeparator();
1485 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1486 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1487 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1488 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1491 // Context menu for floatimage
1492 floatimageContextMenu =new QMenu (this);
1493 a= new QAction (tr ("Save image","Context action"),this);
1494 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1495 floatimageContextMenu->addAction (a);
1497 floatimageContextMenu->addSeparator();
1498 actionEditCopy->addTo( floatimageContextMenu );
1499 actionEditCut->addTo( floatimageContextMenu );
1501 floatimageContextMenu->addSeparator();
1502 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1505 // Context menu for canvas
1506 canvasContextMenu =new QMenu (this);
1507 actionEditMapInfo->addTo( canvasContextMenu );
1508 canvasContextMenu->insertSeparator();
1509 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1510 canvasContextMenu->insertSeparator();
1511 actionFormatLinkColorHint->addTo( canvasContextMenu );
1512 actionFormatLinkColor->addTo( canvasContextMenu );
1513 actionFormatBackColor->addTo( canvasContextMenu );
1515 // Menu for last opened files
1517 for (int i = 0; i < MaxRecentFiles; ++i)
1519 recentFileActs[i] = new QAction(this);
1520 recentFileActs[i]->setVisible(false);
1521 fileLastMapsMenu->addAction(recentFileActs[i]);
1522 connect(recentFileActs[i], SIGNAL(triggered()),
1523 this, SLOT(fileLoadRecent()));
1525 setupRecentMapsMenu();
1528 void Main::setupRecentMapsMenu()
1530 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1532 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1534 for (int i = 0; i < numRecentFiles; ++i) {
1535 //QString text = tr("&%1 %2").arg(i + 1).arg(strippedName(files[i]));
1536 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1537 recentFileActs[i]->setText(text);
1538 recentFileActs[i]->setData(files[i]);
1539 recentFileActs[i]->setVisible(true);
1541 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1542 recentFileActs[j]->setVisible(false);
1545 void Main::hideEvent (QHideEvent * )
1547 if (!textEditor->isMinimized() ) textEditor->hide();
1550 void Main::showEvent (QShowEvent * )
1552 if (textEditor->showWithMain()) textEditor->showNormal();
1555 bool Main::reallyWriteDirectory(const QString &dir)
1557 QStringList eList = QDir(dir).entryList();
1558 if (eList.first() ==".") eList.pop_front(); // remove "."
1559 if (eList.first() =="..") eList.pop_front(); // remove "."
1560 if (!eList.isEmpty())
1562 QMessageBox mb( __VYM,
1563 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?","write directory").arg(dir),
1564 QMessageBox::Warning,
1566 QMessageBox::Cancel | QMessageBox::Default,
1567 QMessageBox::QMessageBox::NoButton );
1569 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1570 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1573 case QMessageBox::Yes:
1576 case QMessageBox::Cancel:
1584 QString Main::browseDirectory (const QString &caption)
1586 Q3FileDialog fd(this,caption);
1587 fd.setMode (Q3FileDialog::DirectoryOnly);
1588 fd.setCaption(__VYM " - "+caption);
1591 if ( fd.exec() == QDialog::Accepted )
1592 return fd.selectedFile();
1597 MapEditor* Main::currentMapEditor() const
1599 if ( tabWidget->currentPage() &&
1600 tabWidget->currentPage()->inherits( "MapEditor" ) )
1601 return (MapEditor*)tabWidget->currentPage();
1605 //TODO not used now, maybe use this for overview window later
1606 void Main::newView()
1608 // Open a new view... have it delete when closed.
1609 Main *m = new Main(0, 0, Qt::WDestructiveClose);
1610 qApp->setMainWidget(m);
1612 qApp->setMainWidget(0);
1615 void Main::editorChanged(QWidget *)
1617 // Unselect all possibly selected objects
1618 // (Important to update note editor)
1621 for (i=0;i<=tabWidget->count() -1;i++)
1624 me=(MapEditor*)tabWidget->page(i);
1627 currentMapEditor()->reselect();
1629 // Update actions to in menus and toolbars according to editor
1630 currentMapEditor()->updateActions();
1633 void Main::fileNew()
1635 QString fn="unnamed";
1636 MapEditor* medit = new MapEditor ( NULL);
1637 tabWidget->addTab (medit,fn);
1638 tabWidget->showPage(medit);
1639 medit->viewport()->setFocus();
1640 // For the very first map we do not have flagrows yet...
1641 medit->select("mc:");
1644 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1646 ErrorCode err=success;
1648 // fn is usually the archive, mapfile the file after uncompressing
1651 // Make fn absolute (needed for unzip)
1652 fn=QDir (fn).absPath();
1658 // Check, if map is already loaded
1660 while (i<=tabWidget->count() -1)
1662 me=(MapEditor*)tabWidget->page(i);
1663 if (me->getFilePath() == fn)
1665 // Already there, ask for confirmation
1666 QMessageBox mb( __VYM,
1667 tr("The map %1\nis already opened."
1668 "Opening the same map in multiple editors may lead \n"
1669 "to confusion when finishing working with vym."
1670 "Do you want to").arg(fn),
1671 QMessageBox::Warning,
1672 QMessageBox::Yes | QMessageBox::Default,
1673 QMessageBox::Cancel | QMessageBox::Escape,
1674 QMessageBox::NoButton);
1675 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1676 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1679 case QMessageBox::Yes:
1681 i=tabWidget->count();
1683 case QMessageBox::Cancel:
1695 if ( !fn.isEmpty() )
1697 me = currentMapEditor();
1698 int tabIndex=tabWidget->currentPageIndex();
1699 // Check first, if mapeditor exists
1700 // If it is not default AND we want a new map,
1701 // create a new mapeditor in a new tab
1702 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1704 me= new MapEditor ( NULL);
1705 tabWidget->addTab (me,fn);
1706 tabIndex=tabWidget->indexOf (me);
1707 tabWidget->setCurrentPage (tabIndex);
1710 // Check, if file exists (important for creating new files
1711 // from command line
1712 if (!QFile(fn).exists() )
1714 QMessageBox mb( __VYM,
1715 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1716 QMessageBox::Question,
1718 QMessageBox::Cancel | QMessageBox::Default,
1719 QMessageBox::NoButton );
1721 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1722 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1725 case QMessageBox::Yes:
1727 currentMapEditor()->setFilePath(fn);
1728 tabWidget->setTabLabel (currentMapEditor(),
1729 currentMapEditor()->getFileName() );
1730 statusBar()->message( "Created " + fn , statusbarTime );
1733 case QMessageBox::Cancel:
1734 // don't create new map
1735 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1742 //tabWidget->currentPage() won't be NULL here, because of above...
1743 tabWidget->showPage(me);
1744 me->viewport()->setFocus();
1746 // Create temporary directory for packing
1748 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
1751 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1752 tr("Couldn't create temporary directory before load\n"));
1756 // Try to unzip file
1757 err=unzipDir (tmpMapDir,fn);
1761 me->setZipped(false);
1764 me->setZipped(true);
1766 // Look for mapname.xml
1767 mapfile= fn.left(fn.findRev(".",-1,true));
1768 mapfile=mapfile.section( '/', -1 );
1769 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1770 if (!file.exists() )
1772 // mapname.xml does not exist, well,
1773 // maybe some renamed the mapname.vym file...
1774 // Try to find any .xml in the toplevel
1775 // directory of the .vym file
1776 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1777 if (flist.count()==1)
1779 // Only one entry, take this one
1780 mapfile=tmpMapDir + "/"+flist.first();
1783 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1784 *it=tmpMapDir + "/" + *it;
1785 // TODO Multiple entries, load all (but only the first one into this ME)
1786 //mainWindow->fileLoadFromTmp (flist);
1787 //returnCode=1; // Silently forget this attempt to load
1788 qWarning ("MainWindow::load (fn) multimap found...");
1791 if (flist.isEmpty() )
1793 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1794 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1797 } //file doesn't exist
1799 mapfile=file.name();
1804 // Save existing filename in case we import
1805 QString fn_org=me->getFilePath();
1807 // Finally load map into mapEditor
1808 me->setFilePath (mapfile,fn);
1809 err=me->load(mapfile,lmode);
1811 // Restore old (maybe empty) filepath, if this is an import
1813 me->setFilePath (fn_org);
1816 // Finally check for errors and go home
1819 if (lmode==NewMap) fileCloseMap();
1820 statusBar()->message( "Could not load " + fn, statusbarTime );
1825 me->setFilePath (fn);
1826 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1827 if (fn.left(9)!="/tmp/vym-")
1829 // Only append to lastMaps if not loaded from a tmpDir
1830 // e.g. imported bookmarks are in a tmpDir
1831 addRecentMap(me->getFilePath() );
1833 actionFilePrint->setEnabled (true);
1835 statusBar()->message( "Loaded " + fn, statusbarTime );
1839 removeDir (QDir(tmpMapDir));
1845 void Main::fileLoad(const LoadMode &lmode)
1847 QStringList filters;
1848 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1849 QFileDialog *fd=new QFileDialog( this);
1850 fd->setDir (lastFileDir);
1851 fd->setFileMode (QFileDialog::ExistingFiles);
1852 fd->setFilters (filters);
1856 fd->setCaption(__VYM " - " +tr("Load vym map"));
1859 fd->setCaption(__VYM " - " +tr("Import: Add vym map to selection"));
1862 fd->setCaption(__VYM " - " +tr("Import: Replace selection with vym map"));
1868 if ( fd->exec() == QDialog::Accepted )
1870 lastFileDir=fd->directory().path();
1871 QStringList flist = fd->selectedFiles();
1872 QStringList::Iterator it = flist.begin();
1873 while( it != flist.end() )
1876 fileLoad(*it, lmode);
1883 void Main::fileLoad()
1888 void Main::fileLoadRecent()
1890 QAction *action = qobject_cast<QAction *>(sender());
1892 fileLoad (action->data().toString(), NewMap);
1895 void Main::addRecentMap (const QString &fileName)
1898 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1899 files.removeAll(fileName);
1900 files.prepend(fileName);
1901 while (files.size() > MaxRecentFiles)
1904 settings.setValue("/mainwindow/recentFileList", files);
1906 setupRecentMapsMenu();
1909 void Main::fileSave(const SaveMode &savemode)
1911 // tmp dir for zipping
1915 ErrorCode err=success;
1917 QString safeFilePath;
1919 bool saveZipped=currentMapEditor()->saveZipped();
1921 MapEditor * me=currentMapEditor();
1924 QString fn=me->getFilePath();
1925 // filename=unnamed, filepath="" in constructor...
1926 if ( !fn.isEmpty() )
1928 // We have a filepath, go on saving
1929 // First remove existing file, we
1930 // don't want to add to old zip archives
1934 QMessageBox::warning( 0, tr( "Save Error" ),
1935 fn+ tr("\ncould not be removed before saving"));
1937 // Look, if we should zip the data:
1940 QMessageBox mb( __VYM,
1941 tr("The map %1\ndid not use the compressed "
1942 "vym file format.\nWriting it uncompressed will also write images \n"
1943 "and flags and thus may overwrite files in the "
1944 "given directory\n\nDo you want to write the map").arg(fn),
1945 QMessageBox::Warning,
1946 QMessageBox::Yes | QMessageBox::Default,
1948 QMessageBox::Cancel | QMessageBox::Escape);
1949 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
1950 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
1951 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1954 case QMessageBox::Yes:
1955 // save compressed (default file format)
1958 case QMessageBox::No:
1959 // save uncompressed
1962 case QMessageBox::Cancel:
1971 // Create temporary directory for packing
1973 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
1976 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1977 tr("Couldn't create temporary directory before save\n"));
1981 safeFilePath=me->getFilePath();
1982 me->setFilePath (tmpMapDir+"/"+
1983 me->getMapName()+ ".xml",
1985 me->save (savemode);
1986 me->setFilePath (safeFilePath);
1988 zipDir (tmpMapDir,fn);
1993 safeFilePath=me->getFilePath();
1994 me->setFilePath (fn, safeFilePath);
1995 me->save (savemode);
1996 me->setFilePath (safeFilePath);
1998 } // filepath available
2001 // We have no filepath yet,
2002 // call fileSaveAs() now, this will call fileSave()
2004 fileSaveAs(savemode);
2008 if (saveZipped && !tmpMapDir.isEmpty())
2010 removeDir (QDir(tmpMapDir));
2014 statusBar()->message(
2015 tr("Saved %1").arg(me->getFilePath()),
2017 addRecentMap (me->getFilePath() );
2019 statusBar()->message(
2020 tr("Couldn't save ").arg(me->getFilePath()),
2024 void Main::fileSave()
2026 fileSave (CompleteMap);
2029 void Main::fileSaveAs(const SaveMode& savemode)
2033 if (currentMapEditor())
2035 if (savemode==CompleteMap)
2036 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2038 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2039 if ( !fn.isEmpty() )
2041 // Check for existing file
2042 if (QFile (fn).exists())
2044 QMessageBox mb( __VYM,
2045 tr("The file %1\nexists already. Do you want to").arg(fn),
2046 QMessageBox::Warning,
2047 QMessageBox::Yes | QMessageBox::Default,
2048 QMessageBox::Cancel | QMessageBox::Escape,
2049 QMessageBox::NoButton);
2050 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2051 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2054 case QMessageBox::Yes:
2057 case QMessageBox::Cancel:
2064 // New file, add extension to filename, if missing
2065 // This is always .vym or .vyp, depending on savemode
2066 if (savemode==CompleteMap)
2068 if (!fn.contains (".vym") && !fn.contains (".xml"))
2072 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2081 currentMapEditor()->setFilePath(fn);
2085 if (savemode==CompleteMap)
2086 tabWidget->setTabLabel (currentMapEditor(),
2087 currentMapEditor()->getFileName() );
2093 void Main::fileSaveAs()
2095 fileSaveAs (CompleteMap);
2098 void Main::fileImportKDEBookmarks()
2100 ImportKDEBookmarks im;
2102 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2103 currentMapEditor()->setFilePath ("");
2106 void Main::fileImportFirefoxBookmarks()
2108 Q3FileDialog *fd=new Q3FileDialog( this);
2109 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2110 fd->setMode (Q3FileDialog::ExistingFiles);
2111 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2112 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2115 if ( fd->exec() == QDialog::Accepted )
2117 ImportFirefoxBookmarks im;
2118 QStringList flist = fd->selectedFiles();
2119 QStringList::Iterator it = flist.begin();
2120 while( it != flist.end() )
2123 if (im.transform() &&
2124 success==fileLoad (im.getTransformedFile(),NewMap) &&
2125 currentMapEditor() )
2126 currentMapEditor()->setFilePath ("");
2133 void Main::fileImportMM()
2137 Q3FileDialog *fd=new Q3FileDialog( this);
2138 fd->setDir (lastFileDir);
2139 fd->setMode (Q3FileDialog::ExistingFiles);
2140 fd->addFilter ("Mind Manager (*.mmap)");
2141 fd->setCaption(tr("Import")+" "+"Mind Manager");
2144 if ( fd->exec() == QDialog::Accepted )
2146 lastFileDir=fd->dirPath();
2147 QStringList flist = fd->selectedFiles();
2148 QStringList::Iterator it = flist.begin();
2149 while( it != flist.end() )
2152 if (im.transform() &&
2153 success==fileLoad (im.getTransformedFile(),NewMap) &&
2154 currentMapEditor() )
2155 currentMapEditor()->setFilePath ("");
2164 void Main::fileImportDir()
2166 if (currentMapEditor())
2167 currentMapEditor()->importDir();
2170 void Main::fileExportXML()
2172 if (currentMapEditor())
2174 QString dir=browseDirectory(tr("Export XML to directory"));
2175 if (dir !="" && reallyWriteDirectory(dir) )
2176 currentMapEditor()->exportXML(dir);
2181 void Main::fileExportXHTML()
2183 MapEditor *me=currentMapEditor();
2187 ExportXHTMLDialog dia(this);
2188 dia.setFilePath (me->getFilePath() );
2189 dia.setMapName (me->getMapName() );
2192 if (dia.exec()==QDialog::Accepted)
2194 QString dir=dia.getDir();
2195 // Check, if warnings should be used before overwriting
2196 // the output directory
2199 ok=reallyWriteDirectory(dir);
2205 me->exportXML (dia.getDir() );
2206 dia.doExport(me->getMapName() );
2207 if (dia.hasChanged())
2214 void Main::fileExportImage()
2216 MapEditor *me=currentMapEditor();
2220 QFileDialog *fd=new QFileDialog (this);
2221 fd->setCaption (tr("Export map as image"));
2222 fd->setFileMode(QFileDialog::AnyFile);
2223 fd->setFilters (imageIO.getFilters() );
2224 fd->setDirectory (lastImageDir);
2227 fl=fd->selectedFiles();
2228 qWarning ("Selected "+fl.first()+" filter: "+fd->selectedFilter());
2229 me->exportImage (fl.first(), imageIO.getType (fd->selectedFilter() ) );
2234 void Main::fileExportASCII()
2236 MapEditor *me=currentMapEditor();
2240 ex.setMapCenter(me->getMapCenter());
2241 ex.addFilter ("TXT (*.txt)");
2242 ex.setCaption(__VYM " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
2243 if (ex.execDialog() )
2245 me->setExportMode(true);
2247 me->setExportMode(false);
2252 void Main::fileExportLaTeX()
2254 MapEditor *me=currentMapEditor();
2258 ex.setMapCenter(me->getMapCenter());
2259 ex.addFilter ("Tex (*.tex)");
2260 ex.setCaption(__VYM " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2261 if (ex.execDialog() )
2263 me->setExportMode(true);
2265 me->setExportMode(false);
2270 void Main::fileExportKDEBookmarks()
2272 ExportKDEBookmarks ex;
2273 MapEditor *me=currentMapEditor();
2276 ex.setMapCenter (me->getMapCenter() );
2281 void Main::fileExportTaskjuggler()
2283 ExportTaskjuggler ex;
2284 MapEditor *me=currentMapEditor();
2287 ex.setMapCenter (me->getMapCenter() );
2288 ex.setCaption ( __VYM " - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2289 ex.addFilter ("Taskjuggler (*.tjp)");
2290 if (ex.execDialog() )
2292 me->setExportMode(true);
2294 me->setExportMode(false);
2299 void Main::fileExportOOPresentation()
2301 ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to")+" Open Office");
2302 // TODO add preview in dialog
2303 //ImagePreview *p =new ImagePreview (fd);
2304 //fd->setContentsPreviewEnabled( TRUE );
2305 //fd->setContentsPreview( p, p );
2306 //fd->setPreviewMode( QFileDialog::Contents );
2307 fd->setCaption(__VYM " - " +tr("Export to")+" Open Office");
2308 fd->setDir (QDir().current());
2309 if (fd->foundConfig())
2313 if ( fd->exec() == QDialog::Accepted )
2315 QString fn=fd->selectedFile();
2316 if (!fn.contains (".odp"))
2319 //lastImageDir=fn.left(fn.findRev ("/"));
2320 if (currentMapEditor())
2321 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2325 QMessageBox::warning(0,
2327 tr("Couldn't find configuration for export to Open Office\n"));
2331 void Main::fileCloseMap()
2333 if (currentMapEditor())
2335 if (currentMapEditor()->hasChanged())
2337 QMessageBox mb( __VYM,
2338 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2339 QMessageBox::Warning,
2340 QMessageBox::Yes | QMessageBox::Default,
2342 QMessageBox::Cancel | QMessageBox::Escape );
2343 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2344 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2347 case QMessageBox::Yes:
2349 fileSave(CompleteMap);
2351 case QMessageBox::No:
2352 // close without saving
2354 case QMessageBox::Cancel:
2359 currentMapEditor()->closeMap();
2360 tabWidget->removePage(currentMapEditor());
2361 if (tabWidget->count()==0)
2362 actionFilePrint->setEnabled (false);
2366 void Main::filePrint()
2368 if (currentMapEditor())
2369 currentMapEditor()->print();
2372 void Main::fileExitVYM()
2374 // Check if one or more editors have changed
2377 for (i=0;i<=tabWidget->count() -1;i++)
2380 me=(MapEditor*)tabWidget->page(i);
2382 // If something changed, ask what to do
2383 if (me->isUnsaved())
2385 tabWidget->setCurrentPage(i);
2386 QMessageBox mb( __VYM,
2387 tr("This map is not saved yet. Do you want to"),
2388 QMessageBox::Warning,
2389 QMessageBox::Yes | QMessageBox::Default,
2391 QMessageBox::Cancel | QMessageBox::Escape );
2392 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2393 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2396 mb.setActiveWindow();
2397 switch( mb.exec() ) {
2398 case QMessageBox::Yes:
2399 // save (the changed editors) and exit
2400 fileSave(CompleteMap);
2402 case QMessageBox::No:
2403 // exit without saving
2405 case QMessageBox::Cancel:
2406 // don't save and don't exit
2410 } // loop over all MEs
2414 void Main::editUndo()
2416 if (currentMapEditor())
2417 currentMapEditor()->undo();
2420 void Main::editRedo()
2422 if (currentMapEditor())
2423 currentMapEditor()->redo();
2426 void Main::editCopy()
2428 if (currentMapEditor())
2429 currentMapEditor()->copy();
2432 void Main::editPaste()
2434 if (currentMapEditor())
2435 currentMapEditor()->paste();
2438 void Main::editCut()
2440 if (currentMapEditor())
2441 currentMapEditor()->cut();
2444 void Main::editOpenFindWindow()
2446 findWindow->popup();
2447 findWindow->raise();
2448 findWindow->setActiveWindow();
2451 void Main::editFind(QString s)
2454 BranchObj *bo=currentMapEditor()->findText(s, cs);
2457 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2460 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2461 tr("No matches found for \"%1\"").arg(s));
2465 void Main::editFindChanged()
2466 { // Notify editor, to abort the current find process
2467 currentMapEditor()->findReset();
2470 void Main::openTabs(QStringList urls)
2472 if (!urls.isEmpty())
2476 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2478 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2480 QString u=urls.takeFirst();
2481 procBrowser = new QProcess( this );
2483 procBrowser->start(browser,args);
2484 if ( !procBrowser->waitForStarted())
2486 // try to set path to browser
2487 QMessageBox::warning(0,
2489 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2490 tr("Please use Settings->")+tr("Set application to open an URL"));
2495 if (browser.contains("konqueror"))
2497 for (int i=0; i<urls.size(); i++)
2500 // Try to open new tab in existing konqueror started previously by vym
2501 p=new QProcess (this);
2503 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2504 "konqueror-mainwindow#1"<<
2507 p->start ("dcop",args);
2508 if ( !p->waitForStarted() ) success=false;
2511 QMessageBox::warning(0,
2513 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2515 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2517 for (int i=0; i<urls.size(); i++)
2519 // Try to open new tab in firefox
2520 p=new QProcess (this);
2521 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2522 p->start (browser,args);
2523 if ( !p->waitForStarted() ) success=false;
2526 QMessageBox::warning(0,
2528 tr("Couldn't start %1 to open a new tab").arg(browser));
2531 QMessageBox::warning(0,
2533 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2537 void Main::editOpenURL()
2540 if (currentMapEditor())
2542 QString url=currentMapEditor()->getURL();
2544 if (url=="") return;
2545 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2546 procBrowser = new QProcess( this );
2548 procBrowser->start(browser,args);
2549 if ( !procBrowser->waitForStarted())
2551 // try to set path to browser
2552 QMessageBox::warning(0,
2554 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2555 tr("Please use Settings->")+tr("Set application to open an URL"));
2560 void Main::editOpenURLTab()
2562 if (currentMapEditor())
2565 urls.append(currentMapEditor()->getURL());
2569 void Main::editOpenMultipleURLTabs()
2571 if (currentMapEditor())
2574 urls=currentMapEditor()->getURLs();
2580 void Main::editURL()
2582 if (currentMapEditor())
2583 currentMapEditor()->editURL();
2586 void Main::editHeading2URL()
2588 if (currentMapEditor())
2589 currentMapEditor()->editHeading2URL();
2592 void Main::editBugzilla2URL()
2594 if (currentMapEditor())
2595 currentMapEditor()->editBugzilla2URL();
2598 void Main::editFATE2URL()
2600 if (currentMapEditor())
2601 currentMapEditor()->editFATE2URL();
2604 void Main::editHeadingFinished()
2606 // only called from editHeading(), so there is a currentME
2607 MapEditor *me=currentMapEditor();
2609 #if defined(Q_OS_MACX)
2611 me->setHeading(lineedit->text());
2613 lineedit->releaseKeyboard();
2617 if (!prevSelection.isEmpty()) me->select(prevSelection);
2621 void Main::editHeading()
2623 if (currentMapEditor())
2625 MapEditor *me=currentMapEditor();
2626 QString oldSel=me->getSelectString();
2628 if (lineedit->isVisible())
2629 editHeadingFinished();
2634 QString s=currentMapEditor()->getHeading(ok,p);
2638 #if defined(Q_OS_MACX)
2639 p = currentMapEditor()->mapToGlobal( currentMapEditor()->worldMatrix().map( p));
2640 QDialog *d =new QDialog(NULL);
2641 QLineEdit *le=new QLineEdit (d);
2642 d->setWindowFlags (Qt::FramelessWindowHint);
2643 d->setGeometry(p.x(),p.y(),230,25);
2644 le->resize (d->width()-10,d->height());
2647 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2648 d->activateWindow();
2650 currentMapEditor()->setHeading (le->text());
2653 editHeadingFinished();
2655 p = currentMapEditor()->mapTo(this, currentMapEditor()->worldMatrix().map( p));
2656 lineedit->setGeometry(p.x(),p.y(),230,25);
2657 lineedit->setText(s);
2658 lineedit->setCursorPosition(1);
2659 lineedit->selectAll();
2661 lineedit->grabKeyboard();
2662 lineedit->setFocus();
2666 } // currentMapEditor()
2669 void Main::openVymLinks(const QStringList &vl)
2671 for (int j=0; j<vl.size(); j++)
2673 // compare path with already loaded maps
2677 for (i=0;i<=tabWidget->count() -1;i++)
2679 me=(MapEditor*)tabWidget->page(i);
2680 if (vl.at(j)==me->getFilePath() )
2689 if (!QFile(vl.at(j)).exists() )
2690 QMessageBox::critical( 0, tr( "Critical Error" ),
2691 tr("Couldn't open map %1").arg(vl.at(j)));
2694 fileLoad (vl.at(j), NewMap);
2695 tabWidget->setCurrentPage (tabWidget->count()-1);
2698 // Go to tab containing the map
2699 tabWidget->setCurrentPage (index);
2703 void Main::editOpenVymLink()
2705 if (currentMapEditor())
2708 vl.append(currentMapEditor()->getVymLink());
2713 void Main::editOpenMultipleVymLinks()
2715 QString currentVymLink;
2716 if (currentMapEditor())
2718 QStringList vl=currentMapEditor()->getVymLinks();
2723 void Main::editVymLink()
2725 if (currentMapEditor())
2726 currentMapEditor()->editVymLink();
2729 void Main::editDeleteVymLink()
2731 if (currentMapEditor())
2732 currentMapEditor()->deleteVymLink();
2735 void Main::editToggleHideExport()
2737 if (currentMapEditor())
2738 currentMapEditor()->toggleHideExport();
2741 void Main::editMapInfo()
2743 if (currentMapEditor())
2744 currentMapEditor()->editMapInfo();
2747 void Main::editMoveUp()
2749 if (currentMapEditor())
2750 currentMapEditor()->moveBranchUp();
2753 void Main::editMoveDown()
2755 if (currentMapEditor())
2756 currentMapEditor()->moveBranchDown();
2759 void Main::editToggleScroll()
2761 if (currentMapEditor())
2763 currentMapEditor()->toggleScroll();
2767 void Main::editUnScrollAll()
2769 if (currentMapEditor())
2770 currentMapEditor()->unScrollAll();
2773 void Main::editNewBranch()
2775 MapEditor *me=currentMapEditor();
2776 if (!lineedit->isVisible() && me)
2778 BranchObj *bo=(BranchObj*)me->getSelection();
2779 BranchObj *newbo=me->addNewBranch(0);
2782 me->select (newbo->getSelectString());
2786 if (actionSettingsAutoEdit->isOn())
2788 if (!actionSettingsAutoSelectHeading->isOn())
2789 prevSelection=bo->getSelectString();
2795 void Main::editNewBranchBefore()
2797 MapEditor *me=currentMapEditor();
2798 if (!lineedit->isVisible() && me)
2800 BranchObj *bo=(BranchObj*)me->getSelection();
2801 BranchObj *newbo=me->addNewBranchBefore();
2804 me->select (newbo->getSelectString());
2808 if (actionSettingsAutoEdit->isOn())
2810 if (!actionSettingsAutoSelectHeading->isOn())
2811 prevSelection=bo->getSelectString();
2817 void Main::editNewBranchAbove()
2819 MapEditor *me=currentMapEditor();
2820 if (!lineedit->isVisible() && me)
2822 BranchObj *bo=(BranchObj*)me->getSelection();
2823 BranchObj *newbo=me->addNewBranch (-1);
2826 me->select (newbo->getSelectString());
2830 if (actionSettingsAutoEdit->isOn())
2832 if (!actionSettingsAutoSelectHeading->isOn())
2833 prevSelection=bo->getSelectString();
2839 void Main::editNewBranchBelow()
2841 MapEditor *me=currentMapEditor();
2842 if (!lineedit->isVisible() && me)
2844 BranchObj *bo=(BranchObj*)me->getSelection();
2845 BranchObj *newbo=me->addNewBranch (1);
2848 me->select (newbo->getSelectString());
2852 if (actionSettingsAutoEdit->isOn())
2854 if (!actionSettingsAutoSelectHeading->isOn())
2855 prevSelection=bo->getSelectString();
2861 void Main::editImportAdd()
2863 fileLoad (ImportAdd);
2866 void Main::editImportReplace()
2868 fileLoad (ImportReplace);
2871 void Main::editSaveBranch()
2873 fileSaveAs (PartOfMap);
2876 void Main::editDeleteKeepChilds()
2878 if (currentMapEditor())
2879 currentMapEditor()->deleteKeepChilds();
2882 void Main::editDeleteChilds()
2884 if (currentMapEditor())
2885 currentMapEditor()->deleteChilds();
2888 void Main::editDeleteSelection()
2890 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2891 currentMapEditor()->deleteSelection();
2894 void Main::editUpperBranch()
2896 if (currentMapEditor())
2897 currentMapEditor()->selectUpperBranch();
2900 void Main::editLowerBranch()
2902 if (currentMapEditor())
2903 currentMapEditor()->selectLowerBranch();
2906 void Main::editLeftBranch()
2908 if (currentMapEditor())
2909 currentMapEditor()->selectLeftBranch();
2912 void Main::editRightBranch()
2914 if (currentMapEditor())
2915 currentMapEditor()->selectRightBranch();
2918 void Main::editFirstBranch()
2920 if (currentMapEditor())
2921 currentMapEditor()->selectFirstBranch();
2924 void Main::editLastBranch()
2926 if (currentMapEditor())
2927 currentMapEditor()->selectLastBranch();
2930 void Main::editLoadImage()
2932 if (currentMapEditor())
2933 currentMapEditor()->loadFloatImage();
2936 void Main::editSaveImage()
2938 if (currentMapEditor())
2939 currentMapEditor()->saveFloatImage();
2942 void Main::editFollowXLink(QAction *a)
2945 if (currentMapEditor())
2946 currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
2949 void Main::editEditXLink(QAction *a)
2951 if (currentMapEditor())
2952 currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
2955 void Main::formatSelectColor()
2957 if (currentMapEditor())
2959 QColor col = QColorDialog::getColor((currentColor ), this );
2960 if ( !col.isValid() ) return;
2961 colorChanged( col );
2965 void Main::formatPickColor()
2967 if (currentMapEditor())
2968 colorChanged( currentMapEditor()->getCurrentHeadingColor() );
2971 void Main::colorChanged(QColor c)
2973 QPixmap pix( 16, 16 );
2975 actionFormatColor->setIconSet( pix );
2979 void Main::formatColorItem()
2981 if (currentMapEditor())
2982 currentMapEditor()->colorItem(currentColor);
2985 void Main::formatColorBranch()
2987 if (currentMapEditor())
2988 currentMapEditor()->colorBranch(currentColor);
2991 void Main::formatLinkStyleLine()
2993 if (currentMapEditor())
2994 currentMapEditor()->setMapLinkStyle("StyleLine");
2997 void Main::formatLinkStyleParabel()
2999 if (currentMapEditor())
3000 currentMapEditor()->setMapLinkStyle("StyleParabel");
3003 void Main::formatLinkStylePolyLine()
3005 if (currentMapEditor())
3006 currentMapEditor()->setMapLinkStyle("StylePolyLine");
3009 void Main::formatLinkStylePolyParabel()
3011 if (currentMapEditor())
3012 currentMapEditor()->setMapLinkStyle("StylePolyParabel");
3015 void Main::formatSelectBackColor()
3017 if (currentMapEditor())
3018 currentMapEditor()->selectMapBackgroundColor();
3021 void Main::formatSelectLinkColor()
3023 if (currentMapEditor())
3024 currentMapEditor()->selectMapLinkColor();
3027 void Main::formatToggleLinkColorHint()
3029 currentMapEditor()->toggleMapLinkColorHint();
3032 void Main::formatFrameNone()
3034 if (currentMapEditor())
3035 currentMapEditor()->setFrame(NoFrame);
3038 void Main::formatFrameRectangle()
3040 if (currentMapEditor())
3041 currentMapEditor()->setFrame(Rectangle);
3044 void Main::formatIncludeImagesVer()
3046 if (currentMapEditor())
3047 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
3050 void Main::formatIncludeImagesHor()
3052 if (currentMapEditor())
3053 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
3056 void Main::formatHideLinkUnselected()
3058 if (currentMapEditor())
3059 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3062 void Main::viewZoomReset()
3064 if (currentMapEditor())
3068 currentMapEditor()->setWorldMatrix( m );
3069 currentMapEditor()->setViewCenter();
3070 currentMapEditor()->adjustCanvasSize();
3074 void Main::viewZoomIn()
3076 if (currentMapEditor())
3078 QMatrix m = currentMapEditor()->worldMatrix();
3079 m.scale( 1.25, 1.25 );
3080 currentMapEditor()->setWorldMatrix( m );
3081 currentMapEditor()->setViewCenter();
3082 currentMapEditor()->adjustCanvasSize();
3086 void Main::viewZoomOut()
3088 if (currentMapEditor())
3090 QMatrix m = currentMapEditor()->worldMatrix();
3091 m.scale( 0.8, 0.8 );
3092 currentMapEditor()->setWorldMatrix( m );
3093 currentMapEditor()->setViewCenter();
3094 currentMapEditor()->adjustCanvasSize();
3098 bool Main::settingsPDF()
3100 // Default browser is set in constructor
3102 QString text = QInputDialog::getText(
3103 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3104 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3106 settings.setValue ("/mainwindow/readerPDF",text);
3111 bool Main::settingsURL()
3113 // Default browser is set in constructor
3115 QString text = QInputDialog::getText(
3116 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3117 settings.value("/mainwindow/readerURL").toString()
3120 settings.setValue ("/mainwindow/readerURL",text);
3124 void Main::settingsToggleDelKey()
3126 if (actionSettingsUseDelKey->isOn())
3128 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3131 actionEditDelete->setAccel (QKeySequence (""));
3135 void Main::windowToggleNoteEditor()
3137 if (textEditor->showWithMain() )
3138 windowHideNoteEditor();
3140 windowShowNoteEditor();
3143 void Main::windowToggleHistory()
3145 if (currentMapEditor())
3146 currentMapEditor()->toggleHistoryWindow();
3149 void Main::updateNoteFlag()
3151 if (currentMapEditor())
3152 currentMapEditor()->updateNoteFlag();
3155 void Main::updateActions()
3157 MapEditor *me=currentMapEditor();
3160 // updateActions is also called when NoteEditor is closed
3161 actionViewToggleNoteEditor->setOn (textEditor->showWithMain());
3164 if (me->getMapLinkColorHint()==HeadingColor)
3165 actionFormatLinkColorHint->setOn(true);
3167 actionFormatLinkColorHint->setOn(false);
3169 switch (me->getMapLinkStyle())
3172 actionFormatLinkStyleLine->setOn(true);
3175 actionFormatLinkStyleParabel->setOn(true);
3178 actionFormatLinkStylePolyLine->setOn(true);
3180 case StylePolyParabel:
3181 actionFormatLinkStylePolyParabel->setOn(true);
3187 QPixmap pix( 16, 16 );
3188 pix.fill( me->getMapBackgroundColor() );
3189 actionFormatBackColor->setIconSet( pix );
3190 pix.fill( me->getMapDefLinkColor() );
3191 actionFormatLinkColor->setIconSet( pix );
3193 actionFileSave->setEnabled( me->isUnsaved() );
3194 if (me->isUndoAvailable())
3195 actionEditUndo->setEnabled( true);
3197 actionEditUndo->setEnabled( false);
3199 if (me->isRedoAvailable())
3200 actionEditRedo->setEnabled( true);
3202 actionEditRedo->setEnabled( false);
3204 LinkableMapObj *selection=me->getSelection();
3207 if ( (typeid(*selection) == typeid(BranchObj)) ||
3208 (typeid(*selection) == typeid(MapCenterObj)) )
3210 BranchObj *bo=(BranchObj*)selection;
3211 // Take care of links
3212 if (bo->countXLinks()==0)
3214 branchXLinksContextMenuEdit->clear();
3215 branchXLinksContextMenuFollow->clear();
3220 branchXLinksContextMenuEdit->clear();
3221 branchXLinksContextMenuFollow->clear();
3222 for (int i=0; i<=bo->countXLinks();i++)
3224 bot=bo->XLinkTargetAt(i);
3227 s=bot->getHeading();
3230 branchXLinksContextMenuFollow->addAction (s);
3231 branchXLinksContextMenuEdit->addAction (s);
3236 standardFlagsDefault->setEnabled (true);
3238 actionEditToggleScroll->setEnabled (true);
3239 if ( bo->isScrolled() )
3240 actionEditToggleScroll->setOn(true);
3242 actionEditToggleScroll->setOn(false);
3244 if ( bo->getURL().isEmpty() )
3246 actionEditOpenURL->setEnabled (false);
3247 actionEditOpenURLTab->setEnabled (false);
3251 actionEditOpenURL->setEnabled (true);
3252 actionEditOpenURLTab->setEnabled (true);
3254 if ( bo->getVymLink().isEmpty() )
3256 actionEditOpenVymLink->setEnabled (false);
3257 actionEditDeleteVymLink->setEnabled (false);
3260 actionEditOpenVymLink->setEnabled (true);
3261 actionEditDeleteVymLink->setEnabled (true);
3264 if (bo->canMoveBranchUp())
3265 actionEditMoveUp->setEnabled (true);
3267 actionEditMoveUp->setEnabled (false);
3268 if (bo->canMoveBranchDown())
3269 actionEditMoveDown->setEnabled (true);
3271 actionEditMoveDown->setEnabled (false);
3274 actionEditToggleHideExport->setEnabled (true);
3275 actionEditToggleHideExport->setOn (bo->hideInExport() );
3277 actionEditCopy->setEnabled (true);
3278 actionEditCut->setEnabled (true);
3279 if (!clipboardEmpty)
3280 actionEditPaste->setEnabled (true);
3282 actionEditPaste->setEnabled (false);
3283 for (a=actionListBranches.first();a;a=actionListBranches.next())
3284 a->setEnabled(true);
3285 actionEditDelete->setEnabled (true);
3286 switch (selection->getFrameType())
3289 actionFormatFrameNone->setOn(true);
3292 actionFormatFrameRectangle->setOn(true);
3297 actionFormatIncludeImagesVer->setOn
3298 ( ((BranchObj*)selection)->getIncludeImagesVer());
3299 actionFormatIncludeImagesHor->setOn
3300 ( ((BranchObj*)selection)->getIncludeImagesHor());
3301 actionFormatHideLinkUnselected->setOn
3302 (selection->getHideLinkUnselected());
3304 if ( (typeid(*selection) == typeid(FloatImageObj)) )
3306 FloatObj *fo=(FloatImageObj*)selection;
3307 //FIXME do this in mainwindow standardFlagsDefault->setEnabled (false);
3309 actionEditOpenURL->setEnabled (false);
3310 actionEditOpenVymLink->setEnabled (false);
3311 actionEditDeleteVymLink->setEnabled (false);
3312 actionEditToggleHideExport->setEnabled (true);
3313 actionEditToggleHideExport->setOn (fo->hideInExport() );
3316 actionEditCopy->setEnabled (true);
3317 actionEditCut->setEnabled (true);
3318 actionEditPaste->setEnabled (false);
3319 for (a=actionListBranches.first();a;a=actionListBranches.next())
3320 a->setEnabled(false);
3321 actionEditDelete->setEnabled (true);
3322 actionFormatHideLinkUnselected->setOn
3323 ( selection->getHideLinkUnselected());
3324 actionEditMoveUp->setEnabled (false);
3325 actionEditMoveDown->setEnabled (false);
3330 actionEditCopy->setEnabled (false);
3331 actionEditCut->setEnabled (false);
3332 actionEditPaste->setEnabled (false);
3333 for (a=actionListBranches.first();a;a=actionListBranches.next())
3334 a->setEnabled(false);
3336 actionEditToggleScroll->setEnabled (false);
3337 actionEditOpenURL->setEnabled (false);
3338 actionEditOpenVymLink->setEnabled (false);
3339 actionEditDeleteVymLink->setEnabled (false);
3340 actionEditHeading2URL->setEnabled (false);
3341 actionEditDelete->setEnabled (false);
3342 actionEditMoveUp->setEnabled (false);
3343 actionEditMoveDown->setEnabled (false);
3344 actionEditToggleHideExport->setEnabled (false);
3348 ModMode Main::getModMode()
3350 if (actionModModeColor->isOn()) return ModModeColor;
3351 if (actionModModeCopy->isOn()) return ModModeCopy;
3352 if (actionModModeXLink->isOn()) return ModModeXLink;
3356 bool Main::autoEdit()
3358 return actionSettingsAutoEdit->isOn();
3361 bool Main::autoSelectHeading()
3363 return actionSettingsAutoSelectHeading->isOn();
3366 bool Main::useFlagGroups()
3368 return actionSettingsUseFlagGroups->isOn();
3371 void Main::windowShowNoteEditor()
3373 textEditor->setShowWithMain(true);
3375 actionViewToggleNoteEditor->setOn (true);
3378 void Main::windowHideNoteEditor()
3380 textEditor->setShowWithMain(false);
3382 actionViewToggleNoteEditor->setOn (false);
3385 void Main::windowNextEditor()
3387 if (tabWidget->currentPageIndex() < tabWidget->count())
3388 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3391 void Main::windowPreviousEditor()
3393 if (tabWidget->currentPageIndex() >0)
3394 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3397 void Main::standardFlagChanged()
3399 currentMapEditor()->toggleStandardFlag(sender()->name());
3402 void Main::testFunction()
3404 if (!currentMapEditor()) return;
3405 currentMapEditor()->testFunction();
3408 void Main::testCommand()
3410 if (!currentMapEditor()) return;
3412 QString com = QInputDialog::getText(
3413 __VYM, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3414 if (ok) currentMapEditor()->parseAtom(com);
3417 void Main::helpDoc()
3419 QString locale = QLocale::system().name();
3421 if (locale.left(2)=="es")
3422 docname="vym_es.pdf";
3426 #if defined(Q_OS_MACX)
3427 docdir.setPath("./vym.app/Contents");
3429 // default path in SUSE LINUX
3430 docdir.setPath("/usr/share/doc/packages/vym/doc");
3433 if (!docdir.exists() )
3435 // relative path for easy testing in tarball
3436 docdir.setPath("doc");
3437 if (!docdir.exists() )
3439 // relative path for testing while still writing vym.tex
3440 docdir.setPath("doc/tex/vym.pdf");
3441 if (!docdir.exists() )
3443 // Try yet another one for Knoppix
3444 docdir.setPath("/usr/share/doc/packages/vym");
3445 if (!docdir.exists() )
3447 QMessageBox::critical(0,
3448 tr("Critcal error"),
3449 tr("Couldn't find the documentation\n"
3450 "vym.pdf in various directories."));
3457 QString docpath=docdir.path()+"/"+docname;
3458 Process *pdfProc = new Process();
3459 pdfProc->clearArguments();
3460 pdfProc->addArgument( settings.value("/mainwindow/readerPDF").toString());
3461 pdfProc->addArgument( docpath);
3463 if ( !pdfProc->start() )
3466 QMessageBox::warning(0,
3468 tr("Couldn't find a viewer to open %1.\n").arg(docpath)+
3469 tr("Please use Settings->")+tr("Set application to open PDF files"));
3476 void Main::helpAbout()
3479 ad.setName ("aboutwindow");
3480 ad.setMinimumSize(500,500);
3481 ad.resize (QSize (500,500));
3485 void Main::helpAboutQT()
3487 QMessageBox::aboutQt( this, "Qt Application Example" );