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 (XHTML)","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( "Webpage (XHTML)...",this ); //Export XHTML
485 //a->setShortcut (Qt::ALT + Qt::SHIFT + Qt::Key_X); a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
486 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
487 fileExportMenu->addAction (a);
489 a = new QAction( "Text (A&O report)...", this);
490 a->setStatusTip ( tr( "Export as %1").arg("A&O report "+tr("(still experimental)" )));
491 switchboard.addConnection(a,tr("File","Shortcut group"));
492 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportAO() ) );
493 fileExportMenu->addAction (a);
495 a = new QAction( "Text (ASCII)...", this);
496 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
497 switchboard.addConnection(a,tr("File","Shortcut group"));
498 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
499 fileExportMenu->addAction (a);
501 a = new QAction( "Spreadsheet (CSV)...", this);
502 a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
503 switchboard.addConnection(a,tr("File","Shortcut group"));
504 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
505 fileExportMenu->addAction (a);
507 a = new QAction( tr("KDE 3 Bookmarks","File menu"), this);
508 a->setStatusTip( tr( "Export as %1").arg(tr("KDE 3 Bookmarks" )));
509 switchboard.addConnection(a,tr("File","Shortcut group"));
510 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE3Bookmarks() ) );
511 fileExportMenu->addAction (a);
513 a = new QAction( tr("KDE 4 Bookmarks","File menu"), this);
514 a->setStatusTip( tr( "Export as %1").arg(tr("KDE 4 Bookmarks" )));
515 switchboard.addConnection(a,tr("File","Shortcut group"));
516 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE4Bookmarks() ) );
517 fileExportMenu->addAction (a);
519 a = new QAction( "Taskjuggler...", this );
520 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
521 switchboard.addConnection(a,tr("File","Shortcut group"));
522 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
523 fileExportMenu->addAction (a);
525 a = new QAction( "LaTeX...", this);
526 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
527 switchboard.addConnection(a,tr("File","Shortcut group"));
528 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
529 fileExportMenu->addAction (a);
531 a = new QAction( "XML..." , this );
532 a->setStatusTip (tr( "Export as %1").arg("XML"));
533 switchboard.addConnection(a,tr("File","Shortcut group"));
534 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
535 fileExportMenu->addAction (a);
537 fileMenu->addSeparator();
539 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
540 a->setStatusTip ( tr( "Print" ,"File menu") );
541 a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map
543 switchboard.addConnection(a,tr("File","Shortcut group"));
544 fileMenu->addAction (a);
545 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
548 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
549 a->setStatusTip (tr( "Close Map" ) );
550 a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map
551 switchboard.addConnection(a,tr("File","Shortcut group"));
552 fileMenu->addAction (a);
553 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
555 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
556 a->setStatusTip ( tr( "Exit")+" "+vymName );
557 a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym
558 switchboard.addConnection(a,tr("File","Shortcut group"));
559 fileMenu->addAction (a);
560 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
565 void Main::setupEditActions()
567 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
568 tb->setLabel( "Edit Actions" );
569 tb->setObjectName ("actionsTB");
570 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
573 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
574 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
575 a->setStatusTip (tr( "Undo" ) );
576 a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action
577 a->setEnabled (false);
578 switchboard.addConnection(a,tr("Edit","Shortcut group"));
580 editMenu->addAction (a);
583 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
584 a->setStatusTip (tr( "Redo" ));
585 a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action
586 switchboard.addConnection(a,tr("Edit","Shortcut group"));
588 editMenu->addAction (a);
589 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
592 editMenu->addSeparator();
593 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
594 a->setStatusTip ( tr( "Copy" ) );
595 a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy
596 a->setEnabled (false);
597 switchboard.addConnection(a,tr("Edit","Shortcut group"));
599 editMenu->addAction (a);
600 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
603 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
604 a->setStatusTip ( tr( "Cut" ) );
605 a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut
606 a->setEnabled (false);
608 switchboard.addConnection(a,tr("Edit","Shortcut group"));
609 editMenu->addAction (a);
611 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
613 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
614 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
615 a->setStatusTip ( tr( "Paste" ) );
616 a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste
617 a->setEnabled (false);
619 switchboard.addConnection(a,tr("Edit","Shortcut group"));
620 editMenu->addAction (a);
623 // Shortcut to delete selection
624 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
625 a->setStatusTip (tr( "Delete Selection" ));
626 a->setShortcut ( Qt::Key_Delete); //Delete selection
627 a->setShortcutContext (Qt::WindowShortcut);
628 switchboard.addConnection(a,tr("Edit","Shortcut group"));
630 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
633 // Shortcut to add attribute
634 a= new QAction(tr( "Add attribute" ), this);
635 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
637 a->setShortcut ( Qt::Key_Q);
638 a->setShortcutContext (Qt::WindowShortcut);
639 switchboard.addConnection(a,tr("Edit","Shortcut group"));
642 connect( a, SIGNAL( triggered() ), this, SLOT( editAddAttribute() ) );
643 actionAddAttribute= a;
646 // Shortcut to add mapcenter
647 a= new QAction(QPixmap(iconPath+"newmapcenter.png"),tr( "Add mapcenter","Canvas context menu" ), this);
648 a->setShortcut ( Qt::Key_M);
649 a->setShortcutContext (Qt::WindowShortcut);
650 switchboard.addConnection(a,tr("Edit","Shortcut group"));
651 connect( a, SIGNAL( triggered() ), this, SLOT( editAddMapCenter() ) );
652 //actionListBranches.append(a);
654 actionAddMapCenter = a;
657 // Shortcut to add branch
658 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
659 a->setStatusTip ( tr( "Add a branch as child of selection" ));
660 a->setShortcut (Qt::Key_A); //Add branch
661 a->setShortcutContext (Qt::WindowShortcut);
662 switchboard.addConnection(a,tr("Edit","Shortcut group"));
664 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
665 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
666 a->setStatusTip ( tr( "Add a branch as child of selection" ));
667 a->setShortcut (Qt::Key_Insert); //Add branch
668 switchboard.addConnection(a,tr("Edit","Shortcut group"));
669 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
670 actionListBranches.append(a);
672 editMenu->addAction (actionAddBranch);
673 tb->addAction (actionAddBranch);
676 // Add branch by inserting it at selection
677 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
678 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
679 a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch
680 a->setShortcutContext (Qt::WindowShortcut);
681 switchboard.addConnection(a,tr("Edit","Shortcut group"));
683 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
684 actionListBranches.append(a);
685 actionAddBranchBefore=a;
688 a = new QAction(tr( "Add branch above","Edit menu" ), this);
689 a->setStatusTip ( tr( "Add a branch above selection" ));
690 a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
691 a->setShortcutContext (Qt::WindowShortcut);
692 switchboard.addConnection(a,tr("Edit","Shortcut group"));
694 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
695 a->setEnabled (false);
696 actionListBranches.append(a);
697 actionAddBranchAbove=a;
698 a = new QAction(tr( "Add branch above","Edit menu" ), this);
699 a->setStatusTip ( tr( "Add a branch above selection" ));
700 a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above
701 a->setShortcutContext (Qt::WindowShortcut);
702 switchboard.addConnection(a,tr("Edit","Shortcut group"));
704 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
705 actionListBranches.append(a);
708 a = new QAction(tr( "Add branch below","Edit menu" ), this);
709 a->setStatusTip ( tr( "Add a branch below selection" ));
710 a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
711 a->setShortcutContext (Qt::WindowShortcut);
712 switchboard.addConnection(a,tr("Edit","Shortcut group"));
714 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
715 a->setEnabled (false);
716 actionListBranches.append(a);
717 actionAddBranchBelow=a;
718 a = new QAction(tr( "Add branch below","Edit menu" ), this);
719 a->setStatusTip ( tr( "Add a branch below selection" ));
720 a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below
721 a->setShortcutContext (Qt::WindowShortcut);
722 switchboard.addConnection(a,tr("Edit","Shortcut group"));
724 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
725 actionListBranches.append(a);
727 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
728 a->setStatusTip ( tr( "Move branch up" ) );
729 a->setShortcut (Qt::Key_PageUp ); // Move branch up //FIXME-2 If already on top, GraphicsView scrolls up, probably because this action is disabled?!
730 a->setEnabled (false);
731 switchboard.addConnection(a,tr("Edit","Shortcut group"));
733 editMenu->addAction (a);
734 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
737 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
738 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
739 a->setStatusTip (tr( "Move branch down" ) );
740 a->setShortcut ( Qt::Key_PageDown ); // Move branch down
741 a->setEnabled (false);
742 switchboard.addConnection(a,tr("Edit","Shortcut group"));
744 editMenu->addAction (a);
747 a = new QAction(QPixmap(), tr( "&Detach","Context menu" ),this);
748 a->setStatusTip ( tr( "Detach branch and use as mapcenter","Context menu" ) );
749 a->setShortcut ( Qt::Key_D ); // Detach branch
750 switchboard.addConnection(a,tr("Edit","Shortcut group"));
751 editMenu->addAction (a);
752 connect( a, SIGNAL( triggered() ), this, SLOT( editDetach() ) );
755 a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this );
756 connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) );
757 a->setEnabled (true);
759 switchboard.addConnection(a,tr("Edit","Shortcut group"));
760 editMenu->addAction (a);
761 actionSortChildren=a;
763 a = new QAction( QPixmap(iconPath+"editsortback.png" ), tr( "Sort children backwards","Edit menu" ), this );
764 connect( a, SIGNAL( activated() ), this, SLOT( editSortBackChildren() ) );
765 a->setEnabled (true);
767 switchboard.addConnection(a,tr("Edit","Shortcut group"));
768 editMenu->addAction (a);
769 actionSortBackChildren=a;
771 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
772 a->setShortcut ( Qt::Key_S ); // Scroll branch
773 a->setStatusTip (tr( "Scroll branch" ));
774 switchboard.addConnection(a,tr("Edit","Shortcut group"));
775 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
776 a->setEnabled (false);
777 a->setToggleAction(true);
778 actionToggleScroll=a;
779 tb->addAction (actionToggleScroll);
780 editMenu->addAction ( actionToggleScroll);
781 editMenu->addAction (actionToggleScroll);
783 actionListBranches.append(actionToggleScroll);
785 a = new QAction( QPixmap(), tr( "Expand all branches","Edit menu" ), this);
786 a->setShortcut ( Qt::SHIFT + Qt::Key_X ); // Expand all branches
787 a->setStatusTip (tr( "Expand all branches" ));
788 switchboard.addConnection(a,tr("Edit","Shortcut group"));
789 connect( a, SIGNAL( triggered() ), this, SLOT( editExpandAll() ) );
791 actionExpandAll->setEnabled (false);
792 actionExpandAll->setToggleAction(false);
793 //tb->addAction (actionExpandAll);
794 editMenu->addAction ( actionExpandAll);
796 actionListBranches.append(actionExpandAll);
798 a = new QAction( QPixmap(), tr( "Expand one level","Edit menu" ), this);
799 a->setShortcut ( Qt::Key_Greater ); // Expand one level in tree editor
800 switchboard.addConnection(a,tr("Edit","Shortcut group"));
801 a->setStatusTip (tr( "Expand one level in tree editor" ));
802 connect( a, SIGNAL( triggered() ), this, SLOT( editExpandOneLevel() ) );
803 a->setEnabled (false);
804 a->setToggleAction(false);
805 actionExpandOneLevel=a;
807 editMenu->addAction ( a);
809 actionListBranches.append(a);
811 a = new QAction( QPixmap(), tr( "Collapse one level","Edit menu" ), this);
812 a->setShortcut ( Qt::Key_Less); // Collapse one level in tree editor
813 switchboard.addConnection(a,tr("Edit","Shortcut group"));
814 a->setStatusTip (tr( "Collapse one level in tree editor" ));
815 connect( a, SIGNAL( triggered() ), this, SLOT( editCollapseOneLevel() ) );
816 a->setEnabled (false);
817 a->setToggleAction(false);
818 actionCollapseOneLevel=a;
820 editMenu->addAction ( a);
822 actionListBranches.append(a);
824 a = new QAction( tr( "Unscroll children","Edit menu" ), this);
825 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
826 switchboard.addConnection(a,tr("Edit","Shortcut group"));
827 editMenu->addAction (a);
828 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChildren() ) );
830 editMenu->addSeparator();
832 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
833 a->setStatusTip (tr( "Find" ) );
834 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
835 switchboard.addConnection(a,tr("Edit","Shortcut group"));
836 editMenu->addAction (a);
837 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWidget() ) );
839 a = new QAction( tr( "Find duplicate URLs","Edit menu"), this);
840 //a->setStatusTip (tr( "Find" ) );
841 a->setShortcut (Qt::SHIFT + Qt::Key_F); //Find duplicate URLs
842 switchboard.addConnection(a,tr("Edit","Shortcut group"));
843 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
844 editMenu->addAction (a);
845 connect( a, SIGNAL( triggered() ), this, SLOT( editFindDuplicateURLs() ) );
847 editMenu->addSeparator();
849 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
850 a->setShortcut (Qt::SHIFT + Qt::Key_U );
851 switchboard.addConnection(a,tr("Edit","Shortcut group"));
854 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
857 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
858 a->setStatusTip (tr( "Open URL in new tab" ));
859 //a->setShortcut (Qt::CTRL+Qt::Key_U );
860 switchboard.addConnection(a,tr("Edit","Shortcut group"));
862 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
865 a = new QAction( tr( "Open all URLs in subtree (including scrolled branches)","Edit menu" ), this);
866 a->setStatusTip (tr( "Open all URLs in subtree (including scrolled branches)" ));
867 a->setShortcut ( Qt::CTRL + Qt::Key_U );
868 switchboard.addConnection(a,tr("Edit","Shortcut group"));
870 actionListBranches.append(a);
871 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVisURLTabs() ) );
872 actionOpenMultipleVisURLTabs=a;
874 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
875 a->setStatusTip (tr( "Open all URLs in subtree" ));
876 switchboard.addConnection(a,tr("Edit","Shortcut group"));
878 actionListBranches.append(a);
879 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
880 actionOpenMultipleURLTabs=a;
882 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
883 a->setStatusTip ( tr( "Edit URL" ) );
884 a->setShortcut ( Qt::Key_U );
885 a->setShortcutContext (Qt::WindowShortcut);
886 switchboard.addConnection(a,tr("Edit","Shortcut group"));
887 actionListBranches.append(a);
889 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
892 a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
893 a->setStatusTip ( tr( "Edit local URL" ) );
894 //a->setShortcut (Qt::SHIFT + Qt::Key_U );
895 a->setShortcutContext (Qt::WindowShortcut);
896 switchboard.addConnection(a,tr("Edit","Shortcut group"));
897 actionListBranches.append(a);
899 connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
902 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
903 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
904 a->setEnabled (false);
905 switchboard.addConnection(a,tr("Edit","Shortcut group"));
906 actionListBranches.append(a);
907 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
910 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
911 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
912 a->setEnabled (false);
913 actionListBranches.append(a);
914 a->setShortcut ( Qt::Key_B );
915 a->setShortcutContext (Qt::WindowShortcut);
916 switchboard.addConnection(a,tr("Edit","Shortcut group"));
918 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
919 actionBugzilla2URL=a;
921 a = new QAction(tr( "Get data from Novell Bugzilla","Edit menu" ), this);
922 a->setStatusTip ( tr( "Get data from Novell Bugzilla" ));
923 a->setEnabled (false);
924 actionListBranches.append(a);
925 a->setShortcut ( Qt::Key_B + Qt::SHIFT);
926 a->setShortcutContext (Qt::WindowShortcut);
927 switchboard.addConnection(a,tr("Edit","Shortcut group"));
929 connect( a, SIGNAL( triggered() ), this, SLOT( getBugzillaData() ) );
930 actionGetBugzillaData=a;
932 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
933 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
934 a->setEnabled (false);
935 switchboard.addConnection(a,tr("Edit","Shortcut group"));
936 actionListBranches.append(a);
937 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
940 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
941 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
943 a->setEnabled (false);
944 switchboard.addConnection(a,tr("Edit","Shortcut group"));
945 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
948 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
949 a->setStatusTip ( tr( "Open all vym links in subtree" ));
950 a->setEnabled (false);
951 switchboard.addConnection(a,tr("Edit","Shortcut group"));
952 actionListBranches.append(a);
953 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
954 actionOpenMultipleVymLinks=a;
957 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
958 a->setEnabled (false);
959 a->setStatusTip ( tr( "Edit link to another vym map" ));
960 switchboard.addConnection(a,tr("Edit","Shortcut group"));
961 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
962 actionListBranches.append(a);
965 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
966 a->setStatusTip ( tr( "Delete link to another vym map" ));
967 a->setEnabled (false);
968 switchboard.addConnection(a,tr("Edit","Shortcut group"));
969 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
970 actionDeleteVymLink=a;
972 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
973 a->setStatusTip ( tr( "Hide object in exports" ) );
974 a->setShortcut (Qt::Key_H );
975 a->setToggleAction(true);
977 a->setEnabled (false);
978 switchboard.addConnection(a,tr("Edit","Shortcut group"));
979 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
980 actionToggleHideExport=a;
982 a = new QAction(tr( "Add timestamp","Edit menu" ), this);
983 a->setStatusTip ( tr( "Add timestamp" ));
984 a->setEnabled (false);
985 actionListBranches.append(a);
986 a->setShortcut ( Qt::Key_T ); // Add timestamp
987 a->setShortcutContext (Qt::WindowShortcut);
988 switchboard.addConnection(a,tr("Edit","Shortcut group"));
990 connect( a, SIGNAL( triggered() ), this, SLOT( editAddTimestamp() ) );
991 actionAddTimestamp=a;
993 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
994 a->setStatusTip ( tr( "Edit Map Info" ));
995 a->setEnabled (true);
996 switchboard.addConnection(a,tr("Edit","Shortcut group"));
997 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
1000 // Import at selection (adding to selection)
1001 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
1002 a->setStatusTip (tr( "Add map at selection" ));
1003 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
1004 a->setEnabled (false);
1005 switchboard.addConnection(a,tr("Edit","Shortcut group"));
1006 actionListBranches.append(a);
1009 // Import at selection (replacing selection)
1010 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
1011 a->setStatusTip (tr( "Replace selection with map" ));
1012 switchboard.addConnection(a,tr("Edit","Shortcut group"));
1013 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
1014 a->setEnabled (false);
1015 actionListBranches.append(a);
1016 actionImportReplace=a;
1019 a = new QAction( tr( "Save selection","Edit menu" ), this);
1020 a->setStatusTip (tr( "Save selection" ));
1021 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
1022 a->setEnabled (false);
1023 switchboard.addConnection(a,tr("Edit","Shortcut group"));
1024 actionListBranches.append(a);
1027 // Only remove branch, not its children
1028 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
1029 a->setStatusTip ( tr( "Remove only branch and keep its children" ));
1030 a->setShortcut (Qt::ALT + Qt::Key_Delete );
1031 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChildren() ) );
1032 a->setEnabled (false);
1033 switchboard.addConnection(a,tr("Edit","Shortcut group"));
1035 actionListBranches.append(a);
1036 actionDeleteKeepChildren=a;
1038 // Only remove children of a branch
1039 a = new QAction( tr( "Remove children","Edit menu" ), this);
1040 a->setStatusTip (tr( "Remove children of branch" ));
1041 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
1042 switchboard.addConnection(a,tr("Edit","Shortcut group"));
1043 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChildren() ) );
1044 a->setEnabled (false);
1045 actionListBranches.append(a);
1046 actionDeleteChildren=a;
1048 a = new QAction( tr( "Add Image...","Edit menu" ), this);
1049 a->setStatusTip (tr( "Add Image" ));
1050 switchboard.addConnection(a,tr("Edit","Shortcut group"));
1051 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
1054 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
1055 a->setStatusTip (tr( "Set properties for selection" ));
1056 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
1057 a->setShortcutContext (Qt::WindowShortcut);
1058 a->setToggleAction (true);
1059 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1061 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
1062 actionViewTogglePropertyWindow=a;
1066 void Main::setupFormatActions()
1068 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
1070 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
1071 tb->setObjectName ("formatTB");
1073 QPixmap pix( 16,16);
1074 pix.fill (Qt::black);
1075 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
1076 a->setStatusTip ( tr( "Set Color" ));
1077 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
1079 formatMenu->addAction (a);
1080 actionFormatColor=a;
1081 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
1082 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
1083 a->setShortcut (Qt::CTRL + Qt::Key_K );
1084 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
1085 a->setEnabled (false);
1087 formatMenu->addAction (a);
1088 actionListBranches.append(a);
1089 actionFormatPickColor=a;
1091 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
1092 a->setStatusTip ( tr( "Color branch" ) );
1093 a->setShortcut (Qt::CTRL + Qt::Key_B + Qt::SHIFT);
1094 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
1095 a->setEnabled (false);
1097 formatMenu->addAction (a);
1098 actionListBranches.append(a);
1099 actionFormatColorSubtree=a;
1101 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
1102 a->setStatusTip ( tr( "Color Subtree" ));
1103 a->setShortcut (Qt::CTRL + Qt::Key_B); // Color subtree
1104 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
1105 a->setEnabled (false);
1106 formatMenu->addAction (a);
1108 actionListBranches.append(a);
1109 actionFormatColorSubtree=a;
1111 formatMenu->addSeparator();
1112 actionGroupFormatLinkStyles=new QActionGroup ( this);
1113 actionGroupFormatLinkStyles->setExclusive (true);
1114 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
1115 a->setStatusTip (tr( "Line" ));
1116 a->setToggleAction(true);
1117 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
1118 formatMenu->addAction (a);
1119 actionFormatLinkStyleLine=a;
1120 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
1121 a->setStatusTip (tr( "Line" ));
1122 a->setToggleAction(true);
1123 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
1124 formatMenu->addAction (a);
1125 actionFormatLinkStyleParabel=a;
1126 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
1127 a->setStatusTip (tr( "PolyLine" ));
1128 a->setToggleAction(true);
1129 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
1130 formatMenu->addAction (a);
1131 actionFormatLinkStylePolyLine=a;
1132 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
1133 a->setStatusTip (tr( "PolyParabel" ) );
1134 a->setToggleAction(true);
1135 a->setChecked (true);
1136 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
1137 formatMenu->addAction (a);
1138 actionFormatLinkStylePolyParabel=a;
1140 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
1141 a->setStatusTip (tr( "Hide link" ));
1142 a->setToggleAction(true);
1143 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
1144 actionFormatHideLinkUnselected=a;
1146 formatMenu->addSeparator();
1147 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
1148 a->setStatusTip (tr( "Use same color for links and headings" ));
1149 a->setToggleAction(true);
1150 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
1151 formatMenu->addAction (a);
1152 actionFormatLinkColorHint=a;
1154 pix.fill (Qt::white);
1155 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
1156 a->setStatusTip (tr( "Set Link Color" ));
1157 formatMenu->addAction (a);
1158 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
1159 actionFormatLinkColor=a;
1161 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
1162 a->setStatusTip (tr( "Set Selection Color" ));
1163 formatMenu->addAction (a);
1164 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
1165 actionFormatSelectionColor=a;
1167 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
1168 a->setStatusTip (tr( "Set Background Color" ));
1169 formatMenu->addAction (a);
1170 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
1171 actionFormatBackColor=a;
1173 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
1174 a->setStatusTip (tr( "Set Background image" ));
1175 formatMenu->addAction (a);
1176 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
1177 actionFormatBackImage=a;
1181 void Main::setupViewActions()
1183 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
1184 tb->setLabel( "View Actions" );
1185 tb->setObjectName ("viewTB");
1186 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
1190 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
1191 a->setStatusTip ( tr( "Zoom reset" ) );
1192 a->setShortcut (Qt::Key_Comma); // Reset zoom
1193 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1195 viewMenu->addAction (a);
1196 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
1198 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
1199 a->setStatusTip (tr( "Zoom in" ));
1200 a->setShortcut(Qt::Key_Plus);
1201 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1203 viewMenu->addAction (a);
1204 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
1206 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
1207 a->setStatusTip (tr( "Zoom out" ));
1208 a->setShortcut(Qt::Key_Minus);
1209 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1211 viewMenu->addAction (a);
1212 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1214 a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
1215 a->setStatusTip (tr( "Show selection" ));
1216 a->setShortcut(Qt::Key_Period);
1217 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1219 viewMenu->addAction (a);
1220 connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
1222 viewMenu->addSeparator();
1224 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
1225 a->setStatusTip ( tr( "Show Note Editor" ));
1226 a->setShortcut ( Qt::CTRL + Qt::Key_E ); // Toggle Note Editor
1227 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1228 a->setToggleAction(true);
1230 viewMenu->addAction (a);
1231 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1232 actionViewToggleNoteEditor=a;
1234 // Original icon is "category" from KDE
1235 a = new QAction(QPixmap(iconPath+"treeeditor.png"), tr( "Show tree editor","View action" ),this);
1236 a->setStatusTip ( tr( "Show tree editor" ));
1237 a->setShortcut ( Qt::CTRL + Qt::Key_T ); // Toggle Tree Editor // FIXME-3 originally: color subtree
1238 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1239 a->setToggleAction(true);
1241 viewMenu->addAction (a);
1242 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleTreeEditor() ) );
1243 actionViewToggleTreeEditor=a;
1245 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
1246 a->setStatusTip ( tr( "Show History Window" ));
1247 a->setShortcut ( Qt::CTRL + Qt::Key_H ); // Toggle history window
1248 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1249 a->setToggleAction(true);
1251 viewMenu->addAction (a);
1252 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1253 actionViewToggleHistoryWindow=a;
1255 viewMenu->addAction (actionViewTogglePropertyWindow);
1257 viewMenu->addSeparator();
1259 a = new QAction(tr( "Antialiasing","View action" ),this );
1260 a->setStatusTip ( tr( "Antialiasing" ));
1261 a->setToggleAction(true);
1262 a->setChecked (settings.value("/mainwindow/view/AntiAlias",true).toBool());
1263 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1264 viewMenu->addAction (a);
1265 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
1266 actionViewToggleAntiAlias=a;
1268 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1269 a->setStatusTip (a->text());
1270 a->setToggleAction(true);
1271 a->setChecked (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1272 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1273 viewMenu->addAction (a);
1274 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1275 actionViewToggleSmoothPixmapTransform=a;
1277 a = new QAction(tr( "Next Map","View action" ), this);
1278 a->setStatusTip (a->text());
1279 a->setShortcut (Qt::ALT + Qt::Key_N );
1280 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1281 viewMenu->addAction (a);
1282 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1284 a = new QAction (tr( "Previous Map","View action" ), this );
1285 a->setStatusTip (a->text());
1286 a->setShortcut (Qt::ALT + Qt::Key_P );
1287 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1288 viewMenu->addAction (a);
1289 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1293 void Main::setupModeActions()
1295 //QPopupMenu *menu = new QPopupMenu( this );
1296 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1298 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1299 tb->setObjectName ("modesTB");
1301 actionGroupModModes=new QActionGroup ( this);
1302 actionGroupModModes->setExclusive (true);
1303 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1304 a->setShortcut (Qt::Key_J);
1305 switchboard.addConnection(a,tr("Modes","Shortcut group"));
1306 a->setStatusTip ( tr( "Use modifier to color branches" ));
1307 a->setToggleAction(true);
1309 a->setChecked(true);
1310 actionModModeColor=a;
1312 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1313 a->setShortcut( Qt::Key_K);
1314 switchboard.addConnection(a,tr("Modes","Shortcut group"));
1315 a->setStatusTip( tr( "Use modifier to copy" ));
1316 a->setToggleAction(true);
1318 actionModModeCopy=a;
1320 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1321 a->setShortcut (Qt::Key_L);
1322 switchboard.addConnection(a,tr("Modes","Shortcut group"));
1323 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1324 a->setToggleAction(true);
1326 actionModModeXLink=a;
1330 void Main::setupFlagActions()
1332 // Create System Flags
1335 Flag *flag=new Flag(flagsPath+"flag-note.png");
1336 setupFlag (flag,tb,"system-note",tr("Note","SystemFlag"));
1338 flag=new Flag(flagsPath+"flag-url.png");
1339 setupFlag (flag,tb,"system-url",tr("URL to Document ","SystemFlag"));
1341 flag=new Flag(flagsPath+"flag-url-bugzilla-novell.png");
1342 setupFlag (flag,tb,"system-url-bugzilla-novell",tr("URL to Bugzilla ","SystemFlag"));
1344 flag=new Flag(flagsPath+"flag-vymlink.png");
1345 setupFlag (flag,tb,"system-vymLink",tr("Link to another vym map","SystemFlag"));
1347 flag=new Flag(flagsPath+"flag-scrolled-right.png");
1348 setupFlag (flag,tb,"system-scrolledright",tr("subtree is scrolled","SystemFlag"));
1350 flag=new Flag(flagsPath+"flag-tmpUnscrolled-right.png");
1351 setupFlag (flag,tb,"system-tmpUnscrolledRight",tr("subtree is temporary scrolled","SystemFlag"));
1353 flag=new Flag(flagsPath+"flag-hideexport.png");
1354 setupFlag (flag,tb,"system-hideInExport",tr("Hide object in exported maps","SystemFlag"));
1356 // Create Standard Flags
1357 tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1358 tb->setObjectName ("standardFlagTB");
1359 standardFlagsMaster->setToolBar (tb);
1361 flag=new Flag(flagsPath+"flag-exclamationmark.png");
1362 flag->setGroup("standard-mark");
1363 setupFlag (flag,tb,"exclamationmark",tr("Take care!","Standardflag"));
1365 flag=new Flag(flagsPath+"flag-questionmark.png");
1366 flag->setGroup("standard-mark");
1367 setupFlag (flag,tb,"questionmark",tr("Really?","Standardflag"));
1369 flag=new Flag(flagsPath+"flag-hook-green.png");
1370 flag->setGroup("standard-status");
1371 setupFlag (flag,tb,"hook-green",tr("Status - ok,done","Standardflag"));
1373 flag=new Flag(flagsPath+"flag-wip.png");
1374 flag->setGroup("standard-status");
1375 setupFlag (flag,tb,"wip",tr("Status - work in progress","Standardflag"));
1377 flag=new Flag(flagsPath+"flag-cross-red.png");
1378 flag->setGroup("standard-status");
1379 setupFlag (flag,tb,"cross-red",tr("Status - missing, not started","Standardflag"));
1382 flag=new Flag(flagsPath+"flag-stopsign.png");
1383 setupFlag (flag,tb,"stopsign",tr("This won't work!","Standardflag"));
1385 flag=new Flag(flagsPath+"flag-smiley-good.png");
1386 flag->setGroup("standard-smiley");
1387 setupFlag (flag,tb,"smiley-good",tr("Good","Standardflag"));
1389 flag=new Flag(flagsPath+"flag-smiley-sad.png");
1390 flag->setGroup("standard-smiley");
1391 setupFlag (flag,tb,"smiley-sad",tr("Bad","Standardflag"));
1393 flag=new Flag(flagsPath+"flag-smiley-omg.png");
1394 flag->setGroup("standard-smiley");
1395 setupFlag (flag,tb,"smiley-omb",tr("Oh no!","Standardflag"));
1396 // Original omg.png (in KDE emoticons)
1399 flag=new Flag(flagsPath+"flag-kalarm.png");
1400 setupFlag (flag,tb,"clock",tr("Time critical","Standardflag"));
1402 flag=new Flag(flagsPath+"flag-phone.png");
1403 setupFlag (flag,tb,"phone",tr("Call...","Standardflag"));
1405 flag=new Flag(flagsPath+"flag-lamp.png");
1406 setupFlag (flag,tb,"lamp",tr("Idea!","Standardflag"));
1408 flag=new Flag(flagsPath+"flag-arrow-up.png");
1409 flag->setGroup("standard-arrow");
1410 setupFlag (flag,tb,"arrow-up",tr("Important","Standardflag"));
1412 flag=new Flag(flagsPath+"flag-arrow-down.png");
1413 flag->setGroup("standard-arrow");
1414 setupFlag (flag,tb,"arrow-down",tr("Unimportant","Standardflag"));
1416 flag=new Flag(flagsPath+"flag-arrow-2up.png");
1417 flag->setGroup("standard-arrow");
1418 setupFlag (flag,tb,"2arrow-up",tr("Very important!","Standardflag"));
1420 flag=new Flag(flagsPath+"flag-arrow-2down.png");
1421 flag->setGroup("standard-arrow");
1422 setupFlag (flag,tb,"2arrow-down",tr("Very unimportant!","Standardflag"));
1425 flag=new Flag(flagsPath+"flag-thumb-up.png");
1426 flag->setGroup("standard-thumb");
1427 setupFlag (flag,tb,"thumb-up",tr("I like this","Standardflag"));
1429 flag=new Flag(flagsPath+"flag-thumb-down.png");
1430 flag->setGroup("standard-thumb");
1431 setupFlag (flag,tb,"thumb-down",tr("I do not like this","Standardflag"));
1434 flag=new Flag(flagsPath+"flag-rose.png");
1435 setupFlag (flag,tb,"rose",tr("Rose","Standardflag"));
1437 flag=new Flag(flagsPath+"flag-heart.png");
1438 setupFlag (flag,tb,"heart",tr("I just love...","Standardflag"));
1440 flag=new Flag(flagsPath+"flag-present.png");
1441 setupFlag (flag,tb,"present",tr("Surprise!","Standardflag"));
1443 flag=new Flag(flagsPath+"flag-flash.png");
1444 setupFlag (flag,tb,"flash",tr("Dangerous","Standardflag"));
1446 // Original: xsldbg_output.png
1447 flag=new Flag(flagsPath+"flag-info.png");
1448 setupFlag (flag,tb,"info",tr("Info","Standardflag"));
1450 // Original khelpcenter.png
1451 flag=new Flag(flagsPath+"flag-lifebelt.png");
1452 setupFlag (flag,tb,"lifebelt",tr("This will help","Standardflag"));
1455 flag=new Flag(flagsPath+"freemind/warning.png");
1456 flag->setVisible(false);
1457 setupFlag (flag,tb, "freemind-warning",tr("Important","Freemind-Flag"));
1459 for (int i=1; i<8; i++)
1461 flag=new Flag(flagsPath+QString("freemind/priority-%1.png").arg(i));
1462 flag->setVisible(false);
1463 flag->setGroup ("Freemind-priority");
1464 setupFlag (flag,tb, QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
1467 flag=new Flag(flagsPath+"freemind/back.png");
1468 flag->setVisible(false);
1469 setupFlag (flag,tb,"freemind-back",tr("Back","Freemind-Flag"));
1471 flag=new Flag(flagsPath+"freemind/forward.png");
1472 flag->setVisible(false);
1473 setupFlag (flag,tb,"freemind-forward",tr("forward","Freemind-Flag"));
1475 flag=new Flag(flagsPath+"freemind/attach.png");
1476 flag->setVisible(false);
1477 setupFlag (flag,tb,"freemind-attach",tr("Look here","Freemind-Flag"));
1479 flag=new Flag(flagsPath+"freemind/clanbomber.png");
1480 flag->setVisible(false);
1481 setupFlag (flag,tb,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
1483 flag=new Flag(flagsPath+"freemind/desktopnew.png");
1484 flag->setVisible(false);
1485 setupFlag (flag,tb,"freemind-desktopnew",tr("Don't flagrget","Freemind-Flag"));
1487 flag=new Flag(flagsPath+"freemind/flag.png");
1488 flag->setVisible(false);
1489 setupFlag (flag,tb,"freemind-flag",tr("Flag","Freemind-Flag"));
1492 flag=new Flag(flagsPath+"freemind/gohome.png");
1493 flag->setVisible(false);
1494 setupFlag (flag,tb,"freemind-gohome",tr("Home","Freemind-Flag"));
1496 flag=new Flag(flagsPath+"freemind/kaddressbook.png");
1497 flag->setVisible(false);
1498 setupFlag (flag,tb,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
1500 flag=new Flag(flagsPath+"freemind/knotify.png");
1501 flag->setVisible(false);
1502 setupFlag (flag,tb,"freemind-knotify",tr("Music","Freemind-Flag"));
1504 flag=new Flag(flagsPath+"freemind/korn.png");
1505 flag->setVisible(false);
1506 setupFlag (flag,tb,"freemind-korn",tr("Mailbox","Freemind-Flag"));
1508 flag=new Flag(flagsPath+"freemind/mail.png");
1509 flag->setVisible(false);
1510 setupFlag (flag,tb,"freemind-mail",tr("Maix","Freemind-Flag"));
1512 flag=new Flag(flagsPath+"freemind/password.png");
1513 flag->setVisible(false);
1514 setupFlag (flag,tb,"freemind-password",tr("Password","Freemind-Flag"));
1516 flag=new Flag(flagsPath+"freemind/pencil.png");
1517 flag->setVisible(false);
1518 setupFlag (flag,tb,"freemind-pencil",tr("To be improved","Freemind-Flag"));
1520 flag=new Flag(flagsPath+"freemind/stop.png");
1521 flag->setVisible(false);
1522 setupFlag (flag,tb,"freemind-stop",tr("Stop","Freemind-Flag"));
1524 flag=new Flag(flagsPath+"freemind/wizard.png");
1525 flag->setVisible(false);
1526 setupFlag (flag,tb,"freemind-wizard",tr("Magic","Freemind-Flag"));
1528 flag=new Flag(flagsPath+"freemind/xmag.png");
1529 flag->setVisible(false);
1530 setupFlag (flag,tb,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
1532 flag=new Flag(flagsPath+"freemind/bell.png");
1533 flag->setVisible(false);
1534 setupFlag (flag,tb,"freemind-bell",tr("Reminder","Freemind-Flag"));
1536 flag=new Flag(flagsPath+"freemind/bookmark.png");
1537 flag->setVisible(false);
1538 setupFlag (flag,tb,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
1540 flag= new Flag(flagsPath+"freemind/penguin.png");
1541 flag->setVisible(false);
1542 setupFlag (flag,tb,"freemind-penguin",tr("Linux","Freemind-Flag"));
1544 flag=new Flag (flagsPath+"freemind/licq.png");
1545 flag->setVisible(false);
1546 setupFlag (flag,tb,"freemind-licq",tr("Sweet","Freemind-Flag"));
1549 void Main::setupFlag (Flag *flag, QToolBar *tb, const QString &name, const QString &tooltip)
1551 flag->setName(name);
1552 flag->setToolTip (tooltip);
1556 a=new QAction (flag->getPixmap(),name,this);
1559 flag->setAction (a);
1560 a->setVisible (flag->isVisible());
1561 a->setCheckable(true);
1562 a->setObjectName(name);
1563 a->setToolTip(tooltip);
1564 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1565 standardFlagsMaster->addFlag (flag);
1569 systemFlagsMaster->addFlag (flag);
1574 void Main::setupNetworkActions()
1576 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1578 QMenu *netMenu = menuBar()->addMenu( "Network" );
1582 a = new QAction( "Start TCPserver for MapEditor",this);
1583 //a->setStatusTip ( "Set application to open pdf files"));
1584 //a->setShortcut ( Qt::ALT + Qt::Key_T ); //New TCP server
1585 switchboard.addConnection(a,tr("Network shortcuts","Shortcut group"));
1586 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1587 netMenu->addAction (a);
1589 a = new QAction( "Connect MapEditor to server",this);
1590 //a->setStatusTip ( "Set application to open pdf files"));
1591 a->setShortcut ( Qt::ALT + Qt::Key_C ); // Connect to server
1592 switchboard.addConnection(a,tr("Network shortcuts","Shortcut group"));
1593 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1594 netMenu->addAction (a);
1598 void Main::setupSettingsActions()
1600 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1604 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1605 a->setStatusTip ( tr( "Set application to open pdf files"));
1606 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1607 settingsMenu->addAction (a);
1609 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1610 a->setStatusTip( tr( "Set application to open external links"));
1611 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1612 settingsMenu->addAction (a);
1614 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1615 a->setStatusTip( tr( "Set path for macros"));
1616 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1617 settingsMenu->addAction (a);
1619 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1620 a->setStatusTip( tr( "Set number of undo levels"));
1621 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1622 settingsMenu->addAction (a);
1624 settingsMenu->addSeparator();
1626 a = new QAction( tr( "Autosave","Settings action"), this);
1627 a->setStatusTip( tr( "Autosave"));
1628 a->setToggleAction(true);
1629 a->setChecked ( settings.value ("/mainwindow/autosave/use",false).toBool());
1630 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1631 settingsMenu->addAction (a);
1632 actionSettingsAutosaveToggle=a;
1634 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1635 a->setStatusTip( tr( "Autosave time"));
1636 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1637 settingsMenu->addAction (a);
1638 actionSettingsAutosaveTime=a;
1640 a = new QAction( tr( "Write backup file on save","Settings action"), this);
1641 a->setStatusTip( tr( "Write backup file on save"));
1642 a->setToggleAction(true);
1643 a->setChecked ( settings.value ("/mainwindow/writeBackupFile",false).toBool());
1644 connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) );
1645 settingsMenu->addAction (a);
1646 actionSettingsWriteBackupFile=a;
1648 settingsMenu->addSeparator();
1650 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1651 a->setStatusTip( tr( "Edit branch after adding it" ));
1652 a->setToggleAction(true);
1653 a->setChecked ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1654 settingsMenu->addAction (a);
1655 actionSettingsAutoEditNewBranch=a;
1657 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1658 a->setStatusTip( tr( "Select branch after adding it" ));
1659 a->setToggleAction(true);
1660 a->setChecked ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1661 settingsMenu->addAction (a);
1662 actionSettingsAutoSelectNewBranch=a;
1664 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1665 a->setStatusTip( tr( "Select heading before editing" ));
1666 a->setToggleAction(true);
1667 a->setChecked ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1668 settingsMenu->addAction (a);
1669 actionSettingsAutoSelectText=a;
1671 a= new QAction( tr( "Delete key","Settings action" ), this);
1672 a->setStatusTip( tr( "Delete key for deleting branches" ));
1673 a->setToggleAction(true);
1674 a->setChecked ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1675 settingsMenu->addAction (a);
1676 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1677 actionSettingsUseDelKey=a;
1679 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1680 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1681 a->setToggleAction(true);
1682 a->setChecked ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1683 settingsMenu->addAction (a);
1684 actionSettingsUseFlagGroups=a;
1686 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1687 a->setStatusTip( tr( "Use hide flag during exports " ));
1688 a->setToggleAction(true);
1689 a->setChecked ( settings.value ("/export/useHideExport",true).toBool() );
1690 settingsMenu->addAction (a);
1691 actionSettingsUseHideExport=a;
1693 settingsMenu->addSeparator();
1695 a = new QAction( tr( "Animation","Settings action"), this);
1696 a->setStatusTip( tr( "Animation"));
1697 a->setToggleAction(true);
1698 a->setChecked (settings.value("/animation/use",true).toBool() );
1699 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) );
1700 settingsMenu->addAction (a);
1701 actionSettingsUseAnimation=a;
1703 a = new QAction( tr( "Automatic layout","Settings action"), this);
1704 a->setStatusTip( tr( "Automatic layout"));
1705 a->setToggleAction(true);
1706 a->setChecked ( settings.value ("/mainwindow/autoLayout/use",true).toBool());
1707 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutoLayoutToggle() ) );
1708 settingsMenu->addAction (a);
1709 actionSettingsAutoLayoutToggle=a;
1714 void Main::setupTestActions()
1716 QMenu *testMenu = menuBar()->addMenu( tr( "Test" ));
1719 a = new QAction( "Test function 1" , this);
1720 a->setStatusTip( "Call test function 1" );
1721 a->setShortcut (Qt::SHIFT + Qt::Key_T); // Test function 1
1722 switchboard.addConnection(a,tr("Test shortcuts","Shortcut group"));
1723 testMenu->addAction (a);
1724 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1726 a = new QAction( "Test function 2" , this);
1727 a->setStatusTip( "Call test function 2" );
1728 a->setShortcut (Qt::ALT + Qt::Key_T); // Test function 2
1729 switchboard.addConnection(a,tr("Test shortcuts","Shortcut group"));
1730 testMenu->addAction (a);
1731 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1733 a = new QAction( "Command" , this);
1734 a->setStatusTip( "Enter command to call in editor" );
1735 switchboard.addConnection(a,tr("Test shortcuts","Shortcut group"));
1736 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1737 testMenu->addAction (a);
1741 void Main::setupHelpActions()
1743 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1746 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1747 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1748 switchboard.addConnection(a,tr("Help shortcuts","Shortcut group"));
1749 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1750 helpMenu->addAction (a);
1752 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1753 a->setStatusTip( tr( "Open VYM example maps " ));
1754 switchboard.addConnection(a,tr("Help shortcuts","Shortcut group"));
1755 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1756 helpMenu->addAction (a);
1758 a = new QAction( tr( "About VYM","Help action" ), this);
1759 a->setStatusTip( tr( "About VYM")+vymName);
1760 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1761 helpMenu->addAction (a);
1763 a = new QAction( tr( "About QT","Help action" ), this);
1764 a->setStatusTip( tr( "Information about QT toolkit" ));
1765 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1766 helpMenu->addAction (a);
1770 void Main::setupContextMenus()
1772 // Context Menu for branch or mapcenter
1773 branchContextMenu =new QMenu (this);
1774 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1775 branchContextMenu->addSeparator();
1778 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1779 branchAddContextMenu->addAction (actionPaste );
1780 branchAddContextMenu->addAction ( actionAddMapCenter );
1781 branchAddContextMenu->addAction ( actionAddBranch );
1782 branchAddContextMenu->addAction ( actionAddBranchBefore );
1783 branchAddContextMenu->addAction ( actionAddBranchAbove);
1784 branchAddContextMenu->addAction ( actionAddBranchBelow );
1785 branchAddContextMenu->addSeparator();
1786 branchAddContextMenu->addAction ( actionImportAdd );
1787 branchAddContextMenu->addAction ( actionImportReplace );
1790 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1791 branchRemoveContextMenu->addAction (actionCut);
1792 branchRemoveContextMenu->addAction ( actionDelete );
1793 branchRemoveContextMenu->addAction ( actionDeleteKeepChildren );
1794 branchRemoveContextMenu->addAction ( actionDeleteChildren );
1797 actionSaveBranch->addTo( branchContextMenu );
1798 actionFileNewCopy->addTo (branchContextMenu );
1799 actionDetach->addTo (branchContextMenu );
1801 branchContextMenu->addSeparator();
1802 branchContextMenu->addAction ( actionLoadImage);
1803 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1804 branchContextMenu->addAction ( actionAddAttribute);
1806 // Submenu for Links (URLs, vymLinks)
1807 branchLinksContextMenu =new QMenu (this);
1809 branchContextMenu->addSeparator();
1810 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1811 branchLinksContextMenu->addAction ( actionOpenURL );
1812 branchLinksContextMenu->addAction ( actionOpenURLTab );
1813 branchLinksContextMenu->addAction ( actionOpenMultipleVisURLTabs );
1814 branchLinksContextMenu->addAction ( actionOpenMultipleURLTabs );
1815 branchLinksContextMenu->addAction ( actionURL );
1816 branchLinksContextMenu->addAction ( actionLocalURL );
1817 branchLinksContextMenu->addAction ( actionHeading2URL );
1818 branchLinksContextMenu->addAction ( actionBugzilla2URL );
1819 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1821 branchLinksContextMenu->addAction ( actionGetBugzillaData );
1822 branchLinksContextMenu->addAction ( actionFATE2URL );
1824 branchLinksContextMenu->addSeparator();
1825 branchLinksContextMenu->addAction ( actionOpenVymLink );
1826 branchLinksContextMenu->addAction ( actionOpenMultipleVymLinks );
1827 branchLinksContextMenu->addAction ( actionVymLink );
1828 branchLinksContextMenu->addAction ( actionDeleteVymLink );
1831 // Context Menu for XLinks in a branch menu
1832 // This will be populated "on demand" in MapEditor::updateActions
1833 branchContextMenu->addSeparator();
1834 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1835 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1838 // Context menu for floatimage
1839 floatimageContextMenu =new QMenu (this);
1840 QAction *a= new QAction (tr ("Save image","Context action"),this);
1841 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1842 floatimageContextMenu->addAction (a);
1844 floatimageContextMenu->addSeparator();
1845 actionCopy->addTo( floatimageContextMenu );
1846 actionCut->addTo( floatimageContextMenu );
1848 floatimageContextMenu->addSeparator();
1849 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1852 // Context menu for canvas
1853 canvasContextMenu =new QMenu (this);
1854 actionAddMapCenter->addTo( canvasContextMenu );
1855 actionMapInfo->addTo( canvasContextMenu );
1856 canvasContextMenu->insertSeparator();
1857 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1858 canvasContextMenu->insertSeparator();
1859 actionFormatLinkColorHint->addTo( canvasContextMenu );
1860 actionFormatLinkColor->addTo( canvasContextMenu );
1861 actionFormatSelectionColor->addTo( canvasContextMenu );
1862 actionFormatBackColor->addTo( canvasContextMenu );
1863 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME-4 makes vym too slow: postponed for later version
1865 // Menu for last opened files
1867 for (int i = 0; i < MaxRecentFiles; ++i)
1869 recentFileActions[i] = new QAction(this);
1870 recentFileActions[i]->setVisible(false);
1871 fileLastMapsMenu->addAction(recentFileActions[i]);
1872 connect(recentFileActions[i], SIGNAL(triggered()),
1873 this, SLOT(fileLoadRecent()));
1875 setupRecentMapsMenu();
1878 void Main::setupRecentMapsMenu()
1880 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1882 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1884 for (int i = 0; i < numRecentFiles; ++i) {
1885 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1886 recentFileActions[i]->setText(text);
1887 recentFileActions[i]->setData(files[i]);
1888 recentFileActions[i]->setVisible(true);
1890 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1891 recentFileActions[j]->setVisible(false);
1894 void Main::setupMacros()
1896 for (int i = 0; i <= 11; i++)
1898 macroActions[i] = new QAction(this);
1899 macroActions[i]->setData(i);
1900 addAction (macroActions[i]);
1901 //switchboard.addConnection(macroActions[i],tr("Macro shortcuts","Shortcut group"));
1902 connect(macroActions[i], SIGNAL(triggered()),
1903 this, SLOT(callMacro()));
1905 macroActions[0]->setShortcut ( Qt::Key_F1 );
1906 macroActions[1]->setShortcut ( Qt::Key_F2 );
1907 macroActions[2]->setShortcut ( Qt::Key_F3 );
1908 macroActions[3]->setShortcut ( Qt::Key_F4 );
1909 macroActions[4]->setShortcut ( Qt::Key_F5 );
1910 macroActions[5]->setShortcut ( Qt::Key_F6 );
1911 macroActions[6]->setShortcut ( Qt::Key_F7 );
1912 macroActions[7]->setShortcut ( Qt::Key_F8 );
1913 macroActions[8]->setShortcut ( Qt::Key_F9 );
1914 macroActions[9]->setShortcut ( Qt::Key_F10 );
1915 macroActions[10]->setShortcut ( Qt::Key_F11 );
1916 macroActions[11]->setShortcut ( Qt::Key_F12 );
1919 void Main::hideEvent (QHideEvent * )
1921 if (!textEditor->isMinimized() ) textEditor->hide();
1924 void Main::showEvent (QShowEvent * )
1926 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1930 MapEditor* Main::currentMapEditor() const
1932 if ( tabWidget->currentPage())
1933 return vymViews.at(tabWidget->currentIndex())->getMapEditor();
1937 uint Main::currentModelID() const
1940 return currentModel()->getID();
1944 VymModel* Main::currentModel() const
1946 if ( tabWidget->currentPage())
1947 return vymViews.at(tabWidget->currentIndex())->getModel();
1951 VymModel* Main::getModel(uint id) const
1954 for (int i=0; i<vymViews.count();i++)
1955 if (vymViews.at(i)->getModel()->getID()==id)
1956 return vymViews.at(i)->getModel();
1961 void Main::editorChanged(QWidget *)
1963 // Unselect all possibly selected objects
1964 // (Important to update note editor)
1966 for (int i=0;i<=tabWidget->count() -1;i++)
1968 m= vymViews.at(i)->getModel();
1969 if (m) m->unselect();
1972 if (m) m->reselect();
1974 // Update actions to in menus and toolbars according to editor
1978 void Main::fileNew()
1980 VymModel *vm=new VymModel;
1982 /////////////////////////////////////
1983 // new ModelTest(vm, this); //FIXME-3
1984 /////////////////////////////////////
1986 VymView *vv=new VymView (vm);
1987 vymViews.append (vv);
1988 tabWidget->addTab (vv,tr("unnamed","MainWindow: name for new and empty file"));
1989 tabWidget->setCurrentIndex (vymViews.count() );
1992 // Create MapCenter for empty map
1996 // For the very first map we do not have flagrows yet...
2000 void Main::fileNewCopy()
2002 QString fn="unnamed";
2003 VymModel *srcModel=currentModel();
2008 VymModel *dstModel=vymViews.last()->getModel();
2009 dstModel->select("mc:");
2010 dstModel->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
2014 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
2016 ErrorCode err=success;
2018 // fn is usually the archive, mapfile the file after uncompressing
2021 // Make fn absolute (needed for unzip)
2022 fn=QDir (fn).absPath();
2028 // Check, if map is already loaded
2030 while (i<=tabWidget->count() -1)
2032 if (vymViews.at(i)->getModel()->getFilePath() == fn)
2034 // Already there, ask for confirmation
2035 QMessageBox mb( vymName,
2036 tr("The map %1\nis already opened."
2037 "Opening the same map in multiple editors may lead \n"
2038 "to confusion when finishing working with vym."
2039 "Do you want to").arg(fn),
2040 QMessageBox::Warning,
2041 QMessageBox::Yes | QMessageBox::Default,
2042 QMessageBox::Cancel | QMessageBox::Escape,
2043 QMessageBox::NoButton);
2044 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
2045 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2048 case QMessageBox::Yes:
2049 // end loop and load anyway
2050 i=tabWidget->count();
2052 case QMessageBox::Cancel:
2062 int tabIndex=tabWidget->currentPageIndex();
2065 if ( !fn.isEmpty() )
2067 vm = currentModel();
2068 // Check first, if mapeditor exists
2069 // If it is not default AND we want a new map,
2070 // create a new mapeditor in a new tab
2071 if ( lmode==NewMap && (!vm || !vm->isDefault() ) )
2074 VymView *vv=new VymView (vm);
2075 vymViews.append (vv);
2076 tabWidget->addTab (vv,fn);
2077 tabIndex=tabWidget->count()-1;
2078 tabWidget->setCurrentPage (tabIndex);
2082 // Check, if file exists (important for creating new files
2083 // from command line
2084 if (!QFile(fn).exists() )
2086 QMessageBox mb( vymName,
2087 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
2088 QMessageBox::Question,
2090 QMessageBox::Cancel | QMessageBox::Default,
2091 QMessageBox::NoButton );
2093 mb.setButtonText( QMessageBox::Yes, tr("Create"));
2094 mb.setButtonText( QMessageBox::No, tr("Cancel"));
2097 case QMessageBox::Yes:
2099 currentMapEditor()->getModel()->setFilePath(fn);
2100 tabWidget->setTabText (tabIndex,
2101 currentMapEditor()->getModel()->getFileName() );
2102 statusBar()->message( "Created " + fn , statusbarTime );
2105 case QMessageBox::Cancel:
2106 // don't create new map
2107 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
2114 //tabWidget->currentPage() won't be NULL here, because of above...
2115 tabWidget->setCurrentIndex (tabIndex);
2116 //FIXME-3 no me anymore... me->viewport()->setFocus();
2120 // Save existing filename in case we import
2121 QString fn_org=vm->getFilePath();
2123 // Finally load map into mapEditor
2124 vm->setFilePath (fn);
2125 err=vm->load(fn,lmode,ftype);
2127 // Restore old (maybe empty) filepath, if this is an import
2129 vm->setFilePath (fn_org);
2132 // Finally check for errors and go home
2135 if (lmode==NewMap) fileCloseMap();
2136 statusBar()->message( "Could not load " + fn, statusbarTime );
2141 vm->setFilePath (fn);
2142 tabWidget->setTabText (tabIndex, vm->getFileName());
2143 if (!isInTmpDir (fn))
2145 // Only append to lastMaps if not loaded from a tmpDir
2146 // e.g. imported bookmarks are in a tmpDir
2147 addRecentMap(vm->getFilePath() );
2149 actionFilePrint->setEnabled (true);
2151 statusBar()->message( "Loaded " + fn, statusbarTime );
2158 void Main::fileLoad(const LoadMode &lmode)
2160 QStringList filters;
2161 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
2162 QFileDialog *fd=new QFileDialog( this);
2163 fd->setDir (lastFileDir);
2164 fd->setFileMode (QFileDialog::ExistingFiles);
2165 fd->setFilters (filters);
2169 fd->setCaption(vymName+ " - " +tr("Load vym map"));
2172 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
2175 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
2181 if ( fd->exec() == QDialog::Accepted )
2183 lastFileDir=fd->directory().path();
2184 QStringList flist = fd->selectedFiles();
2185 QStringList::Iterator it = flist.begin();
2187 progressCounter=flist.count();
2188 progressCounterTotal=flist.count();
2189 while( it != flist.end() )
2192 fileLoad(*it, lmode);
2199 void Main::fileLoad()
2204 void Main::fileLoadRecent()
2206 QAction *action = qobject_cast<QAction *>(sender());
2208 fileLoad (action->data().toString(), NewMap);
2211 void Main::addRecentMap (const QString &fileName)
2214 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
2215 files.removeAll(fileName);
2216 files.prepend(fileName);
2217 while (files.size() > MaxRecentFiles)
2220 settings.setValue("/mainwindow/recentFileList", files);
2222 setupRecentMapsMenu();
2225 void Main::fileSave(VymModel *m, const SaveMode &savemode)
2229 if ( m->getFilePath().isEmpty() )
2231 // We have no filepath yet,
2232 // call fileSaveAs() now, this will call fileSave()
2234 // First switch to editor
2235 //FIXME-3 needed??? tabWidget->setCurrentWidget (m->getMapEditor());
2236 fileSaveAs(savemode);
2239 if (m->save (savemode)==success)
2241 statusBar()->message(
2242 tr("Saved %1").arg(m->getFilePath()),
2244 addRecentMap (m->getFilePath() );
2246 statusBar()->message(
2247 tr("Couldn't save ").arg(m->getFilePath()),
2251 void Main::fileSave()
2253 fileSave (currentModel(), CompleteMap);
2256 void Main::fileSave(VymModel *m)
2258 fileSave (m,CompleteMap);
2261 void Main::fileSaveAs(const SaveMode& savemode)
2265 if (currentMapEditor())
2267 if (savemode==CompleteMap)
2268 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2270 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2271 if ( !fn.isEmpty() )
2273 // Check for existing file
2274 if (QFile (fn).exists())
2276 QMessageBox mb( vymName,
2277 tr("The file %1\nexists already. Do you want to").arg(fn),
2278 QMessageBox::Warning,
2279 QMessageBox::Yes | QMessageBox::Default,
2280 QMessageBox::Cancel | QMessageBox::Escape,
2281 QMessageBox::NoButton);
2282 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2283 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2286 case QMessageBox::Yes:
2289 case QMessageBox::Cancel:
2296 // New file, add extension to filename, if missing
2297 // This is always .vym or .vyp, depending on savemode
2298 if (savemode==CompleteMap)
2300 if (!fn.contains (".vym") && !fn.contains (".xml"))
2304 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2313 VymModel *m=currentModel();
2315 fileSave(m, savemode);
2317 // Set name of tab, assuming current tab is the one we just saved
2318 if (savemode==CompleteMap)
2319 tabWidget->setTabText (tabWidget->currentIndex(), m->getFileName() );
2325 void Main::fileSaveAs()
2327 fileSaveAs (CompleteMap);
2330 void Main::fileImportKDE3Bookmarks()
2332 ImportKDE3Bookmarks im;
2334 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2335 currentMapEditor()->getModel()->setFilePath ("");
2338 void Main::fileImportKDE4Bookmarks()
2340 ImportKDE4Bookmarks im;
2342 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2343 currentMapEditor()->getModel()->setFilePath ("");
2346 void Main::fileImportFirefoxBookmarks()
2348 Q3FileDialog *fd=new Q3FileDialog( this);
2349 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2350 fd->setMode (Q3FileDialog::ExistingFiles);
2351 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2352 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2355 if ( fd->exec() == QDialog::Accepted )
2357 ImportFirefoxBookmarks im;
2358 QStringList flist = fd->selectedFiles();
2359 QStringList::Iterator it = flist.begin();
2360 while( it != flist.end() )
2363 if (im.transform() &&
2364 aborted!=fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2365 currentMapEditor() )
2366 currentMapEditor()->getModel()->setFilePath ("");
2373 void Main::fileImportFreemind()
2375 QStringList filters;
2376 filters <<"Freemind map (*.mm)"<<"All files (*)";
2377 QFileDialog *fd=new QFileDialog( this);
2378 fd->setDir (lastFileDir);
2379 fd->setFileMode (QFileDialog::ExistingFiles);
2380 fd->setFilters (filters);
2381 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2385 if ( fd->exec() == QDialog::Accepted )
2387 lastFileDir=fd->directory().path();
2388 QStringList flist = fd->selectedFiles();
2389 QStringList::Iterator it = flist.begin();
2390 while( it != flist.end() )
2393 if ( fileLoad (fn,NewMap, FreemindMap) )
2395 currentMapEditor()->getModel()->setFilePath ("");
2404 void Main::fileImportMM()
2408 Q3FileDialog *fd=new Q3FileDialog( this);
2409 fd->setDir (lastFileDir);
2410 fd->setMode (Q3FileDialog::ExistingFiles);
2411 fd->addFilter ("Mind Manager (*.mmap)");
2412 fd->setCaption(tr("Import")+" "+"Mind Manager");
2415 if ( fd->exec() == QDialog::Accepted )
2417 lastFileDir=fd->dirPath();
2418 QStringList flist = fd->selectedFiles();
2419 QStringList::Iterator it = flist.begin();
2420 while( it != flist.end() )
2423 if (im.transform() &&
2424 success==fileLoad (im.getTransformedFile(),NewMap) &&
2425 currentMapEditor() )
2426 currentMapEditor()->getModel()->setFilePath ("");
2433 void Main::fileImportDir()
2435 VymModel *m=currentModel();
2436 if (m) m->importDir();
2439 void Main::fileExportXML()
2441 VymModel *m=currentModel();
2442 if (m) m->exportXML();
2445 void Main::fileExportHTML()
2447 VymModel *m=currentModel();
2448 if (m) m->exportHTML();
2452 void Main::fileExportXHTML()
2454 VymModel *m=currentModel();
2455 if (m) m->exportXHTML();
2458 void Main::fileExportImage()
2460 VymModel *m=currentModel();
2461 if (m) m->exportImage();
2464 void Main::fileExportAO()
2466 VymModel *m=currentModel();
2467 if (m) m->exportAO();
2470 void Main::fileExportASCII()
2472 VymModel *m=currentModel();
2473 if (m) m->exportASCII();
2476 void Main::fileExportCSV() //FIXME-3 not scriptable yet
2478 VymModel *m=currentModel();
2483 ex.addFilter ("CSV (*.csv)");
2484 ex.setDir(lastImageDir);
2485 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2486 if (ex.execDialog() )
2488 m->setExportMode(true);
2490 m->setExportMode(false);
2495 void Main::fileExportLaTeX() //FIXME-3 not scriptable yet
2497 VymModel *m=currentModel();
2502 ex.addFilter ("Tex (*.tex)");
2503 ex.setDir(lastImageDir);
2504 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2505 if (ex.execDialog() )
2507 m->setExportMode(true);
2509 m->setExportMode(false);
2514 void Main::fileExportKDE3Bookmarks() //FIXME-3 not scriptable yet
2516 ExportKDE3Bookmarks ex;
2517 VymModel *m=currentModel();
2525 void Main::fileExportKDE4Bookmarks() //FIXME-3 not scriptable yet
2527 ExportKDE4Bookmarks ex;
2528 VymModel *m=currentModel();
2536 void Main::fileExportTaskjuggler() //FIXME-3 not scriptable yet
2538 ExportTaskjuggler ex;
2539 VymModel *m=currentModel();
2543 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2544 ex.setDir(lastImageDir);
2545 ex.addFilter ("Taskjuggler (*.tjp)");
2546 if (ex.execDialog() )
2548 m->setExportMode(true);
2550 m->setExportMode(false);
2555 void Main::fileExportOOPresentation() //FIXME-3 not scriptable yet
2557 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2558 // TODO add preview in dialog
2559 //ImagePreview *p =new ImagePreview (fd);
2560 //fd->setContentsPreviewEnabled( TRUE );
2561 //fd->setContentsPreview( p, p );
2562 //fd->setPreviewMode( QFileDialog::Contents );
2563 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2564 fd->setDir (QDir().current());
2565 if (fd->foundConfig())
2569 if ( fd->exec() == QDialog::Accepted )
2571 QString fn=fd->selectedFile();
2572 if (!fn.contains (".odp"))
2575 //lastImageDir=fn.left(fn.findRev ("/"));
2576 VymModel *m=currentModel();
2577 if (m) m->exportOOPresentation(fn,fd->selectedConfig());
2581 QMessageBox::warning(0,
2583 tr("Couldn't find configuration for export to Open Office\n"));
2587 void Main::fileCloseMap()
2589 VymModel *m=currentModel();
2592 if (m->hasChanged())
2594 QMessageBox mb( vymName,
2595 tr("The map %1 has been modified but not saved yet. Do you want to").arg(m->getFileName()),
2596 QMessageBox::Warning,
2597 QMessageBox::Yes | QMessageBox::Default,
2599 QMessageBox::Cancel | QMessageBox::Escape );
2600 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2601 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2604 case QMessageBox::Yes:
2606 fileSave(m, CompleteMap);
2608 case QMessageBox::No:
2609 // close without saving
2611 case QMessageBox::Cancel:
2616 // And here comes the segfault, because removeTab triggers
2617 // FIXME-3 currentChanged->Main::editorChanged -> updateActions and VM is not NULL yet...
2618 vymViews.removeAt (tabWidget->currentIndex() );
2619 tabWidget->removeTab (tabWidget->currentIndex() );
2621 // Remove mapEditor/model FIXME-3 Huh? seems to work now...
2622 // Better would be delete (me), but then we could have a Qt error:
2623 // "QObject: Do not delete object, 'MapEditor', during its event handler!"
2624 // So we only remove data now and call deconstructor when vym closes later
2625 // this needs to be moved to vymview... me->clear();
2626 // some model->clear is needed to free up memory ...
2628 delete (m->getMapEditor());
2635 void Main::filePrint()
2637 if (currentMapEditor())
2638 currentMapEditor()->print();
2641 void Main::fileExitVYM()
2643 // Check if one or more editors have changed
2645 for (i=0;i<=vymViews.count() -1;i++)
2647 // If something changed, ask what to do
2648 if (vymViews.at(i)->getModel()->hasChanged())
2650 tabWidget->setCurrentPage(i);
2651 QMessageBox mb( vymName,
2652 tr("This map is not saved yet. Do you want to"),
2653 QMessageBox::Warning,
2654 QMessageBox::Yes | QMessageBox::Default,
2656 QMessageBox::Cancel | QMessageBox::Escape );
2657 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2658 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2661 mb.setActiveWindow();
2662 switch( mb.exec() ) {
2663 case QMessageBox::Yes:
2664 // save (the changed editors) and exit
2665 fileSave(currentModel(), CompleteMap);
2667 case QMessageBox::No:
2668 // exit without saving
2670 case QMessageBox::Cancel:
2671 // don't save and don't exit
2675 } // loop over all MEs
2679 void Main::editUndo()
2681 VymModel *m=currentModel();
2685 void Main::editRedo()
2687 VymModel *m=currentModel();
2691 void Main::gotoHistoryStep (int i)
2693 VymModel *m=currentModel();
2694 if (m) m->gotoHistoryStep(i);
2697 void Main::editCopy()
2699 VymModel *m=currentModel();
2703 void Main::editPaste()
2705 VymModel *m=currentModel();
2709 void Main::editCut()
2711 VymModel *m=currentModel();
2715 void Main::editOpenFindWidget()
2717 if (!findWidget->isVisible())
2720 findWidget->setFocus();
2721 } else if (!findResultWidget->parentWidget()->isVisible())
2722 findResultWidget->parentWidget()->show();
2726 findResultWidget->parentWidget()->hide();
2730 void Main::editHideFindWidget()
2732 // findWidget hides itself, but we want
2733 // to have focus back at mapEditor usually
2734 MapEditor *me=currentMapEditor();
2735 if (me) me->setFocus();
2738 void Main::editFindNext(QString s)
2740 Qt::CaseSensitivity cs=Qt::CaseInsensitive;
2741 VymModel *m=currentModel();
2744 m->findAll (findResultWidget->getResultModel(),s,cs);
2746 BranchItem *bi=m->findText(s, cs);
2749 findWidget->setStatus (FindWidget::Success);
2752 findWidget->setStatus (FindWidget::Failed);
2756 void Main::editFindDuplicateURLs() //FIXME-4 feature: use FindResultWidget for display
2758 VymModel *m=currentModel();
2759 if (m) m->findDuplicateURLs();
2762 void Main::openTabs(QStringList urls)
2764 if (!urls.isEmpty())
2768 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2769 //qDebug ()<<"Services: "<<QDBusConnection::sessionBus().interface()->registeredServiceNames().value();
2770 if (*browserPID==0 ||
2771 (browser.contains("konqueror") &&
2772 !QDBusConnection::sessionBus().interface()->registeredServiceNames().value().contains (QString("org.kde.konqueror-%1").arg(*browserPID)))
2775 // Start a new browser, if there is not one running already or
2776 // if a previously started konqueror is gone.
2777 if (debug) cout <<"Main::openTabs no konqueror-"<<*browserPID<<" found\n";
2778 QString u=urls.takeFirst();
2780 QString workDir=QDir::currentDirPath();
2781 if (!QProcess::startDetached(browser,args,workDir,browserPID))
2783 // try to set path to browser
2784 QMessageBox::warning(0,
2786 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2787 tr("Please use Settings->")+tr("Set application to open an URL"));
2790 if (debug) cout << "Main::openTabs Started konqueror-"<<*browserPID<<endl;
2791 #if defined(Q_OS_WIN32)
2792 // There's no sleep in VCEE, replace it with Qt's QThread::wait().
2793 this->thread()->wait(3000);
2795 sleep (3); //FIXME-3 needed?
2799 if (browser.contains("konqueror"))
2801 for (int i=0; i<urls.size(); i++)
2804 // Try to open new tab in existing konqueror started previously by vym
2808 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2809 "konqueror-mainwindow#1"<<
2813 args<< QString("org.kde.konqueror-%1").arg(*browserPID)<<
2814 "/konqueror/MainWindow_1"<<
2818 if (debug) cout << "MainWindow::openURLs args="<<args.join(" ").toStdString()<<endl;
2819 if (!QProcess::startDetached ("qdbus",args))
2823 QMessageBox::warning(0,
2825 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2827 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2829 for (int i=0; i<urls.size(); i++)
2831 // Try to open new tab in firefox
2832 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2833 if (!QProcess::startDetached (browser,args))
2837 QMessageBox::warning(0,
2839 tr("Couldn't start %1 to open a new tab").arg(browser));
2842 QMessageBox::warning(0,
2844 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2848 void Main::editOpenURL()
2851 VymModel *m=currentModel();
2854 QString url=m->getURL();
2856 if (url=="") return;
2857 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2859 QString workDir=QDir::currentDirPath();
2860 if (!procBrowser->startDetached(browser,args))
2862 // try to set path to browser
2863 QMessageBox::warning(0,
2865 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2866 tr("Please use Settings->")+tr("Set application to open an URL"));
2871 void Main::editOpenURLTab()
2873 VymModel *m=currentModel();
2877 urls.append(m->getURL());
2882 void Main::editOpenMultipleVisURLTabs(bool ignoreScrolled)
2884 VymModel *m=currentModel();
2888 urls=m->getURLs(ignoreScrolled);
2893 void Main::editOpenMultipleURLTabs()
2895 editOpenMultipleVisURLTabs (false);
2899 void Main::editURL()
2901 VymModel *m=currentModel();
2902 if (m) m->editURL();
2905 void Main::editLocalURL()
2907 VymModel *m=currentModel();
2908 if (m) m->editLocalURL();
2911 void Main::editHeading2URL()
2913 VymModel *m=currentModel();
2914 if (m) m->editHeading2URL();
2917 void Main::editBugzilla2URL()
2919 VymModel *m=currentModel();
2920 if (m) m->editBugzilla2URL();
2923 void Main::getBugzillaData()
2925 VymModel *m=currentModel();
2927 QProgressDialog progress ("Doing stuff","cancl",0,10,this);
2928 progress.setWindowModality(Qt::WindowModal);
2929 //progress.setCancelButton (NULL);
2931 progress.setMinimumDuration (0);
2932 progress.setValue (1);
2933 progress.setValue (5);
2937 QProgressBar *pb=new QProgressBar;
2943 if (m) m->getBugzillaData();
2946 void Main::editFATE2URL()
2948 VymModel *m=currentModel();
2949 if (m) m->editFATE2URL();
2952 void Main::editHeadingFinished(VymModel *m)
2956 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2957 !prevSelection.isEmpty())
2958 m->select(prevSelection);
2963 void Main::openVymLinks(const QStringList &vl)
2965 for (int j=0; j<vl.size(); j++)
2967 // compare path with already loaded maps
2970 for (i=0;i<=vymViews.count() -1;i++)
2972 if (vl.at(j)==vymViews.at(i)->getModel()->getFilePath() )
2981 if (!QFile(vl.at(j)).exists() )
2982 QMessageBox::critical( 0, tr( "Critical Error" ),
2983 tr("Couldn't open map %1").arg(vl.at(j)));
2986 fileLoad (vl.at(j), NewMap);
2987 tabWidget->setCurrentIndex (tabWidget->count()-1);
2990 // Go to tab containing the map
2991 tabWidget->setCurrentIndex (index);
2995 void Main::editOpenVymLink()
2997 VymModel *m=currentModel();
3001 vl.append(m->getVymLink());
3006 void Main::editOpenMultipleVymLinks()
3008 QString currentVymLink;
3009 VymModel *m=currentModel();
3012 QStringList vl=m->getVymLinks();
3017 void Main::editVymLink()
3019 VymModel *m=currentModel();
3024 void Main::editDeleteVymLink()
3026 VymModel *m=currentModel();
3027 if (m) m->deleteVymLink();
3030 void Main::editToggleHideExport()
3032 VymModel *m=currentModel();
3033 if (m) m->toggleHideExport();
3036 void Main::editAddTimestamp()
3038 VymModel *m=currentModel();
3039 if (m) m->addTimestamp();
3042 void Main::editMapInfo()
3044 VymModel *m=currentModel();
3047 ExtraInfoDialog dia;
3048 dia.setMapName (m->getFileName() );
3049 dia.setAuthor (m->getAuthor() );
3050 dia.setComment(m->getComment() );
3054 stats+=tr("%1 items on map\n","Info about map").arg (m->getScene()->items().size(),6);
3060 BranchItem *cur=NULL;
3061 BranchItem *prev=NULL;
3062 m->nextBranch(cur,prev);
3065 if (!cur->getNote().isEmpty() ) n++;
3066 f+= cur->imageCount();
3068 xl+=cur->xlinkCount();
3069 m->nextBranch(cur,prev);
3072 stats+=QString ("%1 xLinks \n").arg (xl,6);
3073 stats+=QString ("%1 notes\n").arg (n,6);
3074 stats+=QString ("%1 images\n").arg (f,6);
3075 stats+=QString ("%1 branches\n").arg (m->branchCount(),6);
3076 dia.setStats (stats);
3078 // Finally show dialog
3079 if (dia.exec() == QDialog::Accepted)
3081 m->setAuthor (dia.getAuthor() );
3082 m->setComment (dia.getComment() );
3086 void Main::editMoveUp()
3088 VymModel *m=currentModel();
3092 void Main::editMoveDown()
3094 VymModel *m=currentModel();
3095 if (m) m->moveDown();
3098 void Main::editDetach()
3100 VymModel *m=currentModel();
3104 void Main::editSortChildren()
3106 VymModel *m=currentModel();
3107 if (m) m->sortChildren(false);
3110 void Main::editSortBackChildren()
3112 VymModel *m=currentModel();
3113 if (m) m->sortChildren(true);
3116 void Main::editToggleScroll()
3118 VymModel *m=currentModel();
3119 if (m) m->toggleScroll();
3122 void Main::editExpandAll()
3124 VymModel *m=currentModel();
3125 if (m) m->emitExpandAll();
3128 void Main::editExpandOneLevel()
3130 VymModel *m=currentModel();
3131 if (m) m->emitExpandOneLevel();
3134 void Main::editCollapseOneLevel()
3136 VymModel *m=currentModel();
3137 if (m) m->emitCollapseOneLevel();
3140 void Main::editUnscrollChildren()
3142 VymModel *m=currentModel();
3143 if (m) m->unscrollChildren();
3146 void Main::editAddAttribute()
3148 VymModel *m=currentModel();
3156 void Main::editAddMapCenter()
3158 VymModel *m=currentModel();
3159 if (m) m->select (m->addMapCenter ());
3162 void Main::editNewBranch()
3164 VymModel *m=currentModel();
3167 BranchItem *bi=m->addNewBranch();
3170 if (actionSettingsAutoEditNewBranch->isOn()
3171 && !actionSettingsAutoSelectNewBranch->isOn() )
3172 prevSelection=m->getSelectString();
3174 prevSelection=QString();
3176 if (actionSettingsAutoSelectNewBranch->isOn()
3177 || actionSettingsAutoEditNewBranch->isOn())
3180 if (actionSettingsAutoEditNewBranch->isOn())
3181 currentMapEditor()->editHeading();
3186 void Main::editNewBranchBefore()
3188 VymModel *m=currentModel();
3191 BranchItem *bi=m->addNewBranchBefore();
3198 if (actionSettingsAutoEditNewBranch->isOn())
3200 if (!actionSettingsAutoSelectNewBranch->isOn())
3201 prevSelection=m->getSelectString(bi);
3202 currentMapEditor()->editHeading();
3207 void Main::editNewBranchAbove()
3209 VymModel *m=currentModel();
3212 BranchItem *bi=m->addNewBranch (-1);
3220 if (actionSettingsAutoEditNewBranch->isOn())
3222 if (!actionSettingsAutoSelectNewBranch->isOn())
3223 prevSelection=m->getSelectString (bi);
3224 currentMapEditor()->editHeading();
3229 void Main::editNewBranchBelow()
3231 VymModel *m=currentModel();
3234 BranchItem *bi=m->addNewBranch (1);
3241 if (actionSettingsAutoEditNewBranch->isOn())
3243 if (!actionSettingsAutoSelectNewBranch->isOn())
3244 prevSelection=m->getSelectString(bi);
3245 currentMapEditor()->editHeading();
3250 void Main::editImportAdd()
3252 fileLoad (ImportAdd);
3255 void Main::editImportReplace()
3257 fileLoad (ImportReplace);
3260 void Main::editSaveBranch()
3262 fileSaveAs (PartOfMap);
3265 void Main::editDeleteKeepChildren()
3267 VymModel *m=currentModel();
3268 if (m) m->deleteKeepChildren();
3271 void Main::editDeleteChildren()
3273 VymModel *m=currentModel();
3274 if (m) m->deleteChildren();
3277 void Main::editDeleteSelection()
3279 VymModel *m=currentModel();
3280 if (m && actionSettingsUseDelKey->isOn())
3281 m->deleteSelection();
3284 void Main::editLoadImage()
3286 VymModel *m=currentModel();
3287 if (m) m->loadFloatImage();
3290 void Main::editSaveImage()
3292 VymModel *m=currentModel();
3293 if (m) m->saveFloatImage();
3296 void Main::editEditXLink(QAction *a)
3298 VymModel *m=currentModel();
3300 m->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3303 void Main::formatSelectColor()
3305 QColor col = QColorDialog::getColor((currentColor ), this );
3306 if ( !col.isValid() ) return;
3307 colorChanged( col );
3310 void Main::formatPickColor()
3312 VymModel *m=currentModel();
3314 colorChanged( m->getCurrentHeadingColor() );
3317 void Main::colorChanged(QColor c)
3319 QPixmap pix( 16, 16 );
3321 actionFormatColor->setIconSet( pix );
3325 void Main::formatColorBranch()
3327 VymModel *m=currentModel();
3328 if (m) m->colorBranch(currentColor);
3331 void Main::formatColorSubtree()
3333 VymModel *m=currentModel();
3334 if (m) m->colorSubtree (currentColor);
3337 void Main::formatLinkStyleLine()
3339 VymModel *m=currentModel();
3342 m->setMapLinkStyle("StyleLine");
3343 actionFormatLinkStyleLine->setChecked(true);
3347 void Main::formatLinkStyleParabel()
3349 VymModel *m=currentModel();
3352 m->setMapLinkStyle("StyleParabel");
3353 actionFormatLinkStyleParabel->setChecked(true);
3357 void Main::formatLinkStylePolyLine()
3359 VymModel *m=currentModel();
3362 m->setMapLinkStyle("StylePolyLine");
3363 actionFormatLinkStylePolyLine->setChecked(true);
3367 void Main::formatLinkStylePolyParabel()
3369 VymModel *m=currentModel();
3372 m->setMapLinkStyle("StylePolyParabel");
3373 actionFormatLinkStylePolyParabel->setChecked(true);
3377 void Main::formatSelectBackColor()
3379 VymModel *m=currentModel();
3380 if (m) m->selectMapBackgroundColor();
3383 void Main::formatSelectBackImage()
3385 VymModel *m=currentModel();
3387 m->selectMapBackgroundImage();
3390 void Main::formatSelectLinkColor()
3392 VymModel *m=currentModel();
3395 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3396 m->setMapDefLinkColor( col );
3400 void Main::formatSelectSelectionColor()
3402 VymModel *m=currentModel();
3405 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3406 m->setSelectionColor (col);
3411 void Main::formatToggleLinkColorHint()
3413 VymModel *m=currentModel();
3414 if (m) m->toggleMapLinkColorHint();
3418 void Main::formatHideLinkUnselected() //FIXME-3 get rid of this with imagepropertydialog
3420 VymModel *m=currentModel();
3422 m->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3425 void Main::viewZoomReset()
3427 MapEditor *me=currentMapEditor();
3428 if (me) me->setZoomFactorTarget (1);
3431 void Main::viewZoomIn()
3433 MapEditor *me=currentMapEditor();
3434 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*1.15);
3437 void Main::viewZoomOut()
3439 MapEditor *me=currentMapEditor();
3440 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*0.85);
3443 void Main::viewCenter()
3445 VymModel *m=currentModel();
3446 if (m) m->emitShowSelection();
3449 void Main::networkStartServer()
3451 VymModel *m=currentModel();
3452 if (m) m->newServer();
3455 void Main::networkConnect()
3457 VymModel *m=currentModel();
3458 if (m) m->connectToServer();
3461 bool Main::settingsPDF()
3463 // Default browser is set in constructor
3465 QString text = QInputDialog::getText(
3466 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3467 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3469 settings.setValue ("/mainwindow/readerPDF",text);
3474 bool Main::settingsURL()
3476 // Default browser is set in constructor
3478 QString text = QInputDialog::getText(
3479 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3480 settings.value("/mainwindow/readerURL").toString()
3483 settings.setValue ("/mainwindow/readerURL",text);
3487 void Main::settingsMacroDir()
3489 QDir defdir(vymBaseDir.path() + "/macros");
3490 if (!defdir.exists())
3492 QDir dir=QFileDialog::getExistingDirectory (
3494 tr ("Directory with vym macros:"),
3495 settings.value ("/macros/macroDir",defdir.path()).toString()
3498 settings.setValue ("/macros/macroDir",dir.absolutePath());
3501 void Main::settingsUndoLevels()
3504 int i = QInputDialog::getInteger(
3506 tr("QInputDialog::getInteger()"),
3507 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3510 settings.setValue ("/mapeditor/stepsTotal",i);
3511 QMessageBox::information( this, tr( "VYM -Information:" ),
3512 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3516 void Main::settingsAutosaveToggle()
3518 settings.setValue ("/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
3521 void Main::settingsAutosaveTime()
3524 int i = QInputDialog::getInteger(
3526 tr("QInputDialog::getInteger()"),
3527 tr("Number of seconds before autosave:"), settings.value("/mainwindow/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3529 settings.setValue ("/mainwindow/autosave/ms",i * 1000);
3532 void Main::settingsAutoLayoutToggle()
3534 settings.setValue ("/mainwindow/autoLayout/use",actionSettingsAutosaveToggle->isOn() );
3537 void Main::settingsWriteBackupFileToggle()
3539 settings.setValue ("/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
3542 void Main::settingsToggleAnimation()
3544 settings.setValue ("/animation/use",actionSettingsUseAnimation->isOn() );
3547 void Main::settingsToggleDelKey()
3549 if (actionSettingsUseDelKey->isOn())
3551 actionDelete->setAccel (QKeySequence (Qt::Key_Delete));
3554 actionDelete->setAccel (QKeySequence (""));
3558 void Main::windowToggleNoteEditor()
3560 if (textEditor->isVisible() )
3561 windowHideNoteEditor();
3563 windowShowNoteEditor();
3566 void Main::windowToggleTreeEditor()
3568 if ( tabWidget->currentPage())
3569 vymViews.at(tabWidget->currentIndex())->toggleTreeEditor();
3572 void Main::windowToggleHistory()
3574 if (historyWindow->isVisible())
3575 historyWindow->hide();
3577 historyWindow->show();
3581 void Main::windowToggleProperty()
3583 if (branchPropertyWindow->isVisible())
3584 branchPropertyWindow->hide();
3586 branchPropertyWindow->show();
3587 branchPropertyWindow->setModel (currentModel() );
3590 void Main::windowToggleAntiAlias()
3592 bool b=actionViewToggleAntiAlias->isOn();
3594 for (int i=0;i<vymViews.count();i++)
3596 me=vymViews.at(i)->getMapEditor();
3597 if (me) me->setAntiAlias(b);
3602 bool Main::isAliased()
3604 return actionViewToggleAntiAlias->isOn();
3607 bool Main::hasSmoothPixmapTransform()
3609 return actionViewToggleSmoothPixmapTransform->isOn();
3612 void Main::windowToggleSmoothPixmap()
3614 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3616 for (int i=0;i<vymViews.count();i++)
3619 me=vymViews.at(i)->getMapEditor();
3620 if (me) me->setSmoothPixmap(b);
3624 void Main::updateHistory(SimpleSettings &undoSet)
3626 historyWindow->update (undoSet);
3629 void Main::updateNoteFlag()
3631 // this slot is connected to TextEditor::textHasChanged()
3632 VymModel *m=currentModel();
3633 if (m) m->updateNoteFlag();
3636 void Main::updateNoteEditor(QModelIndex index )
3638 TreeItem *ti=((VymModel*) QObject::sender())->getItem(index);
3640 cout << "Main::updateNoteEditor model="<<sender();
3641 cout << " item="<<ti->getHeadingStd()<<" ("<<ti<<")"<<endl;
3643 textEditor->setNote (ti->getNoteObj() );
3646 void Main::selectInNoteEditor(QString s,int i)
3648 // TreeItem is already selected at this time, therefor
3649 // the note is already in the editor
3650 textEditor->findText (s,0,i);
3653 void Main::changeSelection (VymModel *model, const QItemSelection &newsel, const QItemSelection &oldsel)
3655 branchPropertyWindow->setModel (model ); //FIXME-3 this used to be called from BranchObj::select(). Maybe use signal now...
3657 if (model && model==currentModel() )
3661 if (!oldsel.indexes().isEmpty() )
3663 ti=model->getItem(oldsel.indexes().first());
3665 // Don't update note if both treeItem and textEditor are empty
3666 //if (! (ti->hasEmptyNote() && textEditor->isEmpty() ))
3667 // ti->setNoteObj (textEditor->getNoteObj(),false );
3669 if (!newsel.indexes().isEmpty() )
3671 ti=model->getItem(newsel.indexes().first());
3672 if (!ti->hasEmptyNote() )
3673 textEditor->setNote(ti->getNoteObj() );
3675 textEditor->setNote(NoteObj() ); //FIXME-4 maybe add a clear() to TE
3677 // Show URL and link in statusbar
3679 QString s=ti->getURL();
3680 if (!s.isEmpty() ) status+="URL: "+s+" ";
3682 if (!s.isEmpty() ) status+="Link: "+s;
3683 if (!status.isEmpty() ) statusMessage (status);
3686 textEditor->setInactive();
3692 void Main::updateActions()
3694 // updateActions is also called when satellites are closed //FIXME-2 doesn't update immediatly, e.g. historyWindow is still visible, when "close" is pressed
3695 actionViewToggleNoteEditor->setChecked (textEditor->isVisible());
3696 actionViewToggleHistoryWindow->setChecked (historyWindow->isVisible());
3697 actionViewTogglePropertyWindow->setChecked (branchPropertyWindow->isVisible());
3698 if ( tabWidget->currentPage())
3699 actionViewToggleTreeEditor->setChecked (
3700 vymViews.at(tabWidget->currentIndex())->getTreeEditor()->isVisible()
3703 VymModel *m =currentModel();
3707 actionFilePrint->setEnabled (true);
3709 // Link style in context menu
3710 switch (m->getMapLinkStyle())
3712 case LinkableMapObj::Line:
3713 actionFormatLinkStyleLine->setChecked(true);
3715 case LinkableMapObj::Parabel:
3716 actionFormatLinkStyleParabel->setChecked(true);
3718 case LinkableMapObj::PolyLine:
3719 actionFormatLinkStylePolyLine->setChecked(true);
3721 case LinkableMapObj::PolyParabel:
3722 actionFormatLinkStylePolyParabel->setChecked(true);
3729 QPixmap pix( 16, 16 );
3730 pix.fill( m->getMapBackgroundColor() );
3731 actionFormatBackColor->setIconSet( pix );
3732 pix.fill( m->getSelectionColor() );
3733 actionFormatSelectionColor->setIconSet( pix );
3734 pix.fill( m->getMapDefLinkColor() );
3735 actionFormatLinkColor->setIconSet( pix );
3738 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName()));
3741 // Expanding/collapsing
3742 actionExpandAll->setEnabled (true);
3743 actionExpandOneLevel->setEnabled (true);
3744 actionCollapseOneLevel->setEnabled (true);
3748 actionFilePrint->setEnabled (false);
3750 // Expanding/collapsing
3751 actionExpandAll->setEnabled (false);
3752 actionExpandOneLevel->setEnabled (false);
3753 actionCollapseOneLevel->setEnabled (false);
3756 if (m && m->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3757 actionFormatLinkColorHint->setChecked(true);
3759 actionFormatLinkColorHint->setChecked(false);
3762 if (m && m->hasChanged() )
3763 actionFileSave->setEnabled( true);
3765 actionFileSave->setEnabled( false);
3766 if (m && m->isUndoAvailable())
3767 actionUndo->setEnabled( true);
3769 actionUndo->setEnabled( false);
3771 if (m && m->isRedoAvailable())
3772 actionRedo->setEnabled( true);
3774 actionRedo->setEnabled( false);
3778 TreeItem *selti=m->getSelectedItem();
3779 BranchItem *selbi=m->getSelectedBranch();
3782 if (selbi || selti->getType()==TreeItem::Image)
3784 actionFormatHideLinkUnselected->setChecked (((MapItem*)selti)->getHideLinkUnselected());
3785 actionFormatHideLinkUnselected->setEnabled (true);
3790 // Take care of xlinks
3791 branchXLinksContextMenuEdit->clear();
3792 if (selbi->xlinkCount()>0)
3796 for (int i=0; i<selbi->xlinkCount();++i)
3798 bi=selbi->getXLinkNum(i)->getPartnerBranch();
3802 if (s.length()>xLinkMenuWidth)
3803 s=s.left(xLinkMenuWidth)+"...";
3804 branchXLinksContextMenuEdit->addAction (s);
3809 standardFlagsMaster->updateToolBar (selbi->activeStandardFlagNames() );
3812 actionToggleScroll->setEnabled (true);
3813 if ( selbi->isScrolled() )
3814 actionToggleScroll->setChecked(true);
3816 actionToggleScroll->setChecked(false);
3818 if ( selti->getURL().isEmpty() )
3820 actionOpenURL->setEnabled (false);
3821 actionOpenURLTab->setEnabled (false);
3825 actionOpenURL->setEnabled (true);
3826 actionOpenURLTab->setEnabled (true);
3828 if ( selti->getVymLink().isEmpty() )
3830 actionOpenVymLink->setEnabled (false);
3831 actionDeleteVymLink->setEnabled (false);
3834 actionOpenVymLink->setEnabled (true);
3835 actionDeleteVymLink->setEnabled (true);
3838 if (selbi->canMoveUp())
3839 actionMoveUp->setEnabled (true);
3841 actionMoveUp->setEnabled (false);
3842 if (selbi->canMoveDown())
3843 actionMoveDown->setEnabled (true);
3845 actionMoveDown->setEnabled (false);
3847 actionSortChildren->setEnabled (true);
3848 actionSortBackChildren->setEnabled (true);
3850 actionToggleHideExport->setEnabled (true);
3851 actionToggleHideExport->setChecked (selbi->hideInExport() );
3853 actionCopy->setEnabled (true);
3854 actionCut->setEnabled (true);
3855 if (!clipboardEmpty)
3856 actionPaste->setEnabled (true);
3858 actionPaste->setEnabled (false);
3859 for (int i=0; i<actionListBranches.size(); ++i)
3860 actionListBranches.at(i)->setEnabled(true);
3861 actionDelete->setEnabled (true);
3863 if ( selti->getType()==TreeItem::Image)
3865 actionOpenURL->setEnabled (false);
3866 actionOpenVymLink->setEnabled (false);
3867 actionDeleteVymLink->setEnabled (false);
3868 actionToggleHideExport->setEnabled (true);
3869 actionToggleHideExport->setChecked (selti->hideInExport() );
3872 actionCopy->setEnabled (true);
3873 actionCut->setEnabled (true);
3874 actionPaste->setEnabled (false); //FIXME-4 why not allowing copy of images?
3875 for (int i=0; i<actionListBranches.size(); ++i)
3876 actionListBranches.at(i)->setEnabled(false);
3877 actionDelete->setEnabled (true);
3878 actionMoveUp->setEnabled (false);
3879 actionMoveDown->setEnabled (false);
3884 actionCopy->setEnabled (false);
3885 actionCut->setEnabled (false);
3886 actionPaste->setEnabled (false);
3887 for (int i=0; i<actionListBranches.size(); ++i)
3888 actionListBranches.at(i)->setEnabled(false);
3890 actionToggleScroll->setEnabled (false);
3891 actionOpenURL->setEnabled (false);
3892 actionOpenVymLink->setEnabled (false);
3893 actionDeleteVymLink->setEnabled (false);
3894 actionHeading2URL->setEnabled (false);
3895 actionDelete->setEnabled (false);
3896 actionMoveUp->setEnabled (false);
3897 actionMoveDown->setEnabled (false);
3898 actionFormatHideLinkUnselected->setEnabled (false);
3899 actionSortChildren->setEnabled (false);
3900 actionSortBackChildren->setEnabled (false);
3901 actionToggleHideExport->setEnabled (false);
3906 Main::ModMode Main::getModMode()
3908 if (actionModModeColor->isOn()) return ModModeColor;
3909 if (actionModModeCopy->isOn()) return ModModeCopy;
3910 if (actionModModeXLink->isOn()) return ModModeXLink;
3914 bool Main::autoEditNewBranch()
3916 return actionSettingsAutoEditNewBranch->isOn();
3919 bool Main::autoSelectNewBranch()
3921 return actionSettingsAutoSelectNewBranch->isOn();
3924 void Main::windowShowNoteEditor()
3926 textEditor->setShowWithMain(true);
3928 actionViewToggleNoteEditor->setChecked (true);
3931 void Main::windowHideNoteEditor()
3933 textEditor->setShowWithMain(false);
3935 actionViewToggleNoteEditor->setChecked (false);
3938 void Main::setScript (const QString &script)
3940 scriptEditor->setScript (script);
3943 void Main::runScript (const QString &script)
3945 VymModel *m=currentModel();
3946 if (m) m->runScript (script);
3949 void Main::runScriptEverywhere (const QString &script)
3952 for (int i=0;i<=tabWidget->count() -1;i++)
3954 me=(MapEditor*)tabWidget->page(i);
3955 if (me) me->getModel()->runScript (script);
3959 void Main::windowNextEditor()
3961 if (tabWidget->currentIndex() < tabWidget->count())
3962 tabWidget->setCurrentIndex (tabWidget->currentIndex() +1);
3965 void Main::windowPreviousEditor()
3967 if (tabWidget->currentIndex() >0)
3968 tabWidget->setCurrentIndex (tabWidget->currentIndex() -1);
3971 void Main::standardFlagChanged()
3975 if ( actionSettingsUseFlagGroups->isOn() )
3976 currentModel()->toggleStandardFlag(sender()->name(),standardFlagsMaster);
3978 currentModel()->toggleStandardFlag(sender()->name());
3984 void Main::testFunction1()
3987 #include "attributeitem.h"
3988 VymModel *m=currentModel();
3991 BranchItem *selbi=m->getSelectedBranch();
3994 QList<QVariant> cData;
3995 cData << "new ai" << "undef";
3997 AttributeItem *ai=new AttributeItem (cData,selbi);
3998 ai->set ("Key 1","Val a",AttributeItem::FreeString);
4000 m->addAttribute (ai);
4004 if (!currentMapEditor()) return;
4005 currentMapEditor()->testFunction1();
4008 void Main::testFunction2()
4010 if (!currentMapEditor()) return;
4011 currentMapEditor()->testFunction2();
4014 void Main::testCommand()
4016 if (!currentMapEditor()) return;
4017 scriptEditor->show();
4020 QString com = QInputDialog::getText(
4021 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
4022 if (ok) currentMapEditor()->parseAtom(com);
4026 void Main::helpDoc()
4028 QString locale = QLocale::system().name();
4030 if (locale.left(2)=="es")
4031 docname="vym_es.pdf";
4035 QStringList searchList;
4037 #if defined(Q_OS_MACX)
4038 searchList << "./vym.app/Contents/Resources/doc";
4039 #elif defined(Q_OS_WIN32)
4040 searchList << vymInstallDir.path() + "/share/doc/packages/vym";
4042 #if defined(VYM_DOCDIR)
4043 searchList << VYM_DOCDIR;
4045 // default path in SUSE LINUX
4046 searchList << "/usr/share/doc/packages/vym";
4049 searchList << "doc"; // relative path for easy testing in tarball
4050 searchList << "doc/tex"; // Easy testing working on vym.tex
4051 searchList << "/usr/share/doc/vym"; // Debian
4052 searchList << "/usr/share/doc/packages";// Knoppix
4056 for (int i=0; i<searchList.count(); ++i)
4058 docfile.setFileName(searchList.at(i)+"/"+docname);
4059 if (docfile.exists())
4068 QMessageBox::critical(0,
4069 tr("Critcal error"),
4070 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
4075 Process *pdfProc = new Process();
4076 args << QDir::toNativeSeparators(docfile.fileName());
4078 if (!pdfProc->startDetached( settings.value("/mainwindow/readerPDF").toString(),args) )
4081 QMessageBox::warning(0,
4083 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
4084 tr("Please use Settings->")+tr("Set application to open PDF files"));
4091 void Main::helpDemo()
4093 QStringList filters;
4094 filters <<"VYM example map (*.vym)";
4095 QFileDialog *fd=new QFileDialog( this);
4096 #if defined(Q_OS_MACX)
4097 fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
4099 // default path in SUSE LINUX
4100 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
4103 fd->setFileMode (QFileDialog::ExistingFiles);
4104 fd->setFilters (filters);
4105 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
4109 if ( fd->exec() == QDialog::Accepted )
4111 lastFileDir=fd->directory().path();
4112 QStringList flist = fd->selectedFiles();
4113 QStringList::Iterator it = flist.begin();
4114 while( it != flist.end() )
4117 fileLoad(*it, NewMap);
4125 void Main::helpAbout()
4128 ad.setName ("aboutwindow");
4129 ad.setMinimumSize(500,500);
4130 ad.resize (QSize (500,500));
4134 void Main::helpAboutQT()
4136 QMessageBox::aboutQt( this, "Qt Application Example" );
4139 void Main::callMacro ()
4141 QAction *action = qobject_cast<QAction *>(sender());
4145 i=action->data().toInt();
4146 QString mDir (settings.value ("macros/macroDir").toString() );
4148 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
4150 if ( !f.open( QIODevice::ReadOnly ) )
4152 QMessageBox::warning(0,
4154 tr("Couldn't find a macro at %1.\n").arg(fn)+
4155 tr("Please use Settings->")+tr("Set directory for vym macros"));
4159 QTextStream ts( &f );
4160 QString macro= ts.read();
4162 if (! macro.isEmpty())
4164 VymModel *m=currentModel();
4165 if (m) m->runScript(macro);