1.11.2 split up of xml helper functions. started to work on attributes
1 #include "mainwindow.h"
8 #include "aboutdialog.h"
9 #include "branchpropwindow.h"
10 #include "exportoofiledialog.h"
13 #include "flagrowobj.h"
14 #include "historywindow.h"
16 #include "mapeditor.h"
21 #include "texteditor.h"
22 #include "warningdialog.h"
24 #if defined(Q_OS_WIN32)
25 // Define only this structure as opposed to
26 // including full 'windows.h'. FindWindow
27 // clashes with the one in Win32 API.
28 typedef struct _PROCESS_INFORMATION
34 } PROCESS_INFORMATION, *LPPROCESS_INFORMATION;
37 extern TextEditor *textEditor;
38 extern Main *mainWindow;
39 extern QString tmpVymDir;
40 extern QString clipboardDir;
41 extern QString clipboardFile;
42 extern bool clipboardEmpty;
43 extern int statusbarTime;
44 extern FlagRowObj* standardFlagsDefault;
45 extern FlagRowObj* systemFlagsDefault;
46 extern QString vymName;
47 extern QString vymVersion;
48 extern QString vymBuildDate;
51 QMenu* branchContextMenu;
52 QMenu* branchAddContextMenu;
53 QMenu* branchRemoveContextMenu;
54 QMenu* branchLinksContextMenu;
55 QMenu* branchXLinksContextMenuEdit;
56 QMenu* branchXLinksContextMenuFollow;
57 QMenu* floatimageContextMenu;
58 QMenu* canvasContextMenu;
59 QMenu* fileLastMapsMenu;
60 QMenu* fileImportMenu;
61 QMenu* fileExportMenu;
64 extern Settings settings;
65 extern Options options;
66 extern ImageIO imageIO;
68 extern QDir vymBaseDir;
69 extern QDir lastImageDir;
70 extern QDir lastFileDir;
71 extern QString iconPath;
72 extern QString flagsPath;
74 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
75 QMainWindow(parent,name,f)
79 setCaption ("VYM - View Your Mind");
81 // Load window settings
82 resize (settings.value( "/mainwindow/geometry/size",QSize (800,600)).toSize());
83 move (settings.value( "/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
86 // Sometimes we may need to remember old selections
90 currentColor=Qt::black;
92 // Create unique temporary directory
94 tmpVymDir=makeTmpDir (ok,"vym");
97 qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
100 if (debug) qDebug (QString("vym tmpDir=%1").arg(tmpVymDir) );
102 // Create direcctory for clipboard
103 clipboardDir=tmpVymDir+"/clipboard";
104 clipboardFile="map.xml";
105 QDir d(clipboardDir);
106 d.mkdir (clipboardDir,true);
107 makeSubDirs (clipboardDir);
112 // Satellite windows //////////////////////////////////////////
115 historyWindow=new HistoryWindow();
116 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
119 branchPropertyWindow = new BranchPropertyWindow();
120 connect (branchPropertyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
122 // Connect TextEditor, so that we can update flags if text changes
123 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
124 connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
126 // Connect HistoryWindow, so that we can update flags
127 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
130 // Initialize script editor
131 scriptEditor = new SimpleScriptEditor();
132 scriptEditor->move (50,50);
134 connect( scriptEditor, SIGNAL( runScript ( QString ) ),
135 this, SLOT( runScript( QString ) ) );
138 // Initialize Find window
139 findWindow=new FindWindow(NULL);
140 findWindow->move (x(),y()+70);
141 connect (findWindow, SIGNAL( findButton(QString) ),
142 this, SLOT(editFind(QString) ) );
143 connect (findWindow, SIGNAL( somethingChanged() ),
144 this, SLOT(editFindChanged() ) );
146 // Initialize some settings, which are platform dependant
149 // application to open URLs
150 p="/mainwindow/readerURL";
151 #if defined(Q_OS_LINUX)
152 s=settings.value (p,"xdg-open").toString();
154 #if defined(Q_OS_MACX)
155 s=settings.value (p,"/usr/bin/open").toString();
158 #if defined(Q_OS_WIN32)
159 // Assume that system has been set up so that
160 // Explorer automagically opens up the URL
161 // in the user's preferred browser.
162 s=settings.value (p,"explorer").toString();
164 s=settings.value (p,"mozilla").toString();
168 settings.setValue( p,s);
170 // application to open PDFs
171 p="/mainwindow/readerPDF";
172 #if defined(Q_OS_LINUX)
173 s=settings.value (p,"xdg-open").toString();
175 #if defined(Q_OS_MACX)
176 s=settings.value (p,"/usr/bin/open").toString();
178 s=settings.value (p,"acroread").toString();
181 settings.setValue( p,s);
183 // width of xLinksMenu
186 // Create tab widget which holds the maps
187 tabWidget= new QTabWidget (this);
188 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
189 this, SLOT( editorChanged( QWidget * ) ) );
191 lineedit=new QLineEdit (this);
194 setCentralWidget(tabWidget);
198 setupFormatActions();
202 setupNetworkActions();
203 setupSettingsActions();
206 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
211 restoreState (settings.value("/mainwindow/state",0).toByteArray());
219 settings.setValue ( "/mainwindow/geometry/size", size() );
220 settings.setValue ( "/mainwindow/geometry/pos", pos() );
221 settings.setValue ("/mainwindow/state",saveState(0));
223 settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
224 settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
225 settings.setValue( "/version/version", vymVersion );
226 settings.setValue( "/version/builddate", vymBuildDate );
228 settings.setValue( "/mapeditor/autosave/use",actionSettingsAutosaveToggle->isOn() );
229 settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isOn() );
230 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
231 settings.setValue( "/mapeditor/editmode/autoEditNewBranch",actionSettingsAutoEditNewBranch->isOn() );
232 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
233 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
234 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
236 //TODO save scriptEditor settings
238 // call the destructors
240 delete historyWindow;
241 delete branchPropertyWindow;
243 // Remove temporary directory
244 removeDir (QDir(tmpVymDir));
247 void Main::loadCmdLine()
249 /* TODO draw some kind of splashscreen while loading...
255 QStringList flist=options.getFileList();
256 QStringList::Iterator it=flist.begin();
258 while (it !=flist.end() )
260 fileLoad (*it, NewMap);
266 void Main::statusMessage(const QString &s)
268 statusBar()->message( s);
271 void Main::closeEvent (QCloseEvent* )
277 void Main::setupFileActions()
279 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
280 QToolBar *tb = addToolBar( tr ("&Map") );
281 tb->setObjectName ("mapTB");
284 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this);
285 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
286 a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map
288 fileMenu->addAction (a);
289 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
291 a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this);
292 a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) );
293 a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N ); //New map
294 fileMenu->addAction (a);
295 connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) );
297 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
298 a->setStatusTip (tr( "Open","Status tip File menu" ) );
299 a->setShortcut ( Qt::CTRL + Qt::Key_O ); //Open map
301 fileMenu->addAction (a);
302 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
304 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
305 fileMenu->addSeparator();
307 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
308 a->setStatusTip ( tr( "Save","Status tip file menu" ));
309 a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map
311 fileMenu->addAction (a);
312 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
315 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
316 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
317 fileMenu->addAction (a);
318 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
320 fileMenu->addSeparator();
322 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
324 a = new QAction(tr("KDE Bookmarks"), this);
325 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE bookmarks")));
326 a->addTo (fileImportMenu);
327 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) );
329 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
331 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
332 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
333 a->addTo (fileImportMenu);
334 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
337 a = new QAction("Freemind...",this);
338 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Freemind") );
339 fileImportMenu->addAction (a);
340 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFreemind() ) );
342 a = new QAction("Mind Manager...",this);
343 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
344 fileImportMenu->addAction (a);
345 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
347 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
348 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
349 fileImportMenu->addAction (a);
350 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
352 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
354 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
355 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
356 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
357 fileExportMenu->addAction (a);
359 a = new QAction( "Open Office...", this);
360 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
361 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
362 fileExportMenu->addAction (a);
364 a = new QAction( "Webpage (XHTML)...",this );
365 a->setShortcut (Qt::ALT + Qt::Key_X); //Export XHTML
366 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
367 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
368 fileExportMenu->addAction (a);
370 a = new QAction( "Text (ASCII)...", this);
371 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
372 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
373 fileExportMenu->addAction (a);
375 a = new QAction( "Spreadsheet (CSV)...", this);
376 a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
377 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
378 fileExportMenu->addAction (a);
380 a = new QAction( tr("KDE Bookmarks","File menu"), this);
381 a->setStatusTip( tr( "Export as %1").arg(tr("KDE Bookmarks" )));
382 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
383 fileExportMenu->addAction (a);
385 a = new QAction( "Taskjuggler...", this );
386 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
387 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
388 fileExportMenu->addAction (a);
390 a = new QAction( "LaTeX...", this);
391 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
392 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
393 fileExportMenu->addAction (a);
395 a = new QAction( "XML..." , this );
396 a->setStatusTip (tr( "Export as %1").arg("XML"));
397 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
398 fileExportMenu->addAction (a);
400 fileMenu->addSeparator();
402 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
403 a->setStatusTip ( tr( "Print" ,"File menu") );
404 a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map
406 fileMenu->addAction (a);
407 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
410 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
411 a->setStatusTip (tr( "Close Map" ) );
412 a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map
413 fileMenu->addAction (a);
414 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
416 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
417 a->setStatusTip ( tr( "Exit")+" "+vymName );
418 a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym
419 fileMenu->addAction (a);
420 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
425 void Main::setupEditActions()
427 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
428 tb->setLabel( "Edit Actions" );
429 tb->setObjectName ("actionsTB");
430 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
434 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
435 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
436 a->setStatusTip (tr( "Undo" ) );
437 a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action
438 a->setEnabled (false);
440 editMenu->addAction (a);
443 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
444 a->setStatusTip (tr( "Redo" ));
445 a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action
447 editMenu->addAction (a);
448 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
451 editMenu->addSeparator();
452 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
453 a->setStatusTip ( tr( "Copy" ) );
454 a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy
455 a->setEnabled (false);
457 editMenu->addAction (a);
458 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
461 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
462 a->setStatusTip ( tr( "Cut" ) );
463 a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut
464 a->setEnabled (false);
466 editMenu->addAction (a);
468 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
470 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
471 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
472 a->setStatusTip ( tr( "Paste" ) );
473 a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste
474 a->setEnabled (false);
476 editMenu->addAction (a);
479 // Shortcuts to modify heading:
480 a = new QAction(tr( "Edit heading","Edit menu" ),this);
481 a->setStatusTip ( tr( "edit Heading" ));
482 a->setShortcut ( Qt::Key_Enter); //Edit heading
483 // a->setShortcutContext (Qt::WindowShortcut);
485 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
486 actionListBranches.append(a);
487 a = new QAction( tr( "Edit heading","Edit menu" ), this);
488 a->setStatusTip (tr( "edit Heading" ));
489 a->setShortcut (Qt::Key_Return ); //Edit heading
490 //a->setShortcutContext (Qt::WindowShortcut);
492 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
493 actionListBranches.append(a);
494 editMenu->addAction (a);
496 a = new QAction( tr( "Edit heading","Edit menu" ), this);
497 a->setStatusTip (tr( "edit Heading" ));
498 //a->setShortcut ( Qt::Key_F2 ); //Edit heading
499 a->setShortcutContext (Qt::WindowShortcut);
501 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
502 actionListBranches.append(a);
504 // Shortcut to delete selection
505 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
506 a->setStatusTip (tr( "Delete Selection" ));
507 a->setShortcut ( Qt::Key_Delete); //Delete selection
508 a->setShortcutContext (Qt::WindowShortcut);
510 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
513 // Shortcut to add branch
514 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
515 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
516 alt->setShortcut (Qt::Key_A); //Add branch
517 alt->setShortcutContext (Qt::WindowShortcut);
519 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
520 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
521 a->setStatusTip ( tr( "Add a branch as child of selection" ));
522 a->setShortcut (Qt::Key_Insert); //Add branch
523 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
524 actionListBranches.append(a);
525 #if defined (Q_OS_MACX)
526 // In OSX show different shortcut in menues, the keys work indepently always
527 actionEditAddBranch=alt;
529 actionEditAddBranch=a;
531 editMenu->addAction (actionEditAddBranch);
532 tb->addAction (actionEditAddBranch);
535 // Add branch by inserting it at selection
536 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
537 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
538 a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch
539 a->setShortcutContext (Qt::WindowShortcut);
541 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
542 a->setEnabled (false);
543 actionListBranches.append(a);
544 actionEditAddBranchBefore=a;
545 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
546 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
547 a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch
548 a->setShortcutContext (Qt::WindowShortcut);
550 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
551 actionListBranches.append(a);
554 a = new QAction(tr( "Add branch above","Edit menu" ), this);
555 a->setStatusTip ( tr( "Add a branch above selection" ));
556 a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
557 a->setShortcutContext (Qt::WindowShortcut);
559 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
560 a->setEnabled (false);
561 actionListBranches.append(a);
562 actionEditAddBranchAbove=a;
563 a = new QAction(tr( "Add branch above","Edit menu" ), this);
564 a->setStatusTip ( tr( "Add a branch above selection" ));
565 a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above
566 a->setShortcutContext (Qt::WindowShortcut);
568 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
569 actionListBranches.append(a);
572 a = new QAction(tr( "Add branch below","Edit menu" ), this);
573 a->setStatusTip ( tr( "Add a branch below selection" ));
574 a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
575 a->setShortcutContext (Qt::WindowShortcut);
577 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
578 a->setEnabled (false);
579 actionListBranches.append(a);
580 actionEditAddBranchBelow=a;
581 a = new QAction(tr( "Add branch below","Edit menu" ), this);
582 a->setStatusTip ( tr( "Add a branch below selection" ));
583 a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below
584 a->setShortcutContext (Qt::WindowShortcut);
586 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
587 actionListBranches.append(a);
589 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
590 a->setStatusTip ( tr( "Move branch up" ) );
591 a->setShortcut (Qt::Key_PageUp ); // Move branch up
592 a->setEnabled (false);
594 editMenu->addAction (a);
595 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
598 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
599 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
600 a->setStatusTip (tr( "Move branch down" ) );
601 a->setShortcut ( Qt::Key_PageDown ); // Move branch down
602 a->setEnabled (false);
604 editMenu->addAction (a);
605 actionEditMoveDown=a;
607 a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this );
608 connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) );
609 a->setEnabled (true);
611 editMenu->addAction (a);
612 actionEditSortChildren=a;
614 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this);
615 a->setShortcut ( Qt::Key_ScrollLock );
616 a->setStatusTip (tr( "Scroll branch" ) );
617 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
619 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
620 alt->setShortcut ( Qt::Key_S ); // Scroll branch
621 alt->setStatusTip (tr( "Scroll branch" ));
622 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
623 #if defined(Q_OS_MACX)
624 actionEditToggleScroll=alt;
626 actionEditToggleScroll=a;
628 actionEditToggleScroll->setEnabled (false);
629 actionEditToggleScroll->setToggleAction(true);
630 tb->addAction (actionEditToggleScroll);
631 editMenu->addAction ( actionEditToggleScroll);
632 editMenu->addAction (actionEditToggleScroll);
635 actionListBranches.append(actionEditToggleScroll);
637 a = new QAction( tr( "Unscroll childs","Edit menu" ), this);
638 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
639 editMenu->addAction (a);
640 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChilds() ) );
642 editMenu->addSeparator();
644 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
645 a->setStatusTip (tr( "Find" ) );
646 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
647 editMenu->addAction (a);
648 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
650 editMenu->addSeparator();
652 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
653 a->setShortcut (Qt::CTRL + Qt::Key_U );
654 a->setShortcut (tr( "Open URL" ));
657 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
660 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
661 a->setStatusTip (tr( "Open URL in new tab" ));
662 //a->setShortcut (Qt::CTRL+Qt::Key_U );
664 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
665 actionEditOpenURLTab=a;
667 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
668 a->setStatusTip (tr( "Open all URLs in subtree" ));
670 actionListBranches.append(a);
671 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
672 actionEditOpenMultipleURLTabs=a;
674 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
675 a->setStatusTip ( tr( "Edit URL" ) );
676 a->setShortcut ( Qt::Key_U );
677 a->setShortcutContext (Qt::WindowShortcut);
678 actionListBranches.append(a);
680 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
683 a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
684 a->setStatusTip ( tr( "Edit local URL" ) );
685 a->setShortcut (Qt::SHIFT + Qt::Key_U );
686 a->setShortcutContext (Qt::WindowShortcut);
687 actionListBranches.append(a);
689 connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
690 actionEditLocalURL=a;
692 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
693 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
694 a->setEnabled (false);
695 actionListBranches.append(a);
696 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
697 actionEditHeading2URL=a;
699 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
700 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
701 a->setEnabled (false);
702 actionListBranches.append(a);
703 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
704 actionEditBugzilla2URL=a;
706 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
707 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
708 a->setEnabled (false);
709 actionListBranches.append(a);
710 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
711 actionEditFATE2URL=a;
713 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
714 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
716 a->setEnabled (false);
717 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
718 actionEditOpenVymLink=a;
720 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
721 a->setStatusTip ( tr( "Open all vym links in subtree" ));
722 a->setEnabled (false);
723 actionListBranches.append(a);
724 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
725 actionEditOpenMultipleVymLinks=a;
728 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
729 a->setEnabled (false);
730 a->setStatusTip ( tr( "Edit link to another vym map" ));
731 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
732 actionListBranches.append(a);
735 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
736 a->setStatusTip ( tr( "Delete link to another vym map" ));
737 a->setEnabled (false);
738 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
739 actionEditDeleteVymLink=a;
741 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
742 a->setStatusTip ( tr( "Hide object in exports" ) );
743 a->setShortcut (Qt::Key_H );
744 a->setToggleAction(true);
746 a->setEnabled (false);
747 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
748 actionEditToggleHideExport=a;
750 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
751 a->setStatusTip ( tr( "Edit Map Info" ));
752 a->setEnabled (true);
753 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
756 // Import at selection (adding to selection)
757 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
758 a->setStatusTip (tr( "Add map at selection" ));
759 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
760 a->setEnabled (false);
761 actionListBranches.append(a);
762 actionEditImportAdd=a;
764 // Import at selection (replacing selection)
765 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
766 a->setStatusTip (tr( "Replace selection with map" ));
767 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
768 a->setEnabled (false);
769 actionListBranches.append(a);
770 actionEditImportReplace=a;
773 a = new QAction( tr( "Save selection","Edit menu" ), this);
774 a->setStatusTip (tr( "Save selection" ));
775 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
776 a->setEnabled (false);
777 actionListBranches.append(a);
778 actionEditSaveBranch=a;
780 // Only remove branch, not its childs
781 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
782 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
783 a->setShortcut (Qt::ALT + Qt::Key_Delete );
784 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChilds() ) );
785 a->setEnabled (false);
787 actionListBranches.append(a);
788 actionEditDeleteKeepChilds=a;
790 // Only remove childs of a branch
791 a = new QAction( tr( "Remove childs","Edit menu" ), this);
792 a->setStatusTip (tr( "Remove childs of branch" ));
793 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
794 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChilds() ) );
795 a->setEnabled (false);
796 actionListBranches.append(a);
797 actionEditDeleteChilds=a;
799 // Shortcuts for navigating with cursor:
800 a = new QAction(tr( "Select upper branch","Edit menu" ), this);
801 a->setStatusTip ( tr( "Select upper branch" ));
802 a->setShortcut (Qt::Key_Up );
803 a->setShortcutContext (Qt::WindowShortcut);
805 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
806 a = new QAction( tr( "Select lower branch","Edit menu" ),this);
807 a->setStatusTip (tr( "Select lower branch" ));
808 a->setShortcut ( Qt::Key_Down );
809 a->setShortcutContext (Qt::WindowShortcut);
811 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
812 a = new QAction(tr( "Select left branch","Edit menu" ), this);
813 a->setStatusTip ( tr( "Select left branch" ));
814 a->setShortcut (Qt::Key_Left );
815 a->setShortcutContext (Qt::WindowShortcut);
817 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
818 a = new QAction( tr( "Select child branch","Edit menu" ), this);
819 a->setStatusTip (tr( "Select right branch" ));
820 a->setShortcut (Qt::Key_Right);
821 a->setShortcutContext (Qt::WindowShortcut);
823 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
824 a = new QAction( tr( "Select first branch","Edit menu" ), this);
825 a->setStatusTip (tr( "Select first branch" ));
826 a->setShortcut (Qt::Key_Home );
827 a->setShortcutContext (Qt::WindowShortcut);
829 a->setEnabled (false);
830 editMenu->addAction (a);
831 actionListBranches.append(a);
832 actionEditSelectFirst=a;
833 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
834 a = new QAction( tr( "Select last branch","Edit menu" ),this);
835 a->setStatusTip (tr( "Select last branch" ));
836 a->setShortcut ( Qt::Key_End );
837 a->setShortcutContext (Qt::WindowShortcut);
839 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
840 a->setEnabled (false);
841 editMenu->addAction (a);
842 actionListBranches.append(a);
843 actionEditSelectLast=a;
845 a = new QAction( tr( "Add Image...","Edit menu" ), this);
846 a->setStatusTip (tr( "Add Image" ));
847 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
848 actionEditLoadImage=a;
850 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
851 a->setStatusTip (tr( "Set properties for selection" ));
852 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
853 a->setShortcutContext (Qt::WindowShortcut);
854 a->setToggleAction (true);
856 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
857 actionViewTogglePropertyWindow=a;
861 void Main::setupFormatActions()
863 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
865 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
866 tb->setObjectName ("formatTB");
869 pix.fill (Qt::black);
870 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
871 a->setStatusTip ( tr( "Set Color" ));
872 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
874 formatMenu->addAction (a);
876 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
877 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
878 a->setShortcut (Qt::CTRL + Qt::Key_K );
879 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
880 a->setEnabled (false);
882 formatMenu->addAction (a);
883 actionListBranches.append(a);
884 actionFormatPickColor=a;
886 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
887 a->setStatusTip ( tr( "Color branch" ) );
888 a->setShortcut (Qt::CTRL + Qt::Key_B);
889 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
890 a->setEnabled (false);
892 formatMenu->addAction (a);
893 actionListBranches.append(a);
894 actionFormatColorSubtree=a;
896 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
897 a->setStatusTip ( tr( "Color Subtree" ));
898 a->setShortcut (Qt::CTRL + Qt::Key_T);
899 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
900 a->setEnabled (false);
901 formatMenu->addAction (a);
903 actionListBranches.append(a);
904 actionFormatColorSubtree=a;
906 formatMenu->addSeparator();
907 actionGroupFormatLinkStyles=new QActionGroup ( this);
908 actionGroupFormatLinkStyles->setExclusive (true);
909 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
910 a->setStatusTip (tr( "Line" ));
911 a->setToggleAction(true);
912 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
913 formatMenu->addAction (a);
914 actionFormatLinkStyleLine=a;
915 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
916 a->setStatusTip (tr( "Line" ));
917 a->setToggleAction(true);
918 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
919 formatMenu->addAction (a);
920 actionFormatLinkStyleParabel=a;
921 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
922 a->setStatusTip (tr( "PolyLine" ));
923 a->setToggleAction(true);
924 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
925 formatMenu->addAction (a);
926 actionFormatLinkStylePolyLine=a;
927 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
928 a->setStatusTip (tr( "PolyParabel" ) );
929 a->setToggleAction(true);
930 a->setChecked (true);
931 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
932 formatMenu->addAction (a);
933 actionFormatLinkStylePolyParabel=a;
935 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
936 a->setStatusTip (tr( "Hide link" ));
937 a->setToggleAction(true);
938 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
939 actionFormatHideLinkUnselected=a;
941 formatMenu->addSeparator();
942 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
943 a->setStatusTip (tr( "Use same color for links and headings" ));
944 a->setToggleAction(true);
945 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
946 formatMenu->addAction (a);
947 actionFormatLinkColorHint=a;
949 pix.fill (Qt::white);
950 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
951 a->setStatusTip (tr( "Set Link Color" ));
952 formatMenu->addAction (a);
953 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
954 actionFormatLinkColor=a;
956 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
957 a->setStatusTip (tr( "Set Selection Color" ));
958 formatMenu->addAction (a);
959 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
960 actionFormatSelectionColor=a;
962 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
963 a->setStatusTip (tr( "Set Background Color" ));
964 formatMenu->addAction (a);
965 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
966 actionFormatBackColor=a;
968 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
969 a->setStatusTip (tr( "Set Background image" ));
970 formatMenu->addAction (a);
971 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
972 actionFormatBackImage=a;
976 void Main::setupViewActions()
978 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
979 tb->setLabel( "View Actions" );
980 tb->setObjectName ("viewTB");
981 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
984 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
985 a->setStatusTip ( tr( "Zoom reset" ) );
986 a->setShortcut (Qt::CTRL + Qt::Key_0 );
988 viewMenu->addAction (a);
989 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
991 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
992 a->setStatusTip (tr( "Zoom in" ));
993 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
995 viewMenu->addAction (a);
996 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
998 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
999 a->setStatusTip (tr( "Zoom out" ));
1000 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
1002 viewMenu->addAction (a);
1003 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1005 a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
1006 a->setStatusTip (tr( "Show selection" ));
1007 a->setShortcut (Qt::Key_Period);
1009 viewMenu->addAction (a);
1010 connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
1012 viewMenu->addSeparator();
1014 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
1015 a->setStatusTip ( tr( "Show Note Editor" ));
1016 a->setShortcut ( Qt::CTRL + Qt::Key_E );
1017 a->setToggleAction(true);
1019 viewMenu->addAction (a);
1020 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1021 actionViewToggleNoteEditor=a;
1023 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
1024 a->setStatusTip ( tr( "Show History Window" ));
1025 a->setShortcut ( Qt::CTRL + Qt::Key_H );
1026 a->setToggleAction(true);
1028 viewMenu->addAction (a);
1029 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1030 actionViewToggleHistoryWindow=a;
1032 viewMenu->addAction (actionViewTogglePropertyWindow);
1034 viewMenu->addSeparator();
1036 a = new QAction(tr( "Antialiasing","View action" ),this );
1037 a->setStatusTip ( tr( "Antialiasing" ));
1038 a->setToggleAction(true);
1039 a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
1040 viewMenu->addAction (a);
1041 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
1042 actionViewToggleAntiAlias=a;
1044 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1045 a->setStatusTip (a->text());
1046 a->setToggleAction(true);
1047 a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1048 viewMenu->addAction (a);
1049 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1050 actionViewToggleSmoothPixmapTransform=a;
1052 a = new QAction(tr( "Next Map","View action" ), this);
1053 a->setStatusTip (a->text());
1054 a->setShortcut (Qt::ALT + Qt::Key_N );
1055 viewMenu->addAction (a);
1056 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1058 a = new QAction (tr( "Previous Map","View action" ), this );
1059 a->setStatusTip (a->text());
1060 a->setShortcut (Qt::ALT + Qt::Key_P );
1061 viewMenu->addAction (a);
1062 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1066 void Main::setupModeActions()
1068 //QPopupMenu *menu = new QPopupMenu( this );
1069 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1071 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1072 tb->setObjectName ("modesTB");
1074 actionGroupModModes=new QActionGroup ( this);
1075 actionGroupModModes->setExclusive (true);
1076 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1077 a->setShortcut (Qt::Key_J);
1078 a->setStatusTip ( tr( "Use modifier to color branches" ));
1079 a->setToggleAction(true);
1082 actionModModeColor=a;
1084 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1085 a->setShortcut( Qt::Key_K);
1086 a->setStatusTip( tr( "Use modifier to copy" ));
1087 a->setToggleAction(true);
1089 actionModModeCopy=a;
1091 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1092 a->setShortcut (Qt::Key_L);
1093 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1094 a->setToggleAction(true);
1096 actionModModeXLink=a;
1100 void Main::setupFlagActions()
1102 // Create System Flags
1106 systemFlagsDefault = new FlagRowObj ();
1107 systemFlagsDefault->setVisibility (false);
1108 systemFlagsDefault->setName ("systemFlagsDef");
1110 FlagObj *fo = new FlagObj ();
1111 fo->load(QPixmap(flagsPath+"flag-note.png"));
1112 setupFlag (fo,tb,avis,"note",tr("Note","SystemFlag"));
1114 fo->load(QPixmap(flagsPath+"flag-url.png"));
1115 setupFlag (fo,tb,avis,"url",tr("URL to Document ","SystemFlag"));
1117 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1118 setupFlag (fo,tb,avis,"vymLink",tr("Link to another vym map","SystemFlag"));
1120 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1121 setupFlag (fo,tb,avis,"scrolledright",tr("subtree is scrolled","SystemFlag"));
1123 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1124 setupFlag (fo,tb,avis,"tmpUnscrolledright",tr("subtree is temporary scrolled","SystemFlag"));
1126 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1127 setupFlag (fo,tb,avis,"hideInExport",tr("Hide object in exported maps","SystemFlag"));
1129 // Create Standard Flags
1130 tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1131 tb->setObjectName ("standardFlagTB");
1133 standardFlagsDefault = new FlagRowObj ();
1134 standardFlagsDefault->setVisibility (false);
1135 standardFlagsDefault->setName ("standardFlagsDef");
1136 standardFlagsDefault->setToolBar (tb);
1138 fo->load(flagsPath+"flag-exclamationmark.png");
1139 fo->setGroup("standard-mark");
1140 setupFlag (fo,tb,avis,"exclamationmark",tr("Take care!","Standardflag"));
1142 fo->load(flagsPath+"flag-questionmark.png");
1143 fo->setGroup("standard-mark");
1144 setupFlag (fo,tb,avis,"questionmark",tr("Really?","Standardflag"));
1146 fo->load(flagsPath+"flag-hook-green.png");
1147 fo->setGroup("standard-hook");
1148 setupFlag (fo,tb,avis,"hook-green",tr("ok!","Standardflag"));
1150 fo->load(flagsPath+"flag-cross-red.png");
1151 fo->setGroup("standard-hook");
1152 setupFlag (fo,tb,avis,"cross-red",tr("Not ok!","Standardflag"));
1155 fo->load(flagsPath+"flag-stopsign.png");
1156 setupFlag (fo,tb,avis,"stopsign",tr("This won't work!","Standardflag"));
1158 fo->load(flagsPath+"flag-smiley-good.png");
1159 fo->setGroup("standard-smiley");
1160 setupFlag (fo,tb,avis,"smiley-good",tr("Good","Standardflag"));
1162 fo->load(flagsPath+"flag-smiley-sad.png");
1163 fo->setGroup("standard-smiley");
1164 setupFlag (fo,tb,avis,"smiley-sad",tr("Bad","Standardflag"));
1166 fo->load(flagsPath+"flag-smiley-omg.png");
1167 fo->setGroup("standard-smiley");
1168 setupFlag (fo,tb,avis,"smiley-omb",tr("Oh no!","Standardflag"));
1169 // Original omg.png (in KDE emoticons)
1172 fo->load(flagsPath+"flag-kalarm.png");
1173 setupFlag (fo,tb,avis,"clock",tr("Time critical","Standardflag"));
1175 fo->load(flagsPath+"flag-phone.png");
1176 setupFlag (fo,tb,avis,"phone",tr("Call...","Standardflag"));
1178 fo->load(flagsPath+"flag-lamp.png");
1179 setupFlag (fo,tb,avis,"lamp",tr("Idea!","Standardflag"));
1181 fo->load(flagsPath+"flag-arrow-up.png");
1182 fo->setGroup("standard-arrow");
1183 setupFlag (fo,tb,avis,"arrow-up",tr("Important","Standardflag"));
1185 fo->load(flagsPath+"flag-arrow-down.png");
1186 fo->setGroup("standard-arrow");
1187 setupFlag (fo,tb,avis,"arrow-down",tr("Unimportant","Standardflag"));
1189 fo->load(flagsPath+"flag-arrow-2up.png");
1190 fo->setGroup("standard-arrow");
1191 setupFlag (fo,tb,avis,"2arrow-up",tr("Very important!","Standardflag"));
1193 fo->load(flagsPath+"flag-arrow-2down.png");
1194 fo->setGroup("standard-arrow");
1195 setupFlag (fo,tb,avis,"2arrow-down",tr("Very unimportant!","Standardflag"));
1198 fo->load(flagsPath+"flag-thumb-up.png");
1199 fo->setGroup("standard-thumb");
1200 setupFlag (fo,tb,avis,"thumb-up",tr("I like this","Standardflag"));
1202 fo->load(flagsPath+"flag-thumb-down.png");
1203 fo->setGroup("standard-thumb");
1204 setupFlag (fo,tb,avis,"thumb-down",tr("I do not like this","Standardflag"));
1207 fo->load(flagsPath+"flag-rose.png");
1208 setupFlag (fo,tb,avis,"rose",tr("Rose","Standardflag"));
1210 fo->load(flagsPath+"flag-heart.png");
1211 setupFlag (fo,tb,avis,"heart",tr("I just love...","Standardflag"));
1213 fo->load(flagsPath+"flag-present.png");
1214 setupFlag (fo,tb,avis,"present",tr("Surprise!","Standardflag"));
1216 fo->load(flagsPath+"flag-flash.png");
1217 setupFlag (fo,tb,avis,"flash",tr("Dangerous","Standardflag"));
1219 // Original: xsldbg_output.png
1220 fo->load(flagsPath+"flag-info.png");
1221 setupFlag (fo,tb,avis,"info",tr("Info","Standardflag"));
1223 // Original khelpcenter.png
1224 fo->load(flagsPath+"flag-lifebelt.png");
1225 setupFlag (fo,tb,avis,"lifebelt",tr("This will help","Standardflag"));
1231 fo->load(flagsPath+"freemind/warning.png");
1232 setupFlag (fo,tb, avis, "freemind-warning",tr("Important","Freemind-Flag"));
1234 for (int i=1; i<8; i++)
1236 fo->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
1237 setupFlag (fo,tb, avis,QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
1240 fo->load(flagsPath+"freemind/back.png");
1241 setupFlag (fo,tb,avis,"freemind-back",tr("Back","Freemind-Flag"));
1243 fo->load(flagsPath+"freemind/forward.png");
1244 setupFlag (fo,tb,avis,"freemind-forward",tr("Forward","Freemind-Flag"));
1246 fo->load(flagsPath+"freemind/attach.png");
1247 setupFlag (fo,tb,avis,"freemind-attach",tr("Look here","Freemind-Flag"));
1249 fo->load(flagsPath+"freemind/clanbomber.png");
1250 setupFlag (fo,tb,avis,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
1252 fo->load(flagsPath+"freemind/desktopnew.png");
1253 setupFlag (fo,tb,avis,"freemind-desktopnew",tr("Don't forget","Freemind-Flag"));
1255 fo->load(flagsPath+"freemind/flag.png");
1256 setupFlag (fo,tb,avis,"freemind-flag",tr("Flag","Freemind-Flag"));
1259 fo->load(flagsPath+"freemind/gohome.png");
1260 setupFlag (fo,tb,avis,"freemind-gohome",tr("Home","Freemind-Flag"));
1263 fo->load(flagsPath+"freemind/kaddressbook.png");
1264 setupFlag (fo,tb,avis,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
1266 fo->load(flagsPath+"freemind/knotify.png");
1267 setupFlag (fo,tb,avis,"freemind-knotify",tr("Music","Freemind-Flag"));
1269 fo->load(flagsPath+"freemind/korn.png");
1270 setupFlag (fo,tb,avis,"freemind-korn",tr("Mailbox","Freemind-Flag"));
1272 fo->load(flagsPath+"freemind/mail.png");
1273 setupFlag (fo,tb,avis,"freemind-mail",tr("Maix","Freemind-Flag"));
1275 fo->load(flagsPath+"freemind/password.png");
1276 setupFlag (fo,tb,avis,"freemind-password",tr("Password","Freemind-Flag"));
1278 fo->load(flagsPath+"freemind/pencil.png");
1279 setupFlag (fo,tb,avis,"freemind-pencil",tr("To be improved","Freemind-Flag"));
1281 fo->load(flagsPath+"freemind/stop.png");
1282 setupFlag (fo,tb,avis,"freemind-stop",tr("Stop","Freemind-Flag"));
1284 fo->load(flagsPath+"freemind/wizard.png");
1285 setupFlag (fo,tb,avis,"freemind-wizard",tr("Magic","Freemind-Flag"));
1287 fo->load(flagsPath+"freemind/xmag.png");
1288 setupFlag (fo,tb,avis,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
1290 fo->load(flagsPath+"freemind/bell.png");
1291 setupFlag (fo,tb,avis,"freemind-bell",tr("Reminder","Freemind-Flag"));
1293 fo->load(flagsPath+"freemind/bookmark.png");
1294 setupFlag (fo,tb,avis,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
1296 fo->load(flagsPath+"freemind/penguin.png");
1297 setupFlag (fo,tb,avis,"freemind-penguin",tr("Linux","Freemind-Flag"));
1299 fo->load(flagsPath+"freemind/licq.png");
1300 setupFlag (fo,tb,avis,"freemind-licq",tr("Sweet","Freemind-Flag"));
1305 void Main::setupFlag (FlagObj *fo, QToolBar *tb, bool aw, const QString &name, const QString &tooltip)
1308 fo->setToolTip (tooltip);
1309 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1315 fo->setAlwaysVisible(aw);
1316 a->setCheckable(true);
1317 a->setObjectName(fo->getName());
1318 a->setToolTip(tooltip);
1319 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1320 standardFlagsDefault->addFlag (fo);
1324 systemFlagsDefault->addFlag (fo);
1328 void Main::setupNetworkActions()
1330 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1332 QMenu *netMenu = menuBar()->addMenu( "&Network" );
1336 a = new QAction( "Start TCPserver for MapEditor",this);
1337 //a->setStatusTip ( "Set application to open pdf files"));
1338 a->setShortcut ( Qt::Key_T ); //New TCP server
1339 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1340 netMenu->addAction (a);
1342 a = new QAction( "Connect MapEditor to server",this);
1343 //a->setStatusTip ( "Set application to open pdf files"));
1344 a->setShortcut ( Qt::Key_C ); // Connect to server
1345 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1346 netMenu->addAction (a);
1350 void Main::setupSettingsActions()
1352 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1356 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1357 a->setStatusTip ( tr( "Set application to open pdf files"));
1358 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1359 settingsMenu->addAction (a);
1361 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1362 a->setStatusTip( tr( "Set application to open external links"));
1363 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1364 settingsMenu->addAction (a);
1366 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1367 a->setStatusTip( tr( "Set path for macros"));
1368 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1369 settingsMenu->addAction (a);
1371 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1372 a->setStatusTip( tr( "Set number of undo levels"));
1373 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1374 settingsMenu->addAction (a);
1376 settingsMenu->addSeparator();
1378 a = new QAction( tr( "Autosave","Settings action"), this);
1379 a->setStatusTip( tr( "Autosave"));
1380 a->setToggleAction(true);
1381 a->setOn ( settings.value ("/mapeditor/autosave/use",true).toBool());
1382 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1383 settingsMenu->addAction (a);
1384 actionSettingsAutosaveToggle=a;
1386 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1387 a->setStatusTip( tr( "Autosave time"));
1388 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1389 settingsMenu->addAction (a);
1390 actionSettingsAutosaveTime=a;
1392 settingsMenu->addSeparator();
1394 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1395 a->setStatusTip( tr( "Edit branch after adding it" ));
1396 a->setToggleAction(true);
1397 a->setOn ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1398 settingsMenu->addAction (a);
1399 actionSettingsAutoEditNewBranch=a;
1401 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1402 a->setStatusTip( tr( "Select branch after adding it" ));
1403 a->setToggleAction(true);
1404 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1405 settingsMenu->addAction (a);
1406 actionSettingsAutoSelectNewBranch=a;
1408 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1409 a->setStatusTip( tr( "Select heading before editing" ));
1410 a->setToggleAction(true);
1411 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1412 settingsMenu->addAction (a);
1413 actionSettingsAutoSelectText=a;
1415 a= new QAction( tr( "Delete key","Settings action" ), this);
1416 a->setStatusTip( tr( "Delete key for deleting branches" ));
1417 a->setToggleAction(true);
1418 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1419 settingsMenu->addAction (a);
1420 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1421 actionSettingsUseDelKey=a;
1423 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1424 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1425 a->setToggleAction(true);
1426 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1427 settingsMenu->addAction (a);
1428 actionSettingsUseFlagGroups=a;
1430 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1431 a->setStatusTip( tr( "Use hide flag during exports " ));
1432 a->setToggleAction(true);
1433 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1434 settingsMenu->addAction (a);
1435 actionSettingsUseHideExport=a;
1439 void Main::setupTestActions()
1441 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1444 a = new QAction( "Test function 1" , this);
1445 a->setStatusTip( "Call test function 1" );
1446 testMenu->addAction (a);
1447 //a->setShortcut (Qt::Key_F4 );
1448 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1450 a = new QAction( "Test function 2" , this);
1451 a->setStatusTip( "Call test function 2" );
1452 //a->setShortcut (Qt::Key_F4 );
1453 testMenu->addAction (a);
1454 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1456 a = new QAction( "Command" , this);
1457 a->setStatusTip( "Enter command to call in editor" );
1458 //a->setShortcut (Qt::Key_F5 );
1459 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1460 testMenu->addAction (a);
1464 void Main::setupHelpActions()
1466 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1469 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1470 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1471 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1472 helpMenu->addAction (a);
1474 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1475 a->setStatusTip( tr( "Open VYM example maps " ));
1476 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1477 helpMenu->addAction (a);
1479 a = new QAction( tr( "About VYM","Help action" ), this);
1480 a->setStatusTip( tr( "About VYM")+vymName);
1481 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1482 helpMenu->addAction (a);
1484 a = new QAction( tr( "About QT","Help action" ), this);
1485 a->setStatusTip( tr( "Information about QT toolkit" ));
1486 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1487 helpMenu->addAction (a);
1491 void Main::setupContextMenus()
1495 // Context Menu for branch or mapcenter
1496 branchContextMenu =new QMenu (this);
1497 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1498 branchContextMenu->addSeparator();
1501 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1502 branchAddContextMenu->addAction (actionEditPaste );
1503 branchAddContextMenu->addAction ( actionEditAddBranch );
1504 branchAddContextMenu->addAction ( actionEditAddBranchBefore );
1505 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1506 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1507 branchAddContextMenu->addSeparator();
1508 branchAddContextMenu->addAction ( actionEditImportAdd );
1509 branchAddContextMenu->addAction ( actionEditImportReplace );
1512 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1513 branchRemoveContextMenu->addAction (actionEditCut);
1514 branchRemoveContextMenu->addAction ( actionEditDelete );
1515 branchRemoveContextMenu->addAction ( actionEditDeleteKeepChilds );
1516 branchRemoveContextMenu->addAction ( actionEditDeleteChilds );
1519 actionEditSaveBranch->addTo( branchContextMenu );
1521 branchContextMenu->addSeparator();
1522 branchContextMenu->addAction ( actionEditLoadImage);
1524 // Submenu for Links (URLs, vymLinks)
1525 branchLinksContextMenu =new QMenu (this);
1527 branchContextMenu->addSeparator();
1528 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1529 branchLinksContextMenu->addAction ( actionEditOpenURL );
1530 branchLinksContextMenu->addAction ( actionEditOpenURLTab );
1531 branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
1532 branchLinksContextMenu->addAction ( actionEditURL );
1533 branchLinksContextMenu->addAction ( actionEditLocalURL );
1534 branchLinksContextMenu->addAction ( actionEditHeading2URL );
1535 branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
1536 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1538 branchLinksContextMenu->addAction ( actionEditFATE2URL );
1540 branchLinksContextMenu->addSeparator();
1541 branchLinksContextMenu->addAction ( actionEditOpenVymLink );
1542 branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
1543 branchLinksContextMenu->addAction ( actionEditVymLink );
1544 branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
1547 // Context Menu for XLinks in a branch menu
1548 // This will be populated "on demand" in MapEditor::updateActions
1549 branchContextMenu->addSeparator();
1550 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1551 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1552 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1553 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1556 // Context menu for floatimage
1557 floatimageContextMenu =new QMenu (this);
1558 a= new QAction (tr ("Save image","Context action"),this);
1559 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1560 floatimageContextMenu->addAction (a);
1562 floatimageContextMenu->addSeparator();
1563 actionEditCopy->addTo( floatimageContextMenu );
1564 actionEditCut->addTo( floatimageContextMenu );
1566 floatimageContextMenu->addSeparator();
1567 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1570 // Context menu for canvas
1571 canvasContextMenu =new QMenu (this);
1572 actionEditMapInfo->addTo( canvasContextMenu );
1573 canvasContextMenu->insertSeparator();
1574 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1575 canvasContextMenu->insertSeparator();
1576 actionFormatLinkColorHint->addTo( canvasContextMenu );
1577 actionFormatLinkColor->addTo( canvasContextMenu );
1578 actionFormatSelectionColor->addTo( canvasContextMenu );
1579 actionFormatBackColor->addTo( canvasContextMenu );
1580 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME makes vym too slow: postponed for later version
1582 // Menu for last opened files
1584 for (int i = 0; i < MaxRecentFiles; ++i)
1586 recentFileActions[i] = new QAction(this);
1587 recentFileActions[i]->setVisible(false);
1588 fileLastMapsMenu->addAction(recentFileActions[i]);
1589 connect(recentFileActions[i], SIGNAL(triggered()),
1590 this, SLOT(fileLoadRecent()));
1592 setupRecentMapsMenu();
1595 void Main::setupRecentMapsMenu()
1597 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1599 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1601 for (int i = 0; i < numRecentFiles; ++i) {
1602 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1603 recentFileActions[i]->setText(text);
1604 recentFileActions[i]->setData(files[i]);
1605 recentFileActions[i]->setVisible(true);
1607 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1608 recentFileActions[j]->setVisible(false);
1611 void Main::setupMacros()
1613 for (int i = 0; i <= 11; i++)
1615 macroActions[i] = new QAction(this);
1616 macroActions[i]->setData(i);
1617 addAction (macroActions[i]);
1618 connect(macroActions[i], SIGNAL(triggered()),
1619 this, SLOT(callMacro()));
1621 macroActions[0]->setShortcut ( Qt::Key_F1 );
1622 macroActions[1]->setShortcut ( Qt::Key_F2 );
1623 macroActions[2]->setShortcut ( Qt::Key_F3 );
1624 macroActions[3]->setShortcut ( Qt::Key_F4 );
1625 macroActions[4]->setShortcut ( Qt::Key_F5 );
1626 macroActions[5]->setShortcut ( Qt::Key_F6 );
1627 macroActions[6]->setShortcut ( Qt::Key_F7 );
1628 macroActions[7]->setShortcut ( Qt::Key_F8 );
1629 macroActions[8]->setShortcut ( Qt::Key_F9 );
1630 macroActions[9]->setShortcut ( Qt::Key_F10 );
1631 macroActions[10]->setShortcut ( Qt::Key_F11 );
1632 macroActions[11]->setShortcut ( Qt::Key_F12 );
1635 void Main::hideEvent (QHideEvent * )
1637 if (!textEditor->isMinimized() ) textEditor->hide();
1640 void Main::showEvent (QShowEvent * )
1642 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1646 MapEditor* Main::currentMapEditor() const
1648 if ( tabWidget->currentPage() &&
1649 tabWidget->currentPage()->inherits( "MapEditor" ) )
1650 return (MapEditor*)tabWidget->currentPage();
1655 void Main::editorChanged(QWidget *)
1657 // Unselect all possibly selected objects
1658 // (Important to update note editor)
1660 for (int i=0;i<=tabWidget->count() -1;i++)
1663 me=(MapEditor*)tabWidget->page(i);
1666 currentMapEditor()->reselect();
1668 // Update actions to in menus and toolbars according to editor
1672 void Main::fileNew()
1674 QString fn="unnamed";
1675 MapEditor* me = new MapEditor ( NULL);
1676 tabWidget->addTab (me,fn);
1677 tabWidget->showPage(me);
1678 me->viewport()->setFocus();
1679 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1680 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1682 // For the very first map we do not have flagrows yet...
1686 void Main::fileNewCopy()
1688 QString fn="unnamed";
1689 MapEditor* oldME =currentMapEditor();
1693 MapEditor* newME = new MapEditor ( NULL);
1696 tabWidget->addTab (newME,fn);
1697 tabWidget->showPage(newME);
1698 newME->viewport()->setFocus();
1699 newME->setAntiAlias (actionViewToggleAntiAlias->isOn());
1700 newME->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1701 // For the very first map we do not have flagrows yet...
1702 newME->select("mc:");
1703 newME->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
1709 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
1711 ErrorCode err=success;
1713 // fn is usually the archive, mapfile the file after uncompressing
1716 // Make fn absolute (needed for unzip)
1717 fn=QDir (fn).absPath();
1723 // Check, if map is already loaded
1725 while (i<=tabWidget->count() -1)
1727 me=(MapEditor*)tabWidget->page(i);
1728 if (me->getFilePath() == fn)
1730 // Already there, ask for confirmation
1731 QMessageBox mb( vymName,
1732 tr("The map %1\nis already opened."
1733 "Opening the same map in multiple editors may lead \n"
1734 "to confusion when finishing working with vym."
1735 "Do you want to").arg(fn),
1736 QMessageBox::Warning,
1737 QMessageBox::Yes | QMessageBox::Default,
1738 QMessageBox::Cancel | QMessageBox::Escape,
1739 QMessageBox::NoButton);
1740 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1741 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1744 case QMessageBox::Yes:
1746 i=tabWidget->count();
1748 case QMessageBox::Cancel:
1760 if ( !fn.isEmpty() )
1762 me = currentMapEditor();
1763 int tabIndex=tabWidget->currentPageIndex();
1764 // Check first, if mapeditor exists
1765 // If it is not default AND we want a new map,
1766 // create a new mapeditor in a new tab
1767 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1769 me= new MapEditor ( NULL);
1770 tabWidget->addTab (me,fn);
1771 tabIndex=tabWidget->indexOf (me);
1772 tabWidget->setCurrentPage (tabIndex);
1773 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1774 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1777 // Check, if file exists (important for creating new files
1778 // from command line
1779 if (!QFile(fn).exists() )
1781 QMessageBox mb( vymName,
1782 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1783 QMessageBox::Question,
1785 QMessageBox::Cancel | QMessageBox::Default,
1786 QMessageBox::NoButton );
1788 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1789 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1792 case QMessageBox::Yes:
1794 currentMapEditor()->setFilePath(fn);
1795 tabWidget->setTabLabel (currentMapEditor(),
1796 currentMapEditor()->getFileName() );
1797 statusBar()->message( "Created " + fn , statusbarTime );
1800 case QMessageBox::Cancel:
1801 // don't create new map
1802 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1809 //tabWidget->currentPage() won't be NULL here, because of above...
1810 tabWidget->showPage(me);
1811 me->viewport()->setFocus();
1813 // Create temporary directory for packing
1815 QString tmpMapDir=makeTmpDir (ok,"vym-pack");
1818 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1819 tr("Couldn't create temporary directory before load\n"));
1823 // Try to unzip file
1824 err=unzipDir (tmpMapDir,fn);
1828 me->setZipped(false);
1831 me->setZipped(true);
1833 // Look for mapname.xml
1834 mapfile= fn.left(fn.findRev(".",-1,true));
1835 mapfile=mapfile.section( '/', -1 );
1836 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1837 if (!file.exists() )
1839 // mapname.xml does not exist, well,
1840 // maybe someone renamed the mapname.vym file...
1841 // Try to find any .xml in the toplevel
1842 // directory of the .vym file
1843 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1844 if (flist.count()==1)
1846 // Only one entry, take this one
1847 mapfile=tmpMapDir + "/"+flist.first();
1850 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1851 *it=tmpMapDir + "/" + *it;
1852 // TODO Multiple entries, load all (but only the first one into this ME)
1853 //mainWindow->fileLoadFromTmp (flist);
1854 //returnCode=1; // Silently forget this attempt to load
1855 qWarning ("MainWindow::load (fn) multimap found...");
1858 if (flist.isEmpty() )
1860 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1861 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1864 } //file doesn't exist
1866 mapfile=file.name();
1871 // Save existing filename in case we import
1872 QString fn_org=me->getFilePath();
1874 // Finally load map into mapEditor
1875 me->setFilePath (mapfile,fn);
1876 err=me->load(mapfile,lmode,ftype);
1878 // Restore old (maybe empty) filepath, if this is an import
1880 me->setFilePath (fn_org);
1883 // Finally check for errors and go home
1886 if (lmode==NewMap) fileCloseMap();
1887 statusBar()->message( "Could not load " + fn, statusbarTime );
1892 me->setFilePath (fn);
1893 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1894 if (!isInTmpDir (fn))
1896 // Only append to lastMaps if not loaded from a tmpDir
1897 // e.g. imported bookmarks are in a tmpDir
1898 addRecentMap(me->getFilePath() );
1900 actionFilePrint->setEnabled (true);
1902 statusBar()->message( "Loaded " + fn, statusbarTime );
1906 removeDir (QDir(tmpMapDir));
1912 void Main::fileLoad(const LoadMode &lmode)
1914 QStringList filters;
1915 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1916 QFileDialog *fd=new QFileDialog( this);
1917 fd->setDir (lastFileDir);
1918 fd->setFileMode (QFileDialog::ExistingFiles);
1919 fd->setFilters (filters);
1923 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1926 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1929 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1935 if ( fd->exec() == QDialog::Accepted )
1937 lastFileDir=fd->directory().path();
1938 QStringList flist = fd->selectedFiles();
1939 QStringList::Iterator it = flist.begin();
1940 while( it != flist.end() )
1943 fileLoad(*it, lmode);
1950 void Main::fileLoad()
1955 void Main::fileLoadRecent()
1957 QAction *action = qobject_cast<QAction *>(sender());
1959 fileLoad (action->data().toString(), NewMap);
1962 void Main::addRecentMap (const QString &fileName)
1965 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1966 files.removeAll(fileName);
1967 files.prepend(fileName);
1968 while (files.size() > MaxRecentFiles)
1971 settings.setValue("/mainwindow/recentFileList", files);
1973 setupRecentMapsMenu();
1976 void Main::fileSave(MapEditor *me, const SaveMode &savemode)
1978 // tmp dir for zipping
1982 ErrorCode err=success;
1984 QString safeFilePath;
1986 bool saveZipped=me->saveZipped();
1990 QString fn=me->getFilePath();
1991 // filename=unnamed, filepath="" in constructor of mapEditor
1992 if ( !fn.isEmpty() )
1994 // We have a filepath, go on saving
1995 // First remove existing file, we
1996 // don't want to add to old zip archives
2000 QMessageBox::warning( 0, tr( "Save Error" ),
2001 fn+ tr("\ncould not be removed before saving"));
2003 // Look, if we should zip the data:
2006 QMessageBox mb( vymName,
2007 tr("The map %1\ndid not use the compressed "
2008 "vym file format.\nWriting it uncompressed will also write images \n"
2009 "and flags and thus may overwrite files in the "
2010 "given directory\n\nDo you want to write the map").arg(fn),
2011 QMessageBox::Warning,
2012 QMessageBox::Yes | QMessageBox::Default,
2014 QMessageBox::Cancel | QMessageBox::Escape);
2015 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
2016 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
2017 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2020 case QMessageBox::Yes:
2021 // save compressed (default file format)
2024 case QMessageBox::No:
2025 // save uncompressed
2028 case QMessageBox::Cancel:
2033 me->setZipped (saveZipped);
2038 // Create temporary directory for packing
2040 QString tmpMapDir=makeTmpDir (ok,"vym-zip");
2043 QMessageBox::critical( 0, tr( "Critical Load Error" ),
2044 tr("Couldn't create temporary directory before save\n"));
2048 safeFilePath=me->getFilePath();
2049 me->setFilePath (tmpMapDir+"/"+
2050 me->getMapName()+ ".xml",
2052 me->save (savemode);
2053 me->setFilePath (safeFilePath);
2055 zipDir (tmpMapDir,fn);
2060 safeFilePath=me->getFilePath();
2061 me->setFilePath (fn, safeFilePath);
2062 me->save (savemode);
2063 me->setFilePath (safeFilePath);
2065 } // filepath available
2068 // We have no filepath yet,
2069 // call fileSaveAs() now, this will call fileSave()
2071 // First switch to editor
2072 tabWidget->setCurrentWidget (me);
2073 fileSaveAs(savemode);
2077 if (saveZipped && !tmpMapDir.isEmpty())
2079 removeDir (QDir(tmpMapDir));
2083 statusBar()->message(
2084 tr("Saved %1").arg(me->getFilePath()),
2086 addRecentMap (me->getFilePath() );
2088 statusBar()->message(
2089 tr("Couldn't save ").arg(me->getFilePath()),
2093 void Main::fileSave()
2095 fileSave (currentMapEditor(), CompleteMap);
2098 void Main::fileSave(MapEditor *me)
2100 fileSave (me,CompleteMap);
2103 void Main::fileSaveAs(const SaveMode& savemode)
2107 if (currentMapEditor())
2109 if (savemode==CompleteMap)
2110 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2112 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2113 if ( !fn.isEmpty() )
2115 // Check for existing file
2116 if (QFile (fn).exists())
2118 QMessageBox mb( vymName,
2119 tr("The file %1\nexists already. Do you want to").arg(fn),
2120 QMessageBox::Warning,
2121 QMessageBox::Yes | QMessageBox::Default,
2122 QMessageBox::Cancel | QMessageBox::Escape,
2123 QMessageBox::NoButton);
2124 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2125 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2128 case QMessageBox::Yes:
2131 case QMessageBox::Cancel:
2138 // New file, add extension to filename, if missing
2139 // This is always .vym or .vyp, depending on savemode
2140 if (savemode==CompleteMap)
2142 if (!fn.contains (".vym") && !fn.contains (".xml"))
2146 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2155 currentMapEditor()->setFilePath(fn);
2156 fileSave(currentMapEditor(), savemode);
2159 if (savemode==CompleteMap)
2160 tabWidget->setTabLabel (currentMapEditor(),
2161 currentMapEditor()->getFileName() );
2167 void Main::fileSaveAs()
2169 fileSaveAs (CompleteMap);
2172 void Main::fileImportKDEBookmarks()
2174 ImportKDEBookmarks im;
2176 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2177 currentMapEditor()->setFilePath ("");
2180 void Main::fileImportFirefoxBookmarks()
2182 Q3FileDialog *fd=new Q3FileDialog( this);
2183 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2184 fd->setMode (Q3FileDialog::ExistingFiles);
2185 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2186 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2189 if ( fd->exec() == QDialog::Accepted )
2191 ImportFirefoxBookmarks im;
2192 QStringList flist = fd->selectedFiles();
2193 QStringList::Iterator it = flist.begin();
2194 while( it != flist.end() )
2197 if (im.transform() &&
2198 success==fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2199 currentMapEditor() )
2200 currentMapEditor()->setFilePath ("");
2207 void Main::fileImportFreemind()
2209 QStringList filters;
2210 filters <<"Freemind map (*.mm)"<<"All files (*)";
2211 QFileDialog *fd=new QFileDialog( this);
2212 fd->setDir (lastFileDir);
2213 fd->setFileMode (QFileDialog::ExistingFiles);
2214 fd->setFilters (filters);
2215 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2219 if ( fd->exec() == QDialog::Accepted )
2221 lastFileDir=fd->directory().path();
2222 QStringList flist = fd->selectedFiles();
2223 QStringList::Iterator it = flist.begin();
2224 while( it != flist.end() )
2227 if ( fileLoad (fn,NewMap, FreemindMap) )
2229 currentMapEditor()->setFilePath ("");
2238 void Main::fileImportMM()
2242 Q3FileDialog *fd=new Q3FileDialog( this);
2243 fd->setDir (lastFileDir);
2244 fd->setMode (Q3FileDialog::ExistingFiles);
2245 fd->addFilter ("Mind Manager (*.mmap)");
2246 fd->setCaption(tr("Import")+" "+"Mind Manager");
2249 if ( fd->exec() == QDialog::Accepted )
2251 lastFileDir=fd->dirPath();
2252 QStringList flist = fd->selectedFiles();
2253 QStringList::Iterator it = flist.begin();
2254 while( it != flist.end() )
2257 if (im.transform() &&
2258 success==fileLoad (im.getTransformedFile(),NewMap) &&
2259 currentMapEditor() )
2260 currentMapEditor()->setFilePath ("");
2269 void Main::fileImportDir()
2271 if (currentMapEditor())
2272 currentMapEditor()->importDir();
2275 void Main::fileExportXML()
2277 MapEditor *me=currentMapEditor();
2278 if (me) me->exportXML();
2282 void Main::fileExportXHTML()
2284 MapEditor *me=currentMapEditor();
2285 if (me) me->exportXHTML();
2288 void Main::fileExportImage()
2290 MapEditor *me=currentMapEditor();
2291 if (me) me->exportImage();
2294 void Main::fileExportASCII()
2296 MapEditor *me=currentMapEditor();
2297 if (me) me->exportASCII();
2300 void Main::fileExportCSV() //FIXME not scriptable yet
2302 MapEditor *me=currentMapEditor();
2306 ex.setMapCenter(me->getMapCenter());
2307 ex.addFilter ("CSV (*.csv)");
2308 ex.setDir(lastImageDir);
2309 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2310 if (ex.execDialog() )
2312 me->setExportMode(true);
2314 me->setExportMode(false);
2319 void Main::fileExportLaTeX() //FIXME not scriptable yet
2321 MapEditor *me=currentMapEditor();
2325 ex.setMapCenter(me->getMapCenter());
2326 ex.addFilter ("Tex (*.tex)");
2327 ex.setDir(lastImageDir);
2328 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2329 if (ex.execDialog() )
2331 me->setExportMode(true);
2333 me->setExportMode(false);
2338 void Main::fileExportKDEBookmarks() //FIXME not scriptable yet
2340 ExportKDEBookmarks ex;
2341 MapEditor *me=currentMapEditor();
2344 ex.setMapCenter (me->getMapCenter() );
2349 void Main::fileExportTaskjuggler() //FIXME not scriptable yet
2351 ExportTaskjuggler ex;
2352 MapEditor *me=currentMapEditor();
2355 ex.setMapCenter (me->getMapCenter() );
2356 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2357 ex.setDir(lastImageDir);
2358 ex.addFilter ("Taskjuggler (*.tjp)");
2359 if (ex.execDialog() )
2361 me->setExportMode(true);
2363 me->setExportMode(false);
2368 void Main::fileExportOOPresentation() //FIXME not scriptable yet
2370 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2371 // TODO add preview in dialog
2372 //ImagePreview *p =new ImagePreview (fd);
2373 //fd->setContentsPreviewEnabled( TRUE );
2374 //fd->setContentsPreview( p, p );
2375 //fd->setPreviewMode( QFileDialog::Contents );
2376 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2377 fd->setDir (QDir().current());
2378 if (fd->foundConfig())
2382 if ( fd->exec() == QDialog::Accepted )
2384 QString fn=fd->selectedFile();
2385 if (!fn.contains (".odp"))
2388 //lastImageDir=fn.left(fn.findRev ("/"));
2389 if (currentMapEditor())
2390 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2394 QMessageBox::warning(0,
2396 tr("Couldn't find configuration for export to Open Office\n"));
2400 void Main::fileCloseMap()
2402 if (currentMapEditor())
2404 if (currentMapEditor()->hasChanged())
2406 QMessageBox mb( vymName,
2407 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2408 QMessageBox::Warning,
2409 QMessageBox::Yes | QMessageBox::Default,
2411 QMessageBox::Cancel | QMessageBox::Escape );
2412 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2413 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2416 case QMessageBox::Yes:
2418 fileSave(currentMapEditor(), CompleteMap);
2420 case QMessageBox::No:
2421 // close without saving
2423 case QMessageBox::Cancel:
2428 currentMapEditor()->closeMap();
2429 tabWidget->removePage(currentMapEditor());
2430 if (tabWidget->count()==0)
2431 actionFilePrint->setEnabled (false);
2435 void Main::filePrint()
2437 if (currentMapEditor())
2438 currentMapEditor()->print();
2441 void Main::fileExitVYM()
2443 // Check if one or more editors have changed
2446 for (i=0;i<=tabWidget->count() -1;i++)
2449 me=(MapEditor*)tabWidget->page(i);
2451 // If something changed, ask what to do
2452 if (me->hasChanged())
2454 tabWidget->setCurrentPage(i);
2455 QMessageBox mb( vymName,
2456 tr("This map is not saved yet. Do you want to"),
2457 QMessageBox::Warning,
2458 QMessageBox::Yes | QMessageBox::Default,
2460 QMessageBox::Cancel | QMessageBox::Escape );
2461 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2462 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2465 mb.setActiveWindow();
2466 switch( mb.exec() ) {
2467 case QMessageBox::Yes:
2468 // save (the changed editors) and exit
2469 fileSave(currentMapEditor(), CompleteMap);
2471 case QMessageBox::No:
2472 // exit without saving
2474 case QMessageBox::Cancel:
2475 // don't save and don't exit
2479 } // loop over all MEs
2483 void Main::editUndo()
2485 if (currentMapEditor())
2486 currentMapEditor()->undo();
2489 void Main::editRedo()
2491 if (currentMapEditor())
2492 currentMapEditor()->redo();
2495 void Main::gotoHistoryStep (int i)
2497 if (currentMapEditor())
2498 currentMapEditor()->gotoHistoryStep (i);
2501 void Main::editCopy()
2503 if (currentMapEditor())
2504 currentMapEditor()->copy();
2507 void Main::editPaste()
2509 if (currentMapEditor())
2510 currentMapEditor()->paste();
2513 void Main::editCut()
2515 if (currentMapEditor())
2516 currentMapEditor()->cut();
2519 void Main::editOpenFindWindow()
2521 findWindow->popup();
2522 findWindow->raise();
2523 findWindow->setActiveWindow();
2526 void Main::editFind(QString s)
2529 BranchObj *bo=currentMapEditor()->findText(s, cs);
2532 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2535 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2536 tr("No matches found for \"%1\"").arg(s));
2540 void Main::editFindChanged()
2541 { // Notify editor, to abort the current find process
2542 currentMapEditor()->findReset();
2545 void Main::openTabs(QStringList urls)
2547 if (!urls.isEmpty())
2551 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2553 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2555 QString u=urls.takeFirst();
2556 procBrowser = new QProcess( this );
2558 procBrowser->start(browser,args);
2559 if ( !procBrowser->waitForStarted())
2561 // try to set path to browser
2562 QMessageBox::warning(0,
2564 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2565 tr("Please use Settings->")+tr("Set application to open an URL"));
2568 #if defined(Q_OS_WIN32)
2569 // There's no sleep in VCEE, replace it with Qt's QThread::wait().
2570 this->thread()->wait(3000);
2575 if (browser.contains("konqueror"))
2577 for (int i=0; i<urls.size(); i++)
2580 // Try to open new tab in existing konqueror started previously by vym
2581 p=new QProcess (this);
2583 #if defined(Q_OS_WIN32)
2584 // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
2585 // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
2586 args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
2587 "konqueror-mainwindow#1"<<
2591 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2592 "konqueror-mainwindow#1"<<
2596 p->start ("dcop",args);
2597 cout << args.join(" ").ascii()<<endl;
2598 if ( !p->waitForStarted() ) success=false;
2601 QMessageBox::warning(0,
2603 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2605 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2607 for (int i=0; i<urls.size(); i++)
2609 // Try to open new tab in firefox
2610 p=new QProcess (this);
2611 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2612 p->start (browser,args);
2613 if ( !p->waitForStarted() ) success=false;
2616 QMessageBox::warning(0,
2618 tr("Couldn't start %1 to open a new tab").arg(browser));
2621 QMessageBox::warning(0,
2623 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2627 void Main::editOpenURL()
2630 if (currentMapEditor())
2632 QString url=currentMapEditor()->getURL();
2634 if (url=="") return;
2635 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2636 procBrowser = new QProcess( this );
2638 procBrowser->start(browser,args);
2639 if ( !procBrowser->waitForStarted())
2641 // try to set path to browser
2642 QMessageBox::warning(0,
2644 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2645 tr("Please use Settings->")+tr("Set application to open an URL"));
2650 void Main::editOpenURLTab()
2652 if (currentMapEditor())
2655 urls.append(currentMapEditor()->getURL());
2659 void Main::editOpenMultipleURLTabs()
2661 if (currentMapEditor())
2664 urls=currentMapEditor()->getURLs();
2670 void Main::editURL()
2672 if (currentMapEditor())
2673 currentMapEditor()->editURL();
2676 void Main::editLocalURL()
2678 if (currentMapEditor())
2679 currentMapEditor()->editLocalURL();
2682 void Main::editHeading2URL()
2684 if (currentMapEditor())
2685 currentMapEditor()->editHeading2URL();
2688 void Main::editBugzilla2URL()
2690 if (currentMapEditor())
2691 currentMapEditor()->editBugzilla2URL();
2694 void Main::editFATE2URL()
2696 if (currentMapEditor())
2697 currentMapEditor()->editFATE2URL();
2700 void Main::editHeadingFinished()
2702 // only called from editHeading(), so there is a currentME
2703 MapEditor *me=currentMapEditor();
2706 me->setStateEditHeading (false);
2707 QPoint p; //Not used here, only to find out pos of branch
2709 QString s=me->getHeading(ok,p);
2711 #if defined(Q_OS_MACX)
2713 if (ok && s!=lineedit->text())
2714 me->setHeading(lineedit->text());
2716 lineedit->releaseKeyboard();
2720 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2721 !prevSelection.isEmpty())
2722 me->select(prevSelection);
2727 void Main::editHeading()
2729 if (currentMapEditor())
2731 MapEditor *me=currentMapEditor();
2732 QString oldSel=me->getSelectString();
2734 if (lineedit->isVisible())
2735 editHeadingFinished();
2740 QString s=me->getHeading(ok,p);
2744 me->setStateEditHeading (true);
2745 #if defined(Q_OS_MACX)
2746 p=me->mapToGlobal (p);
2747 QDialog *d =new QDialog(NULL);
2748 QLineEdit *le=new QLineEdit (d);
2749 d->setWindowFlags (Qt::FramelessWindowHint);
2750 d->setGeometry(p.x(),p.y(),230,25);
2751 le->resize (d->width()-10,d->height());
2754 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2755 d->activateWindow();
2757 me->setHeading (le->text());
2760 editHeadingFinished();
2762 p=me->mapTo (this,p);
2763 lineedit->setGeometry(p.x(),p.y(),230,25);
2764 lineedit->setText(s);
2765 lineedit->setCursorPosition(1);
2766 lineedit->selectAll();
2768 lineedit->grabKeyboard();
2769 lineedit->setFocus();
2773 } // currentMapEditor()
2776 void Main::editAttributeFinished()
2778 // only called from editHeading(), so there is a currentME
2781 MapEditor *me=currentMapEditor();
2784 me->setStateEditHeading (false);
2785 QPoint p; //Not used here, only to find out pos of branch
2787 QString s=me->getHeading(ok,p);
2789 #if defined(Q_OS_MACX)
2791 if (ok && s!=lineedit->text())
2792 me->setHeading(lineedit->text());
2794 lineedit->releaseKeyboard();
2798 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2799 !prevSelection.isEmpty())
2800 me->select(prevSelection);
2806 void Main::editAttribute()
2809 if (currentMapEditor())
2811 MapEditor *me=currentMapEditor();
2812 QString oldSel=me->getSelectString();
2814 if (lineedit->isVisible())
2815 editAttributeFinished();
2820 QString s=me->getHeading(ok,p);
2824 me->setStateEditHeading (true);
2825 #if defined(Q_OS_MACX)
2826 p=me->mapToGlobal (p);
2827 QDialog *d =new QDialog(NULL);
2828 QLineEdit *le=new QLineEdit (d);
2829 d->setWindowFlags (Qt::FramelessWindowHint);
2830 d->setGeometry(p.x(),p.y(),230,25);
2831 le->resize (d->width()-10,d->height());
2834 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2835 d->activateWindow();
2837 me->setHeading (le->text());
2840 editHeadingFinished();
2842 p=me->mapTo (this,p);
2843 lineedit->setGeometry(p.x(),p.y(),230,25);
2844 lineedit->setText(s);
2845 lineedit->setCursorPosition(1);
2846 lineedit->selectAll();
2848 lineedit->grabKeyboard();
2849 lineedit->setFocus();
2853 } // currentMapEditor()
2858 void Main::openVymLinks(const QStringList &vl)
2860 for (int j=0; j<vl.size(); j++)
2862 // compare path with already loaded maps
2866 for (i=0;i<=tabWidget->count() -1;i++)
2868 me=(MapEditor*)tabWidget->page(i);
2869 if (vl.at(j)==me->getFilePath() )
2878 if (!QFile(vl.at(j)).exists() )
2879 QMessageBox::critical( 0, tr( "Critical Error" ),
2880 tr("Couldn't open map %1").arg(vl.at(j)));
2883 fileLoad (vl.at(j), NewMap);
2884 tabWidget->setCurrentPage (tabWidget->count()-1);
2887 // Go to tab containing the map
2888 tabWidget->setCurrentPage (index);
2892 void Main::editOpenVymLink()
2894 if (currentMapEditor())
2897 vl.append(currentMapEditor()->getVymLink());
2902 void Main::editOpenMultipleVymLinks()
2904 QString currentVymLink;
2905 if (currentMapEditor())
2907 QStringList vl=currentMapEditor()->getVymLinks();
2912 void Main::editVymLink()
2914 if (currentMapEditor())
2915 currentMapEditor()->editVymLink();
2918 void Main::editDeleteVymLink()
2920 if (currentMapEditor())
2921 currentMapEditor()->deleteVymLink();
2924 void Main::editToggleHideExport()
2926 if (currentMapEditor())
2927 currentMapEditor()->toggleHideExport();
2930 void Main::editMapInfo()
2932 if (currentMapEditor())
2933 currentMapEditor()->editMapInfo();
2936 void Main::editMoveUp()
2938 if (currentMapEditor())
2939 currentMapEditor()->moveBranchUp();
2942 void Main::editMoveDown()
2944 if (currentMapEditor())
2945 currentMapEditor()->moveBranchDown();
2948 void Main::editSortChildren()
2950 if (currentMapEditor())
2951 currentMapEditor()->sortChildren();
2954 void Main::editToggleScroll()
2956 if (currentMapEditor())
2958 currentMapEditor()->toggleScroll();
2962 void Main::editUnscrollChilds()
2964 if (currentMapEditor())
2965 currentMapEditor()->unscrollChilds();
2968 void Main::editNewBranch()
2970 MapEditor *me=currentMapEditor();
2971 if (!lineedit->isVisible() && me)
2973 BranchObj *bo=(BranchObj*)me->getSelection();
2974 BranchObj *newbo=me->addNewBranch(0);
2976 prevSelection=bo->getSelectString();
2978 me->select (newbo->getSelectString());
2982 if (actionSettingsAutoEditNewBranch->isOn())
2987 if (!prevSelection.isEmpty())
2989 me->select(prevSelection);
2996 void Main::editNewBranchBefore()
2998 MapEditor *me=currentMapEditor();
2999 if (!lineedit->isVisible() && me)
3001 BranchObj *bo=(BranchObj*)me->getSelection();
3002 BranchObj *newbo=me->addNewBranchBefore();
3005 me->select (newbo->getSelectString());
3009 if (actionSettingsAutoEditNewBranch->isOn())
3011 if (!actionSettingsAutoSelectNewBranch->isOn())
3012 prevSelection=bo->getSelectString();
3018 void Main::editNewBranchAbove()
3020 MapEditor *me=currentMapEditor();
3021 if (!lineedit->isVisible() && me)
3023 BranchObj *bo=(BranchObj*)me->getSelection();
3024 BranchObj *newbo=me->addNewBranch (-1);
3027 me->select (newbo->getSelectString());
3031 if (actionSettingsAutoEditNewBranch->isOn())
3033 if (!actionSettingsAutoSelectNewBranch->isOn())
3034 prevSelection=bo->getSelectString();
3040 void Main::editNewBranchBelow()
3042 MapEditor *me=currentMapEditor();
3043 if (!lineedit->isVisible() && me)
3045 BranchObj *bo=(BranchObj*)me->getSelection();
3046 BranchObj *newbo=me->addNewBranch (1);
3049 me->select (newbo->getSelectString());
3053 if (actionSettingsAutoEditNewBranch->isOn())
3055 if (!actionSettingsAutoSelectNewBranch->isOn())
3056 prevSelection=bo->getSelectString();
3062 void Main::editImportAdd()
3064 fileLoad (ImportAdd);
3067 void Main::editImportReplace()
3069 fileLoad (ImportReplace);
3072 void Main::editSaveBranch()
3074 fileSaveAs (PartOfMap);
3077 void Main::editDeleteKeepChilds()
3079 if (currentMapEditor())
3080 currentMapEditor()->deleteKeepChilds();
3083 void Main::editDeleteChilds()
3085 if (currentMapEditor())
3086 currentMapEditor()->deleteChilds();
3089 void Main::editDeleteSelection()
3091 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
3092 currentMapEditor()->deleteSelection();
3095 void Main::editUpperBranch()
3097 if (currentMapEditor())
3098 currentMapEditor()->selectUpperBranch();
3101 void Main::editLowerBranch()
3103 if (currentMapEditor())
3104 currentMapEditor()->selectLowerBranch();
3107 void Main::editLeftBranch()
3109 if (currentMapEditor())
3110 currentMapEditor()->selectLeftBranch();
3113 void Main::editRightBranch()
3115 if (currentMapEditor())
3116 currentMapEditor()->selectRightBranch();
3119 void Main::editFirstBranch()
3121 if (currentMapEditor())
3122 currentMapEditor()->selectFirstBranch();
3125 void Main::editLastBranch()
3127 if (currentMapEditor())
3128 currentMapEditor()->selectLastBranch();
3131 void Main::editLoadImage()
3133 if (currentMapEditor())
3134 currentMapEditor()->loadFloatImage();
3137 void Main::editSaveImage()
3139 if (currentMapEditor())
3140 currentMapEditor()->saveFloatImage();
3143 void Main::editFollowXLink(QAction *a)
3146 if (currentMapEditor())
3147 currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
3150 void Main::editEditXLink(QAction *a)
3152 if (currentMapEditor())
3153 currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3156 void Main::formatSelectColor()
3158 if (currentMapEditor())
3160 QColor col = QColorDialog::getColor((currentColor ), this );
3161 if ( !col.isValid() ) return;
3162 colorChanged( col );
3166 void Main::formatPickColor()
3168 if (currentMapEditor())
3169 colorChanged( currentMapEditor()->getCurrentHeadingColor() );
3172 void Main::colorChanged(QColor c)
3174 QPixmap pix( 16, 16 );
3176 actionFormatColor->setIconSet( pix );
3180 void Main::formatColorBranch()
3182 if (currentMapEditor())
3183 currentMapEditor()->colorBranch(currentColor);
3186 void Main::formatColorSubtree()
3188 if (currentMapEditor())
3189 currentMapEditor()->colorSubtree (currentColor);
3192 void Main::formatLinkStyleLine()
3194 if (currentMapEditor())
3195 currentMapEditor()->setMapLinkStyle("StyleLine");
3198 void Main::formatLinkStyleParabel()
3200 if (currentMapEditor())
3201 currentMapEditor()->setMapLinkStyle("StyleParabel");
3204 void Main::formatLinkStylePolyLine()
3206 if (currentMapEditor())
3207 currentMapEditor()->setMapLinkStyle("StylePolyLine");
3210 void Main::formatLinkStylePolyParabel()
3212 if (currentMapEditor())
3213 currentMapEditor()->setMapLinkStyle("StylePolyParabel");
3216 void Main::formatSelectBackColor()
3218 if (currentMapEditor())
3219 currentMapEditor()->selectMapBackgroundColor();
3222 void Main::formatSelectBackImage()
3224 if (currentMapEditor())
3225 currentMapEditor()->selectMapBackgroundImage();
3228 void Main::formatSelectLinkColor()
3230 if (currentMapEditor())
3231 currentMapEditor()->selectMapLinkColor();
3234 void Main::formatSelectSelectionColor()
3236 if (currentMapEditor())
3237 currentMapEditor()->selectMapSelectionColor();
3240 void Main::formatToggleLinkColorHint()
3242 currentMapEditor()->toggleMapLinkColorHint();
3246 void Main::formatHideLinkUnselected() //FIXME get rid of this with imagepropertydialog
3248 if (currentMapEditor())
3249 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3252 void Main::viewZoomReset()
3254 if (currentMapEditor())
3258 currentMapEditor()->setMatrix( m );
3262 void Main::viewZoomIn()
3264 if (currentMapEditor())
3266 QMatrix m = currentMapEditor()->matrix();
3267 m.scale( 1.25, 1.25 );
3268 currentMapEditor()->setMatrix( m );
3272 void Main::viewZoomOut()
3274 if (currentMapEditor())
3276 QMatrix m = currentMapEditor()->matrix();
3277 m.scale( 0.8, 0.8 );
3278 currentMapEditor()->setMatrix( m );
3282 void Main::viewCenter()
3284 MapEditor *me=currentMapEditor();
3287 me->ensureSelectionVisible();
3291 void Main::networkStartServer()
3293 MapEditor *me=currentMapEditor();
3294 if (me) me->newServer();
3297 void Main::networkConnect()
3299 MapEditor *me=currentMapEditor();
3300 if (me) me->connectToServer();
3303 bool Main::settingsPDF()
3305 // Default browser is set in constructor
3307 QString text = QInputDialog::getText(
3308 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3309 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3311 settings.setValue ("/mainwindow/readerPDF",text);
3316 bool Main::settingsURL()
3318 // Default browser is set in constructor
3320 QString text = QInputDialog::getText(
3321 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3322 settings.value("/mainwindow/readerURL").toString()
3325 settings.setValue ("/mainwindow/readerURL",text);
3329 void Main::settingsMacroDir()
3331 QDir defdir=vymBaseDir;
3332 defdir.cd("macros");
3333 if (!defdir.exists())
3335 QDir dir=QFileDialog::getExistingDirectory (
3337 tr ("Directory with vym macros:"),
3338 settings.value ("/macros/macroDir",defdir.path()).toString()
3341 settings.setValue ("/macros/macroDir",dir.path());
3344 void Main::settingsUndoLevels()
3347 int i = QInputDialog::getInteger(
3349 tr("QInputDialog::getInteger()"),
3350 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3353 settings.setValue ("/mapeditor/stepsTotal",i);
3354 QMessageBox::information( this, tr( "VYM -Information:" ),
3355 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3359 void Main::settingsAutosaveToggle()
3361 settings.setValue ("/mapeditor/autosave/use",actionSettingsAutosaveToggle->isOn() );
3364 void Main::settingsAutosaveTime()
3367 int i = QInputDialog::getInteger(
3369 tr("QInputDialog::getInteger()"),
3370 tr("Number of seconds before autosave:"), settings.value("/mapeditor/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3373 settings.setValue ("/mapeditor/autosave/ms",i * 1000);
3377 void Main::settingsToggleDelKey()
3379 if (actionSettingsUseDelKey->isOn())
3381 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3384 actionEditDelete->setAccel (QKeySequence (""));
3388 void Main::windowToggleNoteEditor()
3390 if (textEditor->isVisible() )
3391 windowHideNoteEditor();
3393 windowShowNoteEditor();
3396 void Main::windowToggleHistory()
3398 if (historyWindow->isVisible())
3399 historyWindow->hide();
3401 historyWindow->show();
3405 void Main::windowToggleProperty()
3407 if (branchPropertyWindow->isVisible())
3408 branchPropertyWindow->hide();
3410 branchPropertyWindow->show();
3412 if(currentMapEditor())
3414 LinkableMapObj *sel=currentMapEditor()->getSelection();
3415 if (sel && (typeid(*sel) == typeid(BranchObj) ||
3416 typeid(*sel) == typeid(MapCenterObj)))
3418 branchPropertyWindow->setMapEditor(currentMapEditor());
3419 branchPropertyWindow->setBranch((BranchObj*)sel);
3424 branchPropertyWindow->setBranch(NULL);
3427 void Main::windowToggleAntiAlias()
3429 bool b=actionViewToggleAntiAlias->isOn();
3431 for (int i=0;i<tabWidget->count();i++)
3434 me=(MapEditor*)tabWidget->page(i);
3435 me->setAntiAlias(b);
3440 void Main::windowToggleSmoothPixmap()
3442 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3444 for (int i=0;i<tabWidget->count();i++)
3447 me=(MapEditor*)tabWidget->page(i);
3448 me->setSmoothPixmap(b);
3452 void Main::updateHistory(SimpleSettings &undoSet)
3454 historyWindow->update (undoSet);
3457 void Main::updateNoteFlag()
3459 if (currentMapEditor())
3460 currentMapEditor()->updateNoteFlag();
3463 void Main::updateSatellites(MapEditor *me)
3465 branchPropertyWindow->setMapEditor (me);
3468 void Main::updateActions()
3470 MapEditor *me=currentMapEditor();
3473 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(currentMapEditor()->getFileName()));
3475 // updateActions is also called when NoteEditor is closed
3476 actionViewToggleNoteEditor->setOn (textEditor->isVisible());
3477 actionViewToggleHistoryWindow->setOn (historyWindow->isVisible());
3478 actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible());
3480 if (me->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3481 actionFormatLinkColorHint->setOn(true);
3483 actionFormatLinkColorHint->setOn(false);
3485 switch (me->getMapLinkStyle())
3487 case LinkableMapObj::Line:
3488 actionFormatLinkStyleLine->setOn(true);
3490 case LinkableMapObj::Parabel:
3491 actionFormatLinkStyleParabel->setOn(true);
3493 case LinkableMapObj::PolyLine:
3494 actionFormatLinkStylePolyLine->setOn(true);
3496 case LinkableMapObj::PolyParabel:
3497 actionFormatLinkStylePolyParabel->setOn(true);
3504 QPixmap pix( 16, 16 );
3505 pix.fill( me->getMapBackgroundColor() );
3506 actionFormatBackColor->setIconSet( pix );
3507 pix.fill( me->getSelectionColor() );
3508 actionFormatSelectionColor->setIconSet( pix );
3509 pix.fill( me->getMapDefLinkColor() );
3510 actionFormatLinkColor->setIconSet( pix );
3513 actionFileSave->setEnabled( me->hasChanged() );
3514 if (me->isUndoAvailable())
3515 actionEditUndo->setEnabled( true);
3517 actionEditUndo->setEnabled( false);
3519 if (me->isRedoAvailable())
3520 actionEditRedo->setEnabled( true);
3522 actionEditRedo->setEnabled( false);
3524 LinkableMapObj *selection=me->getSelection();
3527 if ( (typeid(*selection) == typeid(BranchObj)) ||
3528 (typeid(*selection) == typeid(MapCenterObj)) )
3530 BranchObj *bo=(BranchObj*)selection;
3531 // Take care of links
3532 if (bo->countXLinks()==0)
3534 branchXLinksContextMenuEdit->clear();
3535 branchXLinksContextMenuFollow->clear();
3540 branchXLinksContextMenuEdit->clear();
3541 branchXLinksContextMenuFollow->clear();
3542 for (int i=0; i<=bo->countXLinks();i++)
3544 bot=bo->XLinkTargetAt(i);
3547 s=bot->getHeading();
3548 if (s.length()>xLinkMenuWidth)
3549 s=s.left(xLinkMenuWidth)+"...";
3550 branchXLinksContextMenuFollow->addAction (s);
3551 branchXLinksContextMenuEdit->addAction (s);
3556 standardFlagsDefault->setEnabled (true);
3558 actionEditToggleScroll->setEnabled (true);
3559 if ( bo->isScrolled() )
3560 actionEditToggleScroll->setOn(true);
3562 actionEditToggleScroll->setOn(false);
3564 if ( bo->getURL().isEmpty() )
3566 actionEditOpenURL->setEnabled (false);
3567 actionEditOpenURLTab->setEnabled (false);
3571 actionEditOpenURL->setEnabled (true);
3572 actionEditOpenURLTab->setEnabled (true);
3574 if ( bo->getVymLink().isEmpty() )
3576 actionEditOpenVymLink->setEnabled (false);
3577 actionEditDeleteVymLink->setEnabled (false);
3580 actionEditOpenVymLink->setEnabled (true);
3581 actionEditDeleteVymLink->setEnabled (true);
3584 if (bo->canMoveBranchUp())
3585 actionEditMoveUp->setEnabled (true);
3587 actionEditMoveUp->setEnabled (false);
3588 if (bo->canMoveBranchDown())
3589 actionEditMoveDown->setEnabled (true);
3591 actionEditMoveDown->setEnabled (false);
3594 actionEditToggleHideExport->setEnabled (true);
3595 actionEditToggleHideExport->setOn (bo->hideInExport() );
3597 actionEditCopy->setEnabled (true);
3598 actionEditCut->setEnabled (true);
3599 if (!clipboardEmpty)
3600 actionEditPaste->setEnabled (true);
3602 actionEditPaste->setEnabled (false);
3603 for (int i=0; i<actionListBranches.size(); ++i)
3604 actionListBranches.at(i)->setEnabled(true);
3605 actionEditDelete->setEnabled (true);
3606 actionFormatHideLinkUnselected->setOn
3607 (selection->getHideLinkUnselected());
3609 if ( (typeid(*selection) == typeid(FloatImageObj)) )
3611 FloatObj *fo=(FloatImageObj*)selection;
3613 actionEditOpenURL->setEnabled (false);
3614 actionEditOpenVymLink->setEnabled (false);
3615 actionEditDeleteVymLink->setEnabled (false);
3616 actionEditToggleHideExport->setEnabled (true);
3617 actionEditToggleHideExport->setOn (fo->hideInExport() );
3620 actionEditCopy->setEnabled (true);
3621 actionEditCut->setEnabled (true);
3622 actionEditPaste->setEnabled (false);
3623 for (int i=0; i<actionListBranches.size(); ++i)
3624 actionListBranches.at(i)->setEnabled(false);
3625 actionEditDelete->setEnabled (true);
3626 actionFormatHideLinkUnselected->setOn
3627 ( selection->getHideLinkUnselected());
3628 actionEditMoveUp->setEnabled (false);
3629 actionEditMoveDown->setEnabled (false);
3634 actionEditCopy->setEnabled (false);
3635 actionEditCut->setEnabled (false);
3636 actionEditPaste->setEnabled (false);
3637 for (int i=0; i<actionListBranches.size(); ++i)
3638 actionListBranches.at(i)->setEnabled(false);
3640 actionEditToggleScroll->setEnabled (false);
3641 actionEditOpenURL->setEnabled (false);
3642 actionEditOpenVymLink->setEnabled (false);
3643 actionEditDeleteVymLink->setEnabled (false);
3644 actionEditHeading2URL->setEnabled (false);
3645 actionEditDelete->setEnabled (false);
3646 actionEditMoveUp->setEnabled (false);
3647 actionEditMoveDown->setEnabled (false);
3648 actionEditToggleHideExport->setEnabled (false);
3652 Main::ModMode Main::getModMode()
3654 if (actionModModeColor->isOn()) return ModModeColor;
3655 if (actionModModeCopy->isOn()) return ModModeCopy;
3656 if (actionModModeXLink->isOn()) return ModModeXLink;
3660 bool Main::autoEditNewBranch()
3662 return actionSettingsAutoEditNewBranch->isOn();
3665 bool Main::autoSelectNewBranch()
3667 return actionSettingsAutoSelectNewBranch->isOn();
3670 bool Main::useFlagGroups()
3672 return actionSettingsUseFlagGroups->isOn();
3675 void Main::windowShowNoteEditor()
3677 textEditor->setShowWithMain(true);
3679 actionViewToggleNoteEditor->setOn (true);
3682 void Main::windowHideNoteEditor()
3684 textEditor->setShowWithMain(false);
3686 actionViewToggleNoteEditor->setOn (false);
3689 void Main::setScript (const QString &script)
3691 scriptEditor->setScript (script);
3694 void Main::runScript (const QString &script)
3696 if (currentMapEditor())
3697 currentMapEditor()->runScript (script);
3700 void Main::runScriptEverywhere (const QString &script)
3703 for (int i=0;i<=tabWidget->count() -1;i++)
3705 me=(MapEditor*)tabWidget->page(i);
3706 if (me) me->runScript (script);
3710 void Main::windowNextEditor()
3712 if (tabWidget->currentPageIndex() < tabWidget->count())
3713 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3716 void Main::windowPreviousEditor()
3718 if (tabWidget->currentPageIndex() >0)
3719 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3722 void Main::standardFlagChanged()
3724 if (currentMapEditor())
3725 currentMapEditor()->toggleStandardFlag(sender()->name());
3728 void Main::testFunction1()
3730 if (!currentMapEditor()) return;
3731 //currentMapEditor()->testFunction1();
3735 void Main::testFunction2()
3737 if (!currentMapEditor()) return;
3738 currentMapEditor()->testFunction2();
3741 void Main::testCommand()
3743 if (!currentMapEditor()) return;
3744 scriptEditor->show();
3747 QString com = QInputDialog::getText(
3748 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3749 if (ok) currentMapEditor()->parseAtom(com);
3753 void Main::helpDoc()
3755 QString locale = QLocale::system().name();
3757 if (locale.left(2)=="es")
3758 docname="vym_es.pdf";
3762 QStringList searchList;
3764 #if defined(Q_OS_MACX)
3765 searchList << "./vym.app/Contents/Resources/doc";
3767 #if defined(VYM_DOCDIR)
3768 searchList << VYM_DOCDIR;
3770 // default path in SUSE LINUX
3771 searchList <<"/usr/share/doc/packages/vym";
3774 searchList << "doc"; // relative path for easy testing in tarball
3775 searchList << "doc/tex"; // Easy testing working on vym.tex
3776 searchList << "/usr/share/doc/vym"; // Debian
3777 searchList << "/usr/share/doc/packages";// Knoppix
3781 for (int i=0; i<searchList.count(); ++i)
3783 docfile.setFileName(QDir::convertSeparators(searchList.at(i)+"/"+docname));
3784 if (docfile.exists() )
3793 QMessageBox::critical(0,
3794 tr("Critcal error"),
3795 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3800 Process *pdfProc = new Process();
3801 args <<docfile.fileName();
3803 pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
3804 if ( !pdfProc->waitForStarted() )
3807 QMessageBox::warning(0,
3809 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3810 tr("Please use Settings->")+tr("Set application to open PDF files"));
3817 void Main::helpDemo()
3819 QStringList filters;
3820 filters <<"VYM example map (*.vym)";
3821 QFileDialog *fd=new QFileDialog( this);
3822 #if defined(Q_OS_MACX)
3823 fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
3825 // default path in SUSE LINUX
3826 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
3829 fd->setFileMode (QFileDialog::ExistingFiles);
3830 fd->setFilters (filters);
3831 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
3835 if ( fd->exec() == QDialog::Accepted )
3837 lastFileDir=fd->directory().path();
3838 QStringList flist = fd->selectedFiles();
3839 QStringList::Iterator it = flist.begin();
3840 while( it != flist.end() )
3843 fileLoad(*it, NewMap);
3851 void Main::helpAbout()
3854 ad.setName ("aboutwindow");
3855 ad.setMinimumSize(500,500);
3856 ad.resize (QSize (500,500));
3860 void Main::helpAboutQT()
3862 QMessageBox::aboutQt( this, "Qt Application Example" );
3865 void Main::callMacro ()
3867 QAction *action = qobject_cast<QAction *>(sender());
3871 i=action->data().toInt();
3872 QString mDir (settings.value ("macros/macroDir").toString() );
3874 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3876 if ( !f.open( QIODevice::ReadOnly ) )
3878 QMessageBox::warning(0,
3880 tr("Couldn't find a macro at %1.\n").arg(fn)+
3881 tr("Please use Settings->")+tr("Set directory for vym macros"));
3885 QTextStream ts( &f );
3886 QString m= ts.read();
3890 //cout <<"Main::callMacro m="<<m.ascii()<<endl;
3891 currentMapEditor()->runScript (m);
3898 //////////////////////////////////
3900 @@ -2544,18 +2576,27 @@
3901 // Try to open new tab in existing konqueror started previously by vym
3902 p=new QProcess (this);
3904 - args<< QString("konqueror-%1").arg(procBrowser->pid())<<
3905 - "konqueror-mainwindow#1"<<
3907 +#if defined(Q_OS_WIN32)
3908 + // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
3909 + // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
3910 + args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
3911 + "konqueror-mainwindow#1"<<
3915 + args<< QString("konqueror-%1").arg(procBrowser->pid())<<
3916 + "konqueror-mainwindow#1"<<
3920 p->start ("dcop",args);
3921 if ( !p->waitForStarted() ) success=false;