1 #include "mainwindow.h"
8 #include "aboutdialog.h"
9 #include "branchpropwindow.h"
10 #include "branchitem.h"
11 #include "exportoofiledialog.h"
15 #include "historywindow.h"
17 #include "mapeditor.h"
22 #include "texteditor.h"
23 #include "warningdialog.h"
24 #include "xlinkitem.h"
26 //#include <modeltest.h> // FIXME-3
28 #if defined(Q_OS_WIN32)
29 // Define only this structure as opposed to
30 // including full 'windows.h'. FindWindow
31 // clashes with the one in Win32 API.
32 typedef struct _PROCESS_INFORMATION
38 } PROCESS_INFORMATION, *LPPROCESS_INFORMATION;
41 extern TextEditor *textEditor;
42 extern Main *mainWindow;
43 extern QString tmpVymDir;
44 extern QString clipboardDir;
45 extern QString clipboardFile;
46 extern bool clipboardEmpty;
47 extern int statusbarTime;
48 extern FlagRow *standardFlagsMaster;
49 extern FlagRow *systemFlagsMaster;
50 extern QString vymName;
51 extern QString vymVersion;
52 extern QString vymBuildDate;
55 QMenu* branchContextMenu;
56 QMenu* branchAddContextMenu;
57 QMenu* branchRemoveContextMenu;
58 QMenu* branchLinksContextMenu;
59 QMenu* branchXLinksContextMenuEdit;
60 QMenu* branchXLinksContextMenuFollow;
61 QMenu* floatimageContextMenu;
62 QMenu* canvasContextMenu;
63 QMenu* fileLastMapsMenu;
64 QMenu* fileImportMenu;
65 QMenu* fileExportMenu;
68 extern Settings settings;
69 extern Options options;
70 extern ImageIO imageIO;
72 extern QDir vymBaseDir;
73 extern QDir lastImageDir;
74 extern QDir lastFileDir;
75 #if defined(Q_OS_WIN32)
76 extern QDir vymInstallDir;
78 extern QString iconPath;
79 extern QString flagsPath;
82 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
83 QMainWindow(parent,name,f)
87 setCaption ("VYM - View Your Mind");
89 // Load window settings
90 #if defined(Q_OS_WIN32)
91 if (settings.value("/mainwindow/geometry/maximized", false).toBool())
93 setWindowState(Qt::WindowMaximized);
98 resize (settings.value("/mainwindow/geometry/size", QSize (800,600)).toSize());
99 move (settings.value("/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
102 // Sometimes we may need to remember old selections
106 currentColor=Qt::black;
108 // Create unique temporary directory
110 tmpVymDir=makeTmpDir (ok,"vym");
113 qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
116 if (debug) qDebug (QString("vym tmpDir=%1").arg(tmpVymDir) );
118 // Create direcctory for clipboard
119 clipboardDir=tmpVymDir+"/clipboard";
120 clipboardFile="map.xml";
121 QDir d(clipboardDir);
122 d.mkdir (clipboardDir,true);
123 makeSubDirs (clipboardDir);
128 // Satellite windows //////////////////////////////////////////
130 historyWindow=new HistoryWindow();
131 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
134 branchPropertyWindow = new BranchPropertyWindow();
135 connect (branchPropertyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
137 // Connect TextEditor, so that we can update flags if text changes
138 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
139 connect (textEditor, 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 setCentralWidget(tabWidget);
208 setupFormatActions();
212 setupNetworkActions();
213 setupSettingsActions();
216 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
219 // Status bar and progress bar there
222 progressBar=new QProgressBar;
224 statusBar()->addPermanentWidget(progressBar);
226 restoreState (settings.value("/mainwindow/state",0).toByteArray());
234 #if defined(Q_OS_WIN32)
235 settings.setValue ("/mainwindow/geometry/maximized", isMaximized());
237 settings.setValue ("/mainwindow/geometry/size", size());
238 settings.setValue ("/mainwindow/geometry/pos", pos());
239 settings.setValue ("/mainwindow/state",saveState(0));
241 settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
242 settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
243 settings.setValue( "/version/version", vymVersion );
244 settings.setValue( "/version/builddate", vymBuildDate );
246 settings.setValue( "/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
247 settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isOn() );
248 settings.setValue( "/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
249 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
250 settings.setValue( "/mapeditor/editmode/autoEditNewBranch",actionSettingsAutoEditNewBranch->isOn() );
251 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
252 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
253 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
255 //TODO save scriptEditor settings
257 // call the destructors
259 delete historyWindow;
260 delete branchPropertyWindow;
263 // Remove temporary directory
264 removeDir (QDir(tmpVymDir));
267 void Main::loadCmdLine()
269 /* TODO draw some kind of splashscreen while loading...
275 QStringList flist=options.getFileList();
276 QStringList::Iterator it=flist.begin();
278 while (it !=flist.end() )
280 fileLoad (*it, NewMap);
286 void Main::statusMessage(const QString &s)
288 // Surpress messages while progressbar during
290 if (progressMin==progressMax)
291 statusBar()->message( s);
294 void Main::setProgressMinimum (int min)
296 progressBar->setMinimum(min);
300 void Main::setProgressMaximum (int max)
302 progressBar->setMaximum(max);
306 statusBar()->addPermanentWidget(progressBar);
311 void Main::setProgressValue (int v)
313 progressBar->setValue (v);
316 void Main::removeProgressBar()
319 statusBar()->removeWidget(progressBar);
320 progressMax=progressMin=0;
323 void Main::closeEvent (QCloseEvent* )
329 void Main::setupFileActions()
331 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
332 QToolBar *tb = addToolBar( tr ("&Map") );
333 tb->setObjectName ("mapTB");
336 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this);
337 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
338 a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map
340 fileMenu->addAction (a);
341 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
343 a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this);
344 a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) );
345 a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N ); //New map
346 fileMenu->addAction (a);
347 connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) );
350 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
351 a->setStatusTip (tr( "Open","Status tip File menu" ) );
352 a->setShortcut ( Qt::CTRL + Qt::Key_O ); //Open map
354 fileMenu->addAction (a);
355 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
357 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
358 fileMenu->addSeparator();
360 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
361 a->setStatusTip ( tr( "Save","Status tip file menu" ));
362 a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map
364 fileMenu->addAction (a);
365 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
368 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
369 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
370 fileMenu->addAction (a);
371 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
373 fileMenu->addSeparator();
375 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
377 a = new QAction(tr("KDE 3 Bookmarks"), this);
378 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 3 bookmarks")));
379 a->addTo (fileImportMenu);
380 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE3Bookmarks() ) );
382 a = new QAction(tr("KDE 4 Bookmarks"), this);
383 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 4 bookmarks")));
384 a->addTo (fileImportMenu);
385 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE4Bookmarks() ) );
387 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
389 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
390 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
391 a->addTo (fileImportMenu);
392 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
395 a = new QAction("Freemind...",this);
396 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Freemind") );
397 fileImportMenu->addAction (a);
398 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFreemind() ) );
400 a = new QAction("Mind Manager...",this);
401 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
402 fileImportMenu->addAction (a);
403 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
405 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
406 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
407 fileImportMenu->addAction (a);
408 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
410 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
412 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
413 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
414 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
415 fileExportMenu->addAction (a);
417 a = new QAction( "Open Office...", this);
418 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
419 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
420 fileExportMenu->addAction (a);
422 a = new QAction( "Webpage (XHTML)...",this );
423 a->setShortcut (Qt::ALT + Qt::Key_X); //Export XHTML
424 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
425 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
426 fileExportMenu->addAction (a);
428 a = new QAction( "Text (ASCII)...", this);
429 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
430 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
431 fileExportMenu->addAction (a);
433 a = new QAction( "Spreadsheet (CSV)...", this);
434 a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
435 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
436 fileExportMenu->addAction (a);
438 a = new QAction( tr("KDE 3 Bookmarks","File menu"), this);
439 a->setStatusTip( tr( "Export as %1").arg(tr("KDE 3 Bookmarks" )));
440 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE3Bookmarks() ) );
441 fileExportMenu->addAction (a);
443 a = new QAction( tr("KDE 4 Bookmarks","File menu"), this);
444 a->setStatusTip( tr( "Export as %1").arg(tr("KDE 4 Bookmarks" )));
445 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE4Bookmarks() ) );
446 fileExportMenu->addAction (a);
448 a = new QAction( "Taskjuggler...", this );
449 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
450 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
451 fileExportMenu->addAction (a);
453 a = new QAction( "LaTeX...", this);
454 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
455 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
456 fileExportMenu->addAction (a);
458 a = new QAction( "XML..." , this );
459 a->setStatusTip (tr( "Export as %1").arg("XML"));
460 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
461 fileExportMenu->addAction (a);
463 fileMenu->addSeparator();
465 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
466 a->setStatusTip ( tr( "Print" ,"File menu") );
467 a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map
469 fileMenu->addAction (a);
470 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
473 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
474 a->setStatusTip (tr( "Close Map" ) );
475 a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map
476 fileMenu->addAction (a);
477 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
479 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
480 a->setStatusTip ( tr( "Exit")+" "+vymName );
481 a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym
482 fileMenu->addAction (a);
483 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
488 void Main::setupEditActions()
490 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
491 tb->setLabel( "Edit Actions" );
492 tb->setObjectName ("actionsTB");
493 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
497 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
498 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
499 a->setStatusTip (tr( "Undo" ) );
500 a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action
501 a->setEnabled (false);
503 editMenu->addAction (a);
506 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
507 a->setStatusTip (tr( "Redo" ));
508 a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action
510 editMenu->addAction (a);
511 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
514 editMenu->addSeparator();
515 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
516 a->setStatusTip ( tr( "Copy" ) );
517 a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy
518 a->setEnabled (false);
520 editMenu->addAction (a);
521 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
524 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
525 a->setStatusTip ( tr( "Cut" ) );
526 a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut
527 a->setEnabled (false);
529 editMenu->addAction (a);
531 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
533 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
534 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
535 a->setStatusTip ( tr( "Paste" ) );
536 a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste
537 a->setEnabled (false);
539 editMenu->addAction (a);
542 // Shortcut to delete selection
543 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
544 a->setStatusTip (tr( "Delete Selection" ));
545 a->setShortcut ( Qt::Key_Delete); //Delete selection
546 a->setShortcutContext (Qt::WindowShortcut);
548 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
551 // Shortcut to add attribute
552 a= new QAction(tr( "Add attribute" ), this);
553 a->setShortcut ( Qt::Key_Q);
554 a->setShortcutContext (Qt::WindowShortcut);
556 connect( a, SIGNAL( triggered() ), this, SLOT( editAddAttribute() ) );
557 actionAddAttribute= a;
560 // Shortcut to add mapcenter
561 a= new QAction(QPixmap(iconPath+"newmapcenter.png"),tr( "Add mapcenter","Canvas context menu" ), this);
562 a->setShortcut ( Qt::Key_M);
563 a->setShortcutContext (Qt::WindowShortcut);
564 connect( a, SIGNAL( triggered() ), this, SLOT( editAddMapCenter() ) );
565 //actionListBranches.append(a);
567 actionAddMapCenter = a;
570 // Shortcut to add branch
571 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
572 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
573 alt->setShortcut (Qt::Key_A); //Add branch
574 alt->setShortcutContext (Qt::WindowShortcut);
576 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
577 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
578 a->setStatusTip ( tr( "Add a branch as child of selection" ));
579 a->setShortcut (Qt::Key_Insert); //Add branch
580 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
581 actionListBranches.append(a);
582 #if defined (Q_OS_MACX)
583 // In OSX show different shortcut in menues, the keys work indepently always
588 editMenu->addAction (actionAddBranch);
589 tb->addAction (actionAddBranch);
592 // Add branch by inserting it at selection
593 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
594 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
595 a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch
596 a->setShortcutContext (Qt::WindowShortcut);
598 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
599 a->setEnabled (false);
600 actionListBranches.append(a);
601 actionAddBranchBefore=a;
602 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
603 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
604 a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch
605 a->setShortcutContext (Qt::WindowShortcut);
607 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
608 actionListBranches.append(a);
611 a = new QAction(tr( "Add branch above","Edit menu" ), this);
612 a->setStatusTip ( tr( "Add a branch above selection" ));
613 a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
614 a->setShortcutContext (Qt::WindowShortcut);
616 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
617 a->setEnabled (false);
618 actionListBranches.append(a);
619 actionAddBranchAbove=a;
620 a = new QAction(tr( "Add branch above","Edit menu" ), this);
621 a->setStatusTip ( tr( "Add a branch above selection" ));
622 a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above
623 a->setShortcutContext (Qt::WindowShortcut);
625 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
626 actionListBranches.append(a);
629 a = new QAction(tr( "Add branch below","Edit menu" ), this);
630 a->setStatusTip ( tr( "Add a branch below selection" ));
631 a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
632 a->setShortcutContext (Qt::WindowShortcut);
634 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
635 a->setEnabled (false);
636 actionListBranches.append(a);
637 actionAddBranchBelow=a;
638 a = new QAction(tr( "Add branch below","Edit menu" ), this);
639 a->setStatusTip ( tr( "Add a branch below selection" ));
640 a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below
641 a->setShortcutContext (Qt::WindowShortcut);
643 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
644 actionListBranches.append(a);
646 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
647 a->setStatusTip ( tr( "Move branch up" ) );
648 a->setShortcut (Qt::Key_PageUp ); // Move branch up
649 a->setEnabled (false);
651 editMenu->addAction (a);
652 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
655 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
656 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
657 a->setStatusTip (tr( "Move branch down" ) );
658 a->setShortcut ( Qt::Key_PageDown ); // Move branch down
659 a->setEnabled (false);
661 editMenu->addAction (a);
664 a = new QAction(QPixmap(), tr( "&Detach","Context menu" ),this);
665 a->setStatusTip ( tr( "Detach branch and use as mapcenter","Context menu" ) );
666 a->setShortcut ( Qt::Key_D ); // Detach branch
667 editMenu->addAction (a);
668 connect( a, SIGNAL( triggered() ), this, SLOT( editDetach() ) );
671 a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this );
672 connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) );
673 a->setEnabled (true);
675 editMenu->addAction (a);
676 actionSortChildren=a;
678 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
679 alt->setShortcut ( Qt::Key_S ); // Scroll branch
680 alt->setStatusTip (tr( "Scroll branch" ));
681 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
682 #if defined(Q_OS_MACX)
683 actionToggleScroll=alt;
685 actionToggleScroll=a;
687 actionToggleScroll->setEnabled (false);
688 actionToggleScroll->setToggleAction(true);
689 tb->addAction (actionToggleScroll);
690 editMenu->addAction ( actionToggleScroll);
691 editMenu->addAction (actionToggleScroll);
694 actionListBranches.append(actionToggleScroll);
696 a = new QAction( QPixmap(), tr( "Expand all branches","Edit menu" ), this);
697 a->setShortcut ( Qt::SHIFT + Qt::Key_X ); // Expand all branches
698 a->setStatusTip (tr( "Expand all branches" ));
699 connect( a, SIGNAL( triggered() ), this, SLOT( editExpandAll() ) );
701 actionExpandAll->setEnabled (false);
702 actionExpandAll->setToggleAction(false);
703 //tb->addAction (actionExpandAll);
704 editMenu->addAction ( actionExpandAll);
706 actionListBranches.append(actionExpandAll);
709 a = new QAction( tr( "Unscroll children","Edit menu" ), this);
710 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
711 editMenu->addAction (a);
712 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChildren() ) );
714 editMenu->addSeparator();
716 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
717 a->setStatusTip (tr( "Find" ) );
718 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
719 editMenu->addAction (a);
720 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
722 editMenu->addSeparator();
724 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
725 a->setShortcut (Qt::CTRL + Qt::Key_U );
726 a->setShortcut (tr( "Open URL" ));
729 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
732 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
733 a->setStatusTip (tr( "Open URL in new tab" ));
734 //a->setShortcut (Qt::CTRL+Qt::Key_U );
736 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
739 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
740 a->setStatusTip (tr( "Open all URLs in subtree" ));
742 actionListBranches.append(a);
743 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
744 actionOpenMultipleURLTabs=a;
746 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
747 a->setStatusTip ( tr( "Edit URL" ) );
748 a->setShortcut ( Qt::Key_U );
749 a->setShortcutContext (Qt::WindowShortcut);
750 actionListBranches.append(a);
752 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
755 a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
756 a->setStatusTip ( tr( "Edit local URL" ) );
757 a->setShortcut (Qt::SHIFT + Qt::Key_U );
758 a->setShortcutContext (Qt::WindowShortcut);
759 actionListBranches.append(a);
761 connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
764 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
765 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
766 a->setEnabled (false);
767 actionListBranches.append(a);
768 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
771 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
772 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
773 a->setEnabled (false);
774 actionListBranches.append(a);
775 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
776 actionBugzilla2URL=a;
778 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
779 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
780 a->setEnabled (false);
781 actionListBranches.append(a);
782 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
785 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
786 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
788 a->setEnabled (false);
789 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
792 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
793 a->setStatusTip ( tr( "Open all vym links in subtree" ));
794 a->setEnabled (false);
795 actionListBranches.append(a);
796 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
797 actionOpenMultipleVymLinks=a;
800 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
801 a->setEnabled (false);
802 a->setStatusTip ( tr( "Edit link to another vym map" ));
803 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
804 actionListBranches.append(a);
807 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
808 a->setStatusTip ( tr( "Delete link to another vym map" ));
809 a->setEnabled (false);
810 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
811 actionDeleteVymLink=a;
813 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
814 a->setStatusTip ( tr( "Hide object in exports" ) );
815 a->setShortcut (Qt::Key_H );
816 a->setToggleAction(true);
818 a->setEnabled (false);
819 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
820 actionToggleHideExport=a;
822 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
823 a->setStatusTip ( tr( "Edit Map Info" ));
824 a->setEnabled (true);
825 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
828 // Import at selection (adding to selection)
829 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
830 a->setStatusTip (tr( "Add map at selection" ));
831 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
832 a->setEnabled (false);
833 actionListBranches.append(a);
836 // Import at selection (replacing selection)
837 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
838 a->setStatusTip (tr( "Replace selection with map" ));
839 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
840 a->setEnabled (false);
841 actionListBranches.append(a);
842 actionImportReplace=a;
845 a = new QAction( tr( "Save selection","Edit menu" ), this);
846 a->setStatusTip (tr( "Save selection" ));
847 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
848 a->setEnabled (false);
849 actionListBranches.append(a);
852 // Only remove branch, not its children
853 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
854 a->setStatusTip ( tr( "Remove only branch and keep its children" ));
855 a->setShortcut (Qt::ALT + Qt::Key_Delete );
856 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChildren() ) );
857 a->setEnabled (false);
859 actionListBranches.append(a);
860 actionDeleteKeepChildren=a;
862 // Only remove children of a branch
863 a = new QAction( tr( "Remove children","Edit menu" ), this);
864 a->setStatusTip (tr( "Remove children of branch" ));
865 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
866 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChildren() ) );
867 a->setEnabled (false);
868 actionListBranches.append(a);
869 actionDeleteChildren=a;
871 a = new QAction( tr( "Add Image...","Edit menu" ), this);
872 a->setStatusTip (tr( "Add Image" ));
873 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
876 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
877 a->setStatusTip (tr( "Set properties for selection" ));
878 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
879 a->setShortcutContext (Qt::WindowShortcut);
880 a->setToggleAction (true);
882 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
883 actionViewTogglePropertyWindow=a;
887 void Main::setupFormatActions()
889 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
891 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
892 tb->setObjectName ("formatTB");
895 pix.fill (Qt::black);
896 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
897 a->setStatusTip ( tr( "Set Color" ));
898 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
900 formatMenu->addAction (a);
902 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
903 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
904 a->setShortcut (Qt::CTRL + Qt::Key_K );
905 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
906 a->setEnabled (false);
908 formatMenu->addAction (a);
909 actionListBranches.append(a);
910 actionFormatPickColor=a;
912 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
913 a->setStatusTip ( tr( "Color branch" ) );
914 a->setShortcut (Qt::CTRL + Qt::Key_B);
915 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
916 a->setEnabled (false);
918 formatMenu->addAction (a);
919 actionListBranches.append(a);
920 actionFormatColorSubtree=a;
922 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
923 a->setStatusTip ( tr( "Color Subtree" ));
924 a->setShortcut (Qt::CTRL + Qt::Key_T);
925 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
926 a->setEnabled (false);
927 formatMenu->addAction (a);
929 actionListBranches.append(a);
930 actionFormatColorSubtree=a;
932 formatMenu->addSeparator();
933 actionGroupFormatLinkStyles=new QActionGroup ( this);
934 actionGroupFormatLinkStyles->setExclusive (true);
935 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
936 a->setStatusTip (tr( "Line" ));
937 a->setToggleAction(true);
938 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
939 formatMenu->addAction (a);
940 actionFormatLinkStyleLine=a;
941 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
942 a->setStatusTip (tr( "Line" ));
943 a->setToggleAction(true);
944 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
945 formatMenu->addAction (a);
946 actionFormatLinkStyleParabel=a;
947 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
948 a->setStatusTip (tr( "PolyLine" ));
949 a->setToggleAction(true);
950 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
951 formatMenu->addAction (a);
952 actionFormatLinkStylePolyLine=a;
953 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
954 a->setStatusTip (tr( "PolyParabel" ) );
955 a->setToggleAction(true);
956 a->setChecked (true);
957 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
958 formatMenu->addAction (a);
959 actionFormatLinkStylePolyParabel=a;
961 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
962 a->setStatusTip (tr( "Hide link" ));
963 a->setToggleAction(true);
964 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
965 actionFormatHideLinkUnselected=a;
967 formatMenu->addSeparator();
968 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
969 a->setStatusTip (tr( "Use same color for links and headings" ));
970 a->setToggleAction(true);
971 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
972 formatMenu->addAction (a);
973 actionFormatLinkColorHint=a;
975 pix.fill (Qt::white);
976 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
977 a->setStatusTip (tr( "Set Link Color" ));
978 formatMenu->addAction (a);
979 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
980 actionFormatLinkColor=a;
982 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
983 a->setStatusTip (tr( "Set Selection Color" ));
984 formatMenu->addAction (a);
985 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
986 actionFormatSelectionColor=a;
988 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
989 a->setStatusTip (tr( "Set Background Color" ));
990 formatMenu->addAction (a);
991 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
992 actionFormatBackColor=a;
994 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
995 a->setStatusTip (tr( "Set Background image" ));
996 formatMenu->addAction (a);
997 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
998 actionFormatBackImage=a;
1002 void Main::setupViewActions()
1004 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
1005 tb->setLabel( "View Actions" );
1006 tb->setObjectName ("viewTB");
1007 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
1010 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
1011 a->setStatusTip ( tr( "Zoom reset" ) );
1012 a->setShortcut (Qt::CTRL + Qt::Key_0 );
1014 viewMenu->addAction (a);
1015 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
1017 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
1018 a->setStatusTip (tr( "Zoom in" ));
1019 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
1021 viewMenu->addAction (a);
1022 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
1024 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
1025 a->setStatusTip (tr( "Zoom out" ));
1026 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
1028 viewMenu->addAction (a);
1029 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1031 a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
1032 a->setStatusTip (tr( "Show selection" ));
1033 a->setShortcut (Qt::Key_Period);
1035 viewMenu->addAction (a);
1036 connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
1038 viewMenu->addSeparator();
1040 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
1041 a->setStatusTip ( tr( "Show Note Editor" ));
1042 a->setShortcut ( Qt::CTRL + Qt::Key_E );
1043 a->setToggleAction(true);
1045 viewMenu->addAction (a);
1046 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1047 actionViewToggleNoteEditor=a;
1049 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
1050 a->setStatusTip ( tr( "Show History Window" ));
1051 a->setShortcut ( Qt::CTRL + Qt::Key_H );
1052 a->setToggleAction(true);
1054 viewMenu->addAction (a);
1055 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1056 actionViewToggleHistoryWindow=a;
1058 viewMenu->addAction (actionViewTogglePropertyWindow);
1060 viewMenu->addSeparator();
1062 a = new QAction(tr( "Antialiasing","View action" ),this );
1063 a->setStatusTip ( tr( "Antialiasing" ));
1064 a->setToggleAction(true);
1065 a->setChecked (settings.value("/mainwindow/view/AntiAlias",true).toBool());
1066 viewMenu->addAction (a);
1067 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
1068 actionViewToggleAntiAlias=a;
1070 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1071 a->setStatusTip (a->text());
1072 a->setToggleAction(true);
1073 a->setChecked (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1074 viewMenu->addAction (a);
1075 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1076 actionViewToggleSmoothPixmapTransform=a;
1078 a = new QAction(tr( "Next Map","View action" ), this);
1079 a->setStatusTip (a->text());
1080 a->setShortcut (Qt::ALT + Qt::Key_N );
1081 viewMenu->addAction (a);
1082 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1084 a = new QAction (tr( "Previous Map","View action" ), this );
1085 a->setStatusTip (a->text());
1086 a->setShortcut (Qt::ALT + Qt::Key_P );
1087 viewMenu->addAction (a);
1088 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1092 void Main::setupModeActions()
1094 //QPopupMenu *menu = new QPopupMenu( this );
1095 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1097 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1098 tb->setObjectName ("modesTB");
1100 actionGroupModModes=new QActionGroup ( this);
1101 actionGroupModModes->setExclusive (true);
1102 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1103 a->setShortcut (Qt::Key_J);
1104 a->setStatusTip ( tr( "Use modifier to color branches" ));
1105 a->setToggleAction(true);
1107 a->setChecked(true);
1108 actionModModeColor=a;
1110 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1111 a->setShortcut( Qt::Key_K);
1112 a->setStatusTip( tr( "Use modifier to copy" ));
1113 a->setToggleAction(true);
1115 actionModModeCopy=a;
1117 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1118 a->setShortcut (Qt::Key_L);
1119 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1120 a->setToggleAction(true);
1122 actionModModeXLink=a;
1126 void Main::setupFlagActions()
1128 // Create System Flags
1131 Flag *flag=new Flag;;
1132 flag->setVisible(true);
1134 flag->load(QPixmap(flagsPath+"flag-note.png"));
1135 setupFlag (flag,tb,"system-note",tr("Note","SystemFlag"));
1137 flag->load(QPixmap(flagsPath+"flag-url.png"));
1138 setupFlag (flag,tb,"system-url",tr("URL to Document ","SystemFlag"));
1140 flag->load(QPixmap(flagsPath+"flag-vymlink.png"));
1141 setupFlag (flag,tb,"system-vymLink",tr("Link to another vym map","SystemFlag"));
1143 flag->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1144 setupFlag (flag,tb,"system-scrolledright",tr("subtree is scrolled","SystemFlag"));
1146 flag->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1147 setupFlag (flag,tb,"system-tmpUnscrolledRight",tr("subtree is temporary scrolled","SystemFlag"));
1149 flag->load(QPixmap(flagsPath+"flag-hideexport.png"));
1150 setupFlag (flag,tb,"system-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");
1155 standardFlagsMaster->setToolBar (tb);
1157 flag->load(flagsPath+"flag-exclamationmark.png");
1158 flag->setGroup("standard-mark");
1159 setupFlag (flag,tb,"exclamationmark",tr("Take care!","Standardflag"));
1161 flag->load(flagsPath+"flag-questionmark.png");
1162 flag->setGroup("standard-mark");
1163 setupFlag (flag,tb,"questionmark",tr("Really?","Standardflag"));
1165 flag->load(flagsPath+"flag-hook-green.png");
1166 flag->setGroup("standard-hook");
1167 setupFlag (flag,tb,"hook-green",tr("ok!","Standardflag"));
1169 flag->load(flagsPath+"flag-cross-red.png");
1170 flag->setGroup("standard-hook");
1171 setupFlag (flag,tb,"cross-red",tr("Not ok!","Standardflag"));
1174 flag->load(flagsPath+"flag-stopsign.png");
1175 setupFlag (flag,tb,"stopsign",tr("This won't work!","Standardflag"));
1177 flag->load(flagsPath+"flag-smiley-good.png");
1178 flag->setGroup("standard-smiley");
1179 setupFlag (flag,tb,"smiley-good",tr("Good","Standardflag"));
1181 flag->load(flagsPath+"flag-smiley-sad.png");
1182 flag->setGroup("standard-smiley");
1183 setupFlag (flag,tb,"smiley-sad",tr("Bad","Standardflag"));
1185 flag->load(flagsPath+"flag-smiley-omg.png");
1186 flag->setGroup("standard-smiley");
1187 setupFlag (flag,tb,"smiley-omb",tr("Oh no!","Standardflag"));
1188 // Original omg.png (in KDE emoticons)
1191 flag->load(flagsPath+"flag-kalarm.png");
1192 setupFlag (flag,tb,"clock",tr("Time critical","Standardflag"));
1194 flag->load(flagsPath+"flag-phone.png");
1195 setupFlag (flag,tb,"phone",tr("Call...","Standardflag"));
1197 flag->load(flagsPath+"flag-lamp.png");
1198 setupFlag (flag,tb,"lamp",tr("Idea!","Standardflag"));
1200 flag->load(flagsPath+"flag-arrow-up.png");
1201 flag->setGroup("standard-arrow");
1202 setupFlag (flag,tb,"arrow-up",tr("Important","Standardflag"));
1204 flag->load(flagsPath+"flag-arrow-down.png");
1205 flag->setGroup("standard-arrow");
1206 setupFlag (flag,tb,"arrow-down",tr("Unimportant","Standardflag"));
1208 flag->load(flagsPath+"flag-arrow-2up.png");
1209 flag->setGroup("standard-arrow");
1210 setupFlag (flag,tb,"2arrow-up",tr("Very important!","Standardflag"));
1212 flag->load(flagsPath+"flag-arrow-2down.png");
1213 flag->setGroup("standard-arrow");
1214 setupFlag (flag,tb,"2arrow-down",tr("Very unimportant!","Standardflag"));
1217 flag->load(flagsPath+"flag-thumb-up.png");
1218 flag->setGroup("standard-thumb");
1219 setupFlag (flag,tb,"thumb-up",tr("I like this","Standardflag"));
1221 flag->load(flagsPath+"flag-thumb-down.png");
1222 flag->setGroup("standard-thumb");
1223 setupFlag (flag,tb,"thumb-down",tr("I do not like this","Standardflag"));
1226 flag->load(flagsPath+"flag-rose.png");
1227 setupFlag (flag,tb,"rose",tr("Rose","Standardflag"));
1229 flag->load(flagsPath+"flag-heart.png");
1230 setupFlag (flag,tb,"heart",tr("I just love...","Standardflag"));
1232 flag->load(flagsPath+"flag-present.png");
1233 setupFlag (flag,tb,"present",tr("Surprise!","Standardflag"));
1235 flag->load(flagsPath+"flag-flash.png");
1236 setupFlag (flag,tb,"flash",tr("Dangerous","Standardflag"));
1238 // Original: xsldbg_output.png
1239 flag->load(flagsPath+"flag-info.png");
1240 setupFlag (flag,tb,"info",tr("Info","Standardflag"));
1242 // Original khelpcenter.png
1243 flag->load(flagsPath+"flag-lifebelt.png");
1244 setupFlag (flag,tb,"lifebelt",tr("This will help","Standardflag"));
1247 flag->setVisible(false);
1248 flag->load(flagsPath+"freemind/warning.png");
1249 setupFlag (flag,tb, "freemind-warning",tr("Important","Freemind-Flag"));
1251 for (int i=1; i<8; i++)
1253 flag->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
1254 setupFlag (flag,tb, QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
1257 flag->load(flagsPath+"freemind/back.png");
1258 setupFlag (flag,tb,"freemind-back",tr("Back","Freemind-Flag"));
1260 flag->load(flagsPath+"freemind/forward.png");
1261 setupFlag (flag,tb,"freemind-forward",tr("forward","Freemind-Flag"));
1263 flag->load(flagsPath+"freemind/attach.png");
1264 setupFlag (flag,tb,"freemind-attach",tr("Look here","Freemind-Flag"));
1266 flag->load(flagsPath+"freemind/clanbomber.png");
1267 setupFlag (flag,tb,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
1269 flag->load(flagsPath+"freemind/desktopnew.png");
1270 setupFlag (flag,tb,"freemind-desktopnew",tr("Don't flagrget","Freemind-Flag"));
1272 flag->load(flagsPath+"freemind/flag.png");
1273 setupFlag (flag,tb,"freemind-flag",tr("Flag","Freemind-Flag"));
1276 flag->load(flagsPath+"freemind/gohome.png");
1277 setupFlag (flag,tb,"freemind-gohome",tr("Home","Freemind-Flag"));
1280 flag->load(flagsPath+"freemind/kaddressbook.png");
1281 setupFlag (flag,tb,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
1283 flag->load(flagsPath+"freemind/knotify.png");
1284 setupFlag (flag,tb,"freemind-knotify",tr("Music","Freemind-Flag"));
1286 flag->load(flagsPath+"freemind/korn.png");
1287 setupFlag (flag,tb,"freemind-korn",tr("Mailbox","Freemind-Flag"));
1289 flag->load(flagsPath+"freemind/mail.png");
1290 setupFlag (flag,tb,"freemind-mail",tr("Maix","Freemind-Flag"));
1292 flag->load(flagsPath+"freemind/password.png");
1293 setupFlag (flag,tb,"freemind-password",tr("Password","Freemind-Flag"));
1295 flag->load(flagsPath+"freemind/pencil.png");
1296 setupFlag (flag,tb,"freemind-pencil",tr("To be improved","Freemind-Flag"));
1298 flag->load(flagsPath+"freemind/stop.png");
1299 setupFlag (flag,tb,"freemind-stop",tr("Stop","Freemind-Flag"));
1301 flag->load(flagsPath+"freemind/wizard.png");
1302 setupFlag (flag,tb,"freemind-wizard",tr("Magic","Freemind-Flag"));
1304 flag->load(flagsPath+"freemind/xmag.png");
1305 setupFlag (flag,tb,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
1307 flag->load(flagsPath+"freemind/bell.png");
1308 setupFlag (flag,tb,"freemind-bell",tr("Reminder","Freemind-Flag"));
1310 flag->load(flagsPath+"freemind/bookmark.png");
1311 setupFlag (flag,tb,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
1313 flag->load(flagsPath+"freemind/penguin.png");
1314 setupFlag (flag,tb,"freemind-penguin",tr("Linux","Freemind-Flag"));
1316 flag->load(flagsPath+"freemind/licq.png");
1317 setupFlag (flag,tb,"freemind-licq",tr("Sweet","Freemind-Flag"));
1320 void Main::setupFlag (Flag *flag, QToolBar *tb, const QString &name, const QString &tooltip)
1322 flag->setName(name);
1323 flag->setToolTip (tooltip);
1327 a=new QAction (flag->getPixmap(),name,this);
1330 flag->setAction (a);
1331 a->setVisible (flag->isVisible());
1332 a->setCheckable(true);
1333 a->setObjectName(name);
1334 a->setToolTip(tooltip);
1335 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1336 standardFlagsMaster->addFlag (flag);
1340 systemFlagsMaster->addFlag (flag);
1345 void Main::setupNetworkActions()
1347 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1349 QMenu *netMenu = menuBar()->addMenu( "Network" );
1353 a = new QAction( "Start TCPserver for MapEditor",this);
1354 //a->setStatusTip ( "Set application to open pdf files"));
1355 a->setShortcut ( Qt::Key_T ); //New TCP server
1356 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1357 netMenu->addAction (a);
1359 a = new QAction( "Connect MapEditor to server",this);
1360 //a->setStatusTip ( "Set application to open pdf files"));
1361 a->setShortcut ( Qt::Key_C ); // Connect to server
1362 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1363 netMenu->addAction (a);
1367 void Main::setupSettingsActions()
1369 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1373 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1374 a->setStatusTip ( tr( "Set application to open pdf files"));
1375 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1376 settingsMenu->addAction (a);
1378 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1379 a->setStatusTip( tr( "Set application to open external links"));
1380 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1381 settingsMenu->addAction (a);
1383 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1384 a->setStatusTip( tr( "Set path for macros"));
1385 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1386 settingsMenu->addAction (a);
1388 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1389 a->setStatusTip( tr( "Set number of undo levels"));
1390 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1391 settingsMenu->addAction (a);
1393 settingsMenu->addSeparator();
1395 a = new QAction( tr( "Autosave","Settings action"), this);
1396 a->setStatusTip( tr( "Autosave"));
1397 a->setToggleAction(true);
1398 a->setChecked ( settings.value ("/mainwindow/autosave/use",false).toBool());
1399 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1400 settingsMenu->addAction (a);
1401 actionSettingsAutosaveToggle=a;
1403 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1404 a->setStatusTip( tr( "Autosave time"));
1405 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1406 settingsMenu->addAction (a);
1407 actionSettingsAutosaveTime=a;
1409 a = new QAction( tr( "Write backup file on save","Settings action"), this);
1410 a->setStatusTip( tr( "Write backup file on save"));
1411 a->setToggleAction(true);
1412 a->setChecked ( settings.value ("/mainwindow/writeBackupFile",false).toBool());
1413 connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) );
1414 settingsMenu->addAction (a);
1415 actionSettingsWriteBackupFile=a;
1417 settingsMenu->addSeparator();
1419 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1420 a->setStatusTip( tr( "Edit branch after adding it" ));
1421 a->setToggleAction(true);
1422 a->setChecked ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1423 settingsMenu->addAction (a);
1424 actionSettingsAutoEditNewBranch=a;
1426 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1427 a->setStatusTip( tr( "Select branch after adding it" ));
1428 a->setToggleAction(true);
1429 a->setChecked ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1430 settingsMenu->addAction (a);
1431 actionSettingsAutoSelectNewBranch=a;
1433 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1434 a->setStatusTip( tr( "Select heading before editing" ));
1435 a->setToggleAction(true);
1436 a->setChecked ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1437 settingsMenu->addAction (a);
1438 actionSettingsAutoSelectText=a;
1440 a= new QAction( tr( "Delete key","Settings action" ), this);
1441 a->setStatusTip( tr( "Delete key for deleting branches" ));
1442 a->setToggleAction(true);
1443 a->setChecked ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1444 settingsMenu->addAction (a);
1445 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1446 actionSettingsUseDelKey=a;
1448 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1449 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1450 a->setToggleAction(true);
1451 a->setChecked ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1452 settingsMenu->addAction (a);
1453 actionSettingsUseFlagGroups=a;
1455 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1456 a->setStatusTip( tr( "Use hide flag during exports " ));
1457 a->setToggleAction(true);
1458 a->setChecked ( settings.value ("/export/useHideExport",true).toBool() );
1459 settingsMenu->addAction (a);
1460 actionSettingsUseHideExport=a;
1462 a = new QAction( tr( "Animation","Settings action"), this);
1463 a->setStatusTip( tr( "Animation"));
1464 a->setToggleAction(true);
1465 a->setChecked (settings.value("/animation/use",true).toBool() );
1466 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) );
1467 settingsMenu->addAction (a);
1468 actionSettingsUseAnimation=a;
1472 void Main::setupTestActions()
1474 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1477 a = new QAction( "Test function 1" , this);
1478 a->setStatusTip( "Call test function 1" );
1479 testMenu->addAction (a);
1480 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1482 a = new QAction( "Test function 2" , this);
1483 a->setStatusTip( "Call test function 2" );
1484 a->setShortcut (Qt::SHIFT + Qt::Key_T);
1485 testMenu->addAction (a);
1486 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1488 a = new QAction( "Command" , this);
1489 a->setStatusTip( "Enter command to call in editor" );
1490 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1491 testMenu->addAction (a);
1495 void Main::setupHelpActions()
1497 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1500 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1501 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1502 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1503 helpMenu->addAction (a);
1505 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1506 a->setStatusTip( tr( "Open VYM example maps " ));
1507 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1508 helpMenu->addAction (a);
1510 a = new QAction( tr( "About VYM","Help action" ), this);
1511 a->setStatusTip( tr( "About VYM")+vymName);
1512 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1513 helpMenu->addAction (a);
1515 a = new QAction( tr( "About QT","Help action" ), this);
1516 a->setStatusTip( tr( "Information about QT toolkit" ));
1517 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1518 helpMenu->addAction (a);
1522 void Main::setupContextMenus()
1526 // Context Menu for branch or mapcenter
1527 branchContextMenu =new QMenu (this);
1528 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1529 branchContextMenu->addSeparator();
1532 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1533 branchAddContextMenu->addAction (actionPaste );
1534 branchAddContextMenu->addAction ( actionAddMapCenter );
1535 branchAddContextMenu->addAction ( actionAddBranch );
1536 branchAddContextMenu->addAction ( actionAddBranchBefore );
1537 branchAddContextMenu->addAction ( actionAddBranchAbove);
1538 branchAddContextMenu->addAction ( actionAddBranchBelow );
1539 branchAddContextMenu->addSeparator();
1540 branchAddContextMenu->addAction ( actionImportAdd );
1541 branchAddContextMenu->addAction ( actionImportReplace );
1544 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1545 branchRemoveContextMenu->addAction (actionCut);
1546 branchRemoveContextMenu->addAction ( actionDelete );
1547 branchRemoveContextMenu->addAction ( actionDeleteKeepChildren );
1548 branchRemoveContextMenu->addAction ( actionDeleteChildren );
1551 actionSaveBranch->addTo( branchContextMenu );
1552 actionFileNewCopy->addTo (branchContextMenu );
1553 actionDetach->addTo (branchContextMenu );
1555 branchContextMenu->addSeparator();
1556 branchContextMenu->addAction ( actionLoadImage);
1558 // Submenu for Links (URLs, vymLinks)
1559 branchLinksContextMenu =new QMenu (this);
1561 branchContextMenu->addSeparator();
1562 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1563 branchLinksContextMenu->addAction ( actionOpenURL );
1564 branchLinksContextMenu->addAction ( actionOpenURLTab );
1565 branchLinksContextMenu->addAction ( actionOpenMultipleURLTabs );
1566 branchLinksContextMenu->addAction ( actionURL );
1567 branchLinksContextMenu->addAction ( actionLocalURL );
1568 branchLinksContextMenu->addAction ( actionHeading2URL );
1569 branchLinksContextMenu->addAction ( actionBugzilla2URL );
1570 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1572 branchLinksContextMenu->addAction ( actionFATE2URL );
1574 branchLinksContextMenu->addSeparator();
1575 branchLinksContextMenu->addAction ( actionOpenVymLink );
1576 branchLinksContextMenu->addAction ( actionOpenMultipleVymLinks );
1577 branchLinksContextMenu->addAction ( actionVymLink );
1578 branchLinksContextMenu->addAction ( actionDeleteVymLink );
1581 // Context Menu for XLinks in a branch menu
1582 // This will be populated "on demand" in MapEditor::updateActions
1583 branchContextMenu->addSeparator();
1584 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1585 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1586 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1587 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1590 // Context menu for floatimage
1591 floatimageContextMenu =new QMenu (this);
1592 a= new QAction (tr ("Save image","Context action"),this);
1593 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1594 floatimageContextMenu->addAction (a);
1596 floatimageContextMenu->addSeparator();
1597 actionCopy->addTo( floatimageContextMenu );
1598 actionCut->addTo( floatimageContextMenu );
1600 floatimageContextMenu->addSeparator();
1601 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1604 // Context menu for canvas
1605 canvasContextMenu =new QMenu (this);
1606 actionAddMapCenter->addTo( canvasContextMenu );
1607 actionMapInfo->addTo( canvasContextMenu );
1608 canvasContextMenu->insertSeparator();
1609 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1610 canvasContextMenu->insertSeparator();
1611 actionFormatLinkColorHint->addTo( canvasContextMenu );
1612 actionFormatLinkColor->addTo( canvasContextMenu );
1613 actionFormatSelectionColor->addTo( canvasContextMenu );
1614 actionFormatBackColor->addTo( canvasContextMenu );
1615 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME-4 makes vym too slow: postponed for later version
1617 // Menu for last opened files
1619 for (int i = 0; i < MaxRecentFiles; ++i)
1621 recentFileActions[i] = new QAction(this);
1622 recentFileActions[i]->setVisible(false);
1623 fileLastMapsMenu->addAction(recentFileActions[i]);
1624 connect(recentFileActions[i], SIGNAL(triggered()),
1625 this, SLOT(fileLoadRecent()));
1627 setupRecentMapsMenu();
1630 void Main::setupRecentMapsMenu()
1632 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1634 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1636 for (int i = 0; i < numRecentFiles; ++i) {
1637 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1638 recentFileActions[i]->setText(text);
1639 recentFileActions[i]->setData(files[i]);
1640 recentFileActions[i]->setVisible(true);
1642 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1643 recentFileActions[j]->setVisible(false);
1646 void Main::setupMacros()
1648 for (int i = 0; i <= 11; i++)
1650 macroActions[i] = new QAction(this);
1651 macroActions[i]->setData(i);
1652 addAction (macroActions[i]);
1653 connect(macroActions[i], SIGNAL(triggered()),
1654 this, SLOT(callMacro()));
1656 macroActions[0]->setShortcut ( Qt::Key_F1 );
1657 macroActions[1]->setShortcut ( Qt::Key_F2 );
1658 macroActions[2]->setShortcut ( Qt::Key_F3 );
1659 macroActions[3]->setShortcut ( Qt::Key_F4 );
1660 macroActions[4]->setShortcut ( Qt::Key_F5 );
1661 macroActions[5]->setShortcut ( Qt::Key_F6 );
1662 macroActions[6]->setShortcut ( Qt::Key_F7 );
1663 macroActions[7]->setShortcut ( Qt::Key_F8 );
1664 macroActions[8]->setShortcut ( Qt::Key_F9 );
1665 macroActions[9]->setShortcut ( Qt::Key_F10 );
1666 macroActions[10]->setShortcut ( Qt::Key_F11 );
1667 macroActions[11]->setShortcut ( Qt::Key_F12 );
1670 void Main::hideEvent (QHideEvent * )
1672 if (!textEditor->isMinimized() ) textEditor->hide();
1675 void Main::showEvent (QShowEvent * )
1677 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1681 MapEditor* Main::currentMapEditor() const
1683 if ( tabWidget->currentPage())
1684 return vymViews.at(tabWidget->currentIndex())->getMapEditor();
1688 VymModel* Main::currentModel() const
1690 if ( tabWidget->currentPage())
1691 return vymViews.at(tabWidget->currentIndex())->getModel();
1696 void Main::editorChanged(QWidget *)
1698 // Unselect all possibly selected objects
1699 // (Important to update note editor)
1701 for (int i=0;i<=tabWidget->count() -1;i++)
1703 m= vymViews.at(tabWidget->currentIndex())->getModel();
1704 if (m) m->unselect();
1707 if (m) m->reselect();
1709 // Update actions to in menus and toolbars according to editor
1713 void Main::fileNew()
1715 VymModel *vm=new VymModel;
1717 //new ModelTest(vm, this); //FIXME-3
1720 VymView *vv=new VymView (vm);
1721 vymViews.append (vv);
1722 tabWidget->addTab (vv,tr("unnamed","MainWindow: name for new and empty file"));
1723 tabWidget->setCurrentIndex (vymViews.count() );
1726 // Create MapCenter for empty map
1727 //vm->createMapCenter();
1729 // For the very first map we do not have flagrows yet...
1733 void Main::fileNewCopy()
1735 QString fn="unnamed";
1736 VymModel *srcModel=currentModel();
1741 VymModel *dstModel=vymViews.last()->getModel();
1742 dstModel->select("mc:");
1743 dstModel->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
1747 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
1749 ErrorCode err=success;
1751 // fn is usually the archive, mapfile the file after uncompressing
1754 // Make fn absolute (needed for unzip)
1755 fn=QDir (fn).absPath();
1761 // Check, if map is already loaded
1763 while (i<=tabWidget->count() -1)
1765 if (vymViews.at(i)->getModel()->getFilePath() == fn)
1767 // Already there, ask for confirmation
1768 QMessageBox mb( vymName,
1769 tr("The map %1\nis already opened."
1770 "Opening the same map in multiple editors may lead \n"
1771 "to confusion when finishing working with vym."
1772 "Do you want to").arg(fn),
1773 QMessageBox::Warning,
1774 QMessageBox::Yes | QMessageBox::Default,
1775 QMessageBox::Cancel | QMessageBox::Escape,
1776 QMessageBox::NoButton);
1777 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1778 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1781 case QMessageBox::Yes:
1782 // end loop and load anyway
1783 i=tabWidget->count();
1785 case QMessageBox::Cancel:
1795 int tabIndex=tabWidget->currentPageIndex();
1798 if ( !fn.isEmpty() )
1800 vm = currentModel();
1801 // Check first, if mapeditor exists
1802 // If it is not default AND we want a new map,
1803 // create a new mapeditor in a new tab
1804 if ( lmode==NewMap && (!vm || !vm->isDefault() ) )
1807 VymView *vv=new VymView (vm);
1808 vymViews.append (vv);
1809 tabWidget->addTab (vv,fn);
1810 tabIndex=tabWidget->count()-1;
1811 tabWidget->setCurrentPage (tabIndex);
1815 // Check, if file exists (important for creating new files
1816 // from command line
1817 if (!QFile(fn).exists() )
1819 QMessageBox mb( vymName,
1820 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1821 QMessageBox::Question,
1823 QMessageBox::Cancel | QMessageBox::Default,
1824 QMessageBox::NoButton );
1826 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1827 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1830 case QMessageBox::Yes:
1832 currentMapEditor()->getModel()->setFilePath(fn);
1833 tabWidget->setTabText (tabIndex,
1834 currentMapEditor()->getModel()->getFileName() );
1835 statusBar()->message( "Created " + fn , statusbarTime );
1838 case QMessageBox::Cancel:
1839 // don't create new map
1840 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1847 //tabWidget->currentPage() won't be NULL here, because of above...
1848 tabWidget->setCurrentIndex (tabIndex);
1849 //FIXME-3 no me anymore... me->viewport()->setFocus();
1853 // Save existing filename in case we import
1854 QString fn_org=vm->getFilePath();
1856 // Finally load map into mapEditor
1857 vm->setFilePath (fn);
1858 err=vm->load(fn,lmode,ftype);
1860 // Restore old (maybe empty) filepath, if this is an import
1862 vm->setFilePath (fn_org);
1865 // Finally check for errors and go home
1868 if (lmode==NewMap) fileCloseMap();
1869 statusBar()->message( "Could not load " + fn, statusbarTime );
1874 vm->setFilePath (fn);
1875 tabWidget->setTabText (tabIndex, vm->getFileName());
1876 if (!isInTmpDir (fn))
1878 // Only append to lastMaps if not loaded from a tmpDir
1879 // e.g. imported bookmarks are in a tmpDir
1880 addRecentMap(vm->getFilePath() );
1882 actionFilePrint->setEnabled (true);
1884 statusBar()->message( "Loaded " + fn, statusbarTime );
1891 void Main::fileLoad(const LoadMode &lmode)
1893 QStringList filters;
1894 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1895 QFileDialog *fd=new QFileDialog( this);
1896 fd->setDir (lastFileDir);
1897 fd->setFileMode (QFileDialog::ExistingFiles);
1898 fd->setFilters (filters);
1902 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1905 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1908 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1914 if ( fd->exec() == QDialog::Accepted )
1916 lastFileDir=fd->directory().path();
1917 QStringList flist = fd->selectedFiles();
1918 QStringList::Iterator it = flist.begin();
1919 while( it != flist.end() )
1922 fileLoad(*it, lmode);
1929 void Main::fileLoad()
1934 void Main::fileLoadRecent()
1936 QAction *action = qobject_cast<QAction *>(sender());
1938 fileLoad (action->data().toString(), NewMap);
1941 void Main::addRecentMap (const QString &fileName)
1944 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1945 files.removeAll(fileName);
1946 files.prepend(fileName);
1947 while (files.size() > MaxRecentFiles)
1950 settings.setValue("/mainwindow/recentFileList", files);
1952 setupRecentMapsMenu();
1955 void Main::fileSave(VymModel *m, const SaveMode &savemode)
1959 if ( m->getFilePath().isEmpty() )
1961 // We have no filepath yet,
1962 // call fileSaveAs() now, this will call fileSave()
1964 // First switch to editor
1965 //FIXME-3 needed??? tabWidget->setCurrentWidget (m->getMapEditor());
1966 fileSaveAs(savemode);
1969 if (m->save (savemode)==success)
1971 statusBar()->message(
1972 tr("Saved %1").arg(m->getFilePath()),
1974 addRecentMap (m->getFilePath() );
1976 statusBar()->message(
1977 tr("Couldn't save ").arg(m->getFilePath()),
1981 void Main::fileSave()
1983 fileSave (currentModel(), CompleteMap);
1986 void Main::fileSave(VymModel *m)
1988 fileSave (m,CompleteMap);
1991 void Main::fileSaveAs(const SaveMode& savemode)
1995 if (currentMapEditor())
1997 if (savemode==CompleteMap)
1998 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2000 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2001 if ( !fn.isEmpty() )
2003 // Check for existing file
2004 if (QFile (fn).exists())
2006 QMessageBox mb( vymName,
2007 tr("The file %1\nexists already. Do you want to").arg(fn),
2008 QMessageBox::Warning,
2009 QMessageBox::Yes | QMessageBox::Default,
2010 QMessageBox::Cancel | QMessageBox::Escape,
2011 QMessageBox::NoButton);
2012 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2013 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2016 case QMessageBox::Yes:
2019 case QMessageBox::Cancel:
2026 // New file, add extension to filename, if missing
2027 // This is always .vym or .vyp, depending on savemode
2028 if (savemode==CompleteMap)
2030 if (!fn.contains (".vym") && !fn.contains (".xml"))
2034 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2043 VymModel *m=currentModel();
2045 fileSave(m, savemode);
2047 // Set name of tab, assuming current tab is the one we just saved
2048 if (savemode==CompleteMap)
2049 tabWidget->setTabText (tabWidget->currentIndex(), m->getFileName() );
2055 void Main::fileSaveAs()
2057 fileSaveAs (CompleteMap);
2060 void Main::fileImportKDE3Bookmarks()
2062 ImportKDE3Bookmarks im;
2064 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2065 currentMapEditor()->getModel()->setFilePath ("");
2068 void Main::fileImportKDE4Bookmarks()
2070 ImportKDE4Bookmarks im;
2072 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2073 currentMapEditor()->getModel()->setFilePath ("");
2076 void Main::fileImportFirefoxBookmarks()
2078 Q3FileDialog *fd=new Q3FileDialog( this);
2079 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2080 fd->setMode (Q3FileDialog::ExistingFiles);
2081 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2082 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2085 if ( fd->exec() == QDialog::Accepted )
2087 ImportFirefoxBookmarks im;
2088 QStringList flist = fd->selectedFiles();
2089 QStringList::Iterator it = flist.begin();
2090 while( it != flist.end() )
2093 if (im.transform() &&
2094 aborted!=fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2095 currentMapEditor() )
2096 currentMapEditor()->getModel()->setFilePath ("");
2103 void Main::fileImportFreemind()
2105 QStringList filters;
2106 filters <<"Freemind map (*.mm)"<<"All files (*)";
2107 QFileDialog *fd=new QFileDialog( this);
2108 fd->setDir (lastFileDir);
2109 fd->setFileMode (QFileDialog::ExistingFiles);
2110 fd->setFilters (filters);
2111 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2115 if ( fd->exec() == QDialog::Accepted )
2117 lastFileDir=fd->directory().path();
2118 QStringList flist = fd->selectedFiles();
2119 QStringList::Iterator it = flist.begin();
2120 while( it != flist.end() )
2123 if ( fileLoad (fn,NewMap, FreemindMap) )
2125 currentMapEditor()->getModel()->setFilePath ("");
2134 void Main::fileImportMM()
2138 Q3FileDialog *fd=new Q3FileDialog( this);
2139 fd->setDir (lastFileDir);
2140 fd->setMode (Q3FileDialog::ExistingFiles);
2141 fd->addFilter ("Mind Manager (*.mmap)");
2142 fd->setCaption(tr("Import")+" "+"Mind Manager");
2145 if ( fd->exec() == QDialog::Accepted )
2147 lastFileDir=fd->dirPath();
2148 QStringList flist = fd->selectedFiles();
2149 QStringList::Iterator it = flist.begin();
2150 while( it != flist.end() )
2153 if (im.transform() &&
2154 success==fileLoad (im.getTransformedFile(),NewMap) &&
2155 currentMapEditor() )
2156 currentMapEditor()->getModel()->setFilePath ("");
2163 void Main::fileImportDir()
2165 VymModel *m=currentModel();
2166 if (m) m->importDir();
2169 void Main::fileExportXML()
2171 VymModel *m=currentModel();
2172 if (m) m->exportXML();
2176 void Main::fileExportXHTML()
2178 VymModel *m=currentModel();
2179 if (m) m->exportXHTML();
2182 void Main::fileExportImage()
2184 VymModel *m=currentModel();
2185 if (m) m->exportImage();
2188 void Main::fileExportASCII()
2190 VymModel *m=currentModel();
2191 if (m) m->exportASCII();
2194 void Main::fileExportCSV() //FIXME-3 not scriptable yet
2196 VymModel *m=currentModel();
2201 ex.addFilter ("CSV (*.csv)");
2202 ex.setDir(lastImageDir);
2203 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2204 if (ex.execDialog() )
2206 m->setExportMode(true);
2208 m->setExportMode(false);
2213 void Main::fileExportLaTeX() //FIXME-3 not scriptable yet
2215 VymModel *m=currentModel();
2220 ex.addFilter ("Tex (*.tex)");
2221 ex.setDir(lastImageDir);
2222 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2223 if (ex.execDialog() )
2225 m->setExportMode(true);
2227 m->setExportMode(false);
2232 void Main::fileExportKDE3Bookmarks() //FIXME-3 not scriptable yet
2234 ExportKDE3Bookmarks ex;
2235 VymModel *m=currentModel();
2243 void Main::fileExportKDE4Bookmarks() //FIXME-3 not scriptable yet
2245 ExportKDE4Bookmarks ex;
2246 VymModel *m=currentModel();
2254 void Main::fileExportTaskjuggler() //FIXME-3 not scriptable yet
2256 ExportTaskjuggler ex;
2257 VymModel *m=currentModel();
2261 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2262 ex.setDir(lastImageDir);
2263 ex.addFilter ("Taskjuggler (*.tjp)");
2264 if (ex.execDialog() )
2266 m->setExportMode(true);
2268 m->setExportMode(false);
2273 void Main::fileExportOOPresentation() //FIXME-3 not scriptable yet
2275 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2276 // TODO add preview in dialog
2277 //ImagePreview *p =new ImagePreview (fd);
2278 //fd->setContentsPreviewEnabled( TRUE );
2279 //fd->setContentsPreview( p, p );
2280 //fd->setPreviewMode( QFileDialog::Contents );
2281 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2282 fd->setDir (QDir().current());
2283 if (fd->foundConfig())
2287 if ( fd->exec() == QDialog::Accepted )
2289 QString fn=fd->selectedFile();
2290 if (!fn.contains (".odp"))
2293 //lastImageDir=fn.left(fn.findRev ("/"));
2294 VymModel *m=currentModel();
2295 if (m) m->exportOOPresentation(fn,fd->selectedConfig());
2299 QMessageBox::warning(0,
2301 tr("Couldn't find configuration for export to Open Office\n"));
2305 void Main::fileCloseMap()
2307 VymModel *m=currentModel();
2310 if (m->hasChanged())
2312 QMessageBox mb( vymName,
2313 tr("The map %1 has been modified but not saved yet. Do you want to").arg(m->getFileName()),
2314 QMessageBox::Warning,
2315 QMessageBox::Yes | QMessageBox::Default,
2317 QMessageBox::Cancel | QMessageBox::Escape );
2318 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2319 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2322 case QMessageBox::Yes:
2324 fileSave(m, CompleteMap);
2326 case QMessageBox::No:
2327 // close without saving
2329 case QMessageBox::Cancel:
2334 // And here comes the segfault, because removeTab triggers
2335 // currentChanged->Main::editorChanged -> updateActions and VM is not NULL yet...
2336 vymViews.removeAt (tabWidget->currentIndex() );
2337 tabWidget->removeTab (tabWidget->currentIndex() );
2339 // Remove mapEditor/model FIXME-5
2340 // Better would be delete (me), but then we could have a Qt error:
2341 // "QObject: Do not delete object, 'MapEditor', during its event handler!"
2342 // So we only remove data now and call deconstructor when vym closes later
2343 // this needs to be moved to vymview... me->clear();
2344 // some model->clear is needed to free up memory ...
2350 void Main::filePrint()
2352 if (currentMapEditor())
2353 currentMapEditor()->print();
2356 void Main::fileExitVYM()
2358 // Check if one or more editors have changed
2360 for (i=0;i<=vymViews.count() -1;i++)
2362 // If something changed, ask what to do
2363 if (vymViews.at(i)->getModel()->hasChanged())
2365 tabWidget->setCurrentPage(i);
2366 QMessageBox mb( vymName,
2367 tr("This map is not saved yet. Do you want to"),
2368 QMessageBox::Warning,
2369 QMessageBox::Yes | QMessageBox::Default,
2371 QMessageBox::Cancel | QMessageBox::Escape );
2372 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2373 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2376 mb.setActiveWindow();
2377 switch( mb.exec() ) {
2378 case QMessageBox::Yes:
2379 // save (the changed editors) and exit
2380 fileSave(currentModel(), CompleteMap);
2382 case QMessageBox::No:
2383 // exit without saving
2385 case QMessageBox::Cancel:
2386 // don't save and don't exit
2390 } // loop over all MEs
2394 void Main::editUndo()
2396 VymModel *m=currentModel();
2400 void Main::editRedo()
2402 VymModel *m=currentModel();
2406 void Main::gotoHistoryStep (int i)
2408 VymModel *m=currentModel();
2409 if (m) m->gotoHistoryStep(i);
2412 void Main::editCopy()
2414 VymModel *m=currentModel();
2418 void Main::editPaste()
2420 VymModel *m=currentModel();
2424 void Main::editCut()
2426 VymModel *m=currentModel();
2430 void Main::editOpenFindWindow()
2432 findWindow->popup();
2433 findWindow->raise();
2434 findWindow->setActiveWindow();
2437 void Main::editFind(QString s)
2439 VymModel *m=currentModel();
2443 BranchItem *bi=m->findText(s, cs);
2446 statusBar()->message( "Found: " + bi->getHeading(), statusbarTime );
2449 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2450 tr("No matches found for \"%1\"").arg(s));
2455 void Main::editFindChanged()
2456 { // Notify editor, to abort the current find process
2457 VymModel *m=currentModel();
2458 if (m) m->findReset();
2461 void Main::openTabs(QStringList urls)
2463 if (!urls.isEmpty())
2467 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2469 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2471 QString u=urls.takeFirst();
2472 procBrowser = new QProcess( this );
2474 procBrowser->start(browser,args);
2475 if ( !procBrowser->waitForStarted())
2477 // try to set path to browser
2478 QMessageBox::warning(0,
2480 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2481 tr("Please use Settings->")+tr("Set application to open an URL"));
2484 #if defined(Q_OS_WIN32)
2485 // There's no sleep in VCEE, replace it with Qt's QThread::wait().
2486 this->thread()->wait(3000);
2491 if (browser.contains("konqueror"))
2493 for (int i=0; i<urls.size(); i++)
2496 // Try to open new tab in existing konqueror started previously by vym
2497 p=new QProcess (this);
2499 #if defined(Q_OS_WIN32)
2500 // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
2501 // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
2502 args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
2503 "konqueror-mainwindow#1"<<
2507 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2508 "konqueror-mainwindow#1"<<
2512 p->start ("dcop",args);
2513 if (debug) cout << "MainWindo::openURLs args="<<args.join(" ").toStdString()<<endl;
2514 if ( !p->waitForStarted() ) success=false;
2517 QMessageBox::warning(0,
2519 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2521 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2523 for (int i=0; i<urls.size(); i++)
2525 // Try to open new tab in firefox
2526 p=new QProcess (this);
2527 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2528 p->start (browser,args);
2529 if ( !p->waitForStarted() ) success=false;
2532 QMessageBox::warning(0,
2534 tr("Couldn't start %1 to open a new tab").arg(browser));
2537 QMessageBox::warning(0,
2539 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2543 void Main::editOpenURL()
2546 VymModel *m=currentModel();
2549 QString url=m->getURL();
2551 if (url=="") return;
2552 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2553 procBrowser = new QProcess( this );
2555 procBrowser->start(browser,args);
2556 if ( !procBrowser->waitForStarted())
2558 // try to set path to browser
2559 QMessageBox::warning(0,
2561 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2562 tr("Please use Settings->")+tr("Set application to open an URL"));
2567 void Main::editOpenURLTab()
2569 VymModel *m=currentModel();
2573 urls.append(m->getURL());
2577 void Main::editOpenMultipleURLTabs()
2579 VymModel *m=currentModel();
2589 void Main::editURL()
2591 VymModel *m=currentModel();
2592 if (m) m->editURL();
2595 void Main::editLocalURL()
2597 VymModel *m=currentModel();
2598 if (m) m->editLocalURL();
2601 void Main::editHeading2URL()
2603 VymModel *m=currentModel();
2604 if (m) m->editHeading2URL();
2607 void Main::editBugzilla2URL()
2609 VymModel *m=currentModel();
2610 if (m) m->editBugzilla2URL();
2613 void Main::editFATE2URL()
2615 VymModel *m=currentModel();
2616 if (m) m->editFATE2URL();
2619 void Main::editHeadingFinished(VymModel *m)
2623 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2624 !prevSelection.isEmpty())
2625 m->select(prevSelection);
2630 void Main::openVymLinks(const QStringList &vl)
2632 for (int j=0; j<vl.size(); j++)
2634 // compare path with already loaded maps
2637 for (i=0;i<=vymViews.count() -1;i++)
2639 if (vl.at(j)==vymViews.at(i)->getModel()->getFilePath() )
2648 if (!QFile(vl.at(j)).exists() )
2649 QMessageBox::critical( 0, tr( "Critical Error" ),
2650 tr("Couldn't open map %1").arg(vl.at(j)));
2653 fileLoad (vl.at(j), NewMap);
2654 tabWidget->setCurrentIndex (tabWidget->count()-1);
2657 // Go to tab containing the map
2658 tabWidget->setCurrentIndex (index);
2662 void Main::editOpenVymLink()
2664 VymModel *m=currentModel();
2668 vl.append(m->getVymLink());
2673 void Main::editOpenMultipleVymLinks()
2675 QString currentVymLink;
2676 VymModel *m=currentModel();
2679 QStringList vl=m->getVymLinks();
2684 void Main::editVymLink()
2686 VymModel *m=currentModel();
2691 void Main::editDeleteVymLink()
2693 VymModel *m=currentModel();
2694 if (m) m->deleteVymLink();
2697 void Main::editToggleHideExport()
2699 VymModel *m=currentModel();
2700 if (m) m->toggleHideExport();
2703 void Main::editMapInfo()
2705 VymModel *m=currentModel();
2708 ExtraInfoDialog dia;
2709 dia.setMapName (m->getFileName() );
2710 dia.setAuthor (m->getAuthor() );
2711 dia.setComment(m->getComment() );
2715 stats+=tr("%1 items on map\n","Info about map").arg (m->getScene()->items().size(),6);
2721 BranchItem *cur=NULL;
2722 BranchItem *prev=NULL;
2726 if (!cur->getNote().isEmpty() ) n++;
2727 f+= cur->imageCount();
2729 xl+=cur->xlinkCount();
2733 stats+=QString ("%1 xLinks \n").arg (xl,6);
2734 stats+=QString ("%1 notes\n").arg (n,6);
2735 stats+=QString ("%1 images\n").arg (f,6);
2736 stats+=QString ("%1 branches\n").arg (m->branchCount(),6);
2737 dia.setStats (stats);
2739 // Finally show dialog
2740 if (dia.exec() == QDialog::Accepted)
2742 m->setAuthor (dia.getAuthor() );
2743 m->setComment (dia.getComment() );
2747 void Main::editMoveUp()
2749 VymModel *m=currentModel();
2753 void Main::editMoveDown()
2755 VymModel *m=currentModel();
2756 if (m) m->moveDown();
2759 void Main::editDetach()
2761 VymModel *m=currentModel();
2765 void Main::editSortChildren()
2767 VymModel *m=currentModel();
2768 if (m) m->sortChildren();
2771 void Main::editToggleScroll()
2773 VymModel *m=currentModel();
2774 if (m) m->toggleScroll();
2777 void Main::editExpandAll()
2779 VymModel *m=currentModel();
2780 if (m) m->emitExpandAll();
2783 void Main::editUnscrollChildren()
2785 VymModel *m=currentModel();
2786 if (m) m->unscrollChildren();
2789 void Main::editAddAttribute()
2791 VymModel *m=currentModel();
2792 if (m) m->addAttribute();
2795 void Main::editAddMapCenter()
2797 VymModel *m=currentModel();
2798 if (m) m->addMapCenter ();
2801 void Main::editNewBranch()
2803 VymModel *m=currentModel();
2806 BranchItem *bi=m->addNewBranch();
2809 if (actionSettingsAutoEditNewBranch->isOn()
2810 && !actionSettingsAutoSelectNewBranch->isOn() )
2811 prevSelection=m->getSelectString();
2813 prevSelection=QString();
2815 if (actionSettingsAutoSelectNewBranch->isOn()
2816 || actionSettingsAutoEditNewBranch->isOn())
2819 cout << "Main::editNewBranch prevSel="<<prevSelection.toStdString()<<endl;
2820 if (actionSettingsAutoEditNewBranch->isOn())
2821 currentMapEditor()->editHeading();
2826 void Main::editNewBranchBefore()
2828 VymModel *m=currentModel();
2831 BranchItem *bi=m->addNewBranchBefore();
2838 if (actionSettingsAutoEditNewBranch->isOn())
2840 if (!actionSettingsAutoSelectNewBranch->isOn())
2841 prevSelection=m->getSelectString(bi);
2842 currentMapEditor()->editHeading();
2847 void Main::editNewBranchAbove()
2849 VymModel *m=currentModel();
2852 BranchItem *bi=m->addNewBranch (-1);
2860 if (actionSettingsAutoEditNewBranch->isOn())
2862 if (!actionSettingsAutoSelectNewBranch->isOn())
2863 prevSelection=m->getSelectString (bi);
2864 currentMapEditor()->editHeading();
2869 void Main::editNewBranchBelow()
2871 VymModel *m=currentModel();
2874 BranchItem *bi=m->addNewBranch (1);
2881 if (actionSettingsAutoEditNewBranch->isOn())
2883 if (!actionSettingsAutoSelectNewBranch->isOn())
2884 prevSelection=m->getSelectString(bi);
2885 currentMapEditor()->editHeading();
2890 void Main::editImportAdd()
2892 fileLoad (ImportAdd);
2895 void Main::editImportReplace()
2897 fileLoad (ImportReplace);
2900 void Main::editSaveBranch()
2902 fileSaveAs (PartOfMap);
2905 void Main::editDeleteKeepChildren()
2907 VymModel *m=currentModel();
2908 if (m) m->deleteKeepChildren();
2911 void Main::editDeleteChildren()
2913 VymModel *m=currentModel();
2914 if (m) m->deleteChildren();
2917 void Main::editDeleteSelection()
2919 VymModel *m=currentModel();
2920 if (m && actionSettingsUseDelKey->isOn())
2921 m->deleteSelection();
2924 void Main::editLoadImage()
2926 VymModel *m=currentModel();
2927 if (m) m->loadFloatImage();
2930 void Main::editSaveImage()
2932 VymModel *m=currentModel();
2933 if (m) m->saveFloatImage();
2936 void Main::editFollowXLink(QAction *a)
2939 VymModel *m=currentModel();
2941 m->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
2944 void Main::editEditXLink(QAction *a)
2946 VymModel *m=currentModel();
2948 m->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
2951 void Main::formatSelectColor()
2953 QColor col = QColorDialog::getColor((currentColor ), this );
2954 if ( !col.isValid() ) return;
2955 colorChanged( col );
2958 void Main::formatPickColor()
2960 VymModel *m=currentModel();
2962 colorChanged( m->getCurrentHeadingColor() );
2965 void Main::colorChanged(QColor c)
2967 QPixmap pix( 16, 16 );
2969 actionFormatColor->setIconSet( pix );
2973 void Main::formatColorBranch()
2975 VymModel *m=currentModel();
2976 if (m) m->colorBranch(currentColor);
2979 void Main::formatColorSubtree()
2981 VymModel *m=currentModel();
2982 if (m) m->colorSubtree (currentColor);
2985 void Main::formatLinkStyleLine()
2987 VymModel *m=currentModel();
2990 m->setMapLinkStyle("StyleLine");
2991 actionFormatLinkStyleLine->setChecked(true);
2995 void Main::formatLinkStyleParabel()
2997 VymModel *m=currentModel();
3000 m->setMapLinkStyle("StyleParabel");
3001 actionFormatLinkStyleParabel->setChecked(true);
3005 void Main::formatLinkStylePolyLine()
3007 VymModel *m=currentModel();
3010 m->setMapLinkStyle("StylePolyLine");
3011 actionFormatLinkStylePolyLine->setChecked(true);
3015 void Main::formatLinkStylePolyParabel()
3017 VymModel *m=currentModel();
3020 m->setMapLinkStyle("StylePolyParabel");
3021 actionFormatLinkStylePolyParabel->setChecked(true);
3025 void Main::formatSelectBackColor()
3027 VymModel *m=currentModel();
3028 if (m) m->selectMapBackgroundColor();
3031 void Main::formatSelectBackImage()
3033 VymModel *m=currentModel();
3035 m->selectMapBackgroundImage();
3038 void Main::formatSelectLinkColor()
3040 VymModel *m=currentModel();
3043 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3044 m->setMapDefLinkColor( col );
3048 void Main::formatSelectSelectionColor()
3050 VymModel *m=currentModel();
3053 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3054 m->setSelectionColor (col);
3059 void Main::formatToggleLinkColorHint()
3061 VymModel *m=currentModel();
3062 if (m) m->toggleMapLinkColorHint();
3066 void Main::formatHideLinkUnselected() //FIXME-3 get rid of this with imagepropertydialog
3068 VymModel *m=currentModel();
3070 m->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3073 void Main::viewZoomReset()
3075 MapEditor *me=currentMapEditor();
3076 if (me) me->setZoomFactorTarget (1);
3079 void Main::viewZoomIn()
3081 MapEditor *me=currentMapEditor();
3082 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*1.25);
3085 void Main::viewZoomOut()
3087 MapEditor *me=currentMapEditor();
3088 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*0.75);
3091 void Main::viewCenter()
3093 VymModel *m=currentModel();
3094 if (m) m->emitShowSelection();
3097 void Main::networkStartServer()
3099 VymModel *m=currentModel();
3100 if (m) m->newServer();
3103 void Main::networkConnect()
3105 VymModel *m=currentModel();
3106 if (m) m->connectToServer();
3109 bool Main::settingsPDF()
3111 // Default browser is set in constructor
3113 QString text = QInputDialog::getText(
3114 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3115 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3117 settings.setValue ("/mainwindow/readerPDF",text);
3122 bool Main::settingsURL()
3124 // Default browser is set in constructor
3126 QString text = QInputDialog::getText(
3127 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3128 settings.value("/mainwindow/readerURL").toString()
3131 settings.setValue ("/mainwindow/readerURL",text);
3135 void Main::settingsMacroDir()
3137 QDir defdir(vymBaseDir.path() + "/macros");
3138 if (!defdir.exists())
3140 QDir dir=QFileDialog::getExistingDirectory (
3142 tr ("Directory with vym macros:"),
3143 settings.value ("/macros/macroDir",defdir.path()).toString()
3146 settings.setValue ("/macros/macroDir",dir.absolutePath());
3149 void Main::settingsUndoLevels()
3152 int i = QInputDialog::getInteger(
3154 tr("QInputDialog::getInteger()"),
3155 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3158 settings.setValue ("/mapeditor/stepsTotal",i);
3159 QMessageBox::information( this, tr( "VYM -Information:" ),
3160 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3164 void Main::settingsAutosaveToggle()
3166 settings.setValue ("/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
3169 void Main::settingsAutosaveTime()
3172 int i = QInputDialog::getInteger(
3174 tr("QInputDialog::getInteger()"),
3175 tr("Number of seconds before autosave:"), settings.value("/mainwindow/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3177 settings.setValue ("/mainwindow/autosave/ms",i * 1000);
3180 void Main::settingsWriteBackupFileToggle()
3182 settings.setValue ("/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
3185 void Main::settingsToggleAnimation()
3187 settings.setValue ("/animation/use",actionSettingsUseAnimation->isOn() );
3190 void Main::settingsToggleDelKey()
3192 if (actionSettingsUseDelKey->isOn())
3194 actionDelete->setAccel (QKeySequence (Qt::Key_Delete));
3197 actionDelete->setAccel (QKeySequence (""));
3201 void Main::windowToggleNoteEditor()
3203 if (textEditor->isVisible() )
3204 windowHideNoteEditor();
3206 windowShowNoteEditor();
3209 void Main::windowToggleHistory()
3211 if (historyWindow->isVisible())
3212 historyWindow->hide();
3214 historyWindow->show();
3218 void Main::windowToggleProperty()
3220 if (branchPropertyWindow->isVisible())
3221 branchPropertyWindow->hide();
3223 branchPropertyWindow->show();
3224 branchPropertyWindow->setModel (currentModel() );
3227 void Main::windowToggleAntiAlias()
3229 bool b=actionViewToggleAntiAlias->isOn();
3231 for (int i=0;i<vymViews.count();i++)
3233 me=vymViews.at(i)->getMapEditor();
3234 if (me) me->setAntiAlias(b);
3239 bool Main::isAliased()
3241 return actionViewToggleAntiAlias->isOn();
3244 bool Main::hasSmoothPixmapTransform()
3246 return actionViewToggleSmoothPixmapTransform->isOn();
3249 void Main::windowToggleSmoothPixmap()
3251 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3253 for (int i=0;i<vymViews.count();i++)
3256 me=vymViews.at(i)->getMapEditor();
3257 if (me) me->setSmoothPixmap(b);
3261 void Main::updateHistory(SimpleSettings &undoSet)
3263 historyWindow->update (undoSet);
3266 void Main::updateNoteFlag()
3268 // this slot is connected to TextEditor::textHasChanged()
3270 VymModel *m=currentModel();
3271 if (m) m->updateNoteFlag();
3274 void Main::updateNoteEditor(QModelIndex index )
3276 cout << QObject::sender();
3277 QObject *obj=QObject::sender();
3278 TreeItem *ti=((TreeModel*)obj)->getItem (index);
3279 //TreeItem *ti=((VymModel*) QObject::sender())->getItem(index);
3280 //cout << "Main::updateNoteEditor model="<<sender();
3281 //cout << " item="<<ti->headingStd()<<" ("<<ti<<")"<<endl;
3282 textEditor->setNote (ti->getNoteObj() );
3285 void Main::changeSelection (VymModel *model, const QItemSelection &newsel, const QItemSelection &oldsel)
3287 branchPropertyWindow->setModel (model ); //FIXME-3 this used to be called from BranchObj::select(). Maybe use signal now...
3289 if (model && model==currentModel() )
3293 if (!oldsel.indexes().isEmpty() )
3295 ti=model->getItem(oldsel.indexes().first());
3297 // Don't update note if both treeItem and textEditor are empty
3298 //if (! (ti->hasEmptyNote() && textEditor->isEmpty() ))
3299 // ti->setNoteObj (textEditor->getNoteObj(),false );
3301 if (!newsel.indexes().isEmpty() )
3303 ti=model->getItem(newsel.indexes().first());
3304 if (!ti->hasEmptyNote() )
3305 textEditor->setNote(ti->getNoteObj() );
3307 textEditor->setNote(NoteObj() ); //FIXME-4 maybe add a clear() to TE
3309 // Show URL and link in statusbar
3311 QString s=ti->getURL();
3312 if (!s.isEmpty() ) status+="URL: "+s+" ";
3314 if (!s.isEmpty() ) status+="Link: "+s;
3315 if (!status.isEmpty() ) statusMessage (status);
3318 textEditor->setInactive();
3324 void Main::updateActions()
3326 // updateActions is also called when satellites are closed //FIXME-2 doesn't update immediatly, e.g. historyWindow is still visible, when "close" is pressed
3327 actionViewToggleNoteEditor->setChecked (textEditor->isVisible());
3328 actionViewToggleHistoryWindow->setChecked (historyWindow->isVisible());
3329 actionViewTogglePropertyWindow->setChecked (branchPropertyWindow->isVisible());
3331 VymModel *m =currentModel();
3335 actionFilePrint->setEnabled (true);
3337 // Link style in context menu
3338 switch (m->getMapLinkStyle())
3340 case LinkableMapObj::Line:
3341 actionFormatLinkStyleLine->setChecked(true);
3343 case LinkableMapObj::Parabel:
3344 actionFormatLinkStyleParabel->setChecked(true);
3346 case LinkableMapObj::PolyLine:
3347 actionFormatLinkStylePolyLine->setChecked(true);
3349 case LinkableMapObj::PolyParabel:
3350 actionFormatLinkStylePolyParabel->setChecked(true);
3357 QPixmap pix( 16, 16 );
3358 pix.fill( m->getMapBackgroundColor() );
3359 actionFormatBackColor->setIconSet( pix );
3360 pix.fill( m->getSelectionColor() );
3361 actionFormatSelectionColor->setIconSet( pix );
3362 pix.fill( m->getMapDefLinkColor() );
3363 actionFormatLinkColor->setIconSet( pix );
3366 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName()));
3371 actionFilePrint->setEnabled (false);
3374 if (m && m->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3375 actionFormatLinkColorHint->setChecked(true);
3377 actionFormatLinkColorHint->setChecked(false);
3380 if (m && m->hasChanged() )
3381 actionFileSave->setEnabled( true);
3383 actionFileSave->setEnabled( false);
3384 if (m && m->isUndoAvailable())
3385 actionUndo->setEnabled( true);
3387 actionUndo->setEnabled( false);
3389 if (m && m->isRedoAvailable())
3390 actionRedo->setEnabled( true);
3392 actionRedo->setEnabled( false);
3396 TreeItem *selti=m->getSelectedItem();
3397 BranchItem *selbi=m->getSelectedBranch();
3400 if (selbi || selti->getType()==TreeItem::Image)
3402 actionFormatHideLinkUnselected->setChecked (((MapItem*)selti)->getHideLinkUnselected());
3403 actionFormatHideLinkUnselected->setEnabled (true);
3408 // Take care of xlinks
3409 branchXLinksContextMenuEdit->clear();
3410 branchXLinksContextMenuFollow->clear();
3411 if (selbi->xlinkCount()>0)
3415 for (int i=0; i<selbi->xlinkCount();++i)
3417 bi=selbi->getXLinkNum(i)->getPartnerBranch();
3421 if (s.length()>xLinkMenuWidth)
3422 s=s.left(xLinkMenuWidth)+"...";
3423 branchXLinksContextMenuFollow->addAction (s);
3424 branchXLinksContextMenuEdit->addAction (s);
3429 standardFlagsMaster->updateToolBar (selbi->activeStandardFlagNames() );
3432 actionToggleScroll->setEnabled (true);
3433 if ( selbi->isScrolled() )
3434 actionToggleScroll->setChecked(true);
3436 actionToggleScroll->setChecked(false);
3438 if ( selti->getURL().isEmpty() )
3440 actionOpenURL->setEnabled (false);
3441 actionOpenURLTab->setEnabled (false);
3445 actionOpenURL->setEnabled (true);
3446 actionOpenURLTab->setEnabled (true);
3448 if ( selti->getVymLink().isEmpty() )
3450 actionOpenVymLink->setEnabled (false);
3451 actionDeleteVymLink->setEnabled (false);
3454 actionOpenVymLink->setEnabled (true);
3455 actionDeleteVymLink->setEnabled (true);
3458 if (selbi->canMoveUp())
3459 actionMoveUp->setEnabled (true);
3461 actionMoveUp->setEnabled (false);
3462 if (selbi->canMoveDown())
3463 actionMoveDown->setEnabled (true);
3465 actionMoveDown->setEnabled (false);
3467 actionSortChildren->setEnabled (true);
3469 actionToggleHideExport->setEnabled (true);
3470 actionToggleHideExport->setChecked (selbi->hideInExport() );
3472 actionCopy->setEnabled (true);
3473 actionCut->setEnabled (true);
3474 if (!clipboardEmpty)
3475 actionPaste->setEnabled (true);
3477 actionPaste->setEnabled (false);
3478 for (int i=0; i<actionListBranches.size(); ++i)
3479 actionListBranches.at(i)->setEnabled(true);
3480 actionDelete->setEnabled (true);
3482 if ( selti->getType()==TreeItem::Image)
3484 actionOpenURL->setEnabled (false);
3485 actionOpenVymLink->setEnabled (false);
3486 actionDeleteVymLink->setEnabled (false);
3487 actionToggleHideExport->setEnabled (true);
3488 actionToggleHideExport->setChecked (selti->hideInExport() );
3491 actionCopy->setEnabled (true);
3492 actionCut->setEnabled (true);
3493 actionPaste->setEnabled (false); //FIXME-4 why not allowing copy of images?
3494 for (int i=0; i<actionListBranches.size(); ++i)
3495 actionListBranches.at(i)->setEnabled(false);
3496 actionDelete->setEnabled (true);
3497 actionMoveUp->setEnabled (false);
3498 actionMoveDown->setEnabled (false);
3503 actionCopy->setEnabled (false);
3504 actionCut->setEnabled (false);
3505 actionPaste->setEnabled (false);
3506 for (int i=0; i<actionListBranches.size(); ++i)
3507 actionListBranches.at(i)->setEnabled(false);
3509 actionToggleScroll->setEnabled (false);
3510 actionOpenURL->setEnabled (false);
3511 actionOpenVymLink->setEnabled (false);
3512 actionDeleteVymLink->setEnabled (false);
3513 actionHeading2URL->setEnabled (false);
3514 actionDelete->setEnabled (false);
3515 actionMoveUp->setEnabled (false);
3516 actionMoveDown->setEnabled (false);
3517 actionFormatHideLinkUnselected->setEnabled (false);
3518 actionSortChildren->setEnabled (false);
3519 actionToggleHideExport->setEnabled (false);
3524 Main::ModMode Main::getModMode()
3526 if (actionModModeColor->isOn()) return ModModeColor;
3527 if (actionModModeCopy->isOn()) return ModModeCopy;
3528 if (actionModModeXLink->isOn()) return ModModeXLink;
3532 bool Main::autoEditNewBranch()
3534 return actionSettingsAutoEditNewBranch->isOn();
3537 bool Main::autoSelectNewBranch()
3539 return actionSettingsAutoSelectNewBranch->isOn();
3542 void Main::windowShowNoteEditor()
3544 textEditor->setShowWithMain(true);
3546 actionViewToggleNoteEditor->setChecked (true);
3549 void Main::windowHideNoteEditor()
3551 textEditor->setShowWithMain(false);
3553 actionViewToggleNoteEditor->setChecked (false);
3556 void Main::setScript (const QString &script)
3558 scriptEditor->setScript (script);
3561 void Main::runScript (const QString &script)
3563 VymModel *m=currentModel();
3564 if (m) m->runScript (script);
3567 void Main::runScriptEverywhere (const QString &script)
3570 for (int i=0;i<=tabWidget->count() -1;i++)
3572 me=(MapEditor*)tabWidget->page(i);
3573 if (me) me->getModel()->runScript (script);
3577 void Main::windowNextEditor()
3579 if (tabWidget->currentIndex() < tabWidget->count())
3580 tabWidget->setCurrentIndex (tabWidget->currentIndex() +1);
3583 void Main::windowPreviousEditor()
3585 if (tabWidget->currentIndex() >0)
3586 tabWidget->setCurrentIndex (tabWidget->currentIndex() -1);
3589 void Main::standardFlagChanged()
3593 if ( actionSettingsUseFlagGroups->isOn() )
3594 currentModel()->toggleStandardFlag(sender()->name(),standardFlagsMaster);
3596 currentModel()->toggleStandardFlag(sender()->name());
3601 void Main::testFunction1()
3603 if (!currentMapEditor()) return;
3604 //currentMapEditor()->testFunction1();
3607 VymModel *m=currentModel();
3611 QString text = QInputDialog::getText(
3612 "VYM", "Enter Filter:", QLineEdit::Normal, // FIXME-3 no translation yet
3613 m->getSortFilter(), &ok, NULL);
3615 // user entered something and pressed OK
3616 m->setSortFilter (text);
3619 void Main::testFunction2()
3621 if (!currentMapEditor()) return;
3622 currentMapEditor()->testFunction2();
3625 void Main::testCommand()
3627 if (!currentMapEditor()) return;
3628 scriptEditor->show();
3631 QString com = QInputDialog::getText(
3632 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3633 if (ok) currentMapEditor()->parseAtom(com);
3637 void Main::helpDoc()
3639 QString locale = QLocale::system().name();
3641 if (locale.left(2)=="es")
3642 docname="vym_es.pdf";
3646 QStringList searchList;
3648 #if defined(Q_OS_MACX)
3649 searchList << "./vym.app/Contents/Resources/doc";
3650 #elif defined(Q_OS_WIN32)
3651 searchList << vymInstallDir.path() + "/share/doc/packages/vym";
3653 #if defined(VYM_DOCDIR)
3654 searchList << VYM_DOCDIR;
3656 // default path in SUSE LINUX
3657 searchList << "/usr/share/doc/packages/vym";
3660 searchList << "doc"; // relative path for easy testing in tarball
3661 searchList << "doc/tex"; // Easy testing working on vym.tex
3662 searchList << "/usr/share/doc/vym"; // Debian
3663 searchList << "/usr/share/doc/packages";// Knoppix
3667 for (int i=0; i<searchList.count(); ++i)
3669 docfile.setFileName(searchList.at(i)+"/"+docname);
3670 if (docfile.exists())
3679 QMessageBox::critical(0,
3680 tr("Critcal error"),
3681 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3686 Process *pdfProc = new Process();
3687 args << QDir::toNativeSeparators(docfile.fileName());
3689 pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
3690 if ( !pdfProc->waitForStarted() )
3693 QMessageBox::warning(0,
3695 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3696 tr("Please use Settings->")+tr("Set application to open PDF files"));
3703 void Main::helpDemo()
3705 QStringList filters;
3706 filters <<"VYM example map (*.vym)";
3707 QFileDialog *fd=new QFileDialog( this);
3708 #if defined(Q_OS_MACX)
3709 fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
3711 // default path in SUSE LINUX
3712 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
3715 fd->setFileMode (QFileDialog::ExistingFiles);
3716 fd->setFilters (filters);
3717 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
3721 if ( fd->exec() == QDialog::Accepted )
3723 lastFileDir=fd->directory().path();
3724 QStringList flist = fd->selectedFiles();
3725 QStringList::Iterator it = flist.begin();
3726 while( it != flist.end() )
3729 fileLoad(*it, NewMap);
3737 void Main::helpAbout()
3740 ad.setName ("aboutwindow");
3741 ad.setMinimumSize(500,500);
3742 ad.resize (QSize (500,500));
3746 void Main::helpAboutQT()
3748 QMessageBox::aboutQt( this, "Qt Application Example" );
3751 void Main::callMacro ()
3753 QAction *action = qobject_cast<QAction *>(sender());
3757 i=action->data().toInt();
3758 QString mDir (settings.value ("macros/macroDir").toString() );
3760 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3762 if ( !f.open( QIODevice::ReadOnly ) )
3764 QMessageBox::warning(0,
3766 tr("Couldn't find a macro at %1.\n").arg(fn)+
3767 tr("Please use Settings->")+tr("Set directory for vym macros"));
3771 QTextStream ts( &f );
3772 QString macro= ts.read();
3774 if (! macro.isEmpty())
3776 VymModel *m=currentModel();
3777 if (m) m->runScript(macro);