1 #include "mainwindow.h"
7 #include "aboutdialog.h"
8 #include "branchpropwindow.h"
9 #include "exportoofiledialog.h"
11 #include "exportxhtmldialog.h"
13 #include "flagrowobj.h"
14 #include "historywindow.h"
16 #include "mapeditor.h"
21 #include "texteditor.h"
22 #include "warningdialog.h"
24 extern TextEditor *textEditor;
25 extern Main *mainWindow;
26 extern QString tmpVymDir;
27 extern QString clipboardDir;
28 extern QString clipboardFile;
29 extern bool clipboardEmpty;
30 extern int statusbarTime;
31 extern FlagRowObj* standardFlagsDefault;
32 extern FlagRowObj* systemFlagsDefault;
33 extern QString vymName;
34 extern QString vymVersion;
35 extern QString vymBuildDate;
37 QMenu* branchContextMenu;
38 QMenu* branchAddContextMenu;
39 QMenu* branchRemoveContextMenu;
40 QMenu* branchLinksContextMenu;
41 QMenu* branchXLinksContextMenuEdit;
42 QMenu* branchXLinksContextMenuFollow;
43 QMenu* floatimageContextMenu;
44 QMenu* canvasContextMenu;
45 QMenu* fileLastMapsMenu;
46 QMenu* fileImportMenu;
47 QMenu* fileExportMenu;
50 extern Settings settings;
51 extern Options options;
52 extern ImageIO imageIO;
54 extern QDir vymBaseDir;
55 extern QDir lastImageDir;
56 extern QDir lastFileDir;
57 extern QString iconPath;
58 extern QString flagsPath;
60 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
61 QMainWindow(parent,name,f)
65 setCaption ("VYM - View Your Mind");
67 // Load window settings
68 resize (settings.value( "/mainwindow/geometry/size",QSize (800,600)).toSize());
69 move (settings.value( "/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
72 // Sometimes we may need to remember old selections
76 currentColor=Qt::black;
78 // Create unique temporary directory
80 tmpVymDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
83 qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
87 // Create direcctory for clipboard
88 clipboardDir=tmpVymDir+"/clipboard";
89 clipboardFile="part.xml";
91 d.mkdir (clipboardDir,true);
92 makeSubDirs (clipboardDir);
97 // Satellite windows //////////////////////////////////////////
100 historyWindow=new HistoryWindow();
101 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
104 branchPropertyWindow = new BranchPropertyWindow();
105 connect (branchPropertyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
107 // Connect TextEditor, so that we can update flags if text changes
108 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
109 connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
111 // Connect HistoryWindow, so that we can update flags
112 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
115 // Initialize script editor
116 scriptEditor = new SimpleScriptEditor();
117 scriptEditor->move (50,50);
119 connect( scriptEditor, SIGNAL( runScript ( QString ) ),
120 this, SLOT( runScript( QString ) ) );
123 // Initialize Find window
124 findWindow=new FindWindow(NULL);
125 findWindow->move (x(),y()+70);
126 connect (findWindow, SIGNAL( findButton(QString) ),
127 this, SLOT(editFind(QString) ) );
128 connect (findWindow, SIGNAL( somethingChanged() ),
129 this, SLOT(editFindChanged() ) );
131 // Initialize some settings, which are platform dependant
134 // application to open URLs
135 p="/mainwindow/readerURL";
136 #if defined(Q_OS_LINUX)
137 s=settings.value (p,"konqueror").toString();
139 #if defined(Q_OS_MACX)
140 s=settings.value (p,"/usr/bin/open").toString();
142 s=settings.value (p,"mozilla");
145 settings.setValue( p,s);
147 // application to open PDFs
148 p="/mainwindow/readerPDF";
149 #if defined(Q_OS_LINUX)
150 s=settings.value (p,"acroread").toString();
152 #if defined(Q_OS_MACX)
153 s=settings.value (p,"/usr/bin/open").toString();
155 s=settings.value (p,"acroread").toString();
158 settings.setValue( p,s);
161 // Create tab widget which holds the maps
162 tabWidget= new QTabWidget (this);
163 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
164 this, SLOT( editorChanged( QWidget * ) ) );
166 lineedit=new QLineEdit (this);
169 setCentralWidget(tabWidget);
173 setupFormatActions();
177 setupSettingsActions();
180 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
185 restoreState (settings.value("/mainwindow/state",0).toByteArray());
193 settings.setValue ( "/mainwindow/geometry/size", size() );
194 settings.setValue ( "/mainwindow/geometry/pos", pos() );
195 settings.setValue ("/mainwindow/state",saveState(0));
197 settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
198 settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
199 settings.setValue( "/version/version", vymVersion );
200 settings.setValue( "/version/builddate", vymBuildDate );
202 settings.setValue( "/mapeditor/autosave/use",actionSettingsAutosaveToggle->isOn() );
203 settings.setValue( "/mapeditor/editmode/autoSelectHeading",actionSettingsAutoSelectHeading->isOn() );
204 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
205 settings.setValue( "/mapeditor/editmode/autoEdit",actionSettingsAutoEdit->isOn() );
206 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
207 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
208 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
210 //TODO save scriptEditor settings
212 // call the destructors
214 delete historyWindow;
215 delete branchPropertyWindow;
217 // Remove temporary directory
218 removeDir (QDir(tmpVymDir));
221 void Main::loadCmdLine()
223 /* TODO draw some kind of splashscreen while loading...
229 QStringList flist=options.getFileList();
230 QStringList::Iterator it=flist.begin();
232 while (it !=flist.end() )
234 fileLoad (*it, NewMap);
240 void Main::statusMessage(const QString &s)
242 statusBar()->message (s);
245 void Main::closeEvent (QCloseEvent* )
251 void Main::setupFileActions()
253 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
254 QToolBar *tb = addToolBar( tr ("&Map") );
255 tb->setObjectName ("mapTB");
258 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this);
259 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
260 a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map
262 fileMenu->addAction (a);
263 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
265 a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this);
266 a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) );
267 a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N ); //New map
268 fileMenu->addAction (a);
269 connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) );
271 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
272 a->setStatusTip (tr( "Open","Status tip File menu" ) );
273 a->setShortcut ( Qt::CTRL + Qt::Key_O ); //Open map
275 fileMenu->addAction (a);
276 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
278 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
279 fileMenu->addSeparator();
281 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
282 a->setStatusTip ( tr( "Save","Status tip file menu" ));
283 a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map
285 fileMenu->addAction (a);
286 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
289 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
290 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
291 fileMenu->addAction (a);
292 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
294 fileMenu->addSeparator();
296 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
298 a = new QAction(tr("KDE Bookmarks"), this);
299 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE bookmarks")));
300 a->addTo (fileImportMenu);
301 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) );
303 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
305 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
306 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
307 a->addTo (fileImportMenu);
308 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
311 a = new QAction("Mind Manager...",this);
312 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
313 fileImportMenu->addAction (a);
314 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
316 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
317 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
318 fileImportMenu->addAction (a);
319 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
321 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
323 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
324 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
325 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
326 fileExportMenu->addAction (a);
328 a = new QAction( "Open Office...", this);
329 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
330 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
331 fileExportMenu->addAction (a);
333 a = new QAction( "Webpage (XHTML)...",this );
334 a->setShortcut (Qt::ALT + Qt::Key_X); //Export XHTML
335 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
336 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
337 fileExportMenu->addAction (a);
339 a = new QAction( "Text (ASCII)...", this);
340 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
341 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
342 fileExportMenu->addAction (a);
344 a = new QAction( "Spreadsheet (CSV)...", this);
345 a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
346 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
347 fileExportMenu->addAction (a);
349 a = new QAction( tr("KDE Bookmarks","File menu"), this);
350 a->setStatusTip( tr( "Export as %1").arg(tr("KDE Bookmarks" )));
351 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
352 fileExportMenu->addAction (a);
354 a = new QAction( "Taskjuggler...", this );
355 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
356 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
357 fileExportMenu->addAction (a);
359 a = new QAction( "LaTeX...", this);
360 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
361 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
362 fileExportMenu->addAction (a);
364 a = new QAction( "XML..." , this );
365 a->setStatusTip (tr( "Export as %1").arg("XML"));
366 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
367 fileExportMenu->addAction (a);
369 fileMenu->addSeparator();
371 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
372 a->setStatusTip ( tr( "Print" ,"File menu") );
373 a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map
375 fileMenu->addAction (a);
376 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
379 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
380 a->setStatusTip (tr( "Close Map" ) );
381 a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map
382 fileMenu->addAction (a);
383 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
385 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
386 a->setStatusTip ( tr( "Exit")+" "+vymName );
387 a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym
388 fileMenu->addAction (a);
389 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
394 void Main::setupEditActions()
396 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
397 tb->setLabel( "Edit Actions" );
398 tb->setObjectName ("actionsTB");
399 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
403 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
404 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
405 a->setStatusTip (tr( "Undo" ) );
406 a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action
407 a->setEnabled (false);
409 editMenu->addAction (a);
412 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
413 a->setStatusTip (tr( "Redo" ));
414 a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action
416 editMenu->addAction (a);
417 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
420 editMenu->addSeparator();
421 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
422 a->setStatusTip ( tr( "Copy" ) );
423 a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy
424 a->setEnabled (false);
426 editMenu->addAction (a);
427 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
430 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
431 a->setStatusTip ( tr( "Cut" ) );
432 a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut
433 a->setEnabled (false);
435 editMenu->addAction (a);
437 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
439 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
440 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
441 a->setStatusTip ( tr( "Paste" ) );
442 a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste
443 a->setEnabled (false);
445 editMenu->addAction (a);
448 // Shortcuts to modify heading:
449 a = new QAction(tr( "Edit heading","Edit menu" ),this);
450 a->setStatusTip ( tr( "edit Heading" ));
451 a->setShortcut ( Qt::Key_Enter); //Edit heading
452 // a->setShortcutContext (Qt::WindowShortcut);
454 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
455 actionListBranches.append(a);
456 a = new QAction( tr( "Edit heading","Edit menu" ), this);
457 a->setStatusTip (tr( "edit Heading" ));
458 a->setShortcut (Qt::Key_Return ); //Edit heading
459 //a->setShortcutContext (Qt::WindowShortcut);
461 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
462 actionListBranches.append(a);
463 editMenu->addAction (a);
465 a = new QAction( tr( "Edit heading","Edit menu" ), this);
466 a->setStatusTip (tr( "edit Heading" ));
467 //a->setShortcut ( Qt::Key_F2 ); //Edit heading
468 a->setShortcutContext (Qt::WindowShortcut);
470 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
471 actionListBranches.append(a);
473 // Shortcut to delete selection
474 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
475 a->setStatusTip (tr( "Delete Selection" ));
476 a->setShortcut ( Qt::Key_Delete); //Delete selection
477 a->setShortcutContext (Qt::WindowShortcut);
479 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
482 // Shortcut to add branch
483 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
484 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
485 alt->setShortcut (Qt::Key_A); //Add branch
486 alt->setShortcutContext (Qt::WindowShortcut);
488 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
489 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
490 a->setStatusTip ( tr( "Add a branch as child of selection" ));
491 a->setShortcut (Qt::Key_Insert); //Add branch
492 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
493 actionListBranches.append(a);
494 #if defined (Q_OS_MACX)
495 // In OSX show different shortcut in menues, the keys work indepently always
496 actionEditAddBranch=alt;
498 actionEditAddBranch=a;
500 editMenu->addAction (actionEditAddBranch);
501 tb->addAction (actionEditAddBranch);
504 // Add branch by inserting it at selection
505 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
506 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
507 a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch
508 a->setShortcutContext (Qt::WindowShortcut);
510 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
511 a->setEnabled (false);
512 actionListBranches.append(a);
513 actionEditAddBranchBefore=a;
514 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
515 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
516 a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch
517 a->setShortcutContext (Qt::WindowShortcut);
519 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
520 actionListBranches.append(a);
523 a = new QAction(tr( "Add branch above","Edit menu" ), this);
524 a->setStatusTip ( tr( "Add a branch above selection" ));
525 a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
526 a->setShortcutContext (Qt::WindowShortcut);
528 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
529 a->setEnabled (false);
530 actionListBranches.append(a);
531 actionEditAddBranchAbove=a;
532 a = new QAction(tr( "Add branch above","Edit menu" ), this);
533 a->setStatusTip ( tr( "Add a branch above selection" ));
534 a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above
535 a->setShortcutContext (Qt::WindowShortcut);
537 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
538 actionListBranches.append(a);
541 a = new QAction(tr( "Add branch below","Edit menu" ), this);
542 a->setStatusTip ( tr( "Add a branch below selection" ));
543 a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
544 a->setShortcutContext (Qt::WindowShortcut);
546 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
547 a->setEnabled (false);
548 actionListBranches.append(a);
549 actionEditAddBranchBelow=a;
550 a = new QAction(tr( "Add branch below","Edit menu" ), this);
551 a->setStatusTip ( tr( "Add a branch below selection" ));
552 a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below
553 a->setShortcutContext (Qt::WindowShortcut);
555 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
556 actionListBranches.append(a);
558 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
559 a->setStatusTip ( tr( "Move branch up" ) );
560 a->setShortcut (Qt::Key_PageUp ); // Move branch up
561 a->setEnabled (false);
563 editMenu->addAction (a);
564 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
567 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
568 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
569 a->setStatusTip (tr( "Move branch down" ) );
570 a->setShortcut ( Qt::Key_PageDown ); // Move branch down
571 a->setEnabled (false);
573 editMenu->addAction (a);
574 actionEditMoveDown=a;
577 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this);
578 a->setShortcut ( Qt::Key_ScrollLock );
579 a->setStatusTip (tr( "Scroll branch" ) );
580 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
582 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
583 alt->setShortcut ( Qt::Key_S ); // Scroll branch
584 alt->setStatusTip (tr( "Scroll branch" ));
585 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
586 #if defined(Q_OS_MACX)
587 actionEditToggleScroll=alt;
589 actionEditToggleScroll=a;
591 actionEditToggleScroll->setEnabled (false);
592 actionEditToggleScroll->setToggleAction(true);
593 tb->addAction (actionEditToggleScroll);
594 editMenu->addAction ( actionEditToggleScroll);
595 editMenu->addAction (actionEditToggleScroll);
598 actionListBranches.append(actionEditToggleScroll);
600 a = new QAction( tr( "Unscroll childs","Edit menu" ), this);
601 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
602 editMenu->addAction (a);
603 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChilds() ) );
605 editMenu->addSeparator();
607 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
608 a->setStatusTip (tr( "Find" ) );
609 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
610 editMenu->addAction (a);
611 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
613 editMenu->addSeparator();
615 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
616 a->setShortcut (Qt::CTRL + Qt::Key_U );
617 a->setShortcut (tr( "Open URL" ));
620 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
623 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
624 a->setStatusTip (tr( "Open URL in new tab" ));
625 a->setShortcut (Qt::CTRL+Qt::Key_U );
627 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
628 actionEditOpenURLTab=a;
630 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
631 a->setStatusTip (tr( "Open all URLs in subtree" ));
633 actionListBranches.append(a);
634 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
635 actionEditOpenMultipleURLTabs=a;
637 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
638 a->setStatusTip ( tr( "Edit URL" ) );
639 a->setShortcut (Qt::SHIFT + Qt::CTRL + Qt::Key_U );
640 //a->setShortcut ( Qt::Key_U );
641 a->setShortcutContext (Qt::WindowShortcut);
642 actionListBranches.append(a);
644 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
647 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
648 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
649 a->setEnabled (false);
650 actionListBranches.append(a);
651 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
652 actionEditHeading2URL=a;
654 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
655 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
656 a->setEnabled (false);
657 actionListBranches.append(a);
658 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
659 actionEditBugzilla2URL=a;
661 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
662 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
663 a->setEnabled (false);
664 actionListBranches.append(a);
665 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
666 actionEditFATE2URL=a;
668 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
669 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
671 a->setEnabled (false);
672 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
673 actionEditOpenVymLink=a;
675 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
676 a->setStatusTip ( tr( "Open all vym links in subtree" ));
677 a->setEnabled (false);
678 actionListBranches.append(a);
679 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
680 actionEditOpenMultipleVymLinks=a;
683 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
684 a->setEnabled (false);
685 a->setStatusTip ( tr( "Edit link to another vym map" ));
686 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
687 actionListBranches.append(a);
690 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
691 a->setStatusTip ( tr( "Delete link to another vym map" ));
692 a->setEnabled (false);
693 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
694 actionEditDeleteVymLink=a;
696 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
697 a->setStatusTip ( tr( "Hide object in exports" ) );
698 a->setShortcut (Qt::Key_H );
699 a->setToggleAction(true);
701 a->setEnabled (false);
702 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
703 actionEditToggleHideExport=a;
705 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
706 a->setStatusTip ( tr( "Edit Map Info" ));
707 a->setEnabled (true);
708 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
711 // Import at selection (adding to selection)
712 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
713 a->setStatusTip (tr( "Add map at selection" ));
714 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
715 a->setEnabled (false);
716 actionListBranches.append(a);
717 actionEditImportAdd=a;
719 // Import at selection (replacing selection)
720 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
721 a->setStatusTip (tr( "Replace selection with map" ));
722 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
723 a->setEnabled (false);
724 actionListBranches.append(a);
725 actionEditImportReplace=a;
728 a = new QAction( tr( "Save selection","Edit menu" ), this);
729 a->setStatusTip (tr( "Save selection" ));
730 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
731 a->setEnabled (false);
732 actionListBranches.append(a);
733 actionEditSaveBranch=a;
735 // Only remove branch, not its childs
736 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
737 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
738 a->setShortcut (Qt::ALT + Qt::Key_Delete );
739 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChilds() ) );
740 a->setEnabled (false);
742 actionListBranches.append(a);
743 actionEditDeleteKeepChilds=a;
745 // Only remove childs of a branch
746 a = new QAction( tr( "Remove childs","Edit menu" ), this);
747 a->setStatusTip (tr( "Remove childs of branch" ));
748 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
749 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChilds() ) );
750 a->setEnabled (false);
751 actionListBranches.append(a);
752 actionEditDeleteChilds=a;
754 // Shortcuts for navigating with cursor:
755 a = new QAction(tr( "Select upper branch","Edit menu" ), this);
756 a->setStatusTip ( tr( "Select upper branch" ));
757 a->setShortcut (Qt::Key_Up );
758 a->setShortcutContext (Qt::WindowShortcut);
760 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
761 a = new QAction( tr( "Select lower branch","Edit menu" ),this);
762 a->setStatusTip (tr( "Select lower branch" ));
763 a->setShortcut ( Qt::Key_Down );
764 a->setShortcutContext (Qt::WindowShortcut);
766 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
767 a = new QAction(tr( "Select left branch","Edit menu" ), this);
768 a->setStatusTip ( tr( "Select left branch" ));
769 a->setShortcut (Qt::Key_Left );
770 a->setShortcutContext (Qt::WindowShortcut);
772 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
773 a = new QAction( tr( "Select child branch","Edit menu" ), this);
774 a->setStatusTip (tr( "Select right branch" ));
775 a->setShortcut (Qt::Key_Right);
776 a->setShortcutContext (Qt::WindowShortcut);
778 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
779 a = new QAction( tr( "Select first branch","Edit menu" ), this);
780 a->setStatusTip (tr( "Select first branch" ));
781 a->setShortcut (Qt::Key_Home );
782 a->setShortcutContext (Qt::WindowShortcut);
784 a->setEnabled (false);
785 editMenu->addAction (a);
786 actionListBranches.append(a);
787 actionEditSelectFirst=a;
788 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
789 a = new QAction( tr( "Select last branch","Edit menu" ),this);
790 a->setStatusTip (tr( "Select last branch" ));
791 a->setShortcut ( Qt::Key_End );
792 a->setShortcutContext (Qt::WindowShortcut);
794 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
795 a->setEnabled (false);
796 editMenu->addAction (a);
797 actionListBranches.append(a);
798 actionEditSelectLast=a;
800 a = new QAction( tr( "Add Image...","Edit menu" ), this);
801 a->setStatusTip (tr( "Add Image" ));
802 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
803 actionEditLoadImage=a;
805 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
806 a->setStatusTip (tr( "Set properties for selection" ));
807 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
808 a->setShortcutContext (Qt::WindowShortcut);
809 a->setToggleAction (true);
811 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
812 actionViewTogglePropertyWindow=a;
816 void Main::setupFormatActions()
818 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
820 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
821 tb->setObjectName ("formatTB");
824 pix.fill (Qt::black);
825 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
826 a->setStatusTip ( tr( "Set Color" ));
827 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
829 formatMenu->addAction (a);
831 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
832 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
833 a->setShortcut (Qt::CTRL + Qt::Key_K );
834 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
835 a->setEnabled (false);
837 formatMenu->addAction (a);
838 actionListBranches.append(a);
839 actionFormatPickColor=a;
841 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
842 a->setStatusTip ( tr( "Color branch" ) );
843 a->setShortcut (Qt::CTRL + Qt::Key_B);
844 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
845 a->setEnabled (false);
847 formatMenu->addAction (a);
848 actionListBranches.append(a);
849 actionFormatColorSubtree=a;
851 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
852 a->setStatusTip ( tr( "Color Subtree" ));
853 a->setShortcut (Qt::CTRL + Qt::Key_T);
854 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
855 a->setEnabled (false);
856 formatMenu->addAction (a);
858 actionListBranches.append(a);
859 actionFormatColorSubtree=a;
861 formatMenu->addSeparator();
862 actionGroupFormatLinkStyles=new QActionGroup ( this);
863 actionGroupFormatLinkStyles->setExclusive (true);
864 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
865 a->setStatusTip (tr( "Line" ));
866 a->setToggleAction(true);
867 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
868 formatMenu->addAction (a);
869 actionFormatLinkStyleLine=a;
870 a= new QAction( tr( "Linkstyle Parabel" ), actionGroupFormatLinkStyles);
871 a->setStatusTip (tr( "Line" ));
872 a->setToggleAction(true);
873 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
874 formatMenu->addAction (a);
875 actionFormatLinkStyleParabel=a;
876 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
877 a->setStatusTip (tr( "PolyLine" ));
878 a->setToggleAction(true);
879 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
880 formatMenu->addAction (a);
881 actionFormatLinkStylePolyLine=a;
882 a= new QAction( tr( "Linkstyle Thick Parabel" ), actionGroupFormatLinkStyles);
883 a->setStatusTip (tr( "PolyParabel" ) );
884 a->setToggleAction(true);
885 a->setChecked (true);
886 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
887 formatMenu->addAction (a);
888 actionFormatLinkStylePolyParabel=a;
890 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
891 a->setStatusTip (tr( "Hide link" ));
892 a->setToggleAction(true);
893 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
894 actionFormatHideLinkUnselected=a;
896 formatMenu->addSeparator();
897 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
898 a->setStatusTip (tr( "Use same color for links and headings" ));
899 a->setToggleAction(true);
900 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
901 formatMenu->addAction (a);
902 actionFormatLinkColorHint=a;
904 pix.fill (Qt::white);
905 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
906 a->setStatusTip (tr( "Set Link Color" ));
907 formatMenu->addAction (a);
908 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
909 actionFormatLinkColor=a;
911 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
912 a->setStatusTip (tr( "Set Selection Color" ));
913 formatMenu->addAction (a);
914 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
915 actionFormatSelectionColor=a;
917 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
918 a->setStatusTip (tr( "Set Background Color" ));
919 formatMenu->addAction (a);
920 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
921 actionFormatBackColor=a;
923 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
924 a->setStatusTip (tr( "Set Background image" ));
925 formatMenu->addAction (a);
926 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
927 actionFormatBackImage=a;
931 void Main::setupViewActions()
933 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
934 tb->setLabel( "View Actions" );
935 tb->setObjectName ("viewTB");
936 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
939 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
940 a->setStatusTip ( tr( "Zoom reset" ) );
941 a->setShortcut (Qt::CTRL + Qt::Key_0 );
943 viewMenu->addAction (a);
944 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
946 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
947 a->setStatusTip (tr( "Zoom in" ));
948 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
950 viewMenu->addAction (a);
951 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
953 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
954 a->setStatusTip (tr( "Zoom out" ));
955 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
957 viewMenu->addAction (a);
958 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
960 viewMenu->addSeparator();
962 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
963 a->setStatusTip ( tr( "Show Note Editor" ));
964 a->setShortcut ( Qt::CTRL + Qt::Key_E );
965 a->setToggleAction(true);
967 viewMenu->addAction (a);
968 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
969 actionViewToggleNoteEditor=a;
971 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
972 a->setStatusTip ( tr( "Show History Window" ));
973 a->setShortcut ( Qt::CTRL + Qt::Key_H );
974 a->setToggleAction(true);
976 viewMenu->addAction (a);
977 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
978 actionViewToggleHistoryWindow=a;
980 viewMenu->addAction (actionViewTogglePropertyWindow);
982 viewMenu->addSeparator();
984 a = new QAction(tr( "Antialiasing","View action" ),this );
985 a->setStatusTip ( tr( "Antialiasing" ));
986 a->setToggleAction(true);
987 a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
988 viewMenu->addAction (a);
989 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
990 actionViewToggleAntiAlias=a;
992 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
993 a->setStatusTip (a->text());
994 a->setToggleAction(true);
995 a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
996 viewMenu->addAction (a);
997 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
998 actionViewToggleSmoothPixmapTransform=a;
1000 a = new QAction(tr( "Next Map","View action" ), this);
1001 a->setStatusTip (a->text());
1002 a->setShortcut (Qt::ALT + Qt::Key_N );
1003 viewMenu->addAction (a);
1004 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1006 a = new QAction (tr( "Previous Map","View action" ), this );
1007 a->setStatusTip (a->text());
1008 a->setShortcut (Qt::ALT + Qt::Key_P );
1009 viewMenu->addAction (a);
1010 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1014 void Main::setupModeActions()
1016 //QPopupMenu *menu = new QPopupMenu( this );
1017 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1019 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1020 tb->setObjectName ("modesTB");
1022 actionGroupModModes=new QActionGroup ( this);
1023 actionGroupModModes->setExclusive (true);
1024 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1025 a->setShortcut (Qt::Key_J);
1026 a->setStatusTip ( tr( "Use modifier to color branches" ));
1027 a->setToggleAction(true);
1030 actionModModeColor=a;
1032 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1033 a->setShortcut( Qt::Key_K);
1034 a->setStatusTip( tr( "Use modifier to copy" ));
1035 a->setToggleAction(true);
1037 actionModModeCopy=a;
1039 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1040 a->setShortcut (Qt::Key_L);
1041 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1042 a->setToggleAction(true);
1044 actionModModeXLink=a;
1048 void Main::setupFlagActions()
1050 // Create System Flags
1051 systemFlagsDefault = new FlagRowObj ();
1052 systemFlagsDefault->setVisibility (false);
1053 systemFlagsDefault->setName ("systemFlagsDef");
1055 FlagObj *fo = new FlagObj ();
1056 fo->load(QPixmap(flagsPath+"flag-note.png"));
1057 fo->setName("note");
1058 fo->setToolTip(tr("Note","Systemflag"));
1059 systemFlagsDefault->addFlag (fo); // makes deep copy
1061 fo->load(QPixmap(flagsPath+"flag-url.png"));
1063 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
1064 systemFlagsDefault->addFlag (fo);
1066 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1067 fo->setName("vymLink");
1068 fo->setToolTip(tr("Link to another vym map","Systemflag"));
1069 systemFlagsDefault->addFlag (fo);
1071 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1072 fo->setName("scrolledright");
1073 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
1074 systemFlagsDefault->addFlag (fo);
1076 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1077 fo->setName("tmpUnscrolledright");
1078 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
1079 systemFlagsDefault->addFlag (fo);
1081 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1082 fo->setName("hideInExport");
1083 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
1084 systemFlagsDefault->addFlag (fo);
1086 // Create Standard Flags
1087 QToolBar *tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1088 tb->setObjectName ("standardFlagTB");
1090 standardFlagsDefault = new FlagRowObj ();
1091 standardFlagsDefault->setVisibility (false);
1092 standardFlagsDefault->setName ("standardFlagsDef");
1093 standardFlagsDefault->setToolBar (tb);
1095 fo->load(flagsPath+"flag-exclamationmark.png");
1096 fo->setName ("exclamationmark");
1097 fo->setGroup("standard-mark");
1098 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1101 a->setCheckable(true);
1102 a->setObjectName(fo->getName());
1103 a->setToolTip(tr("Take care!","Standardflag"));
1104 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1105 standardFlagsDefault->addFlag (fo); // makes deep copy
1107 fo->load(flagsPath+"flag-questionmark.png");
1108 fo->setName("questionmark");
1109 fo->setGroup("standard-mark");
1110 a=new QAction (fo->getPixmap(),fo->getName(),this);
1113 a->setCheckable(true);
1114 a->setObjectName(fo->getName());
1115 a->setToolTip(tr("Really?","Standardflag"));
1116 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1117 standardFlagsDefault->addFlag (fo);
1119 fo->load(flagsPath+"flag-hook-green.png");
1120 fo->setName("hook-green");
1121 fo->setGroup("standard-hook");
1122 a=new QAction (fo->getPixmap(),fo->getName(),this);
1125 a->setCheckable(true);
1126 a->setObjectName(fo->getName());
1127 a->setToolTip(tr("ok!","Standardflag"));
1128 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1129 standardFlagsDefault->addFlag (fo);
1131 fo->load(flagsPath+"flag-cross-red.png");
1132 fo->setName("cross-red");
1133 fo->setGroup("standard-hook");
1134 a=new QAction (fo->getPixmap(),fo->getName(),this);
1137 a->setCheckable(true);
1138 a->setObjectName(fo->getName());
1139 a->setToolTip(tr("Not ok!","Standardflag"));
1140 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1141 standardFlagsDefault->addFlag (fo);
1143 fo->load(flagsPath+"flag-stopsign.png");
1144 fo->setName("stopsign");
1145 a=new QAction (fo->getPixmap(),fo->getName(),this);
1148 a->setCheckable(true);
1149 a->setObjectName(fo->getName());
1150 a->setToolTip(tr("This won't work!","Standardflag"));
1151 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1152 standardFlagsDefault->addFlag (fo);
1154 fo->load(flagsPath+"flag-smiley-good.png");
1155 fo->setName("smiley-good");
1156 fo->setGroup("standard-smiley");
1157 a=new QAction (fo->getPixmap(),fo->getName(),this);
1160 a->setCheckable(true);
1161 a->setObjectName(fo->getName());
1162 a->setToolTip(tr("Good","Standardflag"));
1163 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1164 standardFlagsDefault->addFlag (fo);
1166 fo->load(flagsPath+"flag-smiley-sad.png");
1167 fo->setName("smiley-sad");
1168 fo->setGroup("standard-smiley");
1169 a=new QAction (fo->getPixmap(),fo->getName(),this);
1172 a->setCheckable(true);
1173 a->setObjectName(fo->getName());
1174 a->setToolTip(tr("Bad","Standardflag"));
1175 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1176 standardFlagsDefault->addFlag (fo);
1178 fo->load(flagsPath+"flag-smiley-omg.png");
1179 // Original omg.png (in KDE emoticons)
1180 fo->setName("smiley-omg");
1181 fo->setGroup("standard-smiley");
1182 a=new QAction (fo->getPixmap(),fo->getName(),this);
1185 a->setCheckable(true);
1186 a->setObjectName(fo->getName());
1187 a->setToolTip(tr("Oh no!","Standardflag"));
1188 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1189 standardFlagsDefault->addFlag (fo);
1191 fo->load(flagsPath+"flag-kalarm.png");
1192 fo->setName("clock");
1193 a=new QAction (fo->getPixmap(),fo->getName(),this);
1196 a->setCheckable(true);
1197 a->setObjectName(fo->getName());
1198 a->setToolTip(tr("Time critical","Standardflag"));
1199 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1200 standardFlagsDefault->addFlag (fo);
1202 fo->load(flagsPath+"flag-phone.png");
1203 fo->setName("phone");
1204 a=new QAction (fo->getPixmap(),fo->getName(),this);
1207 a->setCheckable(true);
1208 a->setObjectName(fo->getName());
1209 a->setToolTip(tr("Call...","Standardflag"));
1210 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1211 standardFlagsDefault->addFlag (fo);
1213 fo->load(flagsPath+"flag-lamp.png");
1214 fo->setName("lamp");
1215 a=new QAction (fo->getPixmap(),fo->getName(),this);
1218 a->setCheckable(true);
1219 a->setObjectName(fo->getName());
1220 a->setToolTip(tr("Idea!","Standardflag"));
1221 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1222 standardFlagsDefault->addFlag (fo);
1224 fo->load(flagsPath+"flag-arrow-up.png");
1225 fo->setName("arrow-up");
1226 fo->setGroup("standard-arrow");
1227 a=new QAction (fo->getPixmap(),fo->getName(),this);
1230 a->setCheckable(true);
1231 a->setObjectName(fo->getName());
1232 a->setToolTip(tr("Important","Standardflag"));
1233 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1234 standardFlagsDefault->addFlag (fo);
1236 fo->load(flagsPath+"flag-arrow-down.png");
1237 fo->setName("arrow-down");
1238 fo->setGroup("standard-arrow");
1239 a=new QAction (fo->getPixmap(),fo->getName(),this);
1242 a->setCheckable(true);
1243 a->setObjectName(fo->getName());
1244 a->setToolTip(tr("Unimportant","Standardflag"));
1245 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1246 standardFlagsDefault->addFlag (fo);
1248 fo->load(flagsPath+"flag-arrow-2up.png");
1249 fo->setName("2arrow-up");
1250 fo->setGroup("standard-arrow");
1251 a=new QAction (fo->getPixmap(),fo->getName(),this);
1254 a->setCheckable(true);
1255 a->setObjectName(fo->getName());
1256 a->setToolTip(tr("Very important!","Standardflag"));
1257 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1258 standardFlagsDefault->addFlag (fo);
1260 fo->load(flagsPath+"flag-arrow-2down.png");
1261 fo->setName("2arrow-down");
1262 fo->setGroup("standard-arrow");
1263 a=new QAction (fo->getPixmap(),fo->getName(),this);
1266 a->setCheckable(true);
1267 a->setObjectName(fo->getName());
1268 a->setToolTip(tr("Very unimportant!","Standardflag"));
1269 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1270 standardFlagsDefault->addFlag (fo);
1272 fo->load(flagsPath+"flag-thumb-up.png");
1273 fo->setName("thumb-up");
1274 fo->setGroup("standard-thumb");
1275 a=new QAction (fo->getPixmap(),fo->getName(),this);
1278 a->setCheckable(true);
1279 a->setObjectName(fo->getName());
1280 a->setToolTip(tr("I like this","Standardflag"));
1281 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1282 standardFlagsDefault->addFlag (fo);
1284 fo->load(flagsPath+"flag-thumb-down.png");
1285 fo->setName("thumb-down");
1286 fo->setGroup("standard-thumb");
1287 a=new QAction (fo->getPixmap(),fo->getName(),this);
1290 a->setCheckable(true);
1291 a->setObjectName(fo->getName());
1292 a->setToolTip(tr("I do not like this","Standardflag"));
1293 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1294 standardFlagsDefault->addFlag (fo);
1296 fo->load(flagsPath+"flag-rose.png");
1297 fo->setName("rose");
1298 a=new QAction (fo->getPixmap(),fo->getName(),this);
1301 a->setCheckable(true);
1302 a->setObjectName(fo->getName());
1303 a->setToolTip(tr("Rose","Standardflag"));
1304 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1305 standardFlagsDefault->addFlag (fo);
1307 fo->load(flagsPath+"flag-heart.png");
1308 fo->setName("heart");
1309 a=new QAction (fo->getPixmap(),fo->getName(),this);
1311 a->setCheckable(true);
1312 a->setObjectName(fo->getName());
1313 a->setToolTip(tr("I just love... ","Standardflag"));
1314 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1315 standardFlagsDefault->addFlag (fo);
1317 fo->load(flagsPath+"flag-present.png");
1318 fo->setName("present");
1319 a=new QAction (fo->getPixmap(),fo->getName(),this);
1322 a->setCheckable(true);
1323 a->setObjectName(fo->getName());
1324 a->setToolTip(tr("Surprise!","Standardflag"));
1325 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1326 standardFlagsDefault->addFlag (fo);
1328 fo->load(flagsPath+"flag-flash.png");
1329 fo->setName("flash");
1330 a=new QAction (fo->getPixmap(),fo->getName(),this);
1333 a->setCheckable(true);
1334 a->setObjectName(fo->getName());
1335 a->setToolTip(tr("Dangerous","Standardflag"));
1336 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1337 standardFlagsDefault->addFlag (fo);
1339 fo->load(flagsPath+"flag-info.png");
1340 // Original: xsldbg_output.png
1341 fo->setName("info");
1342 a=new QAction (fo->getPixmap(),fo->getName(),this);
1345 a->setCheckable(true);
1346 a->setObjectName(fo->getName());
1347 a->setToolTip(tr("Info","Standardflag"));
1348 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1349 standardFlagsDefault->addFlag (fo);
1351 fo->load(flagsPath+"flag-lifebelt.png");
1352 // Original khelpcenter.png
1353 fo->setName("lifebelt");
1354 a=new QAction (fo->getPixmap(),fo->getName(),this);
1357 a->setCheckable(true);
1358 a->setObjectName(fo->getName());
1359 a->setToolTip(tr("This will help","Standardflag"));
1360 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1361 standardFlagsDefault->addFlag (fo);
1367 void Main::setupSettingsActions()
1369 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1373 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1374 a->setStatusTip ( tr( "Set application to open pdf files"));
1375 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1376 settingsMenu->addAction (a);
1378 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1379 a->setStatusTip( tr( "Set application to open external links"));
1380 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1381 settingsMenu->addAction (a);
1383 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1384 a->setStatusTip( tr( "Set path for macros"));
1385 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1386 settingsMenu->addAction (a);
1388 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1389 a->setStatusTip( tr( "Set number of undo levels"));
1390 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1391 settingsMenu->addAction (a);
1393 settingsMenu->addSeparator();
1395 a = new QAction( tr( "Autosave","Settings action"), this);
1396 a->setStatusTip( tr( "Autosave"));
1397 a->setToggleAction(true);
1398 a->setOn ( settings.value ("/mapeditor/autosave/use",true).toBool());
1399 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1400 settingsMenu->addAction (a);
1401 actionSettingsAutosaveToggle=a;
1403 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1404 a->setStatusTip( tr( "Autosave time"));
1405 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1406 settingsMenu->addAction (a);
1407 actionSettingsAutosaveTime=a;
1409 settingsMenu->addSeparator();
1411 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1412 a->setStatusTip( tr( "Edit branch after adding it" ));
1413 a->setToggleAction(true);
1414 a->setOn ( settings.value ("/mapeditor/editmode/autoEdit",true).toBool());
1415 settingsMenu->addAction (a);
1416 actionSettingsAutoEdit=a;
1418 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1419 a->setStatusTip( tr( "Select branch after adding it" ));
1420 a->setToggleAction(true);
1421 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectHeading",false).toBool() );
1422 settingsMenu->addAction (a);
1423 actionSettingsAutoSelectHeading=a;
1425 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1426 a->setStatusTip( tr( "Select heading before editing" ));
1427 a->setToggleAction(true);
1428 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1429 settingsMenu->addAction (a);
1430 actionSettingsAutoSelectText=a;
1432 a= new QAction( tr( "Delete key","Settings action" ), this);
1433 a->setStatusTip( tr( "Delete key for deleting branches" ));
1434 a->setToggleAction(true);
1435 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",false).toBool() );
1436 settingsMenu->addAction (a);
1437 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1438 actionSettingsUseDelKey=a;
1440 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1441 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1442 a->setToggleAction(true);
1443 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1444 settingsMenu->addAction (a);
1445 actionSettingsUseFlagGroups=a;
1447 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1448 a->setStatusTip( tr( "Use hide flag during exports " ));
1449 a->setToggleAction(true);
1450 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1451 settingsMenu->addAction (a);
1452 actionSettingsUseHideExport=a;
1456 void Main::setupTestActions()
1458 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1461 a = new QAction( "Test function" , this);
1462 a->setStatusTip( "Call test function" );
1463 //a->setShortcut (Qt::Key_F4 );
1464 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction() ) );
1465 testMenu->addAction (a);
1466 a = new QAction( "Command" , this);
1467 a->setStatusTip( "Enter command to call in editor" );
1468 //a->setShortcut (Qt::Key_F5 );
1469 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1470 testMenu->addAction (a);
1474 void Main::setupHelpActions()
1476 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1479 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1480 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1481 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1482 helpMenu->addAction (a);
1484 a = new QAction( tr( "About VYM","Help action" ), this);
1485 a->setStatusTip( tr( "About VYM")+vymName);
1486 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1487 helpMenu->addAction (a);
1489 a = new QAction( tr( "About QT","Help action" ), this);
1490 a->setStatusTip( tr( "Information about QT toolkit" ));
1491 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1492 helpMenu->addAction (a);
1496 void Main::setupContextMenus()
1500 // Context Menu for branch or mapcenter
1501 branchContextMenu =new QMenu (this);
1502 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1503 branchContextMenu->addSeparator();
1506 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1507 branchAddContextMenu->addAction (actionEditPaste );
1508 branchAddContextMenu->addAction ( actionEditAddBranch );
1509 branchAddContextMenu->addAction ( actionEditAddBranchBefore );
1510 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1511 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1512 branchAddContextMenu->addSeparator();
1513 branchAddContextMenu->addAction ( actionEditImportAdd );
1514 branchAddContextMenu->addAction ( actionEditImportReplace );
1517 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1518 branchRemoveContextMenu->addAction (actionEditCut);
1519 branchRemoveContextMenu->addAction ( actionEditDelete );
1520 branchRemoveContextMenu->addAction ( actionEditDeleteKeepChilds );
1521 branchRemoveContextMenu->addAction ( actionEditDeleteChilds );
1524 actionEditSaveBranch->addTo( branchContextMenu );
1526 branchContextMenu->addSeparator();
1527 branchContextMenu->addAction ( actionEditLoadImage);
1529 // Submenu for Links (URLs, vymLinks)
1530 branchLinksContextMenu =new QMenu (this);
1532 branchContextMenu->addSeparator();
1533 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1534 branchLinksContextMenu->addAction ( actionEditOpenURL );
1535 branchLinksContextMenu->addAction ( actionEditOpenURLTab );
1536 branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
1537 branchLinksContextMenu->addAction ( actionEditURL );
1538 branchLinksContextMenu->addAction ( actionEditHeading2URL );
1539 branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
1540 if (settings.value( "/mainwindow/showTestMenu",true).toBool() )
1542 branchLinksContextMenu->addAction ( actionEditFATE2URL );
1544 branchLinksContextMenu->addSeparator();
1545 branchLinksContextMenu->addAction ( actionEditOpenVymLink );
1546 branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
1547 branchLinksContextMenu->addAction ( actionEditVymLink );
1548 branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
1551 // Context Menu for XLinks in a branch menu
1552 // This will be populated "on demand" in MapEditor::updateActions
1553 branchContextMenu->addSeparator();
1554 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1555 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1556 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1557 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1560 // Context menu for floatimage
1561 floatimageContextMenu =new QMenu (this);
1562 a= new QAction (tr ("Save image","Context action"),this);
1563 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1564 floatimageContextMenu->addAction (a);
1566 floatimageContextMenu->addSeparator();
1567 actionEditCopy->addTo( floatimageContextMenu );
1568 actionEditCut->addTo( floatimageContextMenu );
1570 floatimageContextMenu->addSeparator();
1571 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1574 // Context menu for canvas
1575 canvasContextMenu =new QMenu (this);
1576 actionEditMapInfo->addTo( canvasContextMenu );
1577 canvasContextMenu->insertSeparator();
1578 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1579 canvasContextMenu->insertSeparator();
1580 actionFormatLinkColorHint->addTo( canvasContextMenu );
1581 actionFormatLinkColor->addTo( canvasContextMenu );
1582 actionFormatSelectionColor->addTo( canvasContextMenu );
1583 actionFormatBackColor->addTo( canvasContextMenu );
1584 actionFormatBackImage->addTo( canvasContextMenu );
1586 // Menu for last opened files
1588 for (int i = 0; i < MaxRecentFiles; ++i)
1590 recentFileActions[i] = new QAction(this);
1591 recentFileActions[i]->setVisible(false);
1592 fileLastMapsMenu->addAction(recentFileActions[i]);
1593 connect(recentFileActions[i], SIGNAL(triggered()),
1594 this, SLOT(fileLoadRecent()));
1596 setupRecentMapsMenu();
1599 void Main::setupRecentMapsMenu()
1601 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1603 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1605 for (int i = 0; i < numRecentFiles; ++i) {
1606 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1607 recentFileActions[i]->setText(text);
1608 recentFileActions[i]->setData(files[i]);
1609 recentFileActions[i]->setVisible(true);
1611 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1612 recentFileActions[j]->setVisible(false);
1615 void Main::setupMacros()
1617 for (int i = 0; i <= 11; i++)
1619 macroActions[i] = new QAction(this);
1620 macroActions[i]->setData(i);
1621 addAction (macroActions[i]);
1622 connect(macroActions[i], SIGNAL(triggered()),
1623 this, SLOT(callMacro()));
1625 macroActions[0]->setShortcut ( Qt::Key_F1 );
1626 macroActions[1]->setShortcut ( Qt::Key_F2 );
1627 macroActions[2]->setShortcut ( Qt::Key_F3 );
1628 macroActions[3]->setShortcut ( Qt::Key_F4 );
1629 macroActions[4]->setShortcut ( Qt::Key_F5 );
1630 macroActions[5]->setShortcut ( Qt::Key_F6 );
1631 macroActions[6]->setShortcut ( Qt::Key_F7 );
1632 macroActions[7]->setShortcut ( Qt::Key_F8 );
1633 macroActions[8]->setShortcut ( Qt::Key_F9 );
1634 macroActions[9]->setShortcut ( Qt::Key_F10 );
1635 macroActions[10]->setShortcut ( Qt::Key_F11 );
1636 macroActions[11]->setShortcut ( Qt::Key_F12 );
1639 void Main::hideEvent (QHideEvent * )
1641 if (!textEditor->isMinimized() ) textEditor->hide();
1644 void Main::showEvent (QShowEvent * )
1646 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1649 bool Main::reallyWriteDirectory(const QString &dir)
1651 QStringList eList = QDir(dir).entryList();
1652 if (eList.first() ==".") eList.pop_front(); // remove "."
1653 if (eList.first() =="..") eList.pop_front(); // remove "."
1654 if (!eList.isEmpty())
1656 QMessageBox mb( vymName,
1657 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?","write directory").arg(dir),
1658 QMessageBox::Warning,
1660 QMessageBox::Cancel | QMessageBox::Default,
1661 QMessageBox::QMessageBox::NoButton );
1663 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1664 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1667 case QMessageBox::Yes:
1670 case QMessageBox::Cancel:
1678 QString Main::browseDirectory (const QString &caption)
1680 QFileDialog fd(this,caption);
1681 fd.setMode (QFileDialog::DirectoryOnly);
1682 fd.setCaption(vymName+ " - "+caption);
1683 fd.setDir (lastFileDir);
1686 if ( fd.exec() == QDialog::Accepted )
1687 return fd.selectedFile();
1692 MapEditor* Main::currentMapEditor() const
1694 if ( tabWidget->currentPage() &&
1695 tabWidget->currentPage()->inherits( "MapEditor" ) )
1696 return (MapEditor*)tabWidget->currentPage();
1701 void Main::editorChanged(QWidget *)
1703 // Unselect all possibly selected objects
1704 // (Important to update note editor)
1706 for (int i=0;i<=tabWidget->count() -1;i++)
1709 me=(MapEditor*)tabWidget->page(i);
1712 currentMapEditor()->reselect();
1714 // Update actions to in menus and toolbars according to editor
1718 void Main::fileNew()
1720 QString fn="unnamed";
1721 MapEditor* me = new MapEditor ( NULL);
1722 tabWidget->addTab (me,fn);
1723 tabWidget->showPage(me);
1724 me->viewport()->setFocus();
1725 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1726 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1728 // For the very first map we do not have flagrows yet...
1732 void Main::fileNewCopy()
1734 QString fn="unnamed";
1735 MapEditor* oldME =currentMapEditor();
1739 MapEditor* newME = new MapEditor ( NULL);
1742 tabWidget->addTab (newME,fn);
1743 tabWidget->showPage(newME);
1744 newME->viewport()->setFocus();
1745 newME->setAntiAlias (actionViewToggleAntiAlias->isOn());
1746 newME->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1747 // For the very first map we do not have flagrows yet...
1748 newME->select("mc:");
1749 newME->load (clipboardDir+"/"+clipboardFile,ImportReplace);
1755 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1757 ErrorCode err=success;
1759 // fn is usually the archive, mapfile the file after uncompressing
1762 // Make fn absolute (needed for unzip)
1763 fn=QDir (fn).absPath();
1769 // Check, if map is already loaded
1771 while (i<=tabWidget->count() -1)
1773 me=(MapEditor*)tabWidget->page(i);
1774 if (me->getFilePath() == fn)
1776 // Already there, ask for confirmation
1777 QMessageBox mb( vymName,
1778 tr("The map %1\nis already opened."
1779 "Opening the same map in multiple editors may lead \n"
1780 "to confusion when finishing working with vym."
1781 "Do you want to").arg(fn),
1782 QMessageBox::Warning,
1783 QMessageBox::Yes | QMessageBox::Default,
1784 QMessageBox::Cancel | QMessageBox::Escape,
1785 QMessageBox::NoButton);
1786 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1787 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1790 case QMessageBox::Yes:
1792 i=tabWidget->count();
1794 case QMessageBox::Cancel:
1806 if ( !fn.isEmpty() )
1808 me = currentMapEditor();
1809 int tabIndex=tabWidget->currentPageIndex();
1810 // Check first, if mapeditor exists
1811 // If it is not default AND we want a new map,
1812 // create a new mapeditor in a new tab
1813 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1815 me= new MapEditor ( NULL);
1816 tabWidget->addTab (me,fn);
1817 tabIndex=tabWidget->indexOf (me);
1818 tabWidget->setCurrentPage (tabIndex);
1819 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1820 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1823 // Check, if file exists (important for creating new files
1824 // from command line
1825 if (!QFile(fn).exists() )
1827 QMessageBox mb( vymName,
1828 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1829 QMessageBox::Question,
1831 QMessageBox::Cancel | QMessageBox::Default,
1832 QMessageBox::NoButton );
1834 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1835 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1838 case QMessageBox::Yes:
1840 currentMapEditor()->setFilePath(fn);
1841 tabWidget->setTabLabel (currentMapEditor(),
1842 currentMapEditor()->getFileName() );
1843 statusBar()->message( "Created " + fn , statusbarTime );
1846 case QMessageBox::Cancel:
1847 // don't create new map
1848 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1855 //tabWidget->currentPage() won't be NULL here, because of above...
1856 tabWidget->showPage(me);
1857 me->viewport()->setFocus();
1859 // Create temporary directory for packing
1861 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
1864 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1865 tr("Couldn't create temporary directory before load\n"));
1869 // Try to unzip file
1870 err=unzipDir (tmpMapDir,fn);
1874 me->setZipped(false);
1877 me->setZipped(true);
1879 // Look for mapname.xml
1880 mapfile= fn.left(fn.findRev(".",-1,true));
1881 mapfile=mapfile.section( '/', -1 );
1882 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1883 if (!file.exists() )
1885 // mapname.xml does not exist, well,
1886 // maybe someone renamed the mapname.vym file...
1887 // Try to find any .xml in the toplevel
1888 // directory of the .vym file
1889 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1890 if (flist.count()==1)
1892 // Only one entry, take this one
1893 mapfile=tmpMapDir + "/"+flist.first();
1896 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1897 *it=tmpMapDir + "/" + *it;
1898 // TODO Multiple entries, load all (but only the first one into this ME)
1899 //mainWindow->fileLoadFromTmp (flist);
1900 //returnCode=1; // Silently forget this attempt to load
1901 qWarning ("MainWindow::load (fn) multimap found...");
1904 if (flist.isEmpty() )
1906 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1907 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1910 } //file doesn't exist
1912 mapfile=file.name();
1917 // Save existing filename in case we import
1918 QString fn_org=me->getFilePath();
1920 // Finally load map into mapEditor
1921 me->setFilePath (mapfile,fn);
1922 err=me->load(mapfile,lmode);
1924 // Restore old (maybe empty) filepath, if this is an import
1926 me->setFilePath (fn_org);
1929 // Finally check for errors and go home
1932 if (lmode==NewMap) fileCloseMap();
1933 statusBar()->message( "Could not load " + fn, statusbarTime );
1938 me->setFilePath (fn);
1939 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1940 if (fn.left(9)!="/tmp/vym-")
1942 // Only append to lastMaps if not loaded from a tmpDir
1943 // e.g. imported bookmarks are in a tmpDir
1944 addRecentMap(me->getFilePath() );
1946 actionFilePrint->setEnabled (true);
1948 statusBar()->message( "Loaded " + fn, statusbarTime );
1952 removeDir (QDir(tmpMapDir));
1958 void Main::fileLoad(const LoadMode &lmode)
1960 QStringList filters;
1961 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1962 QFileDialog *fd=new QFileDialog( this);
1963 fd->setDir (lastFileDir);
1964 fd->setFileMode (QFileDialog::ExistingFiles);
1965 fd->setFilters (filters);
1969 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1972 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1975 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1981 if ( fd->exec() == QDialog::Accepted )
1983 lastFileDir=fd->directory().path();
1984 QStringList flist = fd->selectedFiles();
1985 QStringList::Iterator it = flist.begin();
1986 while( it != flist.end() )
1989 fileLoad(*it, lmode);
1996 void Main::fileLoad()
2001 void Main::fileLoadRecent()
2003 QAction *action = qobject_cast<QAction *>(sender());
2005 fileLoad (action->data().toString(), NewMap);
2008 void Main::addRecentMap (const QString &fileName)
2011 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
2012 files.removeAll(fileName);
2013 files.prepend(fileName);
2014 while (files.size() > MaxRecentFiles)
2017 settings.setValue("/mainwindow/recentFileList", files);
2019 setupRecentMapsMenu();
2022 void Main::fileSave(MapEditor *me, const SaveMode &savemode)
2024 // tmp dir for zipping
2028 ErrorCode err=success;
2030 QString safeFilePath;
2032 bool saveZipped=me->saveZipped();
2036 QString fn=me->getFilePath();
2037 // filename=unnamed, filepath="" in constructor of mapEditor
2038 if ( !fn.isEmpty() )
2040 // We have a filepath, go on saving
2041 // First remove existing file, we
2042 // don't want to add to old zip archives
2046 QMessageBox::warning( 0, tr( "Save Error" ),
2047 fn+ tr("\ncould not be removed before saving"));
2049 // Look, if we should zip the data:
2052 QMessageBox mb( vymName,
2053 tr("The map %1\ndid not use the compressed "
2054 "vym file format.\nWriting it uncompressed will also write images \n"
2055 "and flags and thus may overwrite files in the "
2056 "given directory\n\nDo you want to write the map").arg(fn),
2057 QMessageBox::Warning,
2058 QMessageBox::Yes | QMessageBox::Default,
2060 QMessageBox::Cancel | QMessageBox::Escape);
2061 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
2062 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
2063 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2066 case QMessageBox::Yes:
2067 // save compressed (default file format)
2070 case QMessageBox::No:
2071 // save uncompressed
2074 case QMessageBox::Cancel:
2083 // Create temporary directory for packing
2085 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
2088 QMessageBox::critical( 0, tr( "Critical Load Error" ),
2089 tr("Couldn't create temporary directory before save\n"));
2093 safeFilePath=me->getFilePath();
2094 me->setFilePath (tmpMapDir+"/"+
2095 me->getMapName()+ ".xml",
2097 me->save (savemode);
2098 me->setFilePath (safeFilePath);
2100 zipDir (tmpMapDir,fn);
2105 safeFilePath=me->getFilePath();
2106 me->setFilePath (fn, safeFilePath);
2107 me->save (savemode);
2108 me->setFilePath (safeFilePath);
2110 } // filepath available
2113 // We have no filepath yet,
2114 // call fileSaveAs() now, this will call fileSave()
2116 // First switch to editor
2117 tabWidget->setCurrentWidget (me);
2118 fileSaveAs(savemode);
2122 if (saveZipped && !tmpMapDir.isEmpty())
2124 removeDir (QDir(tmpMapDir));
2128 statusBar()->message(
2129 tr("Saved %1").arg(me->getFilePath()),
2131 addRecentMap (me->getFilePath() );
2133 statusBar()->message(
2134 tr("Couldn't save ").arg(me->getFilePath()),
2138 void Main::fileSave()
2140 fileSave (currentMapEditor(), CompleteMap);
2143 void Main::fileSave(MapEditor *me)
2145 fileSave (me,CompleteMap);
2148 void Main::fileSaveAs(const SaveMode& savemode)
2152 if (currentMapEditor())
2154 if (savemode==CompleteMap)
2155 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2157 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2158 if ( !fn.isEmpty() )
2160 // Check for existing file
2161 if (QFile (fn).exists())
2163 QMessageBox mb( vymName,
2164 tr("The file %1\nexists already. Do you want to").arg(fn),
2165 QMessageBox::Warning,
2166 QMessageBox::Yes | QMessageBox::Default,
2167 QMessageBox::Cancel | QMessageBox::Escape,
2168 QMessageBox::NoButton);
2169 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2170 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2173 case QMessageBox::Yes:
2176 case QMessageBox::Cancel:
2183 // New file, add extension to filename, if missing
2184 // This is always .vym or .vyp, depending on savemode
2185 if (savemode==CompleteMap)
2187 if (!fn.contains (".vym") && !fn.contains (".xml"))
2191 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2200 currentMapEditor()->setFilePath(fn);
2201 fileSave(currentMapEditor(), savemode);
2204 if (savemode==CompleteMap)
2205 tabWidget->setTabLabel (currentMapEditor(),
2206 currentMapEditor()->getFileName() );
2212 void Main::fileSaveAs()
2214 fileSaveAs (CompleteMap);
2217 void Main::fileImportKDEBookmarks()
2219 ImportKDEBookmarks im;
2221 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2222 currentMapEditor()->setFilePath ("");
2225 void Main::fileImportFirefoxBookmarks()
2227 Q3FileDialog *fd=new Q3FileDialog( this);
2228 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2229 fd->setMode (Q3FileDialog::ExistingFiles);
2230 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2231 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2234 if ( fd->exec() == QDialog::Accepted )
2236 ImportFirefoxBookmarks im;
2237 QStringList flist = fd->selectedFiles();
2238 QStringList::Iterator it = flist.begin();
2239 while( it != flist.end() )
2242 if (im.transform() &&
2243 success==fileLoad (im.getTransformedFile(),NewMap) &&
2244 currentMapEditor() )
2245 currentMapEditor()->setFilePath ("");
2252 void Main::fileImportMM()
2256 Q3FileDialog *fd=new Q3FileDialog( this);
2257 fd->setDir (lastFileDir);
2258 fd->setMode (Q3FileDialog::ExistingFiles);
2259 fd->addFilter ("Mind Manager (*.mmap)");
2260 fd->setCaption(tr("Import")+" "+"Mind Manager");
2263 if ( fd->exec() == QDialog::Accepted )
2265 lastFileDir=fd->dirPath();
2266 QStringList flist = fd->selectedFiles();
2267 QStringList::Iterator it = flist.begin();
2268 while( it != flist.end() )
2271 if (im.transform() &&
2272 success==fileLoad (im.getTransformedFile(),NewMap) &&
2273 currentMapEditor() )
2274 currentMapEditor()->setFilePath ("");
2283 void Main::fileImportDir()
2285 if (currentMapEditor())
2286 currentMapEditor()->importDir();
2289 void Main::fileExportXML()
2291 if (currentMapEditor())
2293 QString dir=browseDirectory(tr("Export XML to directory"));
2294 if (dir !="" && reallyWriteDirectory(dir) )
2295 currentMapEditor()->exportXML(dir);
2300 void Main::fileExportXHTML()
2302 MapEditor *me=currentMapEditor();
2306 ExportXHTMLDialog dia(this);
2307 dia.setFilePath (me->getFilePath() );
2308 dia.setMapName (me->getMapName() );
2311 if (dia.exec()==QDialog::Accepted)
2313 QString dir=dia.getDir();
2314 // Check, if warnings should be used before overwriting
2315 // the output directory
2317 warn.showCancelButton (true);
2318 warn.setText(QString(
2319 "The directory %1 is not empty.\n"
2320 "Do you risk to overwrite some of its contents?").arg(dir));
2321 warn.setCaption("Warning: Directory not empty");
2322 warn.setShowAgainName("mainwindow/overwrite-dir-xhtml");
2323 if (warn.exec()==QDialog::Accepted)
2325 me->exportXML (dia.getDir() );
2326 dia.doExport(me->getMapName() );
2327 if (dia.hasChanged())
2334 void Main::fileExportImage()
2336 MapEditor *me=currentMapEditor();
2340 QFileDialog *fd=new QFileDialog (this);
2341 fd->setCaption (tr("Export map as image"));
2342 fd->setDirectory (lastImageDir);
2343 fd->setFileMode(QFileDialog::AnyFile);
2344 fd->setFilters (imageIO.getFilters() );
2347 fl=fd->selectedFiles();
2348 me->exportImage (fl.first(), imageIO.getType (fd->selectedFilter() ) );
2353 void Main::fileExportASCII()
2355 MapEditor *me=currentMapEditor();
2359 ex.setMapCenter(me->getMapCenter());
2360 ex.addFilter ("TXT (*.txt)");
2361 ex.setDir(lastImageDir);
2362 ex.setCaption(vymName+ " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
2363 if (ex.execDialog() )
2365 me->setExportMode(true);
2367 me->setExportMode(false);
2372 void Main::fileExportCSV()
2374 MapEditor *me=currentMapEditor();
2378 ex.setMapCenter(me->getMapCenter());
2379 ex.addFilter ("CSV (*.csv)");
2380 ex.setDir(lastImageDir);
2381 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2382 if (ex.execDialog() )
2384 me->setExportMode(true);
2386 me->setExportMode(false);
2391 void Main::fileExportLaTeX()
2393 MapEditor *me=currentMapEditor();
2397 ex.setMapCenter(me->getMapCenter());
2398 ex.addFilter ("Tex (*.tex)");
2399 ex.setDir(lastImageDir);
2400 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2401 if (ex.execDialog() )
2403 me->setExportMode(true);
2405 me->setExportMode(false);
2410 void Main::fileExportKDEBookmarks()
2412 ExportKDEBookmarks ex;
2413 MapEditor *me=currentMapEditor();
2416 ex.setMapCenter (me->getMapCenter() );
2421 void Main::fileExportTaskjuggler()
2423 ExportTaskjuggler ex;
2424 MapEditor *me=currentMapEditor();
2427 ex.setMapCenter (me->getMapCenter() );
2428 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2429 ex.setDir(lastImageDir);
2430 ex.addFilter ("Taskjuggler (*.tjp)");
2431 if (ex.execDialog() )
2433 me->setExportMode(true);
2435 me->setExportMode(false);
2440 void Main::fileExportOOPresentation()
2442 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2443 // TODO add preview in dialog
2444 //ImagePreview *p =new ImagePreview (fd);
2445 //fd->setContentsPreviewEnabled( TRUE );
2446 //fd->setContentsPreview( p, p );
2447 //fd->setPreviewMode( QFileDialog::Contents );
2448 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2449 fd->setDir (QDir().current());
2450 if (fd->foundConfig())
2454 if ( fd->exec() == QDialog::Accepted )
2456 QString fn=fd->selectedFile();
2457 if (!fn.contains (".odp"))
2460 //lastImageDir=fn.left(fn.findRev ("/"));
2461 if (currentMapEditor())
2462 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2466 QMessageBox::warning(0,
2468 tr("Couldn't find configuration for export to Open Office\n"));
2472 void Main::fileCloseMap()
2474 if (currentMapEditor())
2476 if (currentMapEditor()->hasChanged())
2478 QMessageBox mb( vymName,
2479 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2480 QMessageBox::Warning,
2481 QMessageBox::Yes | QMessageBox::Default,
2483 QMessageBox::Cancel | QMessageBox::Escape );
2484 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2485 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2488 case QMessageBox::Yes:
2490 fileSave(currentMapEditor(), CompleteMap);
2492 case QMessageBox::No:
2493 // close without saving
2495 case QMessageBox::Cancel:
2500 currentMapEditor()->closeMap();
2501 tabWidget->removePage(currentMapEditor());
2502 if (tabWidget->count()==0)
2503 actionFilePrint->setEnabled (false);
2507 void Main::filePrint()
2509 if (currentMapEditor())
2510 currentMapEditor()->print();
2513 void Main::fileExitVYM()
2515 // Check if one or more editors have changed
2518 for (i=0;i<=tabWidget->count() -1;i++)
2521 me=(MapEditor*)tabWidget->page(i);
2523 // If something changed, ask what to do
2524 if (me->hasChanged())
2526 tabWidget->setCurrentPage(i);
2527 QMessageBox mb( vymName,
2528 tr("This map is not saved yet. Do you want to"),
2529 QMessageBox::Warning,
2530 QMessageBox::Yes | QMessageBox::Default,
2532 QMessageBox::Cancel | QMessageBox::Escape );
2533 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2534 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2537 mb.setActiveWindow();
2538 switch( mb.exec() ) {
2539 case QMessageBox::Yes:
2540 // save (the changed editors) and exit
2541 fileSave(currentMapEditor(), CompleteMap);
2543 case QMessageBox::No:
2544 // exit without saving
2546 case QMessageBox::Cancel:
2547 // don't save and don't exit
2551 } // loop over all MEs
2555 void Main::editUndo()
2557 if (currentMapEditor())
2558 currentMapEditor()->undo();
2561 void Main::editRedo()
2563 if (currentMapEditor())
2564 currentMapEditor()->redo();
2567 void Main::gotoHistoryStep (int i)
2569 if (currentMapEditor())
2570 currentMapEditor()->gotoHistoryStep (i);
2573 void Main::editCopy()
2575 if (currentMapEditor())
2576 currentMapEditor()->copy();
2579 void Main::editPaste()
2581 if (currentMapEditor())
2582 currentMapEditor()->paste();
2585 void Main::editCut()
2587 if (currentMapEditor())
2588 currentMapEditor()->cut();
2591 void Main::editOpenFindWindow()
2593 findWindow->popup();
2594 findWindow->raise();
2595 findWindow->setActiveWindow();
2598 void Main::editFind(QString s)
2601 BranchObj *bo=currentMapEditor()->findText(s, cs);
2604 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2607 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2608 tr("No matches found for \"%1\"").arg(s));
2612 void Main::editFindChanged()
2613 { // Notify editor, to abort the current find process
2614 currentMapEditor()->findReset();
2617 void Main::openTabs(QStringList urls)
2619 if (!urls.isEmpty())
2623 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2625 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2627 QString u=urls.takeFirst();
2628 procBrowser = new QProcess( this );
2630 procBrowser->start(browser,args);
2631 if ( !procBrowser->waitForStarted())
2633 // try to set path to browser
2634 QMessageBox::warning(0,
2636 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2637 tr("Please use Settings->")+tr("Set application to open an URL"));
2642 if (browser.contains("konqueror"))
2644 for (int i=0; i<urls.size(); i++)
2647 // Try to open new tab in existing konqueror started previously by vym
2648 p=new QProcess (this);
2650 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2651 "konqueror-mainwindow#1"<<
2654 p->start ("dcop",args);
2655 if ( !p->waitForStarted() ) success=false;
2658 QMessageBox::warning(0,
2660 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2662 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2664 for (int i=0; i<urls.size(); i++)
2666 // Try to open new tab in firefox
2667 p=new QProcess (this);
2668 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2669 p->start (browser,args);
2670 if ( !p->waitForStarted() ) success=false;
2673 QMessageBox::warning(0,
2675 tr("Couldn't start %1 to open a new tab").arg(browser));
2678 QMessageBox::warning(0,
2680 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2684 void Main::editOpenURL()
2687 if (currentMapEditor())
2689 QString url=currentMapEditor()->getURL();
2691 if (url=="") return;
2692 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2693 procBrowser = new QProcess( this );
2695 procBrowser->start(browser,args);
2696 if ( !procBrowser->waitForStarted())
2698 // try to set path to browser
2699 QMessageBox::warning(0,
2701 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2702 tr("Please use Settings->")+tr("Set application to open an URL"));
2707 void Main::editOpenURLTab()
2709 if (currentMapEditor())
2712 urls.append(currentMapEditor()->getURL());
2716 void Main::editOpenMultipleURLTabs()
2718 if (currentMapEditor())
2721 urls=currentMapEditor()->getURLs();
2727 void Main::editURL()
2729 if (currentMapEditor())
2730 currentMapEditor()->editURL();
2733 void Main::editHeading2URL()
2735 if (currentMapEditor())
2736 currentMapEditor()->editHeading2URL();
2739 void Main::editBugzilla2URL()
2741 if (currentMapEditor())
2742 currentMapEditor()->editBugzilla2URL();
2745 void Main::editFATE2URL()
2747 if (currentMapEditor())
2748 currentMapEditor()->editFATE2URL();
2751 void Main::editHeadingFinished()
2753 // only called from editHeading(), so there is a currentME
2754 MapEditor *me=currentMapEditor();
2757 me->setStateEditHeading (false);
2758 QPoint p; //Not used here, only to find out pos of branch
2760 QString s=me->getHeading(ok,p);
2762 #if defined(Q_OS_MACX)
2764 if (ok && s!=lineedit->text())
2765 me->setHeading(lineedit->text());
2767 lineedit->releaseKeyboard();
2771 if (!prevSelection.isEmpty()) me->select(prevSelection);
2776 void Main::editHeading()
2778 if (currentMapEditor())
2780 MapEditor *me=currentMapEditor();
2781 QString oldSel=me->getSelectString();
2783 if (lineedit->isVisible())
2784 editHeadingFinished();
2789 QString s=currentMapEditor()->getHeading(ok,p);
2793 me->setStateEditHeading (true);
2794 #if defined(Q_OS_MACX)
2795 p=currentMapEditor()->mapTo (this,p);
2796 QDialog *d =new QDialog(NULL);
2797 QLineEdit *le=new QLineEdit (d);
2798 d->setWindowFlags (Qt::FramelessWindowHint);
2799 d->setGeometry(p.x(),p.y(),230,25);
2800 le->resize (d->width()-10,d->height());
2803 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2804 d->activateWindow();
2806 currentMapEditor()->setHeading (le->text());
2809 editHeadingFinished();
2811 p=currentMapEditor()->mapTo (this,p);
2812 lineedit->setGeometry(p.x(),p.y(),230,25);
2813 lineedit->setText(s);
2814 lineedit->setCursorPosition(1);
2815 lineedit->selectAll();
2817 lineedit->grabKeyboard();
2818 lineedit->setFocus();
2822 } // currentMapEditor()
2825 void Main::openVymLinks(const QStringList &vl)
2827 for (int j=0; j<vl.size(); j++)
2829 // compare path with already loaded maps
2833 for (i=0;i<=tabWidget->count() -1;i++)
2835 me=(MapEditor*)tabWidget->page(i);
2836 if (vl.at(j)==me->getFilePath() )
2845 if (!QFile(vl.at(j)).exists() )
2846 QMessageBox::critical( 0, tr( "Critical Error" ),
2847 tr("Couldn't open map %1").arg(vl.at(j)));
2850 fileLoad (vl.at(j), NewMap);
2851 tabWidget->setCurrentPage (tabWidget->count()-1);
2854 // Go to tab containing the map
2855 tabWidget->setCurrentPage (index);
2859 void Main::editOpenVymLink()
2861 if (currentMapEditor())
2864 vl.append(currentMapEditor()->getVymLink());
2869 void Main::editOpenMultipleVymLinks()
2871 QString currentVymLink;
2872 if (currentMapEditor())
2874 QStringList vl=currentMapEditor()->getVymLinks();
2879 void Main::editVymLink()
2881 if (currentMapEditor())
2882 currentMapEditor()->editVymLink();
2885 void Main::editDeleteVymLink()
2887 if (currentMapEditor())
2888 currentMapEditor()->deleteVymLink();
2891 void Main::editToggleHideExport()
2893 if (currentMapEditor())
2894 currentMapEditor()->toggleHideExport();
2897 void Main::editMapInfo()
2899 if (currentMapEditor())
2900 currentMapEditor()->editMapInfo();
2903 void Main::editMoveUp()
2905 if (currentMapEditor())
2906 currentMapEditor()->moveBranchUp();
2909 void Main::editMoveDown()
2911 if (currentMapEditor())
2912 currentMapEditor()->moveBranchDown();
2915 void Main::editToggleScroll()
2917 if (currentMapEditor())
2919 currentMapEditor()->toggleScroll();
2923 void Main::editUnscrollChilds()
2925 if (currentMapEditor())
2926 currentMapEditor()->unscrollChilds();
2929 void Main::editNewBranch()
2931 MapEditor *me=currentMapEditor();
2932 if (!lineedit->isVisible() && me)
2934 BranchObj *bo=(BranchObj*)me->getSelection();
2935 BranchObj *newbo=me->addNewBranch(0);
2938 me->select (newbo->getSelectString());
2942 if (actionSettingsAutoEdit->isOn())
2944 if (!actionSettingsAutoSelectHeading->isOn())
2945 prevSelection=bo->getSelectString();
2951 void Main::editNewBranchBefore()
2953 MapEditor *me=currentMapEditor();
2954 if (!lineedit->isVisible() && me)
2956 BranchObj *bo=(BranchObj*)me->getSelection();
2957 BranchObj *newbo=me->addNewBranchBefore();
2960 me->select (newbo->getSelectString());
2964 if (actionSettingsAutoEdit->isOn())
2966 if (!actionSettingsAutoSelectHeading->isOn())
2967 prevSelection=bo->getSelectString();
2973 void Main::editNewBranchAbove()
2975 MapEditor *me=currentMapEditor();
2976 if (!lineedit->isVisible() && me)
2978 BranchObj *bo=(BranchObj*)me->getSelection();
2979 BranchObj *newbo=me->addNewBranch (-1);
2982 me->select (newbo->getSelectString());
2986 if (actionSettingsAutoEdit->isOn())
2988 if (!actionSettingsAutoSelectHeading->isOn())
2989 prevSelection=bo->getSelectString();
2995 void Main::editNewBranchBelow()
2997 MapEditor *me=currentMapEditor();
2998 if (!lineedit->isVisible() && me)
3000 BranchObj *bo=(BranchObj*)me->getSelection();
3001 BranchObj *newbo=me->addNewBranch (1);
3004 me->select (newbo->getSelectString());
3008 if (actionSettingsAutoEdit->isOn())
3010 if (!actionSettingsAutoSelectHeading->isOn())
3011 prevSelection=bo->getSelectString();
3017 void Main::editImportAdd()
3019 fileLoad (ImportAdd);
3022 void Main::editImportReplace()
3024 fileLoad (ImportReplace);
3027 void Main::editSaveBranch()
3029 fileSaveAs (PartOfMap);
3032 void Main::editDeleteKeepChilds()
3034 if (currentMapEditor())
3035 currentMapEditor()->deleteKeepChilds();
3038 void Main::editDeleteChilds()
3040 if (currentMapEditor())
3041 currentMapEditor()->deleteChilds();
3044 void Main::editDeleteSelection()
3046 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
3047 currentMapEditor()->deleteSelection();
3050 void Main::editUpperBranch()
3052 if (currentMapEditor())
3053 currentMapEditor()->selectUpperBranch();
3056 void Main::editLowerBranch()
3058 if (currentMapEditor())
3059 currentMapEditor()->selectLowerBranch();
3062 void Main::editLeftBranch()
3064 if (currentMapEditor())
3065 currentMapEditor()->selectLeftBranch();
3068 void Main::editRightBranch()
3070 if (currentMapEditor())
3071 currentMapEditor()->selectRightBranch();
3074 void Main::editFirstBranch()
3076 if (currentMapEditor())
3077 currentMapEditor()->selectFirstBranch();
3080 void Main::editLastBranch()
3082 if (currentMapEditor())
3083 currentMapEditor()->selectLastBranch();
3086 void Main::editLoadImage()
3088 if (currentMapEditor())
3089 currentMapEditor()->loadFloatImage();
3092 void Main::editSaveImage()
3094 if (currentMapEditor())
3095 currentMapEditor()->saveFloatImage();
3098 void Main::editFollowXLink(QAction *a)
3101 if (currentMapEditor())
3102 currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
3105 void Main::editEditXLink(QAction *a)
3107 if (currentMapEditor())
3108 currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3111 void Main::formatSelectColor()
3113 if (currentMapEditor())
3115 QColor col = QColorDialog::getColor((currentColor ), this );
3116 if ( !col.isValid() ) return;
3117 colorChanged( col );
3121 void Main::formatPickColor()
3123 if (currentMapEditor())
3124 colorChanged( currentMapEditor()->getCurrentHeadingColor() );
3127 void Main::colorChanged(QColor c)
3129 QPixmap pix( 16, 16 );
3131 actionFormatColor->setIconSet( pix );
3135 void Main::formatColorBranch()
3137 if (currentMapEditor())
3138 currentMapEditor()->colorBranch(currentColor);
3141 void Main::formatColorSubtree()
3143 if (currentMapEditor())
3144 currentMapEditor()->colorSubtree (currentColor);
3147 void Main::formatLinkStyleLine()
3149 if (currentMapEditor())
3150 currentMapEditor()->setMapLinkStyle("StyleLine");
3153 void Main::formatLinkStyleParabel()
3155 if (currentMapEditor())
3156 currentMapEditor()->setMapLinkStyle("StyleParabel");
3159 void Main::formatLinkStylePolyLine()
3161 if (currentMapEditor())
3162 currentMapEditor()->setMapLinkStyle("StylePolyLine");
3165 void Main::formatLinkStylePolyParabel()
3167 if (currentMapEditor())
3168 currentMapEditor()->setMapLinkStyle("StylePolyParabel");
3171 void Main::formatSelectBackColor()
3173 if (currentMapEditor())
3174 currentMapEditor()->selectMapBackgroundColor();
3177 void Main::formatSelectBackImage()
3179 if (currentMapEditor())
3180 currentMapEditor()->selectMapBackgroundImage();
3183 void Main::formatSelectLinkColor()
3185 if (currentMapEditor())
3186 currentMapEditor()->selectMapLinkColor();
3189 void Main::formatSelectSelectionColor()
3191 if (currentMapEditor())
3192 currentMapEditor()->selectMapSelectionColor();
3195 void Main::formatToggleLinkColorHint()
3197 currentMapEditor()->toggleMapLinkColorHint();
3201 void Main::formatHideLinkUnselected() //FIXME get rid of this with imagepropertydialog
3203 if (currentMapEditor())
3204 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3207 void Main::viewZoomReset()
3209 if (currentMapEditor())
3213 currentMapEditor()->setMatrix( m );
3217 void Main::viewZoomIn()
3219 if (currentMapEditor())
3221 QMatrix m = currentMapEditor()->matrix();
3222 m.scale( 1.25, 1.25 );
3223 currentMapEditor()->setMatrix( m );
3227 void Main::viewZoomOut()
3229 if (currentMapEditor())
3231 QMatrix m = currentMapEditor()->matrix();
3232 m.scale( 0.8, 0.8 );
3233 currentMapEditor()->setMatrix( m );
3237 bool Main::settingsPDF()
3239 // Default browser is set in constructor
3241 QString text = QInputDialog::getText(
3242 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3243 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3245 settings.setValue ("/mainwindow/readerPDF",text);
3250 bool Main::settingsURL()
3252 // Default browser is set in constructor
3254 QString text = QInputDialog::getText(
3255 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3256 settings.value("/mainwindow/readerURL").toString()
3259 settings.setValue ("/mainwindow/readerURL",text);
3263 void Main::settingsMacroDir()
3265 QDir defdir=vymBaseDir;
3266 defdir.cd("macros");
3267 if (!defdir.exists())
3269 QDir dir=QFileDialog::getExistingDirectory (
3271 tr ("Directory with vym macros:"),
3272 settings.value ("/macros/macroDir",defdir.path()).toString()
3275 settings.setValue ("/macros/macroDir",dir.path());
3278 void Main::settingsUndoLevels()
3281 int i = QInputDialog::getInteger(
3283 tr("QInputDialog::getInteger()"),
3284 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3287 settings.setValue ("/mapeditor/stepsTotal",i);
3288 QMessageBox::information( this, tr( "VYM -Information:" ),
3289 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3293 void Main::settingsAutosaveToggle()
3295 settings.setValue ("/mapeditor/autosave/used",actionSettingsAutosaveToggle->isOn() );
3298 void Main::settingsAutosaveTime()
3301 int i = QInputDialog::getInteger(
3303 tr("QInputDialog::getInteger()"),
3304 tr("Number of seconds before autosave:"), settings.value("/mapeditor/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3307 settings.setValue ("/mapeditor/autosave/ms",i * 1000);
3311 void Main::settingsToggleDelKey()
3313 if (actionSettingsUseDelKey->isOn())
3315 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3318 actionEditDelete->setAccel (QKeySequence (""));
3322 void Main::windowToggleNoteEditor()
3324 if (textEditor->showWithMain() )
3325 windowHideNoteEditor();
3327 windowShowNoteEditor();
3330 void Main::windowToggleHistory()
3332 if (historyWindow->isVisible())
3333 historyWindow->hide();
3335 historyWindow->show();
3339 void Main::windowToggleProperty()
3341 if (branchPropertyWindow->isVisible())
3342 branchPropertyWindow->hide();
3344 branchPropertyWindow->show();
3346 if(currentMapEditor())
3348 LinkableMapObj *sel=currentMapEditor()->getSelection();
3349 if (sel && (typeid(*sel) == typeid(BranchObj) ||
3350 typeid(*sel) == typeid(MapCenterObj)))
3352 branchPropertyWindow->setMapEditor(currentMapEditor());
3353 branchPropertyWindow->setBranch((BranchObj*)sel);
3358 branchPropertyWindow->setBranch(NULL);
3361 void Main::windowToggleAntiAlias()
3363 bool b=actionViewToggleAntiAlias->isOn();
3365 for (int i=0;i<tabWidget->count();i++)
3368 me=(MapEditor*)tabWidget->page(i);
3369 me->setAntiAlias(b);
3374 void Main::windowToggleSmoothPixmap()
3376 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3378 for (int i=0;i<tabWidget->count();i++)
3381 me=(MapEditor*)tabWidget->page(i);
3382 me->setSmoothPixmap(b);
3386 void Main::updateHistory(SimpleSettings &undoSet)
3388 historyWindow->update (undoSet);
3391 void Main::updateNoteFlag()
3393 if (currentMapEditor())
3394 currentMapEditor()->updateNoteFlag();
3397 void Main::updateSatellites(MapEditor *me)
3399 branchPropertyWindow->setMapEditor (me);
3402 void Main::updateActions()
3404 MapEditor *me=currentMapEditor();
3407 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(currentMapEditor()->getFileName()));
3409 // updateActions is also called when NoteEditor is closed
3410 actionViewToggleNoteEditor->setOn (textEditor->isVisible());
3411 actionViewToggleHistoryWindow->setOn (historyWindow->isVisible());
3412 actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible());
3414 if (me->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3415 actionFormatLinkColorHint->setOn(true);
3417 actionFormatLinkColorHint->setOn(false);
3419 switch (me->getMapLinkStyle())
3421 case LinkableMapObj::Line:
3422 actionFormatLinkStyleLine->setOn(true);
3424 case LinkableMapObj::Parabel:
3425 actionFormatLinkStyleParabel->setOn(true);
3427 case LinkableMapObj::PolyLine:
3428 actionFormatLinkStylePolyLine->setOn(true);
3430 case LinkableMapObj::PolyParabel:
3431 actionFormatLinkStylePolyParabel->setOn(true);
3438 QPixmap pix( 16, 16 );
3439 pix.fill( me->getMapBackgroundColor() );
3440 actionFormatBackColor->setIconSet( pix );
3441 pix.fill( me->getSelectionColor() );
3442 actionFormatSelectionColor->setIconSet( pix );
3443 pix.fill( me->getMapDefLinkColor() );
3444 actionFormatLinkColor->setIconSet( pix );
3447 actionFileSave->setEnabled( me->hasChanged() );
3448 if (me->isUndoAvailable())
3449 actionEditUndo->setEnabled( true);
3451 actionEditUndo->setEnabled( false);
3453 if (me->isRedoAvailable())
3454 actionEditRedo->setEnabled( true);
3456 actionEditRedo->setEnabled( false);
3458 LinkableMapObj *selection=me->getSelection();
3461 if ( (typeid(*selection) == typeid(BranchObj)) ||
3462 (typeid(*selection) == typeid(MapCenterObj)) )
3464 BranchObj *bo=(BranchObj*)selection;
3465 // Take care of links
3466 if (bo->countXLinks()==0)
3468 branchXLinksContextMenuEdit->clear();
3469 branchXLinksContextMenuFollow->clear();
3474 branchXLinksContextMenuEdit->clear();
3475 branchXLinksContextMenuFollow->clear();
3476 for (int i=0; i<=bo->countXLinks();i++)
3478 bot=bo->XLinkTargetAt(i);
3481 s=bot->getHeading();
3484 branchXLinksContextMenuFollow->addAction (s);
3485 branchXLinksContextMenuEdit->addAction (s);
3490 standardFlagsDefault->setEnabled (true);
3492 actionEditToggleScroll->setEnabled (true);
3493 if ( bo->isScrolled() )
3494 actionEditToggleScroll->setOn(true);
3496 actionEditToggleScroll->setOn(false);
3498 if ( bo->getURL().isEmpty() )
3500 actionEditOpenURL->setEnabled (false);
3501 actionEditOpenURLTab->setEnabled (false);
3505 actionEditOpenURL->setEnabled (true);
3506 actionEditOpenURLTab->setEnabled (true);
3508 if ( bo->getVymLink().isEmpty() )
3510 actionEditOpenVymLink->setEnabled (false);
3511 actionEditDeleteVymLink->setEnabled (false);
3514 actionEditOpenVymLink->setEnabled (true);
3515 actionEditDeleteVymLink->setEnabled (true);
3518 if (bo->canMoveBranchUp())
3519 actionEditMoveUp->setEnabled (true);
3521 actionEditMoveUp->setEnabled (false);
3522 if (bo->canMoveBranchDown())
3523 actionEditMoveDown->setEnabled (true);
3525 actionEditMoveDown->setEnabled (false);
3528 actionEditToggleHideExport->setEnabled (true);
3529 actionEditToggleHideExport->setOn (bo->hideInExport() );
3531 actionEditCopy->setEnabled (true);
3532 actionEditCut->setEnabled (true);
3533 if (!clipboardEmpty)
3534 actionEditPaste->setEnabled (true);
3536 actionEditPaste->setEnabled (false);
3537 for (int i=0; i<actionListBranches.size(); ++i)
3538 actionListBranches.at(i)->setEnabled(true);
3539 actionEditDelete->setEnabled (true);
3540 actionFormatHideLinkUnselected->setOn
3541 (selection->getHideLinkUnselected());
3543 if ( (typeid(*selection) == typeid(FloatImageObj)) )
3545 FloatObj *fo=(FloatImageObj*)selection;
3547 actionEditOpenURL->setEnabled (false);
3548 actionEditOpenVymLink->setEnabled (false);
3549 actionEditDeleteVymLink->setEnabled (false);
3550 actionEditToggleHideExport->setEnabled (true);
3551 actionEditToggleHideExport->setOn (fo->hideInExport() );
3554 actionEditCopy->setEnabled (true);
3555 actionEditCut->setEnabled (true);
3556 actionEditPaste->setEnabled (false);
3557 for (int i=0; i<actionListBranches.size(); ++i)
3558 actionListBranches.at(i)->setEnabled(false);
3559 actionEditDelete->setEnabled (true);
3560 actionFormatHideLinkUnselected->setOn
3561 ( selection->getHideLinkUnselected());
3562 actionEditMoveUp->setEnabled (false);
3563 actionEditMoveDown->setEnabled (false);
3568 actionEditCopy->setEnabled (false);
3569 actionEditCut->setEnabled (false);
3570 actionEditPaste->setEnabled (false);
3571 for (int i=0; i<actionListBranches.size(); ++i)
3572 actionListBranches.at(i)->setEnabled(false);
3574 actionEditToggleScroll->setEnabled (false);
3575 actionEditOpenURL->setEnabled (false);
3576 actionEditOpenVymLink->setEnabled (false);
3577 actionEditDeleteVymLink->setEnabled (false);
3578 actionEditHeading2URL->setEnabled (false);
3579 actionEditDelete->setEnabled (false);
3580 actionEditMoveUp->setEnabled (false);
3581 actionEditMoveDown->setEnabled (false);
3582 actionEditToggleHideExport->setEnabled (false);
3586 Main::ModMode Main::getModMode()
3588 if (actionModModeColor->isOn()) return ModModeColor;
3589 if (actionModModeCopy->isOn()) return ModModeCopy;
3590 if (actionModModeXLink->isOn()) return ModModeXLink;
3594 bool Main::autoEdit()
3596 return actionSettingsAutoEdit->isOn();
3599 bool Main::autoSelectHeading()
3601 return actionSettingsAutoSelectHeading->isOn();
3604 bool Main::useFlagGroups()
3606 return actionSettingsUseFlagGroups->isOn();
3609 void Main::windowShowNoteEditor()
3611 textEditor->setShowWithMain(true);
3613 actionViewToggleNoteEditor->setOn (true);
3616 void Main::windowHideNoteEditor()
3618 textEditor->setShowWithMain(false);
3620 actionViewToggleNoteEditor->setOn (false);
3623 void Main::setScript (const QString &script)
3625 scriptEditor->setScript (script);
3628 void Main::runScript (const QString &script)
3630 if (currentMapEditor())
3631 currentMapEditor()->runScript (script);
3634 void Main::windowNextEditor()
3636 if (tabWidget->currentPageIndex() < tabWidget->count())
3637 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3640 void Main::windowPreviousEditor()
3642 if (tabWidget->currentPageIndex() >0)
3643 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3646 void Main::standardFlagChanged()
3648 if (currentMapEditor())
3649 currentMapEditor()->toggleStandardFlag(sender()->name());
3652 void Main::testFunction()
3654 if (!currentMapEditor()) return;
3655 currentMapEditor()->testFunction();
3658 void Main::testCommand()
3660 if (!currentMapEditor()) return;
3661 scriptEditor->show();
3664 QString com = QInputDialog::getText(
3665 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3666 if (ok) currentMapEditor()->parseAtom(com);
3670 void Main::helpDoc()
3672 QString locale = QLocale::system().name();
3674 if (locale.left(2)=="es")
3675 docname="vym_es.pdf";
3679 QStringList searchList;
3681 #if defined(Q_OS_MACX)
3682 searchList << "./vym.app/Contents";
3684 // default path in SUSE LINUX
3685 searchList <<"/usr/share/doc/packages/vym/doc";
3688 searchList << "doc"; // relative path for easy testing in tarball
3689 searchList << "doc/tex"; // Easy testing working on vym.tex
3690 searchList << "/usr/share/doc/vym"; // Debian
3691 searchList << "/usr/share/doc/packages";// Knoppix
3695 for (int i=0; i<searchList.count(); ++i)
3697 docfile.setFileName(QDir::convertSeparators(searchList.at(i)+"/"+docname));
3698 if (docfile.exists() )
3707 QMessageBox::critical(0,
3708 tr("Critcal error"),
3709 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3714 Process *pdfProc = new Process();
3715 args <<docfile.fileName();
3717 pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
3718 if ( !pdfProc->waitForStarted() )
3721 QMessageBox::warning(0,
3723 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3724 tr("Please use Settings->")+tr("Set application to open PDF files"));
3731 void Main::helpAbout()
3734 ad.setName ("aboutwindow");
3735 ad.setMinimumSize(500,500);
3736 ad.resize (QSize (500,500));
3740 void Main::helpAboutQT()
3742 QMessageBox::aboutQt( this, "Qt Application Example" );
3745 void Main::callMacro ()
3747 QAction *action = qobject_cast<QAction *>(sender());
3751 i=action->data().toInt();
3752 QString mDir (settings.value ("macros/macroDir").toString() );
3754 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3756 if ( !f.open( QIODevice::ReadOnly ) )
3758 QMessageBox::warning(0,
3760 tr("Couldn't find a macro at %1.\n").arg(fn)+
3761 tr("Please use Settings->")+tr("Set directory for vym macros"));
3765 QTextStream ts( &f );
3766 QString m= ts.read();
3770 //cout <<"Main::callMacro m="<<m.ascii()<<endl;
3771 currentMapEditor()->runScript (m);