1 #include "mainwindow.h"
8 #include "aboutdialog.h"
9 #include "branchpropwindow.h"
10 #include "branchitem.h"
11 #include "exportoofiledialog.h"
14 #include "findresultwidget.h"
16 #include "historywindow.h"
18 #include "mapeditor.h"
23 #include "shortcuts.h"
24 #include "texteditor.h"
25 #include "warningdialog.h"
26 #include "xlinkitem.h"
28 //#include <modeltest.h> // FIXME-3
30 #if defined(Q_OS_WIN32)
31 // Define only this structure as opposed to
32 // including full 'windows.h'. FindWindow
33 // clashes with the one in Win32 API.
34 typedef struct _PROCESS_INFORMATION
40 } PROCESS_INFORMATION, *LPPROCESS_INFORMATION;
43 extern TextEditor *textEditor;
44 extern Main *mainWindow;
45 extern QString tmpVymDir;
46 extern QString clipboardDir;
47 extern QString clipboardFile;
48 extern bool clipboardEmpty;
49 extern int statusbarTime;
50 extern FlagRow *standardFlagsMaster;
51 extern FlagRow *systemFlagsMaster;
52 extern QString vymName;
53 extern QString vymVersion;
54 extern QString vymBuildDate;
57 QMenu* branchContextMenu;
58 QMenu* branchAddContextMenu;
59 QMenu* branchRemoveContextMenu;
60 QMenu* branchLinksContextMenu;
61 QMenu* branchXLinksContextMenuEdit;
62 QMenu* floatimageContextMenu;
63 QMenu* canvasContextMenu;
64 QMenu* fileLastMapsMenu;
65 QMenu* fileImportMenu;
66 QMenu* fileExportMenu;
69 extern Settings settings;
70 extern Options options;
71 extern ImageIO imageIO;
73 extern QDir vymBaseDir;
74 extern QDir lastImageDir;
75 extern QDir lastFileDir;
76 #if defined(Q_OS_WIN32)
77 extern QDir vymInstallDir;
79 extern QString iconPath;
80 extern QString flagsPath;
83 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
84 QMainWindow(parent,name,f)
88 setCaption ("VYM - View Your Mind");
90 // Load window settings
91 #if defined(Q_OS_WIN32)
92 if (settings.value("/mainwindow/geometry/maximized", false).toBool())
94 setWindowState(Qt::WindowMaximized);
99 resize (settings.value("/mainwindow/geometry/size", QSize (800,600)).toSize());
100 move (settings.value("/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
103 // Sometimes we may need to remember old selections
107 currentColor=Qt::black;
109 // Create unique temporary directory
111 tmpVymDir=makeTmpDir (ok,"vym");
114 qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
117 if (debug) qDebug (QString("vym tmpDir=%1").arg(tmpVymDir) );
119 // Create direcctory for clipboard
120 clipboardDir=tmpVymDir+"/clipboard";
121 clipboardFile="map.xml";
122 QDir d(clipboardDir);
123 d.mkdir (clipboardDir,true);
124 makeSubDirs (clipboardDir);
127 browserPID=new qint64;
130 // Dock widgets //FIXME-2 testing...
132 FindResultWidget *findResultWidget=new FindResultWidget;
133 QDockWidget *dw= new QDockWidget ("Dock Widget",this);
134 dw->setWidget (findResultWidget);
136 addDockWidget (Qt::RightDockWidgetArea,dw);
138 // Satellite windows //////////////////////////////////////////
140 historyWindow=new HistoryWindow();
141 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
144 branchPropertyWindow = new BranchPropertyWindow();
145 connect (branchPropertyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
147 // Connect TextEditor, so that we can update flags if text changes
148 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
149 connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
151 // Initialize script editor
152 scriptEditor = new SimpleScriptEditor();
153 scriptEditor->move (50,50);
155 connect( scriptEditor, SIGNAL( runScript ( QString ) ),
156 this, SLOT( runScript( QString ) ) );
158 // Initialize some settings, which are platform dependant
161 // application to open URLs
162 p="/mainwindow/readerURL";
163 #if defined(Q_OS_LINUX)
164 s=settings.value (p,"xdg-open").toString();
166 #if defined(Q_OS_MACX)
167 s=settings.value (p,"/usr/bin/open").toString();
170 #if defined(Q_OS_WIN32)
171 // Assume that system has been set up so that
172 // Explorer automagically opens up the URL
173 // in the user's preferred browser.
174 s=settings.value (p,"explorer").toString();
176 s=settings.value (p,"mozilla").toString();
180 settings.setValue( p,s);
182 // application to open PDFs
183 p="/mainwindow/readerPDF";
184 #if defined(Q_OS_LINUX)
185 s=settings.value (p,"xdg-open").toString();
187 #if defined(Q_OS_MACX)
188 s=settings.value (p,"/usr/bin/open").toString();
189 #elif defined(Q_OS_WIN32)
190 s=settings.value (p,"acrord32").toString();
192 s=settings.value (p,"acroread").toString();
195 settings.setValue( p,s);
197 // width of xLinksMenu
200 // Create tab widget which holds the maps
201 tabWidget= new QTabWidget (this);
202 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
203 this, SLOT( editorChanged( QWidget * ) ) );
205 setCentralWidget(tabWidget);
209 setupFormatActions();
213 setupNetworkActions();
214 setupSettingsActions();
217 if (debug) switchboard.print();
219 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
222 // Status bar and progress bar there
226 progressCounterTotal=0;
228 progressDialog.setLabelText (tr("Loading maps","Mainwindow"));
229 progressDialog.setAutoReset(false);
230 progressDialog.setAutoClose(false);
231 //progressDialog.setWindowModality (Qt::WindowModal); // That forces mainwindo to update and slows down
232 //progressDialog.setCancelButton (NULL);
234 restoreState (settings.value("/mainwindow/state",0).toByteArray());
242 #if defined(Q_OS_WIN32)
243 settings.setValue ("/mainwindow/geometry/maximized", isMaximized());
245 settings.setValue ("/mainwindow/geometry/size", size());
246 settings.setValue ("/mainwindow/geometry/pos", pos());
247 settings.setValue ("/mainwindow/state",saveState(0));
249 settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
250 settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
251 settings.setValue( "/version/version", vymVersion );
252 settings.setValue( "/version/builddate", vymBuildDate );
254 settings.setValue( "/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
255 settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isOn() );
256 settings.setValue( "/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
257 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
258 settings.setValue( "/mapeditor/editmode/autoEditNewBranch",actionSettingsAutoEditNewBranch->isOn() );
259 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
260 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
261 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
263 //TODO save scriptEditor settings
265 // call the destructors
267 delete historyWindow;
268 delete branchPropertyWindow;
270 // Remove temporary directory
271 removeDir (QDir(tmpVymDir));
274 void Main::loadCmdLine()
276 /* TODO draw some kind of splashscreen while loading...
282 QStringList flist=options.getFileList();
283 QStringList::Iterator it=flist.begin();
285 progressCounter=flist.count();
286 progressCounterTotal=flist.count();
287 while (it !=flist.end() )
289 fileLoad (*it, NewMap);
295 void Main::statusMessage(const QString &s)
297 // Surpress messages while progressdialog during
300 statusBar()->message( s);
303 void Main::setProgressMaximum (int max)
305 if (progressCounterTotal!=0)
307 progressDialog.setRange (0,progressCounterTotal*1000);
309 progressDialog.setRange (0,max+10);
311 progressDialog.setValue (0);
312 progressMax=max*1000;
313 //cout << "Main max="<<max<<" v="<<progressDialog.value()<<endl;
314 progressDialog.show();
317 void Main::addProgressValue (float v)
319 //cout << "addVal v="<<v*1000<<"/"<<progressMax<<" cur="<<progressDialog.value()<<" counter="<<v+progressCounter<<"/"<<progressCounterTotal<<endl;
320 if (progressCounterTotal!=0)
321 progressDialog.setValue ( (v+progressCounterTotal-progressCounter)*1000 );
323 progressDialog.setValue (v+progressDialog.value());
326 void Main::removeProgressCounter()
330 if (progressCounter<=0)
333 progressCounterTotal=0;
334 progressDialog.reset();
335 progressDialog.hide();
339 void Main::closeEvent (QCloseEvent* )
345 void Main::setupFileActions()
347 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
348 QToolBar *tb = addToolBar( tr ("&Map") );
349 tb->setObjectName ("mapTB");
352 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this);
353 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
354 a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map
355 switchboard.addConnection(a,tr("File","Shortcut group"));
357 fileMenu->addAction (a);
358 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
360 a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this);
361 a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) );
362 a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N ); //New map
363 switchboard.addConnection(a,tr("File","Shortcut group"));
364 fileMenu->addAction (a);
365 connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) );
368 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
369 a->setStatusTip (tr( "Open","Status tip File menu" ) );
370 a->setShortcut ( Qt::CTRL + Qt::Key_O ); //Open map
371 switchboard.addConnection(a,tr("File","Shortcut group"));
373 fileMenu->addAction (a);
374 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
376 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
377 fileMenu->addSeparator();
379 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
380 a->setStatusTip ( tr( "Save","Status tip file menu" ));
381 a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map
382 switchboard.addConnection(a,tr("File","Shortcut group"));
384 fileMenu->addAction (a);
385 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
388 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
389 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
390 switchboard.addConnection(a,tr("File","Shortcut group"));
391 fileMenu->addAction (a);
392 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
394 fileMenu->addSeparator();
396 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
398 a = new QAction(tr("KDE 3 Bookmarks"), this);
399 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 3 bookmarks")));
400 switchboard.addConnection(a,tr("File","Shortcut group"));
401 a->addTo (fileImportMenu);
402 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE3Bookmarks() ) );
404 a = new QAction(tr("KDE 4 Bookmarks"), this);
405 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 4 bookmarks")));
406 a->addTo (fileImportMenu);
407 switchboard.addConnection(a,tr("File","Shortcut group"));
408 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE4Bookmarks() ) );
410 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
412 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
413 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
414 a->addTo (fileImportMenu);
415 switchboard.addConnection(a,tr("File","Shortcut group"));
416 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
419 a = new QAction("Freemind...",this);
420 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Freemind") );
421 switchboard.addConnection(a,tr("File","Shortcut group"));
422 fileImportMenu->addAction (a);
423 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFreemind() ) );
425 a = new QAction("Mind Manager...",this);
426 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
427 switchboard.addConnection(a,tr("File","Shortcut group"));
428 fileImportMenu->addAction (a);
429 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
431 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
432 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
433 switchboard.addConnection(a,tr("File","Shortcut group"));
434 fileImportMenu->addAction (a);
435 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
437 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
439 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
440 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
441 switchboard.addConnection(a,tr("File","Shortcut group"));
442 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
443 fileExportMenu->addAction (a);
445 a = new QAction( "Open Office...", this);
446 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
447 switchboard.addConnection(a,tr("File","Shortcut group"));
448 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
449 fileExportMenu->addAction (a);
451 a = new QAction( "Webpage (HTML)...",this );
452 a->setShortcut (Qt::ALT + Qt::Key_X); //Export HTML
453 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
454 switchboard.addConnection(a,tr("File","Shortcut group"));
455 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportHTML() ) );
456 fileExportMenu->addAction (a);
458 a = new QAction( "Webpage (XHTML)...",this ); //Export XHTML
460 //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")));
461 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
462 fileExportMenu->addAction (a);
464 a = new QAction( "Text (A&O report)...", this);
465 a->setStatusTip ( tr( "Export as %1").arg("A&O report "+tr("(still experimental)" )));
466 switchboard.addConnection(a,tr("File","Shortcut group"));
467 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportAO() ) );
468 fileExportMenu->addAction (a);
470 a = new QAction( "Text (ASCII)...", this);
471 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
472 switchboard.addConnection(a,tr("File","Shortcut group"));
473 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
474 fileExportMenu->addAction (a);
476 a = new QAction( "Spreadsheet (CSV)...", this);
477 a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
478 switchboard.addConnection(a,tr("File","Shortcut group"));
479 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
480 fileExportMenu->addAction (a);
482 a = new QAction( tr("KDE 3 Bookmarks","File menu"), this);
483 a->setStatusTip( tr( "Export as %1").arg(tr("KDE 3 Bookmarks" )));
484 switchboard.addConnection(a,tr("File","Shortcut group"));
485 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE3Bookmarks() ) );
486 fileExportMenu->addAction (a);
488 a = new QAction( tr("KDE 4 Bookmarks","File menu"), this);
489 a->setStatusTip( tr( "Export as %1").arg(tr("KDE 4 Bookmarks" )));
490 switchboard.addConnection(a,tr("File","Shortcut group"));
491 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE4Bookmarks() ) );
492 fileExportMenu->addAction (a);
494 a = new QAction( "Taskjuggler...", this );
495 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
496 switchboard.addConnection(a,tr("File","Shortcut group"));
497 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
498 fileExportMenu->addAction (a);
500 a = new QAction( "LaTeX...", this);
501 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
502 switchboard.addConnection(a,tr("File","Shortcut group"));
503 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
504 fileExportMenu->addAction (a);
506 a = new QAction( "XML..." , this );
507 a->setStatusTip (tr( "Export as %1").arg("XML"));
508 switchboard.addConnection(a,tr("File","Shortcut group"));
509 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
510 fileExportMenu->addAction (a);
512 fileMenu->addSeparator();
514 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
515 a->setStatusTip ( tr( "Print" ,"File menu") );
516 a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map
518 switchboard.addConnection(a,tr("File","Shortcut group"));
519 fileMenu->addAction (a);
520 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
523 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
524 a->setStatusTip (tr( "Close Map" ) );
525 a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map
526 switchboard.addConnection(a,tr("File","Shortcut group"));
527 fileMenu->addAction (a);
528 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
530 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
531 a->setStatusTip ( tr( "Exit")+" "+vymName );
532 a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym
533 switchboard.addConnection(a,tr("File","Shortcut group"));
534 fileMenu->addAction (a);
535 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
540 void Main::setupEditActions()
542 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
543 tb->setLabel( "Edit Actions" );
544 tb->setObjectName ("actionsTB");
545 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
549 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
550 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
551 a->setStatusTip (tr( "Undo" ) );
552 a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action
553 a->setEnabled (false);
554 switchboard.addConnection(a,tr("Edit","Shortcut group"));
556 editMenu->addAction (a);
559 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
560 a->setStatusTip (tr( "Redo" ));
561 a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action
562 switchboard.addConnection(a,tr("Edit","Shortcut group"));
564 editMenu->addAction (a);
565 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
568 editMenu->addSeparator();
569 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
570 a->setStatusTip ( tr( "Copy" ) );
571 a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy
572 a->setEnabled (false);
573 switchboard.addConnection(a,tr("Edit","Shortcut group"));
575 editMenu->addAction (a);
576 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
579 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
580 a->setStatusTip ( tr( "Cut" ) );
581 a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut
582 a->setEnabled (false);
584 switchboard.addConnection(a,tr("Edit","Shortcut group"));
585 editMenu->addAction (a);
587 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
589 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
590 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
591 a->setStatusTip ( tr( "Paste" ) );
592 a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste
593 a->setEnabled (false);
595 switchboard.addConnection(a,tr("Edit","Shortcut group"));
596 editMenu->addAction (a);
599 // Shortcut to delete selection
600 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
601 a->setStatusTip (tr( "Delete Selection" ));
602 a->setShortcut ( Qt::Key_Delete); //Delete selection
603 a->setShortcutContext (Qt::WindowShortcut);
604 switchboard.addConnection(a,tr("Edit","Shortcut group"));
606 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
609 // Shortcut to add attribute
610 a= new QAction(tr( "Add attribute" ), this);
611 a->setShortcut ( Qt::Key_Q);
612 a->setShortcutContext (Qt::WindowShortcut);
613 switchboard.addConnection(a,tr("Edit","Shortcut group"));
615 connect( a, SIGNAL( triggered() ), this, SLOT( editAddAttribute() ) );
616 actionAddAttribute= a;
619 // Shortcut to add mapcenter
620 a= new QAction(QPixmap(iconPath+"newmapcenter.png"),tr( "Add mapcenter","Canvas context menu" ), this);
621 a->setShortcut ( Qt::Key_M);
622 a->setShortcutContext (Qt::WindowShortcut);
623 switchboard.addConnection(a,tr("Edit","Shortcut group"));
624 connect( a, SIGNAL( triggered() ), this, SLOT( editAddMapCenter() ) );
625 //actionListBranches.append(a);
627 actionAddMapCenter = a;
630 // Shortcut to add branch
631 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
632 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
633 alt->setShortcut (Qt::Key_A); //Add branch
634 alt->setShortcutContext (Qt::WindowShortcut);
635 switchboard.addConnection(alt,tr("Edit","Shortcut group"));
637 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
638 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
639 a->setStatusTip ( tr( "Add a branch as child of selection" ));
640 a->setShortcut (Qt::Key_Insert); //Add branch
641 switchboard.addConnection(a,tr("Edit","Shortcut group"));
642 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
643 actionListBranches.append(a);
644 #if defined (Q_OS_MACX)
645 // In OSX show different shortcut in menues, the keys work indepently always
650 editMenu->addAction (actionAddBranch);
651 tb->addAction (actionAddBranch);
654 // Add branch by inserting it at selection
655 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
656 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
657 a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch
658 a->setShortcutContext (Qt::WindowShortcut);
659 switchboard.addConnection(a,tr("Edit","Shortcut group"));
661 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
662 a->setEnabled (false);
663 actionListBranches.append(a);
664 actionAddBranchBefore=a;
665 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
666 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
667 a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch
668 a->setShortcutContext (Qt::WindowShortcut);
669 switchboard.addConnection(a,tr("Edit","Shortcut group"));
671 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
672 actionListBranches.append(a);
675 a = new QAction(tr( "Add branch above","Edit menu" ), this);
676 a->setStatusTip ( tr( "Add a branch above selection" ));
677 a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
678 a->setShortcutContext (Qt::WindowShortcut);
679 switchboard.addConnection(a,tr("Edit","Shortcut group"));
681 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
682 a->setEnabled (false);
683 actionListBranches.append(a);
684 actionAddBranchAbove=a;
685 a = new QAction(tr( "Add branch above","Edit menu" ), this);
686 a->setStatusTip ( tr( "Add a branch above selection" ));
687 a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above
688 a->setShortcutContext (Qt::WindowShortcut);
689 switchboard.addConnection(a,tr("Edit","Shortcut group"));
691 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
692 actionListBranches.append(a);
695 a = new QAction(tr( "Add branch below","Edit menu" ), this);
696 a->setStatusTip ( tr( "Add a branch below selection" ));
697 a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
698 a->setShortcutContext (Qt::WindowShortcut);
699 switchboard.addConnection(a,tr("Edit","Shortcut group"));
701 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
702 a->setEnabled (false);
703 actionListBranches.append(a);
704 actionAddBranchBelow=a;
705 a = new QAction(tr( "Add branch below","Edit menu" ), this);
706 a->setStatusTip ( tr( "Add a branch below selection" ));
707 a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below
708 a->setShortcutContext (Qt::WindowShortcut);
709 switchboard.addConnection(a,tr("Edit","Shortcut group"));
711 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
712 actionListBranches.append(a);
714 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
715 a->setStatusTip ( tr( "Move branch up" ) );
716 a->setShortcut (Qt::Key_PageUp ); // Move branch up
717 a->setEnabled (false);
718 switchboard.addConnection(a,tr("Edit","Shortcut group"));
720 editMenu->addAction (a);
721 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
724 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
725 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
726 a->setStatusTip (tr( "Move branch down" ) );
727 a->setShortcut ( Qt::Key_PageDown ); // Move branch down
728 a->setEnabled (false);
729 switchboard.addConnection(a,tr("Edit","Shortcut group"));
731 editMenu->addAction (a);
734 a = new QAction(QPixmap(), tr( "&Detach","Context menu" ),this);
735 a->setStatusTip ( tr( "Detach branch and use as mapcenter","Context menu" ) );
736 a->setShortcut ( Qt::Key_D ); // Detach branch
737 switchboard.addConnection(a,tr("Edit","Shortcut group"));
738 editMenu->addAction (a);
739 connect( a, SIGNAL( triggered() ), this, SLOT( editDetach() ) );
742 a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this );
743 connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) );
744 a->setEnabled (true);
746 switchboard.addConnection(a,tr("Edit","Shortcut group"));
747 editMenu->addAction (a);
748 actionSortChildren=a;
750 a = new QAction( QPixmap(iconPath+"editsortback.png" ), tr( "Sort children backwards","Edit menu" ), this );
751 connect( a, SIGNAL( activated() ), this, SLOT( editSortBackChildren() ) );
752 a->setEnabled (true);
754 switchboard.addConnection(a,tr("Edit","Shortcut group"));
755 editMenu->addAction (a);
756 actionSortBackChildren=a;
758 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
759 alt->setShortcut ( Qt::Key_S ); // Scroll branch
760 alt->setStatusTip (tr( "Scroll branch" ));
761 switchboard.addConnection(alt,tr("Edit","Shortcut group"));
762 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
763 #if defined(Q_OS_MACX)
764 actionToggleScroll=alt;
766 actionToggleScroll=a;
768 actionToggleScroll->setEnabled (false);
769 actionToggleScroll->setToggleAction(true);
770 tb->addAction (actionToggleScroll);
771 editMenu->addAction ( actionToggleScroll);
772 editMenu->addAction (actionToggleScroll);
775 actionListBranches.append(actionToggleScroll);
777 a = new QAction( QPixmap(), tr( "Expand all branches","Edit menu" ), this);
778 a->setShortcut ( Qt::SHIFT + Qt::Key_X ); // Expand all branches
779 a->setStatusTip (tr( "Expand all branches" ));
780 switchboard.addConnection(a,tr("Edit","Shortcut group"));
781 connect( a, SIGNAL( triggered() ), this, SLOT( editExpandAll() ) );
783 actionExpandAll->setEnabled (false);
784 actionExpandAll->setToggleAction(false);
785 //tb->addAction (actionExpandAll);
786 editMenu->addAction ( actionExpandAll);
788 actionListBranches.append(actionExpandAll);
790 a = new QAction( QPixmap(), tr( "Expand one level","Edit menu" ), this);
791 a->setShortcut ( Qt::Key_Greater ); // Expand one level in tree editor
792 switchboard.addConnection(a,tr("Edit","Shortcut group"));
793 a->setStatusTip (tr( "Expand one level in tree editor" ));
794 connect( a, SIGNAL( triggered() ), this, SLOT( editExpandOneLevel() ) );
795 a->setEnabled (false);
796 a->setToggleAction(false);
797 actionExpandOneLevel=a;
799 editMenu->addAction ( a);
801 actionListBranches.append(a);
803 a = new QAction( QPixmap(), tr( "Collapse one level","Edit menu" ), this);
804 a->setShortcut ( Qt::Key_Less); // Collapse one level in tree editor
805 switchboard.addConnection(a,tr("Edit","Shortcut group"));
806 a->setStatusTip (tr( "Collapse one level in tree editor" ));
807 connect( a, SIGNAL( triggered() ), this, SLOT( editCollapseOneLevel() ) );
808 a->setEnabled (false);
809 a->setToggleAction(false);
810 actionCollapseOneLevel=a;
812 editMenu->addAction ( a);
814 actionListBranches.append(a);
816 a = new QAction( tr( "Unscroll children","Edit menu" ), this);
817 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
818 switchboard.addConnection(a,tr("Edit","Shortcut group"));
819 editMenu->addAction (a);
820 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChildren() ) );
822 editMenu->addSeparator();
824 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
825 a->setStatusTip (tr( "Find" ) );
826 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
827 switchboard.addConnection(a,tr("Edit","Shortcut group"));
828 editMenu->addAction (a);
829 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWidget() ) );
831 a = new QAction( tr( "Find duplicate URLs","Edit menu"), this);
832 //a->setStatusTip (tr( "Find" ) );
833 a->setShortcut (Qt::SHIFT + Qt::Key_F); //Find duplicate URLs
834 switchboard.addConnection(a,tr("Edit","Shortcut group"));
835 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
836 editMenu->addAction (a);
837 connect( a, SIGNAL( triggered() ), this, SLOT( editFindDuplicateURLs() ) );
839 editMenu->addSeparator();
841 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
842 a->setShortcut (Qt::SHIFT + Qt::Key_U );
843 switchboard.addConnection(a,tr("Edit","Shortcut group"));
846 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
849 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
850 a->setStatusTip (tr( "Open URL in new tab" ));
851 //a->setShortcut (Qt::CTRL+Qt::Key_U );
852 switchboard.addConnection(a,tr("Edit","Shortcut group"));
854 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
857 a = new QAction( tr( "Open all URLs in subtree (including scrolled branches)","Edit menu" ), this);
858 a->setStatusTip (tr( "Open all URLs in subtree (including scrolled branches)" ));
859 a->setShortcut ( Qt::CTRL + Qt::Key_U );
860 switchboard.addConnection(a,tr("Edit","Shortcut group"));
862 actionListBranches.append(a);
863 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVisURLTabs() ) );
864 actionOpenMultipleVisURLTabs=a;
866 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
867 a->setStatusTip (tr( "Open all URLs in subtree" ));
868 switchboard.addConnection(a,tr("Edit","Shortcut group"));
870 actionListBranches.append(a);
871 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
872 actionOpenMultipleURLTabs=a;
874 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
875 a->setStatusTip ( tr( "Edit URL" ) );
876 a->setShortcut ( Qt::Key_U );
877 a->setShortcutContext (Qt::WindowShortcut);
878 switchboard.addConnection(a,tr("Edit","Shortcut group"));
879 actionListBranches.append(a);
881 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
884 a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
885 a->setStatusTip ( tr( "Edit local URL" ) );
886 //a->setShortcut (Qt::SHIFT + Qt::Key_U );
887 a->setShortcutContext (Qt::WindowShortcut);
888 switchboard.addConnection(a,tr("Edit","Shortcut group"));
889 actionListBranches.append(a);
891 connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
894 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
895 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
896 a->setEnabled (false);
897 switchboard.addConnection(a,tr("Edit","Shortcut group"));
898 actionListBranches.append(a);
899 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
902 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
903 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
904 a->setEnabled (false);
905 actionListBranches.append(a);
906 a->setShortcut ( Qt::Key_B );
907 a->setShortcutContext (Qt::WindowShortcut);
908 switchboard.addConnection(a,tr("Edit","Shortcut group"));
910 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
911 actionBugzilla2URL=a;
913 a = new QAction(tr( "Get data from Novell Bugzilla","Edit menu" ), this);
914 a->setStatusTip ( tr( "Get data from Novell Bugzilla" ));
915 a->setEnabled (false);
916 actionListBranches.append(a);
917 a->setShortcut ( Qt::Key_B + Qt::SHIFT);
918 a->setShortcutContext (Qt::WindowShortcut);
919 switchboard.addConnection(a,tr("Edit","Shortcut group"));
921 connect( a, SIGNAL( triggered() ), this, SLOT( getBugzillaData() ) );
922 actionGetBugzillaData=a;
924 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
925 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
926 a->setEnabled (false);
927 switchboard.addConnection(a,tr("Edit","Shortcut group"));
928 actionListBranches.append(a);
929 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
932 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
933 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
935 a->setEnabled (false);
936 switchboard.addConnection(a,tr("Edit","Shortcut group"));
937 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
940 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
941 a->setStatusTip ( tr( "Open all vym links in subtree" ));
942 a->setEnabled (false);
943 switchboard.addConnection(a,tr("Edit","Shortcut group"));
944 actionListBranches.append(a);
945 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
946 actionOpenMultipleVymLinks=a;
949 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
950 a->setEnabled (false);
951 a->setStatusTip ( tr( "Edit link to another vym map" ));
952 switchboard.addConnection(a,tr("Edit","Shortcut group"));
953 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
954 actionListBranches.append(a);
957 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
958 a->setStatusTip ( tr( "Delete link to another vym map" ));
959 a->setEnabled (false);
960 switchboard.addConnection(a,tr("Edit","Shortcut group"));
961 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
962 actionDeleteVymLink=a;
964 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
965 a->setStatusTip ( tr( "Hide object in exports" ) );
966 a->setShortcut (Qt::Key_H );
967 a->setToggleAction(true);
969 a->setEnabled (false);
970 switchboard.addConnection(a,tr("Edit","Shortcut group"));
971 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
972 actionToggleHideExport=a;
974 a = new QAction(tr( "Add timestamp","Edit menu" ), this);
975 a->setStatusTip ( tr( "Add timestamp" ));
976 a->setEnabled (false);
977 actionListBranches.append(a);
978 a->setShortcut ( Qt::Key_T ); // Add timestamp
979 a->setShortcutContext (Qt::WindowShortcut);
980 switchboard.addConnection(a,tr("Edit","Shortcut group"));
982 connect( a, SIGNAL( triggered() ), this, SLOT( editAddTimestamp() ) );
983 actionAddTimestamp=a;
985 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
986 a->setStatusTip ( tr( "Edit Map Info" ));
987 a->setEnabled (true);
988 switchboard.addConnection(a,tr("Edit","Shortcut group"));
989 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
992 // Import at selection (adding to selection)
993 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
994 a->setStatusTip (tr( "Add map at selection" ));
995 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
996 a->setEnabled (false);
997 switchboard.addConnection(a,tr("Edit","Shortcut group"));
998 actionListBranches.append(a);
1001 // Import at selection (replacing selection)
1002 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
1003 a->setStatusTip (tr( "Replace selection with map" ));
1004 switchboard.addConnection(a,tr("Edit","Shortcut group"));
1005 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
1006 a->setEnabled (false);
1007 actionListBranches.append(a);
1008 actionImportReplace=a;
1011 a = new QAction( tr( "Save selection","Edit menu" ), this);
1012 a->setStatusTip (tr( "Save selection" ));
1013 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
1014 a->setEnabled (false);
1015 switchboard.addConnection(a,tr("Edit","Shortcut group"));
1016 actionListBranches.append(a);
1019 // Only remove branch, not its children
1020 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
1021 a->setStatusTip ( tr( "Remove only branch and keep its children" ));
1022 a->setShortcut (Qt::ALT + Qt::Key_Delete );
1023 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChildren() ) );
1024 a->setEnabled (false);
1025 switchboard.addConnection(a,tr("Edit","Shortcut group"));
1027 actionListBranches.append(a);
1028 actionDeleteKeepChildren=a;
1030 // Only remove children of a branch
1031 a = new QAction( tr( "Remove children","Edit menu" ), this);
1032 a->setStatusTip (tr( "Remove children of branch" ));
1033 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
1034 switchboard.addConnection(a,tr("Edit","Shortcut group"));
1035 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChildren() ) );
1036 a->setEnabled (false);
1037 actionListBranches.append(a);
1038 actionDeleteChildren=a;
1040 a = new QAction( tr( "Add Image...","Edit menu" ), this);
1041 a->setStatusTip (tr( "Add Image" ));
1042 switchboard.addConnection(a,tr("Edit","Shortcut group"));
1043 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
1046 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
1047 a->setStatusTip (tr( "Set properties for selection" ));
1048 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
1049 a->setShortcutContext (Qt::WindowShortcut);
1050 a->setToggleAction (true);
1051 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1053 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
1054 actionViewTogglePropertyWindow=a;
1058 void Main::setupFormatActions()
1060 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
1062 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
1063 tb->setObjectName ("formatTB");
1065 QPixmap pix( 16,16);
1066 pix.fill (Qt::black);
1067 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
1068 a->setStatusTip ( tr( "Set Color" ));
1069 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
1071 formatMenu->addAction (a);
1072 actionFormatColor=a;
1073 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
1074 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
1075 a->setShortcut (Qt::CTRL + Qt::Key_K );
1076 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
1077 a->setEnabled (false);
1079 formatMenu->addAction (a);
1080 actionListBranches.append(a);
1081 actionFormatPickColor=a;
1083 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
1084 a->setStatusTip ( tr( "Color branch" ) );
1085 a->setShortcut (Qt::CTRL + Qt::Key_B + Qt::SHIFT);
1086 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
1087 a->setEnabled (false);
1089 formatMenu->addAction (a);
1090 actionListBranches.append(a);
1091 actionFormatColorSubtree=a;
1093 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
1094 a->setStatusTip ( tr( "Color Subtree" ));
1095 a->setShortcut (Qt::CTRL + Qt::Key_B); // Color subtree
1096 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
1097 a->setEnabled (false);
1098 formatMenu->addAction (a);
1100 actionListBranches.append(a);
1101 actionFormatColorSubtree=a;
1103 formatMenu->addSeparator();
1104 actionGroupFormatLinkStyles=new QActionGroup ( this);
1105 actionGroupFormatLinkStyles->setExclusive (true);
1106 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
1107 a->setStatusTip (tr( "Line" ));
1108 a->setToggleAction(true);
1109 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
1110 formatMenu->addAction (a);
1111 actionFormatLinkStyleLine=a;
1112 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
1113 a->setStatusTip (tr( "Line" ));
1114 a->setToggleAction(true);
1115 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
1116 formatMenu->addAction (a);
1117 actionFormatLinkStyleParabel=a;
1118 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
1119 a->setStatusTip (tr( "PolyLine" ));
1120 a->setToggleAction(true);
1121 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
1122 formatMenu->addAction (a);
1123 actionFormatLinkStylePolyLine=a;
1124 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
1125 a->setStatusTip (tr( "PolyParabel" ) );
1126 a->setToggleAction(true);
1127 a->setChecked (true);
1128 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
1129 formatMenu->addAction (a);
1130 actionFormatLinkStylePolyParabel=a;
1132 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
1133 a->setStatusTip (tr( "Hide link" ));
1134 a->setToggleAction(true);
1135 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
1136 actionFormatHideLinkUnselected=a;
1138 formatMenu->addSeparator();
1139 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
1140 a->setStatusTip (tr( "Use same color for links and headings" ));
1141 a->setToggleAction(true);
1142 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
1143 formatMenu->addAction (a);
1144 actionFormatLinkColorHint=a;
1146 pix.fill (Qt::white);
1147 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
1148 a->setStatusTip (tr( "Set Link Color" ));
1149 formatMenu->addAction (a);
1150 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
1151 actionFormatLinkColor=a;
1153 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
1154 a->setStatusTip (tr( "Set Selection Color" ));
1155 formatMenu->addAction (a);
1156 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
1157 actionFormatSelectionColor=a;
1159 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
1160 a->setStatusTip (tr( "Set Background Color" ));
1161 formatMenu->addAction (a);
1162 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
1163 actionFormatBackColor=a;
1165 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
1166 a->setStatusTip (tr( "Set Background image" ));
1167 formatMenu->addAction (a);
1168 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
1169 actionFormatBackImage=a;
1173 void Main::setupViewActions()
1175 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
1176 tb->setLabel( "View Actions" );
1177 tb->setObjectName ("viewTB");
1178 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
1182 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
1183 a->setStatusTip ( tr( "Zoom reset" ) );
1184 a->setShortcut (Qt::CTRL + Qt::Key_0); // Reset zoom
1185 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1187 viewMenu->addAction (a);
1188 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
1190 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
1191 a->setStatusTip (tr( "Zoom in" ));
1192 a->setShortcut(Qt::CTRL + Qt::Key_Plus);
1193 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1195 viewMenu->addAction (a);
1196 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
1198 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
1199 a->setStatusTip (tr( "Zoom out" ));
1200 a->setShortcut(Qt::CTRL + Qt::Key_Minus);
1201 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1203 viewMenu->addAction (a);
1204 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1206 a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
1207 a->setStatusTip (tr( "Show selection" ));
1208 a->setShortcut(Qt::CTRL + Qt::Key_Period);
1209 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1211 viewMenu->addAction (a);
1212 connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
1214 viewMenu->addSeparator();
1216 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
1217 a->setStatusTip ( tr( "Show Note Editor" ));
1218 a->setShortcut ( Qt::CTRL + Qt::Key_E ); // Toggle Note Editor
1219 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1220 a->setToggleAction(true);
1222 viewMenu->addAction (a);
1223 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1224 actionViewToggleNoteEditor=a;
1226 a = new QAction(QPixmap(), tr( "Show tree editor","View action" ),this);
1227 a->setStatusTip ( tr( "Show tree editor" ));
1228 a->setShortcut ( Qt::CTRL + Qt::Key_T ); // Toggle Tree Editor // FIXME-3 originally: color subtree
1229 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1230 a->setToggleAction(true);
1232 viewMenu->addAction (a);
1233 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleTreeEditor() ) );
1234 actionViewToggleTreeEditor=a;
1236 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
1237 a->setStatusTip ( tr( "Show History Window" ));
1238 a->setShortcut ( Qt::CTRL + Qt::Key_H ); // Toggle history window
1239 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1240 a->setToggleAction(true);
1242 viewMenu->addAction (a);
1243 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1244 actionViewToggleHistoryWindow=a;
1246 viewMenu->addAction (actionViewTogglePropertyWindow);
1248 viewMenu->addSeparator();
1250 a = new QAction(tr( "Antialiasing","View action" ),this );
1251 a->setStatusTip ( tr( "Antialiasing" ));
1252 a->setToggleAction(true);
1253 a->setChecked (settings.value("/mainwindow/view/AntiAlias",true).toBool());
1254 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1255 viewMenu->addAction (a);
1256 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
1257 actionViewToggleAntiAlias=a;
1259 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1260 a->setStatusTip (a->text());
1261 a->setToggleAction(true);
1262 a->setChecked (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1263 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1264 viewMenu->addAction (a);
1265 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1266 actionViewToggleSmoothPixmapTransform=a;
1268 a = new QAction(tr( "Next Map","View action" ), this);
1269 a->setStatusTip (a->text());
1270 a->setShortcut (Qt::ALT + Qt::Key_N );
1271 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1272 viewMenu->addAction (a);
1273 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1275 a = new QAction (tr( "Previous Map","View action" ), this );
1276 a->setStatusTip (a->text());
1277 a->setShortcut (Qt::ALT + Qt::Key_P );
1278 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1279 viewMenu->addAction (a);
1280 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1284 void Main::setupModeActions()
1286 //QPopupMenu *menu = new QPopupMenu( this );
1287 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1289 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1290 tb->setObjectName ("modesTB");
1292 actionGroupModModes=new QActionGroup ( this);
1293 actionGroupModModes->setExclusive (true);
1294 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1295 a->setShortcut (Qt::Key_J);
1296 switchboard.addConnection(a,tr("Modes","Shortcut group"));
1297 a->setStatusTip ( tr( "Use modifier to color branches" ));
1298 a->setToggleAction(true);
1300 a->setChecked(true);
1301 actionModModeColor=a;
1303 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1304 a->setShortcut( Qt::Key_K);
1305 switchboard.addConnection(a,tr("Modes","Shortcut group"));
1306 a->setStatusTip( tr( "Use modifier to copy" ));
1307 a->setToggleAction(true);
1309 actionModModeCopy=a;
1311 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1312 a->setShortcut (Qt::Key_L);
1313 switchboard.addConnection(a,tr("Modes","Shortcut group"));
1314 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1315 a->setToggleAction(true);
1317 actionModModeXLink=a;
1321 void Main::setupFlagActions()
1323 // Create System Flags
1326 Flag *flag=new Flag;;
1327 flag->setVisible(true);
1329 flag->load(flagsPath+"flag-note.png");
1330 setupFlag (flag,tb,"system-note",tr("Note","SystemFlag"));
1332 flag->load(flagsPath+"flag-url.png");
1333 setupFlag (flag,tb,"system-url",tr("URL to Document ","SystemFlag"));
1335 flag->load(flagsPath+"flag-url-bugzilla-novell.png");
1336 setupFlag (flag,tb,"system-url-bugzilla-novell",tr("URL to Bugzilla ","SystemFlag"));
1338 flag->load(flagsPath+"flag-vymlink.png");
1339 setupFlag (flag,tb,"system-vymLink",tr("Link to another vym map","SystemFlag"));
1341 flag->load(flagsPath+"flag-scrolled-right.png");
1342 setupFlag (flag,tb,"system-scrolledright",tr("subtree is scrolled","SystemFlag"));
1344 flag->load(flagsPath+"flag-tmpUnscrolled-right.png");
1345 setupFlag (flag,tb,"system-tmpUnscrolledRight",tr("subtree is temporary scrolled","SystemFlag"));
1347 flag->load(flagsPath+"flag-hideexport.png");
1348 setupFlag (flag,tb,"system-hideInExport",tr("Hide object in exported maps","SystemFlag"));
1350 // Create Standard Flags
1351 tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1352 tb->setObjectName ("standardFlagTB");
1353 standardFlagsMaster->setToolBar (tb);
1355 flag->load(flagsPath+"flag-exclamationmark.png");
1356 flag->setGroup("standard-mark");
1357 setupFlag (flag,tb,"exclamationmark",tr("Take care!","Standardflag"));
1359 flag->load(flagsPath+"flag-questionmark.png");
1360 flag->setGroup("standard-mark");
1361 setupFlag (flag,tb,"questionmark",tr("Really?","Standardflag"));
1363 flag->load(flagsPath+"flag-hook-green.png");
1364 flag->setGroup("standard-status");
1365 setupFlag (flag,tb,"hook-green",tr("Status - ok,done","Standardflag"));
1367 flag->load(flagsPath+"flag-wip.png");
1368 flag->setGroup("standard-status");
1369 setupFlag (flag,tb,"wip",tr("Status - work in progress","Standardflag"));
1371 flag->load(flagsPath+"flag-cross-red.png");
1372 flag->setGroup("standard-status");
1373 setupFlag (flag,tb,"cross-red",tr("Status - missing, not started","Standardflag"));
1376 flag->load(flagsPath+"flag-stopsign.png");
1377 setupFlag (flag,tb,"stopsign",tr("This won't work!","Standardflag"));
1379 flag->load(flagsPath+"flag-smiley-good.png");
1380 flag->setGroup("standard-smiley");
1381 setupFlag (flag,tb,"smiley-good",tr("Good","Standardflag"));
1383 flag->load(flagsPath+"flag-smiley-sad.png");
1384 flag->setGroup("standard-smiley");
1385 setupFlag (flag,tb,"smiley-sad",tr("Bad","Standardflag"));
1387 flag->load(flagsPath+"flag-smiley-omg.png");
1388 flag->setGroup("standard-smiley");
1389 setupFlag (flag,tb,"smiley-omb",tr("Oh no!","Standardflag"));
1390 // Original omg.png (in KDE emoticons)
1393 flag->load(flagsPath+"flag-kalarm.png");
1394 setupFlag (flag,tb,"clock",tr("Time critical","Standardflag"));
1396 flag->load(flagsPath+"flag-phone.png");
1397 setupFlag (flag,tb,"phone",tr("Call...","Standardflag"));
1399 flag->load(flagsPath+"flag-lamp.png");
1400 setupFlag (flag,tb,"lamp",tr("Idea!","Standardflag"));
1402 flag->load(flagsPath+"flag-arrow-up.png");
1403 flag->setGroup("standard-arrow");
1404 setupFlag (flag,tb,"arrow-up",tr("Important","Standardflag"));
1406 flag->load(flagsPath+"flag-arrow-down.png");
1407 flag->setGroup("standard-arrow");
1408 setupFlag (flag,tb,"arrow-down",tr("Unimportant","Standardflag"));
1410 flag->load(flagsPath+"flag-arrow-2up.png");
1411 flag->setGroup("standard-arrow");
1412 setupFlag (flag,tb,"2arrow-up",tr("Very important!","Standardflag"));
1414 flag->load(flagsPath+"flag-arrow-2down.png");
1415 flag->setGroup("standard-arrow");
1416 setupFlag (flag,tb,"2arrow-down",tr("Very unimportant!","Standardflag"));
1419 flag->load(flagsPath+"flag-thumb-up.png");
1420 flag->setGroup("standard-thumb");
1421 setupFlag (flag,tb,"thumb-up",tr("I like this","Standardflag"));
1423 flag->load(flagsPath+"flag-thumb-down.png");
1424 flag->setGroup("standard-thumb");
1425 setupFlag (flag,tb,"thumb-down",tr("I do not like this","Standardflag"));
1428 flag->load(flagsPath+"flag-rose.png");
1429 setupFlag (flag,tb,"rose",tr("Rose","Standardflag"));
1431 flag->load(flagsPath+"flag-heart.png");
1432 setupFlag (flag,tb,"heart",tr("I just love...","Standardflag"));
1434 flag->load(flagsPath+"flag-present.png");
1435 setupFlag (flag,tb,"present",tr("Surprise!","Standardflag"));
1437 flag->load(flagsPath+"flag-flash.png");
1438 setupFlag (flag,tb,"flash",tr("Dangerous","Standardflag"));
1440 // Original: xsldbg_output.png
1441 flag->load(flagsPath+"flag-info.png");
1442 setupFlag (flag,tb,"info",tr("Info","Standardflag"));
1444 // Original khelpcenter.png
1445 flag->load(flagsPath+"flag-lifebelt.png");
1446 setupFlag (flag,tb,"lifebelt",tr("This will help","Standardflag"));
1449 flag->setVisible(false);
1450 flag->load(flagsPath+"freemind/warning.png");
1451 setupFlag (flag,tb, "freemind-warning",tr("Important","Freemind-Flag"));
1453 for (int i=1; i<8; i++)
1455 flag->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
1456 setupFlag (flag,tb, QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
1459 flag->load(flagsPath+"freemind/back.png");
1460 setupFlag (flag,tb,"freemind-back",tr("Back","Freemind-Flag"));
1462 flag->load(flagsPath+"freemind/forward.png");
1463 setupFlag (flag,tb,"freemind-forward",tr("forward","Freemind-Flag"));
1465 flag->load(flagsPath+"freemind/attach.png");
1466 setupFlag (flag,tb,"freemind-attach",tr("Look here","Freemind-Flag"));
1468 flag->load(flagsPath+"freemind/clanbomber.png");
1469 setupFlag (flag,tb,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
1471 flag->load(flagsPath+"freemind/desktopnew.png");
1472 setupFlag (flag,tb,"freemind-desktopnew",tr("Don't flagrget","Freemind-Flag"));
1474 flag->load(flagsPath+"freemind/flag.png");
1475 setupFlag (flag,tb,"freemind-flag",tr("Flag","Freemind-Flag"));
1478 flag->load(flagsPath+"freemind/gohome.png");
1479 setupFlag (flag,tb,"freemind-gohome",tr("Home","Freemind-Flag"));
1482 flag->load(flagsPath+"freemind/kaddressbook.png");
1483 setupFlag (flag,tb,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
1485 flag->load(flagsPath+"freemind/knotify.png");
1486 setupFlag (flag,tb,"freemind-knotify",tr("Music","Freemind-Flag"));
1488 flag->load(flagsPath+"freemind/korn.png");
1489 setupFlag (flag,tb,"freemind-korn",tr("Mailbox","Freemind-Flag"));
1491 flag->load(flagsPath+"freemind/mail.png");
1492 setupFlag (flag,tb,"freemind-mail",tr("Maix","Freemind-Flag"));
1494 flag->load(flagsPath+"freemind/password.png");
1495 setupFlag (flag,tb,"freemind-password",tr("Password","Freemind-Flag"));
1497 flag->load(flagsPath+"freemind/pencil.png");
1498 setupFlag (flag,tb,"freemind-pencil",tr("To be improved","Freemind-Flag"));
1500 flag->load(flagsPath+"freemind/stop.png");
1501 setupFlag (flag,tb,"freemind-stop",tr("Stop","Freemind-Flag"));
1503 flag->load(flagsPath+"freemind/wizard.png");
1504 setupFlag (flag,tb,"freemind-wizard",tr("Magic","Freemind-Flag"));
1506 flag->load(flagsPath+"freemind/xmag.png");
1507 setupFlag (flag,tb,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
1509 flag->load(flagsPath+"freemind/bell.png");
1510 setupFlag (flag,tb,"freemind-bell",tr("Reminder","Freemind-Flag"));
1512 flag->load(flagsPath+"freemind/bookmark.png");
1513 setupFlag (flag,tb,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
1515 flag->load(flagsPath+"freemind/penguin.png");
1516 setupFlag (flag,tb,"freemind-penguin",tr("Linux","Freemind-Flag"));
1518 flag->load(flagsPath+"freemind/licq.png");
1519 setupFlag (flag,tb,"freemind-licq",tr("Sweet","Freemind-Flag"));
1522 void Main::setupFlag (Flag *flag, QToolBar *tb, const QString &name, const QString &tooltip)
1524 flag->setName(name);
1525 flag->setToolTip (tooltip);
1529 a=new QAction (flag->getPixmap(),name,this);
1532 flag->setAction (a);
1533 a->setVisible (flag->isVisible());
1534 a->setCheckable(true);
1535 a->setObjectName(name);
1536 a->setToolTip(tooltip);
1537 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1538 standardFlagsMaster->addFlag (flag);
1542 systemFlagsMaster->addFlag (flag);
1547 void Main::setupNetworkActions()
1549 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1551 QMenu *netMenu = menuBar()->addMenu( "Network" );
1555 a = new QAction( "Start TCPserver for MapEditor",this);
1556 //a->setStatusTip ( "Set application to open pdf files"));
1557 //a->setShortcut ( Qt::ALT + Qt::Key_T ); //New TCP server
1558 switchboard.addConnection(a,tr("Network shortcuts","Shortcut group"));
1559 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1560 netMenu->addAction (a);
1562 a = new QAction( "Connect MapEditor to server",this);
1563 //a->setStatusTip ( "Set application to open pdf files"));
1564 a->setShortcut ( Qt::ALT + Qt::Key_C ); // Connect to server
1565 switchboard.addConnection(a,tr("Network shortcuts","Shortcut group"));
1566 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1567 netMenu->addAction (a);
1571 void Main::setupSettingsActions()
1573 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1577 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1578 a->setStatusTip ( tr( "Set application to open pdf files"));
1579 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1580 settingsMenu->addAction (a);
1582 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1583 a->setStatusTip( tr( "Set application to open external links"));
1584 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1585 settingsMenu->addAction (a);
1587 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1588 a->setStatusTip( tr( "Set path for macros"));
1589 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1590 settingsMenu->addAction (a);
1592 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1593 a->setStatusTip( tr( "Set number of undo levels"));
1594 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1595 settingsMenu->addAction (a);
1597 settingsMenu->addSeparator();
1599 a = new QAction( tr( "Autosave","Settings action"), this);
1600 a->setStatusTip( tr( "Autosave"));
1601 a->setToggleAction(true);
1602 a->setChecked ( settings.value ("/mainwindow/autosave/use",false).toBool());
1603 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1604 settingsMenu->addAction (a);
1605 actionSettingsAutosaveToggle=a;
1607 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1608 a->setStatusTip( tr( "Autosave time"));
1609 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1610 settingsMenu->addAction (a);
1611 actionSettingsAutosaveTime=a;
1613 a = new QAction( tr( "Write backup file on save","Settings action"), this);
1614 a->setStatusTip( tr( "Write backup file on save"));
1615 a->setToggleAction(true);
1616 a->setChecked ( settings.value ("/mainwindow/writeBackupFile",false).toBool());
1617 connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) );
1618 settingsMenu->addAction (a);
1619 actionSettingsWriteBackupFile=a;
1621 settingsMenu->addSeparator();
1623 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1624 a->setStatusTip( tr( "Edit branch after adding it" ));
1625 a->setToggleAction(true);
1626 a->setChecked ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1627 settingsMenu->addAction (a);
1628 actionSettingsAutoEditNewBranch=a;
1630 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1631 a->setStatusTip( tr( "Select branch after adding it" ));
1632 a->setToggleAction(true);
1633 a->setChecked ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1634 settingsMenu->addAction (a);
1635 actionSettingsAutoSelectNewBranch=a;
1637 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1638 a->setStatusTip( tr( "Select heading before editing" ));
1639 a->setToggleAction(true);
1640 a->setChecked ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1641 settingsMenu->addAction (a);
1642 actionSettingsAutoSelectText=a;
1644 a= new QAction( tr( "Delete key","Settings action" ), this);
1645 a->setStatusTip( tr( "Delete key for deleting branches" ));
1646 a->setToggleAction(true);
1647 a->setChecked ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1648 settingsMenu->addAction (a);
1649 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1650 actionSettingsUseDelKey=a;
1652 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1653 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1654 a->setToggleAction(true);
1655 a->setChecked ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1656 settingsMenu->addAction (a);
1657 actionSettingsUseFlagGroups=a;
1659 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1660 a->setStatusTip( tr( "Use hide flag during exports " ));
1661 a->setToggleAction(true);
1662 a->setChecked ( settings.value ("/export/useHideExport",true).toBool() );
1663 settingsMenu->addAction (a);
1664 actionSettingsUseHideExport=a;
1666 a = new QAction( tr( "Animation","Settings action"), this);
1667 a->setStatusTip( tr( "Animation"));
1668 a->setToggleAction(true);
1669 a->setChecked (settings.value("/animation/use",true).toBool() );
1670 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) );
1671 settingsMenu->addAction (a);
1672 actionSettingsUseAnimation=a;
1676 void Main::setupTestActions()
1678 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1681 a = new QAction( "Test function 1" , this);
1682 a->setStatusTip( "Call test function 1" );
1683 a->setShortcut (Qt::SHIFT + Qt::Key_T); // Test function 1
1684 switchboard.addConnection(a,tr("Test shortcuts","Shortcut group"));
1685 testMenu->addAction (a);
1686 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1688 a = new QAction( "Test function 2" , this);
1689 a->setStatusTip( "Call test function 2" );
1690 a->setShortcut (Qt::ALT + Qt::Key_T); // Test function 2
1691 switchboard.addConnection(a,tr("Test shortcuts","Shortcut group"));
1692 testMenu->addAction (a);
1693 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1695 a = new QAction( "Command" , this);
1696 a->setStatusTip( "Enter command to call in editor" );
1697 switchboard.addConnection(a,tr("Test shortcuts","Shortcut group"));
1698 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1699 testMenu->addAction (a);
1703 void Main::setupHelpActions()
1705 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1708 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1709 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1710 switchboard.addConnection(a,tr("Help shortcuts","Shortcut group"));
1711 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1712 helpMenu->addAction (a);
1714 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1715 a->setStatusTip( tr( "Open VYM example maps " ));
1716 switchboard.addConnection(a,tr("Help shortcuts","Shortcut group"));
1717 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1718 helpMenu->addAction (a);
1720 a = new QAction( tr( "About VYM","Help action" ), this);
1721 a->setStatusTip( tr( "About VYM")+vymName);
1722 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1723 helpMenu->addAction (a);
1725 a = new QAction( tr( "About QT","Help action" ), this);
1726 a->setStatusTip( tr( "Information about QT toolkit" ));
1727 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1728 helpMenu->addAction (a);
1732 void Main::setupContextMenus()
1736 // Context Menu for branch or mapcenter
1737 branchContextMenu =new QMenu (this);
1738 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1739 branchContextMenu->addSeparator();
1742 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1743 branchAddContextMenu->addAction (actionPaste );
1744 branchAddContextMenu->addAction ( actionAddMapCenter );
1745 branchAddContextMenu->addAction ( actionAddBranch );
1746 branchAddContextMenu->addAction ( actionAddBranchBefore );
1747 branchAddContextMenu->addAction ( actionAddBranchAbove);
1748 branchAddContextMenu->addAction ( actionAddBranchBelow );
1749 branchAddContextMenu->addSeparator();
1750 branchAddContextMenu->addAction ( actionImportAdd );
1751 branchAddContextMenu->addAction ( actionImportReplace );
1754 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1755 branchRemoveContextMenu->addAction (actionCut);
1756 branchRemoveContextMenu->addAction ( actionDelete );
1757 branchRemoveContextMenu->addAction ( actionDeleteKeepChildren );
1758 branchRemoveContextMenu->addAction ( actionDeleteChildren );
1761 actionSaveBranch->addTo( branchContextMenu );
1762 actionFileNewCopy->addTo (branchContextMenu );
1763 actionDetach->addTo (branchContextMenu );
1765 branchContextMenu->addSeparator();
1766 branchContextMenu->addAction ( actionLoadImage);
1767 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1768 branchContextMenu->addAction ( actionAddAttribute);
1770 // Submenu for Links (URLs, vymLinks)
1771 branchLinksContextMenu =new QMenu (this);
1773 branchContextMenu->addSeparator();
1774 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1775 branchLinksContextMenu->addAction ( actionOpenURL );
1776 branchLinksContextMenu->addAction ( actionOpenURLTab );
1777 branchLinksContextMenu->addAction ( actionOpenMultipleVisURLTabs );
1778 branchLinksContextMenu->addAction ( actionOpenMultipleURLTabs );
1779 branchLinksContextMenu->addAction ( actionURL );
1780 branchLinksContextMenu->addAction ( actionLocalURL );
1781 branchLinksContextMenu->addAction ( actionHeading2URL );
1782 branchLinksContextMenu->addAction ( actionBugzilla2URL );
1783 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1785 branchLinksContextMenu->addAction ( actionGetBugzillaData );
1786 branchLinksContextMenu->addAction ( actionFATE2URL );
1788 branchLinksContextMenu->addSeparator();
1789 branchLinksContextMenu->addAction ( actionOpenVymLink );
1790 branchLinksContextMenu->addAction ( actionOpenMultipleVymLinks );
1791 branchLinksContextMenu->addAction ( actionVymLink );
1792 branchLinksContextMenu->addAction ( actionDeleteVymLink );
1795 // Context Menu for XLinks in a branch menu
1796 // This will be populated "on demand" in MapEditor::updateActions
1797 branchContextMenu->addSeparator();
1798 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1799 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1802 // Context menu for floatimage
1803 floatimageContextMenu =new QMenu (this);
1804 a= new QAction (tr ("Save image","Context action"),this);
1805 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1806 floatimageContextMenu->addAction (a);
1808 floatimageContextMenu->addSeparator();
1809 actionCopy->addTo( floatimageContextMenu );
1810 actionCut->addTo( floatimageContextMenu );
1812 floatimageContextMenu->addSeparator();
1813 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1816 // Context menu for canvas
1817 canvasContextMenu =new QMenu (this);
1818 actionAddMapCenter->addTo( canvasContextMenu );
1819 actionMapInfo->addTo( canvasContextMenu );
1820 canvasContextMenu->insertSeparator();
1821 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1822 canvasContextMenu->insertSeparator();
1823 actionFormatLinkColorHint->addTo( canvasContextMenu );
1824 actionFormatLinkColor->addTo( canvasContextMenu );
1825 actionFormatSelectionColor->addTo( canvasContextMenu );
1826 actionFormatBackColor->addTo( canvasContextMenu );
1827 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME-4 makes vym too slow: postponed for later version
1829 // Menu for last opened files
1831 for (int i = 0; i < MaxRecentFiles; ++i)
1833 recentFileActions[i] = new QAction(this);
1834 recentFileActions[i]->setVisible(false);
1835 fileLastMapsMenu->addAction(recentFileActions[i]);
1836 connect(recentFileActions[i], SIGNAL(triggered()),
1837 this, SLOT(fileLoadRecent()));
1839 setupRecentMapsMenu();
1842 void Main::setupRecentMapsMenu()
1844 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1846 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1848 for (int i = 0; i < numRecentFiles; ++i) {
1849 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1850 recentFileActions[i]->setText(text);
1851 recentFileActions[i]->setData(files[i]);
1852 recentFileActions[i]->setVisible(true);
1854 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1855 recentFileActions[j]->setVisible(false);
1858 void Main::setupMacros()
1860 for (int i = 0; i <= 11; i++)
1862 macroActions[i] = new QAction(this);
1863 macroActions[i]->setData(i);
1864 addAction (macroActions[i]);
1865 //switchboard.addConnection(macroActions[i],tr("Macro shortcuts","Shortcut group"));
1866 connect(macroActions[i], SIGNAL(triggered()),
1867 this, SLOT(callMacro()));
1869 macroActions[0]->setShortcut ( Qt::Key_F1 );
1870 macroActions[1]->setShortcut ( Qt::Key_F2 );
1871 macroActions[2]->setShortcut ( Qt::Key_F3 );
1872 macroActions[3]->setShortcut ( Qt::Key_F4 );
1873 macroActions[4]->setShortcut ( Qt::Key_F5 );
1874 macroActions[5]->setShortcut ( Qt::Key_F6 );
1875 macroActions[6]->setShortcut ( Qt::Key_F7 );
1876 macroActions[7]->setShortcut ( Qt::Key_F8 );
1877 macroActions[8]->setShortcut ( Qt::Key_F9 );
1878 macroActions[9]->setShortcut ( Qt::Key_F10 );
1879 macroActions[10]->setShortcut ( Qt::Key_F11 );
1880 macroActions[11]->setShortcut ( Qt::Key_F12 );
1883 void Main::hideEvent (QHideEvent * )
1885 if (!textEditor->isMinimized() ) textEditor->hide();
1888 void Main::showEvent (QShowEvent * )
1890 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1894 MapEditor* Main::currentMapEditor() const
1896 if ( tabWidget->currentPage())
1897 return vymViews.at(tabWidget->currentIndex())->getMapEditor();
1901 VymModel* Main::currentModel() const
1903 if ( tabWidget->currentPage())
1904 return vymViews.at(tabWidget->currentIndex())->getModel();
1908 VymModel* Main::getModel(uint id) const
1910 if ( tabWidget->currentPage())
1911 return vymViews.at(tabWidget->currentIndex())->getModel();
1916 void Main::editorChanged(QWidget *)
1918 // Unselect all possibly selected objects
1919 // (Important to update note editor)
1921 for (int i=0;i<=tabWidget->count() -1;i++)
1923 m= vymViews.at(i)->getModel();
1924 if (m) m->unselect();
1927 if (m) m->reselect();
1929 // Update actions to in menus and toolbars according to editor
1933 void Main::fileNew()
1935 VymModel *vm=new VymModel;
1937 /////////////////////////////////////
1938 // new ModelTest(vm, this); //FIXME-3
1939 /////////////////////////////////////
1941 VymView *vv=new VymView (vm);
1942 vymViews.append (vv);
1943 tabWidget->addTab (vv,tr("unnamed","MainWindow: name for new and empty file"));
1944 tabWidget->setCurrentIndex (vymViews.count() );
1947 // Create MapCenter for empty map
1951 // For the very first map we do not have flagrows yet...
1955 void Main::fileNewCopy()
1957 QString fn="unnamed";
1958 VymModel *srcModel=currentModel();
1963 VymModel *dstModel=vymViews.last()->getModel();
1964 dstModel->select("mc:");
1965 dstModel->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
1969 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
1971 ErrorCode err=success;
1973 // fn is usually the archive, mapfile the file after uncompressing
1976 // Make fn absolute (needed for unzip)
1977 fn=QDir (fn).absPath();
1983 // Check, if map is already loaded
1985 while (i<=tabWidget->count() -1)
1987 if (vymViews.at(i)->getModel()->getFilePath() == fn)
1989 // Already there, ask for confirmation
1990 QMessageBox mb( vymName,
1991 tr("The map %1\nis already opened."
1992 "Opening the same map in multiple editors may lead \n"
1993 "to confusion when finishing working with vym."
1994 "Do you want to").arg(fn),
1995 QMessageBox::Warning,
1996 QMessageBox::Yes | QMessageBox::Default,
1997 QMessageBox::Cancel | QMessageBox::Escape,
1998 QMessageBox::NoButton);
1999 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
2000 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2003 case QMessageBox::Yes:
2004 // end loop and load anyway
2005 i=tabWidget->count();
2007 case QMessageBox::Cancel:
2017 int tabIndex=tabWidget->currentPageIndex();
2020 if ( !fn.isEmpty() )
2022 vm = currentModel();
2023 // Check first, if mapeditor exists
2024 // If it is not default AND we want a new map,
2025 // create a new mapeditor in a new tab
2026 if ( lmode==NewMap && (!vm || !vm->isDefault() ) )
2029 VymView *vv=new VymView (vm);
2030 vymViews.append (vv);
2031 tabWidget->addTab (vv,fn);
2032 tabIndex=tabWidget->count()-1;
2033 tabWidget->setCurrentPage (tabIndex);
2037 // Check, if file exists (important for creating new files
2038 // from command line
2039 if (!QFile(fn).exists() )
2041 QMessageBox mb( vymName,
2042 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
2043 QMessageBox::Question,
2045 QMessageBox::Cancel | QMessageBox::Default,
2046 QMessageBox::NoButton );
2048 mb.setButtonText( QMessageBox::Yes, tr("Create"));
2049 mb.setButtonText( QMessageBox::No, tr("Cancel"));
2052 case QMessageBox::Yes:
2054 currentMapEditor()->getModel()->setFilePath(fn);
2055 tabWidget->setTabText (tabIndex,
2056 currentMapEditor()->getModel()->getFileName() );
2057 statusBar()->message( "Created " + fn , statusbarTime );
2060 case QMessageBox::Cancel:
2061 // don't create new map
2062 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
2069 //tabWidget->currentPage() won't be NULL here, because of above...
2070 tabWidget->setCurrentIndex (tabIndex);
2071 //FIXME-3 no me anymore... me->viewport()->setFocus();
2075 // Save existing filename in case we import
2076 QString fn_org=vm->getFilePath();
2078 // Finally load map into mapEditor
2079 vm->setFilePath (fn);
2080 err=vm->load(fn,lmode,ftype);
2082 // Restore old (maybe empty) filepath, if this is an import
2084 vm->setFilePath (fn_org);
2087 // Finally check for errors and go home
2090 if (lmode==NewMap) fileCloseMap();
2091 statusBar()->message( "Could not load " + fn, statusbarTime );
2096 vm->setFilePath (fn);
2097 tabWidget->setTabText (tabIndex, vm->getFileName());
2098 if (!isInTmpDir (fn))
2100 // Only append to lastMaps if not loaded from a tmpDir
2101 // e.g. imported bookmarks are in a tmpDir
2102 addRecentMap(vm->getFilePath() );
2104 actionFilePrint->setEnabled (true);
2106 statusBar()->message( "Loaded " + fn, statusbarTime );
2113 void Main::fileLoad(const LoadMode &lmode)
2115 QStringList filters;
2116 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
2117 QFileDialog *fd=new QFileDialog( this);
2118 fd->setDir (lastFileDir);
2119 fd->setFileMode (QFileDialog::ExistingFiles);
2120 fd->setFilters (filters);
2124 fd->setCaption(vymName+ " - " +tr("Load vym map"));
2127 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
2130 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
2136 if ( fd->exec() == QDialog::Accepted )
2138 lastFileDir=fd->directory().path();
2139 QStringList flist = fd->selectedFiles();
2140 QStringList::Iterator it = flist.begin();
2142 progressCounter=flist.count();
2143 progressCounterTotal=flist.count();
2144 while( it != flist.end() )
2147 fileLoad(*it, lmode);
2154 void Main::fileLoad()
2159 void Main::fileLoadRecent()
2161 QAction *action = qobject_cast<QAction *>(sender());
2163 fileLoad (action->data().toString(), NewMap);
2166 void Main::addRecentMap (const QString &fileName)
2169 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
2170 files.removeAll(fileName);
2171 files.prepend(fileName);
2172 while (files.size() > MaxRecentFiles)
2175 settings.setValue("/mainwindow/recentFileList", files);
2177 setupRecentMapsMenu();
2180 void Main::fileSave(VymModel *m, const SaveMode &savemode)
2184 if ( m->getFilePath().isEmpty() )
2186 // We have no filepath yet,
2187 // call fileSaveAs() now, this will call fileSave()
2189 // First switch to editor
2190 //FIXME-3 needed??? tabWidget->setCurrentWidget (m->getMapEditor());
2191 fileSaveAs(savemode);
2194 if (m->save (savemode)==success)
2196 statusBar()->message(
2197 tr("Saved %1").arg(m->getFilePath()),
2199 addRecentMap (m->getFilePath() );
2201 statusBar()->message(
2202 tr("Couldn't save ").arg(m->getFilePath()),
2206 void Main::fileSave()
2208 fileSave (currentModel(), CompleteMap);
2211 void Main::fileSave(VymModel *m)
2213 fileSave (m,CompleteMap);
2216 void Main::fileSaveAs(const SaveMode& savemode)
2220 if (currentMapEditor())
2222 if (savemode==CompleteMap)
2223 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2225 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2226 if ( !fn.isEmpty() )
2228 // Check for existing file
2229 if (QFile (fn).exists())
2231 QMessageBox mb( vymName,
2232 tr("The file %1\nexists already. Do you want to").arg(fn),
2233 QMessageBox::Warning,
2234 QMessageBox::Yes | QMessageBox::Default,
2235 QMessageBox::Cancel | QMessageBox::Escape,
2236 QMessageBox::NoButton);
2237 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2238 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2241 case QMessageBox::Yes:
2244 case QMessageBox::Cancel:
2251 // New file, add extension to filename, if missing
2252 // This is always .vym or .vyp, depending on savemode
2253 if (savemode==CompleteMap)
2255 if (!fn.contains (".vym") && !fn.contains (".xml"))
2259 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2268 VymModel *m=currentModel();
2270 fileSave(m, savemode);
2272 // Set name of tab, assuming current tab is the one we just saved
2273 if (savemode==CompleteMap)
2274 tabWidget->setTabText (tabWidget->currentIndex(), m->getFileName() );
2280 void Main::fileSaveAs()
2282 fileSaveAs (CompleteMap);
2285 void Main::fileImportKDE3Bookmarks()
2287 ImportKDE3Bookmarks im;
2289 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2290 currentMapEditor()->getModel()->setFilePath ("");
2293 void Main::fileImportKDE4Bookmarks()
2295 ImportKDE4Bookmarks im;
2297 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2298 currentMapEditor()->getModel()->setFilePath ("");
2301 void Main::fileImportFirefoxBookmarks()
2303 Q3FileDialog *fd=new Q3FileDialog( this);
2304 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2305 fd->setMode (Q3FileDialog::ExistingFiles);
2306 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2307 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2310 if ( fd->exec() == QDialog::Accepted )
2312 ImportFirefoxBookmarks im;
2313 QStringList flist = fd->selectedFiles();
2314 QStringList::Iterator it = flist.begin();
2315 while( it != flist.end() )
2318 if (im.transform() &&
2319 aborted!=fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2320 currentMapEditor() )
2321 currentMapEditor()->getModel()->setFilePath ("");
2328 void Main::fileImportFreemind()
2330 QStringList filters;
2331 filters <<"Freemind map (*.mm)"<<"All files (*)";
2332 QFileDialog *fd=new QFileDialog( this);
2333 fd->setDir (lastFileDir);
2334 fd->setFileMode (QFileDialog::ExistingFiles);
2335 fd->setFilters (filters);
2336 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2340 if ( fd->exec() == QDialog::Accepted )
2342 lastFileDir=fd->directory().path();
2343 QStringList flist = fd->selectedFiles();
2344 QStringList::Iterator it = flist.begin();
2345 while( it != flist.end() )
2348 if ( fileLoad (fn,NewMap, FreemindMap) )
2350 currentMapEditor()->getModel()->setFilePath ("");
2359 void Main::fileImportMM()
2363 Q3FileDialog *fd=new Q3FileDialog( this);
2364 fd->setDir (lastFileDir);
2365 fd->setMode (Q3FileDialog::ExistingFiles);
2366 fd->addFilter ("Mind Manager (*.mmap)");
2367 fd->setCaption(tr("Import")+" "+"Mind Manager");
2370 if ( fd->exec() == QDialog::Accepted )
2372 lastFileDir=fd->dirPath();
2373 QStringList flist = fd->selectedFiles();
2374 QStringList::Iterator it = flist.begin();
2375 while( it != flist.end() )
2378 if (im.transform() &&
2379 success==fileLoad (im.getTransformedFile(),NewMap) &&
2380 currentMapEditor() )
2381 currentMapEditor()->getModel()->setFilePath ("");
2388 void Main::fileImportDir()
2390 VymModel *m=currentModel();
2391 if (m) m->importDir();
2394 void Main::fileExportXML()
2396 VymModel *m=currentModel();
2397 if (m) m->exportXML();
2400 void Main::fileExportHTML()
2402 VymModel *m=currentModel();
2403 if (m) m->exportHTML();
2407 void Main::fileExportXHTML()
2409 VymModel *m=currentModel();
2410 if (m) m->exportXHTML();
2413 void Main::fileExportImage()
2415 VymModel *m=currentModel();
2416 if (m) m->exportImage();
2419 void Main::fileExportAO()
2421 VymModel *m=currentModel();
2422 if (m) m->exportAO();
2425 void Main::fileExportASCII()
2427 VymModel *m=currentModel();
2428 if (m) m->exportASCII();
2431 void Main::fileExportCSV() //FIXME-3 not scriptable yet
2433 VymModel *m=currentModel();
2438 ex.addFilter ("CSV (*.csv)");
2439 ex.setDir(lastImageDir);
2440 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2441 if (ex.execDialog() )
2443 m->setExportMode(true);
2445 m->setExportMode(false);
2450 void Main::fileExportLaTeX() //FIXME-3 not scriptable yet
2452 VymModel *m=currentModel();
2457 ex.addFilter ("Tex (*.tex)");
2458 ex.setDir(lastImageDir);
2459 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2460 if (ex.execDialog() )
2462 m->setExportMode(true);
2464 m->setExportMode(false);
2469 void Main::fileExportKDE3Bookmarks() //FIXME-3 not scriptable yet
2471 ExportKDE3Bookmarks ex;
2472 VymModel *m=currentModel();
2480 void Main::fileExportKDE4Bookmarks() //FIXME-3 not scriptable yet
2482 ExportKDE4Bookmarks ex;
2483 VymModel *m=currentModel();
2491 void Main::fileExportTaskjuggler() //FIXME-3 not scriptable yet
2493 ExportTaskjuggler ex;
2494 VymModel *m=currentModel();
2498 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2499 ex.setDir(lastImageDir);
2500 ex.addFilter ("Taskjuggler (*.tjp)");
2501 if (ex.execDialog() )
2503 m->setExportMode(true);
2505 m->setExportMode(false);
2510 void Main::fileExportOOPresentation() //FIXME-3 not scriptable yet
2512 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2513 // TODO add preview in dialog
2514 //ImagePreview *p =new ImagePreview (fd);
2515 //fd->setContentsPreviewEnabled( TRUE );
2516 //fd->setContentsPreview( p, p );
2517 //fd->setPreviewMode( QFileDialog::Contents );
2518 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2519 fd->setDir (QDir().current());
2520 if (fd->foundConfig())
2524 if ( fd->exec() == QDialog::Accepted )
2526 QString fn=fd->selectedFile();
2527 if (!fn.contains (".odp"))
2530 //lastImageDir=fn.left(fn.findRev ("/"));
2531 VymModel *m=currentModel();
2532 if (m) m->exportOOPresentation(fn,fd->selectedConfig());
2536 QMessageBox::warning(0,
2538 tr("Couldn't find configuration for export to Open Office\n"));
2542 void Main::fileCloseMap()
2544 VymModel *m=currentModel();
2547 if (m->hasChanged())
2549 QMessageBox mb( vymName,
2550 tr("The map %1 has been modified but not saved yet. Do you want to").arg(m->getFileName()),
2551 QMessageBox::Warning,
2552 QMessageBox::Yes | QMessageBox::Default,
2554 QMessageBox::Cancel | QMessageBox::Escape );
2555 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2556 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2559 case QMessageBox::Yes:
2561 fileSave(m, CompleteMap);
2563 case QMessageBox::No:
2564 // close without saving
2566 case QMessageBox::Cancel:
2571 // And here comes the segfault, because removeTab triggers
2572 // FIXME-3 currentChanged->Main::editorChanged -> updateActions and VM is not NULL yet...
2573 vymViews.removeAt (tabWidget->currentIndex() );
2574 tabWidget->removeTab (tabWidget->currentIndex() );
2576 // Remove mapEditor/model FIXME-3 Huh? seems to work now...
2577 // Better would be delete (me), but then we could have a Qt error:
2578 // "QObject: Do not delete object, 'MapEditor', during its event handler!"
2579 // So we only remove data now and call deconstructor when vym closes later
2580 // this needs to be moved to vymview... me->clear();
2581 // some model->clear is needed to free up memory ...
2583 delete (m->getMapEditor());
2590 void Main::filePrint()
2592 if (currentMapEditor())
2593 currentMapEditor()->print();
2596 void Main::fileExitVYM()
2598 // Check if one or more editors have changed
2600 for (i=0;i<=vymViews.count() -1;i++)
2602 // If something changed, ask what to do
2603 if (vymViews.at(i)->getModel()->hasChanged())
2605 tabWidget->setCurrentPage(i);
2606 QMessageBox mb( vymName,
2607 tr("This map is not saved yet. Do you want to"),
2608 QMessageBox::Warning,
2609 QMessageBox::Yes | QMessageBox::Default,
2611 QMessageBox::Cancel | QMessageBox::Escape );
2612 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2613 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2616 mb.setActiveWindow();
2617 switch( mb.exec() ) {
2618 case QMessageBox::Yes:
2619 // save (the changed editors) and exit
2620 fileSave(currentModel(), CompleteMap);
2622 case QMessageBox::No:
2623 // exit without saving
2625 case QMessageBox::Cancel:
2626 // don't save and don't exit
2630 } // loop over all MEs
2634 void Main::editUndo()
2636 VymModel *m=currentModel();
2640 void Main::editRedo()
2642 VymModel *m=currentModel();
2646 void Main::gotoHistoryStep (int i)
2648 VymModel *m=currentModel();
2649 if (m) m->gotoHistoryStep(i);
2652 void Main::editCopy()
2654 VymModel *m=currentModel();
2658 void Main::editPaste()
2660 VymModel *m=currentModel();
2664 void Main::editCut()
2666 VymModel *m=currentModel();
2670 void Main::editOpenFindWidget()
2672 VymModel *m=currentModel();
2673 if (m) m->emitShowFindWidget();
2676 void Main::editFindDuplicateURLs()
2678 VymModel *m=currentModel();
2679 if (m) m->findDuplicateURLs();
2682 void Main::openTabs(QStringList urls)
2684 if (!urls.isEmpty())
2688 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2689 //qDebug ()<<"Services: "<<QDBusConnection::sessionBus().interface()->registeredServiceNames().value();
2690 if (*browserPID==0 ||
2691 (browser.contains("konqueror") &&
2692 !QDBusConnection::sessionBus().interface()->registeredServiceNames().value().contains (QString("org.kde.konqueror-%1").arg(*browserPID)))
2695 // Start a new browser, if there is not one running already or
2696 // if a previously started konqueror is gone.
2697 if (debug) cout <<"Main::openTabs no konqueror-"<<*browserPID<<" found\n";
2698 QString u=urls.takeFirst();
2700 QString workDir=QDir::currentDirPath();
2701 if (!QProcess::startDetached(browser,args,workDir,browserPID))
2703 // try to set path to browser
2704 QMessageBox::warning(0,
2706 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2707 tr("Please use Settings->")+tr("Set application to open an URL"));
2710 if (debug) cout << "Main::openTabs Started konqueror-"<<*browserPID<<endl;
2711 #if defined(Q_OS_WIN32)
2712 // There's no sleep in VCEE, replace it with Qt's QThread::wait().
2713 this->thread()->wait(3000);
2715 sleep (3); //FIXME-3 needed?
2719 if (browser.contains("konqueror"))
2721 for (int i=0; i<urls.size(); i++)
2724 // Try to open new tab in existing konqueror started previously by vym
2728 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2729 "konqueror-mainwindow#1"<<
2733 args<< QString("org.kde.konqueror-%1").arg(*browserPID)<<
2734 "/konqueror/MainWindow_1"<<
2738 if (debug) cout << "MainWindow::openURLs args="<<args.join(" ").toStdString()<<endl;
2739 if (!QProcess::startDetached ("qdbus",args))
2743 QMessageBox::warning(0,
2745 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2747 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2749 for (int i=0; i<urls.size(); i++)
2751 // Try to open new tab in firefox
2752 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2753 if (!QProcess::startDetached (browser,args))
2757 QMessageBox::warning(0,
2759 tr("Couldn't start %1 to open a new tab").arg(browser));
2762 QMessageBox::warning(0,
2764 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2768 void Main::editOpenURL()
2771 VymModel *m=currentModel();
2774 QString url=m->getURL();
2776 if (url=="") return;
2777 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2779 QString workDir=QDir::currentDirPath();
2780 if (!procBrowser->startDetached(browser,args))
2782 // try to set path to browser
2783 QMessageBox::warning(0,
2785 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2786 tr("Please use Settings->")+tr("Set application to open an URL"));
2791 void Main::editOpenURLTab()
2793 VymModel *m=currentModel();
2797 urls.append(m->getURL());
2802 void Main::editOpenMultipleVisURLTabs(bool ignoreScrolled)
2804 VymModel *m=currentModel();
2808 urls=m->getURLs(ignoreScrolled);
2813 void Main::editOpenMultipleURLTabs()
2815 editOpenMultipleVisURLTabs (false);
2819 void Main::editURL()
2821 VymModel *m=currentModel();
2822 if (m) m->editURL();
2825 void Main::editLocalURL()
2827 VymModel *m=currentModel();
2828 if (m) m->editLocalURL();
2831 void Main::editHeading2URL()
2833 VymModel *m=currentModel();
2834 if (m) m->editHeading2URL();
2837 void Main::editBugzilla2URL()
2839 VymModel *m=currentModel();
2840 if (m) m->editBugzilla2URL();
2843 void Main::getBugzillaData()
2845 VymModel *m=currentModel();
2847 QProgressDialog progress ("Doing stuff","cancl",0,10,this);
2848 progress.setWindowModality(Qt::WindowModal);
2849 //progress.setCancelButton (NULL);
2851 progress.setMinimumDuration (0);
2852 progress.setValue (1);
2853 progress.setValue (5);
2857 QProgressBar *pb=new QProgressBar;
2863 if (m) m->getBugzillaData();
2866 void Main::editFATE2URL()
2868 VymModel *m=currentModel();
2869 if (m) m->editFATE2URL();
2872 void Main::editHeadingFinished(VymModel *m)
2876 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2877 !prevSelection.isEmpty())
2878 m->select(prevSelection);
2883 void Main::openVymLinks(const QStringList &vl)
2885 for (int j=0; j<vl.size(); j++)
2887 // compare path with already loaded maps
2890 for (i=0;i<=vymViews.count() -1;i++)
2892 if (vl.at(j)==vymViews.at(i)->getModel()->getFilePath() )
2901 if (!QFile(vl.at(j)).exists() )
2902 QMessageBox::critical( 0, tr( "Critical Error" ),
2903 tr("Couldn't open map %1").arg(vl.at(j)));
2906 fileLoad (vl.at(j), NewMap);
2907 tabWidget->setCurrentIndex (tabWidget->count()-1);
2910 // Go to tab containing the map
2911 tabWidget->setCurrentIndex (index);
2915 void Main::editOpenVymLink()
2917 VymModel *m=currentModel();
2921 vl.append(m->getVymLink());
2926 void Main::editOpenMultipleVymLinks()
2928 QString currentVymLink;
2929 VymModel *m=currentModel();
2932 QStringList vl=m->getVymLinks();
2937 void Main::editVymLink()
2939 VymModel *m=currentModel();
2944 void Main::editDeleteVymLink()
2946 VymModel *m=currentModel();
2947 if (m) m->deleteVymLink();
2950 void Main::editToggleHideExport()
2952 VymModel *m=currentModel();
2953 if (m) m->toggleHideExport();
2956 void Main::editAddTimestamp()
2958 VymModel *m=currentModel();
2959 if (m) m->addTimestamp();
2962 void Main::editMapInfo()
2964 VymModel *m=currentModel();
2967 ExtraInfoDialog dia;
2968 dia.setMapName (m->getFileName() );
2969 dia.setAuthor (m->getAuthor() );
2970 dia.setComment(m->getComment() );
2974 stats+=tr("%1 items on map\n","Info about map").arg (m->getScene()->items().size(),6);
2980 BranchItem *cur=NULL;
2981 BranchItem *prev=NULL;
2982 m->nextBranch(cur,prev);
2985 if (!cur->getNote().isEmpty() ) n++;
2986 f+= cur->imageCount();
2988 xl+=cur->xlinkCount();
2989 m->nextBranch(cur,prev);
2992 stats+=QString ("%1 xLinks \n").arg (xl,6);
2993 stats+=QString ("%1 notes\n").arg (n,6);
2994 stats+=QString ("%1 images\n").arg (f,6);
2995 stats+=QString ("%1 branches\n").arg (m->branchCount(),6);
2996 dia.setStats (stats);
2998 // Finally show dialog
2999 if (dia.exec() == QDialog::Accepted)
3001 m->setAuthor (dia.getAuthor() );
3002 m->setComment (dia.getComment() );
3006 void Main::editMoveUp()
3008 VymModel *m=currentModel();
3012 void Main::editMoveDown()
3014 VymModel *m=currentModel();
3015 if (m) m->moveDown();
3018 void Main::editDetach()
3020 VymModel *m=currentModel();
3024 void Main::editSortChildren()
3026 VymModel *m=currentModel();
3027 if (m) m->sortChildren(false);
3030 void Main::editSortBackChildren()
3032 VymModel *m=currentModel();
3033 if (m) m->sortChildren(true);
3036 void Main::editToggleScroll()
3038 VymModel *m=currentModel();
3039 if (m) m->toggleScroll();
3042 void Main::editExpandAll()
3044 VymModel *m=currentModel();
3045 if (m) m->emitExpandAll();
3048 void Main::editExpandOneLevel()
3050 VymModel *m=currentModel();
3051 if (m) m->emitExpandOneLevel();
3054 void Main::editCollapseOneLevel()
3056 VymModel *m=currentModel();
3057 if (m) m->emitCollapseOneLevel();
3060 void Main::editUnscrollChildren()
3062 VymModel *m=currentModel();
3063 if (m) m->unscrollChildren();
3066 void Main::editAddAttribute()
3068 VymModel *m=currentModel();
3076 void Main::editAddMapCenter()
3078 VymModel *m=currentModel();
3079 if (m) m->addMapCenter ();
3082 void Main::editNewBranch()
3084 VymModel *m=currentModel();
3087 BranchItem *bi=m->addNewBranch();
3090 if (actionSettingsAutoEditNewBranch->isOn()
3091 && !actionSettingsAutoSelectNewBranch->isOn() )
3092 prevSelection=m->getSelectString();
3094 prevSelection=QString();
3096 if (actionSettingsAutoSelectNewBranch->isOn()
3097 || actionSettingsAutoEditNewBranch->isOn())
3100 if (actionSettingsAutoEditNewBranch->isOn())
3101 currentMapEditor()->editHeading();
3106 void Main::editNewBranchBefore()
3108 VymModel *m=currentModel();
3111 BranchItem *bi=m->addNewBranchBefore();
3118 if (actionSettingsAutoEditNewBranch->isOn())
3120 if (!actionSettingsAutoSelectNewBranch->isOn())
3121 prevSelection=m->getSelectString(bi);
3122 currentMapEditor()->editHeading();
3127 void Main::editNewBranchAbove()
3129 VymModel *m=currentModel();
3132 BranchItem *bi=m->addNewBranch (-1);
3140 if (actionSettingsAutoEditNewBranch->isOn())
3142 if (!actionSettingsAutoSelectNewBranch->isOn())
3143 prevSelection=m->getSelectString (bi);
3144 currentMapEditor()->editHeading();
3149 void Main::editNewBranchBelow()
3151 VymModel *m=currentModel();
3154 BranchItem *bi=m->addNewBranch (1);
3161 if (actionSettingsAutoEditNewBranch->isOn())
3163 if (!actionSettingsAutoSelectNewBranch->isOn())
3164 prevSelection=m->getSelectString(bi);
3165 currentMapEditor()->editHeading();
3170 void Main::editImportAdd()
3172 fileLoad (ImportAdd);
3175 void Main::editImportReplace()
3177 fileLoad (ImportReplace);
3180 void Main::editSaveBranch()
3182 fileSaveAs (PartOfMap);
3185 void Main::editDeleteKeepChildren()
3187 VymModel *m=currentModel();
3188 if (m) m->deleteKeepChildren();
3191 void Main::editDeleteChildren()
3193 VymModel *m=currentModel();
3194 if (m) m->deleteChildren();
3197 void Main::editDeleteSelection()
3199 VymModel *m=currentModel();
3200 if (m && actionSettingsUseDelKey->isOn())
3201 m->deleteSelection();
3204 void Main::editLoadImage()
3206 VymModel *m=currentModel();
3207 if (m) m->loadFloatImage();
3210 void Main::editSaveImage()
3212 VymModel *m=currentModel();
3213 if (m) m->saveFloatImage();
3216 void Main::editEditXLink(QAction *a)
3218 VymModel *m=currentModel();
3220 m->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3223 void Main::formatSelectColor()
3225 QColor col = QColorDialog::getColor((currentColor ), this );
3226 if ( !col.isValid() ) return;
3227 colorChanged( col );
3230 void Main::formatPickColor()
3232 VymModel *m=currentModel();
3234 colorChanged( m->getCurrentHeadingColor() );
3237 void Main::colorChanged(QColor c)
3239 QPixmap pix( 16, 16 );
3241 actionFormatColor->setIconSet( pix );
3245 void Main::formatColorBranch()
3247 VymModel *m=currentModel();
3248 if (m) m->colorBranch(currentColor);
3251 void Main::formatColorSubtree()
3253 VymModel *m=currentModel();
3254 if (m) m->colorSubtree (currentColor);
3257 void Main::formatLinkStyleLine()
3259 VymModel *m=currentModel();
3262 m->setMapLinkStyle("StyleLine");
3263 actionFormatLinkStyleLine->setChecked(true);
3267 void Main::formatLinkStyleParabel()
3269 VymModel *m=currentModel();
3272 m->setMapLinkStyle("StyleParabel");
3273 actionFormatLinkStyleParabel->setChecked(true);
3277 void Main::formatLinkStylePolyLine()
3279 VymModel *m=currentModel();
3282 m->setMapLinkStyle("StylePolyLine");
3283 actionFormatLinkStylePolyLine->setChecked(true);
3287 void Main::formatLinkStylePolyParabel()
3289 VymModel *m=currentModel();
3292 m->setMapLinkStyle("StylePolyParabel");
3293 actionFormatLinkStylePolyParabel->setChecked(true);
3297 void Main::formatSelectBackColor()
3299 VymModel *m=currentModel();
3300 if (m) m->selectMapBackgroundColor();
3303 void Main::formatSelectBackImage()
3305 VymModel *m=currentModel();
3307 m->selectMapBackgroundImage();
3310 void Main::formatSelectLinkColor()
3312 VymModel *m=currentModel();
3315 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3316 m->setMapDefLinkColor( col );
3320 void Main::formatSelectSelectionColor()
3322 VymModel *m=currentModel();
3325 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3326 m->setSelectionColor (col);
3331 void Main::formatToggleLinkColorHint()
3333 VymModel *m=currentModel();
3334 if (m) m->toggleMapLinkColorHint();
3338 void Main::formatHideLinkUnselected() //FIXME-3 get rid of this with imagepropertydialog
3340 VymModel *m=currentModel();
3342 m->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3345 void Main::viewZoomReset()
3347 MapEditor *me=currentMapEditor();
3348 if (me) me->setZoomFactorTarget (1);
3351 void Main::viewZoomIn()
3353 MapEditor *me=currentMapEditor();
3354 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*1.25);
3357 void Main::viewZoomOut()
3359 MapEditor *me=currentMapEditor();
3360 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*0.75);
3363 void Main::viewCenter()
3365 VymModel *m=currentModel();
3366 if (m) m->emitShowSelection();
3369 void Main::networkStartServer()
3371 VymModel *m=currentModel();
3372 if (m) m->newServer();
3375 void Main::networkConnect()
3377 VymModel *m=currentModel();
3378 if (m) m->connectToServer();
3381 bool Main::settingsPDF()
3383 // Default browser is set in constructor
3385 QString text = QInputDialog::getText(
3386 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3387 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3389 settings.setValue ("/mainwindow/readerPDF",text);
3394 bool Main::settingsURL()
3396 // Default browser is set in constructor
3398 QString text = QInputDialog::getText(
3399 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3400 settings.value("/mainwindow/readerURL").toString()
3403 settings.setValue ("/mainwindow/readerURL",text);
3407 void Main::settingsMacroDir()
3409 QDir defdir(vymBaseDir.path() + "/macros");
3410 if (!defdir.exists())
3412 QDir dir=QFileDialog::getExistingDirectory (
3414 tr ("Directory with vym macros:"),
3415 settings.value ("/macros/macroDir",defdir.path()).toString()
3418 settings.setValue ("/macros/macroDir",dir.absolutePath());
3421 void Main::settingsUndoLevels()
3424 int i = QInputDialog::getInteger(
3426 tr("QInputDialog::getInteger()"),
3427 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3430 settings.setValue ("/mapeditor/stepsTotal",i);
3431 QMessageBox::information( this, tr( "VYM -Information:" ),
3432 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3436 void Main::settingsAutosaveToggle()
3438 settings.setValue ("/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
3441 void Main::settingsAutosaveTime()
3444 int i = QInputDialog::getInteger(
3446 tr("QInputDialog::getInteger()"),
3447 tr("Number of seconds before autosave:"), settings.value("/mainwindow/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3449 settings.setValue ("/mainwindow/autosave/ms",i * 1000);
3452 void Main::settingsWriteBackupFileToggle()
3454 settings.setValue ("/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
3457 void Main::settingsToggleAnimation()
3459 settings.setValue ("/animation/use",actionSettingsUseAnimation->isOn() );
3462 void Main::settingsToggleDelKey()
3464 if (actionSettingsUseDelKey->isOn())
3466 actionDelete->setAccel (QKeySequence (Qt::Key_Delete));
3469 actionDelete->setAccel (QKeySequence (""));
3473 void Main::windowToggleNoteEditor()
3475 if (textEditor->isVisible() )
3476 windowHideNoteEditor();
3478 windowShowNoteEditor();
3481 void Main::windowToggleTreeEditor()
3483 if ( tabWidget->currentPage())
3484 vymViews.at(tabWidget->currentIndex())->toggleTreeEditor();
3487 void Main::windowToggleHistory()
3489 if (historyWindow->isVisible())
3490 historyWindow->hide();
3492 historyWindow->show();
3496 void Main::windowToggleProperty()
3498 if (branchPropertyWindow->isVisible())
3499 branchPropertyWindow->hide();
3501 branchPropertyWindow->show();
3502 branchPropertyWindow->setModel (currentModel() );
3505 void Main::windowToggleAntiAlias()
3507 bool b=actionViewToggleAntiAlias->isOn();
3509 for (int i=0;i<vymViews.count();i++)
3511 me=vymViews.at(i)->getMapEditor();
3512 if (me) me->setAntiAlias(b);
3517 bool Main::isAliased()
3519 return actionViewToggleAntiAlias->isOn();
3522 bool Main::hasSmoothPixmapTransform()
3524 return actionViewToggleSmoothPixmapTransform->isOn();
3527 void Main::windowToggleSmoothPixmap()
3529 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3531 for (int i=0;i<vymViews.count();i++)
3534 me=vymViews.at(i)->getMapEditor();
3535 if (me) me->setSmoothPixmap(b);
3539 void Main::updateHistory(SimpleSettings &undoSet)
3541 historyWindow->update (undoSet);
3544 void Main::updateNoteFlag()
3546 // this slot is connected to TextEditor::textHasChanged()
3547 VymModel *m=currentModel();
3548 if (m) m->updateNoteFlag();
3551 void Main::updateNoteEditor(QModelIndex index )
3553 TreeItem *ti=((VymModel*) QObject::sender())->getItem(index);
3555 cout << "Main::updateNoteEditor model="<<sender();
3556 cout << " item="<<ti->getHeadingStd()<<" ("<<ti<<")"<<endl;
3558 textEditor->setNote (ti->getNoteObj() );
3561 void Main::changeSelection (VymModel *model, const QItemSelection &newsel, const QItemSelection &oldsel)
3563 branchPropertyWindow->setModel (model ); //FIXME-3 this used to be called from BranchObj::select(). Maybe use signal now...
3565 if (model && model==currentModel() )
3569 if (!oldsel.indexes().isEmpty() )
3571 ti=model->getItem(oldsel.indexes().first());
3573 // Don't update note if both treeItem and textEditor are empty
3574 //if (! (ti->hasEmptyNote() && textEditor->isEmpty() ))
3575 // ti->setNoteObj (textEditor->getNoteObj(),false );
3577 if (!newsel.indexes().isEmpty() )
3579 ti=model->getItem(newsel.indexes().first());
3580 if (!ti->hasEmptyNote() )
3581 textEditor->setNote(ti->getNoteObj() );
3583 textEditor->setNote(NoteObj() ); //FIXME-4 maybe add a clear() to TE
3585 // Show URL and link in statusbar
3587 QString s=ti->getURL();
3588 if (!s.isEmpty() ) status+="URL: "+s+" ";
3590 if (!s.isEmpty() ) status+="Link: "+s;
3591 if (!status.isEmpty() ) statusMessage (status);
3594 textEditor->setInactive();
3600 void Main::updateActions()
3602 // updateActions is also called when satellites are closed //FIXME-2 doesn't update immediatly, e.g. historyWindow is still visible, when "close" is pressed
3603 actionViewToggleNoteEditor->setChecked (textEditor->isVisible());
3604 actionViewToggleHistoryWindow->setChecked (historyWindow->isVisible());
3605 actionViewTogglePropertyWindow->setChecked (branchPropertyWindow->isVisible());
3607 VymModel *m =currentModel();
3611 actionFilePrint->setEnabled (true);
3613 // Link style in context menu
3614 switch (m->getMapLinkStyle())
3616 case LinkableMapObj::Line:
3617 actionFormatLinkStyleLine->setChecked(true);
3619 case LinkableMapObj::Parabel:
3620 actionFormatLinkStyleParabel->setChecked(true);
3622 case LinkableMapObj::PolyLine:
3623 actionFormatLinkStylePolyLine->setChecked(true);
3625 case LinkableMapObj::PolyParabel:
3626 actionFormatLinkStylePolyParabel->setChecked(true);
3633 QPixmap pix( 16, 16 );
3634 pix.fill( m->getMapBackgroundColor() );
3635 actionFormatBackColor->setIconSet( pix );
3636 pix.fill( m->getSelectionColor() );
3637 actionFormatSelectionColor->setIconSet( pix );
3638 pix.fill( m->getMapDefLinkColor() );
3639 actionFormatLinkColor->setIconSet( pix );
3642 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName()));
3645 // Expanding/collapsing
3646 actionExpandAll->setEnabled (true);
3647 actionExpandOneLevel->setEnabled (true);
3648 actionCollapseOneLevel->setEnabled (true);
3652 actionFilePrint->setEnabled (false);
3654 // Expanding/collapsing
3655 actionExpandAll->setEnabled (false);
3656 actionExpandOneLevel->setEnabled (false);
3657 actionCollapseOneLevel->setEnabled (false);
3660 if (m && m->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3661 actionFormatLinkColorHint->setChecked(true);
3663 actionFormatLinkColorHint->setChecked(false);
3666 if (m && m->hasChanged() )
3667 actionFileSave->setEnabled( true);
3669 actionFileSave->setEnabled( false);
3670 if (m && m->isUndoAvailable())
3671 actionUndo->setEnabled( true);
3673 actionUndo->setEnabled( false);
3675 if (m && m->isRedoAvailable())
3676 actionRedo->setEnabled( true);
3678 actionRedo->setEnabled( false);
3682 TreeItem *selti=m->getSelectedItem();
3683 BranchItem *selbi=m->getSelectedBranch();
3686 if (selbi || selti->getType()==TreeItem::Image)
3688 actionFormatHideLinkUnselected->setChecked (((MapItem*)selti)->getHideLinkUnselected());
3689 actionFormatHideLinkUnselected->setEnabled (true);
3694 // Take care of xlinks
3695 branchXLinksContextMenuEdit->clear();
3696 if (selbi->xlinkCount()>0)
3700 for (int i=0; i<selbi->xlinkCount();++i)
3702 bi=selbi->getXLinkNum(i)->getPartnerBranch();
3706 if (s.length()>xLinkMenuWidth)
3707 s=s.left(xLinkMenuWidth)+"...";
3708 branchXLinksContextMenuEdit->addAction (s);
3713 standardFlagsMaster->updateToolBar (selbi->activeStandardFlagNames() );
3716 actionToggleScroll->setEnabled (true);
3717 if ( selbi->isScrolled() )
3718 actionToggleScroll->setChecked(true);
3720 actionToggleScroll->setChecked(false);
3722 if ( selti->getURL().isEmpty() )
3724 actionOpenURL->setEnabled (false);
3725 actionOpenURLTab->setEnabled (false);
3729 actionOpenURL->setEnabled (true);
3730 actionOpenURLTab->setEnabled (true);
3732 if ( selti->getVymLink().isEmpty() )
3734 actionOpenVymLink->setEnabled (false);
3735 actionDeleteVymLink->setEnabled (false);
3738 actionOpenVymLink->setEnabled (true);
3739 actionDeleteVymLink->setEnabled (true);
3742 if (selbi->canMoveUp())
3743 actionMoveUp->setEnabled (true);
3745 actionMoveUp->setEnabled (false);
3746 if (selbi->canMoveDown())
3747 actionMoveDown->setEnabled (true);
3749 actionMoveDown->setEnabled (false);
3751 actionSortChildren->setEnabled (true);
3752 actionSortBackChildren->setEnabled (true);
3754 actionToggleHideExport->setEnabled (true);
3755 actionToggleHideExport->setChecked (selbi->hideInExport() );
3757 actionCopy->setEnabled (true);
3758 actionCut->setEnabled (true);
3759 if (!clipboardEmpty)
3760 actionPaste->setEnabled (true);
3762 actionPaste->setEnabled (false);
3763 for (int i=0; i<actionListBranches.size(); ++i)
3764 actionListBranches.at(i)->setEnabled(true);
3765 actionDelete->setEnabled (true);
3767 if ( selti->getType()==TreeItem::Image)
3769 actionOpenURL->setEnabled (false);
3770 actionOpenVymLink->setEnabled (false);
3771 actionDeleteVymLink->setEnabled (false);
3772 actionToggleHideExport->setEnabled (true);
3773 actionToggleHideExport->setChecked (selti->hideInExport() );
3776 actionCopy->setEnabled (true);
3777 actionCut->setEnabled (true);
3778 actionPaste->setEnabled (false); //FIXME-4 why not allowing copy of images?
3779 for (int i=0; i<actionListBranches.size(); ++i)
3780 actionListBranches.at(i)->setEnabled(false);
3781 actionDelete->setEnabled (true);
3782 actionMoveUp->setEnabled (false);
3783 actionMoveDown->setEnabled (false);
3788 actionCopy->setEnabled (false);
3789 actionCut->setEnabled (false);
3790 actionPaste->setEnabled (false);
3791 for (int i=0; i<actionListBranches.size(); ++i)
3792 actionListBranches.at(i)->setEnabled(false);
3794 actionToggleScroll->setEnabled (false);
3795 actionOpenURL->setEnabled (false);
3796 actionOpenVymLink->setEnabled (false);
3797 actionDeleteVymLink->setEnabled (false);
3798 actionHeading2URL->setEnabled (false);
3799 actionDelete->setEnabled (false);
3800 actionMoveUp->setEnabled (false);
3801 actionMoveDown->setEnabled (false);
3802 actionFormatHideLinkUnselected->setEnabled (false);
3803 actionSortChildren->setEnabled (false);
3804 actionSortBackChildren->setEnabled (false);
3805 actionToggleHideExport->setEnabled (false);
3810 Main::ModMode Main::getModMode()
3812 if (actionModModeColor->isOn()) return ModModeColor;
3813 if (actionModModeCopy->isOn()) return ModModeCopy;
3814 if (actionModModeXLink->isOn()) return ModModeXLink;
3818 bool Main::autoEditNewBranch()
3820 return actionSettingsAutoEditNewBranch->isOn();
3823 bool Main::autoSelectNewBranch()
3825 return actionSettingsAutoSelectNewBranch->isOn();
3828 void Main::windowShowNoteEditor()
3830 textEditor->setShowWithMain(true);
3832 actionViewToggleNoteEditor->setChecked (true);
3835 void Main::windowHideNoteEditor()
3837 textEditor->setShowWithMain(false);
3839 actionViewToggleNoteEditor->setChecked (false);
3842 void Main::setScript (const QString &script)
3844 scriptEditor->setScript (script);
3847 void Main::runScript (const QString &script)
3849 VymModel *m=currentModel();
3850 if (m) m->runScript (script);
3853 void Main::runScriptEverywhere (const QString &script)
3856 for (int i=0;i<=tabWidget->count() -1;i++)
3858 me=(MapEditor*)tabWidget->page(i);
3859 if (me) me->getModel()->runScript (script);
3863 void Main::windowNextEditor()
3865 if (tabWidget->currentIndex() < tabWidget->count())
3866 tabWidget->setCurrentIndex (tabWidget->currentIndex() +1);
3869 void Main::windowPreviousEditor()
3871 if (tabWidget->currentIndex() >0)
3872 tabWidget->setCurrentIndex (tabWidget->currentIndex() -1);
3875 void Main::standardFlagChanged()
3879 if ( actionSettingsUseFlagGroups->isOn() )
3880 currentModel()->toggleStandardFlag(sender()->name(),standardFlagsMaster);
3882 currentModel()->toggleStandardFlag(sender()->name());
3888 #include "attributeitem.h"
3889 void Main::testFunction1()
3891 VymModel *m=currentModel();
3894 BranchItem *selbi=m->getSelectedBranch();
3897 QList<QVariant> cData;
3898 cData << "new ai" << "undef";
3900 AttributeItem *ai=new AttributeItem (cData,selbi);
3901 ai->set ("Key 1","Val a",AttributeItem::FreeString);
3903 m->addAttribute (ai);
3908 if (!currentMapEditor()) return;
3909 currentMapEditor()->testFunction1();
3913 VymModel *m=currentModel();
3917 QString text = QInputDialog::getText(
3918 "VYM", "Enter Filter:", QLineEdit::Normal, // FIXME-3 no translation yet
3919 m->getSortFilter(), &ok, NULL);
3921 // user entered something and pressed OK
3922 m->setSortFilter (text);
3926 void Main::testFunction2()
3928 if (!currentMapEditor()) return;
3929 currentMapEditor()->testFunction2();
3932 void Main::testCommand()
3934 if (!currentMapEditor()) return;
3935 scriptEditor->show();
3938 QString com = QInputDialog::getText(
3939 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3940 if (ok) currentMapEditor()->parseAtom(com);
3944 void Main::helpDoc()
3946 QString locale = QLocale::system().name();
3948 if (locale.left(2)=="es")
3949 docname="vym_es.pdf";
3953 QStringList searchList;
3955 #if defined(Q_OS_MACX)
3956 searchList << "./vym.app/Contents/Resources/doc";
3957 #elif defined(Q_OS_WIN32)
3958 searchList << vymInstallDir.path() + "/share/doc/packages/vym";
3960 #if defined(VYM_DOCDIR)
3961 searchList << VYM_DOCDIR;
3963 // default path in SUSE LINUX
3964 searchList << "/usr/share/doc/packages/vym";
3967 searchList << "doc"; // relative path for easy testing in tarball
3968 searchList << "doc/tex"; // Easy testing working on vym.tex
3969 searchList << "/usr/share/doc/vym"; // Debian
3970 searchList << "/usr/share/doc/packages";// Knoppix
3974 for (int i=0; i<searchList.count(); ++i)
3976 docfile.setFileName(searchList.at(i)+"/"+docname);
3977 if (docfile.exists())
3986 QMessageBox::critical(0,
3987 tr("Critcal error"),
3988 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3993 Process *pdfProc = new Process();
3994 args << QDir::toNativeSeparators(docfile.fileName());
3996 if (!pdfProc->startDetached( settings.value("/mainwindow/readerPDF").toString(),args) )
3999 QMessageBox::warning(0,
4001 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
4002 tr("Please use Settings->")+tr("Set application to open PDF files"));
4009 void Main::helpDemo()
4011 QStringList filters;
4012 filters <<"VYM example map (*.vym)";
4013 QFileDialog *fd=new QFileDialog( this);
4014 #if defined(Q_OS_MACX)
4015 fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
4017 // default path in SUSE LINUX
4018 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
4021 fd->setFileMode (QFileDialog::ExistingFiles);
4022 fd->setFilters (filters);
4023 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
4027 if ( fd->exec() == QDialog::Accepted )
4029 lastFileDir=fd->directory().path();
4030 QStringList flist = fd->selectedFiles();
4031 QStringList::Iterator it = flist.begin();
4032 while( it != flist.end() )
4035 fileLoad(*it, NewMap);
4043 void Main::helpAbout()
4046 ad.setName ("aboutwindow");
4047 ad.setMinimumSize(500,500);
4048 ad.resize (QSize (500,500));
4052 void Main::helpAboutQT()
4054 QMessageBox::aboutQt( this, "Qt Application Example" );
4057 void Main::callMacro ()
4059 QAction *action = qobject_cast<QAction *>(sender());
4063 i=action->data().toInt();
4064 QString mDir (settings.value ("macros/macroDir").toString() );
4066 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
4068 if ( !f.open( QIODevice::ReadOnly ) )
4070 QMessageBox::warning(0,
4072 tr("Couldn't find a macro at %1.\n").arg(fn)+
4073 tr("Please use Settings->")+tr("Set directory for vym macros"));
4077 QTextStream ts( &f );
4078 QString macro= ts.read();
4080 if (! macro.isEmpty())
4082 VymModel *m=currentModel();
4083 if (m) m->runScript(macro);