1 #include "mainwindow.h"
8 #include "aboutdialog.h"
9 #include "branchpropwindow.h"
10 #include "branchitem.h"
11 #include "exportoofiledialog.h"
14 #include "findresultwidget.h"
15 #include "findwidget.h"
17 #include "historywindow.h"
19 #include "mapeditor.h"
24 #include "shortcuts.h"
25 #include "texteditor.h"
26 #include "treeeditor.h"
27 #include "warningdialog.h"
28 #include "xlinkitem.h"
30 //#include <modeltest.h> // FIXME-3
32 #if defined(Q_OS_WIN32)
33 // Define only this structure as opposed to
34 // including full 'windows.h'. FindWindow
35 // clashes with the one in Win32 API.
36 typedef struct _PROCESS_INFORMATION
42 } PROCESS_INFORMATION, *LPPROCESS_INFORMATION;
45 extern TextEditor *textEditor;
46 extern Main *mainWindow;
47 extern FindWidget *findWidget;
48 extern FindResultWidget *findResultWidget;
49 extern QString tmpVymDir;
50 extern QString clipboardDir;
51 extern QString clipboardFile;
52 extern bool clipboardEmpty;
53 extern int statusbarTime;
54 extern FlagRow *standardFlagsMaster;
55 extern FlagRow *systemFlagsMaster;
56 extern QString vymName;
57 extern QString vymVersion;
58 extern QString vymBuildDate;
61 QMenu* branchContextMenu;
62 QMenu* branchAddContextMenu;
63 QMenu* branchRemoveContextMenu;
64 QMenu* branchLinksContextMenu;
65 QMenu* branchXLinksContextMenuEdit;
66 QMenu* floatimageContextMenu;
67 QMenu* canvasContextMenu;
68 QMenu* fileLastMapsMenu;
69 QMenu* fileImportMenu;
70 QMenu* fileExportMenu;
73 extern Settings settings;
74 extern Options options;
75 extern ImageIO imageIO;
77 extern QDir vymBaseDir;
78 extern QDir lastImageDir;
79 extern QDir lastFileDir;
80 #if defined(Q_OS_WIN32)
81 extern QDir vymInstallDir;
83 extern QString iconPath;
84 extern QString flagsPath;
87 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
88 QMainWindow(parent,name,f)
92 setCaption ("VYM - View Your Mind");
94 // Load window settings
95 #if defined(Q_OS_WIN32)
96 if (settings.value("/mainwindow/geometry/maximized", false).toBool())
98 setWindowState(Qt::WindowMaximized);
103 resize (settings.value("/mainwindow/geometry/size", QSize (800,600)).toSize());
104 move (settings.value("/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
107 // Sometimes we may need to remember old selections
111 currentColor=Qt::black;
113 // Create unique temporary directory
115 tmpVymDir=makeTmpDir (ok,"vym");
118 qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
121 if (debug) qDebug (QString("vym tmpDir=%1").arg(tmpVymDir) );
123 // Create direcctory for clipboard
124 clipboardDir=tmpVymDir+"/clipboard";
125 clipboardFile="map.xml";
126 QDir d(clipboardDir);
127 d.mkdir (clipboardDir,true);
128 makeSubDirs (clipboardDir);
131 // Remember PID of our friendly webbrowser
132 browserPID=new qint64;
136 findResultWidget=new FindResultWidget ();
137 QDockWidget *dw= new QDockWidget (tr ("Search results","FindResultWidget"),this);
138 dw->setWidget (findResultWidget);
139 dw->setObjectName ("FindResultWidget");
141 addDockWidget (Qt::RightDockWidgetArea,dw);
142 connect (findResultWidget, SIGNAL (noteSelected (QString, int)),this, SLOT (selectInNoteEditor (QString, int)));
145 // Satellite windows //////////////////////////////////////////
147 historyWindow=new HistoryWindow();
148 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
151 branchPropertyWindow = new BranchPropertyWindow();
152 connect (branchPropertyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
154 // Connect TextEditor, so that we can update flags if text changes
155 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
156 connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
158 // Initialize script editor
159 scriptEditor = new SimpleScriptEditor();
160 scriptEditor->move (50,50);
162 connect( scriptEditor, SIGNAL( runScript ( QString ) ),
163 this, SLOT( runScript( QString ) ) );
165 // Initialize some settings, which are platform dependant
168 // application to open URLs
169 p="/mainwindow/readerURL";
170 #if defined(Q_OS_LINUX)
171 s=settings.value (p,"xdg-open").toString();
173 #if defined(Q_OS_MACX)
174 s=settings.value (p,"/usr/bin/open").toString();
177 #if defined(Q_OS_WIN32)
178 // Assume that system has been set up so that
179 // Explorer automagically opens up the URL
180 // in the user's preferred browser.
181 s=settings.value (p,"explorer").toString();
183 s=settings.value (p,"mozilla").toString();
187 settings.setValue( p,s);
189 // application to open PDFs
190 p="/mainwindow/readerPDF";
191 #if defined(Q_OS_LINUX)
192 s=settings.value (p,"xdg-open").toString();
194 #if defined(Q_OS_MACX)
195 s=settings.value (p,"/usr/bin/open").toString();
196 #elif defined(Q_OS_WIN32)
197 s=settings.value (p,"acrord32").toString();
199 s=settings.value (p,"acroread").toString();
202 settings.setValue( p,s);
204 // width of xLinksMenu
208 QWidget* centralWidget = new QWidget (this);
209 QVBoxLayout *layout=new QVBoxLayout (centralWidget);
210 setCentralWidget(centralWidget);
212 // Create tab widget which holds the maps
213 tabWidget= new QTabWidget (centralWidget);
214 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
215 this, SLOT( editorChanged( QWidget * ) ) );
218 findWidget = new FindWidget (centralWidget);
220 layout->addWidget (tabWidget);
221 layout->addWidget (findWidget);
224 findWidget, SIGNAL (nextButton (QString) ),
225 this, SLOT (editFindNext(QString) ) );
227 findWidget , SIGNAL (hideFindWidget() ),
228 this, SLOT (editHideFindWidget() ) );
232 setupFormatActions();
236 setupNetworkActions();
237 setupSettingsActions();
240 if (options.isOn("shortcuts")) switchboard.print();
241 if (options.isOn("shortcutsLaTeX")) switchboard.printLaTeX();
243 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
246 // Status bar and progress bar there
250 progressCounterTotal=0;
252 progressDialog.setLabelText (tr("Loading maps","Mainwindow"));
253 progressDialog.setAutoReset(false);
254 progressDialog.setAutoClose(false);
255 //progressDialog.setWindowModality (Qt::WindowModal); // That forces mainwindo to update and slows down
256 //progressDialog.setCancelButton (NULL);
258 restoreState (settings.value("/mainwindow/state",0).toByteArray());
266 #if defined(Q_OS_WIN32)
267 settings.setValue ("/mainwindow/geometry/maximized", isMaximized());
269 settings.setValue ("/mainwindow/geometry/size", size());
270 settings.setValue ("/mainwindow/geometry/pos", pos());
271 settings.setValue ("/mainwindow/state",saveState(0));
273 settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
274 settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
275 settings.setValue( "/version/version", vymVersion );
276 settings.setValue( "/version/builddate", vymBuildDate );
278 settings.setValue( "/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
279 settings.setValue ("/mainwindow/autoLayout/use",actionSettingsAutoLayoutToggle->isOn() );
280 settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isOn() );
281 settings.setValue( "/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
282 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
283 settings.setValue( "/mapeditor/editmode/autoEditNewBranch",actionSettingsAutoEditNewBranch->isOn() );
284 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
285 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
286 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
288 //TODO save scriptEditor settings
290 // call the destructors
292 delete historyWindow;
293 delete branchPropertyWindow;
295 // Remove temporary directory
296 removeDir (QDir(tmpVymDir));
299 void Main::loadCmdLine()
301 /* TODO draw some kind of splashscreen while loading...
307 QStringList flist=options.getFileList();
308 QStringList::Iterator it=flist.begin();
310 progressCounter=flist.count();
311 progressCounterTotal=flist.count();
312 while (it !=flist.end() )
314 fileLoad (*it, NewMap);
320 void Main::statusMessage(const QString &s)
322 // Surpress messages while progressdialog during
325 statusBar()->message( s);
328 void Main::setProgressMaximum (int max)
330 if (progressCounterTotal!=0)
332 progressDialog.setRange (0,progressCounterTotal*1000);
334 progressDialog.setRange (0,max+10);
336 progressDialog.setValue (0);
337 progressMax=max*1000;
338 //cout << "Main max="<<max<<" v="<<progressDialog.value()<<endl;
339 progressDialog.show();
342 void Main::addProgressValue (float v)
344 //cout << "addVal v="<<v*1000<<"/"<<progressMax<<" cur="<<progressDialog.value()<<" counter="<<v+progressCounter<<"/"<<progressCounterTotal<<endl;
345 if (progressCounterTotal!=0)
346 progressDialog.setValue ( (v+progressCounterTotal-progressCounter)*1000 );
348 progressDialog.setValue (v+progressDialog.value());
351 void Main::removeProgressCounter()
355 if (progressCounter<=0)
358 progressCounterTotal=0;
359 progressDialog.reset();
360 progressDialog.hide();
364 void Main::closeEvent (QCloseEvent* )
370 void Main::setupFileActions()
372 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
373 QToolBar *tb = addToolBar( tr ("&Map") );
374 tb->setObjectName ("mapTB");
377 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this);
378 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
379 a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map
380 switchboard.addConnection(a,tr("File","Shortcut group"));
382 fileMenu->addAction (a);
383 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
385 a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this);
386 a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) );
387 a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N ); //New map
388 switchboard.addConnection(a,tr("File","Shortcut group"));
389 fileMenu->addAction (a);
390 connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) );
393 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
394 a->setStatusTip (tr( "Open","Status tip File menu" ) );
395 a->setShortcut ( Qt::CTRL + Qt::Key_O ); //Open map
396 switchboard.addConnection(a,tr("File","Shortcut group"));
398 fileMenu->addAction (a);
399 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
401 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
402 fileMenu->addSeparator();
404 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
405 a->setStatusTip ( tr( "Save","Status tip file menu" ));
406 a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map
407 switchboard.addConnection(a,tr("File","Shortcut group"));
409 fileMenu->addAction (a);
410 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
413 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
414 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
415 switchboard.addConnection(a,tr("File","Shortcut group"));
416 fileMenu->addAction (a);
417 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
419 fileMenu->addSeparator();
421 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
423 a = new QAction(tr("KDE 3 Bookmarks"), this);
424 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 3 bookmarks")));
425 switchboard.addConnection(a,tr("File","Shortcut group"));
426 a->addTo (fileImportMenu);
427 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE3Bookmarks() ) );
429 a = new QAction(tr("KDE 4 Bookmarks"), this);
430 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 4 bookmarks")));
431 a->addTo (fileImportMenu);
432 switchboard.addConnection(a,tr("File","Shortcut group"));
433 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE4Bookmarks() ) );
435 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
437 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
438 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
439 a->addTo (fileImportMenu);
440 switchboard.addConnection(a,tr("File","Shortcut group"));
441 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
444 a = new QAction("Freemind...",this);
445 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Freemind") );
446 switchboard.addConnection(a,tr("File","Shortcut group"));
447 fileImportMenu->addAction (a);
448 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFreemind() ) );
450 a = new QAction("Mind Manager...",this);
451 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
452 switchboard.addConnection(a,tr("File","Shortcut group"));
453 fileImportMenu->addAction (a);
454 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
456 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
457 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
458 switchboard.addConnection(a,tr("File","Shortcut group"));
459 fileImportMenu->addAction (a);
460 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
462 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
464 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
465 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
466 switchboard.addConnection(a,tr("File","Shortcut group"));
467 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
468 fileExportMenu->addAction (a);
470 a = new QAction( "Open Office...", this);
471 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
472 switchboard.addConnection(a,tr("File","Shortcut group"));
473 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
474 fileExportMenu->addAction (a);
476 a = new QAction( "Webpage (HTML)...",this );
477 a->setShortcut (Qt::ALT + Qt::Key_X); //Export HTML
478 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (HTML)","status tip file menu")));
479 switchboard.addConnection(a,tr("File","Shortcut group"));
480 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportHTML() ) );
481 fileExportMenu->addAction (a);
483 a = new QAction( "Text (A&O report)...", this);
484 a->setStatusTip ( tr( "Export as %1").arg("A&O report "+tr("(still experimental)" )));
485 switchboard.addConnection(a,tr("File","Shortcut group"));
486 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportAO() ) );
487 fileExportMenu->addAction (a);
489 a = new QAction( "Text (ASCII)...", this);
490 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
491 switchboard.addConnection(a,tr("File","Shortcut group"));
492 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
493 fileExportMenu->addAction (a);
495 a = new QAction( "Spreadsheet (CSV)...", this);
496 a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
497 switchboard.addConnection(a,tr("File","Shortcut group"));
498 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
499 fileExportMenu->addAction (a);
501 a = new QAction( tr("KDE 3 Bookmarks","File menu"), this);
502 a->setStatusTip( tr( "Export as %1").arg(tr("KDE 3 Bookmarks" )));
503 switchboard.addConnection(a,tr("File","Shortcut group"));
504 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE3Bookmarks() ) );
505 fileExportMenu->addAction (a);
507 a = new QAction( tr("KDE 4 Bookmarks","File menu"), this);
508 a->setStatusTip( tr( "Export as %1").arg(tr("KDE 4 Bookmarks" )));
509 switchboard.addConnection(a,tr("File","Shortcut group"));
510 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE4Bookmarks() ) );
511 fileExportMenu->addAction (a);
513 a = new QAction( "Taskjuggler...", this );
514 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
515 switchboard.addConnection(a,tr("File","Shortcut group"));
516 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
517 fileExportMenu->addAction (a);
519 a = new QAction( "LaTeX...", this);
520 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
521 switchboard.addConnection(a,tr("File","Shortcut group"));
522 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
523 fileExportMenu->addAction (a);
525 a = new QAction( "XML..." , this );
526 a->setStatusTip (tr( "Export as %1").arg("XML"));
527 switchboard.addConnection(a,tr("File","Shortcut group"));
528 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
529 fileExportMenu->addAction (a);
531 fileMenu->addSeparator();
533 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
534 a->setStatusTip ( tr( "Print" ,"File menu") );
535 a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map
537 switchboard.addConnection(a,tr("File","Shortcut group"));
538 fileMenu->addAction (a);
539 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
542 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
543 a->setStatusTip (tr( "Close Map" ) );
544 a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map
545 switchboard.addConnection(a,tr("File","Shortcut group"));
546 fileMenu->addAction (a);
547 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
549 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
550 a->setStatusTip ( tr( "Exit")+" "+vymName );
551 a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym
552 switchboard.addConnection(a,tr("File","Shortcut group"));
553 fileMenu->addAction (a);
554 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
559 void Main::setupEditActions()
561 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
562 tb->setLabel( "Edit Actions" );
563 tb->setObjectName ("actionsTB");
564 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
567 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
568 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
569 a->setStatusTip (tr( "Undo" ) );
570 a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action
571 a->setEnabled (false);
572 switchboard.addConnection(a,tr("Edit","Shortcut group"));
574 editMenu->addAction (a);
577 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
578 a->setStatusTip (tr( "Redo" ));
579 a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action
580 switchboard.addConnection(a,tr("Edit","Shortcut group"));
582 editMenu->addAction (a);
583 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
586 editMenu->addSeparator();
587 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
588 a->setStatusTip ( tr( "Copy" ) );
589 a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy
590 a->setEnabled (false);
591 switchboard.addConnection(a,tr("Edit","Shortcut group"));
593 editMenu->addAction (a);
594 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
597 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
598 a->setStatusTip ( tr( "Cut" ) );
599 a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut
600 a->setEnabled (false);
602 switchboard.addConnection(a,tr("Edit","Shortcut group"));
603 editMenu->addAction (a);
605 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
607 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
608 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
609 a->setStatusTip ( tr( "Paste" ) );
610 a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste
611 a->setEnabled (false);
613 switchboard.addConnection(a,tr("Edit","Shortcut group"));
614 editMenu->addAction (a);
617 // Shortcut to delete selection
618 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
619 a->setStatusTip (tr( "Delete Selection" ));
620 a->setShortcut ( Qt::Key_Delete); //Delete selection
621 a->setShortcutContext (Qt::WindowShortcut);
622 switchboard.addConnection(a,tr("Edit","Shortcut group"));
624 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
627 // Shortcut to add attribute
628 a= new QAction(tr( "Add attribute" ), this);
629 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
631 a->setShortcut ( Qt::Key_Q);
632 a->setShortcutContext (Qt::WindowShortcut);
633 switchboard.addConnection(a,tr("Edit","Shortcut group"));
636 connect( a, SIGNAL( triggered() ), this, SLOT( editAddAttribute() ) );
637 actionAddAttribute= a;
640 // Shortcut to add mapcenter
641 a= new QAction(QPixmap(iconPath+"newmapcenter.png"),tr( "Add mapcenter","Canvas context menu" ), this);
642 a->setShortcut ( Qt::Key_M);
643 a->setShortcutContext (Qt::WindowShortcut);
644 switchboard.addConnection(a,tr("Edit","Shortcut group"));
645 connect( a, SIGNAL( triggered() ), this, SLOT( editAddMapCenter() ) );
646 //actionListBranches.append(a);
648 actionAddMapCenter = a;
651 // Shortcut to add branch
652 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
653 a->setStatusTip ( tr( "Add a branch as child of selection" ));
654 a->setShortcut (Qt::Key_A); //Add branch
655 a->setShortcutContext (Qt::WindowShortcut);
656 switchboard.addConnection(a,tr("Edit","Shortcut group"));
658 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
659 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
660 a->setStatusTip ( tr( "Add a branch as child of selection" ));
661 a->setShortcut (Qt::Key_Insert); //Add branch
662 switchboard.addConnection(a,tr("Edit","Shortcut group"));
663 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
664 actionListBranches.append(a);
666 editMenu->addAction (actionAddBranch);
667 tb->addAction (actionAddBranch);
670 // Add branch by inserting it at selection
671 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
672 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
673 a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch
674 a->setShortcutContext (Qt::WindowShortcut);
675 switchboard.addConnection(a,tr("Edit","Shortcut group"));
677 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
678 actionListBranches.append(a);
679 actionAddBranchBefore=a;
682 a = new QAction(tr( "Add branch above","Edit menu" ), this);
683 a->setStatusTip ( tr( "Add a branch above selection" ));
684 a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
685 a->setShortcutContext (Qt::WindowShortcut);
686 switchboard.addConnection(a,tr("Edit","Shortcut group"));
688 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
689 a->setEnabled (false);
690 actionListBranches.append(a);
691 actionAddBranchAbove=a;
692 a = new QAction(tr( "Add branch above","Edit menu" ), this);
693 a->setStatusTip ( tr( "Add a branch above selection" ));
694 a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above
695 a->setShortcutContext (Qt::WindowShortcut);
696 switchboard.addConnection(a,tr("Edit","Shortcut group"));
698 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
699 actionListBranches.append(a);
702 a = new QAction(tr( "Add branch below","Edit menu" ), this);
703 a->setStatusTip ( tr( "Add a branch below selection" ));
704 a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
705 a->setShortcutContext (Qt::WindowShortcut);
706 switchboard.addConnection(a,tr("Edit","Shortcut group"));
708 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
709 a->setEnabled (false);
710 actionListBranches.append(a);
711 actionAddBranchBelow=a;
712 a = new QAction(tr( "Add branch below","Edit menu" ), this);
713 a->setStatusTip ( tr( "Add a branch below selection" ));
714 a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below
715 a->setShortcutContext (Qt::WindowShortcut);
716 switchboard.addConnection(a,tr("Edit","Shortcut group"));
718 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
719 actionListBranches.append(a);
721 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
722 a->setStatusTip ( tr( "Move branch up" ) );
723 a->setShortcut (Qt::Key_PageUp ); // Move branch up
724 a->setEnabled (false);
725 switchboard.addConnection(a,tr("Edit","Shortcut group"));
727 editMenu->addAction (a);
728 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
731 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
732 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
733 a->setStatusTip (tr( "Move branch down" ) );
734 a->setShortcut ( Qt::Key_PageDown ); // Move branch down
735 a->setEnabled (false);
736 switchboard.addConnection(a,tr("Edit","Shortcut group"));
738 editMenu->addAction (a);
741 a = new QAction(QPixmap(), tr( "&Detach","Context menu" ),this);
742 a->setStatusTip ( tr( "Detach branch and use as mapcenter","Context menu" ) );
743 a->setShortcut ( Qt::Key_D ); // Detach branch
744 switchboard.addConnection(a,tr("Edit","Shortcut group"));
745 editMenu->addAction (a);
746 connect( a, SIGNAL( triggered() ), this, SLOT( editDetach() ) );
749 a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this );
750 connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) );
751 a->setEnabled (true);
753 switchboard.addConnection(a,tr("Edit","Shortcut group"));
754 editMenu->addAction (a);
755 actionSortChildren=a;
757 a = new QAction( QPixmap(iconPath+"editsortback.png" ), tr( "Sort children backwards","Edit menu" ), this );
758 connect( a, SIGNAL( activated() ), this, SLOT( editSortBackChildren() ) );
759 a->setEnabled (true);
761 switchboard.addConnection(a,tr("Edit","Shortcut group"));
762 editMenu->addAction (a);
763 actionSortBackChildren=a;
765 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
766 a->setShortcut ( Qt::Key_S ); // Scroll branch
767 a->setStatusTip (tr( "Scroll branch" ));
768 switchboard.addConnection(a,tr("Edit","Shortcut group"));
769 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
770 a->setEnabled (false);
771 a->setToggleAction(true);
772 actionToggleScroll=a;
773 tb->addAction (actionToggleScroll);
774 editMenu->addAction ( actionToggleScroll);
775 editMenu->addAction (actionToggleScroll);
777 actionListBranches.append(actionToggleScroll);
779 a = new QAction( QPixmap(), tr( "Expand all branches","Edit menu" ), this);
780 a->setShortcut ( Qt::SHIFT + Qt::Key_X ); // Expand all branches
781 a->setStatusTip (tr( "Expand all branches" ));
782 switchboard.addConnection(a,tr("Edit","Shortcut group"));
783 connect( a, SIGNAL( triggered() ), this, SLOT( editExpandAll() ) );
785 actionExpandAll->setEnabled (false);
786 actionExpandAll->setToggleAction(false);
787 //tb->addAction (actionExpandAll);
788 editMenu->addAction ( actionExpandAll);
790 actionListBranches.append(actionExpandAll);
792 a = new QAction( QPixmap(), tr( "Expand one level","Edit menu" ), this);
793 a->setShortcut ( Qt::Key_Greater ); // Expand one level in tree editor
794 switchboard.addConnection(a,tr("Edit","Shortcut group"));
795 a->setStatusTip (tr( "Expand one level in tree editor" ));
796 connect( a, SIGNAL( triggered() ), this, SLOT( editExpandOneLevel() ) );
797 a->setEnabled (false);
798 a->setToggleAction(false);
799 actionExpandOneLevel=a;
801 editMenu->addAction ( a);
803 actionListBranches.append(a);
805 a = new QAction( QPixmap(), tr( "Collapse one level","Edit menu" ), this);
806 a->setShortcut ( Qt::Key_Less); // Collapse one level in tree editor
807 switchboard.addConnection(a,tr("Edit","Shortcut group"));
808 a->setStatusTip (tr( "Collapse one level in tree editor" ));
809 connect( a, SIGNAL( triggered() ), this, SLOT( editCollapseOneLevel() ) );
810 a->setEnabled (false);
811 a->setToggleAction(false);
812 actionCollapseOneLevel=a;
814 editMenu->addAction ( a);
816 actionListBranches.append(a);
818 a = new QAction( tr( "Unscroll children","Edit menu" ), this);
819 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
820 switchboard.addConnection(a,tr("Edit","Shortcut group"));
821 editMenu->addAction (a);
822 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChildren() ) );
824 editMenu->addSeparator();
826 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
827 a->setStatusTip (tr( "Find" ) );
828 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
829 switchboard.addConnection(a,tr("Edit","Shortcut group"));
830 editMenu->addAction (a);
831 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWidget() ) );
833 a = new QAction( tr( "Find duplicate URLs","Edit menu"), this);
834 //a->setStatusTip (tr( "Find" ) );
835 a->setShortcut (Qt::SHIFT + Qt::Key_F); //Find duplicate URLs
836 switchboard.addConnection(a,tr("Edit","Shortcut group"));
837 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
838 editMenu->addAction (a);
839 connect( a, SIGNAL( triggered() ), this, SLOT( editFindDuplicateURLs() ) );
841 editMenu->addSeparator();
843 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
844 a->setShortcut (Qt::SHIFT + Qt::Key_U );
845 switchboard.addConnection(a,tr("Edit","Shortcut group"));
848 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
851 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
852 a->setStatusTip (tr( "Open URL in new tab" ));
853 //a->setShortcut (Qt::CTRL+Qt::Key_U );
854 switchboard.addConnection(a,tr("Edit","Shortcut group"));
856 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
859 a = new QAction( tr( "Open all URLs in subtree (including scrolled branches)","Edit menu" ), this);
860 a->setStatusTip (tr( "Open all URLs in subtree (including scrolled branches)" ));
861 a->setShortcut ( Qt::CTRL + Qt::Key_U );
862 switchboard.addConnection(a,tr("Edit","Shortcut group"));
864 actionListBranches.append(a);
865 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVisURLTabs() ) );
866 actionOpenMultipleVisURLTabs=a;
868 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
869 a->setStatusTip (tr( "Open all URLs in subtree" ));
870 switchboard.addConnection(a,tr("Edit","Shortcut group"));
872 actionListBranches.append(a);
873 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
874 actionOpenMultipleURLTabs=a;
876 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
877 a->setStatusTip ( tr( "Edit URL" ) );
878 a->setShortcut ( Qt::Key_U );
879 a->setShortcutContext (Qt::WindowShortcut);
880 switchboard.addConnection(a,tr("Edit","Shortcut group"));
881 actionListBranches.append(a);
883 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
886 a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
887 a->setStatusTip ( tr( "Edit local URL" ) );
888 //a->setShortcut (Qt::SHIFT + Qt::Key_U );
889 a->setShortcutContext (Qt::WindowShortcut);
890 switchboard.addConnection(a,tr("Edit","Shortcut group"));
891 actionListBranches.append(a);
893 connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
896 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
897 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
898 a->setEnabled (false);
899 switchboard.addConnection(a,tr("Edit","Shortcut group"));
900 actionListBranches.append(a);
901 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
904 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
905 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
906 a->setEnabled (false);
907 actionListBranches.append(a);
908 a->setShortcut ( Qt::Key_B );
909 a->setShortcutContext (Qt::WindowShortcut);
910 switchboard.addConnection(a,tr("Edit","Shortcut group"));
912 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
913 actionBugzilla2URL=a;
915 a = new QAction(tr( "Get data from Novell Bugzilla","Edit menu" ), this);
916 a->setStatusTip ( tr( "Get data from Novell Bugzilla" ));
917 a->setEnabled (false);
918 actionListBranches.append(a);
919 a->setShortcut ( Qt::Key_B + Qt::SHIFT);
920 a->setShortcutContext (Qt::WindowShortcut);
921 switchboard.addConnection(a,tr("Edit","Shortcut group"));
923 connect( a, SIGNAL( triggered() ), this, SLOT( getBugzillaData() ) );
924 actionGetBugzillaData=a;
926 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
927 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
928 a->setEnabled (false);
929 switchboard.addConnection(a,tr("Edit","Shortcut group"));
930 actionListBranches.append(a);
931 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
934 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
935 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
937 a->setEnabled (false);
938 switchboard.addConnection(a,tr("Edit","Shortcut group"));
939 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
942 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
943 a->setStatusTip ( tr( "Open all vym links in subtree" ));
944 a->setEnabled (false);
945 switchboard.addConnection(a,tr("Edit","Shortcut group"));
946 actionListBranches.append(a);
947 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
948 actionOpenMultipleVymLinks=a;
951 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
952 a->setEnabled (false);
953 a->setStatusTip ( tr( "Edit link to another vym map" ));
954 switchboard.addConnection(a,tr("Edit","Shortcut group"));
955 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
956 actionListBranches.append(a);
959 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
960 a->setStatusTip ( tr( "Delete link to another vym map" ));
961 a->setEnabled (false);
962 switchboard.addConnection(a,tr("Edit","Shortcut group"));
963 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
964 actionDeleteVymLink=a;
966 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
967 a->setStatusTip ( tr( "Hide object in exports" ) );
968 a->setShortcut (Qt::Key_H );
969 a->setToggleAction(true);
971 a->setEnabled (false);
972 switchboard.addConnection(a,tr("Edit","Shortcut group"));
973 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
974 actionToggleHideExport=a;
976 a = new QAction(tr( "Add timestamp","Edit menu" ), this);
977 a->setStatusTip ( tr( "Add timestamp" ));
978 a->setEnabled (false);
979 actionListBranches.append(a);
980 a->setShortcut ( Qt::Key_T ); // Add timestamp
981 a->setShortcutContext (Qt::WindowShortcut);
982 switchboard.addConnection(a,tr("Edit","Shortcut group"));
984 connect( a, SIGNAL( triggered() ), this, SLOT( editAddTimestamp() ) );
985 actionAddTimestamp=a;
987 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
988 a->setStatusTip ( tr( "Edit Map Info" ));
989 a->setEnabled (true);
990 switchboard.addConnection(a,tr("Edit","Shortcut group"));
991 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
994 // Import at selection (adding to selection)
995 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
996 a->setStatusTip (tr( "Add map at selection" ));
997 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
998 a->setEnabled (false);
999 switchboard.addConnection(a,tr("Edit","Shortcut group"));
1000 actionListBranches.append(a);
1003 // Import at selection (replacing selection)
1004 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
1005 a->setStatusTip (tr( "Replace selection with map" ));
1006 switchboard.addConnection(a,tr("Edit","Shortcut group"));
1007 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
1008 a->setEnabled (false);
1009 actionListBranches.append(a);
1010 actionImportReplace=a;
1013 a = new QAction( tr( "Save selection","Edit menu" ), this);
1014 a->setStatusTip (tr( "Save selection" ));
1015 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
1016 a->setEnabled (false);
1017 switchboard.addConnection(a,tr("Edit","Shortcut group"));
1018 actionListBranches.append(a);
1021 // Only remove branch, not its children
1022 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
1023 a->setStatusTip ( tr( "Remove only branch and keep its children" ));
1024 a->setShortcut (Qt::ALT + Qt::Key_Delete );
1025 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChildren() ) );
1026 a->setEnabled (false);
1027 switchboard.addConnection(a,tr("Edit","Shortcut group"));
1029 actionListBranches.append(a);
1030 actionDeleteKeepChildren=a;
1032 // Only remove children of a branch
1033 a = new QAction( tr( "Remove children","Edit menu" ), this);
1034 a->setStatusTip (tr( "Remove children of branch" ));
1035 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
1036 switchboard.addConnection(a,tr("Edit","Shortcut group"));
1037 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChildren() ) );
1038 a->setEnabled (false);
1039 actionListBranches.append(a);
1040 actionDeleteChildren=a;
1042 a = new QAction( tr( "Add Image...","Edit menu" ), this);
1043 a->setStatusTip (tr( "Add Image" ));
1044 switchboard.addConnection(a,tr("Edit","Shortcut group"));
1045 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
1048 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
1049 a->setStatusTip (tr( "Set properties for selection" ));
1050 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
1051 a->setShortcutContext (Qt::WindowShortcut);
1052 a->setToggleAction (true);
1053 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1055 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
1056 actionViewTogglePropertyWindow=a;
1060 void Main::setupFormatActions()
1062 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
1064 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
1065 tb->setObjectName ("formatTB");
1067 QPixmap pix( 16,16);
1068 pix.fill (Qt::black);
1069 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
1070 a->setStatusTip ( tr( "Set Color" ));
1071 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
1073 formatMenu->addAction (a);
1074 actionFormatColor=a;
1075 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
1076 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
1077 a->setShortcut (Qt::CTRL + Qt::Key_K );
1078 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
1079 a->setEnabled (false);
1081 formatMenu->addAction (a);
1082 actionListBranches.append(a);
1083 actionFormatPickColor=a;
1085 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
1086 a->setStatusTip ( tr( "Color branch" ) );
1087 a->setShortcut (Qt::CTRL + Qt::Key_B + Qt::SHIFT);
1088 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
1089 a->setEnabled (false);
1091 formatMenu->addAction (a);
1092 actionListBranches.append(a);
1093 actionFormatColorSubtree=a;
1095 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
1096 a->setStatusTip ( tr( "Color Subtree" ));
1097 a->setShortcut (Qt::CTRL + Qt::Key_B); // Color subtree
1098 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
1099 a->setEnabled (false);
1100 formatMenu->addAction (a);
1102 actionListBranches.append(a);
1103 actionFormatColorSubtree=a;
1105 formatMenu->addSeparator();
1106 actionGroupFormatLinkStyles=new QActionGroup ( this);
1107 actionGroupFormatLinkStyles->setExclusive (true);
1108 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
1109 a->setStatusTip (tr( "Line" ));
1110 a->setToggleAction(true);
1111 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
1112 formatMenu->addAction (a);
1113 actionFormatLinkStyleLine=a;
1114 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
1115 a->setStatusTip (tr( "Line" ));
1116 a->setToggleAction(true);
1117 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
1118 formatMenu->addAction (a);
1119 actionFormatLinkStyleParabel=a;
1120 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
1121 a->setStatusTip (tr( "PolyLine" ));
1122 a->setToggleAction(true);
1123 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
1124 formatMenu->addAction (a);
1125 actionFormatLinkStylePolyLine=a;
1126 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
1127 a->setStatusTip (tr( "PolyParabel" ) );
1128 a->setToggleAction(true);
1129 a->setChecked (true);
1130 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
1131 formatMenu->addAction (a);
1132 actionFormatLinkStylePolyParabel=a;
1134 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
1135 a->setStatusTip (tr( "Hide link" ));
1136 a->setToggleAction(true);
1137 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
1138 actionFormatHideLinkUnselected=a;
1140 formatMenu->addSeparator();
1141 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
1142 a->setStatusTip (tr( "Use same color for links and headings" ));
1143 a->setToggleAction(true);
1144 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
1145 formatMenu->addAction (a);
1146 actionFormatLinkColorHint=a;
1148 pix.fill (Qt::white);
1149 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
1150 a->setStatusTip (tr( "Set Link Color" ));
1151 formatMenu->addAction (a);
1152 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
1153 actionFormatLinkColor=a;
1155 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
1156 a->setStatusTip (tr( "Set Selection Color" ));
1157 formatMenu->addAction (a);
1158 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
1159 actionFormatSelectionColor=a;
1161 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
1162 a->setStatusTip (tr( "Set Background Color" ));
1163 formatMenu->addAction (a);
1164 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
1165 actionFormatBackColor=a;
1167 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
1168 a->setStatusTip (tr( "Set Background image" ));
1169 formatMenu->addAction (a);
1170 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
1171 actionFormatBackImage=a;
1175 void Main::setupViewActions()
1177 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
1178 tb->setLabel( "View Actions" );
1179 tb->setObjectName ("viewTB");
1180 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
1184 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
1185 a->setStatusTip ( tr( "Zoom reset" ) );
1186 a->setShortcut (Qt::Key_Comma); // Reset zoom
1187 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1189 viewMenu->addAction (a);
1190 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
1192 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
1193 a->setStatusTip (tr( "Zoom in" ));
1194 a->setShortcut(Qt::Key_Plus);
1195 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1197 viewMenu->addAction (a);
1198 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
1200 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
1201 a->setStatusTip (tr( "Zoom out" ));
1202 a->setShortcut(Qt::Key_Minus);
1203 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1205 viewMenu->addAction (a);
1206 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1208 a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
1209 a->setStatusTip (tr( "Show selection" ));
1210 a->setShortcut(Qt::Key_Period);
1211 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1213 viewMenu->addAction (a);
1214 connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
1216 viewMenu->addSeparator();
1218 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
1219 a->setStatusTip ( tr( "Show Note Editor" ));
1220 a->setShortcut ( Qt::CTRL + Qt::Key_E ); // Toggle Note Editor
1221 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1222 a->setToggleAction(true);
1224 viewMenu->addAction (a);
1225 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1226 actionViewToggleNoteEditor=a;
1228 // Original icon is "category" from KDE
1229 a = new QAction(QPixmap(iconPath+"treeeditor.png"), tr( "Show tree editor","View action" ),this);
1230 a->setStatusTip ( tr( "Show tree editor" ));
1231 a->setShortcut ( Qt::CTRL + Qt::Key_T ); // Toggle Tree Editor // FIXME-3 originally: color subtree
1232 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1233 a->setToggleAction(true);
1235 viewMenu->addAction (a);
1236 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleTreeEditor() ) );
1237 actionViewToggleTreeEditor=a;
1239 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
1240 a->setStatusTip ( tr( "Show History Window" ));
1241 a->setShortcut ( Qt::CTRL + Qt::Key_H ); // Toggle history window
1242 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1243 a->setToggleAction(true);
1245 viewMenu->addAction (a);
1246 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1247 actionViewToggleHistoryWindow=a;
1249 viewMenu->addAction (actionViewTogglePropertyWindow);
1251 viewMenu->addSeparator();
1253 a = new QAction(tr( "Antialiasing","View action" ),this );
1254 a->setStatusTip ( tr( "Antialiasing" ));
1255 a->setToggleAction(true);
1256 a->setChecked (settings.value("/mainwindow/view/AntiAlias",true).toBool());
1257 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1258 viewMenu->addAction (a);
1259 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
1260 actionViewToggleAntiAlias=a;
1262 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1263 a->setStatusTip (a->text());
1264 a->setToggleAction(true);
1265 a->setChecked (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1266 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1267 viewMenu->addAction (a);
1268 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1269 actionViewToggleSmoothPixmapTransform=a;
1271 a = new QAction(tr( "Next Map","View action" ), this);
1272 a->setStatusTip (a->text());
1273 a->setShortcut (Qt::ALT + Qt::Key_N );
1274 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1275 viewMenu->addAction (a);
1276 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1278 a = new QAction (tr( "Previous Map","View action" ), this );
1279 a->setStatusTip (a->text());
1280 a->setShortcut (Qt::ALT + Qt::Key_P );
1281 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1282 viewMenu->addAction (a);
1283 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1287 void Main::setupModeActions()
1289 //QPopupMenu *menu = new QPopupMenu( this );
1290 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1292 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1293 tb->setObjectName ("modesTB");
1295 actionGroupModModes=new QActionGroup ( this);
1296 actionGroupModModes->setExclusive (true);
1297 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1298 a->setShortcut (Qt::Key_J);
1299 switchboard.addConnection(a,tr("Modes","Shortcut group"));
1300 a->setStatusTip ( tr( "Use modifier to color branches" ));
1301 a->setToggleAction(true);
1303 a->setChecked(true);
1304 actionModModeColor=a;
1306 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1307 a->setShortcut( Qt::Key_K);
1308 switchboard.addConnection(a,tr("Modes","Shortcut group"));
1309 a->setStatusTip( tr( "Use modifier to copy" ));
1310 a->setToggleAction(true);
1312 actionModModeCopy=a;
1314 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1315 a->setShortcut (Qt::Key_L);
1316 switchboard.addConnection(a,tr("Modes","Shortcut group"));
1317 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1318 a->setToggleAction(true);
1320 actionModModeXLink=a;
1324 void Main::setupFlagActions()
1326 // Create System Flags
1329 Flag *flag=new Flag(flagsPath+"flag-note.png");
1330 setupFlag (flag,tb,"system-note",tr("Note","SystemFlag"));
1332 flag=new Flag(flagsPath+"flag-url.png");
1333 setupFlag (flag,tb,"system-url",tr("URL to Document ","SystemFlag"));
1335 flag=new Flag(flagsPath+"flag-url-bugzilla-novell.png");
1336 setupFlag (flag,tb,"system-url-bugzilla-novell",tr("URL to Bugzilla ","SystemFlag"));
1338 flag=new Flag(flagsPath+"flag-vymlink.png");
1339 setupFlag (flag,tb,"system-vymLink",tr("Link to another vym map","SystemFlag"));
1341 flag=new Flag(flagsPath+"flag-scrolled-right.png");
1342 setupFlag (flag,tb,"system-scrolledright",tr("subtree is scrolled","SystemFlag"));
1344 flag=new Flag(flagsPath+"flag-tmpUnscrolled-right.png");
1345 setupFlag (flag,tb,"system-tmpUnscrolledRight",tr("subtree is temporary scrolled","SystemFlag"));
1347 flag=new Flag(flagsPath+"flag-hideexport.png");
1348 setupFlag (flag,tb,"system-hideInExport",tr("Hide object in exported maps","SystemFlag"));
1350 // Create Standard Flags
1351 tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1352 tb->setObjectName ("standardFlagTB");
1353 standardFlagsMaster->setToolBar (tb);
1355 flag=new Flag(flagsPath+"flag-exclamationmark.png");
1356 flag->setGroup("standard-mark");
1357 setupFlag (flag,tb,"exclamationmark",tr("Take care!","Standardflag"));
1359 flag=new Flag(flagsPath+"flag-questionmark.png");
1360 flag->setGroup("standard-mark");
1361 setupFlag (flag,tb,"questionmark",tr("Really?","Standardflag"));
1363 flag=new Flag(flagsPath+"flag-hook-green.png");
1364 flag->setGroup("standard-status");
1365 setupFlag (flag,tb,"hook-green",tr("Status - ok,done","Standardflag"));
1367 flag=new Flag(flagsPath+"flag-wip.png");
1368 flag->setGroup("standard-status");
1369 setupFlag (flag,tb,"wip",tr("Status - work in progress","Standardflag"));
1371 flag=new Flag(flagsPath+"flag-cross-red.png");
1372 flag->setGroup("standard-status");
1373 setupFlag (flag,tb,"cross-red",tr("Status - missing, not started","Standardflag"));
1376 flag=new Flag(flagsPath+"flag-stopsign.png");
1377 setupFlag (flag,tb,"stopsign",tr("This won't work!","Standardflag"));
1379 flag=new Flag(flagsPath+"flag-smiley-good.png");
1380 flag->setGroup("standard-smiley");
1381 setupFlag (flag,tb,"smiley-good",tr("Good","Standardflag"));
1383 flag=new Flag(flagsPath+"flag-smiley-sad.png");
1384 flag->setGroup("standard-smiley");
1385 setupFlag (flag,tb,"smiley-sad",tr("Bad","Standardflag"));
1387 flag=new Flag(flagsPath+"flag-smiley-omg.png");
1388 flag->setGroup("standard-smiley");
1389 setupFlag (flag,tb,"smiley-omb",tr("Oh no!","Standardflag"));
1390 // Original omg.png (in KDE emoticons)
1393 flag=new Flag(flagsPath+"flag-kalarm.png");
1394 setupFlag (flag,tb,"clock",tr("Time critical","Standardflag"));
1396 flag=new Flag(flagsPath+"flag-phone.png");
1397 setupFlag (flag,tb,"phone",tr("Call...","Standardflag"));
1399 flag=new Flag(flagsPath+"flag-lamp.png");
1400 setupFlag (flag,tb,"lamp",tr("Idea!","Standardflag"));
1402 flag=new Flag(flagsPath+"flag-arrow-up.png");
1403 flag->setGroup("standard-arrow");
1404 setupFlag (flag,tb,"arrow-up",tr("Important","Standardflag"));
1406 flag=new Flag(flagsPath+"flag-arrow-down.png");
1407 flag->setGroup("standard-arrow");
1408 setupFlag (flag,tb,"arrow-down",tr("Unimportant","Standardflag"));
1410 flag=new Flag(flagsPath+"flag-arrow-2up.png");
1411 flag->setGroup("standard-arrow");
1412 setupFlag (flag,tb,"2arrow-up",tr("Very important!","Standardflag"));
1414 flag=new Flag(flagsPath+"flag-arrow-2down.png");
1415 flag->setGroup("standard-arrow");
1416 setupFlag (flag,tb,"2arrow-down",tr("Very unimportant!","Standardflag"));
1419 flag=new Flag(flagsPath+"flag-thumb-up.png");
1420 flag->setGroup("standard-thumb");
1421 setupFlag (flag,tb,"thumb-up",tr("I like this","Standardflag"));
1423 flag=new Flag(flagsPath+"flag-thumb-down.png");
1424 flag->setGroup("standard-thumb");
1425 setupFlag (flag,tb,"thumb-down",tr("I do not like this","Standardflag"));
1428 flag=new Flag(flagsPath+"flag-rose.png");
1429 setupFlag (flag,tb,"rose",tr("Rose","Standardflag"));
1431 flag=new Flag(flagsPath+"flag-heart.png");
1432 setupFlag (flag,tb,"heart",tr("I just love...","Standardflag"));
1434 flag=new Flag(flagsPath+"flag-present.png");
1435 setupFlag (flag,tb,"present",tr("Surprise!","Standardflag"));
1437 flag=new Flag(flagsPath+"flag-flash.png");
1438 setupFlag (flag,tb,"flash",tr("Dangerous","Standardflag"));
1440 // Original: xsldbg_output.png
1441 flag=new Flag(flagsPath+"flag-info.png");
1442 setupFlag (flag,tb,"info",tr("Info","Standardflag"));
1444 // Original khelpcenter.png
1445 flag=new Flag(flagsPath+"flag-lifebelt.png");
1446 setupFlag (flag,tb,"lifebelt",tr("This will help","Standardflag"));
1449 flag=new Flag(flagsPath+"freemind/warning.png");
1450 flag->setVisible(false);
1451 setupFlag (flag,tb, "freemind-warning",tr("Important","Freemind-Flag"));
1453 for (int i=1; i<8; i++)
1455 flag=new Flag(flagsPath+QString("freemind/priority-%1.png").arg(i));
1456 flag->setVisible(false);
1457 flag->setGroup ("Freemind-priority");
1458 setupFlag (flag,tb, QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
1461 flag=new Flag(flagsPath+"freemind/back.png");
1462 flag->setVisible(false);
1463 setupFlag (flag,tb,"freemind-back",tr("Back","Freemind-Flag"));
1465 flag=new Flag(flagsPath+"freemind/forward.png");
1466 flag->setVisible(false);
1467 setupFlag (flag,tb,"freemind-forward",tr("forward","Freemind-Flag"));
1469 flag=new Flag(flagsPath+"freemind/attach.png");
1470 flag->setVisible(false);
1471 setupFlag (flag,tb,"freemind-attach",tr("Look here","Freemind-Flag"));
1473 flag=new Flag(flagsPath+"freemind/clanbomber.png");
1474 flag->setVisible(false);
1475 setupFlag (flag,tb,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
1477 flag=new Flag(flagsPath+"freemind/desktopnew.png");
1478 flag->setVisible(false);
1479 setupFlag (flag,tb,"freemind-desktopnew",tr("Don't flagrget","Freemind-Flag"));
1481 flag=new Flag(flagsPath+"freemind/flag.png");
1482 flag->setVisible(false);
1483 setupFlag (flag,tb,"freemind-flag",tr("Flag","Freemind-Flag"));
1486 flag=new Flag(flagsPath+"freemind/gohome.png");
1487 flag->setVisible(false);
1488 setupFlag (flag,tb,"freemind-gohome",tr("Home","Freemind-Flag"));
1490 flag=new Flag(flagsPath+"freemind/kaddressbook.png");
1491 flag->setVisible(false);
1492 setupFlag (flag,tb,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
1494 flag=new Flag(flagsPath+"freemind/knotify.png");
1495 flag->setVisible(false);
1496 setupFlag (flag,tb,"freemind-knotify",tr("Music","Freemind-Flag"));
1498 flag=new Flag(flagsPath+"freemind/korn.png");
1499 flag->setVisible(false);
1500 setupFlag (flag,tb,"freemind-korn",tr("Mailbox","Freemind-Flag"));
1502 flag=new Flag(flagsPath+"freemind/mail.png");
1503 flag->setVisible(false);
1504 setupFlag (flag,tb,"freemind-mail",tr("Maix","Freemind-Flag"));
1506 flag=new Flag(flagsPath+"freemind/password.png");
1507 flag->setVisible(false);
1508 setupFlag (flag,tb,"freemind-password",tr("Password","Freemind-Flag"));
1510 flag=new Flag(flagsPath+"freemind/pencil.png");
1511 flag->setVisible(false);
1512 setupFlag (flag,tb,"freemind-pencil",tr("To be improved","Freemind-Flag"));
1514 flag=new Flag(flagsPath+"freemind/stop.png");
1515 flag->setVisible(false);
1516 setupFlag (flag,tb,"freemind-stop",tr("Stop","Freemind-Flag"));
1518 flag=new Flag(flagsPath+"freemind/wizard.png");
1519 flag->setVisible(false);
1520 setupFlag (flag,tb,"freemind-wizard",tr("Magic","Freemind-Flag"));
1522 flag=new Flag(flagsPath+"freemind/xmag.png");
1523 flag->setVisible(false);
1524 setupFlag (flag,tb,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
1526 flag=new Flag(flagsPath+"freemind/bell.png");
1527 flag->setVisible(false);
1528 setupFlag (flag,tb,"freemind-bell",tr("Reminder","Freemind-Flag"));
1530 flag=new Flag(flagsPath+"freemind/bookmark.png");
1531 flag->setVisible(false);
1532 setupFlag (flag,tb,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
1534 flag= new Flag(flagsPath+"freemind/penguin.png");
1535 flag->setVisible(false);
1536 setupFlag (flag,tb,"freemind-penguin",tr("Linux","Freemind-Flag"));
1538 flag=new Flag (flagsPath+"freemind/licq.png");
1539 flag->setVisible(false);
1540 setupFlag (flag,tb,"freemind-licq",tr("Sweet","Freemind-Flag"));
1543 void Main::setupFlag (Flag *flag, QToolBar *tb, const QString &name, const QString &tooltip)
1545 flag->setName(name);
1546 flag->setToolTip (tooltip);
1550 a=new QAction (flag->getPixmap(),name,this);
1553 flag->setAction (a);
1554 a->setVisible (flag->isVisible());
1555 a->setCheckable(true);
1556 a->setObjectName(name);
1557 a->setToolTip(tooltip);
1558 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1559 standardFlagsMaster->addFlag (flag);
1563 systemFlagsMaster->addFlag (flag);
1568 void Main::setupNetworkActions()
1570 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1572 QMenu *netMenu = menuBar()->addMenu( "Network" );
1576 a = new QAction( "Start TCPserver for MapEditor",this);
1577 //a->setStatusTip ( "Set application to open pdf files"));
1578 //a->setShortcut ( Qt::ALT + Qt::Key_T ); //New TCP server
1579 switchboard.addConnection(a,tr("Network shortcuts","Shortcut group"));
1580 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1581 netMenu->addAction (a);
1583 a = new QAction( "Connect MapEditor to server",this);
1584 //a->setStatusTip ( "Set application to open pdf files"));
1585 a->setShortcut ( Qt::ALT + Qt::Key_C ); // Connect to server
1586 switchboard.addConnection(a,tr("Network shortcuts","Shortcut group"));
1587 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1588 netMenu->addAction (a);
1592 void Main::setupSettingsActions()
1594 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1598 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1599 a->setStatusTip ( tr( "Set application to open pdf files"));
1600 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1601 settingsMenu->addAction (a);
1603 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1604 a->setStatusTip( tr( "Set application to open external links"));
1605 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1606 settingsMenu->addAction (a);
1608 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1609 a->setStatusTip( tr( "Set path for macros"));
1610 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1611 settingsMenu->addAction (a);
1613 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1614 a->setStatusTip( tr( "Set number of undo levels"));
1615 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1616 settingsMenu->addAction (a);
1618 settingsMenu->addSeparator();
1620 a = new QAction( tr( "Autosave","Settings action"), this);
1621 a->setStatusTip( tr( "Autosave"));
1622 a->setToggleAction(true);
1623 a->setChecked ( settings.value ("/mainwindow/autosave/use",false).toBool());
1624 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1625 settingsMenu->addAction (a);
1626 actionSettingsAutosaveToggle=a;
1628 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1629 a->setStatusTip( tr( "Autosave time"));
1630 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1631 settingsMenu->addAction (a);
1632 actionSettingsAutosaveTime=a;
1634 a = new QAction( tr( "Write backup file on save","Settings action"), this);
1635 a->setStatusTip( tr( "Write backup file on save"));
1636 a->setToggleAction(true);
1637 a->setChecked ( settings.value ("/mainwindow/writeBackupFile",false).toBool());
1638 connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) );
1639 settingsMenu->addAction (a);
1640 actionSettingsWriteBackupFile=a;
1642 settingsMenu->addSeparator();
1644 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1645 a->setStatusTip( tr( "Edit branch after adding it" ));
1646 a->setToggleAction(true);
1647 a->setChecked ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1648 settingsMenu->addAction (a);
1649 actionSettingsAutoEditNewBranch=a;
1651 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1652 a->setStatusTip( tr( "Select branch after adding it" ));
1653 a->setToggleAction(true);
1654 a->setChecked ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1655 settingsMenu->addAction (a);
1656 actionSettingsAutoSelectNewBranch=a;
1658 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1659 a->setStatusTip( tr( "Select heading before editing" ));
1660 a->setToggleAction(true);
1661 a->setChecked ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1662 settingsMenu->addAction (a);
1663 actionSettingsAutoSelectText=a;
1665 a= new QAction( tr( "Delete key","Settings action" ), this);
1666 a->setStatusTip( tr( "Delete key for deleting branches" ));
1667 a->setToggleAction(true);
1668 a->setChecked ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1669 settingsMenu->addAction (a);
1670 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1671 actionSettingsUseDelKey=a;
1673 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1674 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1675 a->setToggleAction(true);
1676 a->setChecked ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1677 settingsMenu->addAction (a);
1678 actionSettingsUseFlagGroups=a;
1680 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1681 a->setStatusTip( tr( "Use hide flag during exports " ));
1682 a->setToggleAction(true);
1683 a->setChecked ( settings.value ("/export/useHideExport",true).toBool() );
1684 settingsMenu->addAction (a);
1685 actionSettingsUseHideExport=a;
1687 settingsMenu->addSeparator();
1689 a = new QAction( tr( "Animation","Settings action"), this);
1690 a->setStatusTip( tr( "Animation"));
1691 a->setToggleAction(true);
1692 a->setChecked (settings.value("/animation/use",true).toBool() );
1693 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) );
1694 settingsMenu->addAction (a);
1695 actionSettingsUseAnimation=a;
1697 a = new QAction( tr( "Automatic layout","Settings action"), this);
1698 a->setStatusTip( tr( "Automatic layout"));
1699 a->setToggleAction(true);
1700 a->setChecked ( settings.value ("/mainwindow/autoLayout/use",true).toBool());
1701 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutoLayoutToggle() ) );
1702 settingsMenu->addAction (a);
1703 actionSettingsAutoLayoutToggle=a;
1708 void Main::setupTestActions()
1710 QMenu *testMenu = menuBar()->addMenu( tr( "Test" ));
1713 a = new QAction( "Test function 1" , this);
1714 a->setStatusTip( "Call test function 1" );
1715 a->setShortcut (Qt::SHIFT + Qt::Key_T); // Test function 1
1716 switchboard.addConnection(a,tr("Test shortcuts","Shortcut group"));
1717 testMenu->addAction (a);
1718 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1720 a = new QAction( "Test function 2" , this);
1721 a->setStatusTip( "Call test function 2" );
1722 a->setShortcut (Qt::ALT + Qt::Key_T); // Test function 2
1723 switchboard.addConnection(a,tr("Test shortcuts","Shortcut group"));
1724 testMenu->addAction (a);
1725 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1727 a = new QAction( "Command" , this);
1728 a->setStatusTip( "Enter command to call in editor" );
1729 switchboard.addConnection(a,tr("Test shortcuts","Shortcut group"));
1730 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1731 testMenu->addAction (a);
1735 void Main::setupHelpActions()
1737 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1740 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1741 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1742 switchboard.addConnection(a,tr("Help shortcuts","Shortcut group"));
1743 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1744 helpMenu->addAction (a);
1746 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1747 a->setStatusTip( tr( "Open VYM example maps " ));
1748 switchboard.addConnection(a,tr("Help shortcuts","Shortcut group"));
1749 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1750 helpMenu->addAction (a);
1752 a = new QAction( tr( "About VYM","Help action" ), this);
1753 a->setStatusTip( tr( "About VYM")+vymName);
1754 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1755 helpMenu->addAction (a);
1757 a = new QAction( tr( "About QT","Help action" ), this);
1758 a->setStatusTip( tr( "Information about QT toolkit" ));
1759 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1760 helpMenu->addAction (a);
1764 void Main::setupContextMenus()
1766 // Context Menu for branch or mapcenter
1767 branchContextMenu =new QMenu (this);
1768 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1769 branchContextMenu->addSeparator();
1772 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1773 branchAddContextMenu->addAction (actionPaste );
1774 branchAddContextMenu->addAction ( actionAddMapCenter );
1775 branchAddContextMenu->addAction ( actionAddBranch );
1776 branchAddContextMenu->addAction ( actionAddBranchBefore );
1777 branchAddContextMenu->addAction ( actionAddBranchAbove);
1778 branchAddContextMenu->addAction ( actionAddBranchBelow );
1779 branchAddContextMenu->addSeparator();
1780 branchAddContextMenu->addAction ( actionImportAdd );
1781 branchAddContextMenu->addAction ( actionImportReplace );
1784 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1785 branchRemoveContextMenu->addAction (actionCut);
1786 branchRemoveContextMenu->addAction ( actionDelete );
1787 branchRemoveContextMenu->addAction ( actionDeleteKeepChildren );
1788 branchRemoveContextMenu->addAction ( actionDeleteChildren );
1791 actionSaveBranch->addTo( branchContextMenu );
1792 actionFileNewCopy->addTo (branchContextMenu );
1793 actionDetach->addTo (branchContextMenu );
1795 branchContextMenu->addSeparator();
1796 branchContextMenu->addAction ( actionLoadImage);
1797 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1798 branchContextMenu->addAction ( actionAddAttribute);
1800 // Submenu for Links (URLs, vymLinks)
1801 branchLinksContextMenu =new QMenu (this);
1803 branchContextMenu->addSeparator();
1804 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1805 branchLinksContextMenu->addAction ( actionOpenURL );
1806 branchLinksContextMenu->addAction ( actionOpenURLTab );
1807 branchLinksContextMenu->addAction ( actionOpenMultipleVisURLTabs );
1808 branchLinksContextMenu->addAction ( actionOpenMultipleURLTabs );
1809 branchLinksContextMenu->addAction ( actionURL );
1810 branchLinksContextMenu->addAction ( actionLocalURL );
1811 branchLinksContextMenu->addAction ( actionHeading2URL );
1812 branchLinksContextMenu->addAction ( actionBugzilla2URL );
1813 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1815 branchLinksContextMenu->addAction ( actionGetBugzillaData );
1816 branchLinksContextMenu->addAction ( actionFATE2URL );
1818 branchLinksContextMenu->addSeparator();
1819 branchLinksContextMenu->addAction ( actionOpenVymLink );
1820 branchLinksContextMenu->addAction ( actionOpenMultipleVymLinks );
1821 branchLinksContextMenu->addAction ( actionVymLink );
1822 branchLinksContextMenu->addAction ( actionDeleteVymLink );
1825 // Context Menu for XLinks in a branch menu
1826 // This will be populated "on demand" in MapEditor::updateActions
1827 branchContextMenu->addSeparator();
1828 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1829 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1832 // Context menu for floatimage
1833 floatimageContextMenu =new QMenu (this);
1834 QAction *a= new QAction (tr ("Save image","Context action"),this);
1835 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1836 floatimageContextMenu->addAction (a);
1838 floatimageContextMenu->addSeparator();
1839 actionCopy->addTo( floatimageContextMenu );
1840 actionCut->addTo( floatimageContextMenu );
1842 floatimageContextMenu->addSeparator();
1843 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1846 // Context menu for canvas
1847 canvasContextMenu =new QMenu (this);
1848 actionAddMapCenter->addTo( canvasContextMenu );
1849 actionMapInfo->addTo( canvasContextMenu );
1850 canvasContextMenu->insertSeparator();
1851 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1852 canvasContextMenu->insertSeparator();
1853 actionFormatLinkColorHint->addTo( canvasContextMenu );
1854 actionFormatLinkColor->addTo( canvasContextMenu );
1855 actionFormatSelectionColor->addTo( canvasContextMenu );
1856 actionFormatBackColor->addTo( canvasContextMenu );
1857 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME-4 makes vym too slow: postponed for later version
1859 // Menu for last opened files
1861 for (int i = 0; i < MaxRecentFiles; ++i)
1863 recentFileActions[i] = new QAction(this);
1864 recentFileActions[i]->setVisible(false);
1865 fileLastMapsMenu->addAction(recentFileActions[i]);
1866 connect(recentFileActions[i], SIGNAL(triggered()),
1867 this, SLOT(fileLoadRecent()));
1869 setupRecentMapsMenu();
1872 void Main::setupRecentMapsMenu()
1874 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1876 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1878 for (int i = 0; i < numRecentFiles; ++i) {
1879 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1880 recentFileActions[i]->setText(text);
1881 recentFileActions[i]->setData(files[i]);
1882 recentFileActions[i]->setVisible(true);
1884 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1885 recentFileActions[j]->setVisible(false);
1888 void Main::setupMacros()
1890 for (int i = 0; i <= 11; i++)
1892 macroActions[i] = new QAction(this);
1893 macroActions[i]->setData(i);
1894 addAction (macroActions[i]);
1895 //switchboard.addConnection(macroActions[i],tr("Macro shortcuts","Shortcut group"));
1896 connect(macroActions[i], SIGNAL(triggered()),
1897 this, SLOT(callMacro()));
1899 macroActions[0]->setShortcut ( Qt::Key_F1 );
1900 macroActions[1]->setShortcut ( Qt::Key_F2 );
1901 macroActions[2]->setShortcut ( Qt::Key_F3 );
1902 macroActions[3]->setShortcut ( Qt::Key_F4 );
1903 macroActions[4]->setShortcut ( Qt::Key_F5 );
1904 macroActions[5]->setShortcut ( Qt::Key_F6 );
1905 macroActions[6]->setShortcut ( Qt::Key_F7 );
1906 macroActions[7]->setShortcut ( Qt::Key_F8 );
1907 macroActions[8]->setShortcut ( Qt::Key_F9 );
1908 macroActions[9]->setShortcut ( Qt::Key_F10 );
1909 macroActions[10]->setShortcut ( Qt::Key_F11 );
1910 macroActions[11]->setShortcut ( Qt::Key_F12 );
1913 void Main::hideEvent (QHideEvent * )
1915 if (!textEditor->isMinimized() ) textEditor->hide();
1918 void Main::showEvent (QShowEvent * )
1920 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1924 MapEditor* Main::currentMapEditor() const
1926 if ( tabWidget->currentPage())
1927 return vymViews.at(tabWidget->currentIndex())->getMapEditor();
1931 uint Main::currentModelID() const
1934 return currentModel()->getID();
1938 VymModel* Main::currentModel() const
1940 if ( tabWidget->currentPage())
1941 return vymViews.at(tabWidget->currentIndex())->getModel();
1945 VymModel* Main::getModel(uint id) const
1948 for (int i=0; i<vymViews.count();i++)
1949 if (vymViews.at(i)->getModel()->getID()==id)
1950 return vymViews.at(i)->getModel();
1955 void Main::editorChanged(QWidget *)
1957 // Unselect all possibly selected objects
1958 // (Important to update note editor)
1960 for (int i=0;i<=tabWidget->count() -1;i++)
1962 m= vymViews.at(i)->getModel();
1963 if (m) m->unselect();
1966 if (m) m->reselect();
1968 // Update actions to in menus and toolbars according to editor
1972 void Main::fileNew()
1974 VymModel *vm=new VymModel;
1976 /////////////////////////////////////
1977 // new ModelTest(vm, this); //FIXME-3
1978 /////////////////////////////////////
1980 VymView *vv=new VymView (vm);
1981 vymViews.append (vv);
1982 tabWidget->addTab (vv,tr("unnamed","MainWindow: name for new and empty file"));
1983 tabWidget->setCurrentIndex (vymViews.count() );
1986 // Create MapCenter for empty map
1987 vm->addMapCenter(false);
1990 // For the very first map we do not have flagrows yet...
1994 void Main::fileNewCopy()
1996 QString fn="unnamed";
1997 VymModel *srcModel=currentModel();
2002 VymModel *dstModel=vymViews.last()->getModel();
2003 dstModel->select("mc:");
2004 dstModel->loadMap (clipboardDir+"/"+clipboardFile,ImportReplace);
2008 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
2010 ErrorCode err=success;
2012 // fn is usually the archive, mapfile the file after uncompressing
2015 // Make fn absolute (needed for unzip)
2016 fn=QDir (fn).absPath();
2022 // Check, if map is already loaded
2024 while (i<=tabWidget->count() -1)
2026 if (vymViews.at(i)->getModel()->getFilePath() == fn)
2028 // Already there, ask for confirmation
2029 QMessageBox mb( vymName,
2030 tr("The map %1\nis already opened."
2031 "Opening the same map in multiple editors may lead \n"
2032 "to confusion when finishing working with vym."
2033 "Do you want to").arg(fn),
2034 QMessageBox::Warning,
2035 QMessageBox::Yes | QMessageBox::Default,
2036 QMessageBox::Cancel | QMessageBox::Escape,
2037 QMessageBox::NoButton);
2038 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
2039 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2042 case QMessageBox::Yes:
2043 // end loop and load anyway
2044 i=tabWidget->count();
2046 case QMessageBox::Cancel:
2056 int tabIndex=tabWidget->currentPageIndex();
2059 if ( !fn.isEmpty() )
2061 vm = currentModel();
2062 // Check first, if mapeditor exists
2063 // If it is not default AND we want a new map,
2064 // create a new mapeditor in a new tab
2065 if ( lmode==NewMap && (!vm || !vm->isDefault() ) )
2068 VymView *vv=new VymView (vm);
2069 vymViews.append (vv);
2070 tabWidget->addTab (vv,fn);
2071 tabIndex=tabWidget->count()-1;
2072 tabWidget->setCurrentPage (tabIndex);
2076 // Check, if file exists (important for creating new files
2077 // from command line
2078 if (!QFile(fn).exists() )
2080 QMessageBox mb( vymName,
2081 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
2082 QMessageBox::Question,
2084 QMessageBox::Cancel | QMessageBox::Default,
2085 QMessageBox::NoButton );
2087 mb.setButtonText( QMessageBox::Yes, tr("Create"));
2088 mb.setButtonText( QMessageBox::No, tr("Cancel"));
2091 case QMessageBox::Yes:
2093 currentMapEditor()->getModel()->setFilePath(fn);
2094 tabWidget->setTabText (tabIndex,
2095 currentMapEditor()->getModel()->getFileName() );
2096 statusBar()->message( "Created " + fn , statusbarTime );
2099 case QMessageBox::Cancel:
2100 // don't create new map
2101 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
2108 //tabWidget->currentPage() won't be NULL here, because of above...
2109 tabWidget->setCurrentIndex (tabIndex);
2110 //FIXME-3 no me anymore... me->viewport()->setFocus();
2114 // Save existing filename in case we import
2115 QString fn_org=vm->getFilePath();
2117 // Finally load map into mapEditor
2118 vm->setFilePath (fn);
2119 err=vm->loadMap(fn,lmode,true,ftype);
2121 // Restore old (maybe empty) filepath, if this is an import
2123 vm->setFilePath (fn_org);
2126 // Finally check for errors and go home
2129 if (lmode==NewMap) fileCloseMap();
2130 statusBar()->message( "Could not load " + fn, statusbarTime );
2135 vm->setFilePath (fn);
2136 tabWidget->setTabText (tabIndex, vm->getFileName());
2137 if (!isInTmpDir (fn))
2139 // Only append to lastMaps if not loaded from a tmpDir
2140 // e.g. imported bookmarks are in a tmpDir
2141 addRecentMap(vm->getFilePath() );
2143 actionFilePrint->setEnabled (true);
2145 statusBar()->message( "Loaded " + fn, statusbarTime );
2152 void Main::fileLoad(const LoadMode &lmode)
2154 QStringList filters;
2155 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
2156 QFileDialog *fd=new QFileDialog( this);
2157 fd->setDir (lastFileDir);
2158 fd->setFileMode (QFileDialog::ExistingFiles);
2159 fd->setFilters (filters);
2163 fd->setCaption(vymName+ " - " +tr("Load vym map"));
2166 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
2169 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
2175 if ( fd->exec() == QDialog::Accepted )
2177 lastFileDir=fd->directory().path();
2178 QStringList flist = fd->selectedFiles();
2179 QStringList::Iterator it = flist.begin();
2181 progressCounter=flist.count();
2182 progressCounterTotal=flist.count();
2183 while( it != flist.end() )
2186 fileLoad(*it, lmode);
2193 void Main::fileLoad()
2198 void Main::fileLoadRecent()
2200 QAction *action = qobject_cast<QAction *>(sender());
2202 fileLoad (action->data().toString(), NewMap);
2205 void Main::addRecentMap (const QString &fileName)
2208 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
2209 files.removeAll(fileName);
2210 files.prepend(fileName);
2211 while (files.size() > MaxRecentFiles)
2214 settings.setValue("/mainwindow/recentFileList", files);
2216 setupRecentMapsMenu();
2219 void Main::fileSave(VymModel *m, const SaveMode &savemode)
2223 if ( m->getFilePath().isEmpty() )
2225 // We have no filepath yet,
2226 // call fileSaveAs() now, this will call fileSave()
2228 // First switch to editor
2229 //FIXME-3 needed??? tabWidget->setCurrentWidget (m->getMapEditor());
2230 fileSaveAs(savemode);
2233 if (m->save (savemode)==success)
2235 statusBar()->message(
2236 tr("Saved %1").arg(m->getFilePath()),
2238 addRecentMap (m->getFilePath() );
2240 statusBar()->message(
2241 tr("Couldn't save ").arg(m->getFilePath()),
2245 void Main::fileSave()
2247 fileSave (currentModel(), CompleteMap);
2250 void Main::fileSave(VymModel *m)
2252 fileSave (m,CompleteMap);
2255 void Main::fileSaveAs(const SaveMode& savemode)
2259 if (currentMapEditor())
2261 if (savemode==CompleteMap)
2262 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2264 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2265 if ( !fn.isEmpty() )
2267 // Check for existing file
2268 if (QFile (fn).exists())
2270 QMessageBox mb( vymName,
2271 tr("The file %1\nexists already. Do you want to").arg(fn),
2272 QMessageBox::Warning,
2273 QMessageBox::Yes | QMessageBox::Default,
2274 QMessageBox::Cancel | QMessageBox::Escape,
2275 QMessageBox::NoButton);
2276 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2277 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2280 case QMessageBox::Yes:
2283 case QMessageBox::Cancel:
2290 // New file, add extension to filename, if missing
2291 // This is always .vym or .vyp, depending on savemode
2292 if (savemode==CompleteMap)
2294 if (!fn.contains (".vym") && !fn.contains (".xml"))
2298 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2307 VymModel *m=currentModel();
2309 fileSave(m, savemode);
2311 // Set name of tab, assuming current tab is the one we just saved
2312 if (savemode==CompleteMap)
2313 tabWidget->setTabText (tabWidget->currentIndex(), m->getFileName() );
2319 void Main::fileSaveAs()
2321 fileSaveAs (CompleteMap);
2324 void Main::fileImportKDE3Bookmarks()
2326 ImportKDE3Bookmarks im;
2328 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2329 currentMapEditor()->getModel()->setFilePath ("");
2332 void Main::fileImportKDE4Bookmarks()
2334 ImportKDE4Bookmarks im;
2336 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2337 currentMapEditor()->getModel()->setFilePath ("");
2340 void Main::fileImportFirefoxBookmarks()
2342 Q3FileDialog *fd=new Q3FileDialog( this);
2343 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2344 fd->setMode (Q3FileDialog::ExistingFiles);
2345 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2346 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2349 if ( fd->exec() == QDialog::Accepted )
2351 ImportFirefoxBookmarks im;
2352 QStringList flist = fd->selectedFiles();
2353 QStringList::Iterator it = flist.begin();
2354 while( it != flist.end() )
2357 if (im.transform() &&
2358 aborted!=fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2359 currentMapEditor() )
2360 currentMapEditor()->getModel()->setFilePath ("");
2367 void Main::fileImportFreemind()
2369 QStringList filters;
2370 filters <<"Freemind map (*.mm)"<<"All files (*)";
2371 QFileDialog *fd=new QFileDialog( this);
2372 fd->setDir (lastFileDir);
2373 fd->setFileMode (QFileDialog::ExistingFiles);
2374 fd->setFilters (filters);
2375 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2379 if ( fd->exec() == QDialog::Accepted )
2381 lastFileDir=fd->directory().path();
2382 QStringList flist = fd->selectedFiles();
2383 QStringList::Iterator it = flist.begin();
2384 while( it != flist.end() )
2387 if ( fileLoad (fn,NewMap, FreemindMap) )
2389 currentMapEditor()->getModel()->setFilePath ("");
2398 void Main::fileImportMM()
2402 Q3FileDialog *fd=new Q3FileDialog( this);
2403 fd->setDir (lastFileDir);
2404 fd->setMode (Q3FileDialog::ExistingFiles);
2405 fd->addFilter ("Mind Manager (*.mmap)");
2406 fd->setCaption(tr("Import")+" "+"Mind Manager");
2409 if ( fd->exec() == QDialog::Accepted )
2411 lastFileDir=fd->dirPath();
2412 QStringList flist = fd->selectedFiles();
2413 QStringList::Iterator it = flist.begin();
2414 while( it != flist.end() )
2417 if (im.transform() &&
2418 success==fileLoad (im.getTransformedFile(),NewMap) &&
2419 currentMapEditor() )
2420 currentMapEditor()->getModel()->setFilePath ("");
2427 void Main::fileImportDir()
2429 VymModel *m=currentModel();
2430 if (m) m->importDir();
2433 void Main::fileExportXML()
2435 VymModel *m=currentModel();
2436 if (m) m->exportXML();
2439 void Main::fileExportHTML()
2441 VymModel *m=currentModel();
2442 if (m) m->exportHTML();
2445 void Main::fileExportImage()
2447 VymModel *m=currentModel();
2448 if (m) m->exportImage();
2451 void Main::fileExportAO()
2453 VymModel *m=currentModel();
2454 if (m) m->exportAO();
2457 void Main::fileExportASCII()
2459 VymModel *m=currentModel();
2460 if (m) m->exportASCII();
2463 void Main::fileExportCSV() //FIXME-3 not scriptable yet
2465 VymModel *m=currentModel();
2470 ex.addFilter ("CSV (*.csv)");
2471 ex.setDir(lastImageDir);
2472 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2473 if (ex.execDialog() )
2475 m->setExportMode(true);
2477 m->setExportMode(false);
2482 void Main::fileExportLaTeX() //FIXME-3 not scriptable yet
2484 VymModel *m=currentModel();
2489 ex.addFilter ("Tex (*.tex)");
2490 ex.setDir(lastImageDir);
2491 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2492 if (ex.execDialog() )
2494 m->setExportMode(true);
2496 m->setExportMode(false);
2501 void Main::fileExportKDE3Bookmarks() //FIXME-3 not scriptable yet
2503 ExportKDE3Bookmarks ex;
2504 VymModel *m=currentModel();
2512 void Main::fileExportKDE4Bookmarks() //FIXME-3 not scriptable yet
2514 ExportKDE4Bookmarks ex;
2515 VymModel *m=currentModel();
2523 void Main::fileExportTaskjuggler() //FIXME-3 not scriptable yet
2525 ExportTaskjuggler ex;
2526 VymModel *m=currentModel();
2530 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2531 ex.setDir(lastImageDir);
2532 ex.addFilter ("Taskjuggler (*.tjp)");
2533 if (ex.execDialog() )
2535 m->setExportMode(true);
2537 m->setExportMode(false);
2542 void Main::fileExportOOPresentation() //FIXME-3 not scriptable yet
2544 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2545 // TODO add preview in dialog
2546 //ImagePreview *p =new ImagePreview (fd);
2547 //fd->setContentsPreviewEnabled( TRUE );
2548 //fd->setContentsPreview( p, p );
2549 //fd->setPreviewMode( QFileDialog::Contents );
2550 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2551 fd->setDir (QDir().current());
2552 if (fd->foundConfig())
2556 if ( fd->exec() == QDialog::Accepted )
2558 QString fn=fd->selectedFile();
2559 if (!fn.contains (".odp"))
2562 //lastImageDir=fn.left(fn.findRev ("/"));
2563 VymModel *m=currentModel();
2564 if (m) m->exportOOPresentation(fn,fd->selectedConfig());
2568 QMessageBox::warning(0,
2570 tr("Couldn't find configuration for export to Open Office\n"));
2574 bool Main::fileCloseMap()
2576 VymModel *m=currentModel();
2579 //qDebug()<<"Main::fileCloseMap currentIndex="<<tabWidget->currentIndex();
2580 if (m->hasChanged())
2582 QMessageBox mb( vymName,
2583 tr("The map %1 has been modified but not saved yet. Do you want to").arg(m->getFileName()),
2584 QMessageBox::Warning,
2585 QMessageBox::Yes | QMessageBox::Default,
2587 QMessageBox::Cancel | QMessageBox::Escape );
2588 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2589 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2592 mb.setActiveWindow();
2595 case QMessageBox::Yes:
2597 fileSave(m, CompleteMap);
2599 case QMessageBox::No:
2600 // close without saving
2602 case QMessageBox::Cancel:
2607 // And here comes the segfault, because removeTab triggers
2608 // FIXME-3 currentChanged->Main::editorChanged -> updateActions and VM is not NULL yet...
2609 vymViews.removeAt (tabWidget->currentIndex() );
2610 tabWidget->removeTab (tabWidget->currentIndex() );
2612 delete (m); // changing model still will try to update selection in editors, remove model first
2613 //delete (m->getMapEditor());
2618 return true; // Better don't exit vym if there is no currentModel()...
2621 void Main::filePrint()
2623 if (currentMapEditor())
2624 currentMapEditor()->print();
2627 void Main::fileExitVYM()
2629 // Check if one or more editors have changed
2631 while (vymViews.count()>0)
2633 //qDebug()<<"Main::fileExitVym count="<<vymViews.count();
2634 tabWidget->setCurrentPage(i);
2635 if (fileCloseMap()) return;
2640 void Main::editUndo()
2642 VymModel *m=currentModel();
2646 void Main::editRedo()
2648 VymModel *m=currentModel();
2652 void Main::gotoHistoryStep (int i)
2654 VymModel *m=currentModel();
2655 if (m) m->gotoHistoryStep(i);
2658 void Main::editCopy()
2660 VymModel *m=currentModel();
2664 void Main::editPaste()
2666 VymModel *m=currentModel();
2670 void Main::editCut()
2672 VymModel *m=currentModel();
2676 void Main::editOpenFindWidget()
2678 if (!findWidget->isVisible())
2681 findWidget->setFocus();
2682 } else if (!findResultWidget->parentWidget()->isVisible())
2683 findResultWidget->parentWidget()->show();
2687 findResultWidget->parentWidget()->hide();
2691 void Main::editHideFindWidget()
2693 // findWidget hides itself, but we want
2694 // to have focus back at mapEditor usually
2695 MapEditor *me=currentMapEditor();
2696 if (me) me->setFocus();
2699 void Main::editFindNext(QString s)
2701 Qt::CaseSensitivity cs=Qt::CaseInsensitive;
2702 VymModel *m=currentModel();
2705 m->findAll (findResultWidget->getResultModel(),s,cs);
2707 BranchItem *bi=m->findText(s, cs);
2710 findWidget->setStatus (FindWidget::Success);
2713 findWidget->setStatus (FindWidget::Failed);
2717 void Main::editFindDuplicateURLs() //FIXME-4 feature: use FindResultWidget for display
2719 VymModel *m=currentModel();
2720 if (m) m->findDuplicateURLs();
2723 void Main::openTabs(QStringList urls)
2725 if (!urls.isEmpty())
2729 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2730 //qDebug ()<<"Services: "<<QDBusConnection::sessionBus().interface()->registeredServiceNames().value();
2731 if (*browserPID==0 ||
2732 (browser.contains("konqueror") &&
2733 !QDBusConnection::sessionBus().interface()->registeredServiceNames().value().contains (QString("org.kde.konqueror-%1").arg(*browserPID)))
2736 // Start a new browser, if there is not one running already or
2737 // if a previously started konqueror is gone.
2738 if (debug) cout <<"Main::openTabs no konqueror-"<<*browserPID<<" found\n";
2739 QString u=urls.takeFirst();
2741 QString workDir=QDir::currentDirPath();
2742 if (!QProcess::startDetached(browser,args,workDir,browserPID))
2744 // try to set path to browser
2745 QMessageBox::warning(0,
2747 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2748 tr("Please use Settings->")+tr("Set application to open an URL"));
2751 if (debug) cout << "Main::openTabs Started konqueror-"<<*browserPID<<endl;
2752 #if defined(Q_OS_WIN32)
2753 // There's no sleep in VCEE, replace it with Qt's QThread::wait().
2754 this->thread()->wait(3000);
2756 sleep (3); //FIXME-3 needed?
2760 if (browser.contains("konqueror"))
2762 for (int i=0; i<urls.size(); i++)
2765 // Try to open new tab in existing konqueror started previously by vym
2768 args<< QString("org.kde.konqueror-%1").arg(*browserPID)<<
2769 "/konqueror/MainWindow_1"<<
2773 if (debug) cout << "MainWindow::openURLs args="<<args.join(" ").toStdString()<<endl;
2774 if (!QProcess::startDetached ("qdbus",args))
2778 QMessageBox::warning(0,
2780 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2782 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2784 for (int i=0; i<urls.size(); i++)
2786 // Try to open new tab in firefox
2787 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2788 if (!QProcess::startDetached (browser,args))
2792 QMessageBox::warning(0,
2794 tr("Couldn't start %1 to open a new tab").arg(browser));
2797 QMessageBox::warning(0,
2799 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2803 void Main::editOpenURL()
2806 VymModel *m=currentModel();
2809 QString url=m->getURL();
2811 if (url=="") return;
2812 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2814 QString workDir=QDir::currentDirPath();
2815 if (!QProcess::startDetached(browser,args))
2817 // try to set path to browser
2818 QMessageBox::warning(0,
2820 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2821 tr("Please use Settings->")+tr("Set application to open an URL"));
2826 void Main::editOpenURLTab()
2828 VymModel *m=currentModel();
2832 urls.append(m->getURL());
2837 void Main::editOpenMultipleVisURLTabs(bool ignoreScrolled)
2839 VymModel *m=currentModel();
2843 urls=m->getURLs(ignoreScrolled);
2848 void Main::editOpenMultipleURLTabs()
2850 editOpenMultipleVisURLTabs (false);
2854 void Main::editURL()
2856 VymModel *m=currentModel();
2857 if (m) m->editURL();
2860 void Main::editLocalURL()
2862 VymModel *m=currentModel();
2863 if (m) m->editLocalURL();
2866 void Main::editHeading2URL()
2868 VymModel *m=currentModel();
2869 if (m) m->editHeading2URL();
2872 void Main::editBugzilla2URL()
2874 VymModel *m=currentModel();
2875 if (m) m->editBugzilla2URL();
2878 void Main::getBugzillaData()
2880 VymModel *m=currentModel();
2882 QProgressDialog progress ("Doing stuff","cancl",0,10,this);
2883 progress.setWindowModality(Qt::WindowModal);
2884 //progress.setCancelButton (NULL);
2886 progress.setMinimumDuration (0);
2887 progress.setValue (1);
2888 progress.setValue (5);
2892 QProgressBar *pb=new QProgressBar;
2898 if (m) m->getBugzillaData();
2901 void Main::editFATE2URL()
2903 VymModel *m=currentModel();
2904 if (m) m->editFATE2URL();
2907 void Main::editHeadingFinished(VymModel *m)
2911 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2912 !prevSelection.isEmpty())
2913 m->select(prevSelection);
2918 void Main::openVymLinks(const QStringList &vl)
2920 for (int j=0; j<vl.size(); j++)
2922 // compare path with already loaded maps
2925 for (i=0;i<=vymViews.count() -1;i++)
2927 if (vl.at(j)==vymViews.at(i)->getModel()->getFilePath() )
2936 if (!QFile(vl.at(j)).exists() )
2937 QMessageBox::critical( 0, tr( "Critical Error" ),
2938 tr("Couldn't open map %1").arg(vl.at(j)));
2941 fileLoad (vl.at(j), NewMap);
2942 tabWidget->setCurrentIndex (tabWidget->count()-1);
2945 // Go to tab containing the map
2946 tabWidget->setCurrentIndex (index);
2950 void Main::editOpenVymLink()
2952 VymModel *m=currentModel();
2956 vl.append(m->getVymLink());
2961 void Main::editOpenMultipleVymLinks()
2963 QString currentVymLink;
2964 VymModel *m=currentModel();
2967 QStringList vl=m->getVymLinks();
2972 void Main::editVymLink()
2974 VymModel *m=currentModel();
2979 void Main::editDeleteVymLink()
2981 VymModel *m=currentModel();
2982 if (m) m->deleteVymLink();
2985 void Main::editToggleHideExport()
2987 VymModel *m=currentModel();
2988 if (m) m->toggleHideExport();
2991 void Main::editAddTimestamp()
2993 VymModel *m=currentModel();
2994 if (m) m->addTimestamp();
2997 void Main::editMapInfo()
2999 VymModel *m=currentModel();
3002 ExtraInfoDialog dia;
3003 dia.setMapName (m->getFileName() );
3004 dia.setAuthor (m->getAuthor() );
3005 dia.setComment(m->getComment() );
3009 stats+=tr("%1 items on map\n","Info about map").arg (m->getScene()->items().size(),6);
3015 BranchItem *cur=NULL;
3016 BranchItem *prev=NULL;
3017 m->nextBranch(cur,prev);
3020 if (!cur->getNote().isEmpty() ) n++;
3021 f+= cur->imageCount();
3023 xl+=cur->xlinkCount();
3024 m->nextBranch(cur,prev);
3027 stats+=QString ("%1 xLinks \n").arg (xl/2,6);
3028 stats+=QString ("%1 notes\n").arg (n,6);
3029 stats+=QString ("%1 images\n").arg (f,6);
3030 stats+=QString ("%1 branches\n").arg (m->branchCount(),6);
3031 dia.setStats (stats);
3033 // Finally show dialog
3034 if (dia.exec() == QDialog::Accepted)
3036 m->setAuthor (dia.getAuthor() );
3037 m->setComment (dia.getComment() );
3041 void Main::editMoveUp()
3043 VymModel *m=currentModel();
3047 void Main::editMoveDown()
3049 VymModel *m=currentModel();
3050 if (m) m->moveDown();
3053 void Main::editDetach()
3055 VymModel *m=currentModel();
3059 void Main::editSortChildren()
3061 VymModel *m=currentModel();
3062 if (m) m->sortChildren(false);
3065 void Main::editSortBackChildren()
3067 VymModel *m=currentModel();
3068 if (m) m->sortChildren(true);
3071 void Main::editToggleScroll()
3073 VymModel *m=currentModel();
3074 if (m) m->toggleScroll();
3077 void Main::editExpandAll()
3079 VymModel *m=currentModel();
3080 if (m) m->emitExpandAll();
3083 void Main::editExpandOneLevel()
3085 VymModel *m=currentModel();
3086 if (m) m->emitExpandOneLevel();
3089 void Main::editCollapseOneLevel()
3091 VymModel *m=currentModel();
3092 if (m) m->emitCollapseOneLevel();
3095 void Main::editUnscrollChildren()
3097 VymModel *m=currentModel();
3098 if (m) m->unscrollChildren();
3101 void Main::editAddAttribute()
3103 VymModel *m=currentModel();
3111 void Main::editAddMapCenter()
3113 VymModel *m=currentModel();
3114 if (m) m->select (m->addMapCenter ());
3117 void Main::editNewBranch()
3119 VymModel *m=currentModel();
3122 BranchItem *bi=m->addNewBranch();
3125 if (actionSettingsAutoEditNewBranch->isOn()
3126 && !actionSettingsAutoSelectNewBranch->isOn() )
3127 prevSelection=m->getSelectString();
3129 prevSelection=QString();
3131 if (actionSettingsAutoSelectNewBranch->isOn()
3132 || actionSettingsAutoEditNewBranch->isOn())
3135 if (actionSettingsAutoEditNewBranch->isOn())
3136 currentMapEditor()->editHeading();
3141 void Main::editNewBranchBefore()
3143 VymModel *m=currentModel();
3146 BranchItem *bi=m->addNewBranchBefore();
3153 if (actionSettingsAutoEditNewBranch->isOn())
3155 if (!actionSettingsAutoSelectNewBranch->isOn())
3156 prevSelection=m->getSelectString(bi);
3157 currentMapEditor()->editHeading();
3162 void Main::editNewBranchAbove()
3164 VymModel *m=currentModel();
3167 BranchItem *bi=m->addNewBranch (-1);
3175 if (actionSettingsAutoEditNewBranch->isOn())
3177 if (!actionSettingsAutoSelectNewBranch->isOn())
3178 prevSelection=m->getSelectString (bi);
3179 currentMapEditor()->editHeading();
3184 void Main::editNewBranchBelow()
3186 VymModel *m=currentModel();
3189 BranchItem *bi=m->addNewBranch (1);
3196 if (actionSettingsAutoEditNewBranch->isOn())
3198 if (!actionSettingsAutoSelectNewBranch->isOn())
3199 prevSelection=m->getSelectString(bi);
3200 currentMapEditor()->editHeading();
3205 void Main::editImportAdd()
3207 fileLoad (ImportAdd);
3210 void Main::editImportReplace()
3212 fileLoad (ImportReplace);
3215 void Main::editSaveBranch()
3217 fileSaveAs (PartOfMap);
3220 void Main::editDeleteKeepChildren()
3222 VymModel *m=currentModel();
3223 if (m) m->deleteKeepChildren();
3226 void Main::editDeleteChildren()
3228 VymModel *m=currentModel();
3229 if (m) m->deleteChildren();
3232 void Main::editDeleteSelection()
3234 VymModel *m=currentModel();
3235 if (m && actionSettingsUseDelKey->isOn())
3236 m->deleteSelection();
3239 void Main::editLoadImage()
3241 VymModel *m=currentModel();
3242 if (m) m->loadFloatImage();
3245 void Main::editSaveImage()
3247 VymModel *m=currentModel();
3248 if (m) m->saveFloatImage();
3251 void Main::editEditXLink(QAction *a)
3253 VymModel *m=currentModel();
3255 m->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3258 void Main::formatSelectColor()
3260 QColor col = QColorDialog::getColor((currentColor ), this );
3261 if ( !col.isValid() ) return;
3262 colorChanged( col );
3265 void Main::formatPickColor()
3267 VymModel *m=currentModel();
3269 colorChanged( m->getCurrentHeadingColor() );
3272 void Main::colorChanged(QColor c)
3274 QPixmap pix( 16, 16 );
3276 actionFormatColor->setIconSet( pix );
3280 void Main::formatColorBranch()
3282 VymModel *m=currentModel();
3283 if (m) m->colorBranch(currentColor);
3286 void Main::formatColorSubtree()
3288 VymModel *m=currentModel();
3289 if (m) m->colorSubtree (currentColor);
3292 void Main::formatLinkStyleLine()
3294 VymModel *m=currentModel();
3297 m->setMapLinkStyle("StyleLine");
3298 actionFormatLinkStyleLine->setChecked(true);
3302 void Main::formatLinkStyleParabel()
3304 VymModel *m=currentModel();
3307 m->setMapLinkStyle("StyleParabel");
3308 actionFormatLinkStyleParabel->setChecked(true);
3312 void Main::formatLinkStylePolyLine()
3314 VymModel *m=currentModel();
3317 m->setMapLinkStyle("StylePolyLine");
3318 actionFormatLinkStylePolyLine->setChecked(true);
3322 void Main::formatLinkStylePolyParabel()
3324 VymModel *m=currentModel();
3327 m->setMapLinkStyle("StylePolyParabel");
3328 actionFormatLinkStylePolyParabel->setChecked(true);
3332 void Main::formatSelectBackColor()
3334 VymModel *m=currentModel();
3335 if (m) m->selectMapBackgroundColor();
3338 void Main::formatSelectBackImage()
3340 VymModel *m=currentModel();
3342 m->selectMapBackgroundImage();
3345 void Main::formatSelectLinkColor()
3347 VymModel *m=currentModel();
3350 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3351 m->setMapDefLinkColor( col );
3355 void Main::formatSelectSelectionColor()
3357 VymModel *m=currentModel();
3360 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3361 m->setSelectionColor (col);
3366 void Main::formatToggleLinkColorHint()
3368 VymModel *m=currentModel();
3369 if (m) m->toggleMapLinkColorHint();
3373 void Main::formatHideLinkUnselected() //FIXME-3 get rid of this with imagepropertydialog
3375 VymModel *m=currentModel();
3377 m->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3380 void Main::viewZoomReset()
3382 MapEditor *me=currentMapEditor();
3383 if (me) me->setZoomFactorTarget (1);
3386 void Main::viewZoomIn()
3388 MapEditor *me=currentMapEditor();
3389 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*1.15);
3392 void Main::viewZoomOut()
3394 MapEditor *me=currentMapEditor();
3395 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*0.85);
3398 void Main::viewCenter()
3400 VymModel *m=currentModel();
3401 if (m) m->emitShowSelection();
3404 void Main::networkStartServer()
3406 VymModel *m=currentModel();
3407 if (m) m->newServer();
3410 void Main::networkConnect()
3412 VymModel *m=currentModel();
3413 if (m) m->connectToServer();
3416 bool Main::settingsPDF()
3418 // Default browser is set in constructor
3420 QString text = QInputDialog::getText(
3421 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3422 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3424 settings.setValue ("/mainwindow/readerPDF",text);
3429 bool Main::settingsURL()
3431 // Default browser is set in constructor
3433 QString text = QInputDialog::getText(
3434 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3435 settings.value("/mainwindow/readerURL").toString()
3438 settings.setValue ("/mainwindow/readerURL",text);
3442 void Main::settingsMacroDir()
3444 QDir defdir(vymBaseDir.path() + "/macros");
3445 if (!defdir.exists())
3447 QDir dir=QFileDialog::getExistingDirectory (
3449 tr ("Directory with vym macros:"),
3450 settings.value ("/macros/macroDir",defdir.path()).toString()
3453 settings.setValue ("/macros/macroDir",dir.absolutePath());
3456 void Main::settingsUndoLevels()
3459 int i = QInputDialog::getInteger(
3461 tr("QInputDialog::getInteger()"),
3462 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3465 settings.setValue ("/mapeditor/stepsTotal",i);
3466 QMessageBox::information( this, tr( "VYM -Information:" ),
3467 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3471 void Main::settingsAutosaveToggle()
3473 settings.setValue ("/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
3476 void Main::settingsAutosaveTime()
3479 int i = QInputDialog::getInteger(
3481 tr("QInputDialog::getInteger()"),
3482 tr("Number of seconds before autosave:"), settings.value("/mainwindow/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3484 settings.setValue ("/mainwindow/autosave/ms",i * 1000);
3487 void Main::settingsAutoLayoutToggle()
3489 settings.setValue ("/mainwindow/autoLayout/use",actionSettingsAutosaveToggle->isOn() );
3492 void Main::settingsWriteBackupFileToggle()
3494 settings.setValue ("/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
3497 void Main::settingsToggleAnimation()
3499 settings.setValue ("/animation/use",actionSettingsUseAnimation->isOn() );
3502 void Main::settingsToggleDelKey()
3504 if (actionSettingsUseDelKey->isOn())
3506 actionDelete->setAccel (QKeySequence (Qt::Key_Delete));
3509 actionDelete->setAccel (QKeySequence (""));
3513 void Main::windowToggleNoteEditor()
3515 if (textEditor->isVisible() )
3516 windowHideNoteEditor();
3518 windowShowNoteEditor();
3521 void Main::windowToggleTreeEditor()
3523 if ( tabWidget->currentPage())
3524 vymViews.at(tabWidget->currentIndex())->toggleTreeEditor();
3527 void Main::windowToggleHistory()
3529 if (historyWindow->isVisible())
3530 historyWindow->hide();
3532 historyWindow->show();
3536 void Main::windowToggleProperty()
3538 if (branchPropertyWindow->isVisible())
3539 branchPropertyWindow->hide();
3541 branchPropertyWindow->show();
3542 branchPropertyWindow->setModel (currentModel() );
3545 void Main::windowToggleAntiAlias()
3547 bool b=actionViewToggleAntiAlias->isOn();
3549 for (int i=0;i<vymViews.count();i++)
3551 me=vymViews.at(i)->getMapEditor();
3552 if (me) me->setAntiAlias(b);
3557 bool Main::isAliased()
3559 return actionViewToggleAntiAlias->isOn();
3562 bool Main::hasSmoothPixmapTransform()
3564 return actionViewToggleSmoothPixmapTransform->isOn();
3567 void Main::windowToggleSmoothPixmap()
3569 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3571 for (int i=0;i<vymViews.count();i++)
3574 me=vymViews.at(i)->getMapEditor();
3575 if (me) me->setSmoothPixmap(b);
3579 void Main::updateHistory(SimpleSettings &undoSet)
3581 historyWindow->update (undoSet);
3584 void Main::updateNoteFlag()
3586 // this slot is connected to TextEditor::textHasChanged()
3587 VymModel *m=currentModel();
3588 if (m) m->updateNoteFlag();
3591 void Main::updateNoteEditor(QModelIndex index )
3593 TreeItem *ti=((VymModel*) QObject::sender())->getItem(index);
3595 cout << "Main::updateNoteEditor model="<<sender();
3596 cout << " item="<<ti->getHeadingStd()<<" ("<<ti<<")"<<endl;
3598 textEditor->setNote (ti->getNoteObj() );
3601 void Main::selectInNoteEditor(QString s,int i)
3603 // TreeItem is already selected at this time, therefor
3604 // the note is already in the editor
3605 textEditor->findText (s,0,i);
3608 void Main::changeSelection (VymModel *model, const QItemSelection &newsel, const QItemSelection &oldsel)
3610 branchPropertyWindow->setModel (model ); //FIXME-3 this used to be called from BranchObj::select(). Maybe use signal now...
3612 if (model && model==currentModel() )
3616 if (!oldsel.indexes().isEmpty() )
3618 ti=model->getItem(oldsel.indexes().first());
3620 // Don't update note if both treeItem and textEditor are empty
3621 //if (! (ti->hasEmptyNote() && textEditor->isEmpty() ))
3622 // ti->setNoteObj (textEditor->getNoteObj(),false );
3624 if (!newsel.indexes().isEmpty() )
3626 ti=model->getItem(newsel.indexes().first());
3627 if (!ti->hasEmptyNote() )
3628 textEditor->setNote(ti->getNoteObj() );
3630 textEditor->setNote(NoteObj() ); //FIXME-4 maybe add a clear() to TE
3632 // Show URL and link in statusbar
3634 QString s=ti->getURL();
3635 if (!s.isEmpty() ) status+="URL: "+s+" ";
3637 if (!s.isEmpty() ) status+="Link: "+s;
3638 if (!status.isEmpty() ) statusMessage (status);
3641 textEditor->setInactive();
3647 void Main::updateActions()
3649 // updateActions is also called when satellites are closed
3650 actionViewToggleNoteEditor->setChecked (textEditor->isVisible());
3651 actionViewToggleHistoryWindow->setChecked (historyWindow->isVisible());
3652 actionViewTogglePropertyWindow->setChecked (branchPropertyWindow->isVisible());
3653 if ( tabWidget->currentPage())
3654 actionViewToggleTreeEditor->setChecked (
3655 vymViews.at(tabWidget->currentIndex())->getTreeEditor()->isVisible()
3658 VymModel *m =currentModel();
3662 actionFilePrint->setEnabled (true);
3664 // Link style in context menu
3665 switch (m->getMapLinkStyle())
3667 case LinkableMapObj::Line:
3668 actionFormatLinkStyleLine->setChecked(true);
3670 case LinkableMapObj::Parabel:
3671 actionFormatLinkStyleParabel->setChecked(true);
3673 case LinkableMapObj::PolyLine:
3674 actionFormatLinkStylePolyLine->setChecked(true);
3676 case LinkableMapObj::PolyParabel:
3677 actionFormatLinkStylePolyParabel->setChecked(true);
3684 QPixmap pix( 16, 16 );
3685 pix.fill( m->getMapBackgroundColor() );
3686 actionFormatBackColor->setIconSet( pix );
3687 pix.fill( m->getSelectionColor() );
3688 actionFormatSelectionColor->setIconSet( pix );
3689 pix.fill( m->getMapDefLinkColor() );
3690 actionFormatLinkColor->setIconSet( pix );
3693 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName()));
3696 // Expanding/collapsing
3697 actionExpandAll->setEnabled (true);
3698 actionExpandOneLevel->setEnabled (true);
3699 actionCollapseOneLevel->setEnabled (true);
3703 actionFilePrint->setEnabled (false);
3705 // Expanding/collapsing
3706 actionExpandAll->setEnabled (false);
3707 actionExpandOneLevel->setEnabled (false);
3708 actionCollapseOneLevel->setEnabled (false);
3711 if (m && m->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3712 actionFormatLinkColorHint->setChecked(true);
3714 actionFormatLinkColorHint->setChecked(false);
3717 if (m && m->hasChanged() )
3718 actionFileSave->setEnabled( true);
3720 actionFileSave->setEnabled( false);
3721 if (m && m->isUndoAvailable())
3722 actionUndo->setEnabled( true);
3724 actionUndo->setEnabled( false);
3726 if (m && m->isRedoAvailable())
3727 actionRedo->setEnabled( true);
3729 actionRedo->setEnabled( false);
3733 TreeItem *selti=m->getSelectedItem();
3734 BranchItem *selbi=m->getSelectedBranch();
3737 if (selbi || selti->getType()==TreeItem::Image)
3739 actionFormatHideLinkUnselected->setChecked (((MapItem*)selti)->getHideLinkUnselected());
3740 actionFormatHideLinkUnselected->setEnabled (true);
3745 // Take care of xlinks
3746 branchXLinksContextMenuEdit->clear();
3747 if (selbi->xlinkCount()>0)
3751 for (int i=0; i<selbi->xlinkCount();++i)
3753 bi=selbi->getXLinkNum(i)->getPartnerBranch();
3757 if (s.length()>xLinkMenuWidth)
3758 s=s.left(xLinkMenuWidth)+"...";
3759 branchXLinksContextMenuEdit->addAction (s);
3764 standardFlagsMaster->updateToolBar (selbi->activeStandardFlagNames() );
3767 actionToggleScroll->setEnabled (true);
3768 if ( selbi->isScrolled() )
3769 actionToggleScroll->setChecked(true);
3771 actionToggleScroll->setChecked(false);
3773 if ( selti->getURL().isEmpty() )
3775 actionOpenURL->setEnabled (false);
3776 actionOpenURLTab->setEnabled (false);
3780 actionOpenURL->setEnabled (true);
3781 actionOpenURLTab->setEnabled (true);
3783 if ( selti->getVymLink().isEmpty() )
3785 actionOpenVymLink->setEnabled (false);
3786 actionDeleteVymLink->setEnabled (false);
3789 actionOpenVymLink->setEnabled (true);
3790 actionDeleteVymLink->setEnabled (true);
3793 if (selbi->canMoveUp())
3794 actionMoveUp->setEnabled (true);
3796 actionMoveUp->setEnabled (false);
3797 if (selbi->canMoveDown())
3798 actionMoveDown->setEnabled (true);
3800 actionMoveDown->setEnabled (false);
3802 actionSortChildren->setEnabled (true);
3803 actionSortBackChildren->setEnabled (true);
3805 actionToggleHideExport->setEnabled (true);
3806 actionToggleHideExport->setChecked (selbi->hideInExport() );
3808 actionCopy->setEnabled (true);
3809 actionCut->setEnabled (true);
3810 if (!clipboardEmpty)
3811 actionPaste->setEnabled (true);
3813 actionPaste->setEnabled (false);
3814 for (int i=0; i<actionListBranches.size(); ++i)
3815 actionListBranches.at(i)->setEnabled(true);
3816 actionDelete->setEnabled (true);
3818 if ( selti->getType()==TreeItem::Image)
3820 actionOpenURL->setEnabled (false);
3821 actionOpenVymLink->setEnabled (false);
3822 actionDeleteVymLink->setEnabled (false);
3823 actionToggleHideExport->setEnabled (true);
3824 actionToggleHideExport->setChecked (selti->hideInExport() );
3827 actionCopy->setEnabled (true);
3828 actionCut->setEnabled (true);
3829 actionPaste->setEnabled (false); //FIXME-4 why not allowing copy of images?
3830 for (int i=0; i<actionListBranches.size(); ++i)
3831 actionListBranches.at(i)->setEnabled(false);
3832 actionDelete->setEnabled (true);
3833 actionMoveUp->setEnabled (false);
3834 actionMoveDown->setEnabled (false);
3839 actionCopy->setEnabled (false);
3840 actionCut->setEnabled (false);
3841 actionPaste->setEnabled (false);
3842 for (int i=0; i<actionListBranches.size(); ++i)
3843 actionListBranches.at(i)->setEnabled(false);
3845 actionToggleScroll->setEnabled (false);
3846 actionOpenURL->setEnabled (false);
3847 actionOpenVymLink->setEnabled (false);
3848 actionDeleteVymLink->setEnabled (false);
3849 actionHeading2URL->setEnabled (false);
3850 actionDelete->setEnabled (false);
3851 actionMoveUp->setEnabled (false);
3852 actionMoveDown->setEnabled (false);
3853 actionFormatHideLinkUnselected->setEnabled (false);
3854 actionSortChildren->setEnabled (false);
3855 actionSortBackChildren->setEnabled (false);
3856 actionToggleHideExport->setEnabled (false);
3861 Main::ModMode Main::getModMode()
3863 if (actionModModeColor->isOn()) return ModModeColor;
3864 if (actionModModeCopy->isOn()) return ModModeCopy;
3865 if (actionModModeXLink->isOn()) return ModModeXLink;
3869 bool Main::autoEditNewBranch()
3871 return actionSettingsAutoEditNewBranch->isOn();
3874 bool Main::autoSelectNewBranch()
3876 return actionSettingsAutoSelectNewBranch->isOn();
3879 void Main::windowShowNoteEditor()
3881 textEditor->setShowWithMain(true);
3883 actionViewToggleNoteEditor->setChecked (true);
3886 void Main::windowHideNoteEditor()
3888 textEditor->setShowWithMain(false);
3890 actionViewToggleNoteEditor->setChecked (false);
3893 void Main::setScript (const QString &script)
3895 scriptEditor->setScript (script);
3898 void Main::runScript (const QString &script)
3900 VymModel *m=currentModel();
3901 if (m) m->runScript (script);
3904 void Main::runScriptEverywhere (const QString &script)
3907 for (int i=0;i<=tabWidget->count() -1;i++)
3909 me=(MapEditor*)tabWidget->page(i);
3910 if (me) me->getModel()->runScript (script);
3914 void Main::windowNextEditor()
3916 if (tabWidget->currentIndex() < tabWidget->count())
3917 tabWidget->setCurrentIndex (tabWidget->currentIndex() +1);
3920 void Main::windowPreviousEditor()
3922 if (tabWidget->currentIndex() >0)
3923 tabWidget->setCurrentIndex (tabWidget->currentIndex() -1);
3926 void Main::standardFlagChanged()
3930 if ( actionSettingsUseFlagGroups->isOn() )
3931 currentModel()->toggleStandardFlag(sender()->name(),standardFlagsMaster);
3933 currentModel()->toggleStandardFlag(sender()->name());
3939 void Main::testFunction1()
3942 #include "attributeitem.h"
3943 VymModel *m=currentModel();
3946 BranchItem *selbi=m->getSelectedBranch();
3949 QList<QVariant> cData;
3950 cData << "new ai" << "undef";
3952 AttributeItem *ai=new AttributeItem (cData,selbi);
3953 ai->set ("Key 1","Val a",AttributeItem::FreeString);
3955 m->addAttribute (ai);
3959 if (!currentMapEditor()) return;
3960 currentMapEditor()->testFunction1();
3963 void Main::testFunction2()
3965 if (!currentMapEditor()) return;
3966 currentMapEditor()->testFunction2();
3969 void Main::testCommand()
3971 if (!currentMapEditor()) return;
3972 scriptEditor->show();
3975 QString com = QInputDialog::getText(
3976 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3977 if (ok) currentMapEditor()->parseAtom(com);
3981 void Main::helpDoc()
3983 QString locale = QLocale::system().name();
3985 if (locale.left(2)=="es")
3986 docname="vym_es.pdf";
3990 QStringList searchList;
3992 #if defined(Q_OS_MACX)
3993 searchList << "./vym.app/Contents/Resources/doc";
3994 #elif defined(Q_OS_WIN32)
3995 searchList << vymInstallDir.path() + "/share/doc/packages/vym";
3997 #if defined(VYM_DOCDIR)
3998 searchList << VYM_DOCDIR;
4000 // default path in SUSE LINUX
4001 searchList << "/usr/share/doc/packages/vym";
4004 searchList << "doc"; // relative path for easy testing in tarball
4005 searchList << "doc/tex"; // Easy testing working on vym.tex
4006 searchList << "/usr/share/doc/vym"; // Debian
4007 searchList << "/usr/share/doc/packages";// Knoppix
4011 for (int i=0; i<searchList.count(); ++i)
4013 docfile.setFileName(searchList.at(i)+"/"+docname);
4014 if (docfile.exists())
4023 QMessageBox::critical(0,
4024 tr("Critcal error"),
4025 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
4030 Process *pdfProc = new Process();
4031 args << QDir::toNativeSeparators(docfile.fileName());
4033 if (!pdfProc->startDetached( settings.value("/mainwindow/readerPDF").toString(),args) )
4036 QMessageBox::warning(0,
4038 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
4039 tr("Please use Settings->")+tr("Set application to open PDF files"));
4046 void Main::helpDemo()
4048 QStringList filters;
4049 filters <<"VYM example map (*.vym)";
4050 QFileDialog *fd=new QFileDialog( this);
4051 #if defined(Q_OS_MACX)
4052 fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
4054 // default path in SUSE LINUX
4055 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
4058 fd->setFileMode (QFileDialog::ExistingFiles);
4059 fd->setFilters (filters);
4060 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
4064 if ( fd->exec() == QDialog::Accepted )
4066 lastFileDir=fd->directory().path();
4067 QStringList flist = fd->selectedFiles();
4068 QStringList::Iterator it = flist.begin();
4069 while( it != flist.end() )
4072 fileLoad(*it, NewMap);
4080 void Main::helpAbout()
4083 ad.setName ("aboutwindow");
4084 ad.setMinimumSize(500,500);
4085 ad.resize (QSize (500,500));
4089 void Main::helpAboutQT()
4091 QMessageBox::aboutQt( this, "Qt Application Example" );
4094 void Main::callMacro ()
4096 QAction *action = qobject_cast<QAction *>(sender());
4100 i=action->data().toInt();
4101 QString mDir (settings.value ("macros/macroDir").toString() );
4103 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
4105 if ( !f.open( QIODevice::ReadOnly ) )
4107 QMessageBox::warning(0,
4109 tr("Couldn't find a macro at %1.\n").arg(fn)+
4110 tr("Please use Settings->")+tr("Set directory for vym macros"));
4114 QTextStream ts( &f );
4115 QString macro= ts.read();
4117 if (! macro.isEmpty())
4119 VymModel *m=currentModel();
4120 if (m) m->runScript(macro);