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 #if defined(Q_OS_WIN32)
72 extern QDir vymInstallDir;
74 extern QString iconPath;
75 extern QString flagsPath;
77 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
78 QMainWindow(parent,name,f)
82 setCaption ("VYM - View Your Mind");
84 // Load window settings
85 #if defined(Q_OS_WIN32)
86 if (settings.value("/mainwindow/geometry/maximized", false).toBool())
88 setWindowState(Qt::WindowMaximized);
93 resize (settings.value("/mainwindow/geometry/size", QSize (800,600)).toSize());
94 move (settings.value("/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
97 // Sometimes we may need to remember old selections
101 currentColor=Qt::black;
103 // Create unique temporary directory
105 tmpVymDir=makeTmpDir (ok,"vym");
108 qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
111 if (debug) qDebug (QString("vym tmpDir=%1").arg(tmpVymDir) );
113 // Create direcctory for clipboard
114 clipboardDir=tmpVymDir+"/clipboard";
115 clipboardFile="map.xml";
116 QDir d(clipboardDir);
117 d.mkdir (clipboardDir,true);
118 makeSubDirs (clipboardDir);
123 // Satellite windows //////////////////////////////////////////
126 historyWindow=new HistoryWindow();
127 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
130 branchPropertyWindow = new BranchPropertyWindow();
131 connect (branchPropertyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
133 // Connect TextEditor, so that we can update flags if text changes
134 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
135 connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
137 // Connect HistoryWindow, so that we can update flags
138 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
141 // Initialize script editor
142 scriptEditor = new SimpleScriptEditor();
143 scriptEditor->move (50,50);
145 connect( scriptEditor, SIGNAL( runScript ( QString ) ),
146 this, SLOT( runScript( QString ) ) );
149 // Initialize Find window
150 findWindow=new FindWindow(NULL);
151 findWindow->move (x(),y()+70);
152 connect (findWindow, SIGNAL( findButton(QString) ),
153 this, SLOT(editFind(QString) ) );
154 connect (findWindow, SIGNAL( somethingChanged() ),
155 this, SLOT(editFindChanged() ) );
157 // Initialize some settings, which are platform dependant
160 // application to open URLs
161 p="/mainwindow/readerURL";
162 #if defined(Q_OS_LINUX)
163 s=settings.value (p,"xdg-open").toString();
165 #if defined(Q_OS_MACX)
166 s=settings.value (p,"/usr/bin/open").toString();
169 #if defined(Q_OS_WIN32)
170 // Assume that system has been set up so that
171 // Explorer automagically opens up the URL
172 // in the user's preferred browser.
173 s=settings.value (p,"explorer").toString();
175 s=settings.value (p,"mozilla").toString();
179 settings.setValue( p,s);
181 // application to open PDFs
182 p="/mainwindow/readerPDF";
183 #if defined(Q_OS_LINUX)
184 s=settings.value (p,"xdg-open").toString();
186 #if defined(Q_OS_MACX)
187 s=settings.value (p,"/usr/bin/open").toString();
188 #elif defined(Q_OS_WIN32)
189 s=settings.value (p,"acrord32").toString();
191 s=settings.value (p,"acroread").toString();
194 settings.setValue( p,s);
196 // width of xLinksMenu
199 // Create tab widget which holds the maps
200 tabWidget= new QTabWidget (this);
201 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
202 this, SLOT( editorChanged( QWidget * ) ) );
204 lineedit=new QLineEdit (this);
207 setCentralWidget(tabWidget);
211 setupFormatActions();
215 setupNetworkActions();
216 setupSettingsActions();
219 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
224 restoreState (settings.value("/mainwindow/state",0).toByteArray());
232 #if defined(Q_OS_WIN32)
233 settings.setValue ("/mainwindow/geometry/maximized", isMaximized());
235 settings.setValue ("/mainwindow/geometry/size", size());
236 settings.setValue ("/mainwindow/geometry/pos", pos());
237 settings.setValue ("/mainwindow/state",saveState(0));
239 settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
240 settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
241 settings.setValue( "/version/version", vymVersion );
242 settings.setValue( "/version/builddate", vymBuildDate );
244 settings.setValue( "/mapeditor/autosave/use",actionSettingsAutosaveToggle->isOn() );
245 settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isOn() );
246 settings.setValue( "/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
247 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
248 settings.setValue( "/mapeditor/editmode/autoEditNewBranch",actionSettingsAutoEditNewBranch->isOn() );
249 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
250 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
251 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
253 //TODO save scriptEditor settings
255 // call the destructors
257 delete historyWindow;
258 delete branchPropertyWindow;
260 // Remove temporary directory
261 removeDir (QDir(tmpVymDir));
264 void Main::loadCmdLine()
266 /* TODO draw some kind of splashscreen while loading...
272 QStringList flist=options.getFileList();
273 QStringList::Iterator it=flist.begin();
275 while (it !=flist.end() )
277 fileLoad (*it, NewMap);
283 void Main::statusMessage(const QString &s)
285 statusBar()->message( s);
288 void Main::closeEvent (QCloseEvent* )
294 void Main::setupFileActions()
296 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
297 QToolBar *tb = addToolBar( tr ("&Map") );
298 tb->setObjectName ("mapTB");
301 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this);
302 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
303 a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map
305 fileMenu->addAction (a);
306 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
308 a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this);
309 a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) );
310 a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N ); //New map
311 fileMenu->addAction (a);
312 connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) );
314 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
315 a->setStatusTip (tr( "Open","Status tip File menu" ) );
316 a->setShortcut ( Qt::CTRL + Qt::Key_O ); //Open map
318 fileMenu->addAction (a);
319 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
321 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
322 fileMenu->addSeparator();
324 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
325 a->setStatusTip ( tr( "Save","Status tip file menu" ));
326 a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map
328 fileMenu->addAction (a);
329 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
332 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
333 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
334 fileMenu->addAction (a);
335 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
337 fileMenu->addSeparator();
339 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
341 a = new QAction(tr("KDE Bookmarks"), this);
342 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE bookmarks")));
343 a->addTo (fileImportMenu);
344 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) );
346 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
348 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
349 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
350 a->addTo (fileImportMenu);
351 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
354 a = new QAction("Freemind...",this);
355 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Freemind") );
356 fileImportMenu->addAction (a);
357 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFreemind() ) );
359 a = new QAction("Mind Manager...",this);
360 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
361 fileImportMenu->addAction (a);
362 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
364 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
365 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
366 fileImportMenu->addAction (a);
367 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
369 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
371 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
372 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
373 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
374 fileExportMenu->addAction (a);
376 a = new QAction( "Open Office...", this);
377 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
378 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
379 fileExportMenu->addAction (a);
381 a = new QAction( "Webpage (XHTML)...",this );
382 a->setShortcut (Qt::ALT + Qt::Key_X); //Export XHTML
383 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
384 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
385 fileExportMenu->addAction (a);
387 a = new QAction( "Text (ASCII)...", this);
388 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
389 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
390 fileExportMenu->addAction (a);
392 a = new QAction( "Spreadsheet (CSV)...", this);
393 a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
394 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
395 fileExportMenu->addAction (a);
397 a = new QAction( tr("KDE Bookmarks","File menu"), this);
398 a->setStatusTip( tr( "Export as %1").arg(tr("KDE Bookmarks" )));
399 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
400 fileExportMenu->addAction (a);
402 a = new QAction( "Taskjuggler...", this );
403 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
404 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
405 fileExportMenu->addAction (a);
407 a = new QAction( "LaTeX...", this);
408 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
409 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
410 fileExportMenu->addAction (a);
412 a = new QAction( "XML..." , this );
413 a->setStatusTip (tr( "Export as %1").arg("XML"));
414 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
415 fileExportMenu->addAction (a);
417 fileMenu->addSeparator();
419 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
420 a->setStatusTip ( tr( "Print" ,"File menu") );
421 a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map
423 fileMenu->addAction (a);
424 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
427 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
428 a->setStatusTip (tr( "Close Map" ) );
429 a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map
430 fileMenu->addAction (a);
431 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
433 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
434 a->setStatusTip ( tr( "Exit")+" "+vymName );
435 a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym
436 fileMenu->addAction (a);
437 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
442 void Main::setupEditActions()
444 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
445 tb->setLabel( "Edit Actions" );
446 tb->setObjectName ("actionsTB");
447 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
451 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
452 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
453 a->setStatusTip (tr( "Undo" ) );
454 a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action
455 a->setEnabled (false);
457 editMenu->addAction (a);
460 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
461 a->setStatusTip (tr( "Redo" ));
462 a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action
464 editMenu->addAction (a);
465 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
468 editMenu->addSeparator();
469 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
470 a->setStatusTip ( tr( "Copy" ) );
471 a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy
472 a->setEnabled (false);
474 editMenu->addAction (a);
475 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
478 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
479 a->setStatusTip ( tr( "Cut" ) );
480 a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut
481 a->setEnabled (false);
483 editMenu->addAction (a);
485 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
487 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
488 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
489 a->setStatusTip ( tr( "Paste" ) );
490 a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste
491 a->setEnabled (false);
493 editMenu->addAction (a);
496 // Shortcuts to modify heading:
497 a = new QAction(tr( "Edit heading","Edit menu" ),this);
498 a->setStatusTip ( tr( "edit Heading" ));
499 a->setShortcut ( Qt::Key_Enter); //Edit heading
500 // a->setShortcutContext (Qt::WindowShortcut);
502 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
503 actionListBranches.append(a);
504 a = new QAction( tr( "Edit heading","Edit menu" ), this);
505 a->setStatusTip (tr( "edit Heading" ));
506 a->setShortcut (Qt::Key_Return ); //Edit heading
507 //a->setShortcutContext (Qt::WindowShortcut);
509 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
510 actionListBranches.append(a);
511 editMenu->addAction (a);
513 a = new QAction( tr( "Edit heading","Edit menu" ), this);
514 a->setStatusTip (tr( "edit Heading" ));
515 //a->setShortcut ( Qt::Key_F2 ); //Edit heading
516 a->setShortcutContext (Qt::WindowShortcut);
518 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
519 actionListBranches.append(a);
521 // Shortcut to delete selection
522 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
523 a->setStatusTip (tr( "Delete Selection" ));
524 a->setShortcut ( Qt::Key_Delete); //Delete selection
525 a->setShortcutContext (Qt::WindowShortcut);
527 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
530 // Shortcut to add mapcenter
531 a= new QAction(tr( "Add mapcenter","Canvas context menu" ), this);
532 connect( a, SIGNAL( triggered() ), this, SLOT( editAddMapCenter() ) );
533 actionEditAddMapCenter = a;
536 // Shortcut to add branch
537 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
538 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
539 alt->setShortcut (Qt::Key_A); //Add branch
540 alt->setShortcutContext (Qt::WindowShortcut);
542 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
543 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
544 a->setStatusTip ( tr( "Add a branch as child of selection" ));
545 a->setShortcut (Qt::Key_Insert); //Add branch
546 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
547 actionListBranches.append(a);
548 #if defined (Q_OS_MACX)
549 // In OSX show different shortcut in menues, the keys work indepently always
550 actionEditAddBranch=alt;
552 actionEditAddBranch=a;
554 editMenu->addAction (actionEditAddBranch);
555 tb->addAction (actionEditAddBranch);
558 // Add branch by inserting it at selection
559 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
560 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
561 a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch
562 a->setShortcutContext (Qt::WindowShortcut);
564 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
565 a->setEnabled (false);
566 actionListBranches.append(a);
567 actionEditAddBranchBefore=a;
568 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
569 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
570 a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch
571 a->setShortcutContext (Qt::WindowShortcut);
573 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
574 actionListBranches.append(a);
577 a = new QAction(tr( "Add branch above","Edit menu" ), this);
578 a->setStatusTip ( tr( "Add a branch above selection" ));
579 a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
580 a->setShortcutContext (Qt::WindowShortcut);
582 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
583 a->setEnabled (false);
584 actionListBranches.append(a);
585 actionEditAddBranchAbove=a;
586 a = new QAction(tr( "Add branch above","Edit menu" ), this);
587 a->setStatusTip ( tr( "Add a branch above selection" ));
588 a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above
589 a->setShortcutContext (Qt::WindowShortcut);
591 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
592 actionListBranches.append(a);
595 a = new QAction(tr( "Add branch below","Edit menu" ), this);
596 a->setStatusTip ( tr( "Add a branch below selection" ));
597 a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
598 a->setShortcutContext (Qt::WindowShortcut);
600 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
601 a->setEnabled (false);
602 actionListBranches.append(a);
603 actionEditAddBranchBelow=a;
604 a = new QAction(tr( "Add branch below","Edit menu" ), this);
605 a->setStatusTip ( tr( "Add a branch below selection" ));
606 a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below
607 a->setShortcutContext (Qt::WindowShortcut);
609 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
610 actionListBranches.append(a);
612 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
613 a->setStatusTip ( tr( "Move branch up" ) );
614 a->setShortcut (Qt::Key_PageUp ); // Move branch up
615 a->setEnabled (false);
617 editMenu->addAction (a);
618 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
621 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
622 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
623 a->setStatusTip (tr( "Move branch down" ) );
624 a->setShortcut ( Qt::Key_PageDown ); // Move branch down
625 a->setEnabled (false);
627 editMenu->addAction (a);
628 actionEditMoveDown=a;
630 a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this );
631 connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) );
632 a->setEnabled (true);
634 editMenu->addAction (a);
635 actionEditSortChildren=a;
637 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this);
638 a->setShortcut ( Qt::Key_ScrollLock );
639 a->setStatusTip (tr( "Scroll branch" ) );
640 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
642 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
643 alt->setShortcut ( Qt::Key_S ); // Scroll branch
644 alt->setStatusTip (tr( "Scroll branch" ));
645 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
646 #if defined(Q_OS_MACX)
647 actionEditToggleScroll=alt;
649 actionEditToggleScroll=a;
651 actionEditToggleScroll->setEnabled (false);
652 actionEditToggleScroll->setToggleAction(true);
653 tb->addAction (actionEditToggleScroll);
654 editMenu->addAction ( actionEditToggleScroll);
655 editMenu->addAction (actionEditToggleScroll);
658 actionListBranches.append(actionEditToggleScroll);
660 a = new QAction( tr( "Unscroll childs","Edit menu" ), this);
661 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
662 editMenu->addAction (a);
663 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChilds() ) );
665 editMenu->addSeparator();
667 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
668 a->setStatusTip (tr( "Find" ) );
669 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
670 editMenu->addAction (a);
671 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
673 editMenu->addSeparator();
675 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
676 a->setShortcut (Qt::CTRL + Qt::Key_U );
677 a->setShortcut (tr( "Open URL" ));
680 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
683 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
684 a->setStatusTip (tr( "Open URL in new tab" ));
685 //a->setShortcut (Qt::CTRL+Qt::Key_U );
687 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
688 actionEditOpenURLTab=a;
690 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
691 a->setStatusTip (tr( "Open all URLs in subtree" ));
693 actionListBranches.append(a);
694 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
695 actionEditOpenMultipleURLTabs=a;
697 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
698 a->setStatusTip ( tr( "Edit URL" ) );
699 a->setShortcut ( Qt::Key_U );
700 a->setShortcutContext (Qt::WindowShortcut);
701 actionListBranches.append(a);
703 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
706 a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
707 a->setStatusTip ( tr( "Edit local URL" ) );
708 a->setShortcut (Qt::SHIFT + Qt::Key_U );
709 a->setShortcutContext (Qt::WindowShortcut);
710 actionListBranches.append(a);
712 connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
713 actionEditLocalURL=a;
715 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
716 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
717 a->setEnabled (false);
718 actionListBranches.append(a);
719 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
720 actionEditHeading2URL=a;
722 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
723 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
724 a->setEnabled (false);
725 actionListBranches.append(a);
726 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
727 actionEditBugzilla2URL=a;
729 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
730 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
731 a->setEnabled (false);
732 actionListBranches.append(a);
733 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
734 actionEditFATE2URL=a;
736 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
737 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
739 a->setEnabled (false);
740 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
741 actionEditOpenVymLink=a;
743 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
744 a->setStatusTip ( tr( "Open all vym links in subtree" ));
745 a->setEnabled (false);
746 actionListBranches.append(a);
747 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
748 actionEditOpenMultipleVymLinks=a;
751 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
752 a->setEnabled (false);
753 a->setStatusTip ( tr( "Edit link to another vym map" ));
754 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
755 actionListBranches.append(a);
758 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
759 a->setStatusTip ( tr( "Delete link to another vym map" ));
760 a->setEnabled (false);
761 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
762 actionEditDeleteVymLink=a;
764 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
765 a->setStatusTip ( tr( "Hide object in exports" ) );
766 a->setShortcut (Qt::Key_H );
767 a->setToggleAction(true);
769 a->setEnabled (false);
770 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
771 actionEditToggleHideExport=a;
773 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
774 a->setStatusTip ( tr( "Edit Map Info" ));
775 a->setEnabled (true);
776 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
779 // Import at selection (adding to selection)
780 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
781 a->setStatusTip (tr( "Add map at selection" ));
782 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
783 a->setEnabled (false);
784 actionListBranches.append(a);
785 actionEditImportAdd=a;
787 // Import at selection (replacing selection)
788 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
789 a->setStatusTip (tr( "Replace selection with map" ));
790 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
791 a->setEnabled (false);
792 actionListBranches.append(a);
793 actionEditImportReplace=a;
796 a = new QAction( tr( "Save selection","Edit menu" ), this);
797 a->setStatusTip (tr( "Save selection" ));
798 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
799 a->setEnabled (false);
800 actionListBranches.append(a);
801 actionEditSaveBranch=a;
803 // Only remove branch, not its childs
804 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
805 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
806 a->setShortcut (Qt::ALT + Qt::Key_Delete );
807 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChilds() ) );
808 a->setEnabled (false);
810 actionListBranches.append(a);
811 actionEditDeleteKeepChilds=a;
813 // Only remove childs of a branch
814 a = new QAction( tr( "Remove childs","Edit menu" ), this);
815 a->setStatusTip (tr( "Remove childs of branch" ));
816 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
817 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChilds() ) );
818 a->setEnabled (false);
819 actionListBranches.append(a);
820 actionEditDeleteChilds=a;
822 // Shortcuts for navigating with cursor:
823 a = new QAction(tr( "Select upper branch","Edit menu" ), this);
824 a->setStatusTip ( tr( "Select upper branch" ));
825 a->setShortcut (Qt::Key_Up );
826 a->setShortcutContext (Qt::WindowShortcut);
828 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
829 a = new QAction( tr( "Select lower branch","Edit menu" ),this);
830 a->setStatusTip (tr( "Select lower branch" ));
831 a->setShortcut ( Qt::Key_Down );
832 a->setShortcutContext (Qt::WindowShortcut);
834 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
835 a = new QAction(tr( "Select left branch","Edit menu" ), this);
836 a->setStatusTip ( tr( "Select left branch" ));
837 a->setShortcut (Qt::Key_Left );
838 a->setShortcutContext (Qt::WindowShortcut);
840 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
841 a = new QAction( tr( "Select child branch","Edit menu" ), this);
842 a->setStatusTip (tr( "Select right branch" ));
843 a->setShortcut (Qt::Key_Right);
844 a->setShortcutContext (Qt::WindowShortcut);
846 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
847 a = new QAction( tr( "Select first branch","Edit menu" ), this);
848 a->setStatusTip (tr( "Select first branch" ));
849 a->setShortcut (Qt::Key_Home );
850 a->setShortcutContext (Qt::WindowShortcut);
852 a->setEnabled (false);
853 editMenu->addAction (a);
854 actionListBranches.append(a);
855 actionEditSelectFirst=a;
856 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
857 a = new QAction( tr( "Select last branch","Edit menu" ),this);
858 a->setStatusTip (tr( "Select last branch" ));
859 a->setShortcut ( Qt::Key_End );
860 a->setShortcutContext (Qt::WindowShortcut);
862 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
863 a->setEnabled (false);
864 editMenu->addAction (a);
865 actionListBranches.append(a);
866 actionEditSelectLast=a;
868 a = new QAction( tr( "Add Image...","Edit menu" ), this);
869 a->setStatusTip (tr( "Add Image" ));
870 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
871 actionEditLoadImage=a;
873 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
874 a->setStatusTip (tr( "Set properties for selection" ));
875 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
876 a->setShortcutContext (Qt::WindowShortcut);
877 a->setToggleAction (true);
879 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
880 actionViewTogglePropertyWindow=a;
884 void Main::setupFormatActions()
886 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
888 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
889 tb->setObjectName ("formatTB");
892 pix.fill (Qt::black);
893 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
894 a->setStatusTip ( tr( "Set Color" ));
895 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
897 formatMenu->addAction (a);
899 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
900 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
901 a->setShortcut (Qt::CTRL + Qt::Key_K );
902 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
903 a->setEnabled (false);
905 formatMenu->addAction (a);
906 actionListBranches.append(a);
907 actionFormatPickColor=a;
909 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
910 a->setStatusTip ( tr( "Color branch" ) );
911 a->setShortcut (Qt::CTRL + Qt::Key_B);
912 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
913 a->setEnabled (false);
915 formatMenu->addAction (a);
916 actionListBranches.append(a);
917 actionFormatColorSubtree=a;
919 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
920 a->setStatusTip ( tr( "Color Subtree" ));
921 a->setShortcut (Qt::CTRL + Qt::Key_T);
922 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
923 a->setEnabled (false);
924 formatMenu->addAction (a);
926 actionListBranches.append(a);
927 actionFormatColorSubtree=a;
929 formatMenu->addSeparator();
930 actionGroupFormatLinkStyles=new QActionGroup ( this);
931 actionGroupFormatLinkStyles->setExclusive (true);
932 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
933 a->setStatusTip (tr( "Line" ));
934 a->setToggleAction(true);
935 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
936 formatMenu->addAction (a);
937 actionFormatLinkStyleLine=a;
938 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
939 a->setStatusTip (tr( "Line" ));
940 a->setToggleAction(true);
941 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
942 formatMenu->addAction (a);
943 actionFormatLinkStyleParabel=a;
944 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
945 a->setStatusTip (tr( "PolyLine" ));
946 a->setToggleAction(true);
947 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
948 formatMenu->addAction (a);
949 actionFormatLinkStylePolyLine=a;
950 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
951 a->setStatusTip (tr( "PolyParabel" ) );
952 a->setToggleAction(true);
953 a->setChecked (true);
954 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
955 formatMenu->addAction (a);
956 actionFormatLinkStylePolyParabel=a;
958 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
959 a->setStatusTip (tr( "Hide link" ));
960 a->setToggleAction(true);
961 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
962 actionFormatHideLinkUnselected=a;
964 formatMenu->addSeparator();
965 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
966 a->setStatusTip (tr( "Use same color for links and headings" ));
967 a->setToggleAction(true);
968 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
969 formatMenu->addAction (a);
970 actionFormatLinkColorHint=a;
972 pix.fill (Qt::white);
973 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
974 a->setStatusTip (tr( "Set Link Color" ));
975 formatMenu->addAction (a);
976 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
977 actionFormatLinkColor=a;
979 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
980 a->setStatusTip (tr( "Set Selection Color" ));
981 formatMenu->addAction (a);
982 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
983 actionFormatSelectionColor=a;
985 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
986 a->setStatusTip (tr( "Set Background Color" ));
987 formatMenu->addAction (a);
988 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
989 actionFormatBackColor=a;
991 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
992 a->setStatusTip (tr( "Set Background image" ));
993 formatMenu->addAction (a);
994 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
995 actionFormatBackImage=a;
999 void Main::setupViewActions()
1001 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
1002 tb->setLabel( "View Actions" );
1003 tb->setObjectName ("viewTB");
1004 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
1007 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
1008 a->setStatusTip ( tr( "Zoom reset" ) );
1009 a->setShortcut (Qt::CTRL + Qt::Key_0 );
1011 viewMenu->addAction (a);
1012 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
1014 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
1015 a->setStatusTip (tr( "Zoom in" ));
1016 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
1018 viewMenu->addAction (a);
1019 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
1021 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
1022 a->setStatusTip (tr( "Zoom out" ));
1023 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
1025 viewMenu->addAction (a);
1026 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1028 a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
1029 a->setStatusTip (tr( "Show selection" ));
1030 a->setShortcut (Qt::Key_Period);
1032 viewMenu->addAction (a);
1033 connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
1035 viewMenu->addSeparator();
1037 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
1038 a->setStatusTip ( tr( "Show Note Editor" ));
1039 a->setShortcut ( Qt::CTRL + Qt::Key_E );
1040 a->setToggleAction(true);
1042 viewMenu->addAction (a);
1043 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1044 actionViewToggleNoteEditor=a;
1046 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
1047 a->setStatusTip ( tr( "Show History Window" ));
1048 a->setShortcut ( Qt::CTRL + Qt::Key_H );
1049 a->setToggleAction(true);
1051 viewMenu->addAction (a);
1052 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1053 actionViewToggleHistoryWindow=a;
1055 viewMenu->addAction (actionViewTogglePropertyWindow);
1057 viewMenu->addSeparator();
1059 a = new QAction(tr( "Antialiasing","View action" ),this );
1060 a->setStatusTip ( tr( "Antialiasing" ));
1061 a->setToggleAction(true);
1062 a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
1063 viewMenu->addAction (a);
1064 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
1065 actionViewToggleAntiAlias=a;
1067 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1068 a->setStatusTip (a->text());
1069 a->setToggleAction(true);
1070 a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1071 viewMenu->addAction (a);
1072 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1073 actionViewToggleSmoothPixmapTransform=a;
1075 a = new QAction(tr( "Next Map","View action" ), this);
1076 a->setStatusTip (a->text());
1077 a->setShortcut (Qt::ALT + Qt::Key_N );
1078 viewMenu->addAction (a);
1079 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1081 a = new QAction (tr( "Previous Map","View action" ), this );
1082 a->setStatusTip (a->text());
1083 a->setShortcut (Qt::ALT + Qt::Key_P );
1084 viewMenu->addAction (a);
1085 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1089 void Main::setupModeActions()
1091 //QPopupMenu *menu = new QPopupMenu( this );
1092 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1094 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1095 tb->setObjectName ("modesTB");
1097 actionGroupModModes=new QActionGroup ( this);
1098 actionGroupModModes->setExclusive (true);
1099 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1100 a->setShortcut (Qt::Key_J);
1101 a->setStatusTip ( tr( "Use modifier to color branches" ));
1102 a->setToggleAction(true);
1105 actionModModeColor=a;
1107 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1108 a->setShortcut( Qt::Key_K);
1109 a->setStatusTip( tr( "Use modifier to copy" ));
1110 a->setToggleAction(true);
1112 actionModModeCopy=a;
1114 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1115 a->setShortcut (Qt::Key_L);
1116 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1117 a->setToggleAction(true);
1119 actionModModeXLink=a;
1123 void Main::setupFlagActions()
1125 // Create System Flags
1129 systemFlagsDefault = new FlagRowObj ();
1130 systemFlagsDefault->setVisibility (false);
1131 systemFlagsDefault->setName ("systemFlagsDef");
1133 FlagObj *fo = new FlagObj ();
1134 fo->load(QPixmap(flagsPath+"flag-note.png"));
1135 setupFlag (fo,tb,avis,"note",tr("Note","SystemFlag"));
1137 fo->load(QPixmap(flagsPath+"flag-url.png"));
1138 setupFlag (fo,tb,avis,"url",tr("URL to Document ","SystemFlag"));
1140 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1141 setupFlag (fo,tb,avis,"vymLink",tr("Link to another vym map","SystemFlag"));
1143 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1144 setupFlag (fo,tb,avis,"scrolledright",tr("subtree is scrolled","SystemFlag"));
1146 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1147 setupFlag (fo,tb,avis,"tmpUnscrolledright",tr("subtree is temporary scrolled","SystemFlag"));
1149 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1150 setupFlag (fo,tb,avis,"hideInExport",tr("Hide object in exported maps","SystemFlag"));
1152 // Create Standard Flags
1153 tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1154 tb->setObjectName ("standardFlagTB");
1156 standardFlagsDefault = new FlagRowObj ();
1157 standardFlagsDefault->setVisibility (false);
1158 standardFlagsDefault->setName ("standardFlagsDef");
1159 standardFlagsDefault->setToolBar (tb);
1161 fo->load(flagsPath+"flag-exclamationmark.png");
1162 fo->setGroup("standard-mark");
1163 setupFlag (fo,tb,avis,"exclamationmark",tr("Take care!","Standardflag"));
1165 fo->load(flagsPath+"flag-questionmark.png");
1166 fo->setGroup("standard-mark");
1167 setupFlag (fo,tb,avis,"questionmark",tr("Really?","Standardflag"));
1169 fo->load(flagsPath+"flag-hook-green.png");
1170 fo->setGroup("standard-hook");
1171 setupFlag (fo,tb,avis,"hook-green",tr("ok!","Standardflag"));
1173 fo->load(flagsPath+"flag-cross-red.png");
1174 fo->setGroup("standard-hook");
1175 setupFlag (fo,tb,avis,"cross-red",tr("Not ok!","Standardflag"));
1178 fo->load(flagsPath+"flag-stopsign.png");
1179 setupFlag (fo,tb,avis,"stopsign",tr("This won't work!","Standardflag"));
1181 fo->load(flagsPath+"flag-smiley-good.png");
1182 fo->setGroup("standard-smiley");
1183 setupFlag (fo,tb,avis,"smiley-good",tr("Good","Standardflag"));
1185 fo->load(flagsPath+"flag-smiley-sad.png");
1186 fo->setGroup("standard-smiley");
1187 setupFlag (fo,tb,avis,"smiley-sad",tr("Bad","Standardflag"));
1189 fo->load(flagsPath+"flag-smiley-omg.png");
1190 fo->setGroup("standard-smiley");
1191 setupFlag (fo,tb,avis,"smiley-omb",tr("Oh no!","Standardflag"));
1192 // Original omg.png (in KDE emoticons)
1195 fo->load(flagsPath+"flag-kalarm.png");
1196 setupFlag (fo,tb,avis,"clock",tr("Time critical","Standardflag"));
1198 fo->load(flagsPath+"flag-phone.png");
1199 setupFlag (fo,tb,avis,"phone",tr("Call...","Standardflag"));
1201 fo->load(flagsPath+"flag-lamp.png");
1202 setupFlag (fo,tb,avis,"lamp",tr("Idea!","Standardflag"));
1204 fo->load(flagsPath+"flag-arrow-up.png");
1205 fo->setGroup("standard-arrow");
1206 setupFlag (fo,tb,avis,"arrow-up",tr("Important","Standardflag"));
1208 fo->load(flagsPath+"flag-arrow-down.png");
1209 fo->setGroup("standard-arrow");
1210 setupFlag (fo,tb,avis,"arrow-down",tr("Unimportant","Standardflag"));
1212 fo->load(flagsPath+"flag-arrow-2up.png");
1213 fo->setGroup("standard-arrow");
1214 setupFlag (fo,tb,avis,"2arrow-up",tr("Very important!","Standardflag"));
1216 fo->load(flagsPath+"flag-arrow-2down.png");
1217 fo->setGroup("standard-arrow");
1218 setupFlag (fo,tb,avis,"2arrow-down",tr("Very unimportant!","Standardflag"));
1221 fo->load(flagsPath+"flag-thumb-up.png");
1222 fo->setGroup("standard-thumb");
1223 setupFlag (fo,tb,avis,"thumb-up",tr("I like this","Standardflag"));
1225 fo->load(flagsPath+"flag-thumb-down.png");
1226 fo->setGroup("standard-thumb");
1227 setupFlag (fo,tb,avis,"thumb-down",tr("I do not like this","Standardflag"));
1230 fo->load(flagsPath+"flag-rose.png");
1231 setupFlag (fo,tb,avis,"rose",tr("Rose","Standardflag"));
1233 fo->load(flagsPath+"flag-heart.png");
1234 setupFlag (fo,tb,avis,"heart",tr("I just love...","Standardflag"));
1236 fo->load(flagsPath+"flag-present.png");
1237 setupFlag (fo,tb,avis,"present",tr("Surprise!","Standardflag"));
1239 fo->load(flagsPath+"flag-flash.png");
1240 setupFlag (fo,tb,avis,"flash",tr("Dangerous","Standardflag"));
1242 // Original: xsldbg_output.png
1243 fo->load(flagsPath+"flag-info.png");
1244 setupFlag (fo,tb,avis,"info",tr("Info","Standardflag"));
1246 // Original khelpcenter.png
1247 fo->load(flagsPath+"flag-lifebelt.png");
1248 setupFlag (fo,tb,avis,"lifebelt",tr("This will help","Standardflag"));
1254 fo->load(flagsPath+"freemind/warning.png");
1255 setupFlag (fo,tb, avis, "freemind-warning",tr("Important","Freemind-Flag"));
1257 for (int i=1; i<8; i++)
1259 fo->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
1260 setupFlag (fo,tb, avis,QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
1263 fo->load(flagsPath+"freemind/back.png");
1264 setupFlag (fo,tb,avis,"freemind-back",tr("Back","Freemind-Flag"));
1266 fo->load(flagsPath+"freemind/forward.png");
1267 setupFlag (fo,tb,avis,"freemind-forward",tr("Forward","Freemind-Flag"));
1269 fo->load(flagsPath+"freemind/attach.png");
1270 setupFlag (fo,tb,avis,"freemind-attach",tr("Look here","Freemind-Flag"));
1272 fo->load(flagsPath+"freemind/clanbomber.png");
1273 setupFlag (fo,tb,avis,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
1275 fo->load(flagsPath+"freemind/desktopnew.png");
1276 setupFlag (fo,tb,avis,"freemind-desktopnew",tr("Don't forget","Freemind-Flag"));
1278 fo->load(flagsPath+"freemind/flag.png");
1279 setupFlag (fo,tb,avis,"freemind-flag",tr("Flag","Freemind-Flag"));
1282 fo->load(flagsPath+"freemind/gohome.png");
1283 setupFlag (fo,tb,avis,"freemind-gohome",tr("Home","Freemind-Flag"));
1286 fo->load(flagsPath+"freemind/kaddressbook.png");
1287 setupFlag (fo,tb,avis,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
1289 fo->load(flagsPath+"freemind/knotify.png");
1290 setupFlag (fo,tb,avis,"freemind-knotify",tr("Music","Freemind-Flag"));
1292 fo->load(flagsPath+"freemind/korn.png");
1293 setupFlag (fo,tb,avis,"freemind-korn",tr("Mailbox","Freemind-Flag"));
1295 fo->load(flagsPath+"freemind/mail.png");
1296 setupFlag (fo,tb,avis,"freemind-mail",tr("Maix","Freemind-Flag"));
1298 fo->load(flagsPath+"freemind/password.png");
1299 setupFlag (fo,tb,avis,"freemind-password",tr("Password","Freemind-Flag"));
1301 fo->load(flagsPath+"freemind/pencil.png");
1302 setupFlag (fo,tb,avis,"freemind-pencil",tr("To be improved","Freemind-Flag"));
1304 fo->load(flagsPath+"freemind/stop.png");
1305 setupFlag (fo,tb,avis,"freemind-stop",tr("Stop","Freemind-Flag"));
1307 fo->load(flagsPath+"freemind/wizard.png");
1308 setupFlag (fo,tb,avis,"freemind-wizard",tr("Magic","Freemind-Flag"));
1310 fo->load(flagsPath+"freemind/xmag.png");
1311 setupFlag (fo,tb,avis,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
1313 fo->load(flagsPath+"freemind/bell.png");
1314 setupFlag (fo,tb,avis,"freemind-bell",tr("Reminder","Freemind-Flag"));
1316 fo->load(flagsPath+"freemind/bookmark.png");
1317 setupFlag (fo,tb,avis,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
1319 fo->load(flagsPath+"freemind/penguin.png");
1320 setupFlag (fo,tb,avis,"freemind-penguin",tr("Linux","Freemind-Flag"));
1322 fo->load(flagsPath+"freemind/licq.png");
1323 setupFlag (fo,tb,avis,"freemind-licq",tr("Sweet","Freemind-Flag"));
1328 void Main::setupFlag (FlagObj *fo, QToolBar *tb, bool aw, const QString &name, const QString &tooltip)
1331 fo->setToolTip (tooltip);
1332 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1338 fo->setAlwaysVisible(aw);
1339 a->setCheckable(true);
1340 a->setObjectName(fo->getName());
1341 a->setToolTip(tooltip);
1342 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1343 standardFlagsDefault->addFlag (fo);
1347 systemFlagsDefault->addFlag (fo);
1351 void Main::setupNetworkActions()
1353 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1355 QMenu *netMenu = menuBar()->addMenu( "Network" );
1359 a = new QAction( "Start TCPserver for MapEditor",this);
1360 //a->setStatusTip ( "Set application to open pdf files"));
1361 a->setShortcut ( Qt::Key_T ); //New TCP server
1362 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1363 netMenu->addAction (a);
1365 a = new QAction( "Connect MapEditor to server",this);
1366 //a->setStatusTip ( "Set application to open pdf files"));
1367 a->setShortcut ( Qt::Key_C ); // Connect to server
1368 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1369 netMenu->addAction (a);
1373 void Main::setupSettingsActions()
1375 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1379 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1380 a->setStatusTip ( tr( "Set application to open pdf files"));
1381 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1382 settingsMenu->addAction (a);
1384 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1385 a->setStatusTip( tr( "Set application to open external links"));
1386 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1387 settingsMenu->addAction (a);
1389 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1390 a->setStatusTip( tr( "Set path for macros"));
1391 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1392 settingsMenu->addAction (a);
1394 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1395 a->setStatusTip( tr( "Set number of undo levels"));
1396 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1397 settingsMenu->addAction (a);
1399 settingsMenu->addSeparator();
1401 a = new QAction( tr( "Autosave","Settings action"), this);
1402 a->setStatusTip( tr( "Autosave"));
1403 a->setToggleAction(true);
1404 a->setOn ( settings.value ("/mapeditor/autosave/use",false).toBool());
1405 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1406 settingsMenu->addAction (a);
1407 actionSettingsAutosaveToggle=a;
1409 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1410 a->setStatusTip( tr( "Autosave time"));
1411 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1412 settingsMenu->addAction (a);
1413 actionSettingsAutosaveTime=a;
1415 a = new QAction( tr( "Write backup file on save","Settings action"), this);
1416 a->setStatusTip( tr( "Write backup file on save"));
1417 a->setToggleAction(true);
1418 a->setOn ( settings.value ("/mainwindow/writeBackupFile",false).toBool());
1419 connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) );
1420 settingsMenu->addAction (a);
1421 actionSettingsWriteBackupFile=a;
1423 settingsMenu->addSeparator();
1425 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1426 a->setStatusTip( tr( "Edit branch after adding it" ));
1427 a->setToggleAction(true);
1428 a->setOn ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1429 settingsMenu->addAction (a);
1430 actionSettingsAutoEditNewBranch=a;
1432 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1433 a->setStatusTip( tr( "Select branch after adding it" ));
1434 a->setToggleAction(true);
1435 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1436 settingsMenu->addAction (a);
1437 actionSettingsAutoSelectNewBranch=a;
1439 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1440 a->setStatusTip( tr( "Select heading before editing" ));
1441 a->setToggleAction(true);
1442 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1443 settingsMenu->addAction (a);
1444 actionSettingsAutoSelectText=a;
1446 a= new QAction( tr( "Delete key","Settings action" ), this);
1447 a->setStatusTip( tr( "Delete key for deleting branches" ));
1448 a->setToggleAction(true);
1449 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1450 settingsMenu->addAction (a);
1451 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1452 actionSettingsUseDelKey=a;
1454 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1455 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1456 a->setToggleAction(true);
1457 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1458 settingsMenu->addAction (a);
1459 actionSettingsUseFlagGroups=a;
1461 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1462 a->setStatusTip( tr( "Use hide flag during exports " ));
1463 a->setToggleAction(true);
1464 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1465 settingsMenu->addAction (a);
1466 actionSettingsUseHideExport=a;
1470 void Main::setupTestActions()
1472 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1475 a = new QAction( "Test function 1" , this);
1476 a->setStatusTip( "Call test function 1" );
1477 testMenu->addAction (a);
1478 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1480 a = new QAction( "Test function 2" , this);
1481 a->setStatusTip( "Call test function 2" );
1482 testMenu->addAction (a);
1483 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1485 a = new QAction( "Command" , this);
1486 a->setStatusTip( "Enter command to call in editor" );
1487 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1488 testMenu->addAction (a);
1492 void Main::setupHelpActions()
1494 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1497 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1498 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1499 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1500 helpMenu->addAction (a);
1502 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1503 a->setStatusTip( tr( "Open VYM example maps " ));
1504 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1505 helpMenu->addAction (a);
1507 a = new QAction( tr( "About VYM","Help action" ), this);
1508 a->setStatusTip( tr( "About VYM")+vymName);
1509 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1510 helpMenu->addAction (a);
1512 a = new QAction( tr( "About QT","Help action" ), this);
1513 a->setStatusTip( tr( "Information about QT toolkit" ));
1514 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1515 helpMenu->addAction (a);
1519 void Main::setupContextMenus()
1523 // Context Menu for branch or mapcenter
1524 branchContextMenu =new QMenu (this);
1525 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1526 branchContextMenu->addSeparator();
1529 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1530 branchAddContextMenu->addAction (actionEditPaste );
1531 branchAddContextMenu->addAction ( actionEditAddBranch );
1532 branchAddContextMenu->addAction ( actionEditAddBranchBefore );
1533 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1534 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1535 branchAddContextMenu->addSeparator();
1536 branchAddContextMenu->addAction ( actionEditImportAdd );
1537 branchAddContextMenu->addAction ( actionEditImportReplace );
1540 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1541 branchRemoveContextMenu->addAction (actionEditCut);
1542 branchRemoveContextMenu->addAction ( actionEditDelete );
1543 branchRemoveContextMenu->addAction ( actionEditDeleteKeepChilds );
1544 branchRemoveContextMenu->addAction ( actionEditDeleteChilds );
1547 actionEditSaveBranch->addTo( branchContextMenu );
1549 branchContextMenu->addSeparator();
1550 branchContextMenu->addAction ( actionEditLoadImage);
1552 // Submenu for Links (URLs, vymLinks)
1553 branchLinksContextMenu =new QMenu (this);
1555 branchContextMenu->addSeparator();
1556 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1557 branchLinksContextMenu->addAction ( actionEditOpenURL );
1558 branchLinksContextMenu->addAction ( actionEditOpenURLTab );
1559 branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
1560 branchLinksContextMenu->addAction ( actionEditURL );
1561 branchLinksContextMenu->addAction ( actionEditLocalURL );
1562 branchLinksContextMenu->addAction ( actionEditHeading2URL );
1563 branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
1564 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1566 branchLinksContextMenu->addAction ( actionEditFATE2URL );
1568 branchLinksContextMenu->addSeparator();
1569 branchLinksContextMenu->addAction ( actionEditOpenVymLink );
1570 branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
1571 branchLinksContextMenu->addAction ( actionEditVymLink );
1572 branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
1575 // Context Menu for XLinks in a branch menu
1576 // This will be populated "on demand" in MapEditor::updateActions
1577 branchContextMenu->addSeparator();
1578 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1579 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1580 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1581 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1584 // Context menu for floatimage
1585 floatimageContextMenu =new QMenu (this);
1586 a= new QAction (tr ("Save image","Context action"),this);
1587 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1588 floatimageContextMenu->addAction (a);
1590 floatimageContextMenu->addSeparator();
1591 actionEditCopy->addTo( floatimageContextMenu );
1592 actionEditCut->addTo( floatimageContextMenu );
1594 floatimageContextMenu->addSeparator();
1595 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1598 // Context menu for canvas
1599 canvasContextMenu =new QMenu (this);
1600 actionEditMapInfo->addTo( canvasContextMenu );
1601 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1602 actionEditAddMapCenter->addTo( canvasContextMenu );
1603 canvasContextMenu->insertSeparator();
1604 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1605 canvasContextMenu->insertSeparator();
1606 actionFormatLinkColorHint->addTo( canvasContextMenu );
1607 actionFormatLinkColor->addTo( canvasContextMenu );
1608 actionFormatSelectionColor->addTo( canvasContextMenu );
1609 actionFormatBackColor->addTo( canvasContextMenu );
1610 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME makes vym too slow: postponed for later version
1612 // Menu for last opened files
1614 for (int i = 0; i < MaxRecentFiles; ++i)
1616 recentFileActions[i] = new QAction(this);
1617 recentFileActions[i]->setVisible(false);
1618 fileLastMapsMenu->addAction(recentFileActions[i]);
1619 connect(recentFileActions[i], SIGNAL(triggered()),
1620 this, SLOT(fileLoadRecent()));
1622 setupRecentMapsMenu();
1625 void Main::setupRecentMapsMenu()
1627 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1629 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1631 for (int i = 0; i < numRecentFiles; ++i) {
1632 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1633 recentFileActions[i]->setText(text);
1634 recentFileActions[i]->setData(files[i]);
1635 recentFileActions[i]->setVisible(true);
1637 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1638 recentFileActions[j]->setVisible(false);
1641 void Main::setupMacros()
1643 for (int i = 0; i <= 11; i++)
1645 macroActions[i] = new QAction(this);
1646 macroActions[i]->setData(i);
1647 addAction (macroActions[i]);
1648 connect(macroActions[i], SIGNAL(triggered()),
1649 this, SLOT(callMacro()));
1651 macroActions[0]->setShortcut ( Qt::Key_F1 );
1652 macroActions[1]->setShortcut ( Qt::Key_F2 );
1653 macroActions[2]->setShortcut ( Qt::Key_F3 );
1654 macroActions[3]->setShortcut ( Qt::Key_F4 );
1655 macroActions[4]->setShortcut ( Qt::Key_F5 );
1656 macroActions[5]->setShortcut ( Qt::Key_F6 );
1657 macroActions[6]->setShortcut ( Qt::Key_F7 );
1658 macroActions[7]->setShortcut ( Qt::Key_F8 );
1659 macroActions[8]->setShortcut ( Qt::Key_F9 );
1660 macroActions[9]->setShortcut ( Qt::Key_F10 );
1661 macroActions[10]->setShortcut ( Qt::Key_F11 );
1662 macroActions[11]->setShortcut ( Qt::Key_F12 );
1665 void Main::hideEvent (QHideEvent * )
1667 if (!textEditor->isMinimized() ) textEditor->hide();
1670 void Main::showEvent (QShowEvent * )
1672 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1676 MapEditor* Main::currentMapEditor() const
1678 if ( tabWidget->currentPage() &&
1679 tabWidget->currentPage()->inherits( "MapEditor" ) )
1680 return (MapEditor*)tabWidget->currentPage();
1685 void Main::editorChanged(QWidget *)
1687 // Unselect all possibly selected objects
1688 // (Important to update note editor)
1690 for (int i=0;i<=tabWidget->count() -1;i++)
1693 me=(MapEditor*)tabWidget->page(i);
1696 currentMapEditor()->reselect();
1698 // Update actions to in menus and toolbars according to editor
1702 void Main::fileNew()
1704 QString fn="unnamed";
1705 MapEditor* me = new MapEditor ( NULL);
1706 tabWidget->addTab (me,fn);
1707 tabWidget->showPage(me);
1708 me->viewport()->setFocus();
1709 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1710 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1712 // For the very first map we do not have flagrows yet...
1716 void Main::fileNewCopy()
1718 QString fn="unnamed";
1719 MapEditor* oldME =currentMapEditor();
1723 MapEditor* newME = new MapEditor ( NULL);
1726 tabWidget->addTab (newME,fn);
1727 tabWidget->showPage(newME);
1728 newME->viewport()->setFocus();
1729 newME->setAntiAlias (actionViewToggleAntiAlias->isOn());
1730 newME->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1731 // For the very first map we do not have flagrows yet...
1732 newME->select("mc:");
1733 newME->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
1739 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
1741 ErrorCode err=success;
1743 // fn is usually the archive, mapfile the file after uncompressing
1746 // Make fn absolute (needed for unzip)
1747 fn=QDir (fn).absPath();
1753 // Check, if map is already loaded
1755 while (i<=tabWidget->count() -1)
1757 me=(MapEditor*)tabWidget->page(i);
1758 if (me->getFilePath() == fn)
1760 // Already there, ask for confirmation
1761 QMessageBox mb( vymName,
1762 tr("The map %1\nis already opened."
1763 "Opening the same map in multiple editors may lead \n"
1764 "to confusion when finishing working with vym."
1765 "Do you want to").arg(fn),
1766 QMessageBox::Warning,
1767 QMessageBox::Yes | QMessageBox::Default,
1768 QMessageBox::Cancel | QMessageBox::Escape,
1769 QMessageBox::NoButton);
1770 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1771 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1774 case QMessageBox::Yes:
1776 i=tabWidget->count();
1778 case QMessageBox::Cancel:
1790 if ( !fn.isEmpty() )
1792 me = currentMapEditor();
1793 int tabIndex=tabWidget->currentPageIndex();
1794 // Check first, if mapeditor exists
1795 // If it is not default AND we want a new map,
1796 // create a new mapeditor in a new tab
1797 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1799 me= new MapEditor ( NULL);
1800 tabWidget->addTab (me,fn);
1801 tabIndex=tabWidget->indexOf (me);
1802 tabWidget->setCurrentPage (tabIndex);
1803 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1804 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1807 // Check, if file exists (important for creating new files
1808 // from command line
1809 if (!QFile(fn).exists() )
1811 QMessageBox mb( vymName,
1812 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1813 QMessageBox::Question,
1815 QMessageBox::Cancel | QMessageBox::Default,
1816 QMessageBox::NoButton );
1818 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1819 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1822 case QMessageBox::Yes:
1824 currentMapEditor()->setFilePath(fn);
1825 tabWidget->setTabLabel (currentMapEditor(),
1826 currentMapEditor()->getFileName() );
1827 statusBar()->message( "Created " + fn , statusbarTime );
1830 case QMessageBox::Cancel:
1831 // don't create new map
1832 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1839 //tabWidget->currentPage() won't be NULL here, because of above...
1840 tabWidget->showPage(me);
1841 me->viewport()->setFocus();
1845 // Save existing filename in case we import
1846 QString fn_org=me->getFilePath();
1848 // Finally load map into mapEditor
1849 me->setFilePath (fn);
1850 err=me->load(fn,lmode,ftype);
1852 // Restore old (maybe empty) filepath, if this is an import
1854 me->setFilePath (fn_org);
1857 // Finally check for errors and go home
1860 if (lmode==NewMap) fileCloseMap();
1861 statusBar()->message( "Could not load " + fn, statusbarTime );
1866 me->setFilePath (fn);
1867 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1868 if (!isInTmpDir (fn))
1870 // Only append to lastMaps if not loaded from a tmpDir
1871 // e.g. imported bookmarks are in a tmpDir
1872 addRecentMap(me->getFilePath() );
1874 actionFilePrint->setEnabled (true);
1876 statusBar()->message( "Loaded " + fn, statusbarTime );
1883 void Main::fileLoad(const LoadMode &lmode)
1885 QStringList filters;
1886 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1887 QFileDialog *fd=new QFileDialog( this);
1888 fd->setDir (lastFileDir);
1889 fd->setFileMode (QFileDialog::ExistingFiles);
1890 fd->setFilters (filters);
1894 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1897 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1900 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1906 if ( fd->exec() == QDialog::Accepted )
1908 lastFileDir=fd->directory().path();
1909 QStringList flist = fd->selectedFiles();
1910 QStringList::Iterator it = flist.begin();
1911 while( it != flist.end() )
1914 fileLoad(*it, lmode);
1921 void Main::fileLoad()
1926 void Main::fileLoadRecent()
1928 QAction *action = qobject_cast<QAction *>(sender());
1930 fileLoad (action->data().toString(), NewMap);
1933 void Main::addRecentMap (const QString &fileName)
1936 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1937 files.removeAll(fileName);
1938 files.prepend(fileName);
1939 while (files.size() > MaxRecentFiles)
1942 settings.setValue("/mainwindow/recentFileList", files);
1944 setupRecentMapsMenu();
1947 void Main::fileSave(MapEditor *me, const SaveMode &savemode)
1951 if ( me->getFilePath().isEmpty() )
1953 // We have no filepath yet,
1954 // call fileSaveAs() now, this will call fileSave()
1956 // First switch to editor
1957 tabWidget->setCurrentWidget (me);
1958 fileSaveAs(savemode);
1961 if (me->save (savemode)==success)
1963 statusBar()->message(
1964 tr("Saved %1").arg(me->getFilePath()),
1966 addRecentMap (me->getFilePath() );
1968 statusBar()->message(
1969 tr("Couldn't save ").arg(me->getFilePath()),
1973 void Main::fileSave()
1975 fileSave (currentMapEditor(), CompleteMap);
1978 void Main::fileSave(MapEditor *me)
1980 fileSave (me,CompleteMap);
1983 void Main::fileSaveAs(const SaveMode& savemode)
1987 if (currentMapEditor())
1989 if (savemode==CompleteMap)
1990 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
1992 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
1993 if ( !fn.isEmpty() )
1995 // Check for existing file
1996 if (QFile (fn).exists())
1998 QMessageBox mb( vymName,
1999 tr("The file %1\nexists already. Do you want to").arg(fn),
2000 QMessageBox::Warning,
2001 QMessageBox::Yes | QMessageBox::Default,
2002 QMessageBox::Cancel | QMessageBox::Escape,
2003 QMessageBox::NoButton);
2004 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2005 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2008 case QMessageBox::Yes:
2011 case QMessageBox::Cancel:
2018 // New file, add extension to filename, if missing
2019 // This is always .vym or .vyp, depending on savemode
2020 if (savemode==CompleteMap)
2022 if (!fn.contains (".vym") && !fn.contains (".xml"))
2026 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2035 currentMapEditor()->setFilePath(fn);
2036 fileSave(currentMapEditor(), savemode);
2039 if (savemode==CompleteMap)
2040 tabWidget->setTabLabel (currentMapEditor(),
2041 currentMapEditor()->getFileName() );
2047 void Main::fileSaveAs()
2049 fileSaveAs (CompleteMap);
2052 void Main::fileImportKDEBookmarks()
2054 ImportKDEBookmarks im;
2056 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2057 currentMapEditor()->setFilePath ("");
2060 void Main::fileImportFirefoxBookmarks()
2062 Q3FileDialog *fd=new Q3FileDialog( this);
2063 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2064 fd->setMode (Q3FileDialog::ExistingFiles);
2065 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2066 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2069 if ( fd->exec() == QDialog::Accepted )
2071 ImportFirefoxBookmarks im;
2072 QStringList flist = fd->selectedFiles();
2073 QStringList::Iterator it = flist.begin();
2074 while( it != flist.end() )
2077 if (im.transform() &&
2078 success==fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2079 currentMapEditor() )
2080 currentMapEditor()->setFilePath ("");
2087 void Main::fileImportFreemind()
2089 QStringList filters;
2090 filters <<"Freemind map (*.mm)"<<"All files (*)";
2091 QFileDialog *fd=new QFileDialog( this);
2092 fd->setDir (lastFileDir);
2093 fd->setFileMode (QFileDialog::ExistingFiles);
2094 fd->setFilters (filters);
2095 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2099 if ( fd->exec() == QDialog::Accepted )
2101 lastFileDir=fd->directory().path();
2102 QStringList flist = fd->selectedFiles();
2103 QStringList::Iterator it = flist.begin();
2104 while( it != flist.end() )
2107 if ( fileLoad (fn,NewMap, FreemindMap) )
2109 currentMapEditor()->setFilePath ("");
2118 void Main::fileImportMM()
2122 Q3FileDialog *fd=new Q3FileDialog( this);
2123 fd->setDir (lastFileDir);
2124 fd->setMode (Q3FileDialog::ExistingFiles);
2125 fd->addFilter ("Mind Manager (*.mmap)");
2126 fd->setCaption(tr("Import")+" "+"Mind Manager");
2129 if ( fd->exec() == QDialog::Accepted )
2131 lastFileDir=fd->dirPath();
2132 QStringList flist = fd->selectedFiles();
2133 QStringList::Iterator it = flist.begin();
2134 while( it != flist.end() )
2137 if (im.transform() &&
2138 success==fileLoad (im.getTransformedFile(),NewMap) &&
2139 currentMapEditor() )
2140 currentMapEditor()->setFilePath ("");
2149 void Main::fileImportDir()
2151 if (currentMapEditor())
2152 currentMapEditor()->importDir();
2155 void Main::fileExportXML()
2157 MapEditor *me=currentMapEditor();
2158 if (me) me->exportXML();
2162 void Main::fileExportXHTML()
2164 MapEditor *me=currentMapEditor();
2165 if (me) me->exportXHTML();
2168 void Main::fileExportImage()
2170 MapEditor *me=currentMapEditor();
2171 if (me) me->exportImage();
2174 void Main::fileExportASCII()
2176 MapEditor *me=currentMapEditor();
2177 if (me) me->exportASCII();
2180 void Main::fileExportCSV() //FIXME not scriptable yet
2182 MapEditor *me=currentMapEditor();
2186 ex.setModel (me->getModel());
2187 ex.addFilter ("CSV (*.csv)");
2188 ex.setDir(lastImageDir);
2189 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2190 if (ex.execDialog() )
2192 me->setExportMode(true);
2194 me->setExportMode(false);
2199 void Main::fileExportLaTeX() //FIXME not scriptable yet
2201 MapEditor *me=currentMapEditor();
2205 ex.setModel (me->getModel());
2206 ex.addFilter ("Tex (*.tex)");
2207 ex.setDir(lastImageDir);
2208 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2209 if (ex.execDialog() )
2211 me->setExportMode(true);
2213 me->setExportMode(false);
2218 void Main::fileExportKDEBookmarks() //FIXME not scriptable yet
2220 ExportKDEBookmarks ex;
2221 MapEditor *me=currentMapEditor();
2224 ex.setModel (me->getModel());
2229 void Main::fileExportTaskjuggler() //FIXME not scriptable yet
2231 ExportTaskjuggler ex;
2232 MapEditor *me=currentMapEditor();
2235 ex.setModel (me->getModel());
2236 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2237 ex.setDir(lastImageDir);
2238 ex.addFilter ("Taskjuggler (*.tjp)");
2239 if (ex.execDialog() )
2241 me->setExportMode(true);
2243 me->setExportMode(false);
2248 void Main::fileExportOOPresentation() //FIXME not scriptable yet
2250 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2251 // TODO add preview in dialog
2252 //ImagePreview *p =new ImagePreview (fd);
2253 //fd->setContentsPreviewEnabled( TRUE );
2254 //fd->setContentsPreview( p, p );
2255 //fd->setPreviewMode( QFileDialog::Contents );
2256 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2257 fd->setDir (QDir().current());
2258 if (fd->foundConfig())
2262 if ( fd->exec() == QDialog::Accepted )
2264 QString fn=fd->selectedFile();
2265 if (!fn.contains (".odp"))
2268 //lastImageDir=fn.left(fn.findRev ("/"));
2269 if (currentMapEditor())
2270 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2274 QMessageBox::warning(0,
2276 tr("Couldn't find configuration for export to Open Office\n"));
2280 void Main::fileCloseMap()
2282 MapEditor *me = currentMapEditor();
2285 if (me->hasChanged())
2287 QMessageBox mb( vymName,
2288 tr("The map %1 has been modified but not saved yet. Do you want to").arg(me->getFileName()),
2289 QMessageBox::Warning,
2290 QMessageBox::Yes | QMessageBox::Default,
2292 QMessageBox::Cancel | QMessageBox::Escape );
2293 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2294 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2297 case QMessageBox::Yes:
2299 fileSave(me, CompleteMap);
2301 case QMessageBox::No:
2302 // close without saving
2304 case QMessageBox::Cancel:
2310 tabWidget->removePage(me);
2311 if (tabWidget->count()==0)
2312 actionFilePrint->setEnabled (false);
2317 void Main::filePrint()
2319 if (currentMapEditor())
2320 currentMapEditor()->print();
2323 void Main::fileExitVYM()
2325 // Check if one or more editors have changed
2328 for (i=0;i<=tabWidget->count() -1;i++)
2331 me=(MapEditor*)tabWidget->page(i);
2333 // If something changed, ask what to do
2334 if (me->hasChanged())
2336 tabWidget->setCurrentPage(i);
2337 QMessageBox mb( vymName,
2338 tr("This map is not saved yet. Do you want to"),
2339 QMessageBox::Warning,
2340 QMessageBox::Yes | QMessageBox::Default,
2342 QMessageBox::Cancel | QMessageBox::Escape );
2343 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2344 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2347 mb.setActiveWindow();
2348 switch( mb.exec() ) {
2349 case QMessageBox::Yes:
2350 // save (the changed editors) and exit
2351 fileSave(currentMapEditor(), CompleteMap);
2353 case QMessageBox::No:
2354 // exit without saving
2356 case QMessageBox::Cancel:
2357 // don't save and don't exit
2361 } // loop over all MEs
2365 void Main::editUndo()
2367 if (currentMapEditor())
2368 currentMapEditor()->undo();
2371 void Main::editRedo()
2373 if (currentMapEditor())
2374 currentMapEditor()->redo();
2377 void Main::gotoHistoryStep (int i)
2379 if (currentMapEditor())
2380 currentMapEditor()->gotoHistoryStep (i);
2383 void Main::editCopy()
2385 if (currentMapEditor())
2386 currentMapEditor()->copy();
2389 void Main::editPaste()
2391 if (currentMapEditor())
2392 currentMapEditor()->paste();
2395 void Main::editCut()
2397 if (currentMapEditor())
2398 currentMapEditor()->cut();
2401 void Main::editOpenFindWindow()
2403 findWindow->popup();
2404 findWindow->raise();
2405 findWindow->setActiveWindow();
2408 void Main::editFind(QString s)
2411 BranchObj *bo=currentMapEditor()->findText(s, cs);
2414 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2417 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2418 tr("No matches found for \"%1\"").arg(s));
2422 void Main::editFindChanged()
2423 { // Notify editor, to abort the current find process
2424 currentMapEditor()->findReset();
2427 void Main::openTabs(QStringList urls)
2429 if (!urls.isEmpty())
2433 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2435 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2437 QString u=urls.takeFirst();
2438 procBrowser = new QProcess( this );
2440 procBrowser->start(browser,args);
2441 if ( !procBrowser->waitForStarted())
2443 // try to set path to browser
2444 QMessageBox::warning(0,
2446 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2447 tr("Please use Settings->")+tr("Set application to open an URL"));
2450 #if defined(Q_OS_WIN32)
2451 // There's no sleep in VCEE, replace it with Qt's QThread::wait().
2452 this->thread()->wait(3000);
2457 if (browser.contains("konqueror"))
2459 for (int i=0; i<urls.size(); i++)
2462 // Try to open new tab in existing konqueror started previously by vym
2463 p=new QProcess (this);
2465 #if defined(Q_OS_WIN32)
2466 // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
2467 // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
2468 args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
2469 "konqueror-mainwindow#1"<<
2473 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2474 "konqueror-mainwindow#1"<<
2478 p->start ("dcop",args);
2479 //cout << qPrintable (args.join(" "))<<endl;
2480 if ( !p->waitForStarted() ) success=false;
2483 QMessageBox::warning(0,
2485 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2487 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2489 for (int i=0; i<urls.size(); i++)
2491 // Try to open new tab in firefox
2492 p=new QProcess (this);
2493 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2494 p->start (browser,args);
2495 if ( !p->waitForStarted() ) success=false;
2498 QMessageBox::warning(0,
2500 tr("Couldn't start %1 to open a new tab").arg(browser));
2503 QMessageBox::warning(0,
2505 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2509 void Main::editOpenURL()
2512 if (currentMapEditor())
2514 QString url=currentMapEditor()->getURL();
2516 if (url=="") return;
2517 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2518 procBrowser = new QProcess( this );
2520 procBrowser->start(browser,args);
2521 if ( !procBrowser->waitForStarted())
2523 // try to set path to browser
2524 QMessageBox::warning(0,
2526 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2527 tr("Please use Settings->")+tr("Set application to open an URL"));
2532 void Main::editOpenURLTab()
2534 if (currentMapEditor())
2537 urls.append(currentMapEditor()->getURL());
2541 void Main::editOpenMultipleURLTabs()
2543 if (currentMapEditor())
2546 urls=currentMapEditor()->getURLs();
2552 void Main::editURL()
2554 if (currentMapEditor())
2555 currentMapEditor()->editURL();
2558 void Main::editLocalURL()
2560 if (currentMapEditor())
2561 currentMapEditor()->editLocalURL();
2564 void Main::editHeading2URL()
2566 if (currentMapEditor())
2567 currentMapEditor()->editHeading2URL();
2570 void Main::editBugzilla2URL()
2572 if (currentMapEditor())
2573 currentMapEditor()->editBugzilla2URL();
2576 void Main::editFATE2URL()
2578 if (currentMapEditor())
2579 currentMapEditor()->editFATE2URL();
2582 void Main::editHeadingFinished()
2584 // only called from editHeading(), so there is a currentME
2585 MapEditor *me=currentMapEditor();
2588 me->setStateEditHeading (false);
2589 QPoint p; //Not used here, only to find out pos of branch
2591 QString s=me->getHeading(ok,p);
2593 #if defined(Q_OS_MACX) || defined(Q_OS_WIN32)
2595 if (ok && s!=lineedit->text())
2596 me->setHeading(lineedit->text());
2598 lineedit->releaseKeyboard();
2602 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2603 !prevSelection.isEmpty())
2604 me->select(prevSelection);
2609 void Main::editHeading()
2611 if (currentMapEditor())
2613 MapEditor *me=currentMapEditor();
2614 QString oldSel=me->getSelectString();
2616 if (lineedit->isVisible())
2617 editHeadingFinished();
2622 QString s=me->getHeading(ok,p);
2626 me->setStateEditHeading (true);
2627 #if defined(Q_OS_MACX) || defined(Q_OS_WIN32)
2628 p=me->mapToGlobal (p);
2629 QDialog *d =new QDialog(NULL);
2630 QLineEdit *le=new QLineEdit (d);
2631 d->setWindowFlags (Qt::FramelessWindowHint);
2632 d->setGeometry(p.x(),p.y(),230,25);
2633 le->resize (d->width()-10,d->height());
2636 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2637 d->activateWindow();
2639 me->setHeading (le->text());
2642 editHeadingFinished();
2644 p=me->mapTo (this,p);
2645 lineedit->setGeometry(p.x(),p.y(),230,25);
2646 lineedit->setText(s);
2647 lineedit->setCursorPosition(1);
2648 lineedit->selectAll();
2650 lineedit->grabKeyboard();
2651 lineedit->setFocus();
2655 } // currentMapEditor()
2658 void Main::editAttributeFinished()
2660 // only called from editHeading(), so there is a currentME
2663 MapEditor *me=currentMapEditor();
2666 me->setStateEditHeading (false);
2667 QPoint p; //Not used here, only to find out pos of branch
2669 QString s=me->getHeading(ok,p);
2671 #if defined(Q_OS_MACX)
2673 if (ok && s!=lineedit->text())
2674 me->setHeading(lineedit->text());
2676 lineedit->releaseKeyboard();
2680 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2681 !prevSelection.isEmpty())
2682 me->select(prevSelection);
2688 #include "attribute.h"
2689 #include "attributedialog.h"
2690 void Main::editAttribute()
2692 MapEditor *me=currentMapEditor();
2695 BranchObj *bo=me->getSelectedBranch();
2698 AttributeDialog dia(this);
2699 dia.setTable (me->attributeTable() );
2701 dia.setMode (Definition);
2707 if (currentMapEditor())
2709 MapEditor *me=currentMapEditor();
2710 QString oldSel=me->getSelectString();
2712 if (lineedit->isVisible())
2713 editAttributeFinished();
2718 QString s=me->getHeading(ok,p);
2722 me->setStateEditHeading (true);
2723 #if defined(Q_OS_MACX)
2724 p=me->mapToGlobal (p);
2725 QDialog *d =new QDialog(NULL);
2726 QLineEdit *le=new QLineEdit (d);
2727 d->setWindowFlags (Qt::FramelessWindowHint);
2728 d->setGeometry(p.x(),p.y(),230,25);
2729 le->resize (d->width()-10,d->height());
2732 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2733 d->activateWindow();
2735 me->setHeading (le->text());
2738 editHeadingFinished();
2740 p=me->mapTo (this,p);
2741 lineedit->setGeometry(p.x(),p.y(),230,25);
2742 lineedit->setText(s);
2743 lineedit->setCursorPosition(1);
2744 lineedit->selectAll();
2746 lineedit->grabKeyboard();
2747 lineedit->setFocus();
2751 } // currentMapEditor()
2756 void Main::openVymLinks(const QStringList &vl)
2758 for (int j=0; j<vl.size(); j++)
2760 // compare path with already loaded maps
2764 for (i=0;i<=tabWidget->count() -1;i++)
2766 me=(MapEditor*)tabWidget->page(i);
2767 if (vl.at(j)==me->getFilePath() )
2776 if (!QFile(vl.at(j)).exists() )
2777 QMessageBox::critical( 0, tr( "Critical Error" ),
2778 tr("Couldn't open map %1").arg(vl.at(j)));
2781 fileLoad (vl.at(j), NewMap);
2782 tabWidget->setCurrentPage (tabWidget->count()-1);
2785 // Go to tab containing the map
2786 tabWidget->setCurrentPage (index);
2790 void Main::editOpenVymLink()
2792 if (currentMapEditor())
2795 vl.append(currentMapEditor()->getVymLink());
2800 void Main::editOpenMultipleVymLinks()
2802 QString currentVymLink;
2803 if (currentMapEditor())
2805 QStringList vl=currentMapEditor()->getVymLinks();
2810 void Main::editVymLink()
2812 if (currentMapEditor())
2813 currentMapEditor()->editVymLink();
2816 void Main::editDeleteVymLink()
2818 if (currentMapEditor())
2819 currentMapEditor()->deleteVymLink();
2822 void Main::editToggleHideExport()
2824 if (currentMapEditor())
2825 currentMapEditor()->toggleHideExport();
2828 void Main::editMapInfo()
2830 if (currentMapEditor())
2831 currentMapEditor()->editMapInfo();
2834 void Main::editMoveUp()
2836 if (currentMapEditor())
2837 currentMapEditor()->moveBranchUp();
2840 void Main::editMoveDown()
2842 if (currentMapEditor())
2843 currentMapEditor()->moveBranchDown();
2846 void Main::editSortChildren()
2848 if (currentMapEditor())
2849 currentMapEditor()->sortChildren();
2852 void Main::editToggleScroll()
2854 if (currentMapEditor())
2856 currentMapEditor()->toggleScroll();
2860 void Main::editUnscrollChilds()
2862 if (currentMapEditor())
2863 currentMapEditor()->unscrollChilds();
2866 void Main::editAddMapCenter()
2868 MapEditor *me=currentMapEditor();
2869 if (!lineedit->isVisible() && me)
2871 me->addMapCenter ();
2875 void Main::editNewBranch()
2877 MapEditor *me=currentMapEditor();
2878 if (!lineedit->isVisible() && me)
2880 BranchObj *bo=(BranchObj*)me->getSelection();
2881 BranchObj *newbo=me->addNewBranch(0);
2883 prevSelection=me->getModel()->getSelectString(bo);
2889 if (actionSettingsAutoEditNewBranch->isOn())
2894 if (!prevSelection.isEmpty())
2896 me->select(prevSelection);
2903 void Main::editNewBranchBefore()
2905 MapEditor *me=currentMapEditor();
2906 if (!lineedit->isVisible() && me)
2908 BranchObj *bo=(BranchObj*)me->getSelection();
2909 BranchObj *newbo=me->addNewBranchBefore();
2916 if (actionSettingsAutoEditNewBranch->isOn())
2918 if (!actionSettingsAutoSelectNewBranch->isOn())
2919 prevSelection=me->getModel()->getSelectString(bo); //TODO access directly
2925 void Main::editNewBranchAbove()
2927 MapEditor *me=currentMapEditor();
2928 if (!lineedit->isVisible() && me)
2930 BranchObj *bo=(BranchObj*)me->getSelection();
2931 BranchObj *newbo=me->addNewBranch (-1);
2938 if (actionSettingsAutoEditNewBranch->isOn())
2940 if (!actionSettingsAutoSelectNewBranch->isOn())
2941 prevSelection=me->getModel()->getSelectString (bo); // TODO access directly
2947 void Main::editNewBranchBelow()
2949 MapEditor *me=currentMapEditor();
2950 if (!lineedit->isVisible() && me)
2952 BranchObj *bo=(BranchObj*)me->getSelection();
2953 BranchObj *newbo=me->addNewBranch (1);
2960 if (actionSettingsAutoEditNewBranch->isOn())
2962 if (!actionSettingsAutoSelectNewBranch->isOn())
2963 prevSelection=me->getModel()->getSelectString(bo); //TODO access directly
2969 void Main::editImportAdd()
2971 fileLoad (ImportAdd);
2974 void Main::editImportReplace()
2976 fileLoad (ImportReplace);
2979 void Main::editSaveBranch()
2981 fileSaveAs (PartOfMap);
2984 void Main::editDeleteKeepChilds()
2986 if (currentMapEditor())
2987 currentMapEditor()->deleteKeepChilds();
2990 void Main::editDeleteChilds()
2992 if (currentMapEditor())
2993 currentMapEditor()->deleteChilds();
2996 void Main::editDeleteSelection()
2998 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2999 currentMapEditor()->deleteSelection();
3002 void Main::editUpperBranch()
3004 if (currentMapEditor())
3005 currentMapEditor()->selectUpperBranch();
3008 void Main::editLowerBranch()
3010 if (currentMapEditor())
3011 currentMapEditor()->selectLowerBranch();
3014 void Main::editLeftBranch()
3016 if (currentMapEditor())
3017 currentMapEditor()->selectLeftBranch();
3020 void Main::editRightBranch()
3022 if (currentMapEditor())
3023 currentMapEditor()->selectRightBranch();
3026 void Main::editFirstBranch()
3028 if (currentMapEditor())
3029 currentMapEditor()->selectFirstBranch();
3032 void Main::editLastBranch()
3034 if (currentMapEditor())
3035 currentMapEditor()->selectLastBranch();
3038 void Main::editLoadImage()
3040 if (currentMapEditor())
3041 currentMapEditor()->loadFloatImage();
3044 void Main::editSaveImage()
3046 if (currentMapEditor())
3047 currentMapEditor()->saveFloatImage();
3050 void Main::editFollowXLink(QAction *a)
3053 if (currentMapEditor())
3054 currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
3057 void Main::editEditXLink(QAction *a)
3059 if (currentMapEditor())
3060 currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3063 void Main::formatSelectColor()
3065 if (currentMapEditor())
3067 QColor col = QColorDialog::getColor((currentColor ), this );
3068 if ( !col.isValid() ) return;
3069 colorChanged( col );
3073 void Main::formatPickColor()
3075 if (currentMapEditor())
3076 colorChanged( currentMapEditor()->getCurrentHeadingColor() );
3079 void Main::colorChanged(QColor c)
3081 QPixmap pix( 16, 16 );
3083 actionFormatColor->setIconSet( pix );
3087 void Main::formatColorBranch()
3089 if (currentMapEditor())
3090 currentMapEditor()->colorBranch(currentColor);
3093 void Main::formatColorSubtree()
3095 if (currentMapEditor())
3096 currentMapEditor()->colorSubtree (currentColor);
3099 void Main::formatLinkStyleLine()
3101 if (currentMapEditor())
3103 currentMapEditor()->setMapLinkStyle("StyleLine");
3104 actionFormatLinkStyleLine->setOn(true);
3108 void Main::formatLinkStyleParabel()
3110 if (currentMapEditor())
3112 currentMapEditor()->setMapLinkStyle("StyleParabel");
3113 actionFormatLinkStyleParabel->setOn(true);
3117 void Main::formatLinkStylePolyLine()
3119 if (currentMapEditor())
3121 currentMapEditor()->setMapLinkStyle("StylePolyLine");
3122 actionFormatLinkStylePolyLine->setOn(true);
3126 void Main::formatLinkStylePolyParabel()
3128 if (currentMapEditor())
3130 currentMapEditor()->setMapLinkStyle("StylePolyParabel");
3131 actionFormatLinkStylePolyParabel->setOn(true);
3135 void Main::formatSelectBackColor()
3137 if (currentMapEditor())
3138 currentMapEditor()->selectMapBackgroundColor();
3141 void Main::formatSelectBackImage()
3143 if (currentMapEditor())
3144 currentMapEditor()->selectMapBackgroundImage();
3147 void Main::formatSelectLinkColor()
3149 if (currentMapEditor())
3150 currentMapEditor()->selectMapLinkColor();
3153 void Main::formatSelectSelectionColor()
3155 if (currentMapEditor())
3156 currentMapEditor()->selectMapSelectionColor();
3159 void Main::formatToggleLinkColorHint()
3161 currentMapEditor()->toggleMapLinkColorHint();
3165 void Main::formatHideLinkUnselected() //FIXME get rid of this with imagepropertydialog
3167 if (currentMapEditor())
3168 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3171 void Main::viewZoomReset()
3173 if (currentMapEditor())
3177 currentMapEditor()->setMatrix( m );
3181 void Main::viewZoomIn()
3183 if (currentMapEditor())
3185 QMatrix m = currentMapEditor()->matrix();
3186 m.scale( 1.25, 1.25 );
3187 currentMapEditor()->setMatrix( m );
3191 void Main::viewZoomOut()
3193 if (currentMapEditor())
3195 QMatrix m = currentMapEditor()->matrix();
3196 m.scale( 0.8, 0.8 );
3197 currentMapEditor()->setMatrix( m );
3201 void Main::viewCenter()
3203 MapEditor *me=currentMapEditor();
3206 me->ensureSelectionVisible();
3210 void Main::networkStartServer()
3212 MapEditor *me=currentMapEditor();
3213 if (me) me->newServer();
3216 void Main::networkConnect()
3218 MapEditor *me=currentMapEditor();
3219 if (me) me->connectToServer();
3222 bool Main::settingsPDF()
3224 // Default browser is set in constructor
3226 QString text = QInputDialog::getText(
3227 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3228 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3230 settings.setValue ("/mainwindow/readerPDF",text);
3235 bool Main::settingsURL()
3237 // Default browser is set in constructor
3239 QString text = QInputDialog::getText(
3240 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3241 settings.value("/mainwindow/readerURL").toString()
3244 settings.setValue ("/mainwindow/readerURL",text);
3248 void Main::settingsMacroDir()
3250 QDir defdir(vymBaseDir.path() + "/macros");
3251 if (!defdir.exists())
3253 QDir dir=QFileDialog::getExistingDirectory (
3255 tr ("Directory with vym macros:"),
3256 settings.value ("/macros/macroDir",defdir.path()).toString()
3259 settings.setValue ("/macros/macroDir",dir.absolutePath());
3262 void Main::settingsUndoLevels()
3265 int i = QInputDialog::getInteger(
3267 tr("QInputDialog::getInteger()"),
3268 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3271 settings.setValue ("/mapeditor/stepsTotal",i);
3272 QMessageBox::information( this, tr( "VYM -Information:" ),
3273 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3277 void Main::settingsAutosaveToggle()
3279 settings.setValue ("/mapeditor/autosave/use",actionSettingsAutosaveToggle->isOn() );
3282 void Main::settingsAutosaveTime()
3285 int i = QInputDialog::getInteger(
3287 tr("QInputDialog::getInteger()"),
3288 tr("Number of seconds before autosave:"), settings.value("/mapeditor/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3290 settings.setValue ("/mapeditor/autosave/ms",i * 1000);
3293 void Main::settingsWriteBackupFileToggle()
3295 settings.setValue ("/mapeditor/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
3298 void Main::settingsToggleDelKey()
3300 if (actionSettingsUseDelKey->isOn())
3302 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3305 actionEditDelete->setAccel (QKeySequence (""));
3309 void Main::windowToggleNoteEditor()
3311 if (textEditor->isVisible() )
3312 windowHideNoteEditor();
3314 windowShowNoteEditor();
3317 void Main::windowToggleHistory()
3319 if (historyWindow->isVisible())
3320 historyWindow->hide();
3322 historyWindow->show();
3326 void Main::windowToggleProperty()
3328 if (branchPropertyWindow->isVisible())
3329 branchPropertyWindow->hide();
3331 branchPropertyWindow->show();
3333 if(currentMapEditor())
3335 BranchObj *bo=currentMapEditor()->getSelectedBranch();
3338 branchPropertyWindow->setMapEditor(currentMapEditor());
3339 branchPropertyWindow->setBranch(bo);
3344 branchPropertyWindow->setBranch(NULL);
3347 void Main::windowToggleAntiAlias()
3349 bool b=actionViewToggleAntiAlias->isOn();
3351 for (int i=0;i<tabWidget->count();i++)
3354 me=(MapEditor*)tabWidget->page(i);
3355 me->setAntiAlias(b);
3360 void Main::windowToggleSmoothPixmap()
3362 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3364 for (int i=0;i<tabWidget->count();i++)
3367 me=(MapEditor*)tabWidget->page(i);
3368 me->setSmoothPixmap(b);
3372 void Main::updateHistory(SimpleSettings &undoSet)
3374 historyWindow->update (undoSet);
3377 void Main::updateNoteFlag()
3379 if (currentMapEditor())
3380 currentMapEditor()->updateNoteFlag();
3383 void Main::updateSatellites(MapEditor *me)
3385 branchPropertyWindow->setMapEditor (me);
3388 void Main::updateActions()
3390 MapEditor *me=currentMapEditor();
3393 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(currentMapEditor()->getFileName()));
3395 // updateActions is also called when NoteEditor is closed
3396 actionViewToggleNoteEditor->setOn (textEditor->isVisible());
3397 actionViewToggleHistoryWindow->setOn (historyWindow->isVisible());
3398 actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible());
3400 if (me->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3401 actionFormatLinkColorHint->setOn(true);
3403 actionFormatLinkColorHint->setOn(false);
3405 switch (me->getMapLinkStyle())
3407 case LinkableMapObj::Line:
3408 actionFormatLinkStyleLine->setOn(true);
3410 case LinkableMapObj::Parabel:
3411 actionFormatLinkStyleParabel->setOn(true);
3413 case LinkableMapObj::PolyLine:
3414 actionFormatLinkStylePolyLine->setOn(true);
3416 case LinkableMapObj::PolyParabel:
3417 actionFormatLinkStylePolyParabel->setOn(true);
3424 QPixmap pix( 16, 16 );
3425 pix.fill( me->getMapBackgroundColor() );
3426 actionFormatBackColor->setIconSet( pix );
3427 pix.fill( me->getSelectionColor() );
3428 actionFormatSelectionColor->setIconSet( pix );
3429 pix.fill( me->getMapDefLinkColor() );
3430 actionFormatLinkColor->setIconSet( pix );
3433 actionFileSave->setEnabled( me->hasChanged() );
3434 if (me->isUndoAvailable())
3435 actionEditUndo->setEnabled( true);
3437 actionEditUndo->setEnabled( false);
3439 if (me->isRedoAvailable())
3440 actionEditRedo->setEnabled( true);
3442 actionEditRedo->setEnabled( false);
3444 LinkableMapObj *selection=me->getSelection();
3447 if ( (typeid(*selection) == typeid(BranchObj)) ||
3448 (typeid(*selection) == typeid(MapCenterObj)) )
3450 BranchObj *bo=(BranchObj*)selection;
3451 // Take care of links
3452 if (bo->countXLinks()==0)
3454 branchXLinksContextMenuEdit->clear();
3455 branchXLinksContextMenuFollow->clear();
3460 branchXLinksContextMenuEdit->clear();
3461 branchXLinksContextMenuFollow->clear();
3462 for (int i=0; i<=bo->countXLinks();i++)
3464 bot=bo->XLinkTargetAt(i);
3467 s=bot->getHeading();
3468 if (s.length()>xLinkMenuWidth)
3469 s=s.left(xLinkMenuWidth)+"...";
3470 branchXLinksContextMenuFollow->addAction (s);
3471 branchXLinksContextMenuEdit->addAction (s);
3476 standardFlagsDefault->setEnabled (true);
3478 actionEditToggleScroll->setEnabled (true);
3479 if ( bo->isScrolled() )
3480 actionEditToggleScroll->setOn(true);
3482 actionEditToggleScroll->setOn(false);
3484 if ( bo->getURL().isEmpty() )
3486 actionEditOpenURL->setEnabled (false);
3487 actionEditOpenURLTab->setEnabled (false);
3491 actionEditOpenURL->setEnabled (true);
3492 actionEditOpenURLTab->setEnabled (true);
3494 if ( bo->getVymLink().isEmpty() )
3496 actionEditOpenVymLink->setEnabled (false);
3497 actionEditDeleteVymLink->setEnabled (false);
3500 actionEditOpenVymLink->setEnabled (true);
3501 actionEditDeleteVymLink->setEnabled (true);
3504 if (bo->canMoveBranchUp())
3505 actionEditMoveUp->setEnabled (true);
3507 actionEditMoveUp->setEnabled (false);
3508 if (bo->canMoveBranchDown())
3509 actionEditMoveDown->setEnabled (true);
3511 actionEditMoveDown->setEnabled (false);
3514 actionEditToggleHideExport->setEnabled (true);
3515 actionEditToggleHideExport->setOn (bo->hideInExport() );
3517 actionEditCopy->setEnabled (true);
3518 actionEditCut->setEnabled (true);
3519 if (!clipboardEmpty)
3520 actionEditPaste->setEnabled (true);
3522 actionEditPaste->setEnabled (false);
3523 for (int i=0; i<actionListBranches.size(); ++i)
3524 actionListBranches.at(i)->setEnabled(true);
3525 actionEditDelete->setEnabled (true);
3526 actionFormatHideLinkUnselected->setOn
3527 (selection->getHideLinkUnselected());
3529 if ( (typeid(*selection) == typeid(FloatImageObj)) )
3531 FloatObj *fo=(FloatImageObj*)selection;
3533 actionEditOpenURL->setEnabled (false);
3534 actionEditOpenVymLink->setEnabled (false);
3535 actionEditDeleteVymLink->setEnabled (false);
3536 actionEditToggleHideExport->setEnabled (true);
3537 actionEditToggleHideExport->setOn (fo->hideInExport() );
3540 actionEditCopy->setEnabled (true);
3541 actionEditCut->setEnabled (true);
3542 actionEditPaste->setEnabled (false);
3543 for (int i=0; i<actionListBranches.size(); ++i)
3544 actionListBranches.at(i)->setEnabled(false);
3545 actionEditDelete->setEnabled (true);
3546 actionFormatHideLinkUnselected->setOn
3547 ( selection->getHideLinkUnselected());
3548 actionEditMoveUp->setEnabled (false);
3549 actionEditMoveDown->setEnabled (false);
3554 actionEditCopy->setEnabled (false);
3555 actionEditCut->setEnabled (false);
3556 actionEditPaste->setEnabled (false);
3557 for (int i=0; i<actionListBranches.size(); ++i)
3558 actionListBranches.at(i)->setEnabled(false);
3560 actionEditToggleScroll->setEnabled (false);
3561 actionEditOpenURL->setEnabled (false);
3562 actionEditOpenVymLink->setEnabled (false);
3563 actionEditDeleteVymLink->setEnabled (false);
3564 actionEditHeading2URL->setEnabled (false);
3565 actionEditDelete->setEnabled (false);
3566 actionEditMoveUp->setEnabled (false);
3567 actionEditMoveDown->setEnabled (false);
3568 actionEditToggleHideExport->setEnabled (false);
3572 Main::ModMode Main::getModMode()
3574 if (actionModModeColor->isOn()) return ModModeColor;
3575 if (actionModModeCopy->isOn()) return ModModeCopy;
3576 if (actionModModeXLink->isOn()) return ModModeXLink;
3580 bool Main::autoEditNewBranch()
3582 return actionSettingsAutoEditNewBranch->isOn();
3585 bool Main::autoSelectNewBranch()
3587 return actionSettingsAutoSelectNewBranch->isOn();
3590 bool Main::useFlagGroups()
3592 return actionSettingsUseFlagGroups->isOn();
3595 void Main::windowShowNoteEditor()
3597 textEditor->setShowWithMain(true);
3599 actionViewToggleNoteEditor->setOn (true);
3602 void Main::windowHideNoteEditor()
3604 textEditor->setShowWithMain(false);
3606 actionViewToggleNoteEditor->setOn (false);
3609 void Main::setScript (const QString &script)
3611 scriptEditor->setScript (script);
3614 void Main::runScript (const QString &script)
3616 if (currentMapEditor())
3617 currentMapEditor()->runScript (script);
3620 void Main::runScriptEverywhere (const QString &script)
3623 for (int i=0;i<=tabWidget->count() -1;i++)
3625 me=(MapEditor*)tabWidget->page(i);
3626 if (me) me->runScript (script);
3630 void Main::windowNextEditor()
3632 if (tabWidget->currentPageIndex() < tabWidget->count())
3633 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3636 void Main::windowPreviousEditor()
3638 if (tabWidget->currentPageIndex() >0)
3639 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3642 void Main::standardFlagChanged()
3644 if (currentMapEditor())
3645 currentMapEditor()->toggleStandardFlag(sender()->name());
3648 void Main::testFunction1()
3650 if (!currentMapEditor()) return;
3651 //currentMapEditor()->testFunction1();
3655 void Main::testFunction2()
3657 if (!currentMapEditor()) return;
3658 currentMapEditor()->testFunction2();
3661 void Main::testCommand()
3663 if (!currentMapEditor()) return;
3664 scriptEditor->show();
3667 QString com = QInputDialog::getText(
3668 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3669 if (ok) currentMapEditor()->parseAtom(com);
3673 void Main::helpDoc()
3675 QString locale = QLocale::system().name();
3677 if (locale.left(2)=="es")
3678 docname="vym_es.pdf";
3682 QStringList searchList;
3684 #if defined(Q_OS_MACX)
3685 searchList << "./vym.app/Contents/Resources/doc";
3686 #elif defined(Q_OS_WIN32)
3687 searchList << vymInstallDir.path() + "/share/doc/packages/vym";
3689 #if defined(VYM_DOCDIR)
3690 searchList << VYM_DOCDIR;
3692 // default path in SUSE LINUX
3693 searchList << "/usr/share/doc/packages/vym";
3696 searchList << "doc"; // relative path for easy testing in tarball
3697 searchList << "doc/tex"; // Easy testing working on vym.tex
3698 searchList << "/usr/share/doc/vym"; // Debian
3699 searchList << "/usr/share/doc/packages";// Knoppix
3703 for (int i=0; i<searchList.count(); ++i)
3705 docfile.setFileName(searchList.at(i)+"/"+docname);
3706 if (docfile.exists())
3715 QMessageBox::critical(0,
3716 tr("Critcal error"),
3717 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3722 Process *pdfProc = new Process();
3723 args << QDir::toNativeSeparators(docfile.fileName());
3725 pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
3726 if ( !pdfProc->waitForStarted() )
3729 QMessageBox::warning(0,
3731 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3732 tr("Please use Settings->")+tr("Set application to open PDF files"));
3739 void Main::helpDemo()
3741 QStringList filters;
3742 filters <<"VYM example map (*.vym)";
3743 QFileDialog *fd=new QFileDialog( this);
3744 #if defined(Q_OS_MACX)
3745 fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
3747 // default path in SUSE LINUX
3748 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
3751 fd->setFileMode (QFileDialog::ExistingFiles);
3752 fd->setFilters (filters);
3753 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
3757 if ( fd->exec() == QDialog::Accepted )
3759 lastFileDir=fd->directory().path();
3760 QStringList flist = fd->selectedFiles();
3761 QStringList::Iterator it = flist.begin();
3762 while( it != flist.end() )
3765 fileLoad(*it, NewMap);
3773 void Main::helpAbout()
3776 ad.setName ("aboutwindow");
3777 ad.setMinimumSize(500,500);
3778 ad.resize (QSize (500,500));
3782 void Main::helpAboutQT()
3784 QMessageBox::aboutQt( this, "Qt Application Example" );
3787 void Main::callMacro ()
3789 QAction *action = qobject_cast<QAction *>(sender());
3793 i=action->data().toInt();
3794 QString mDir (settings.value ("macros/macroDir").toString() );
3796 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3798 if ( !f.open( QIODevice::ReadOnly ) )
3800 QMessageBox::warning(0,
3802 tr("Couldn't find a macro at %1.\n").arg(fn)+
3803 tr("Please use Settings->")+tr("Set directory for vym macros"));
3807 QTextStream ts( &f );
3808 QString m= ts.read();
3812 //cout <<"Main::callMacro m="<<qPrintable (m)<<endl;
3813 currentMapEditor()->runScript (m);
3820 //////////////////////////////////
3822 @@ -2544,18 +2576,27 @@
3823 // Try to open new tab in existing konqueror started previously by vym
3824 p=new QProcess (this);
3826 - args<< QString("konqueror-%1").arg(procBrowser->pid())<<
3827 - "konqueror-mainwindow#1"<<
3829 +#if defined(Q_OS_WIN32)
3830 + // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
3831 + // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
3832 + args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
3833 + "konqueror-mainwindow#1"<<
3837 + args<< QString("konqueror-%1").arg(procBrowser->pid())<<
3838 + "konqueror-mainwindow#1"<<
3842 p->start ("dcop",args);
3843 if ( !p->waitForStarted() ) success=false;