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 actionEditSortChildren=a;
613 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this);
614 a->setShortcut ( Qt::Key_ScrollLock );
615 a->setStatusTip (tr( "Scroll branch" ) );
616 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
618 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
619 alt->setShortcut ( Qt::Key_S ); // Scroll branch
620 alt->setStatusTip (tr( "Scroll branch" ));
621 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
622 #if defined(Q_OS_MACX)
623 actionEditToggleScroll=alt;
625 actionEditToggleScroll=a;
627 actionEditToggleScroll->setEnabled (false);
628 actionEditToggleScroll->setToggleAction(true);
629 tb->addAction (actionEditToggleScroll);
630 editMenu->addAction ( actionEditToggleScroll);
631 editMenu->addAction (actionEditToggleScroll);
634 actionListBranches.append(actionEditToggleScroll);
636 a = new QAction( tr( "Unscroll childs","Edit menu" ), this);
637 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
638 editMenu->addAction (a);
639 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChilds() ) );
641 editMenu->addSeparator();
643 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
644 a->setStatusTip (tr( "Find" ) );
645 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
646 editMenu->addAction (a);
647 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
649 editMenu->addSeparator();
651 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
652 a->setShortcut (Qt::CTRL + Qt::Key_U );
653 a->setShortcut (tr( "Open URL" ));
656 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
659 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
660 a->setStatusTip (tr( "Open URL in new tab" ));
661 //a->setShortcut (Qt::CTRL+Qt::Key_U );
663 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
664 actionEditOpenURLTab=a;
666 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
667 a->setStatusTip (tr( "Open all URLs in subtree" ));
669 actionListBranches.append(a);
670 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
671 actionEditOpenMultipleURLTabs=a;
673 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
674 a->setStatusTip ( tr( "Edit URL" ) );
675 a->setShortcut ( Qt::Key_U );
676 a->setShortcutContext (Qt::WindowShortcut);
677 actionListBranches.append(a);
679 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
682 a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
683 a->setStatusTip ( tr( "Edit local URL" ) );
684 a->setShortcut (Qt::SHIFT + Qt::Key_U );
685 a->setShortcutContext (Qt::WindowShortcut);
686 actionListBranches.append(a);
688 connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
689 actionEditLocalURL=a;
691 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
692 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
693 a->setEnabled (false);
694 actionListBranches.append(a);
695 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
696 actionEditHeading2URL=a;
698 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
699 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
700 a->setEnabled (false);
701 actionListBranches.append(a);
702 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
703 actionEditBugzilla2URL=a;
705 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
706 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
707 a->setEnabled (false);
708 actionListBranches.append(a);
709 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
710 actionEditFATE2URL=a;
712 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
713 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
715 a->setEnabled (false);
716 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
717 actionEditOpenVymLink=a;
719 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
720 a->setStatusTip ( tr( "Open all vym links in subtree" ));
721 a->setEnabled (false);
722 actionListBranches.append(a);
723 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
724 actionEditOpenMultipleVymLinks=a;
727 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
728 a->setEnabled (false);
729 a->setStatusTip ( tr( "Edit link to another vym map" ));
730 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
731 actionListBranches.append(a);
734 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
735 a->setStatusTip ( tr( "Delete link to another vym map" ));
736 a->setEnabled (false);
737 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
738 actionEditDeleteVymLink=a;
740 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
741 a->setStatusTip ( tr( "Hide object in exports" ) );
742 a->setShortcut (Qt::Key_H );
743 a->setToggleAction(true);
745 a->setEnabled (false);
746 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
747 actionEditToggleHideExport=a;
749 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
750 a->setStatusTip ( tr( "Edit Map Info" ));
751 a->setEnabled (true);
752 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
755 // Import at selection (adding to selection)
756 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
757 a->setStatusTip (tr( "Add map at selection" ));
758 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
759 a->setEnabled (false);
760 actionListBranches.append(a);
761 actionEditImportAdd=a;
763 // Import at selection (replacing selection)
764 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
765 a->setStatusTip (tr( "Replace selection with map" ));
766 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
767 a->setEnabled (false);
768 actionListBranches.append(a);
769 actionEditImportReplace=a;
772 a = new QAction( tr( "Save selection","Edit menu" ), this);
773 a->setStatusTip (tr( "Save selection" ));
774 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
775 a->setEnabled (false);
776 actionListBranches.append(a);
777 actionEditSaveBranch=a;
779 // Only remove branch, not its childs
780 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
781 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
782 a->setShortcut (Qt::ALT + Qt::Key_Delete );
783 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChilds() ) );
784 a->setEnabled (false);
786 actionListBranches.append(a);
787 actionEditDeleteKeepChilds=a;
789 // Only remove childs of a branch
790 a = new QAction( tr( "Remove childs","Edit menu" ), this);
791 a->setStatusTip (tr( "Remove childs of branch" ));
792 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
793 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChilds() ) );
794 a->setEnabled (false);
795 actionListBranches.append(a);
796 actionEditDeleteChilds=a;
798 // Shortcuts for navigating with cursor:
799 a = new QAction(tr( "Select upper branch","Edit menu" ), this);
800 a->setStatusTip ( tr( "Select upper branch" ));
801 a->setShortcut (Qt::Key_Up );
802 a->setShortcutContext (Qt::WindowShortcut);
804 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
805 a = new QAction( tr( "Select lower branch","Edit menu" ),this);
806 a->setStatusTip (tr( "Select lower branch" ));
807 a->setShortcut ( Qt::Key_Down );
808 a->setShortcutContext (Qt::WindowShortcut);
810 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
811 a = new QAction(tr( "Select left branch","Edit menu" ), this);
812 a->setStatusTip ( tr( "Select left branch" ));
813 a->setShortcut (Qt::Key_Left );
814 a->setShortcutContext (Qt::WindowShortcut);
816 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
817 a = new QAction( tr( "Select child branch","Edit menu" ), this);
818 a->setStatusTip (tr( "Select right branch" ));
819 a->setShortcut (Qt::Key_Right);
820 a->setShortcutContext (Qt::WindowShortcut);
822 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
823 a = new QAction( tr( "Select first branch","Edit menu" ), this);
824 a->setStatusTip (tr( "Select first branch" ));
825 a->setShortcut (Qt::Key_Home );
826 a->setShortcutContext (Qt::WindowShortcut);
828 a->setEnabled (false);
829 editMenu->addAction (a);
830 actionListBranches.append(a);
831 actionEditSelectFirst=a;
832 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
833 a = new QAction( tr( "Select last branch","Edit menu" ),this);
834 a->setStatusTip (tr( "Select last branch" ));
835 a->setShortcut ( Qt::Key_End );
836 a->setShortcutContext (Qt::WindowShortcut);
838 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
839 a->setEnabled (false);
840 editMenu->addAction (a);
841 actionListBranches.append(a);
842 actionEditSelectLast=a;
844 a = new QAction( tr( "Add Image...","Edit menu" ), this);
845 a->setStatusTip (tr( "Add Image" ));
846 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
847 actionEditLoadImage=a;
849 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
850 a->setStatusTip (tr( "Set properties for selection" ));
851 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
852 a->setShortcutContext (Qt::WindowShortcut);
853 a->setToggleAction (true);
855 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
856 actionViewTogglePropertyWindow=a;
860 void Main::setupFormatActions()
862 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
864 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
865 tb->setObjectName ("formatTB");
868 pix.fill (Qt::black);
869 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
870 a->setStatusTip ( tr( "Set Color" ));
871 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
873 formatMenu->addAction (a);
875 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
876 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
877 a->setShortcut (Qt::CTRL + Qt::Key_K );
878 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
879 a->setEnabled (false);
881 formatMenu->addAction (a);
882 actionListBranches.append(a);
883 actionFormatPickColor=a;
885 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
886 a->setStatusTip ( tr( "Color branch" ) );
887 a->setShortcut (Qt::CTRL + Qt::Key_B);
888 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
889 a->setEnabled (false);
891 formatMenu->addAction (a);
892 actionListBranches.append(a);
893 actionFormatColorSubtree=a;
895 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
896 a->setStatusTip ( tr( "Color Subtree" ));
897 a->setShortcut (Qt::CTRL + Qt::Key_T);
898 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
899 a->setEnabled (false);
900 formatMenu->addAction (a);
902 actionListBranches.append(a);
903 actionFormatColorSubtree=a;
905 formatMenu->addSeparator();
906 actionGroupFormatLinkStyles=new QActionGroup ( this);
907 actionGroupFormatLinkStyles->setExclusive (true);
908 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
909 a->setStatusTip (tr( "Line" ));
910 a->setToggleAction(true);
911 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
912 formatMenu->addAction (a);
913 actionFormatLinkStyleLine=a;
914 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
915 a->setStatusTip (tr( "Line" ));
916 a->setToggleAction(true);
917 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
918 formatMenu->addAction (a);
919 actionFormatLinkStyleParabel=a;
920 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
921 a->setStatusTip (tr( "PolyLine" ));
922 a->setToggleAction(true);
923 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
924 formatMenu->addAction (a);
925 actionFormatLinkStylePolyLine=a;
926 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
927 a->setStatusTip (tr( "PolyParabel" ) );
928 a->setToggleAction(true);
929 a->setChecked (true);
930 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
931 formatMenu->addAction (a);
932 actionFormatLinkStylePolyParabel=a;
934 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
935 a->setStatusTip (tr( "Hide link" ));
936 a->setToggleAction(true);
937 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
938 actionFormatHideLinkUnselected=a;
940 formatMenu->addSeparator();
941 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
942 a->setStatusTip (tr( "Use same color for links and headings" ));
943 a->setToggleAction(true);
944 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
945 formatMenu->addAction (a);
946 actionFormatLinkColorHint=a;
948 pix.fill (Qt::white);
949 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
950 a->setStatusTip (tr( "Set Link Color" ));
951 formatMenu->addAction (a);
952 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
953 actionFormatLinkColor=a;
955 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
956 a->setStatusTip (tr( "Set Selection Color" ));
957 formatMenu->addAction (a);
958 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
959 actionFormatSelectionColor=a;
961 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
962 a->setStatusTip (tr( "Set Background Color" ));
963 formatMenu->addAction (a);
964 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
965 actionFormatBackColor=a;
967 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
968 a->setStatusTip (tr( "Set Background image" ));
969 formatMenu->addAction (a);
970 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
971 actionFormatBackImage=a;
975 void Main::setupViewActions()
977 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
978 tb->setLabel( "View Actions" );
979 tb->setObjectName ("viewTB");
980 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
983 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
984 a->setStatusTip ( tr( "Zoom reset" ) );
985 a->setShortcut (Qt::CTRL + Qt::Key_0 );
987 viewMenu->addAction (a);
988 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
990 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
991 a->setStatusTip (tr( "Zoom in" ));
992 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
994 viewMenu->addAction (a);
995 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
997 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
998 a->setStatusTip (tr( "Zoom out" ));
999 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
1001 viewMenu->addAction (a);
1002 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1004 a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
1005 a->setStatusTip (tr( "Show selection" ));
1006 a->setShortcut (Qt::Key_Period);
1008 viewMenu->addAction (a);
1009 connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
1011 viewMenu->addSeparator();
1013 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
1014 a->setStatusTip ( tr( "Show Note Editor" ));
1015 a->setShortcut ( Qt::CTRL + Qt::Key_E );
1016 a->setToggleAction(true);
1018 viewMenu->addAction (a);
1019 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1020 actionViewToggleNoteEditor=a;
1022 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
1023 a->setStatusTip ( tr( "Show History Window" ));
1024 a->setShortcut ( Qt::CTRL + Qt::Key_H );
1025 a->setToggleAction(true);
1027 viewMenu->addAction (a);
1028 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1029 actionViewToggleHistoryWindow=a;
1031 viewMenu->addAction (actionViewTogglePropertyWindow);
1033 viewMenu->addSeparator();
1035 a = new QAction(tr( "Antialiasing","View action" ),this );
1036 a->setStatusTip ( tr( "Antialiasing" ));
1037 a->setToggleAction(true);
1038 a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
1039 viewMenu->addAction (a);
1040 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
1041 actionViewToggleAntiAlias=a;
1043 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1044 a->setStatusTip (a->text());
1045 a->setToggleAction(true);
1046 a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1047 viewMenu->addAction (a);
1048 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1049 actionViewToggleSmoothPixmapTransform=a;
1051 a = new QAction(tr( "Next Map","View action" ), this);
1052 a->setStatusTip (a->text());
1053 a->setShortcut (Qt::ALT + Qt::Key_N );
1054 viewMenu->addAction (a);
1055 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1057 a = new QAction (tr( "Previous Map","View action" ), this );
1058 a->setStatusTip (a->text());
1059 a->setShortcut (Qt::ALT + Qt::Key_P );
1060 viewMenu->addAction (a);
1061 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1065 void Main::setupModeActions()
1067 //QPopupMenu *menu = new QPopupMenu( this );
1068 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1070 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1071 tb->setObjectName ("modesTB");
1073 actionGroupModModes=new QActionGroup ( this);
1074 actionGroupModModes->setExclusive (true);
1075 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1076 a->setShortcut (Qt::Key_J);
1077 a->setStatusTip ( tr( "Use modifier to color branches" ));
1078 a->setToggleAction(true);
1081 actionModModeColor=a;
1083 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1084 a->setShortcut( Qt::Key_K);
1085 a->setStatusTip( tr( "Use modifier to copy" ));
1086 a->setToggleAction(true);
1088 actionModModeCopy=a;
1090 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1091 a->setShortcut (Qt::Key_L);
1092 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1093 a->setToggleAction(true);
1095 actionModModeXLink=a;
1099 void Main::setupFlagActions()
1101 // Create System Flags
1105 systemFlagsDefault = new FlagRowObj ();
1106 systemFlagsDefault->setVisibility (false);
1107 systemFlagsDefault->setName ("systemFlagsDef");
1109 FlagObj *fo = new FlagObj ();
1110 fo->load(QPixmap(flagsPath+"flag-note.png"));
1111 setupFlag (fo,tb,avis,"note",tr("Note","SystemFlag"));
1113 fo->load(QPixmap(flagsPath+"flag-url.png"));
1114 setupFlag (fo,tb,avis,"url",tr("URL to Document ","SystemFlag"));
1116 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1117 setupFlag (fo,tb,avis,"vymLink",tr("Link to another vym map","SystemFlag"));
1119 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1120 setupFlag (fo,tb,avis,"scrolledright",tr("subtree is scrolled","SystemFlag"));
1122 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1123 setupFlag (fo,tb,avis,"tmpUnscrolledright",tr("subtree is temporary scrolled","SystemFlag"));
1125 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1126 setupFlag (fo,tb,avis,"hideInExport",tr("Hide object in exported maps","SystemFlag"));
1128 // Create Standard Flags
1129 tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1130 tb->setObjectName ("standardFlagTB");
1132 standardFlagsDefault = new FlagRowObj ();
1133 standardFlagsDefault->setVisibility (false);
1134 standardFlagsDefault->setName ("standardFlagsDef");
1135 standardFlagsDefault->setToolBar (tb);
1137 fo->load(flagsPath+"flag-exclamationmark.png");
1138 fo->setGroup("standard-mark");
1139 setupFlag (fo,tb,avis,"exclamationmark",tr("Take care!","Standardflag"));
1141 fo->load(flagsPath+"flag-questionmark.png");
1142 fo->setGroup("standard-mark");
1143 setupFlag (fo,tb,avis,"questionmark",tr("Really?","Standardflag"));
1145 fo->load(flagsPath+"flag-hook-green.png");
1146 fo->setGroup("standard-hook");
1147 setupFlag (fo,tb,avis,"hook-green",tr("ok!","Standardflag"));
1149 fo->load(flagsPath+"flag-cross-red.png");
1150 fo->setGroup("standard-hook");
1151 setupFlag (fo,tb,avis,"cross-red",tr("Not ok!","Standardflag"));
1154 fo->load(flagsPath+"flag-stopsign.png");
1155 setupFlag (fo,tb,avis,"stopsign",tr("This won't work!","Standardflag"));
1157 fo->load(flagsPath+"flag-smiley-good.png");
1158 fo->setGroup("standard-smiley");
1159 setupFlag (fo,tb,avis,"smiley-good",tr("Good","Standardflag"));
1161 fo->load(flagsPath+"flag-smiley-sad.png");
1162 fo->setGroup("standard-smiley");
1163 setupFlag (fo,tb,avis,"smiley-sad",tr("Bad","Standardflag"));
1165 fo->load(flagsPath+"flag-smiley-omg.png");
1166 fo->setGroup("standard-smiley");
1167 setupFlag (fo,tb,avis,"smiley-omb",tr("Oh no!","Standardflag"));
1168 // Original omg.png (in KDE emoticons)
1171 fo->load(flagsPath+"flag-kalarm.png");
1172 setupFlag (fo,tb,avis,"clock",tr("Time critical","Standardflag"));
1174 fo->load(flagsPath+"flag-phone.png");
1175 setupFlag (fo,tb,avis,"phone",tr("Call...","Standardflag"));
1177 fo->load(flagsPath+"flag-lamp.png");
1178 setupFlag (fo,tb,avis,"lamp",tr("Idea!","Standardflag"));
1180 fo->load(flagsPath+"flag-arrow-up.png");
1181 fo->setGroup("standard-arrow");
1182 setupFlag (fo,tb,avis,"arrow-up",tr("Important","Standardflag"));
1184 fo->load(flagsPath+"flag-arrow-down.png");
1185 fo->setGroup("standard-arrow");
1186 setupFlag (fo,tb,avis,"arrow-down",tr("Unimportant","Standardflag"));
1188 fo->load(flagsPath+"flag-arrow-2up.png");
1189 fo->setGroup("standard-arrow");
1190 setupFlag (fo,tb,avis,"2arrow-up",tr("Very important!","Standardflag"));
1192 fo->load(flagsPath+"flag-arrow-2down.png");
1193 fo->setGroup("standard-arrow");
1194 setupFlag (fo,tb,avis,"present",tr("Very unimportant!","Standardflag"));
1197 fo->load(flagsPath+"flag-thumb-up.png");
1198 fo->setGroup("standard-thumb");
1199 setupFlag (fo,tb,avis,"thumb-up",tr("I like this","Standardflag"));
1201 fo->load(flagsPath+"flag-thumb-down.png");
1202 fo->setGroup("standard-thumb");
1203 setupFlag (fo,tb,avis,"thumb-down",tr("I do not like this","Standardflag"));
1206 fo->load(flagsPath+"flag-rose.png");
1207 setupFlag (fo,tb,avis,"rose",tr("Rose","Standardflag"));
1209 fo->load(flagsPath+"flag-heart.png");
1210 setupFlag (fo,tb,avis,"heart",tr("I just love...","Standardflag"));
1212 fo->load(flagsPath+"flag-present.png");
1213 setupFlag (fo,tb,avis,"present",tr("Surprise!","Standardflag"));
1215 fo->load(flagsPath+"flag-flash.png");
1216 setupFlag (fo,tb,avis,"flash",tr("Dangerous","Standardflag"));
1218 // Original: xsldbg_output.png
1219 fo->load(flagsPath+"flag-info.png");
1220 setupFlag (fo,tb,avis,"info",tr("Info","Standardflag"));
1222 // Original khelpcenter.png
1223 fo->load(flagsPath+"flag-lifebelt.png");
1224 setupFlag (fo,tb,avis,"lifebelt",tr("This will help","Standardflag"));
1230 fo->load(flagsPath+"freemind/warning.png");
1231 setupFlag (fo,tb, avis, "freemind-warning",tr("Important","Freemind-Flag"));
1233 for (int i=1; i<8; i++)
1235 fo->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
1236 setupFlag (fo,tb, avis,QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
1239 fo->load(flagsPath+"freemind/back.png");
1240 setupFlag (fo,tb,avis,"freemind-back",tr("Back","Freemind-Flag"));
1242 fo->load(flagsPath+"freemind/forward.png");
1243 setupFlag (fo,tb,avis,"freemind-forward",tr("Forward","Freemind-Flag"));
1245 fo->load(flagsPath+"freemind/attach.png");
1246 setupFlag (fo,tb,avis,"freemind-attach",tr("Look here","Freemind-Flag"));
1248 fo->load(flagsPath+"freemind/clanbomber.png");
1249 setupFlag (fo,tb,avis,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
1251 fo->load(flagsPath+"freemind/desktopnew.png");
1252 setupFlag (fo,tb,avis,"freemind-desktopnew",tr("Don't forget","Freemind-Flag"));
1254 fo->load(flagsPath+"freemind/flag.png");
1255 setupFlag (fo,tb,avis,"freemind-flag",tr("Flag","Freemind-Flag"));
1258 fo->load(flagsPath+"freemind/gohome.png");
1259 setupFlag (fo,tb,avis,"freemind-gohome",tr("Home","Freemind-Flag"));
1262 fo->load(flagsPath+"freemind/kaddressbook.png");
1263 setupFlag (fo,tb,avis,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
1265 fo->load(flagsPath+"freemind/knotify.png");
1266 setupFlag (fo,tb,avis,"freemind-knotify",tr("Music","Freemind-Flag"));
1268 fo->load(flagsPath+"freemind/korn.png");
1269 setupFlag (fo,tb,avis,"freemind-korn",tr("Mailbox","Freemind-Flag"));
1271 fo->load(flagsPath+"freemind/mail.png");
1272 setupFlag (fo,tb,avis,"freemind-mail",tr("Maix","Freemind-Flag"));
1274 fo->load(flagsPath+"freemind/password.png");
1275 setupFlag (fo,tb,avis,"freemind-password",tr("Password","Freemind-Flag"));
1277 fo->load(flagsPath+"freemind/pencil.png");
1278 setupFlag (fo,tb,avis,"freemind-pencil",tr("To be improved","Freemind-Flag"));
1280 fo->load(flagsPath+"freemind/stop.png");
1281 setupFlag (fo,tb,avis,"freemind-stop",tr("Stop","Freemind-Flag"));
1283 fo->load(flagsPath+"freemind/wizard.png");
1284 setupFlag (fo,tb,avis,"freemind-wizard",tr("Magic","Freemind-Flag"));
1286 fo->load(flagsPath+"freemind/xmag.png");
1287 setupFlag (fo,tb,avis,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
1289 fo->load(flagsPath+"freemind/bell.png");
1290 setupFlag (fo,tb,avis,"freemind-bell",tr("Reminder","Freemind-Flag"));
1292 fo->load(flagsPath+"freemind/bookmark.png");
1293 setupFlag (fo,tb,avis,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
1295 fo->load(flagsPath+"freemind/penguin.png");
1296 setupFlag (fo,tb,avis,"freemind-penguin",tr("Linux","Freemind-Flag"));
1298 fo->load(flagsPath+"freemind/licq.png");
1299 setupFlag (fo,tb,avis,"freemind-licq",tr("Sweet","Freemind-Flag"));
1304 void Main::setupFlag (FlagObj *fo, QToolBar *tb, bool aw, const QString &name, const QString &tooltip)
1307 fo->setToolTip (tooltip);
1308 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1314 fo->setAlwaysVisible(aw);
1315 a->setCheckable(true);
1316 a->setObjectName(fo->getName());
1317 a->setToolTip(tooltip);
1318 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1319 standardFlagsDefault->addFlag (fo);
1323 systemFlagsDefault->addFlag (fo);
1327 void Main::setupNetworkActions()
1329 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1331 QMenu *netMenu = menuBar()->addMenu( "&Network" );
1335 a = new QAction( "Start TCPserver for MapEditor",this);
1336 //a->setStatusTip ( "Set application to open pdf files"));
1337 a->setShortcut ( Qt::Key_T ); //New TCP server
1338 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1339 netMenu->addAction (a);
1341 a = new QAction( "Connect MapEditor to server",this);
1342 //a->setStatusTip ( "Set application to open pdf files"));
1343 a->setShortcut ( Qt::Key_C ); // Connect to server
1344 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1345 netMenu->addAction (a);
1349 void Main::setupSettingsActions()
1351 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1355 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1356 a->setStatusTip ( tr( "Set application to open pdf files"));
1357 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1358 settingsMenu->addAction (a);
1360 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1361 a->setStatusTip( tr( "Set application to open external links"));
1362 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1363 settingsMenu->addAction (a);
1365 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1366 a->setStatusTip( tr( "Set path for macros"));
1367 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1368 settingsMenu->addAction (a);
1370 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1371 a->setStatusTip( tr( "Set number of undo levels"));
1372 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1373 settingsMenu->addAction (a);
1375 settingsMenu->addSeparator();
1377 a = new QAction( tr( "Autosave","Settings action"), this);
1378 a->setStatusTip( tr( "Autosave"));
1379 a->setToggleAction(true);
1380 a->setOn ( settings.value ("/mapeditor/autosave/use",true).toBool());
1381 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1382 settingsMenu->addAction (a);
1383 actionSettingsAutosaveToggle=a;
1385 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1386 a->setStatusTip( tr( "Autosave time"));
1387 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1388 settingsMenu->addAction (a);
1389 actionSettingsAutosaveTime=a;
1391 settingsMenu->addSeparator();
1393 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1394 a->setStatusTip( tr( "Edit branch after adding it" ));
1395 a->setToggleAction(true);
1396 a->setOn ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1397 settingsMenu->addAction (a);
1398 actionSettingsAutoEditNewBranch=a;
1400 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1401 a->setStatusTip( tr( "Select branch after adding it" ));
1402 a->setToggleAction(true);
1403 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1404 settingsMenu->addAction (a);
1405 actionSettingsAutoSelectNewBranch=a;
1407 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1408 a->setStatusTip( tr( "Select heading before editing" ));
1409 a->setToggleAction(true);
1410 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1411 settingsMenu->addAction (a);
1412 actionSettingsAutoSelectText=a;
1414 a= new QAction( tr( "Delete key","Settings action" ), this);
1415 a->setStatusTip( tr( "Delete key for deleting branches" ));
1416 a->setToggleAction(true);
1417 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1418 settingsMenu->addAction (a);
1419 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1420 actionSettingsUseDelKey=a;
1422 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1423 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1424 a->setToggleAction(true);
1425 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1426 settingsMenu->addAction (a);
1427 actionSettingsUseFlagGroups=a;
1429 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1430 a->setStatusTip( tr( "Use hide flag during exports " ));
1431 a->setToggleAction(true);
1432 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1433 settingsMenu->addAction (a);
1434 actionSettingsUseHideExport=a;
1438 void Main::setupTestActions()
1440 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1443 a = new QAction( "Test function 1" , this);
1444 a->setStatusTip( "Call test function 1" );
1445 testMenu->addAction (a);
1446 //a->setShortcut (Qt::Key_F4 );
1447 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1449 a = new QAction( "Test function 2" , this);
1450 a->setStatusTip( "Call test function 2" );
1451 //a->setShortcut (Qt::Key_F4 );
1452 testMenu->addAction (a);
1453 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1455 a = new QAction( "Command" , this);
1456 a->setStatusTip( "Enter command to call in editor" );
1457 //a->setShortcut (Qt::Key_F5 );
1458 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1459 testMenu->addAction (a);
1463 void Main::setupHelpActions()
1465 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1468 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1469 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1470 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1471 helpMenu->addAction (a);
1473 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1474 a->setStatusTip( tr( "Open VYM example maps " ));
1475 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1476 helpMenu->addAction (a);
1478 a = new QAction( tr( "About VYM","Help action" ), this);
1479 a->setStatusTip( tr( "About VYM")+vymName);
1480 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1481 helpMenu->addAction (a);
1483 a = new QAction( tr( "About QT","Help action" ), this);
1484 a->setStatusTip( tr( "Information about QT toolkit" ));
1485 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1486 helpMenu->addAction (a);
1490 void Main::setupContextMenus()
1494 // Context Menu for branch or mapcenter
1495 branchContextMenu =new QMenu (this);
1496 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1497 branchContextMenu->addSeparator();
1500 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1501 branchAddContextMenu->addAction (actionEditPaste );
1502 branchAddContextMenu->addAction ( actionEditAddBranch );
1503 branchAddContextMenu->addAction ( actionEditAddBranchBefore );
1504 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1505 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1506 branchAddContextMenu->addSeparator();
1507 branchAddContextMenu->addAction ( actionEditImportAdd );
1508 branchAddContextMenu->addAction ( actionEditImportReplace );
1511 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1512 branchRemoveContextMenu->addAction (actionEditCut);
1513 branchRemoveContextMenu->addAction ( actionEditDelete );
1514 branchRemoveContextMenu->addAction ( actionEditDeleteKeepChilds );
1515 branchRemoveContextMenu->addAction ( actionEditDeleteChilds );
1518 actionEditSaveBranch->addTo( branchContextMenu );
1520 branchContextMenu->addSeparator();
1521 branchContextMenu->addAction ( actionEditLoadImage);
1523 // Submenu for Links (URLs, vymLinks)
1524 branchLinksContextMenu =new QMenu (this);
1526 branchContextMenu->addSeparator();
1527 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1528 branchLinksContextMenu->addAction ( actionEditOpenURL );
1529 branchLinksContextMenu->addAction ( actionEditOpenURLTab );
1530 branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
1531 branchLinksContextMenu->addAction ( actionEditURL );
1532 branchLinksContextMenu->addAction ( actionEditLocalURL );
1533 branchLinksContextMenu->addAction ( actionEditHeading2URL );
1534 branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
1535 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1537 branchLinksContextMenu->addAction ( actionEditFATE2URL );
1539 branchLinksContextMenu->addSeparator();
1540 branchLinksContextMenu->addAction ( actionEditOpenVymLink );
1541 branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
1542 branchLinksContextMenu->addAction ( actionEditVymLink );
1543 branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
1546 // Context Menu for XLinks in a branch menu
1547 // This will be populated "on demand" in MapEditor::updateActions
1548 branchContextMenu->addSeparator();
1549 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1550 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1551 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1552 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1555 // Context menu for floatimage
1556 floatimageContextMenu =new QMenu (this);
1557 a= new QAction (tr ("Save image","Context action"),this);
1558 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1559 floatimageContextMenu->addAction (a);
1561 floatimageContextMenu->addSeparator();
1562 actionEditCopy->addTo( floatimageContextMenu );
1563 actionEditCut->addTo( floatimageContextMenu );
1565 floatimageContextMenu->addSeparator();
1566 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1569 // Context menu for canvas
1570 canvasContextMenu =new QMenu (this);
1571 actionEditMapInfo->addTo( canvasContextMenu );
1572 canvasContextMenu->insertSeparator();
1573 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1574 canvasContextMenu->insertSeparator();
1575 actionFormatLinkColorHint->addTo( canvasContextMenu );
1576 actionFormatLinkColor->addTo( canvasContextMenu );
1577 actionFormatSelectionColor->addTo( canvasContextMenu );
1578 actionFormatBackColor->addTo( canvasContextMenu );
1579 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME makes vym too slow: postponed for later version
1581 // Menu for last opened files
1583 for (int i = 0; i < MaxRecentFiles; ++i)
1585 recentFileActions[i] = new QAction(this);
1586 recentFileActions[i]->setVisible(false);
1587 fileLastMapsMenu->addAction(recentFileActions[i]);
1588 connect(recentFileActions[i], SIGNAL(triggered()),
1589 this, SLOT(fileLoadRecent()));
1591 setupRecentMapsMenu();
1594 void Main::setupRecentMapsMenu()
1596 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1598 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1600 for (int i = 0; i < numRecentFiles; ++i) {
1601 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1602 recentFileActions[i]->setText(text);
1603 recentFileActions[i]->setData(files[i]);
1604 recentFileActions[i]->setVisible(true);
1606 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1607 recentFileActions[j]->setVisible(false);
1610 void Main::setupMacros()
1612 for (int i = 0; i <= 11; i++)
1614 macroActions[i] = new QAction(this);
1615 macroActions[i]->setData(i);
1616 addAction (macroActions[i]);
1617 connect(macroActions[i], SIGNAL(triggered()),
1618 this, SLOT(callMacro()));
1620 macroActions[0]->setShortcut ( Qt::Key_F1 );
1621 macroActions[1]->setShortcut ( Qt::Key_F2 );
1622 macroActions[2]->setShortcut ( Qt::Key_F3 );
1623 macroActions[3]->setShortcut ( Qt::Key_F4 );
1624 macroActions[4]->setShortcut ( Qt::Key_F5 );
1625 macroActions[5]->setShortcut ( Qt::Key_F6 );
1626 macroActions[6]->setShortcut ( Qt::Key_F7 );
1627 macroActions[7]->setShortcut ( Qt::Key_F8 );
1628 macroActions[8]->setShortcut ( Qt::Key_F9 );
1629 macroActions[9]->setShortcut ( Qt::Key_F10 );
1630 macroActions[10]->setShortcut ( Qt::Key_F11 );
1631 macroActions[11]->setShortcut ( Qt::Key_F12 );
1634 void Main::hideEvent (QHideEvent * )
1636 if (!textEditor->isMinimized() ) textEditor->hide();
1639 void Main::showEvent (QShowEvent * )
1641 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1645 MapEditor* Main::currentMapEditor() const
1647 if ( tabWidget->currentPage() &&
1648 tabWidget->currentPage()->inherits( "MapEditor" ) )
1649 return (MapEditor*)tabWidget->currentPage();
1654 void Main::editorChanged(QWidget *)
1656 // Unselect all possibly selected objects
1657 // (Important to update note editor)
1659 for (int i=0;i<=tabWidget->count() -1;i++)
1662 me=(MapEditor*)tabWidget->page(i);
1665 currentMapEditor()->reselect();
1667 // Update actions to in menus and toolbars according to editor
1671 void Main::fileNew()
1673 QString fn="unnamed";
1674 MapEditor* me = new MapEditor ( NULL);
1675 tabWidget->addTab (me,fn);
1676 tabWidget->showPage(me);
1677 me->viewport()->setFocus();
1678 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1679 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1681 // For the very first map we do not have flagrows yet...
1685 void Main::fileNewCopy()
1687 QString fn="unnamed";
1688 MapEditor* oldME =currentMapEditor();
1692 MapEditor* newME = new MapEditor ( NULL);
1695 tabWidget->addTab (newME,fn);
1696 tabWidget->showPage(newME);
1697 newME->viewport()->setFocus();
1698 newME->setAntiAlias (actionViewToggleAntiAlias->isOn());
1699 newME->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1700 // For the very first map we do not have flagrows yet...
1701 newME->select("mc:");
1702 newME->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
1708 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
1710 ErrorCode err=success;
1712 // fn is usually the archive, mapfile the file after uncompressing
1715 // Make fn absolute (needed for unzip)
1716 fn=QDir (fn).absPath();
1722 // Check, if map is already loaded
1724 while (i<=tabWidget->count() -1)
1726 me=(MapEditor*)tabWidget->page(i);
1727 if (me->getFilePath() == fn)
1729 // Already there, ask for confirmation
1730 QMessageBox mb( vymName,
1731 tr("The map %1\nis already opened."
1732 "Opening the same map in multiple editors may lead \n"
1733 "to confusion when finishing working with vym."
1734 "Do you want to").arg(fn),
1735 QMessageBox::Warning,
1736 QMessageBox::Yes | QMessageBox::Default,
1737 QMessageBox::Cancel | QMessageBox::Escape,
1738 QMessageBox::NoButton);
1739 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1740 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1743 case QMessageBox::Yes:
1745 i=tabWidget->count();
1747 case QMessageBox::Cancel:
1759 if ( !fn.isEmpty() )
1761 me = currentMapEditor();
1762 int tabIndex=tabWidget->currentPageIndex();
1763 // Check first, if mapeditor exists
1764 // If it is not default AND we want a new map,
1765 // create a new mapeditor in a new tab
1766 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1768 me= new MapEditor ( NULL);
1769 tabWidget->addTab (me,fn);
1770 tabIndex=tabWidget->indexOf (me);
1771 tabWidget->setCurrentPage (tabIndex);
1772 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1773 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1776 // Check, if file exists (important for creating new files
1777 // from command line
1778 if (!QFile(fn).exists() )
1780 QMessageBox mb( vymName,
1781 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1782 QMessageBox::Question,
1784 QMessageBox::Cancel | QMessageBox::Default,
1785 QMessageBox::NoButton );
1787 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1788 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1791 case QMessageBox::Yes:
1793 currentMapEditor()->setFilePath(fn);
1794 tabWidget->setTabLabel (currentMapEditor(),
1795 currentMapEditor()->getFileName() );
1796 statusBar()->message( "Created " + fn , statusbarTime );
1799 case QMessageBox::Cancel:
1800 // don't create new map
1801 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1808 //tabWidget->currentPage() won't be NULL here, because of above...
1809 tabWidget->showPage(me);
1810 me->viewport()->setFocus();
1812 // Create temporary directory for packing
1814 QString tmpMapDir=makeTmpDir (ok,"vym-pack");
1817 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1818 tr("Couldn't create temporary directory before load\n"));
1822 // Try to unzip file
1823 err=unzipDir (tmpMapDir,fn);
1827 me->setZipped(false);
1830 me->setZipped(true);
1832 // Look for mapname.xml
1833 mapfile= fn.left(fn.findRev(".",-1,true));
1834 mapfile=mapfile.section( '/', -1 );
1835 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1836 if (!file.exists() )
1838 // mapname.xml does not exist, well,
1839 // maybe someone renamed the mapname.vym file...
1840 // Try to find any .xml in the toplevel
1841 // directory of the .vym file
1842 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1843 if (flist.count()==1)
1845 // Only one entry, take this one
1846 mapfile=tmpMapDir + "/"+flist.first();
1849 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1850 *it=tmpMapDir + "/" + *it;
1851 // TODO Multiple entries, load all (but only the first one into this ME)
1852 //mainWindow->fileLoadFromTmp (flist);
1853 //returnCode=1; // Silently forget this attempt to load
1854 qWarning ("MainWindow::load (fn) multimap found...");
1857 if (flist.isEmpty() )
1859 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1860 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1863 } //file doesn't exist
1865 mapfile=file.name();
1870 // Save existing filename in case we import
1871 QString fn_org=me->getFilePath();
1873 // Finally load map into mapEditor
1874 me->setFilePath (mapfile,fn);
1875 err=me->load(mapfile,lmode,ftype);
1877 // Restore old (maybe empty) filepath, if this is an import
1879 me->setFilePath (fn_org);
1882 // Finally check for errors and go home
1885 if (lmode==NewMap) fileCloseMap();
1886 statusBar()->message( "Could not load " + fn, statusbarTime );
1891 me->setFilePath (fn);
1892 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1893 if (!isInTmpDir (fn))
1895 // Only append to lastMaps if not loaded from a tmpDir
1896 // e.g. imported bookmarks are in a tmpDir
1897 addRecentMap(me->getFilePath() );
1899 actionFilePrint->setEnabled (true);
1901 statusBar()->message( "Loaded " + fn, statusbarTime );
1905 removeDir (QDir(tmpMapDir));
1911 void Main::fileLoad(const LoadMode &lmode)
1913 QStringList filters;
1914 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1915 QFileDialog *fd=new QFileDialog( this);
1916 fd->setDir (lastFileDir);
1917 fd->setFileMode (QFileDialog::ExistingFiles);
1918 fd->setFilters (filters);
1922 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1925 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1928 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1934 if ( fd->exec() == QDialog::Accepted )
1936 lastFileDir=fd->directory().path();
1937 QStringList flist = fd->selectedFiles();
1938 QStringList::Iterator it = flist.begin();
1939 while( it != flist.end() )
1942 fileLoad(*it, lmode);
1949 void Main::fileLoad()
1954 void Main::fileLoadRecent()
1956 QAction *action = qobject_cast<QAction *>(sender());
1958 fileLoad (action->data().toString(), NewMap);
1961 void Main::addRecentMap (const QString &fileName)
1964 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1965 files.removeAll(fileName);
1966 files.prepend(fileName);
1967 while (files.size() > MaxRecentFiles)
1970 settings.setValue("/mainwindow/recentFileList", files);
1972 setupRecentMapsMenu();
1975 void Main::fileSave(MapEditor *me, const SaveMode &savemode)
1977 // tmp dir for zipping
1981 ErrorCode err=success;
1983 QString safeFilePath;
1985 bool saveZipped=me->saveZipped();
1989 QString fn=me->getFilePath();
1990 // filename=unnamed, filepath="" in constructor of mapEditor
1991 if ( !fn.isEmpty() )
1993 // We have a filepath, go on saving
1994 // First remove existing file, we
1995 // don't want to add to old zip archives
1999 QMessageBox::warning( 0, tr( "Save Error" ),
2000 fn+ tr("\ncould not be removed before saving"));
2002 // Look, if we should zip the data:
2005 QMessageBox mb( vymName,
2006 tr("The map %1\ndid not use the compressed "
2007 "vym file format.\nWriting it uncompressed will also write images \n"
2008 "and flags and thus may overwrite files in the "
2009 "given directory\n\nDo you want to write the map").arg(fn),
2010 QMessageBox::Warning,
2011 QMessageBox::Yes | QMessageBox::Default,
2013 QMessageBox::Cancel | QMessageBox::Escape);
2014 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
2015 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
2016 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2019 case QMessageBox::Yes:
2020 // save compressed (default file format)
2023 case QMessageBox::No:
2024 // save uncompressed
2027 case QMessageBox::Cancel:
2036 // Create temporary directory for packing
2038 QString tmpMapDir=makeTmpDir (ok,"vym-zip");
2041 QMessageBox::critical( 0, tr( "Critical Load Error" ),
2042 tr("Couldn't create temporary directory before save\n"));
2046 safeFilePath=me->getFilePath();
2047 me->setFilePath (tmpMapDir+"/"+
2048 me->getMapName()+ ".xml",
2050 me->save (savemode);
2051 me->setFilePath (safeFilePath);
2053 zipDir (tmpMapDir,fn);
2058 safeFilePath=me->getFilePath();
2059 me->setFilePath (fn, safeFilePath);
2060 me->save (savemode);
2061 me->setFilePath (safeFilePath);
2063 } // filepath available
2066 // We have no filepath yet,
2067 // call fileSaveAs() now, this will call fileSave()
2069 // First switch to editor
2070 tabWidget->setCurrentWidget (me);
2071 fileSaveAs(savemode);
2075 if (saveZipped && !tmpMapDir.isEmpty())
2077 removeDir (QDir(tmpMapDir));
2081 statusBar()->message(
2082 tr("Saved %1").arg(me->getFilePath()),
2084 addRecentMap (me->getFilePath() );
2086 statusBar()->message(
2087 tr("Couldn't save ").arg(me->getFilePath()),
2091 void Main::fileSave()
2093 fileSave (currentMapEditor(), CompleteMap);
2096 void Main::fileSave(MapEditor *me)
2098 fileSave (me,CompleteMap);
2101 void Main::fileSaveAs(const SaveMode& savemode)
2105 if (currentMapEditor())
2107 if (savemode==CompleteMap)
2108 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2110 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2111 if ( !fn.isEmpty() )
2113 // Check for existing file
2114 if (QFile (fn).exists())
2116 QMessageBox mb( vymName,
2117 tr("The file %1\nexists already. Do you want to").arg(fn),
2118 QMessageBox::Warning,
2119 QMessageBox::Yes | QMessageBox::Default,
2120 QMessageBox::Cancel | QMessageBox::Escape,
2121 QMessageBox::NoButton);
2122 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2123 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2126 case QMessageBox::Yes:
2129 case QMessageBox::Cancel:
2136 // New file, add extension to filename, if missing
2137 // This is always .vym or .vyp, depending on savemode
2138 if (savemode==CompleteMap)
2140 if (!fn.contains (".vym") && !fn.contains (".xml"))
2144 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2153 currentMapEditor()->setFilePath(fn);
2154 fileSave(currentMapEditor(), savemode);
2157 if (savemode==CompleteMap)
2158 tabWidget->setTabLabel (currentMapEditor(),
2159 currentMapEditor()->getFileName() );
2165 void Main::fileSaveAs()
2167 fileSaveAs (CompleteMap);
2170 void Main::fileImportKDEBookmarks()
2172 ImportKDEBookmarks im;
2174 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2175 currentMapEditor()->setFilePath ("");
2178 void Main::fileImportFirefoxBookmarks()
2180 Q3FileDialog *fd=new Q3FileDialog( this);
2181 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2182 fd->setMode (Q3FileDialog::ExistingFiles);
2183 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2184 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2187 if ( fd->exec() == QDialog::Accepted )
2189 ImportFirefoxBookmarks im;
2190 QStringList flist = fd->selectedFiles();
2191 QStringList::Iterator it = flist.begin();
2192 while( it != flist.end() )
2195 if (im.transform() &&
2196 success==fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2197 currentMapEditor() )
2198 currentMapEditor()->setFilePath ("");
2205 void Main::fileImportFreemind()
2207 QStringList filters;
2208 filters <<"Freemind map (*.mm)"<<"All files (*)";
2209 QFileDialog *fd=new QFileDialog( this);
2210 fd->setDir (lastFileDir);
2211 fd->setFileMode (QFileDialog::ExistingFiles);
2212 fd->setFilters (filters);
2213 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2217 if ( fd->exec() == QDialog::Accepted )
2219 lastFileDir=fd->directory().path();
2220 QStringList flist = fd->selectedFiles();
2221 QStringList::Iterator it = flist.begin();
2222 while( it != flist.end() )
2225 if ( fileLoad (fn,NewMap, FreemindMap) )
2227 currentMapEditor()->setFilePath ("");
2236 void Main::fileImportMM()
2240 Q3FileDialog *fd=new Q3FileDialog( this);
2241 fd->setDir (lastFileDir);
2242 fd->setMode (Q3FileDialog::ExistingFiles);
2243 fd->addFilter ("Mind Manager (*.mmap)");
2244 fd->setCaption(tr("Import")+" "+"Mind Manager");
2247 if ( fd->exec() == QDialog::Accepted )
2249 lastFileDir=fd->dirPath();
2250 QStringList flist = fd->selectedFiles();
2251 QStringList::Iterator it = flist.begin();
2252 while( it != flist.end() )
2255 if (im.transform() &&
2256 success==fileLoad (im.getTransformedFile(),NewMap) &&
2257 currentMapEditor() )
2258 currentMapEditor()->setFilePath ("");
2267 void Main::fileImportDir()
2269 if (currentMapEditor())
2270 currentMapEditor()->importDir();
2273 void Main::fileExportXML()
2275 MapEditor *me=currentMapEditor();
2276 if (me) me->exportXML();
2280 void Main::fileExportXHTML()
2282 MapEditor *me=currentMapEditor();
2283 if (me) me->exportXHTML();
2286 void Main::fileExportImage()
2288 MapEditor *me=currentMapEditor();
2289 if (me) me->exportImage();
2292 void Main::fileExportASCII()
2294 MapEditor *me=currentMapEditor();
2295 if (me) me->exportASCII();
2298 void Main::fileExportCSV() //FIXME not scriptable yet
2300 MapEditor *me=currentMapEditor();
2304 ex.setMapCenter(me->getMapCenter());
2305 ex.addFilter ("CSV (*.csv)");
2306 ex.setDir(lastImageDir);
2307 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2308 if (ex.execDialog() )
2310 me->setExportMode(true);
2312 me->setExportMode(false);
2317 void Main::fileExportLaTeX() //FIXME not scriptable yet
2319 MapEditor *me=currentMapEditor();
2323 ex.setMapCenter(me->getMapCenter());
2324 ex.addFilter ("Tex (*.tex)");
2325 ex.setDir(lastImageDir);
2326 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2327 if (ex.execDialog() )
2329 me->setExportMode(true);
2331 me->setExportMode(false);
2336 void Main::fileExportKDEBookmarks() //FIXME not scriptable yet
2338 ExportKDEBookmarks ex;
2339 MapEditor *me=currentMapEditor();
2342 ex.setMapCenter (me->getMapCenter() );
2347 void Main::fileExportTaskjuggler() //FIXME not scriptable yet
2349 ExportTaskjuggler ex;
2350 MapEditor *me=currentMapEditor();
2353 ex.setMapCenter (me->getMapCenter() );
2354 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2355 ex.setDir(lastImageDir);
2356 ex.addFilter ("Taskjuggler (*.tjp)");
2357 if (ex.execDialog() )
2359 me->setExportMode(true);
2361 me->setExportMode(false);
2366 void Main::fileExportOOPresentation() //FIXME not scriptable yet
2368 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2369 // TODO add preview in dialog
2370 //ImagePreview *p =new ImagePreview (fd);
2371 //fd->setContentsPreviewEnabled( TRUE );
2372 //fd->setContentsPreview( p, p );
2373 //fd->setPreviewMode( QFileDialog::Contents );
2374 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2375 fd->setDir (QDir().current());
2376 if (fd->foundConfig())
2380 if ( fd->exec() == QDialog::Accepted )
2382 QString fn=fd->selectedFile();
2383 if (!fn.contains (".odp"))
2386 //lastImageDir=fn.left(fn.findRev ("/"));
2387 if (currentMapEditor())
2388 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2392 QMessageBox::warning(0,
2394 tr("Couldn't find configuration for export to Open Office\n"));
2398 void Main::fileCloseMap()
2400 if (currentMapEditor())
2402 if (currentMapEditor()->hasChanged())
2404 QMessageBox mb( vymName,
2405 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2406 QMessageBox::Warning,
2407 QMessageBox::Yes | QMessageBox::Default,
2409 QMessageBox::Cancel | QMessageBox::Escape );
2410 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2411 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2414 case QMessageBox::Yes:
2416 fileSave(currentMapEditor(), CompleteMap);
2418 case QMessageBox::No:
2419 // close without saving
2421 case QMessageBox::Cancel:
2426 currentMapEditor()->closeMap();
2427 tabWidget->removePage(currentMapEditor());
2428 if (tabWidget->count()==0)
2429 actionFilePrint->setEnabled (false);
2433 void Main::filePrint()
2435 if (currentMapEditor())
2436 currentMapEditor()->print();
2439 void Main::fileExitVYM()
2441 // Check if one or more editors have changed
2444 for (i=0;i<=tabWidget->count() -1;i++)
2447 me=(MapEditor*)tabWidget->page(i);
2449 // If something changed, ask what to do
2450 if (me->hasChanged())
2452 tabWidget->setCurrentPage(i);
2453 QMessageBox mb( vymName,
2454 tr("This map is not saved yet. Do you want to"),
2455 QMessageBox::Warning,
2456 QMessageBox::Yes | QMessageBox::Default,
2458 QMessageBox::Cancel | QMessageBox::Escape );
2459 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2460 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2463 mb.setActiveWindow();
2464 switch( mb.exec() ) {
2465 case QMessageBox::Yes:
2466 // save (the changed editors) and exit
2467 fileSave(currentMapEditor(), CompleteMap);
2469 case QMessageBox::No:
2470 // exit without saving
2472 case QMessageBox::Cancel:
2473 // don't save and don't exit
2477 } // loop over all MEs
2481 void Main::editUndo()
2483 if (currentMapEditor())
2484 currentMapEditor()->undo();
2487 void Main::editRedo()
2489 if (currentMapEditor())
2490 currentMapEditor()->redo();
2493 void Main::gotoHistoryStep (int i)
2495 if (currentMapEditor())
2496 currentMapEditor()->gotoHistoryStep (i);
2499 void Main::editCopy()
2501 if (currentMapEditor())
2502 currentMapEditor()->copy();
2505 void Main::editPaste()
2507 if (currentMapEditor())
2508 currentMapEditor()->paste();
2511 void Main::editCut()
2513 if (currentMapEditor())
2514 currentMapEditor()->cut();
2517 void Main::editOpenFindWindow()
2519 findWindow->popup();
2520 findWindow->raise();
2521 findWindow->setActiveWindow();
2524 void Main::editFind(QString s)
2527 BranchObj *bo=currentMapEditor()->findText(s, cs);
2530 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2533 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2534 tr("No matches found for \"%1\"").arg(s));
2538 void Main::editFindChanged()
2539 { // Notify editor, to abort the current find process
2540 currentMapEditor()->findReset();
2543 void Main::openTabs(QStringList urls)
2545 if (!urls.isEmpty())
2549 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2551 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2553 QString u=urls.takeFirst();
2554 procBrowser = new QProcess( this );
2556 procBrowser->start(browser,args);
2557 if ( !procBrowser->waitForStarted())
2559 // try to set path to browser
2560 QMessageBox::warning(0,
2562 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2563 tr("Please use Settings->")+tr("Set application to open an URL"));
2566 #if defined(Q_OS_WIN32)
2567 // There's no sleep in VCEE, replace it with Qt's QThread::wait().
2568 this->thread()->wait(3000);
2573 if (browser.contains("konqueror"))
2575 for (int i=0; i<urls.size(); i++)
2578 // Try to open new tab in existing konqueror started previously by vym
2579 p=new QProcess (this);
2581 #if defined(Q_OS_WIN32)
2582 // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
2583 // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
2584 args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
2585 "konqueror-mainwindow#1"<<
2589 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2590 "konqueror-mainwindow#1"<<
2594 p->start ("dcop",args);
2595 cout << args.join(" ").ascii()<<endl;
2596 if ( !p->waitForStarted() ) success=false;
2599 QMessageBox::warning(0,
2601 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2603 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2605 for (int i=0; i<urls.size(); i++)
2607 // Try to open new tab in firefox
2608 p=new QProcess (this);
2609 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2610 p->start (browser,args);
2611 if ( !p->waitForStarted() ) success=false;
2614 QMessageBox::warning(0,
2616 tr("Couldn't start %1 to open a new tab").arg(browser));
2619 QMessageBox::warning(0,
2621 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2625 void Main::editOpenURL()
2628 if (currentMapEditor())
2630 QString url=currentMapEditor()->getURL();
2632 if (url=="") return;
2633 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2634 procBrowser = new QProcess( this );
2636 procBrowser->start(browser,args);
2637 if ( !procBrowser->waitForStarted())
2639 // try to set path to browser
2640 QMessageBox::warning(0,
2642 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2643 tr("Please use Settings->")+tr("Set application to open an URL"));
2648 void Main::editOpenURLTab()
2650 if (currentMapEditor())
2653 urls.append(currentMapEditor()->getURL());
2657 void Main::editOpenMultipleURLTabs()
2659 if (currentMapEditor())
2662 urls=currentMapEditor()->getURLs();
2668 void Main::editURL()
2670 if (currentMapEditor())
2671 currentMapEditor()->editURL();
2674 void Main::editLocalURL()
2676 if (currentMapEditor())
2677 currentMapEditor()->editLocalURL();
2680 void Main::editHeading2URL()
2682 if (currentMapEditor())
2683 currentMapEditor()->editHeading2URL();
2686 void Main::editBugzilla2URL()
2688 if (currentMapEditor())
2689 currentMapEditor()->editBugzilla2URL();
2692 void Main::editFATE2URL()
2694 if (currentMapEditor())
2695 currentMapEditor()->editFATE2URL();
2698 void Main::editHeadingFinished()
2700 // only called from editHeading(), so there is a currentME
2701 MapEditor *me=currentMapEditor();
2704 me->setStateEditHeading (false);
2705 QPoint p; //Not used here, only to find out pos of branch
2707 QString s=me->getHeading(ok,p);
2709 #if defined(Q_OS_MACX)
2711 if (ok && s!=lineedit->text())
2712 me->setHeading(lineedit->text());
2714 lineedit->releaseKeyboard();
2718 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2719 !prevSelection.isEmpty())
2720 me->select(prevSelection);
2725 void Main::editHeading()
2727 if (currentMapEditor())
2729 MapEditor *me=currentMapEditor();
2730 QString oldSel=me->getSelectString();
2732 if (lineedit->isVisible())
2733 editHeadingFinished();
2738 QString s=me->getHeading(ok,p);
2742 me->setStateEditHeading (true);
2743 #if defined(Q_OS_MACX)
2744 p=me->mapToGlobal (p);
2745 QDialog *d =new QDialog(NULL);
2746 QLineEdit *le=new QLineEdit (d);
2747 d->setWindowFlags (Qt::FramelessWindowHint);
2748 d->setGeometry(p.x(),p.y(),230,25);
2749 le->resize (d->width()-10,d->height());
2752 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2753 d->activateWindow();
2755 me->setHeading (le->text());
2758 editHeadingFinished();
2760 p=me->mapTo (this,p);
2761 lineedit->setGeometry(p.x(),p.y(),230,25);
2762 lineedit->setText(s);
2763 lineedit->setCursorPosition(1);
2764 lineedit->selectAll();
2766 lineedit->grabKeyboard();
2767 lineedit->setFocus();
2771 } // currentMapEditor()
2774 void Main::openVymLinks(const QStringList &vl)
2776 for (int j=0; j<vl.size(); j++)
2778 // compare path with already loaded maps
2782 for (i=0;i<=tabWidget->count() -1;i++)
2784 me=(MapEditor*)tabWidget->page(i);
2785 if (vl.at(j)==me->getFilePath() )
2794 if (!QFile(vl.at(j)).exists() )
2795 QMessageBox::critical( 0, tr( "Critical Error" ),
2796 tr("Couldn't open map %1").arg(vl.at(j)));
2799 fileLoad (vl.at(j), NewMap);
2800 tabWidget->setCurrentPage (tabWidget->count()-1);
2803 // Go to tab containing the map
2804 tabWidget->setCurrentPage (index);
2808 void Main::editOpenVymLink()
2810 if (currentMapEditor())
2813 vl.append(currentMapEditor()->getVymLink());
2818 void Main::editOpenMultipleVymLinks()
2820 QString currentVymLink;
2821 if (currentMapEditor())
2823 QStringList vl=currentMapEditor()->getVymLinks();
2828 void Main::editVymLink()
2830 if (currentMapEditor())
2831 currentMapEditor()->editVymLink();
2834 void Main::editDeleteVymLink()
2836 if (currentMapEditor())
2837 currentMapEditor()->deleteVymLink();
2840 void Main::editToggleHideExport()
2842 if (currentMapEditor())
2843 currentMapEditor()->toggleHideExport();
2846 void Main::editMapInfo()
2848 if (currentMapEditor())
2849 currentMapEditor()->editMapInfo();
2852 void Main::editMoveUp()
2854 if (currentMapEditor())
2855 currentMapEditor()->moveBranchUp();
2858 void Main::editMoveDown()
2860 if (currentMapEditor())
2861 currentMapEditor()->moveBranchDown();
2864 void Main::editSortChildren()
2866 if (currentMapEditor())
2867 currentMapEditor()->sortChildren();
2870 void Main::editToggleScroll()
2872 if (currentMapEditor())
2874 currentMapEditor()->toggleScroll();
2878 void Main::editUnscrollChilds()
2880 if (currentMapEditor())
2881 currentMapEditor()->unscrollChilds();
2884 void Main::editNewBranch()
2886 MapEditor *me=currentMapEditor();
2887 if (!lineedit->isVisible() && me)
2889 BranchObj *bo=(BranchObj*)me->getSelection();
2890 BranchObj *newbo=me->addNewBranch(0);
2892 prevSelection=bo->getSelectString();
2894 me->select (newbo->getSelectString());
2898 if (actionSettingsAutoEditNewBranch->isOn())
2903 if (!prevSelection.isEmpty())
2905 me->select(prevSelection);
2912 void Main::editNewBranchBefore()
2914 MapEditor *me=currentMapEditor();
2915 if (!lineedit->isVisible() && me)
2917 BranchObj *bo=(BranchObj*)me->getSelection();
2918 BranchObj *newbo=me->addNewBranchBefore();
2921 me->select (newbo->getSelectString());
2925 if (actionSettingsAutoEditNewBranch->isOn())
2927 if (!actionSettingsAutoSelectNewBranch->isOn())
2928 prevSelection=bo->getSelectString();
2934 void Main::editNewBranchAbove()
2936 MapEditor *me=currentMapEditor();
2937 if (!lineedit->isVisible() && me)
2939 BranchObj *bo=(BranchObj*)me->getSelection();
2940 BranchObj *newbo=me->addNewBranch (-1);
2943 me->select (newbo->getSelectString());
2947 if (actionSettingsAutoEditNewBranch->isOn())
2949 if (!actionSettingsAutoSelectNewBranch->isOn())
2950 prevSelection=bo->getSelectString();
2956 void Main::editNewBranchBelow()
2958 MapEditor *me=currentMapEditor();
2959 if (!lineedit->isVisible() && me)
2961 BranchObj *bo=(BranchObj*)me->getSelection();
2962 BranchObj *newbo=me->addNewBranch (1);
2965 me->select (newbo->getSelectString());
2969 if (actionSettingsAutoEditNewBranch->isOn())
2971 if (!actionSettingsAutoSelectNewBranch->isOn())
2972 prevSelection=bo->getSelectString();
2978 void Main::editImportAdd()
2980 fileLoad (ImportAdd);
2983 void Main::editImportReplace()
2985 fileLoad (ImportReplace);
2988 void Main::editSaveBranch()
2990 fileSaveAs (PartOfMap);
2993 void Main::editDeleteKeepChilds()
2995 if (currentMapEditor())
2996 currentMapEditor()->deleteKeepChilds();
2999 void Main::editDeleteChilds()
3001 if (currentMapEditor())
3002 currentMapEditor()->deleteChilds();
3005 void Main::editDeleteSelection()
3007 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
3008 currentMapEditor()->deleteSelection();
3011 void Main::editUpperBranch()
3013 if (currentMapEditor())
3014 currentMapEditor()->selectUpperBranch();
3017 void Main::editLowerBranch()
3019 if (currentMapEditor())
3020 currentMapEditor()->selectLowerBranch();
3023 void Main::editLeftBranch()
3025 if (currentMapEditor())
3026 currentMapEditor()->selectLeftBranch();
3029 void Main::editRightBranch()
3031 if (currentMapEditor())
3032 currentMapEditor()->selectRightBranch();
3035 void Main::editFirstBranch()
3037 if (currentMapEditor())
3038 currentMapEditor()->selectFirstBranch();
3041 void Main::editLastBranch()
3043 if (currentMapEditor())
3044 currentMapEditor()->selectLastBranch();
3047 void Main::editLoadImage()
3049 if (currentMapEditor())
3050 currentMapEditor()->loadFloatImage();
3053 void Main::editSaveImage()
3055 if (currentMapEditor())
3056 currentMapEditor()->saveFloatImage();
3059 void Main::editFollowXLink(QAction *a)
3062 if (currentMapEditor())
3063 currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
3066 void Main::editEditXLink(QAction *a)
3068 if (currentMapEditor())
3069 currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3072 void Main::formatSelectColor()
3074 if (currentMapEditor())
3076 QColor col = QColorDialog::getColor((currentColor ), this );
3077 if ( !col.isValid() ) return;
3078 colorChanged( col );
3082 void Main::formatPickColor()
3084 if (currentMapEditor())
3085 colorChanged( currentMapEditor()->getCurrentHeadingColor() );
3088 void Main::colorChanged(QColor c)
3090 QPixmap pix( 16, 16 );
3092 actionFormatColor->setIconSet( pix );
3096 void Main::formatColorBranch()
3098 if (currentMapEditor())
3099 currentMapEditor()->colorBranch(currentColor);
3102 void Main::formatColorSubtree()
3104 if (currentMapEditor())
3105 currentMapEditor()->colorSubtree (currentColor);
3108 void Main::formatLinkStyleLine()
3110 if (currentMapEditor())
3111 currentMapEditor()->setMapLinkStyle("StyleLine");
3114 void Main::formatLinkStyleParabel()
3116 if (currentMapEditor())
3117 currentMapEditor()->setMapLinkStyle("StyleParabel");
3120 void Main::formatLinkStylePolyLine()
3122 if (currentMapEditor())
3123 currentMapEditor()->setMapLinkStyle("StylePolyLine");
3126 void Main::formatLinkStylePolyParabel()
3128 if (currentMapEditor())
3129 currentMapEditor()->setMapLinkStyle("StylePolyParabel");
3132 void Main::formatSelectBackColor()
3134 if (currentMapEditor())
3135 currentMapEditor()->selectMapBackgroundColor();
3138 void Main::formatSelectBackImage()
3140 if (currentMapEditor())
3141 currentMapEditor()->selectMapBackgroundImage();
3144 void Main::formatSelectLinkColor()
3146 if (currentMapEditor())
3147 currentMapEditor()->selectMapLinkColor();
3150 void Main::formatSelectSelectionColor()
3152 if (currentMapEditor())
3153 currentMapEditor()->selectMapSelectionColor();
3156 void Main::formatToggleLinkColorHint()
3158 currentMapEditor()->toggleMapLinkColorHint();
3162 void Main::formatHideLinkUnselected() //FIXME get rid of this with imagepropertydialog
3164 if (currentMapEditor())
3165 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3168 void Main::viewZoomReset()
3170 if (currentMapEditor())
3174 currentMapEditor()->setMatrix( m );
3178 void Main::viewZoomIn()
3180 if (currentMapEditor())
3182 QMatrix m = currentMapEditor()->matrix();
3183 m.scale( 1.25, 1.25 );
3184 currentMapEditor()->setMatrix( m );
3188 void Main::viewZoomOut()
3190 if (currentMapEditor())
3192 QMatrix m = currentMapEditor()->matrix();
3193 m.scale( 0.8, 0.8 );
3194 currentMapEditor()->setMatrix( m );
3198 void Main::viewCenter()
3200 MapEditor *me=currentMapEditor();
3203 me->ensureSelectionVisible();
3207 void Main::networkStartServer()
3209 MapEditor *me=currentMapEditor();
3210 if (me) me->newServer();
3213 void Main::networkConnect()
3215 MapEditor *me=currentMapEditor();
3216 if (me) me->connectToServer();
3219 bool Main::settingsPDF()
3221 // Default browser is set in constructor
3223 QString text = QInputDialog::getText(
3224 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3225 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3227 settings.setValue ("/mainwindow/readerPDF",text);
3232 bool Main::settingsURL()
3234 // Default browser is set in constructor
3236 QString text = QInputDialog::getText(
3237 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3238 settings.value("/mainwindow/readerURL").toString()
3241 settings.setValue ("/mainwindow/readerURL",text);
3245 void Main::settingsMacroDir()
3247 QDir defdir=vymBaseDir;
3248 defdir.cd("macros");
3249 if (!defdir.exists())
3251 QDir dir=QFileDialog::getExistingDirectory (
3253 tr ("Directory with vym macros:"),
3254 settings.value ("/macros/macroDir",defdir.path()).toString()
3257 settings.setValue ("/macros/macroDir",dir.path());
3260 void Main::settingsUndoLevels()
3263 int i = QInputDialog::getInteger(
3265 tr("QInputDialog::getInteger()"),
3266 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3269 settings.setValue ("/mapeditor/stepsTotal",i);
3270 QMessageBox::information( this, tr( "VYM -Information:" ),
3271 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3275 void Main::settingsAutosaveToggle()
3277 settings.setValue ("/mapeditor/autosave/use",actionSettingsAutosaveToggle->isOn() );
3280 void Main::settingsAutosaveTime()
3283 int i = QInputDialog::getInteger(
3285 tr("QInputDialog::getInteger()"),
3286 tr("Number of seconds before autosave:"), settings.value("/mapeditor/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3289 settings.setValue ("/mapeditor/autosave/ms",i * 1000);
3293 void Main::settingsToggleDelKey()
3295 if (actionSettingsUseDelKey->isOn())
3297 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3300 actionEditDelete->setAccel (QKeySequence (""));
3304 void Main::windowToggleNoteEditor()
3306 if (textEditor->isVisible() )
3307 windowHideNoteEditor();
3309 windowShowNoteEditor();
3312 void Main::windowToggleHistory()
3314 if (historyWindow->isVisible())
3315 historyWindow->hide();
3317 historyWindow->show();
3321 void Main::windowToggleProperty()
3323 if (branchPropertyWindow->isVisible())
3324 branchPropertyWindow->hide();
3326 branchPropertyWindow->show();
3328 if(currentMapEditor())
3330 LinkableMapObj *sel=currentMapEditor()->getSelection();
3331 if (sel && (typeid(*sel) == typeid(BranchObj) ||
3332 typeid(*sel) == typeid(MapCenterObj)))
3334 branchPropertyWindow->setMapEditor(currentMapEditor());
3335 branchPropertyWindow->setBranch((BranchObj*)sel);
3340 branchPropertyWindow->setBranch(NULL);
3343 void Main::windowToggleAntiAlias()
3345 bool b=actionViewToggleAntiAlias->isOn();
3347 for (int i=0;i<tabWidget->count();i++)
3350 me=(MapEditor*)tabWidget->page(i);
3351 me->setAntiAlias(b);
3356 void Main::windowToggleSmoothPixmap()
3358 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3360 for (int i=0;i<tabWidget->count();i++)
3363 me=(MapEditor*)tabWidget->page(i);
3364 me->setSmoothPixmap(b);
3368 void Main::updateHistory(SimpleSettings &undoSet)
3370 historyWindow->update (undoSet);
3373 void Main::updateNoteFlag()
3375 if (currentMapEditor())
3376 currentMapEditor()->updateNoteFlag();
3379 void Main::updateSatellites(MapEditor *me)
3381 branchPropertyWindow->setMapEditor (me);
3384 void Main::updateActions()
3386 MapEditor *me=currentMapEditor();
3389 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(currentMapEditor()->getFileName()));
3391 // updateActions is also called when NoteEditor is closed
3392 actionViewToggleNoteEditor->setOn (textEditor->isVisible());
3393 actionViewToggleHistoryWindow->setOn (historyWindow->isVisible());
3394 actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible());
3396 if (me->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3397 actionFormatLinkColorHint->setOn(true);
3399 actionFormatLinkColorHint->setOn(false);
3401 switch (me->getMapLinkStyle())
3403 case LinkableMapObj::Line:
3404 actionFormatLinkStyleLine->setOn(true);
3406 case LinkableMapObj::Parabel:
3407 actionFormatLinkStyleParabel->setOn(true);
3409 case LinkableMapObj::PolyLine:
3410 actionFormatLinkStylePolyLine->setOn(true);
3412 case LinkableMapObj::PolyParabel:
3413 actionFormatLinkStylePolyParabel->setOn(true);
3420 QPixmap pix( 16, 16 );
3421 pix.fill( me->getMapBackgroundColor() );
3422 actionFormatBackColor->setIconSet( pix );
3423 pix.fill( me->getSelectionColor() );
3424 actionFormatSelectionColor->setIconSet( pix );
3425 pix.fill( me->getMapDefLinkColor() );
3426 actionFormatLinkColor->setIconSet( pix );
3429 actionFileSave->setEnabled( me->hasChanged() );
3430 if (me->isUndoAvailable())
3431 actionEditUndo->setEnabled( true);
3433 actionEditUndo->setEnabled( false);
3435 if (me->isRedoAvailable())
3436 actionEditRedo->setEnabled( true);
3438 actionEditRedo->setEnabled( false);
3440 LinkableMapObj *selection=me->getSelection();
3443 if ( (typeid(*selection) == typeid(BranchObj)) ||
3444 (typeid(*selection) == typeid(MapCenterObj)) )
3446 BranchObj *bo=(BranchObj*)selection;
3447 // Take care of links
3448 if (bo->countXLinks()==0)
3450 branchXLinksContextMenuEdit->clear();
3451 branchXLinksContextMenuFollow->clear();
3456 branchXLinksContextMenuEdit->clear();
3457 branchXLinksContextMenuFollow->clear();
3458 for (int i=0; i<=bo->countXLinks();i++)
3460 bot=bo->XLinkTargetAt(i);
3463 s=bot->getHeading();
3464 if (s.length()>xLinkMenuWidth)
3465 s=s.left(xLinkMenuWidth)+"...";
3466 branchXLinksContextMenuFollow->addAction (s);
3467 branchXLinksContextMenuEdit->addAction (s);
3472 standardFlagsDefault->setEnabled (true);
3474 actionEditToggleScroll->setEnabled (true);
3475 if ( bo->isScrolled() )
3476 actionEditToggleScroll->setOn(true);
3478 actionEditToggleScroll->setOn(false);
3480 if ( bo->getURL().isEmpty() )
3482 actionEditOpenURL->setEnabled (false);
3483 actionEditOpenURLTab->setEnabled (false);
3487 actionEditOpenURL->setEnabled (true);
3488 actionEditOpenURLTab->setEnabled (true);
3490 if ( bo->getVymLink().isEmpty() )
3492 actionEditOpenVymLink->setEnabled (false);
3493 actionEditDeleteVymLink->setEnabled (false);
3496 actionEditOpenVymLink->setEnabled (true);
3497 actionEditDeleteVymLink->setEnabled (true);
3500 if (bo->canMoveBranchUp())
3501 actionEditMoveUp->setEnabled (true);
3503 actionEditMoveUp->setEnabled (false);
3504 if (bo->canMoveBranchDown())
3505 actionEditMoveDown->setEnabled (true);
3507 actionEditMoveDown->setEnabled (false);
3510 actionEditToggleHideExport->setEnabled (true);
3511 actionEditToggleHideExport->setOn (bo->hideInExport() );
3513 actionEditCopy->setEnabled (true);
3514 actionEditCut->setEnabled (true);
3515 if (!clipboardEmpty)
3516 actionEditPaste->setEnabled (true);
3518 actionEditPaste->setEnabled (false);
3519 for (int i=0; i<actionListBranches.size(); ++i)
3520 actionListBranches.at(i)->setEnabled(true);
3521 actionEditDelete->setEnabled (true);
3522 actionFormatHideLinkUnselected->setOn
3523 (selection->getHideLinkUnselected());
3525 if ( (typeid(*selection) == typeid(FloatImageObj)) )
3527 FloatObj *fo=(FloatImageObj*)selection;
3529 actionEditOpenURL->setEnabled (false);
3530 actionEditOpenVymLink->setEnabled (false);
3531 actionEditDeleteVymLink->setEnabled (false);
3532 actionEditToggleHideExport->setEnabled (true);
3533 actionEditToggleHideExport->setOn (fo->hideInExport() );
3536 actionEditCopy->setEnabled (true);
3537 actionEditCut->setEnabled (true);
3538 actionEditPaste->setEnabled (false);
3539 for (int i=0; i<actionListBranches.size(); ++i)
3540 actionListBranches.at(i)->setEnabled(false);
3541 actionEditDelete->setEnabled (true);
3542 actionFormatHideLinkUnselected->setOn
3543 ( selection->getHideLinkUnselected());
3544 actionEditMoveUp->setEnabled (false);
3545 actionEditMoveDown->setEnabled (false);
3550 actionEditCopy->setEnabled (false);
3551 actionEditCut->setEnabled (false);
3552 actionEditPaste->setEnabled (false);
3553 for (int i=0; i<actionListBranches.size(); ++i)
3554 actionListBranches.at(i)->setEnabled(false);
3556 actionEditToggleScroll->setEnabled (false);
3557 actionEditOpenURL->setEnabled (false);
3558 actionEditOpenVymLink->setEnabled (false);
3559 actionEditDeleteVymLink->setEnabled (false);
3560 actionEditHeading2URL->setEnabled (false);
3561 actionEditDelete->setEnabled (false);
3562 actionEditMoveUp->setEnabled (false);
3563 actionEditMoveDown->setEnabled (false);
3564 actionEditToggleHideExport->setEnabled (false);
3568 Main::ModMode Main::getModMode()
3570 if (actionModModeColor->isOn()) return ModModeColor;
3571 if (actionModModeCopy->isOn()) return ModModeCopy;
3572 if (actionModModeXLink->isOn()) return ModModeXLink;
3576 bool Main::autoEditNewBranch()
3578 return actionSettingsAutoEditNewBranch->isOn();
3581 bool Main::autoSelectNewBranch()
3583 return actionSettingsAutoSelectNewBranch->isOn();
3586 bool Main::useFlagGroups()
3588 return actionSettingsUseFlagGroups->isOn();
3591 void Main::windowShowNoteEditor()
3593 textEditor->setShowWithMain(true);
3595 actionViewToggleNoteEditor->setOn (true);
3598 void Main::windowHideNoteEditor()
3600 textEditor->setShowWithMain(false);
3602 actionViewToggleNoteEditor->setOn (false);
3605 void Main::setScript (const QString &script)
3607 scriptEditor->setScript (script);
3610 void Main::runScript (const QString &script)
3612 if (currentMapEditor())
3613 currentMapEditor()->runScript (script);
3616 void Main::runScriptEverywhere (const QString &script)
3619 for (int i=0;i<=tabWidget->count() -1;i++)
3621 me=(MapEditor*)tabWidget->page(i);
3622 if (me) me->runScript (script);
3626 void Main::windowNextEditor()
3628 if (tabWidget->currentPageIndex() < tabWidget->count())
3629 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3632 void Main::windowPreviousEditor()
3634 if (tabWidget->currentPageIndex() >0)
3635 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3638 void Main::standardFlagChanged()
3640 if (currentMapEditor())
3641 currentMapEditor()->toggleStandardFlag(sender()->name());
3644 void Main::testFunction1()
3646 if (!currentMapEditor()) return;
3647 currentMapEditor()->testFunction1();
3650 void Main::testFunction2()
3652 if (!currentMapEditor()) return;
3653 currentMapEditor()->testFunction2();
3656 void Main::testCommand()
3658 if (!currentMapEditor()) return;
3659 scriptEditor->show();
3662 QString com = QInputDialog::getText(
3663 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3664 if (ok) currentMapEditor()->parseAtom(com);
3668 void Main::helpDoc()
3670 QString locale = QLocale::system().name();
3672 if (locale.left(2)=="es")
3673 docname="vym_es.pdf";
3677 QStringList searchList;
3679 #if defined(Q_OS_MACX)
3680 searchList << "./vym.app/Contents/Resources/doc";
3682 #if defined(VYM_DOCDIR)
3683 searchList << VYM_DOCDIR;
3685 // default path in SUSE LINUX
3686 searchList <<"/usr/share/doc/packages/vym";
3689 searchList << "doc"; // relative path for easy testing in tarball
3690 searchList << "doc/tex"; // Easy testing working on vym.tex
3691 searchList << "/usr/share/doc/vym"; // Debian
3692 searchList << "/usr/share/doc/packages";// Knoppix
3696 for (int i=0; i<searchList.count(); ++i)
3698 docfile.setFileName(QDir::convertSeparators(searchList.at(i)+"/"+docname));
3699 if (docfile.exists() )
3708 QMessageBox::critical(0,
3709 tr("Critcal error"),
3710 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3715 Process *pdfProc = new Process();
3716 args <<docfile.fileName();
3718 pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
3719 if ( !pdfProc->waitForStarted() )
3722 QMessageBox::warning(0,
3724 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3725 tr("Please use Settings->")+tr("Set application to open PDF files"));
3732 void Main::helpDemo()
3734 QStringList filters;
3735 filters <<"VYM example map (*.vym)";
3736 QFileDialog *fd=new QFileDialog( this);
3737 #if defined(Q_OS_MACX)
3738 fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
3740 // default path in SUSE LINUX
3741 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
3744 fd->setFileMode (QFileDialog::ExistingFiles);
3745 fd->setFilters (filters);
3746 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
3750 if ( fd->exec() == QDialog::Accepted )
3752 lastFileDir=fd->directory().path();
3753 QStringList flist = fd->selectedFiles();
3754 QStringList::Iterator it = flist.begin();
3755 while( it != flist.end() )
3758 fileLoad(*it, NewMap);
3766 void Main::helpAbout()
3769 ad.setName ("aboutwindow");
3770 ad.setMinimumSize(500,500);
3771 ad.resize (QSize (500,500));
3775 void Main::helpAboutQT()
3777 QMessageBox::aboutQt( this, "Qt Application Example" );
3780 void Main::callMacro ()
3782 QAction *action = qobject_cast<QAction *>(sender());
3786 i=action->data().toInt();
3787 QString mDir (settings.value ("macros/macroDir").toString() );
3789 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3791 if ( !f.open( QIODevice::ReadOnly ) )
3793 QMessageBox::warning(0,
3795 tr("Couldn't find a macro at %1.\n").arg(fn)+
3796 tr("Please use Settings->")+tr("Set directory for vym macros"));
3800 QTextStream ts( &f );
3801 QString m= ts.read();
3805 //cout <<"Main::callMacro m="<<m.ascii()<<endl;
3806 currentMapEditor()->runScript (m);
3813 //////////////////////////////////
3815 @@ -2544,18 +2576,27 @@
3816 // Try to open new tab in existing konqueror started previously by vym
3817 p=new QProcess (this);
3819 - args<< QString("konqueror-%1").arg(procBrowser->pid())<<
3820 - "konqueror-mainwindow#1"<<
3822 +#if defined(Q_OS_WIN32)
3823 + // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
3824 + // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
3825 + args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
3826 + "konqueror-mainwindow#1"<<
3830 + args<< QString("konqueror-%1").arg(procBrowser->pid())<<
3831 + "konqueror-mainwindow#1"<<
3835 p->start ("dcop",args);
3836 if ( !p->waitForStarted() ) success=false;