1 #include "mainwindow.h"
8 #include "aboutdialog.h"
9 #include "branchpropwindow.h"
10 #include "branchitem.h"
11 #include "exportoofiledialog.h"
14 #include "findresultwidget.h"
15 #include "findwidget.h"
17 #include "historywindow.h"
19 #include "mapeditor.h"
24 #include "shortcuts.h"
25 #include "texteditor.h"
26 #include "warningdialog.h"
27 #include "xlinkitem.h"
29 //#include <modeltest.h> // FIXME-3
31 #if defined(Q_OS_WIN32)
32 // Define only this structure as opposed to
33 // including full 'windows.h'. FindWindow
34 // clashes with the one in Win32 API.
35 typedef struct _PROCESS_INFORMATION
41 } PROCESS_INFORMATION, *LPPROCESS_INFORMATION;
44 extern TextEditor *textEditor;
45 extern Main *mainWindow;
46 extern FindWidget *findWidget;
47 extern FindResultWidget *findResultWidget;
48 extern QString tmpVymDir;
49 extern QString clipboardDir;
50 extern QString clipboardFile;
51 extern bool clipboardEmpty;
52 extern int statusbarTime;
53 extern FlagRow *standardFlagsMaster;
54 extern FlagRow *systemFlagsMaster;
55 extern QString vymName;
56 extern QString vymVersion;
57 extern QString vymBuildDate;
60 QMenu* branchContextMenu;
61 QMenu* branchAddContextMenu;
62 QMenu* branchRemoveContextMenu;
63 QMenu* branchLinksContextMenu;
64 QMenu* branchXLinksContextMenuEdit;
65 QMenu* floatimageContextMenu;
66 QMenu* canvasContextMenu;
67 QMenu* fileLastMapsMenu;
68 QMenu* fileImportMenu;
69 QMenu* fileExportMenu;
72 extern Settings settings;
73 extern Options options;
74 extern ImageIO imageIO;
76 extern QDir vymBaseDir;
77 extern QDir lastImageDir;
78 extern QDir lastFileDir;
79 #if defined(Q_OS_WIN32)
80 extern QDir vymInstallDir;
82 extern QString iconPath;
83 extern QString flagsPath;
86 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
87 QMainWindow(parent,name,f)
91 setCaption ("VYM - View Your Mind");
93 // Load window settings
94 #if defined(Q_OS_WIN32)
95 if (settings.value("/mainwindow/geometry/maximized", false).toBool())
97 setWindowState(Qt::WindowMaximized);
102 resize (settings.value("/mainwindow/geometry/size", QSize (800,600)).toSize());
103 move (settings.value("/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
106 // Sometimes we may need to remember old selections
110 currentColor=Qt::black;
112 // Create unique temporary directory
114 tmpVymDir=makeTmpDir (ok,"vym");
117 qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
120 if (debug) qDebug (QString("vym tmpDir=%1").arg(tmpVymDir) );
122 // Create direcctory for clipboard
123 clipboardDir=tmpVymDir+"/clipboard";
124 clipboardFile="map.xml";
125 QDir d(clipboardDir);
126 d.mkdir (clipboardDir,true);
127 makeSubDirs (clipboardDir);
130 // Remember PID of our friendly webbrowser
131 browserPID=new qint64;
135 findResultWidget=new FindResultWidget ();
136 QDockWidget *dw= new QDockWidget (tr ("Search results","FindResultWidget"),this);
137 dw->setWidget (findResultWidget);
138 dw->setObjectName ("FindResultWidget");
140 addDockWidget (Qt::RightDockWidgetArea,dw);
142 // Satellite windows //////////////////////////////////////////
144 historyWindow=new HistoryWindow();
145 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
148 branchPropertyWindow = new BranchPropertyWindow();
149 connect (branchPropertyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
151 // Connect TextEditor, so that we can update flags if text changes
152 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
153 connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
155 // Initialize script editor
156 scriptEditor = new SimpleScriptEditor();
157 scriptEditor->move (50,50);
159 connect( scriptEditor, SIGNAL( runScript ( QString ) ),
160 this, SLOT( runScript( QString ) ) );
162 // Initialize some settings, which are platform dependant
165 // application to open URLs
166 p="/mainwindow/readerURL";
167 #if defined(Q_OS_LINUX)
168 s=settings.value (p,"xdg-open").toString();
170 #if defined(Q_OS_MACX)
171 s=settings.value (p,"/usr/bin/open").toString();
174 #if defined(Q_OS_WIN32)
175 // Assume that system has been set up so that
176 // Explorer automagically opens up the URL
177 // in the user's preferred browser.
178 s=settings.value (p,"explorer").toString();
180 s=settings.value (p,"mozilla").toString();
184 settings.setValue( p,s);
186 // application to open PDFs
187 p="/mainwindow/readerPDF";
188 #if defined(Q_OS_LINUX)
189 s=settings.value (p,"xdg-open").toString();
191 #if defined(Q_OS_MACX)
192 s=settings.value (p,"/usr/bin/open").toString();
193 #elif defined(Q_OS_WIN32)
194 s=settings.value (p,"acrord32").toString();
196 s=settings.value (p,"acroread").toString();
199 settings.setValue( p,s);
201 // width of xLinksMenu
205 QWidget* centralWidget = new QWidget (this);
206 QVBoxLayout *layout=new QVBoxLayout (centralWidget);
207 setCentralWidget(centralWidget);
209 // Create tab widget which holds the maps
210 tabWidget= new QTabWidget (centralWidget);
211 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
212 this, SLOT( editorChanged( QWidget * ) ) );
215 findWidget = new FindWidget (centralWidget);
217 layout->addWidget (tabWidget);
218 layout->addWidget (findWidget);
221 findWidget, SIGNAL (nextButton (QString) ),
222 this, SLOT (editFindNext(QString) ) );
224 findWidget , SIGNAL (hideFindWidget() ),
225 this, SLOT (editHideFindWidget() ) );
229 setupFormatActions();
233 setupNetworkActions();
234 setupSettingsActions();
237 if (debug) switchboard.print();
239 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
242 // Status bar and progress bar there
246 progressCounterTotal=0;
248 progressDialog.setLabelText (tr("Loading maps","Mainwindow"));
249 progressDialog.setAutoReset(false);
250 progressDialog.setAutoClose(false);
251 //progressDialog.setWindowModality (Qt::WindowModal); // That forces mainwindo to update and slows down
252 //progressDialog.setCancelButton (NULL);
254 restoreState (settings.value("/mainwindow/state",0).toByteArray());
262 #if defined(Q_OS_WIN32)
263 settings.setValue ("/mainwindow/geometry/maximized", isMaximized());
265 settings.setValue ("/mainwindow/geometry/size", size());
266 settings.setValue ("/mainwindow/geometry/pos", pos());
267 settings.setValue ("/mainwindow/state",saveState(0));
269 settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
270 settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
271 settings.setValue( "/version/version", vymVersion );
272 settings.setValue( "/version/builddate", vymBuildDate );
274 settings.setValue( "/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
275 settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isOn() );
276 settings.setValue( "/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
277 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
278 settings.setValue( "/mapeditor/editmode/autoEditNewBranch",actionSettingsAutoEditNewBranch->isOn() );
279 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
280 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
281 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
283 //TODO save scriptEditor settings
285 // call the destructors
287 delete historyWindow;
288 delete branchPropertyWindow;
290 // Remove temporary directory
291 removeDir (QDir(tmpVymDir));
294 void Main::loadCmdLine()
296 /* TODO draw some kind of splashscreen while loading...
302 QStringList flist=options.getFileList();
303 QStringList::Iterator it=flist.begin();
305 progressCounter=flist.count();
306 progressCounterTotal=flist.count();
307 while (it !=flist.end() )
309 fileLoad (*it, NewMap);
315 void Main::statusMessage(const QString &s)
317 // Surpress messages while progressdialog during
320 statusBar()->message( s);
323 void Main::setProgressMaximum (int max)
325 if (progressCounterTotal!=0)
327 progressDialog.setRange (0,progressCounterTotal*1000);
329 progressDialog.setRange (0,max+10);
331 progressDialog.setValue (0);
332 progressMax=max*1000;
333 //cout << "Main max="<<max<<" v="<<progressDialog.value()<<endl;
334 progressDialog.show();
337 void Main::addProgressValue (float v)
339 //cout << "addVal v="<<v*1000<<"/"<<progressMax<<" cur="<<progressDialog.value()<<" counter="<<v+progressCounter<<"/"<<progressCounterTotal<<endl;
340 if (progressCounterTotal!=0)
341 progressDialog.setValue ( (v+progressCounterTotal-progressCounter)*1000 );
343 progressDialog.setValue (v+progressDialog.value());
346 void Main::removeProgressCounter()
350 if (progressCounter<=0)
353 progressCounterTotal=0;
354 progressDialog.reset();
355 progressDialog.hide();
359 void Main::closeEvent (QCloseEvent* )
365 void Main::setupFileActions()
367 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
368 QToolBar *tb = addToolBar( tr ("&Map") );
369 tb->setObjectName ("mapTB");
372 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this);
373 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
374 a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map
375 switchboard.addConnection(a,tr("File","Shortcut group"));
377 fileMenu->addAction (a);
378 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
380 a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this);
381 a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) );
382 a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N ); //New map
383 switchboard.addConnection(a,tr("File","Shortcut group"));
384 fileMenu->addAction (a);
385 connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) );
388 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
389 a->setStatusTip (tr( "Open","Status tip File menu" ) );
390 a->setShortcut ( Qt::CTRL + Qt::Key_O ); //Open map
391 switchboard.addConnection(a,tr("File","Shortcut group"));
393 fileMenu->addAction (a);
394 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
396 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
397 fileMenu->addSeparator();
399 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
400 a->setStatusTip ( tr( "Save","Status tip file menu" ));
401 a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map
402 switchboard.addConnection(a,tr("File","Shortcut group"));
404 fileMenu->addAction (a);
405 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
408 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
409 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
410 switchboard.addConnection(a,tr("File","Shortcut group"));
411 fileMenu->addAction (a);
412 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
414 fileMenu->addSeparator();
416 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
418 a = new QAction(tr("KDE 3 Bookmarks"), this);
419 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 3 bookmarks")));
420 switchboard.addConnection(a,tr("File","Shortcut group"));
421 a->addTo (fileImportMenu);
422 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE3Bookmarks() ) );
424 a = new QAction(tr("KDE 4 Bookmarks"), this);
425 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 4 bookmarks")));
426 a->addTo (fileImportMenu);
427 switchboard.addConnection(a,tr("File","Shortcut group"));
428 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE4Bookmarks() ) );
430 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
432 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
433 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
434 a->addTo (fileImportMenu);
435 switchboard.addConnection(a,tr("File","Shortcut group"));
436 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
439 a = new QAction("Freemind...",this);
440 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Freemind") );
441 switchboard.addConnection(a,tr("File","Shortcut group"));
442 fileImportMenu->addAction (a);
443 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFreemind() ) );
445 a = new QAction("Mind Manager...",this);
446 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
447 switchboard.addConnection(a,tr("File","Shortcut group"));
448 fileImportMenu->addAction (a);
449 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
451 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
452 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
453 switchboard.addConnection(a,tr("File","Shortcut group"));
454 fileImportMenu->addAction (a);
455 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
457 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
459 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
460 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
461 switchboard.addConnection(a,tr("File","Shortcut group"));
462 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
463 fileExportMenu->addAction (a);
465 a = new QAction( "Open Office...", this);
466 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
467 switchboard.addConnection(a,tr("File","Shortcut group"));
468 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
469 fileExportMenu->addAction (a);
471 a = new QAction( "Webpage (HTML)...",this );
472 a->setShortcut (Qt::ALT + Qt::Key_X); //Export HTML
473 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
474 switchboard.addConnection(a,tr("File","Shortcut group"));
475 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportHTML() ) );
476 fileExportMenu->addAction (a);
478 a = new QAction( "Webpage (XHTML)...",this ); //Export XHTML
480 //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")));
481 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
482 fileExportMenu->addAction (a);
484 a = new QAction( "Text (A&O report)...", this);
485 a->setStatusTip ( tr( "Export as %1").arg("A&O report "+tr("(still experimental)" )));
486 switchboard.addConnection(a,tr("File","Shortcut group"));
487 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportAO() ) );
488 fileExportMenu->addAction (a);
490 a = new QAction( "Text (ASCII)...", this);
491 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
492 switchboard.addConnection(a,tr("File","Shortcut group"));
493 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
494 fileExportMenu->addAction (a);
496 a = new QAction( "Spreadsheet (CSV)...", this);
497 a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
498 switchboard.addConnection(a,tr("File","Shortcut group"));
499 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
500 fileExportMenu->addAction (a);
502 a = new QAction( tr("KDE 3 Bookmarks","File menu"), this);
503 a->setStatusTip( tr( "Export as %1").arg(tr("KDE 3 Bookmarks" )));
504 switchboard.addConnection(a,tr("File","Shortcut group"));
505 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE3Bookmarks() ) );
506 fileExportMenu->addAction (a);
508 a = new QAction( tr("KDE 4 Bookmarks","File menu"), this);
509 a->setStatusTip( tr( "Export as %1").arg(tr("KDE 4 Bookmarks" )));
510 switchboard.addConnection(a,tr("File","Shortcut group"));
511 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE4Bookmarks() ) );
512 fileExportMenu->addAction (a);
514 a = new QAction( "Taskjuggler...", this );
515 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
516 switchboard.addConnection(a,tr("File","Shortcut group"));
517 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
518 fileExportMenu->addAction (a);
520 a = new QAction( "LaTeX...", this);
521 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
522 switchboard.addConnection(a,tr("File","Shortcut group"));
523 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
524 fileExportMenu->addAction (a);
526 a = new QAction( "XML..." , this );
527 a->setStatusTip (tr( "Export as %1").arg("XML"));
528 switchboard.addConnection(a,tr("File","Shortcut group"));
529 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
530 fileExportMenu->addAction (a);
532 fileMenu->addSeparator();
534 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
535 a->setStatusTip ( tr( "Print" ,"File menu") );
536 a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map
538 switchboard.addConnection(a,tr("File","Shortcut group"));
539 fileMenu->addAction (a);
540 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
543 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
544 a->setStatusTip (tr( "Close Map" ) );
545 a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map
546 switchboard.addConnection(a,tr("File","Shortcut group"));
547 fileMenu->addAction (a);
548 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
550 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
551 a->setStatusTip ( tr( "Exit")+" "+vymName );
552 a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym
553 switchboard.addConnection(a,tr("File","Shortcut group"));
554 fileMenu->addAction (a);
555 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
560 void Main::setupEditActions()
562 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
563 tb->setLabel( "Edit Actions" );
564 tb->setObjectName ("actionsTB");
565 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
569 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
570 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
571 a->setStatusTip (tr( "Undo" ) );
572 a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action
573 a->setEnabled (false);
574 switchboard.addConnection(a,tr("Edit","Shortcut group"));
576 editMenu->addAction (a);
579 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
580 a->setStatusTip (tr( "Redo" ));
581 a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action
582 switchboard.addConnection(a,tr("Edit","Shortcut group"));
584 editMenu->addAction (a);
585 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
588 editMenu->addSeparator();
589 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
590 a->setStatusTip ( tr( "Copy" ) );
591 a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy
592 a->setEnabled (false);
593 switchboard.addConnection(a,tr("Edit","Shortcut group"));
595 editMenu->addAction (a);
596 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
599 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
600 a->setStatusTip ( tr( "Cut" ) );
601 a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut
602 a->setEnabled (false);
604 switchboard.addConnection(a,tr("Edit","Shortcut group"));
605 editMenu->addAction (a);
607 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
609 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
610 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
611 a->setStatusTip ( tr( "Paste" ) );
612 a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste
613 a->setEnabled (false);
615 switchboard.addConnection(a,tr("Edit","Shortcut group"));
616 editMenu->addAction (a);
619 // Shortcut to delete selection
620 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
621 a->setStatusTip (tr( "Delete Selection" ));
622 a->setShortcut ( Qt::Key_Delete); //Delete selection
623 a->setShortcutContext (Qt::WindowShortcut);
624 switchboard.addConnection(a,tr("Edit","Shortcut group"));
626 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
629 // Shortcut to add attribute
630 a= new QAction(tr( "Add attribute" ), this);
631 a->setShortcut ( Qt::Key_Q);
632 a->setShortcutContext (Qt::WindowShortcut);
633 switchboard.addConnection(a,tr("Edit","Shortcut group"));
635 connect( a, SIGNAL( triggered() ), this, SLOT( editAddAttribute() ) );
636 actionAddAttribute= a;
639 // Shortcut to add mapcenter
640 a= new QAction(QPixmap(iconPath+"newmapcenter.png"),tr( "Add mapcenter","Canvas context menu" ), this);
641 a->setShortcut ( Qt::Key_M);
642 a->setShortcutContext (Qt::WindowShortcut);
643 switchboard.addConnection(a,tr("Edit","Shortcut group"));
644 connect( a, SIGNAL( triggered() ), this, SLOT( editAddMapCenter() ) );
645 //actionListBranches.append(a);
647 actionAddMapCenter = a;
650 // Shortcut to add branch
651 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
652 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
653 alt->setShortcut (Qt::Key_A); //Add branch
654 alt->setShortcutContext (Qt::WindowShortcut);
655 switchboard.addConnection(alt,tr("Edit","Shortcut group"));
657 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
658 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
659 a->setStatusTip ( tr( "Add a branch as child of selection" ));
660 a->setShortcut (Qt::Key_Insert); //Add branch
661 switchboard.addConnection(a,tr("Edit","Shortcut group"));
662 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
663 actionListBranches.append(a);
664 #if defined (Q_OS_MACX)
665 // In OSX show different shortcut in menues, the keys work indepently always
670 editMenu->addAction (actionAddBranch);
671 tb->addAction (actionAddBranch);
674 // Add branch by inserting it at selection
675 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
676 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
677 a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch
678 a->setShortcutContext (Qt::WindowShortcut);
679 switchboard.addConnection(a,tr("Edit","Shortcut group"));
681 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
682 a->setEnabled (false);
683 actionListBranches.append(a);
684 actionAddBranchBefore=a;
685 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
686 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
687 a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch
688 a->setShortcutContext (Qt::WindowShortcut);
689 switchboard.addConnection(a,tr("Edit","Shortcut group"));
691 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
692 actionListBranches.append(a);
695 a = new QAction(tr( "Add branch above","Edit menu" ), this);
696 a->setStatusTip ( tr( "Add a branch above selection" ));
697 a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
698 a->setShortcutContext (Qt::WindowShortcut);
699 switchboard.addConnection(a,tr("Edit","Shortcut group"));
701 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
702 a->setEnabled (false);
703 actionListBranches.append(a);
704 actionAddBranchAbove=a;
705 a = new QAction(tr( "Add branch above","Edit menu" ), this);
706 a->setStatusTip ( tr( "Add a branch above selection" ));
707 a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above
708 a->setShortcutContext (Qt::WindowShortcut);
709 switchboard.addConnection(a,tr("Edit","Shortcut group"));
711 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
712 actionListBranches.append(a);
715 a = new QAction(tr( "Add branch below","Edit menu" ), this);
716 a->setStatusTip ( tr( "Add a branch below selection" ));
717 a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
718 a->setShortcutContext (Qt::WindowShortcut);
719 switchboard.addConnection(a,tr("Edit","Shortcut group"));
721 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
722 a->setEnabled (false);
723 actionListBranches.append(a);
724 actionAddBranchBelow=a;
725 a = new QAction(tr( "Add branch below","Edit menu" ), this);
726 a->setStatusTip ( tr( "Add a branch below selection" ));
727 a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below
728 a->setShortcutContext (Qt::WindowShortcut);
729 switchboard.addConnection(a,tr("Edit","Shortcut group"));
731 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
732 actionListBranches.append(a);
734 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
735 a->setStatusTip ( tr( "Move branch up" ) );
736 a->setShortcut (Qt::Key_PageUp ); // Move branch up
737 a->setEnabled (false);
738 switchboard.addConnection(a,tr("Edit","Shortcut group"));
740 editMenu->addAction (a);
741 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
744 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
745 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
746 a->setStatusTip (tr( "Move branch down" ) );
747 a->setShortcut ( Qt::Key_PageDown ); // Move branch down
748 a->setEnabled (false);
749 switchboard.addConnection(a,tr("Edit","Shortcut group"));
751 editMenu->addAction (a);
754 a = new QAction(QPixmap(), tr( "&Detach","Context menu" ),this);
755 a->setStatusTip ( tr( "Detach branch and use as mapcenter","Context menu" ) );
756 a->setShortcut ( Qt::Key_D ); // Detach branch
757 switchboard.addConnection(a,tr("Edit","Shortcut group"));
758 editMenu->addAction (a);
759 connect( a, SIGNAL( triggered() ), this, SLOT( editDetach() ) );
762 a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this );
763 connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) );
764 a->setEnabled (true);
766 switchboard.addConnection(a,tr("Edit","Shortcut group"));
767 editMenu->addAction (a);
768 actionSortChildren=a;
770 a = new QAction( QPixmap(iconPath+"editsortback.png" ), tr( "Sort children backwards","Edit menu" ), this );
771 connect( a, SIGNAL( activated() ), this, SLOT( editSortBackChildren() ) );
772 a->setEnabled (true);
774 switchboard.addConnection(a,tr("Edit","Shortcut group"));
775 editMenu->addAction (a);
776 actionSortBackChildren=a;
778 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
779 a->setShortcut ( Qt::Key_S ); // Scroll branch
780 a->setStatusTip (tr( "Scroll branch" ));
781 switchboard.addConnection(alt,tr("Edit","Shortcut group"));
782 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
783 a->setEnabled (false);
784 a->setToggleAction(true);
785 actionToggleScroll=a;
786 tb->addAction (actionToggleScroll);
787 editMenu->addAction ( actionToggleScroll);
788 editMenu->addAction (actionToggleScroll);
790 actionListBranches.append(actionToggleScroll);
792 a = new QAction( QPixmap(), tr( "Expand all branches","Edit menu" ), this);
793 a->setShortcut ( Qt::SHIFT + Qt::Key_X ); // Expand all branches
794 a->setStatusTip (tr( "Expand all branches" ));
795 switchboard.addConnection(a,tr("Edit","Shortcut group"));
796 connect( a, SIGNAL( triggered() ), this, SLOT( editExpandAll() ) );
798 actionExpandAll->setEnabled (false);
799 actionExpandAll->setToggleAction(false);
800 //tb->addAction (actionExpandAll);
801 editMenu->addAction ( actionExpandAll);
803 actionListBranches.append(actionExpandAll);
805 a = new QAction( QPixmap(), tr( "Expand one level","Edit menu" ), this);
806 a->setShortcut ( Qt::Key_Greater ); // Expand one level in tree editor
807 switchboard.addConnection(a,tr("Edit","Shortcut group"));
808 a->setStatusTip (tr( "Expand one level in tree editor" ));
809 connect( a, SIGNAL( triggered() ), this, SLOT( editExpandOneLevel() ) );
810 a->setEnabled (false);
811 a->setToggleAction(false);
812 actionExpandOneLevel=a;
814 editMenu->addAction ( a);
816 actionListBranches.append(a);
818 a = new QAction( QPixmap(), tr( "Collapse one level","Edit menu" ), this);
819 a->setShortcut ( Qt::Key_Less); // Collapse one level in tree editor
820 switchboard.addConnection(a,tr("Edit","Shortcut group"));
821 a->setStatusTip (tr( "Collapse one level in tree editor" ));
822 connect( a, SIGNAL( triggered() ), this, SLOT( editCollapseOneLevel() ) );
823 a->setEnabled (false);
824 a->setToggleAction(false);
825 actionCollapseOneLevel=a;
827 editMenu->addAction ( a);
829 actionListBranches.append(a);
831 a = new QAction( tr( "Unscroll children","Edit menu" ), this);
832 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
833 switchboard.addConnection(a,tr("Edit","Shortcut group"));
834 editMenu->addAction (a);
835 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChildren() ) );
837 editMenu->addSeparator();
839 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
840 a->setStatusTip (tr( "Find" ) );
841 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
842 switchboard.addConnection(a,tr("Edit","Shortcut group"));
843 editMenu->addAction (a);
844 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWidget() ) );
846 a = new QAction( tr( "Find duplicate URLs","Edit menu"), this);
847 //a->setStatusTip (tr( "Find" ) );
848 a->setShortcut (Qt::SHIFT + Qt::Key_F); //Find duplicate URLs
849 switchboard.addConnection(a,tr("Edit","Shortcut group"));
850 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
851 editMenu->addAction (a);
852 connect( a, SIGNAL( triggered() ), this, SLOT( editFindDuplicateURLs() ) );
854 editMenu->addSeparator();
856 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
857 a->setShortcut (Qt::SHIFT + Qt::Key_U );
858 switchboard.addConnection(a,tr("Edit","Shortcut group"));
861 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
864 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
865 a->setStatusTip (tr( "Open URL in new tab" ));
866 //a->setShortcut (Qt::CTRL+Qt::Key_U );
867 switchboard.addConnection(a,tr("Edit","Shortcut group"));
869 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
872 a = new QAction( tr( "Open all URLs in subtree (including scrolled branches)","Edit menu" ), this);
873 a->setStatusTip (tr( "Open all URLs in subtree (including scrolled branches)" ));
874 a->setShortcut ( Qt::CTRL + Qt::Key_U );
875 switchboard.addConnection(a,tr("Edit","Shortcut group"));
877 actionListBranches.append(a);
878 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVisURLTabs() ) );
879 actionOpenMultipleVisURLTabs=a;
881 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
882 a->setStatusTip (tr( "Open all URLs in subtree" ));
883 switchboard.addConnection(a,tr("Edit","Shortcut group"));
885 actionListBranches.append(a);
886 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
887 actionOpenMultipleURLTabs=a;
889 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
890 a->setStatusTip ( tr( "Edit URL" ) );
891 a->setShortcut ( Qt::Key_U );
892 a->setShortcutContext (Qt::WindowShortcut);
893 switchboard.addConnection(a,tr("Edit","Shortcut group"));
894 actionListBranches.append(a);
896 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
899 a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
900 a->setStatusTip ( tr( "Edit local URL" ) );
901 //a->setShortcut (Qt::SHIFT + Qt::Key_U );
902 a->setShortcutContext (Qt::WindowShortcut);
903 switchboard.addConnection(a,tr("Edit","Shortcut group"));
904 actionListBranches.append(a);
906 connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
909 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
910 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
911 a->setEnabled (false);
912 switchboard.addConnection(a,tr("Edit","Shortcut group"));
913 actionListBranches.append(a);
914 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
917 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
918 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
919 a->setEnabled (false);
920 actionListBranches.append(a);
921 a->setShortcut ( Qt::Key_B );
922 a->setShortcutContext (Qt::WindowShortcut);
923 switchboard.addConnection(a,tr("Edit","Shortcut group"));
925 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
926 actionBugzilla2URL=a;
928 a = new QAction(tr( "Get data from Novell Bugzilla","Edit menu" ), this);
929 a->setStatusTip ( tr( "Get data from Novell Bugzilla" ));
930 a->setEnabled (false);
931 actionListBranches.append(a);
932 a->setShortcut ( Qt::Key_B + Qt::SHIFT);
933 a->setShortcutContext (Qt::WindowShortcut);
934 switchboard.addConnection(a,tr("Edit","Shortcut group"));
936 connect( a, SIGNAL( triggered() ), this, SLOT( getBugzillaData() ) );
937 actionGetBugzillaData=a;
939 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
940 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
941 a->setEnabled (false);
942 switchboard.addConnection(a,tr("Edit","Shortcut group"));
943 actionListBranches.append(a);
944 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
947 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
948 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
950 a->setEnabled (false);
951 switchboard.addConnection(a,tr("Edit","Shortcut group"));
952 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
955 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
956 a->setStatusTip ( tr( "Open all vym links in subtree" ));
957 a->setEnabled (false);
958 switchboard.addConnection(a,tr("Edit","Shortcut group"));
959 actionListBranches.append(a);
960 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
961 actionOpenMultipleVymLinks=a;
964 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
965 a->setEnabled (false);
966 a->setStatusTip ( tr( "Edit link to another vym map" ));
967 switchboard.addConnection(a,tr("Edit","Shortcut group"));
968 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
969 actionListBranches.append(a);
972 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
973 a->setStatusTip ( tr( "Delete link to another vym map" ));
974 a->setEnabled (false);
975 switchboard.addConnection(a,tr("Edit","Shortcut group"));
976 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
977 actionDeleteVymLink=a;
979 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
980 a->setStatusTip ( tr( "Hide object in exports" ) );
981 a->setShortcut (Qt::Key_H );
982 a->setToggleAction(true);
984 a->setEnabled (false);
985 switchboard.addConnection(a,tr("Edit","Shortcut group"));
986 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
987 actionToggleHideExport=a;
989 a = new QAction(tr( "Add timestamp","Edit menu" ), this);
990 a->setStatusTip ( tr( "Add timestamp" ));
991 a->setEnabled (false);
992 actionListBranches.append(a);
993 a->setShortcut ( Qt::Key_T ); // Add timestamp
994 a->setShortcutContext (Qt::WindowShortcut);
995 switchboard.addConnection(a,tr("Edit","Shortcut group"));
997 connect( a, SIGNAL( triggered() ), this, SLOT( editAddTimestamp() ) );
998 actionAddTimestamp=a;
1000 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
1001 a->setStatusTip ( tr( "Edit Map Info" ));
1002 a->setEnabled (true);
1003 switchboard.addConnection(a,tr("Edit","Shortcut group"));
1004 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
1007 // Import at selection (adding to selection)
1008 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
1009 a->setStatusTip (tr( "Add map at selection" ));
1010 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
1011 a->setEnabled (false);
1012 switchboard.addConnection(a,tr("Edit","Shortcut group"));
1013 actionListBranches.append(a);
1016 // Import at selection (replacing selection)
1017 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
1018 a->setStatusTip (tr( "Replace selection with map" ));
1019 switchboard.addConnection(a,tr("Edit","Shortcut group"));
1020 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
1021 a->setEnabled (false);
1022 actionListBranches.append(a);
1023 actionImportReplace=a;
1026 a = new QAction( tr( "Save selection","Edit menu" ), this);
1027 a->setStatusTip (tr( "Save selection" ));
1028 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
1029 a->setEnabled (false);
1030 switchboard.addConnection(a,tr("Edit","Shortcut group"));
1031 actionListBranches.append(a);
1034 // Only remove branch, not its children
1035 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
1036 a->setStatusTip ( tr( "Remove only branch and keep its children" ));
1037 a->setShortcut (Qt::ALT + Qt::Key_Delete );
1038 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChildren() ) );
1039 a->setEnabled (false);
1040 switchboard.addConnection(a,tr("Edit","Shortcut group"));
1042 actionListBranches.append(a);
1043 actionDeleteKeepChildren=a;
1045 // Only remove children of a branch
1046 a = new QAction( tr( "Remove children","Edit menu" ), this);
1047 a->setStatusTip (tr( "Remove children of branch" ));
1048 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
1049 switchboard.addConnection(a,tr("Edit","Shortcut group"));
1050 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChildren() ) );
1051 a->setEnabled (false);
1052 actionListBranches.append(a);
1053 actionDeleteChildren=a;
1055 a = new QAction( tr( "Add Image...","Edit menu" ), this);
1056 a->setStatusTip (tr( "Add Image" ));
1057 switchboard.addConnection(a,tr("Edit","Shortcut group"));
1058 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
1061 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
1062 a->setStatusTip (tr( "Set properties for selection" ));
1063 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
1064 a->setShortcutContext (Qt::WindowShortcut);
1065 a->setToggleAction (true);
1066 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1068 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
1069 actionViewTogglePropertyWindow=a;
1073 void Main::setupFormatActions()
1075 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
1077 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
1078 tb->setObjectName ("formatTB");
1080 QPixmap pix( 16,16);
1081 pix.fill (Qt::black);
1082 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
1083 a->setStatusTip ( tr( "Set Color" ));
1084 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
1086 formatMenu->addAction (a);
1087 actionFormatColor=a;
1088 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
1089 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
1090 a->setShortcut (Qt::CTRL + Qt::Key_K );
1091 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
1092 a->setEnabled (false);
1094 formatMenu->addAction (a);
1095 actionListBranches.append(a);
1096 actionFormatPickColor=a;
1098 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
1099 a->setStatusTip ( tr( "Color branch" ) );
1100 a->setShortcut (Qt::CTRL + Qt::Key_B + Qt::SHIFT);
1101 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
1102 a->setEnabled (false);
1104 formatMenu->addAction (a);
1105 actionListBranches.append(a);
1106 actionFormatColorSubtree=a;
1108 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
1109 a->setStatusTip ( tr( "Color Subtree" ));
1110 a->setShortcut (Qt::CTRL + Qt::Key_B); // Color subtree
1111 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
1112 a->setEnabled (false);
1113 formatMenu->addAction (a);
1115 actionListBranches.append(a);
1116 actionFormatColorSubtree=a;
1118 formatMenu->addSeparator();
1119 actionGroupFormatLinkStyles=new QActionGroup ( this);
1120 actionGroupFormatLinkStyles->setExclusive (true);
1121 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
1122 a->setStatusTip (tr( "Line" ));
1123 a->setToggleAction(true);
1124 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
1125 formatMenu->addAction (a);
1126 actionFormatLinkStyleLine=a;
1127 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
1128 a->setStatusTip (tr( "Line" ));
1129 a->setToggleAction(true);
1130 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
1131 formatMenu->addAction (a);
1132 actionFormatLinkStyleParabel=a;
1133 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
1134 a->setStatusTip (tr( "PolyLine" ));
1135 a->setToggleAction(true);
1136 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
1137 formatMenu->addAction (a);
1138 actionFormatLinkStylePolyLine=a;
1139 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
1140 a->setStatusTip (tr( "PolyParabel" ) );
1141 a->setToggleAction(true);
1142 a->setChecked (true);
1143 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
1144 formatMenu->addAction (a);
1145 actionFormatLinkStylePolyParabel=a;
1147 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
1148 a->setStatusTip (tr( "Hide link" ));
1149 a->setToggleAction(true);
1150 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
1151 actionFormatHideLinkUnselected=a;
1153 formatMenu->addSeparator();
1154 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
1155 a->setStatusTip (tr( "Use same color for links and headings" ));
1156 a->setToggleAction(true);
1157 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
1158 formatMenu->addAction (a);
1159 actionFormatLinkColorHint=a;
1161 pix.fill (Qt::white);
1162 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
1163 a->setStatusTip (tr( "Set Link Color" ));
1164 formatMenu->addAction (a);
1165 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
1166 actionFormatLinkColor=a;
1168 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
1169 a->setStatusTip (tr( "Set Selection Color" ));
1170 formatMenu->addAction (a);
1171 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
1172 actionFormatSelectionColor=a;
1174 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
1175 a->setStatusTip (tr( "Set Background Color" ));
1176 formatMenu->addAction (a);
1177 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
1178 actionFormatBackColor=a;
1180 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
1181 a->setStatusTip (tr( "Set Background image" ));
1182 formatMenu->addAction (a);
1183 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
1184 actionFormatBackImage=a;
1188 void Main::setupViewActions()
1190 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
1191 tb->setLabel( "View Actions" );
1192 tb->setObjectName ("viewTB");
1193 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
1197 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
1198 a->setStatusTip ( tr( "Zoom reset" ) );
1199 a->setShortcut (Qt::CTRL + Qt::Key_0); // Reset zoom
1200 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1202 viewMenu->addAction (a);
1203 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
1205 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
1206 a->setStatusTip (tr( "Zoom in" ));
1207 a->setShortcut(Qt::CTRL + Qt::Key_Plus);
1208 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1210 viewMenu->addAction (a);
1211 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
1213 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
1214 a->setStatusTip (tr( "Zoom out" ));
1215 a->setShortcut(Qt::CTRL + Qt::Key_Minus);
1216 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1218 viewMenu->addAction (a);
1219 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1221 a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
1222 a->setStatusTip (tr( "Show selection" ));
1223 a->setShortcut(Qt::CTRL + Qt::Key_Period);
1224 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1226 viewMenu->addAction (a);
1227 connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
1229 viewMenu->addSeparator();
1231 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
1232 a->setStatusTip ( tr( "Show Note Editor" ));
1233 a->setShortcut ( Qt::CTRL + Qt::Key_E ); // Toggle Note Editor
1234 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1235 a->setToggleAction(true);
1237 viewMenu->addAction (a);
1238 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1239 actionViewToggleNoteEditor=a;
1241 a = new QAction(QPixmap(), tr( "Show tree editor","View action" ),this);
1242 a->setStatusTip ( tr( "Show tree editor" ));
1243 a->setShortcut ( Qt::CTRL + Qt::Key_T ); // Toggle Tree Editor // FIXME-3 originally: color subtree
1244 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1245 a->setToggleAction(true);
1247 viewMenu->addAction (a);
1248 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleTreeEditor() ) );
1249 actionViewToggleTreeEditor=a;
1251 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
1252 a->setStatusTip ( tr( "Show History Window" ));
1253 a->setShortcut ( Qt::CTRL + Qt::Key_H ); // Toggle history window
1254 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1255 a->setToggleAction(true);
1257 viewMenu->addAction (a);
1258 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1259 actionViewToggleHistoryWindow=a;
1261 viewMenu->addAction (actionViewTogglePropertyWindow);
1263 viewMenu->addSeparator();
1265 a = new QAction(tr( "Antialiasing","View action" ),this );
1266 a->setStatusTip ( tr( "Antialiasing" ));
1267 a->setToggleAction(true);
1268 a->setChecked (settings.value("/mainwindow/view/AntiAlias",true).toBool());
1269 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1270 viewMenu->addAction (a);
1271 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
1272 actionViewToggleAntiAlias=a;
1274 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1275 a->setStatusTip (a->text());
1276 a->setToggleAction(true);
1277 a->setChecked (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1278 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1279 viewMenu->addAction (a);
1280 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1281 actionViewToggleSmoothPixmapTransform=a;
1283 a = new QAction(tr( "Next Map","View action" ), this);
1284 a->setStatusTip (a->text());
1285 a->setShortcut (Qt::ALT + Qt::Key_N );
1286 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1287 viewMenu->addAction (a);
1288 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1290 a = new QAction (tr( "Previous Map","View action" ), this );
1291 a->setStatusTip (a->text());
1292 a->setShortcut (Qt::ALT + Qt::Key_P );
1293 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1294 viewMenu->addAction (a);
1295 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1299 void Main::setupModeActions()
1301 //QPopupMenu *menu = new QPopupMenu( this );
1302 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1304 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1305 tb->setObjectName ("modesTB");
1307 actionGroupModModes=new QActionGroup ( this);
1308 actionGroupModModes->setExclusive (true);
1309 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1310 a->setShortcut (Qt::Key_J);
1311 switchboard.addConnection(a,tr("Modes","Shortcut group"));
1312 a->setStatusTip ( tr( "Use modifier to color branches" ));
1313 a->setToggleAction(true);
1315 a->setChecked(true);
1316 actionModModeColor=a;
1318 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1319 a->setShortcut( Qt::Key_K);
1320 switchboard.addConnection(a,tr("Modes","Shortcut group"));
1321 a->setStatusTip( tr( "Use modifier to copy" ));
1322 a->setToggleAction(true);
1324 actionModModeCopy=a;
1326 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1327 a->setShortcut (Qt::Key_L);
1328 switchboard.addConnection(a,tr("Modes","Shortcut group"));
1329 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1330 a->setToggleAction(true);
1332 actionModModeXLink=a;
1336 void Main::setupFlagActions()
1338 // Create System Flags
1341 Flag *flag=new Flag;;
1342 flag->setVisible(true);
1344 flag->load(flagsPath+"flag-note.png");
1345 setupFlag (flag,tb,"system-note",tr("Note","SystemFlag"));
1347 flag->load(flagsPath+"flag-url.png");
1348 setupFlag (flag,tb,"system-url",tr("URL to Document ","SystemFlag"));
1350 flag->load(flagsPath+"flag-url-bugzilla-novell.png");
1351 setupFlag (flag,tb,"system-url-bugzilla-novell",tr("URL to Bugzilla ","SystemFlag"));
1353 flag->load(flagsPath+"flag-vymlink.png");
1354 setupFlag (flag,tb,"system-vymLink",tr("Link to another vym map","SystemFlag"));
1356 flag->load(flagsPath+"flag-scrolled-right.png");
1357 setupFlag (flag,tb,"system-scrolledright",tr("subtree is scrolled","SystemFlag"));
1359 flag->load(flagsPath+"flag-tmpUnscrolled-right.png");
1360 setupFlag (flag,tb,"system-tmpUnscrolledRight",tr("subtree is temporary scrolled","SystemFlag"));
1362 flag->load(flagsPath+"flag-hideexport.png");
1363 setupFlag (flag,tb,"system-hideInExport",tr("Hide object in exported maps","SystemFlag"));
1365 // Create Standard Flags
1366 tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1367 tb->setObjectName ("standardFlagTB");
1368 standardFlagsMaster->setToolBar (tb);
1370 flag->load(flagsPath+"flag-exclamationmark.png");
1371 flag->setGroup("standard-mark");
1372 setupFlag (flag,tb,"exclamationmark",tr("Take care!","Standardflag"));
1374 flag->load(flagsPath+"flag-questionmark.png");
1375 flag->setGroup("standard-mark");
1376 setupFlag (flag,tb,"questionmark",tr("Really?","Standardflag"));
1378 flag->load(flagsPath+"flag-hook-green.png");
1379 flag->setGroup("standard-status");
1380 setupFlag (flag,tb,"hook-green",tr("Status - ok,done","Standardflag"));
1382 flag->load(flagsPath+"flag-wip.png");
1383 flag->setGroup("standard-status");
1384 setupFlag (flag,tb,"wip",tr("Status - work in progress","Standardflag"));
1386 flag->load(flagsPath+"flag-cross-red.png");
1387 flag->setGroup("standard-status");
1388 setupFlag (flag,tb,"cross-red",tr("Status - missing, not started","Standardflag"));
1391 flag->load(flagsPath+"flag-stopsign.png");
1392 setupFlag (flag,tb,"stopsign",tr("This won't work!","Standardflag"));
1394 flag->load(flagsPath+"flag-smiley-good.png");
1395 flag->setGroup("standard-smiley");
1396 setupFlag (flag,tb,"smiley-good",tr("Good","Standardflag"));
1398 flag->load(flagsPath+"flag-smiley-sad.png");
1399 flag->setGroup("standard-smiley");
1400 setupFlag (flag,tb,"smiley-sad",tr("Bad","Standardflag"));
1402 flag->load(flagsPath+"flag-smiley-omg.png");
1403 flag->setGroup("standard-smiley");
1404 setupFlag (flag,tb,"smiley-omb",tr("Oh no!","Standardflag"));
1405 // Original omg.png (in KDE emoticons)
1408 flag->load(flagsPath+"flag-kalarm.png");
1409 setupFlag (flag,tb,"clock",tr("Time critical","Standardflag"));
1411 flag->load(flagsPath+"flag-phone.png");
1412 setupFlag (flag,tb,"phone",tr("Call...","Standardflag"));
1414 flag->load(flagsPath+"flag-lamp.png");
1415 setupFlag (flag,tb,"lamp",tr("Idea!","Standardflag"));
1417 flag->load(flagsPath+"flag-arrow-up.png");
1418 flag->setGroup("standard-arrow");
1419 setupFlag (flag,tb,"arrow-up",tr("Important","Standardflag"));
1421 flag->load(flagsPath+"flag-arrow-down.png");
1422 flag->setGroup("standard-arrow");
1423 setupFlag (flag,tb,"arrow-down",tr("Unimportant","Standardflag"));
1425 flag->load(flagsPath+"flag-arrow-2up.png");
1426 flag->setGroup("standard-arrow");
1427 setupFlag (flag,tb,"2arrow-up",tr("Very important!","Standardflag"));
1429 flag->load(flagsPath+"flag-arrow-2down.png");
1430 flag->setGroup("standard-arrow");
1431 setupFlag (flag,tb,"2arrow-down",tr("Very unimportant!","Standardflag"));
1434 flag->load(flagsPath+"flag-thumb-up.png");
1435 flag->setGroup("standard-thumb");
1436 setupFlag (flag,tb,"thumb-up",tr("I like this","Standardflag"));
1438 flag->load(flagsPath+"flag-thumb-down.png");
1439 flag->setGroup("standard-thumb");
1440 setupFlag (flag,tb,"thumb-down",tr("I do not like this","Standardflag"));
1443 flag->load(flagsPath+"flag-rose.png");
1444 setupFlag (flag,tb,"rose",tr("Rose","Standardflag"));
1446 flag->load(flagsPath+"flag-heart.png");
1447 setupFlag (flag,tb,"heart",tr("I just love...","Standardflag"));
1449 flag->load(flagsPath+"flag-present.png");
1450 setupFlag (flag,tb,"present",tr("Surprise!","Standardflag"));
1452 flag->load(flagsPath+"flag-flash.png");
1453 setupFlag (flag,tb,"flash",tr("Dangerous","Standardflag"));
1455 // Original: xsldbg_output.png
1456 flag->load(flagsPath+"flag-info.png");
1457 setupFlag (flag,tb,"info",tr("Info","Standardflag"));
1459 // Original khelpcenter.png
1460 flag->load(flagsPath+"flag-lifebelt.png");
1461 setupFlag (flag,tb,"lifebelt",tr("This will help","Standardflag"));
1464 flag->setVisible(false);
1465 flag->load(flagsPath+"freemind/warning.png");
1466 setupFlag (flag,tb, "freemind-warning",tr("Important","Freemind-Flag"));
1468 for (int i=1; i<8; i++)
1470 flag->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
1471 setupFlag (flag,tb, QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
1474 flag->load(flagsPath+"freemind/back.png");
1475 setupFlag (flag,tb,"freemind-back",tr("Back","Freemind-Flag"));
1477 flag->load(flagsPath+"freemind/forward.png");
1478 setupFlag (flag,tb,"freemind-forward",tr("forward","Freemind-Flag"));
1480 flag->load(flagsPath+"freemind/attach.png");
1481 setupFlag (flag,tb,"freemind-attach",tr("Look here","Freemind-Flag"));
1483 flag->load(flagsPath+"freemind/clanbomber.png");
1484 setupFlag (flag,tb,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
1486 flag->load(flagsPath+"freemind/desktopnew.png");
1487 setupFlag (flag,tb,"freemind-desktopnew",tr("Don't flagrget","Freemind-Flag"));
1489 flag->load(flagsPath+"freemind/flag.png");
1490 setupFlag (flag,tb,"freemind-flag",tr("Flag","Freemind-Flag"));
1493 flag->load(flagsPath+"freemind/gohome.png");
1494 setupFlag (flag,tb,"freemind-gohome",tr("Home","Freemind-Flag"));
1497 flag->load(flagsPath+"freemind/kaddressbook.png");
1498 setupFlag (flag,tb,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
1500 flag->load(flagsPath+"freemind/knotify.png");
1501 setupFlag (flag,tb,"freemind-knotify",tr("Music","Freemind-Flag"));
1503 flag->load(flagsPath+"freemind/korn.png");
1504 setupFlag (flag,tb,"freemind-korn",tr("Mailbox","Freemind-Flag"));
1506 flag->load(flagsPath+"freemind/mail.png");
1507 setupFlag (flag,tb,"freemind-mail",tr("Maix","Freemind-Flag"));
1509 flag->load(flagsPath+"freemind/password.png");
1510 setupFlag (flag,tb,"freemind-password",tr("Password","Freemind-Flag"));
1512 flag->load(flagsPath+"freemind/pencil.png");
1513 setupFlag (flag,tb,"freemind-pencil",tr("To be improved","Freemind-Flag"));
1515 flag->load(flagsPath+"freemind/stop.png");
1516 setupFlag (flag,tb,"freemind-stop",tr("Stop","Freemind-Flag"));
1518 flag->load(flagsPath+"freemind/wizard.png");
1519 setupFlag (flag,tb,"freemind-wizard",tr("Magic","Freemind-Flag"));
1521 flag->load(flagsPath+"freemind/xmag.png");
1522 setupFlag (flag,tb,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
1524 flag->load(flagsPath+"freemind/bell.png");
1525 setupFlag (flag,tb,"freemind-bell",tr("Reminder","Freemind-Flag"));
1527 flag->load(flagsPath+"freemind/bookmark.png");
1528 setupFlag (flag,tb,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
1530 flag->load(flagsPath+"freemind/penguin.png");
1531 setupFlag (flag,tb,"freemind-penguin",tr("Linux","Freemind-Flag"));
1533 flag->load(flagsPath+"freemind/licq.png");
1534 setupFlag (flag,tb,"freemind-licq",tr("Sweet","Freemind-Flag"));
1537 void Main::setupFlag (Flag *flag, QToolBar *tb, const QString &name, const QString &tooltip)
1539 flag->setName(name);
1540 flag->setToolTip (tooltip);
1544 a=new QAction (flag->getPixmap(),name,this);
1547 flag->setAction (a);
1548 a->setVisible (flag->isVisible());
1549 a->setCheckable(true);
1550 a->setObjectName(name);
1551 a->setToolTip(tooltip);
1552 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1553 standardFlagsMaster->addFlag (flag);
1557 systemFlagsMaster->addFlag (flag);
1562 void Main::setupNetworkActions()
1564 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1566 QMenu *netMenu = menuBar()->addMenu( "Network" );
1570 a = new QAction( "Start TCPserver for MapEditor",this);
1571 //a->setStatusTip ( "Set application to open pdf files"));
1572 //a->setShortcut ( Qt::ALT + Qt::Key_T ); //New TCP server
1573 switchboard.addConnection(a,tr("Network shortcuts","Shortcut group"));
1574 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1575 netMenu->addAction (a);
1577 a = new QAction( "Connect MapEditor to server",this);
1578 //a->setStatusTip ( "Set application to open pdf files"));
1579 a->setShortcut ( Qt::ALT + Qt::Key_C ); // Connect to server
1580 switchboard.addConnection(a,tr("Network shortcuts","Shortcut group"));
1581 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1582 netMenu->addAction (a);
1586 void Main::setupSettingsActions()
1588 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1592 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1593 a->setStatusTip ( tr( "Set application to open pdf files"));
1594 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1595 settingsMenu->addAction (a);
1597 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1598 a->setStatusTip( tr( "Set application to open external links"));
1599 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1600 settingsMenu->addAction (a);
1602 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1603 a->setStatusTip( tr( "Set path for macros"));
1604 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1605 settingsMenu->addAction (a);
1607 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1608 a->setStatusTip( tr( "Set number of undo levels"));
1609 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1610 settingsMenu->addAction (a);
1612 settingsMenu->addSeparator();
1614 a = new QAction( tr( "Autosave","Settings action"), this);
1615 a->setStatusTip( tr( "Autosave"));
1616 a->setToggleAction(true);
1617 a->setChecked ( settings.value ("/mainwindow/autosave/use",false).toBool());
1618 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1619 settingsMenu->addAction (a);
1620 actionSettingsAutosaveToggle=a;
1622 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1623 a->setStatusTip( tr( "Autosave time"));
1624 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1625 settingsMenu->addAction (a);
1626 actionSettingsAutosaveTime=a;
1628 a = new QAction( tr( "Write backup file on save","Settings action"), this);
1629 a->setStatusTip( tr( "Write backup file on save"));
1630 a->setToggleAction(true);
1631 a->setChecked ( settings.value ("/mainwindow/writeBackupFile",false).toBool());
1632 connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) );
1633 settingsMenu->addAction (a);
1634 actionSettingsWriteBackupFile=a;
1636 settingsMenu->addSeparator();
1638 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1639 a->setStatusTip( tr( "Edit branch after adding it" ));
1640 a->setToggleAction(true);
1641 a->setChecked ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1642 settingsMenu->addAction (a);
1643 actionSettingsAutoEditNewBranch=a;
1645 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1646 a->setStatusTip( tr( "Select branch after adding it" ));
1647 a->setToggleAction(true);
1648 a->setChecked ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1649 settingsMenu->addAction (a);
1650 actionSettingsAutoSelectNewBranch=a;
1652 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1653 a->setStatusTip( tr( "Select heading before editing" ));
1654 a->setToggleAction(true);
1655 a->setChecked ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1656 settingsMenu->addAction (a);
1657 actionSettingsAutoSelectText=a;
1659 a= new QAction( tr( "Delete key","Settings action" ), this);
1660 a->setStatusTip( tr( "Delete key for deleting branches" ));
1661 a->setToggleAction(true);
1662 a->setChecked ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1663 settingsMenu->addAction (a);
1664 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1665 actionSettingsUseDelKey=a;
1667 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1668 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1669 a->setToggleAction(true);
1670 a->setChecked ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1671 settingsMenu->addAction (a);
1672 actionSettingsUseFlagGroups=a;
1674 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1675 a->setStatusTip( tr( "Use hide flag during exports " ));
1676 a->setToggleAction(true);
1677 a->setChecked ( settings.value ("/export/useHideExport",true).toBool() );
1678 settingsMenu->addAction (a);
1679 actionSettingsUseHideExport=a;
1681 a = new QAction( tr( "Animation","Settings action"), this);
1682 a->setStatusTip( tr( "Animation"));
1683 a->setToggleAction(true);
1684 a->setChecked (settings.value("/animation/use",true).toBool() );
1685 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) );
1686 settingsMenu->addAction (a);
1687 actionSettingsUseAnimation=a;
1691 void Main::setupTestActions()
1693 QMenu *testMenu = menuBar()->addMenu( tr( "Test" ));
1696 a = new QAction( "Test function 1" , this);
1697 a->setStatusTip( "Call test function 1" );
1698 a->setShortcut (Qt::SHIFT + Qt::Key_T); // Test function 1
1699 switchboard.addConnection(a,tr("Test shortcuts","Shortcut group"));
1700 testMenu->addAction (a);
1701 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1703 a = new QAction( "Test function 2" , this);
1704 a->setStatusTip( "Call test function 2" );
1705 a->setShortcut (Qt::ALT + Qt::Key_T); // Test function 2
1706 switchboard.addConnection(a,tr("Test shortcuts","Shortcut group"));
1707 testMenu->addAction (a);
1708 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1710 a = new QAction( "Command" , this);
1711 a->setStatusTip( "Enter command to call in editor" );
1712 switchboard.addConnection(a,tr("Test shortcuts","Shortcut group"));
1713 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1714 testMenu->addAction (a);
1718 void Main::setupHelpActions()
1720 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1723 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1724 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1725 switchboard.addConnection(a,tr("Help shortcuts","Shortcut group"));
1726 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1727 helpMenu->addAction (a);
1729 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1730 a->setStatusTip( tr( "Open VYM example maps " ));
1731 switchboard.addConnection(a,tr("Help shortcuts","Shortcut group"));
1732 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1733 helpMenu->addAction (a);
1735 a = new QAction( tr( "About VYM","Help action" ), this);
1736 a->setStatusTip( tr( "About VYM")+vymName);
1737 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1738 helpMenu->addAction (a);
1740 a = new QAction( tr( "About QT","Help action" ), this);
1741 a->setStatusTip( tr( "Information about QT toolkit" ));
1742 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1743 helpMenu->addAction (a);
1747 void Main::setupContextMenus()
1751 // Context Menu for branch or mapcenter
1752 branchContextMenu =new QMenu (this);
1753 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1754 branchContextMenu->addSeparator();
1757 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1758 branchAddContextMenu->addAction (actionPaste );
1759 branchAddContextMenu->addAction ( actionAddMapCenter );
1760 branchAddContextMenu->addAction ( actionAddBranch );
1761 branchAddContextMenu->addAction ( actionAddBranchBefore );
1762 branchAddContextMenu->addAction ( actionAddBranchAbove);
1763 branchAddContextMenu->addAction ( actionAddBranchBelow );
1764 branchAddContextMenu->addSeparator();
1765 branchAddContextMenu->addAction ( actionImportAdd );
1766 branchAddContextMenu->addAction ( actionImportReplace );
1769 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1770 branchRemoveContextMenu->addAction (actionCut);
1771 branchRemoveContextMenu->addAction ( actionDelete );
1772 branchRemoveContextMenu->addAction ( actionDeleteKeepChildren );
1773 branchRemoveContextMenu->addAction ( actionDeleteChildren );
1776 actionSaveBranch->addTo( branchContextMenu );
1777 actionFileNewCopy->addTo (branchContextMenu );
1778 actionDetach->addTo (branchContextMenu );
1780 branchContextMenu->addSeparator();
1781 branchContextMenu->addAction ( actionLoadImage);
1782 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1783 branchContextMenu->addAction ( actionAddAttribute);
1785 // Submenu for Links (URLs, vymLinks)
1786 branchLinksContextMenu =new QMenu (this);
1788 branchContextMenu->addSeparator();
1789 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1790 branchLinksContextMenu->addAction ( actionOpenURL );
1791 branchLinksContextMenu->addAction ( actionOpenURLTab );
1792 branchLinksContextMenu->addAction ( actionOpenMultipleVisURLTabs );
1793 branchLinksContextMenu->addAction ( actionOpenMultipleURLTabs );
1794 branchLinksContextMenu->addAction ( actionURL );
1795 branchLinksContextMenu->addAction ( actionLocalURL );
1796 branchLinksContextMenu->addAction ( actionHeading2URL );
1797 branchLinksContextMenu->addAction ( actionBugzilla2URL );
1798 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1800 branchLinksContextMenu->addAction ( actionGetBugzillaData );
1801 branchLinksContextMenu->addAction ( actionFATE2URL );
1803 branchLinksContextMenu->addSeparator();
1804 branchLinksContextMenu->addAction ( actionOpenVymLink );
1805 branchLinksContextMenu->addAction ( actionOpenMultipleVymLinks );
1806 branchLinksContextMenu->addAction ( actionVymLink );
1807 branchLinksContextMenu->addAction ( actionDeleteVymLink );
1810 // Context Menu for XLinks in a branch menu
1811 // This will be populated "on demand" in MapEditor::updateActions
1812 branchContextMenu->addSeparator();
1813 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1814 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1817 // Context menu for floatimage
1818 floatimageContextMenu =new QMenu (this);
1819 a= new QAction (tr ("Save image","Context action"),this);
1820 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1821 floatimageContextMenu->addAction (a);
1823 floatimageContextMenu->addSeparator();
1824 actionCopy->addTo( floatimageContextMenu );
1825 actionCut->addTo( floatimageContextMenu );
1827 floatimageContextMenu->addSeparator();
1828 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1831 // Context menu for canvas
1832 canvasContextMenu =new QMenu (this);
1833 actionAddMapCenter->addTo( canvasContextMenu );
1834 actionMapInfo->addTo( canvasContextMenu );
1835 canvasContextMenu->insertSeparator();
1836 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1837 canvasContextMenu->insertSeparator();
1838 actionFormatLinkColorHint->addTo( canvasContextMenu );
1839 actionFormatLinkColor->addTo( canvasContextMenu );
1840 actionFormatSelectionColor->addTo( canvasContextMenu );
1841 actionFormatBackColor->addTo( canvasContextMenu );
1842 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME-4 makes vym too slow: postponed for later version
1844 // Menu for last opened files
1846 for (int i = 0; i < MaxRecentFiles; ++i)
1848 recentFileActions[i] = new QAction(this);
1849 recentFileActions[i]->setVisible(false);
1850 fileLastMapsMenu->addAction(recentFileActions[i]);
1851 connect(recentFileActions[i], SIGNAL(triggered()),
1852 this, SLOT(fileLoadRecent()));
1854 setupRecentMapsMenu();
1857 void Main::setupRecentMapsMenu()
1859 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1861 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1863 for (int i = 0; i < numRecentFiles; ++i) {
1864 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1865 recentFileActions[i]->setText(text);
1866 recentFileActions[i]->setData(files[i]);
1867 recentFileActions[i]->setVisible(true);
1869 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1870 recentFileActions[j]->setVisible(false);
1873 void Main::setupMacros()
1875 for (int i = 0; i <= 11; i++)
1877 macroActions[i] = new QAction(this);
1878 macroActions[i]->setData(i);
1879 addAction (macroActions[i]);
1880 //switchboard.addConnection(macroActions[i],tr("Macro shortcuts","Shortcut group"));
1881 connect(macroActions[i], SIGNAL(triggered()),
1882 this, SLOT(callMacro()));
1884 macroActions[0]->setShortcut ( Qt::Key_F1 );
1885 macroActions[1]->setShortcut ( Qt::Key_F2 );
1886 macroActions[2]->setShortcut ( Qt::Key_F3 );
1887 macroActions[3]->setShortcut ( Qt::Key_F4 );
1888 macroActions[4]->setShortcut ( Qt::Key_F5 );
1889 macroActions[5]->setShortcut ( Qt::Key_F6 );
1890 macroActions[6]->setShortcut ( Qt::Key_F7 );
1891 macroActions[7]->setShortcut ( Qt::Key_F8 );
1892 macroActions[8]->setShortcut ( Qt::Key_F9 );
1893 macroActions[9]->setShortcut ( Qt::Key_F10 );
1894 macroActions[10]->setShortcut ( Qt::Key_F11 );
1895 macroActions[11]->setShortcut ( Qt::Key_F12 );
1898 void Main::hideEvent (QHideEvent * )
1900 if (!textEditor->isMinimized() ) textEditor->hide();
1903 void Main::showEvent (QShowEvent * )
1905 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1909 MapEditor* Main::currentMapEditor() const
1911 if ( tabWidget->currentPage())
1912 return vymViews.at(tabWidget->currentIndex())->getMapEditor();
1916 VymModel* Main::currentModel() const
1918 if ( tabWidget->currentPage())
1919 return vymViews.at(tabWidget->currentIndex())->getModel();
1923 VymModel* Main::getModel(uint id) const //FIXME-2 id not used
1926 if ( tabWidget->currentPage())
1927 return vymViews.at(tabWidget->currentIndex())->getModel();
1932 void Main::editorChanged(QWidget *)
1934 // Unselect all possibly selected objects
1935 // (Important to update note editor)
1937 for (int i=0;i<=tabWidget->count() -1;i++)
1939 m= vymViews.at(i)->getModel();
1940 if (m) m->unselect();
1943 if (m) m->reselect();
1945 // Update actions to in menus and toolbars according to editor
1949 void Main::fileNew()
1951 VymModel *vm=new VymModel;
1953 /////////////////////////////////////
1954 // new ModelTest(vm, this); //FIXME-3
1955 /////////////////////////////////////
1957 VymView *vv=new VymView (vm);
1958 vymViews.append (vv);
1959 tabWidget->addTab (vv,tr("unnamed","MainWindow: name for new and empty file"));
1960 tabWidget->setCurrentIndex (vymViews.count() );
1963 // Create MapCenter for empty map
1967 // For the very first map we do not have flagrows yet...
1971 void Main::fileNewCopy()
1973 QString fn="unnamed";
1974 VymModel *srcModel=currentModel();
1979 VymModel *dstModel=vymViews.last()->getModel();
1980 dstModel->select("mc:");
1981 dstModel->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
1985 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
1987 ErrorCode err=success;
1989 // fn is usually the archive, mapfile the file after uncompressing
1992 // Make fn absolute (needed for unzip)
1993 fn=QDir (fn).absPath();
1999 // Check, if map is already loaded
2001 while (i<=tabWidget->count() -1)
2003 if (vymViews.at(i)->getModel()->getFilePath() == fn)
2005 // Already there, ask for confirmation
2006 QMessageBox mb( vymName,
2007 tr("The map %1\nis already opened."
2008 "Opening the same map in multiple editors may lead \n"
2009 "to confusion when finishing working with vym."
2010 "Do you want to").arg(fn),
2011 QMessageBox::Warning,
2012 QMessageBox::Yes | QMessageBox::Default,
2013 QMessageBox::Cancel | QMessageBox::Escape,
2014 QMessageBox::NoButton);
2015 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
2016 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2019 case QMessageBox::Yes:
2020 // end loop and load anyway
2021 i=tabWidget->count();
2023 case QMessageBox::Cancel:
2033 int tabIndex=tabWidget->currentPageIndex();
2036 if ( !fn.isEmpty() )
2038 vm = currentModel();
2039 // Check first, if mapeditor exists
2040 // If it is not default AND we want a new map,
2041 // create a new mapeditor in a new tab
2042 if ( lmode==NewMap && (!vm || !vm->isDefault() ) )
2045 VymView *vv=new VymView (vm);
2046 vymViews.append (vv);
2047 tabWidget->addTab (vv,fn);
2048 tabIndex=tabWidget->count()-1;
2049 tabWidget->setCurrentPage (tabIndex);
2053 // Check, if file exists (important for creating new files
2054 // from command line
2055 if (!QFile(fn).exists() )
2057 QMessageBox mb( vymName,
2058 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
2059 QMessageBox::Question,
2061 QMessageBox::Cancel | QMessageBox::Default,
2062 QMessageBox::NoButton );
2064 mb.setButtonText( QMessageBox::Yes, tr("Create"));
2065 mb.setButtonText( QMessageBox::No, tr("Cancel"));
2068 case QMessageBox::Yes:
2070 currentMapEditor()->getModel()->setFilePath(fn);
2071 tabWidget->setTabText (tabIndex,
2072 currentMapEditor()->getModel()->getFileName() );
2073 statusBar()->message( "Created " + fn , statusbarTime );
2076 case QMessageBox::Cancel:
2077 // don't create new map
2078 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
2085 //tabWidget->currentPage() won't be NULL here, because of above...
2086 tabWidget->setCurrentIndex (tabIndex);
2087 //FIXME-3 no me anymore... me->viewport()->setFocus();
2091 // Save existing filename in case we import
2092 QString fn_org=vm->getFilePath();
2094 // Finally load map into mapEditor
2095 vm->setFilePath (fn);
2096 err=vm->load(fn,lmode,ftype);
2098 // Restore old (maybe empty) filepath, if this is an import
2100 vm->setFilePath (fn_org);
2103 // Finally check for errors and go home
2106 if (lmode==NewMap) fileCloseMap();
2107 statusBar()->message( "Could not load " + fn, statusbarTime );
2112 vm->setFilePath (fn);
2113 tabWidget->setTabText (tabIndex, vm->getFileName());
2114 if (!isInTmpDir (fn))
2116 // Only append to lastMaps if not loaded from a tmpDir
2117 // e.g. imported bookmarks are in a tmpDir
2118 addRecentMap(vm->getFilePath() );
2120 actionFilePrint->setEnabled (true);
2122 statusBar()->message( "Loaded " + fn, statusbarTime );
2129 void Main::fileLoad(const LoadMode &lmode)
2131 QStringList filters;
2132 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
2133 QFileDialog *fd=new QFileDialog( this);
2134 fd->setDir (lastFileDir);
2135 fd->setFileMode (QFileDialog::ExistingFiles);
2136 fd->setFilters (filters);
2140 fd->setCaption(vymName+ " - " +tr("Load vym map"));
2143 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
2146 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
2152 if ( fd->exec() == QDialog::Accepted )
2154 lastFileDir=fd->directory().path();
2155 QStringList flist = fd->selectedFiles();
2156 QStringList::Iterator it = flist.begin();
2158 progressCounter=flist.count();
2159 progressCounterTotal=flist.count();
2160 while( it != flist.end() )
2163 fileLoad(*it, lmode);
2170 void Main::fileLoad()
2175 void Main::fileLoadRecent()
2177 QAction *action = qobject_cast<QAction *>(sender());
2179 fileLoad (action->data().toString(), NewMap);
2182 void Main::addRecentMap (const QString &fileName)
2185 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
2186 files.removeAll(fileName);
2187 files.prepend(fileName);
2188 while (files.size() > MaxRecentFiles)
2191 settings.setValue("/mainwindow/recentFileList", files);
2193 setupRecentMapsMenu();
2196 void Main::fileSave(VymModel *m, const SaveMode &savemode)
2200 if ( m->getFilePath().isEmpty() )
2202 // We have no filepath yet,
2203 // call fileSaveAs() now, this will call fileSave()
2205 // First switch to editor
2206 //FIXME-3 needed??? tabWidget->setCurrentWidget (m->getMapEditor());
2207 fileSaveAs(savemode);
2210 if (m->save (savemode)==success)
2212 statusBar()->message(
2213 tr("Saved %1").arg(m->getFilePath()),
2215 addRecentMap (m->getFilePath() );
2217 statusBar()->message(
2218 tr("Couldn't save ").arg(m->getFilePath()),
2222 void Main::fileSave()
2224 fileSave (currentModel(), CompleteMap);
2227 void Main::fileSave(VymModel *m)
2229 fileSave (m,CompleteMap);
2232 void Main::fileSaveAs(const SaveMode& savemode)
2236 if (currentMapEditor())
2238 if (savemode==CompleteMap)
2239 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2241 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2242 if ( !fn.isEmpty() )
2244 // Check for existing file
2245 if (QFile (fn).exists())
2247 QMessageBox mb( vymName,
2248 tr("The file %1\nexists already. Do you want to").arg(fn),
2249 QMessageBox::Warning,
2250 QMessageBox::Yes | QMessageBox::Default,
2251 QMessageBox::Cancel | QMessageBox::Escape,
2252 QMessageBox::NoButton);
2253 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2254 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2257 case QMessageBox::Yes:
2260 case QMessageBox::Cancel:
2267 // New file, add extension to filename, if missing
2268 // This is always .vym or .vyp, depending on savemode
2269 if (savemode==CompleteMap)
2271 if (!fn.contains (".vym") && !fn.contains (".xml"))
2275 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2284 VymModel *m=currentModel();
2286 fileSave(m, savemode);
2288 // Set name of tab, assuming current tab is the one we just saved
2289 if (savemode==CompleteMap)
2290 tabWidget->setTabText (tabWidget->currentIndex(), m->getFileName() );
2296 void Main::fileSaveAs()
2298 fileSaveAs (CompleteMap);
2301 void Main::fileImportKDE3Bookmarks()
2303 ImportKDE3Bookmarks im;
2305 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2306 currentMapEditor()->getModel()->setFilePath ("");
2309 void Main::fileImportKDE4Bookmarks()
2311 ImportKDE4Bookmarks im;
2313 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2314 currentMapEditor()->getModel()->setFilePath ("");
2317 void Main::fileImportFirefoxBookmarks()
2319 Q3FileDialog *fd=new Q3FileDialog( this);
2320 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2321 fd->setMode (Q3FileDialog::ExistingFiles);
2322 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2323 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2326 if ( fd->exec() == QDialog::Accepted )
2328 ImportFirefoxBookmarks im;
2329 QStringList flist = fd->selectedFiles();
2330 QStringList::Iterator it = flist.begin();
2331 while( it != flist.end() )
2334 if (im.transform() &&
2335 aborted!=fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2336 currentMapEditor() )
2337 currentMapEditor()->getModel()->setFilePath ("");
2344 void Main::fileImportFreemind()
2346 QStringList filters;
2347 filters <<"Freemind map (*.mm)"<<"All files (*)";
2348 QFileDialog *fd=new QFileDialog( this);
2349 fd->setDir (lastFileDir);
2350 fd->setFileMode (QFileDialog::ExistingFiles);
2351 fd->setFilters (filters);
2352 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2356 if ( fd->exec() == QDialog::Accepted )
2358 lastFileDir=fd->directory().path();
2359 QStringList flist = fd->selectedFiles();
2360 QStringList::Iterator it = flist.begin();
2361 while( it != flist.end() )
2364 if ( fileLoad (fn,NewMap, FreemindMap) )
2366 currentMapEditor()->getModel()->setFilePath ("");
2375 void Main::fileImportMM()
2379 Q3FileDialog *fd=new Q3FileDialog( this);
2380 fd->setDir (lastFileDir);
2381 fd->setMode (Q3FileDialog::ExistingFiles);
2382 fd->addFilter ("Mind Manager (*.mmap)");
2383 fd->setCaption(tr("Import")+" "+"Mind Manager");
2386 if ( fd->exec() == QDialog::Accepted )
2388 lastFileDir=fd->dirPath();
2389 QStringList flist = fd->selectedFiles();
2390 QStringList::Iterator it = flist.begin();
2391 while( it != flist.end() )
2394 if (im.transform() &&
2395 success==fileLoad (im.getTransformedFile(),NewMap) &&
2396 currentMapEditor() )
2397 currentMapEditor()->getModel()->setFilePath ("");
2404 void Main::fileImportDir()
2406 VymModel *m=currentModel();
2407 if (m) m->importDir();
2410 void Main::fileExportXML()
2412 VymModel *m=currentModel();
2413 if (m) m->exportXML();
2416 void Main::fileExportHTML()
2418 VymModel *m=currentModel();
2419 if (m) m->exportHTML();
2423 void Main::fileExportXHTML()
2425 VymModel *m=currentModel();
2426 if (m) m->exportXHTML();
2429 void Main::fileExportImage()
2431 VymModel *m=currentModel();
2432 if (m) m->exportImage();
2435 void Main::fileExportAO()
2437 VymModel *m=currentModel();
2438 if (m) m->exportAO();
2441 void Main::fileExportASCII()
2443 VymModel *m=currentModel();
2444 if (m) m->exportASCII();
2447 void Main::fileExportCSV() //FIXME-3 not scriptable yet
2449 VymModel *m=currentModel();
2454 ex.addFilter ("CSV (*.csv)");
2455 ex.setDir(lastImageDir);
2456 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2457 if (ex.execDialog() )
2459 m->setExportMode(true);
2461 m->setExportMode(false);
2466 void Main::fileExportLaTeX() //FIXME-3 not scriptable yet
2468 VymModel *m=currentModel();
2473 ex.addFilter ("Tex (*.tex)");
2474 ex.setDir(lastImageDir);
2475 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2476 if (ex.execDialog() )
2478 m->setExportMode(true);
2480 m->setExportMode(false);
2485 void Main::fileExportKDE3Bookmarks() //FIXME-3 not scriptable yet
2487 ExportKDE3Bookmarks ex;
2488 VymModel *m=currentModel();
2496 void Main::fileExportKDE4Bookmarks() //FIXME-3 not scriptable yet
2498 ExportKDE4Bookmarks ex;
2499 VymModel *m=currentModel();
2507 void Main::fileExportTaskjuggler() //FIXME-3 not scriptable yet
2509 ExportTaskjuggler ex;
2510 VymModel *m=currentModel();
2514 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2515 ex.setDir(lastImageDir);
2516 ex.addFilter ("Taskjuggler (*.tjp)");
2517 if (ex.execDialog() )
2519 m->setExportMode(true);
2521 m->setExportMode(false);
2526 void Main::fileExportOOPresentation() //FIXME-3 not scriptable yet
2528 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2529 // TODO add preview in dialog
2530 //ImagePreview *p =new ImagePreview (fd);
2531 //fd->setContentsPreviewEnabled( TRUE );
2532 //fd->setContentsPreview( p, p );
2533 //fd->setPreviewMode( QFileDialog::Contents );
2534 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2535 fd->setDir (QDir().current());
2536 if (fd->foundConfig())
2540 if ( fd->exec() == QDialog::Accepted )
2542 QString fn=fd->selectedFile();
2543 if (!fn.contains (".odp"))
2546 //lastImageDir=fn.left(fn.findRev ("/"));
2547 VymModel *m=currentModel();
2548 if (m) m->exportOOPresentation(fn,fd->selectedConfig());
2552 QMessageBox::warning(0,
2554 tr("Couldn't find configuration for export to Open Office\n"));
2558 void Main::fileCloseMap()
2560 VymModel *m=currentModel();
2563 if (m->hasChanged())
2565 QMessageBox mb( vymName,
2566 tr("The map %1 has been modified but not saved yet. Do you want to").arg(m->getFileName()),
2567 QMessageBox::Warning,
2568 QMessageBox::Yes | QMessageBox::Default,
2570 QMessageBox::Cancel | QMessageBox::Escape );
2571 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2572 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2575 case QMessageBox::Yes:
2577 fileSave(m, CompleteMap);
2579 case QMessageBox::No:
2580 // close without saving
2582 case QMessageBox::Cancel:
2587 // And here comes the segfault, because removeTab triggers
2588 // FIXME-3 currentChanged->Main::editorChanged -> updateActions and VM is not NULL yet...
2589 vymViews.removeAt (tabWidget->currentIndex() );
2590 tabWidget->removeTab (tabWidget->currentIndex() );
2592 // Remove mapEditor/model FIXME-3 Huh? seems to work now...
2593 // Better would be delete (me), but then we could have a Qt error:
2594 // "QObject: Do not delete object, 'MapEditor', during its event handler!"
2595 // So we only remove data now and call deconstructor when vym closes later
2596 // this needs to be moved to vymview... me->clear();
2597 // some model->clear is needed to free up memory ...
2599 delete (m->getMapEditor());
2606 void Main::filePrint()
2608 if (currentMapEditor())
2609 currentMapEditor()->print();
2612 void Main::fileExitVYM()
2614 // Check if one or more editors have changed
2616 for (i=0;i<=vymViews.count() -1;i++)
2618 // If something changed, ask what to do
2619 if (vymViews.at(i)->getModel()->hasChanged())
2621 tabWidget->setCurrentPage(i);
2622 QMessageBox mb( vymName,
2623 tr("This map is not saved yet. Do you want to"),
2624 QMessageBox::Warning,
2625 QMessageBox::Yes | QMessageBox::Default,
2627 QMessageBox::Cancel | QMessageBox::Escape );
2628 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2629 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2632 mb.setActiveWindow();
2633 switch( mb.exec() ) {
2634 case QMessageBox::Yes:
2635 // save (the changed editors) and exit
2636 fileSave(currentModel(), CompleteMap);
2638 case QMessageBox::No:
2639 // exit without saving
2641 case QMessageBox::Cancel:
2642 // don't save and don't exit
2646 } // loop over all MEs
2650 void Main::editUndo()
2652 VymModel *m=currentModel();
2656 void Main::editRedo()
2658 VymModel *m=currentModel();
2662 void Main::gotoHistoryStep (int i)
2664 VymModel *m=currentModel();
2665 if (m) m->gotoHistoryStep(i);
2668 void Main::editCopy()
2670 VymModel *m=currentModel();
2674 void Main::editPaste()
2676 VymModel *m=currentModel();
2680 void Main::editCut()
2682 VymModel *m=currentModel();
2686 void Main::editOpenFindWidget()
2688 if (!findWidget->isVisible())
2691 findWidget->setFocus();
2692 } else if (!findResultWidget->parentWidget()->isVisible())
2693 findResultWidget->parentWidget()->show();
2697 findResultWidget->parentWidget()->hide();
2701 void Main::editHideFindWidget()
2703 // findWidget hides itself, but we want
2704 // to have focus back at mapEditor usually
2705 MapEditor *me=currentMapEditor();
2706 if (me) me->setFocus();
2709 void Main::editFindNext(QString s)
2711 Qt::CaseSensitivity cs=Qt::CaseInsensitive;
2713 VymModel *m=currentModel();
2716 m->findAll (findResultWidget->getResultModel(),s,cs);
2718 BranchItem *bi=m->findText(s, cs,cursor);
2721 findWidget->setStatus (FindWidget::Success);
2724 findWidget->setStatus (FindWidget::Failed);
2728 void Main::editFindDuplicateURLs() //FIXME-4 feature: use FindResultWidget for display
2730 VymModel *m=currentModel();
2731 if (m) m->findDuplicateURLs();
2734 void Main::openTabs(QStringList urls)
2736 if (!urls.isEmpty())
2740 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2741 //qDebug ()<<"Services: "<<QDBusConnection::sessionBus().interface()->registeredServiceNames().value();
2742 if (*browserPID==0 ||
2743 (browser.contains("konqueror") &&
2744 !QDBusConnection::sessionBus().interface()->registeredServiceNames().value().contains (QString("org.kde.konqueror-%1").arg(*browserPID)))
2747 // Start a new browser, if there is not one running already or
2748 // if a previously started konqueror is gone.
2749 if (debug) cout <<"Main::openTabs no konqueror-"<<*browserPID<<" found\n";
2750 QString u=urls.takeFirst();
2752 QString workDir=QDir::currentDirPath();
2753 if (!QProcess::startDetached(browser,args,workDir,browserPID))
2755 // try to set path to browser
2756 QMessageBox::warning(0,
2758 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2759 tr("Please use Settings->")+tr("Set application to open an URL"));
2762 if (debug) cout << "Main::openTabs Started konqueror-"<<*browserPID<<endl;
2763 #if defined(Q_OS_WIN32)
2764 // There's no sleep in VCEE, replace it with Qt's QThread::wait().
2765 this->thread()->wait(3000);
2767 sleep (3); //FIXME-3 needed?
2771 if (browser.contains("konqueror"))
2773 for (int i=0; i<urls.size(); i++)
2776 // Try to open new tab in existing konqueror started previously by vym
2780 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2781 "konqueror-mainwindow#1"<<
2785 args<< QString("org.kde.konqueror-%1").arg(*browserPID)<<
2786 "/konqueror/MainWindow_1"<<
2790 if (debug) cout << "MainWindow::openURLs args="<<args.join(" ").toStdString()<<endl;
2791 if (!QProcess::startDetached ("qdbus",args))
2795 QMessageBox::warning(0,
2797 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2799 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2801 for (int i=0; i<urls.size(); i++)
2803 // Try to open new tab in firefox
2804 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2805 if (!QProcess::startDetached (browser,args))
2809 QMessageBox::warning(0,
2811 tr("Couldn't start %1 to open a new tab").arg(browser));
2814 QMessageBox::warning(0,
2816 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2820 void Main::editOpenURL()
2823 VymModel *m=currentModel();
2826 QString url=m->getURL();
2828 if (url=="") return;
2829 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2831 QString workDir=QDir::currentDirPath();
2832 if (!procBrowser->startDetached(browser,args))
2834 // try to set path to browser
2835 QMessageBox::warning(0,
2837 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2838 tr("Please use Settings->")+tr("Set application to open an URL"));
2843 void Main::editOpenURLTab()
2845 VymModel *m=currentModel();
2849 urls.append(m->getURL());
2854 void Main::editOpenMultipleVisURLTabs(bool ignoreScrolled)
2856 VymModel *m=currentModel();
2860 urls=m->getURLs(ignoreScrolled);
2865 void Main::editOpenMultipleURLTabs()
2867 editOpenMultipleVisURLTabs (false);
2871 void Main::editURL()
2873 VymModel *m=currentModel();
2874 if (m) m->editURL();
2877 void Main::editLocalURL()
2879 VymModel *m=currentModel();
2880 if (m) m->editLocalURL();
2883 void Main::editHeading2URL()
2885 VymModel *m=currentModel();
2886 if (m) m->editHeading2URL();
2889 void Main::editBugzilla2URL()
2891 VymModel *m=currentModel();
2892 if (m) m->editBugzilla2URL();
2895 void Main::getBugzillaData()
2897 VymModel *m=currentModel();
2899 QProgressDialog progress ("Doing stuff","cancl",0,10,this);
2900 progress.setWindowModality(Qt::WindowModal);
2901 //progress.setCancelButton (NULL);
2903 progress.setMinimumDuration (0);
2904 progress.setValue (1);
2905 progress.setValue (5);
2909 QProgressBar *pb=new QProgressBar;
2915 if (m) m->getBugzillaData();
2918 void Main::editFATE2URL()
2920 VymModel *m=currentModel();
2921 if (m) m->editFATE2URL();
2924 void Main::editHeadingFinished(VymModel *m)
2928 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2929 !prevSelection.isEmpty())
2930 m->select(prevSelection);
2935 void Main::openVymLinks(const QStringList &vl)
2937 for (int j=0; j<vl.size(); j++)
2939 // compare path with already loaded maps
2942 for (i=0;i<=vymViews.count() -1;i++)
2944 if (vl.at(j)==vymViews.at(i)->getModel()->getFilePath() )
2953 if (!QFile(vl.at(j)).exists() )
2954 QMessageBox::critical( 0, tr( "Critical Error" ),
2955 tr("Couldn't open map %1").arg(vl.at(j)));
2958 fileLoad (vl.at(j), NewMap);
2959 tabWidget->setCurrentIndex (tabWidget->count()-1);
2962 // Go to tab containing the map
2963 tabWidget->setCurrentIndex (index);
2967 void Main::editOpenVymLink()
2969 VymModel *m=currentModel();
2973 vl.append(m->getVymLink());
2978 void Main::editOpenMultipleVymLinks()
2980 QString currentVymLink;
2981 VymModel *m=currentModel();
2984 QStringList vl=m->getVymLinks();
2989 void Main::editVymLink()
2991 VymModel *m=currentModel();
2996 void Main::editDeleteVymLink()
2998 VymModel *m=currentModel();
2999 if (m) m->deleteVymLink();
3002 void Main::editToggleHideExport()
3004 VymModel *m=currentModel();
3005 if (m) m->toggleHideExport();
3008 void Main::editAddTimestamp()
3010 VymModel *m=currentModel();
3011 if (m) m->addTimestamp();
3014 void Main::editMapInfo()
3016 VymModel *m=currentModel();
3019 ExtraInfoDialog dia;
3020 dia.setMapName (m->getFileName() );
3021 dia.setAuthor (m->getAuthor() );
3022 dia.setComment(m->getComment() );
3026 stats+=tr("%1 items on map\n","Info about map").arg (m->getScene()->items().size(),6);
3032 BranchItem *cur=NULL;
3033 BranchItem *prev=NULL;
3034 m->nextBranch(cur,prev);
3037 if (!cur->getNote().isEmpty() ) n++;
3038 f+= cur->imageCount();
3040 xl+=cur->xlinkCount();
3041 m->nextBranch(cur,prev);
3044 stats+=QString ("%1 xLinks \n").arg (xl,6);
3045 stats+=QString ("%1 notes\n").arg (n,6);
3046 stats+=QString ("%1 images\n").arg (f,6);
3047 stats+=QString ("%1 branches\n").arg (m->branchCount(),6);
3048 dia.setStats (stats);
3050 // Finally show dialog
3051 if (dia.exec() == QDialog::Accepted)
3053 m->setAuthor (dia.getAuthor() );
3054 m->setComment (dia.getComment() );
3058 void Main::editMoveUp()
3060 VymModel *m=currentModel();
3064 void Main::editMoveDown()
3066 VymModel *m=currentModel();
3067 if (m) m->moveDown();
3070 void Main::editDetach()
3072 VymModel *m=currentModel();
3076 void Main::editSortChildren()
3078 VymModel *m=currentModel();
3079 if (m) m->sortChildren(false);
3082 void Main::editSortBackChildren()
3084 VymModel *m=currentModel();
3085 if (m) m->sortChildren(true);
3088 void Main::editToggleScroll()
3090 VymModel *m=currentModel();
3091 if (m) m->toggleScroll();
3094 void Main::editExpandAll()
3096 VymModel *m=currentModel();
3097 if (m) m->emitExpandAll();
3100 void Main::editExpandOneLevel()
3102 VymModel *m=currentModel();
3103 if (m) m->emitExpandOneLevel();
3106 void Main::editCollapseOneLevel()
3108 VymModel *m=currentModel();
3109 if (m) m->emitCollapseOneLevel();
3112 void Main::editUnscrollChildren()
3114 VymModel *m=currentModel();
3115 if (m) m->unscrollChildren();
3118 void Main::editAddAttribute()
3120 VymModel *m=currentModel();
3128 void Main::editAddMapCenter()
3130 VymModel *m=currentModel();
3131 if (m) m->addMapCenter ();
3134 void Main::editNewBranch()
3136 VymModel *m=currentModel();
3139 BranchItem *bi=m->addNewBranch();
3142 if (actionSettingsAutoEditNewBranch->isOn()
3143 && !actionSettingsAutoSelectNewBranch->isOn() )
3144 prevSelection=m->getSelectString();
3146 prevSelection=QString();
3148 if (actionSettingsAutoSelectNewBranch->isOn()
3149 || actionSettingsAutoEditNewBranch->isOn())
3152 if (actionSettingsAutoEditNewBranch->isOn())
3153 currentMapEditor()->editHeading();
3158 void Main::editNewBranchBefore()
3160 VymModel *m=currentModel();
3163 BranchItem *bi=m->addNewBranchBefore();
3170 if (actionSettingsAutoEditNewBranch->isOn())
3172 if (!actionSettingsAutoSelectNewBranch->isOn())
3173 prevSelection=m->getSelectString(bi);
3174 currentMapEditor()->editHeading();
3179 void Main::editNewBranchAbove()
3181 VymModel *m=currentModel();
3184 BranchItem *bi=m->addNewBranch (-1);
3192 if (actionSettingsAutoEditNewBranch->isOn())
3194 if (!actionSettingsAutoSelectNewBranch->isOn())
3195 prevSelection=m->getSelectString (bi);
3196 currentMapEditor()->editHeading();
3201 void Main::editNewBranchBelow()
3203 VymModel *m=currentModel();
3206 BranchItem *bi=m->addNewBranch (1);
3213 if (actionSettingsAutoEditNewBranch->isOn())
3215 if (!actionSettingsAutoSelectNewBranch->isOn())
3216 prevSelection=m->getSelectString(bi);
3217 currentMapEditor()->editHeading();
3222 void Main::editImportAdd()
3224 fileLoad (ImportAdd);
3227 void Main::editImportReplace()
3229 fileLoad (ImportReplace);
3232 void Main::editSaveBranch()
3234 fileSaveAs (PartOfMap);
3237 void Main::editDeleteKeepChildren()
3239 VymModel *m=currentModel();
3240 if (m) m->deleteKeepChildren();
3243 void Main::editDeleteChildren()
3245 VymModel *m=currentModel();
3246 if (m) m->deleteChildren();
3249 void Main::editDeleteSelection()
3251 VymModel *m=currentModel();
3252 if (m && actionSettingsUseDelKey->isOn())
3253 m->deleteSelection();
3256 void Main::editLoadImage()
3258 VymModel *m=currentModel();
3259 if (m) m->loadFloatImage();
3262 void Main::editSaveImage()
3264 VymModel *m=currentModel();
3265 if (m) m->saveFloatImage();
3268 void Main::editEditXLink(QAction *a)
3270 VymModel *m=currentModel();
3272 m->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3275 void Main::formatSelectColor()
3277 QColor col = QColorDialog::getColor((currentColor ), this );
3278 if ( !col.isValid() ) return;
3279 colorChanged( col );
3282 void Main::formatPickColor()
3284 VymModel *m=currentModel();
3286 colorChanged( m->getCurrentHeadingColor() );
3289 void Main::colorChanged(QColor c)
3291 QPixmap pix( 16, 16 );
3293 actionFormatColor->setIconSet( pix );
3297 void Main::formatColorBranch()
3299 VymModel *m=currentModel();
3300 if (m) m->colorBranch(currentColor);
3303 void Main::formatColorSubtree()
3305 VymModel *m=currentModel();
3306 if (m) m->colorSubtree (currentColor);
3309 void Main::formatLinkStyleLine()
3311 VymModel *m=currentModel();
3314 m->setMapLinkStyle("StyleLine");
3315 actionFormatLinkStyleLine->setChecked(true);
3319 void Main::formatLinkStyleParabel()
3321 VymModel *m=currentModel();
3324 m->setMapLinkStyle("StyleParabel");
3325 actionFormatLinkStyleParabel->setChecked(true);
3329 void Main::formatLinkStylePolyLine()
3331 VymModel *m=currentModel();
3334 m->setMapLinkStyle("StylePolyLine");
3335 actionFormatLinkStylePolyLine->setChecked(true);
3339 void Main::formatLinkStylePolyParabel()
3341 VymModel *m=currentModel();
3344 m->setMapLinkStyle("StylePolyParabel");
3345 actionFormatLinkStylePolyParabel->setChecked(true);
3349 void Main::formatSelectBackColor()
3351 VymModel *m=currentModel();
3352 if (m) m->selectMapBackgroundColor();
3355 void Main::formatSelectBackImage()
3357 VymModel *m=currentModel();
3359 m->selectMapBackgroundImage();
3362 void Main::formatSelectLinkColor()
3364 VymModel *m=currentModel();
3367 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3368 m->setMapDefLinkColor( col );
3372 void Main::formatSelectSelectionColor()
3374 VymModel *m=currentModel();
3377 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3378 m->setSelectionColor (col);
3383 void Main::formatToggleLinkColorHint()
3385 VymModel *m=currentModel();
3386 if (m) m->toggleMapLinkColorHint();
3390 void Main::formatHideLinkUnselected() //FIXME-3 get rid of this with imagepropertydialog
3392 VymModel *m=currentModel();
3394 m->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3397 void Main::viewZoomReset()
3399 MapEditor *me=currentMapEditor();
3400 if (me) me->setZoomFactorTarget (1);
3403 void Main::viewZoomIn()
3405 MapEditor *me=currentMapEditor();
3406 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*1.25);
3409 void Main::viewZoomOut()
3411 MapEditor *me=currentMapEditor();
3412 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*0.75);
3415 void Main::viewCenter()
3417 VymModel *m=currentModel();
3418 if (m) m->emitShowSelection();
3421 void Main::networkStartServer()
3423 VymModel *m=currentModel();
3424 if (m) m->newServer();
3427 void Main::networkConnect()
3429 VymModel *m=currentModel();
3430 if (m) m->connectToServer();
3433 bool Main::settingsPDF()
3435 // Default browser is set in constructor
3437 QString text = QInputDialog::getText(
3438 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3439 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3441 settings.setValue ("/mainwindow/readerPDF",text);
3446 bool Main::settingsURL()
3448 // Default browser is set in constructor
3450 QString text = QInputDialog::getText(
3451 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3452 settings.value("/mainwindow/readerURL").toString()
3455 settings.setValue ("/mainwindow/readerURL",text);
3459 void Main::settingsMacroDir()
3461 QDir defdir(vymBaseDir.path() + "/macros");
3462 if (!defdir.exists())
3464 QDir dir=QFileDialog::getExistingDirectory (
3466 tr ("Directory with vym macros:"),
3467 settings.value ("/macros/macroDir",defdir.path()).toString()
3470 settings.setValue ("/macros/macroDir",dir.absolutePath());
3473 void Main::settingsUndoLevels()
3476 int i = QInputDialog::getInteger(
3478 tr("QInputDialog::getInteger()"),
3479 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3482 settings.setValue ("/mapeditor/stepsTotal",i);
3483 QMessageBox::information( this, tr( "VYM -Information:" ),
3484 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3488 void Main::settingsAutosaveToggle()
3490 settings.setValue ("/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
3493 void Main::settingsAutosaveTime()
3496 int i = QInputDialog::getInteger(
3498 tr("QInputDialog::getInteger()"),
3499 tr("Number of seconds before autosave:"), settings.value("/mainwindow/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3501 settings.setValue ("/mainwindow/autosave/ms",i * 1000);
3504 void Main::settingsWriteBackupFileToggle()
3506 settings.setValue ("/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
3509 void Main::settingsToggleAnimation()
3511 settings.setValue ("/animation/use",actionSettingsUseAnimation->isOn() );
3514 void Main::settingsToggleDelKey()
3516 if (actionSettingsUseDelKey->isOn())
3518 actionDelete->setAccel (QKeySequence (Qt::Key_Delete));
3521 actionDelete->setAccel (QKeySequence (""));
3525 void Main::windowToggleNoteEditor()
3527 if (textEditor->isVisible() )
3528 windowHideNoteEditor();
3530 windowShowNoteEditor();
3533 void Main::windowToggleTreeEditor()
3535 if ( tabWidget->currentPage())
3536 vymViews.at(tabWidget->currentIndex())->toggleTreeEditor();
3539 void Main::windowToggleHistory()
3541 if (historyWindow->isVisible())
3542 historyWindow->hide();
3544 historyWindow->show();
3548 void Main::windowToggleProperty()
3550 if (branchPropertyWindow->isVisible())
3551 branchPropertyWindow->hide();
3553 branchPropertyWindow->show();
3554 branchPropertyWindow->setModel (currentModel() );
3557 void Main::windowToggleAntiAlias()
3559 bool b=actionViewToggleAntiAlias->isOn();
3561 for (int i=0;i<vymViews.count();i++)
3563 me=vymViews.at(i)->getMapEditor();
3564 if (me) me->setAntiAlias(b);
3569 bool Main::isAliased()
3571 return actionViewToggleAntiAlias->isOn();
3574 bool Main::hasSmoothPixmapTransform()
3576 return actionViewToggleSmoothPixmapTransform->isOn();
3579 void Main::windowToggleSmoothPixmap()
3581 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3583 for (int i=0;i<vymViews.count();i++)
3586 me=vymViews.at(i)->getMapEditor();
3587 if (me) me->setSmoothPixmap(b);
3591 void Main::updateHistory(SimpleSettings &undoSet)
3593 historyWindow->update (undoSet);
3596 void Main::updateNoteFlag()
3598 // this slot is connected to TextEditor::textHasChanged()
3599 VymModel *m=currentModel();
3600 if (m) m->updateNoteFlag();
3603 void Main::updateNoteEditor(QModelIndex index )
3605 TreeItem *ti=((VymModel*) QObject::sender())->getItem(index);
3607 cout << "Main::updateNoteEditor model="<<sender();
3608 cout << " item="<<ti->getHeadingStd()<<" ("<<ti<<")"<<endl;
3610 textEditor->setNote (ti->getNoteObj() );
3613 void Main::changeSelection (VymModel *model, const QItemSelection &newsel, const QItemSelection &oldsel)
3615 branchPropertyWindow->setModel (model ); //FIXME-3 this used to be called from BranchObj::select(). Maybe use signal now...
3617 if (model && model==currentModel() )
3621 if (!oldsel.indexes().isEmpty() )
3623 ti=model->getItem(oldsel.indexes().first());
3625 // Don't update note if both treeItem and textEditor are empty
3626 //if (! (ti->hasEmptyNote() && textEditor->isEmpty() ))
3627 // ti->setNoteObj (textEditor->getNoteObj(),false );
3629 if (!newsel.indexes().isEmpty() )
3631 ti=model->getItem(newsel.indexes().first());
3632 if (!ti->hasEmptyNote() )
3633 textEditor->setNote(ti->getNoteObj() );
3635 textEditor->setNote(NoteObj() ); //FIXME-4 maybe add a clear() to TE
3637 // Show URL and link in statusbar
3639 QString s=ti->getURL();
3640 if (!s.isEmpty() ) status+="URL: "+s+" ";
3642 if (!s.isEmpty() ) status+="Link: "+s;
3643 if (!status.isEmpty() ) statusMessage (status);
3646 textEditor->setInactive();
3652 void Main::updateActions()
3654 // updateActions is also called when satellites are closed //FIXME-2 doesn't update immediatly, e.g. historyWindow is still visible, when "close" is pressed
3655 actionViewToggleNoteEditor->setChecked (textEditor->isVisible());
3656 actionViewToggleHistoryWindow->setChecked (historyWindow->isVisible());
3657 actionViewTogglePropertyWindow->setChecked (branchPropertyWindow->isVisible());
3659 VymModel *m =currentModel();
3663 actionFilePrint->setEnabled (true);
3665 // Link style in context menu
3666 switch (m->getMapLinkStyle())
3668 case LinkableMapObj::Line:
3669 actionFormatLinkStyleLine->setChecked(true);
3671 case LinkableMapObj::Parabel:
3672 actionFormatLinkStyleParabel->setChecked(true);
3674 case LinkableMapObj::PolyLine:
3675 actionFormatLinkStylePolyLine->setChecked(true);
3677 case LinkableMapObj::PolyParabel:
3678 actionFormatLinkStylePolyParabel->setChecked(true);
3685 QPixmap pix( 16, 16 );
3686 pix.fill( m->getMapBackgroundColor() );
3687 actionFormatBackColor->setIconSet( pix );
3688 pix.fill( m->getSelectionColor() );
3689 actionFormatSelectionColor->setIconSet( pix );
3690 pix.fill( m->getMapDefLinkColor() );
3691 actionFormatLinkColor->setIconSet( pix );
3694 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName()));
3697 // Expanding/collapsing
3698 actionExpandAll->setEnabled (true);
3699 actionExpandOneLevel->setEnabled (true);
3700 actionCollapseOneLevel->setEnabled (true);
3704 actionFilePrint->setEnabled (false);
3706 // Expanding/collapsing
3707 actionExpandAll->setEnabled (false);
3708 actionExpandOneLevel->setEnabled (false);
3709 actionCollapseOneLevel->setEnabled (false);
3712 if (m && m->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3713 actionFormatLinkColorHint->setChecked(true);
3715 actionFormatLinkColorHint->setChecked(false);
3718 if (m && m->hasChanged() )
3719 actionFileSave->setEnabled( true);
3721 actionFileSave->setEnabled( false);
3722 if (m && m->isUndoAvailable())
3723 actionUndo->setEnabled( true);
3725 actionUndo->setEnabled( false);
3727 if (m && m->isRedoAvailable())
3728 actionRedo->setEnabled( true);
3730 actionRedo->setEnabled( false);
3734 TreeItem *selti=m->getSelectedItem();
3735 BranchItem *selbi=m->getSelectedBranch();
3738 if (selbi || selti->getType()==TreeItem::Image)
3740 actionFormatHideLinkUnselected->setChecked (((MapItem*)selti)->getHideLinkUnselected());
3741 actionFormatHideLinkUnselected->setEnabled (true);
3746 // Take care of xlinks
3747 branchXLinksContextMenuEdit->clear();
3748 if (selbi->xlinkCount()>0)
3752 for (int i=0; i<selbi->xlinkCount();++i)
3754 bi=selbi->getXLinkNum(i)->getPartnerBranch();
3758 if (s.length()>xLinkMenuWidth)
3759 s=s.left(xLinkMenuWidth)+"...";
3760 branchXLinksContextMenuEdit->addAction (s);
3765 standardFlagsMaster->updateToolBar (selbi->activeStandardFlagNames() );
3768 actionToggleScroll->setEnabled (true);
3769 if ( selbi->isScrolled() )
3770 actionToggleScroll->setChecked(true);
3772 actionToggleScroll->setChecked(false);
3774 if ( selti->getURL().isEmpty() )
3776 actionOpenURL->setEnabled (false);
3777 actionOpenURLTab->setEnabled (false);
3781 actionOpenURL->setEnabled (true);
3782 actionOpenURLTab->setEnabled (true);
3784 if ( selti->getVymLink().isEmpty() )
3786 actionOpenVymLink->setEnabled (false);
3787 actionDeleteVymLink->setEnabled (false);
3790 actionOpenVymLink->setEnabled (true);
3791 actionDeleteVymLink->setEnabled (true);
3794 if (selbi->canMoveUp())
3795 actionMoveUp->setEnabled (true);
3797 actionMoveUp->setEnabled (false);
3798 if (selbi->canMoveDown())
3799 actionMoveDown->setEnabled (true);
3801 actionMoveDown->setEnabled (false);
3803 actionSortChildren->setEnabled (true);
3804 actionSortBackChildren->setEnabled (true);
3806 actionToggleHideExport->setEnabled (true);
3807 actionToggleHideExport->setChecked (selbi->hideInExport() );
3809 actionCopy->setEnabled (true);
3810 actionCut->setEnabled (true);
3811 if (!clipboardEmpty)
3812 actionPaste->setEnabled (true);
3814 actionPaste->setEnabled (false);
3815 for (int i=0; i<actionListBranches.size(); ++i)
3816 actionListBranches.at(i)->setEnabled(true);
3817 actionDelete->setEnabled (true);
3819 if ( selti->getType()==TreeItem::Image)
3821 actionOpenURL->setEnabled (false);
3822 actionOpenVymLink->setEnabled (false);
3823 actionDeleteVymLink->setEnabled (false);
3824 actionToggleHideExport->setEnabled (true);
3825 actionToggleHideExport->setChecked (selti->hideInExport() );
3828 actionCopy->setEnabled (true);
3829 actionCut->setEnabled (true);
3830 actionPaste->setEnabled (false); //FIXME-4 why not allowing copy of images?
3831 for (int i=0; i<actionListBranches.size(); ++i)
3832 actionListBranches.at(i)->setEnabled(false);
3833 actionDelete->setEnabled (true);
3834 actionMoveUp->setEnabled (false);
3835 actionMoveDown->setEnabled (false);
3840 actionCopy->setEnabled (false);
3841 actionCut->setEnabled (false);
3842 actionPaste->setEnabled (false);
3843 for (int i=0; i<actionListBranches.size(); ++i)
3844 actionListBranches.at(i)->setEnabled(false);
3846 actionToggleScroll->setEnabled (false);
3847 actionOpenURL->setEnabled (false);
3848 actionOpenVymLink->setEnabled (false);
3849 actionDeleteVymLink->setEnabled (false);
3850 actionHeading2URL->setEnabled (false);
3851 actionDelete->setEnabled (false);
3852 actionMoveUp->setEnabled (false);
3853 actionMoveDown->setEnabled (false);
3854 actionFormatHideLinkUnselected->setEnabled (false);
3855 actionSortChildren->setEnabled (false);
3856 actionSortBackChildren->setEnabled (false);
3857 actionToggleHideExport->setEnabled (false);
3862 Main::ModMode Main::getModMode()
3864 if (actionModModeColor->isOn()) return ModModeColor;
3865 if (actionModModeCopy->isOn()) return ModModeCopy;
3866 if (actionModModeXLink->isOn()) return ModModeXLink;
3870 bool Main::autoEditNewBranch()
3872 return actionSettingsAutoEditNewBranch->isOn();
3875 bool Main::autoSelectNewBranch()
3877 return actionSettingsAutoSelectNewBranch->isOn();
3880 void Main::windowShowNoteEditor()
3882 textEditor->setShowWithMain(true);
3884 actionViewToggleNoteEditor->setChecked (true);
3887 void Main::windowHideNoteEditor()
3889 textEditor->setShowWithMain(false);
3891 actionViewToggleNoteEditor->setChecked (false);
3894 void Main::setScript (const QString &script)
3896 scriptEditor->setScript (script);
3899 void Main::runScript (const QString &script)
3901 VymModel *m=currentModel();
3902 if (m) m->runScript (script);
3905 void Main::runScriptEverywhere (const QString &script)
3908 for (int i=0;i<=tabWidget->count() -1;i++)
3910 me=(MapEditor*)tabWidget->page(i);
3911 if (me) me->getModel()->runScript (script);
3915 void Main::windowNextEditor()
3917 if (tabWidget->currentIndex() < tabWidget->count())
3918 tabWidget->setCurrentIndex (tabWidget->currentIndex() +1);
3921 void Main::windowPreviousEditor()
3923 if (tabWidget->currentIndex() >0)
3924 tabWidget->setCurrentIndex (tabWidget->currentIndex() -1);
3927 void Main::standardFlagChanged()
3931 if ( actionSettingsUseFlagGroups->isOn() )
3932 currentModel()->toggleStandardFlag(sender()->name(),standardFlagsMaster);
3934 currentModel()->toggleStandardFlag(sender()->name());
3940 #include "attributeitem.h"
3941 void Main::testFunction1()
3943 VymModel *m=currentModel();
3946 BranchItem *selbi=m->getSelectedBranch();
3949 QList<QVariant> cData;
3950 cData << "new ai" << "undef";
3952 AttributeItem *ai=new AttributeItem (cData,selbi);
3953 ai->set ("Key 1","Val a",AttributeItem::FreeString);
3955 m->addAttribute (ai);
3960 if (!currentMapEditor()) return;
3961 currentMapEditor()->testFunction1();
3965 VymModel *m=currentModel();
3969 QString text = QInputDialog::getText(
3970 "VYM", "Enter Filter:", QLineEdit::Normal, // FIXME-3 no translation yet
3971 m->getSortFilter(), &ok, NULL);
3973 // user entered something and pressed OK
3974 m->setSortFilter (text);
3978 void Main::testFunction2()
3980 findResultWidget->setModel (currentModel());
3981 findResultWidget->addResult ("Test",currentModel()->getSelectedItem());
3985 if (!currentMapEditor()) return;
3986 currentMapEditor()->testFunction2();
3989 void Main::testCommand()
3991 if (!currentMapEditor()) return;
3992 scriptEditor->show();
3995 QString com = QInputDialog::getText(
3996 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3997 if (ok) currentMapEditor()->parseAtom(com);
4001 void Main::helpDoc()
4003 QString locale = QLocale::system().name();
4005 if (locale.left(2)=="es")
4006 docname="vym_es.pdf";
4010 QStringList searchList;
4012 #if defined(Q_OS_MACX)
4013 searchList << "./vym.app/Contents/Resources/doc";
4014 #elif defined(Q_OS_WIN32)
4015 searchList << vymInstallDir.path() + "/share/doc/packages/vym";
4017 #if defined(VYM_DOCDIR)
4018 searchList << VYM_DOCDIR;
4020 // default path in SUSE LINUX
4021 searchList << "/usr/share/doc/packages/vym";
4024 searchList << "doc"; // relative path for easy testing in tarball
4025 searchList << "doc/tex"; // Easy testing working on vym.tex
4026 searchList << "/usr/share/doc/vym"; // Debian
4027 searchList << "/usr/share/doc/packages";// Knoppix
4031 for (int i=0; i<searchList.count(); ++i)
4033 docfile.setFileName(searchList.at(i)+"/"+docname);
4034 if (docfile.exists())
4043 QMessageBox::critical(0,
4044 tr("Critcal error"),
4045 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
4050 Process *pdfProc = new Process();
4051 args << QDir::toNativeSeparators(docfile.fileName());
4053 if (!pdfProc->startDetached( settings.value("/mainwindow/readerPDF").toString(),args) )
4056 QMessageBox::warning(0,
4058 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
4059 tr("Please use Settings->")+tr("Set application to open PDF files"));
4066 void Main::helpDemo()
4068 QStringList filters;
4069 filters <<"VYM example map (*.vym)";
4070 QFileDialog *fd=new QFileDialog( this);
4071 #if defined(Q_OS_MACX)
4072 fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
4074 // default path in SUSE LINUX
4075 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
4078 fd->setFileMode (QFileDialog::ExistingFiles);
4079 fd->setFilters (filters);
4080 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
4084 if ( fd->exec() == QDialog::Accepted )
4086 lastFileDir=fd->directory().path();
4087 QStringList flist = fd->selectedFiles();
4088 QStringList::Iterator it = flist.begin();
4089 while( it != flist.end() )
4092 fileLoad(*it, NewMap);
4100 void Main::helpAbout()
4103 ad.setName ("aboutwindow");
4104 ad.setMinimumSize(500,500);
4105 ad.resize (QSize (500,500));
4109 void Main::helpAboutQT()
4111 QMessageBox::aboutQt( this, "Qt Application Example" );
4114 void Main::callMacro ()
4116 QAction *action = qobject_cast<QAction *>(sender());
4120 i=action->data().toInt();
4121 QString mDir (settings.value ("macros/macroDir").toString() );
4123 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
4125 if ( !f.open( QIODevice::ReadOnly ) )
4127 QMessageBox::warning(0,
4129 tr("Couldn't find a macro at %1.\n").arg(fn)+
4130 tr("Please use Settings->")+tr("Set directory for vym macros"));
4134 QTextStream ts( &f );
4135 QString macro= ts.read();
4137 if (! macro.isEmpty())
4139 VymModel *m=currentModel();
4140 if (m) m->runScript(macro);