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; //FIXME-2 is toggle action? why?
778 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
779 alt->setShortcut ( Qt::Key_S ); // Scroll branch
780 alt->setStatusTip (tr( "Scroll branch" ));
781 switchboard.addConnection(alt,tr("Edit","Shortcut group"));
782 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
783 #if defined(Q_OS_MACX)
784 actionToggleScroll=alt;
786 actionToggleScroll=a;
788 actionToggleScroll->setEnabled (false);
789 actionToggleScroll->setToggleAction(true);
790 tb->addAction (actionToggleScroll);
791 editMenu->addAction ( actionToggleScroll);
792 editMenu->addAction (actionToggleScroll);
795 actionListBranches.append(actionToggleScroll);
797 a = new QAction( QPixmap(), tr( "Expand all branches","Edit menu" ), this);
798 a->setShortcut ( Qt::SHIFT + Qt::Key_X ); // Expand all branches
799 a->setStatusTip (tr( "Expand all branches" ));
800 switchboard.addConnection(a,tr("Edit","Shortcut group"));
801 connect( a, SIGNAL( triggered() ), this, SLOT( editExpandAll() ) );
803 actionExpandAll->setEnabled (false);
804 actionExpandAll->setToggleAction(false);
805 //tb->addAction (actionExpandAll);
806 editMenu->addAction ( actionExpandAll);
808 actionListBranches.append(actionExpandAll);
810 a = new QAction( QPixmap(), tr( "Expand one level","Edit menu" ), this);
811 a->setShortcut ( Qt::Key_Greater ); // Expand one level in tree editor
812 switchboard.addConnection(a,tr("Edit","Shortcut group"));
813 a->setStatusTip (tr( "Expand one level in tree editor" ));
814 connect( a, SIGNAL( triggered() ), this, SLOT( editExpandOneLevel() ) );
815 a->setEnabled (false);
816 a->setToggleAction(false);
817 actionExpandOneLevel=a;
819 editMenu->addAction ( a);
821 actionListBranches.append(a);
823 a = new QAction( QPixmap(), tr( "Collapse one level","Edit menu" ), this);
824 a->setShortcut ( Qt::Key_Less); // Collapse one level in tree editor
825 switchboard.addConnection(a,tr("Edit","Shortcut group"));
826 a->setStatusTip (tr( "Collapse one level in tree editor" ));
827 connect( a, SIGNAL( triggered() ), this, SLOT( editCollapseOneLevel() ) );
828 a->setEnabled (false);
829 a->setToggleAction(false);
830 actionCollapseOneLevel=a;
832 editMenu->addAction ( a);
834 actionListBranches.append(a);
836 a = new QAction( tr( "Unscroll children","Edit menu" ), this);
837 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
838 switchboard.addConnection(a,tr("Edit","Shortcut group"));
839 editMenu->addAction (a);
840 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChildren() ) );
842 editMenu->addSeparator();
844 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
845 a->setStatusTip (tr( "Find" ) );
846 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
847 switchboard.addConnection(a,tr("Edit","Shortcut group"));
848 editMenu->addAction (a);
849 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWidget() ) );
851 a = new QAction( tr( "Find duplicate URLs","Edit menu"), this);
852 //a->setStatusTip (tr( "Find" ) );
853 a->setShortcut (Qt::SHIFT + Qt::Key_F); //Find duplicate URLs
854 switchboard.addConnection(a,tr("Edit","Shortcut group"));
855 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
856 editMenu->addAction (a);
857 connect( a, SIGNAL( triggered() ), this, SLOT( editFindDuplicateURLs() ) );
859 editMenu->addSeparator();
861 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
862 a->setShortcut (Qt::SHIFT + Qt::Key_U );
863 switchboard.addConnection(a,tr("Edit","Shortcut group"));
866 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
869 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
870 a->setStatusTip (tr( "Open URL in new tab" ));
871 //a->setShortcut (Qt::CTRL+Qt::Key_U );
872 switchboard.addConnection(a,tr("Edit","Shortcut group"));
874 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
877 a = new QAction( tr( "Open all URLs in subtree (including scrolled branches)","Edit menu" ), this);
878 a->setStatusTip (tr( "Open all URLs in subtree (including scrolled branches)" ));
879 a->setShortcut ( Qt::CTRL + Qt::Key_U );
880 switchboard.addConnection(a,tr("Edit","Shortcut group"));
882 actionListBranches.append(a);
883 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVisURLTabs() ) );
884 actionOpenMultipleVisURLTabs=a;
886 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
887 a->setStatusTip (tr( "Open all URLs in subtree" ));
888 switchboard.addConnection(a,tr("Edit","Shortcut group"));
890 actionListBranches.append(a);
891 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
892 actionOpenMultipleURLTabs=a;
894 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
895 a->setStatusTip ( tr( "Edit URL" ) );
896 a->setShortcut ( Qt::Key_U );
897 a->setShortcutContext (Qt::WindowShortcut);
898 switchboard.addConnection(a,tr("Edit","Shortcut group"));
899 actionListBranches.append(a);
901 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
904 a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
905 a->setStatusTip ( tr( "Edit local URL" ) );
906 //a->setShortcut (Qt::SHIFT + Qt::Key_U );
907 a->setShortcutContext (Qt::WindowShortcut);
908 switchboard.addConnection(a,tr("Edit","Shortcut group"));
909 actionListBranches.append(a);
911 connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
914 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
915 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
916 a->setEnabled (false);
917 switchboard.addConnection(a,tr("Edit","Shortcut group"));
918 actionListBranches.append(a);
919 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
922 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
923 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
924 a->setEnabled (false);
925 actionListBranches.append(a);
926 a->setShortcut ( Qt::Key_B );
927 a->setShortcutContext (Qt::WindowShortcut);
928 switchboard.addConnection(a,tr("Edit","Shortcut group"));
930 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
931 actionBugzilla2URL=a;
933 a = new QAction(tr( "Get data from Novell Bugzilla","Edit menu" ), this);
934 a->setStatusTip ( tr( "Get data from Novell Bugzilla" ));
935 a->setEnabled (false);
936 actionListBranches.append(a);
937 a->setShortcut ( Qt::Key_B + Qt::SHIFT);
938 a->setShortcutContext (Qt::WindowShortcut);
939 switchboard.addConnection(a,tr("Edit","Shortcut group"));
941 connect( a, SIGNAL( triggered() ), this, SLOT( getBugzillaData() ) );
942 actionGetBugzillaData=a;
944 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
945 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
946 a->setEnabled (false);
947 switchboard.addConnection(a,tr("Edit","Shortcut group"));
948 actionListBranches.append(a);
949 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
952 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
953 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
955 a->setEnabled (false);
956 switchboard.addConnection(a,tr("Edit","Shortcut group"));
957 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
960 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
961 a->setStatusTip ( tr( "Open all vym links in subtree" ));
962 a->setEnabled (false);
963 switchboard.addConnection(a,tr("Edit","Shortcut group"));
964 actionListBranches.append(a);
965 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
966 actionOpenMultipleVymLinks=a;
969 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
970 a->setEnabled (false);
971 a->setStatusTip ( tr( "Edit link to another vym map" ));
972 switchboard.addConnection(a,tr("Edit","Shortcut group"));
973 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
974 actionListBranches.append(a);
977 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
978 a->setStatusTip ( tr( "Delete link to another vym map" ));
979 a->setEnabled (false);
980 switchboard.addConnection(a,tr("Edit","Shortcut group"));
981 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
982 actionDeleteVymLink=a;
984 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
985 a->setStatusTip ( tr( "Hide object in exports" ) );
986 a->setShortcut (Qt::Key_H );
987 a->setToggleAction(true);
989 a->setEnabled (false);
990 switchboard.addConnection(a,tr("Edit","Shortcut group"));
991 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
992 actionToggleHideExport=a;
994 a = new QAction(tr( "Add timestamp","Edit menu" ), this);
995 a->setStatusTip ( tr( "Add timestamp" ));
996 a->setEnabled (false);
997 actionListBranches.append(a);
998 a->setShortcut ( Qt::Key_T ); // Add timestamp
999 a->setShortcutContext (Qt::WindowShortcut);
1000 switchboard.addConnection(a,tr("Edit","Shortcut group"));
1002 connect( a, SIGNAL( triggered() ), this, SLOT( editAddTimestamp() ) );
1003 actionAddTimestamp=a;
1005 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
1006 a->setStatusTip ( tr( "Edit Map Info" ));
1007 a->setEnabled (true);
1008 switchboard.addConnection(a,tr("Edit","Shortcut group"));
1009 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
1012 // Import at selection (adding to selection)
1013 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
1014 a->setStatusTip (tr( "Add map at selection" ));
1015 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
1016 a->setEnabled (false);
1017 switchboard.addConnection(a,tr("Edit","Shortcut group"));
1018 actionListBranches.append(a);
1021 // Import at selection (replacing selection)
1022 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
1023 a->setStatusTip (tr( "Replace selection with map" ));
1024 switchboard.addConnection(a,tr("Edit","Shortcut group"));
1025 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
1026 a->setEnabled (false);
1027 actionListBranches.append(a);
1028 actionImportReplace=a;
1031 a = new QAction( tr( "Save selection","Edit menu" ), this);
1032 a->setStatusTip (tr( "Save selection" ));
1033 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
1034 a->setEnabled (false);
1035 switchboard.addConnection(a,tr("Edit","Shortcut group"));
1036 actionListBranches.append(a);
1039 // Only remove branch, not its children
1040 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
1041 a->setStatusTip ( tr( "Remove only branch and keep its children" ));
1042 a->setShortcut (Qt::ALT + Qt::Key_Delete );
1043 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChildren() ) );
1044 a->setEnabled (false);
1045 switchboard.addConnection(a,tr("Edit","Shortcut group"));
1047 actionListBranches.append(a);
1048 actionDeleteKeepChildren=a;
1050 // Only remove children of a branch
1051 a = new QAction( tr( "Remove children","Edit menu" ), this);
1052 a->setStatusTip (tr( "Remove children of branch" ));
1053 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
1054 switchboard.addConnection(a,tr("Edit","Shortcut group"));
1055 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChildren() ) );
1056 a->setEnabled (false);
1057 actionListBranches.append(a);
1058 actionDeleteChildren=a;
1060 a = new QAction( tr( "Add Image...","Edit menu" ), this);
1061 a->setStatusTip (tr( "Add Image" ));
1062 switchboard.addConnection(a,tr("Edit","Shortcut group"));
1063 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
1066 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
1067 a->setStatusTip (tr( "Set properties for selection" ));
1068 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
1069 a->setShortcutContext (Qt::WindowShortcut);
1070 a->setToggleAction (true);
1071 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1073 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
1074 actionViewTogglePropertyWindow=a;
1078 void Main::setupFormatActions()
1080 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
1082 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
1083 tb->setObjectName ("formatTB");
1085 QPixmap pix( 16,16);
1086 pix.fill (Qt::black);
1087 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
1088 a->setStatusTip ( tr( "Set Color" ));
1089 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
1091 formatMenu->addAction (a);
1092 actionFormatColor=a;
1093 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
1094 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
1095 a->setShortcut (Qt::CTRL + Qt::Key_K );
1096 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
1097 a->setEnabled (false);
1099 formatMenu->addAction (a);
1100 actionListBranches.append(a);
1101 actionFormatPickColor=a;
1103 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
1104 a->setStatusTip ( tr( "Color branch" ) );
1105 a->setShortcut (Qt::CTRL + Qt::Key_B + Qt::SHIFT);
1106 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
1107 a->setEnabled (false);
1109 formatMenu->addAction (a);
1110 actionListBranches.append(a);
1111 actionFormatColorSubtree=a;
1113 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
1114 a->setStatusTip ( tr( "Color Subtree" ));
1115 a->setShortcut (Qt::CTRL + Qt::Key_B); // Color subtree
1116 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
1117 a->setEnabled (false);
1118 formatMenu->addAction (a);
1120 actionListBranches.append(a);
1121 actionFormatColorSubtree=a;
1123 formatMenu->addSeparator();
1124 actionGroupFormatLinkStyles=new QActionGroup ( this);
1125 actionGroupFormatLinkStyles->setExclusive (true);
1126 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
1127 a->setStatusTip (tr( "Line" ));
1128 a->setToggleAction(true);
1129 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
1130 formatMenu->addAction (a);
1131 actionFormatLinkStyleLine=a;
1132 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
1133 a->setStatusTip (tr( "Line" ));
1134 a->setToggleAction(true);
1135 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
1136 formatMenu->addAction (a);
1137 actionFormatLinkStyleParabel=a;
1138 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
1139 a->setStatusTip (tr( "PolyLine" ));
1140 a->setToggleAction(true);
1141 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
1142 formatMenu->addAction (a);
1143 actionFormatLinkStylePolyLine=a;
1144 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
1145 a->setStatusTip (tr( "PolyParabel" ) );
1146 a->setToggleAction(true);
1147 a->setChecked (true);
1148 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
1149 formatMenu->addAction (a);
1150 actionFormatLinkStylePolyParabel=a;
1152 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
1153 a->setStatusTip (tr( "Hide link" ));
1154 a->setToggleAction(true);
1155 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
1156 actionFormatHideLinkUnselected=a;
1158 formatMenu->addSeparator();
1159 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
1160 a->setStatusTip (tr( "Use same color for links and headings" ));
1161 a->setToggleAction(true);
1162 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
1163 formatMenu->addAction (a);
1164 actionFormatLinkColorHint=a;
1166 pix.fill (Qt::white);
1167 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
1168 a->setStatusTip (tr( "Set Link Color" ));
1169 formatMenu->addAction (a);
1170 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
1171 actionFormatLinkColor=a;
1173 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
1174 a->setStatusTip (tr( "Set Selection Color" ));
1175 formatMenu->addAction (a);
1176 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
1177 actionFormatSelectionColor=a;
1179 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
1180 a->setStatusTip (tr( "Set Background Color" ));
1181 formatMenu->addAction (a);
1182 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
1183 actionFormatBackColor=a;
1185 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
1186 a->setStatusTip (tr( "Set Background image" ));
1187 formatMenu->addAction (a);
1188 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
1189 actionFormatBackImage=a;
1193 void Main::setupViewActions()
1195 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
1196 tb->setLabel( "View Actions" );
1197 tb->setObjectName ("viewTB");
1198 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
1202 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
1203 a->setStatusTip ( tr( "Zoom reset" ) );
1204 a->setShortcut (Qt::CTRL + Qt::Key_0); // Reset zoom
1205 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1207 viewMenu->addAction (a);
1208 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
1210 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
1211 a->setStatusTip (tr( "Zoom in" ));
1212 a->setShortcut(Qt::CTRL + Qt::Key_Plus);
1213 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1215 viewMenu->addAction (a);
1216 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
1218 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
1219 a->setStatusTip (tr( "Zoom out" ));
1220 a->setShortcut(Qt::CTRL + Qt::Key_Minus);
1221 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1223 viewMenu->addAction (a);
1224 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1226 a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
1227 a->setStatusTip (tr( "Show selection" ));
1228 a->setShortcut(Qt::CTRL + Qt::Key_Period);
1229 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1231 viewMenu->addAction (a);
1232 connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
1234 viewMenu->addSeparator();
1236 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
1237 a->setStatusTip ( tr( "Show Note Editor" ));
1238 a->setShortcut ( Qt::CTRL + Qt::Key_E ); // Toggle Note Editor
1239 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1240 a->setToggleAction(true);
1242 viewMenu->addAction (a);
1243 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1244 actionViewToggleNoteEditor=a;
1246 a = new QAction(QPixmap(), tr( "Show tree editor","View action" ),this);
1247 a->setStatusTip ( tr( "Show tree editor" ));
1248 a->setShortcut ( Qt::CTRL + Qt::Key_T ); // Toggle Tree Editor // FIXME-3 originally: color subtree
1249 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1250 a->setToggleAction(true);
1252 viewMenu->addAction (a);
1253 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleTreeEditor() ) );
1254 actionViewToggleTreeEditor=a;
1256 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
1257 a->setStatusTip ( tr( "Show History Window" ));
1258 a->setShortcut ( Qt::CTRL + Qt::Key_H ); // Toggle history window
1259 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1260 a->setToggleAction(true);
1262 viewMenu->addAction (a);
1263 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1264 actionViewToggleHistoryWindow=a;
1266 viewMenu->addAction (actionViewTogglePropertyWindow);
1268 viewMenu->addSeparator();
1270 a = new QAction(tr( "Antialiasing","View action" ),this );
1271 a->setStatusTip ( tr( "Antialiasing" ));
1272 a->setToggleAction(true);
1273 a->setChecked (settings.value("/mainwindow/view/AntiAlias",true).toBool());
1274 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1275 viewMenu->addAction (a);
1276 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
1277 actionViewToggleAntiAlias=a;
1279 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1280 a->setStatusTip (a->text());
1281 a->setToggleAction(true);
1282 a->setChecked (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1283 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1284 viewMenu->addAction (a);
1285 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1286 actionViewToggleSmoothPixmapTransform=a;
1288 a = new QAction(tr( "Next Map","View action" ), this);
1289 a->setStatusTip (a->text());
1290 a->setShortcut (Qt::ALT + Qt::Key_N );
1291 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1292 viewMenu->addAction (a);
1293 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1295 a = new QAction (tr( "Previous Map","View action" ), this );
1296 a->setStatusTip (a->text());
1297 a->setShortcut (Qt::ALT + Qt::Key_P );
1298 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1299 viewMenu->addAction (a);
1300 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1304 void Main::setupModeActions()
1306 //QPopupMenu *menu = new QPopupMenu( this );
1307 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1309 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1310 tb->setObjectName ("modesTB");
1312 actionGroupModModes=new QActionGroup ( this);
1313 actionGroupModModes->setExclusive (true);
1314 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1315 a->setShortcut (Qt::Key_J);
1316 switchboard.addConnection(a,tr("Modes","Shortcut group"));
1317 a->setStatusTip ( tr( "Use modifier to color branches" ));
1318 a->setToggleAction(true);
1320 a->setChecked(true);
1321 actionModModeColor=a;
1323 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1324 a->setShortcut( Qt::Key_K);
1325 switchboard.addConnection(a,tr("Modes","Shortcut group"));
1326 a->setStatusTip( tr( "Use modifier to copy" ));
1327 a->setToggleAction(true);
1329 actionModModeCopy=a;
1331 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1332 a->setShortcut (Qt::Key_L);
1333 switchboard.addConnection(a,tr("Modes","Shortcut group"));
1334 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1335 a->setToggleAction(true);
1337 actionModModeXLink=a;
1341 void Main::setupFlagActions()
1343 // Create System Flags
1346 Flag *flag=new Flag;;
1347 flag->setVisible(true);
1349 flag->load(flagsPath+"flag-note.png");
1350 setupFlag (flag,tb,"system-note",tr("Note","SystemFlag"));
1352 flag->load(flagsPath+"flag-url.png");
1353 setupFlag (flag,tb,"system-url",tr("URL to Document ","SystemFlag"));
1355 flag->load(flagsPath+"flag-url-bugzilla-novell.png");
1356 setupFlag (flag,tb,"system-url-bugzilla-novell",tr("URL to Bugzilla ","SystemFlag"));
1358 flag->load(flagsPath+"flag-vymlink.png");
1359 setupFlag (flag,tb,"system-vymLink",tr("Link to another vym map","SystemFlag"));
1361 flag->load(flagsPath+"flag-scrolled-right.png");
1362 setupFlag (flag,tb,"system-scrolledright",tr("subtree is scrolled","SystemFlag"));
1364 flag->load(flagsPath+"flag-tmpUnscrolled-right.png");
1365 setupFlag (flag,tb,"system-tmpUnscrolledRight",tr("subtree is temporary scrolled","SystemFlag"));
1367 flag->load(flagsPath+"flag-hideexport.png");
1368 setupFlag (flag,tb,"system-hideInExport",tr("Hide object in exported maps","SystemFlag"));
1370 // Create Standard Flags
1371 tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1372 tb->setObjectName ("standardFlagTB");
1373 standardFlagsMaster->setToolBar (tb);
1375 flag->load(flagsPath+"flag-exclamationmark.png");
1376 flag->setGroup("standard-mark");
1377 setupFlag (flag,tb,"exclamationmark",tr("Take care!","Standardflag"));
1379 flag->load(flagsPath+"flag-questionmark.png");
1380 flag->setGroup("standard-mark");
1381 setupFlag (flag,tb,"questionmark",tr("Really?","Standardflag"));
1383 flag->load(flagsPath+"flag-hook-green.png");
1384 flag->setGroup("standard-status");
1385 setupFlag (flag,tb,"hook-green",tr("Status - ok,done","Standardflag"));
1387 flag->load(flagsPath+"flag-wip.png");
1388 flag->setGroup("standard-status");
1389 setupFlag (flag,tb,"wip",tr("Status - work in progress","Standardflag"));
1391 flag->load(flagsPath+"flag-cross-red.png");
1392 flag->setGroup("standard-status");
1393 setupFlag (flag,tb,"cross-red",tr("Status - missing, not started","Standardflag"));
1396 flag->load(flagsPath+"flag-stopsign.png");
1397 setupFlag (flag,tb,"stopsign",tr("This won't work!","Standardflag"));
1399 flag->load(flagsPath+"flag-smiley-good.png");
1400 flag->setGroup("standard-smiley");
1401 setupFlag (flag,tb,"smiley-good",tr("Good","Standardflag"));
1403 flag->load(flagsPath+"flag-smiley-sad.png");
1404 flag->setGroup("standard-smiley");
1405 setupFlag (flag,tb,"smiley-sad",tr("Bad","Standardflag"));
1407 flag->load(flagsPath+"flag-smiley-omg.png");
1408 flag->setGroup("standard-smiley");
1409 setupFlag (flag,tb,"smiley-omb",tr("Oh no!","Standardflag"));
1410 // Original omg.png (in KDE emoticons)
1413 flag->load(flagsPath+"flag-kalarm.png");
1414 setupFlag (flag,tb,"clock",tr("Time critical","Standardflag"));
1416 flag->load(flagsPath+"flag-phone.png");
1417 setupFlag (flag,tb,"phone",tr("Call...","Standardflag"));
1419 flag->load(flagsPath+"flag-lamp.png");
1420 setupFlag (flag,tb,"lamp",tr("Idea!","Standardflag"));
1422 flag->load(flagsPath+"flag-arrow-up.png");
1423 flag->setGroup("standard-arrow");
1424 setupFlag (flag,tb,"arrow-up",tr("Important","Standardflag"));
1426 flag->load(flagsPath+"flag-arrow-down.png");
1427 flag->setGroup("standard-arrow");
1428 setupFlag (flag,tb,"arrow-down",tr("Unimportant","Standardflag"));
1430 flag->load(flagsPath+"flag-arrow-2up.png");
1431 flag->setGroup("standard-arrow");
1432 setupFlag (flag,tb,"2arrow-up",tr("Very important!","Standardflag"));
1434 flag->load(flagsPath+"flag-arrow-2down.png");
1435 flag->setGroup("standard-arrow");
1436 setupFlag (flag,tb,"2arrow-down",tr("Very unimportant!","Standardflag"));
1439 flag->load(flagsPath+"flag-thumb-up.png");
1440 flag->setGroup("standard-thumb");
1441 setupFlag (flag,tb,"thumb-up",tr("I like this","Standardflag"));
1443 flag->load(flagsPath+"flag-thumb-down.png");
1444 flag->setGroup("standard-thumb");
1445 setupFlag (flag,tb,"thumb-down",tr("I do not like this","Standardflag"));
1448 flag->load(flagsPath+"flag-rose.png");
1449 setupFlag (flag,tb,"rose",tr("Rose","Standardflag"));
1451 flag->load(flagsPath+"flag-heart.png");
1452 setupFlag (flag,tb,"heart",tr("I just love...","Standardflag"));
1454 flag->load(flagsPath+"flag-present.png");
1455 setupFlag (flag,tb,"present",tr("Surprise!","Standardflag"));
1457 flag->load(flagsPath+"flag-flash.png");
1458 setupFlag (flag,tb,"flash",tr("Dangerous","Standardflag"));
1460 // Original: xsldbg_output.png
1461 flag->load(flagsPath+"flag-info.png");
1462 setupFlag (flag,tb,"info",tr("Info","Standardflag"));
1464 // Original khelpcenter.png
1465 flag->load(flagsPath+"flag-lifebelt.png");
1466 setupFlag (flag,tb,"lifebelt",tr("This will help","Standardflag"));
1469 flag->setVisible(false);
1470 flag->load(flagsPath+"freemind/warning.png");
1471 setupFlag (flag,tb, "freemind-warning",tr("Important","Freemind-Flag"));
1473 for (int i=1; i<8; i++)
1475 flag->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
1476 setupFlag (flag,tb, QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
1479 flag->load(flagsPath+"freemind/back.png");
1480 setupFlag (flag,tb,"freemind-back",tr("Back","Freemind-Flag"));
1482 flag->load(flagsPath+"freemind/forward.png");
1483 setupFlag (flag,tb,"freemind-forward",tr("forward","Freemind-Flag"));
1485 flag->load(flagsPath+"freemind/attach.png");
1486 setupFlag (flag,tb,"freemind-attach",tr("Look here","Freemind-Flag"));
1488 flag->load(flagsPath+"freemind/clanbomber.png");
1489 setupFlag (flag,tb,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
1491 flag->load(flagsPath+"freemind/desktopnew.png");
1492 setupFlag (flag,tb,"freemind-desktopnew",tr("Don't flagrget","Freemind-Flag"));
1494 flag->load(flagsPath+"freemind/flag.png");
1495 setupFlag (flag,tb,"freemind-flag",tr("Flag","Freemind-Flag"));
1498 flag->load(flagsPath+"freemind/gohome.png");
1499 setupFlag (flag,tb,"freemind-gohome",tr("Home","Freemind-Flag"));
1502 flag->load(flagsPath+"freemind/kaddressbook.png");
1503 setupFlag (flag,tb,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
1505 flag->load(flagsPath+"freemind/knotify.png");
1506 setupFlag (flag,tb,"freemind-knotify",tr("Music","Freemind-Flag"));
1508 flag->load(flagsPath+"freemind/korn.png");
1509 setupFlag (flag,tb,"freemind-korn",tr("Mailbox","Freemind-Flag"));
1511 flag->load(flagsPath+"freemind/mail.png");
1512 setupFlag (flag,tb,"freemind-mail",tr("Maix","Freemind-Flag"));
1514 flag->load(flagsPath+"freemind/password.png");
1515 setupFlag (flag,tb,"freemind-password",tr("Password","Freemind-Flag"));
1517 flag->load(flagsPath+"freemind/pencil.png");
1518 setupFlag (flag,tb,"freemind-pencil",tr("To be improved","Freemind-Flag"));
1520 flag->load(flagsPath+"freemind/stop.png");
1521 setupFlag (flag,tb,"freemind-stop",tr("Stop","Freemind-Flag"));
1523 flag->load(flagsPath+"freemind/wizard.png");
1524 setupFlag (flag,tb,"freemind-wizard",tr("Magic","Freemind-Flag"));
1526 flag->load(flagsPath+"freemind/xmag.png");
1527 setupFlag (flag,tb,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
1529 flag->load(flagsPath+"freemind/bell.png");
1530 setupFlag (flag,tb,"freemind-bell",tr("Reminder","Freemind-Flag"));
1532 flag->load(flagsPath+"freemind/bookmark.png");
1533 setupFlag (flag,tb,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
1535 flag->load(flagsPath+"freemind/penguin.png");
1536 setupFlag (flag,tb,"freemind-penguin",tr("Linux","Freemind-Flag"));
1538 flag->load(flagsPath+"freemind/licq.png");
1539 setupFlag (flag,tb,"freemind-licq",tr("Sweet","Freemind-Flag"));
1542 void Main::setupFlag (Flag *flag, QToolBar *tb, const QString &name, const QString &tooltip)
1544 flag->setName(name);
1545 flag->setToolTip (tooltip);
1549 a=new QAction (flag->getPixmap(),name,this);
1552 flag->setAction (a);
1553 a->setVisible (flag->isVisible());
1554 a->setCheckable(true);
1555 a->setObjectName(name);
1556 a->setToolTip(tooltip);
1557 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1558 standardFlagsMaster->addFlag (flag);
1562 systemFlagsMaster->addFlag (flag);
1567 void Main::setupNetworkActions()
1569 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1571 QMenu *netMenu = menuBar()->addMenu( "Network" );
1575 a = new QAction( "Start TCPserver for MapEditor",this);
1576 //a->setStatusTip ( "Set application to open pdf files"));
1577 //a->setShortcut ( Qt::ALT + Qt::Key_T ); //New TCP server
1578 switchboard.addConnection(a,tr("Network shortcuts","Shortcut group"));
1579 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1580 netMenu->addAction (a);
1582 a = new QAction( "Connect MapEditor to server",this);
1583 //a->setStatusTip ( "Set application to open pdf files"));
1584 a->setShortcut ( Qt::ALT + Qt::Key_C ); // Connect to server
1585 switchboard.addConnection(a,tr("Network shortcuts","Shortcut group"));
1586 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1587 netMenu->addAction (a);
1591 void Main::setupSettingsActions()
1593 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1597 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1598 a->setStatusTip ( tr( "Set application to open pdf files"));
1599 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1600 settingsMenu->addAction (a);
1602 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1603 a->setStatusTip( tr( "Set application to open external links"));
1604 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1605 settingsMenu->addAction (a);
1607 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1608 a->setStatusTip( tr( "Set path for macros"));
1609 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1610 settingsMenu->addAction (a);
1612 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1613 a->setStatusTip( tr( "Set number of undo levels"));
1614 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1615 settingsMenu->addAction (a);
1617 settingsMenu->addSeparator();
1619 a = new QAction( tr( "Autosave","Settings action"), this);
1620 a->setStatusTip( tr( "Autosave"));
1621 a->setToggleAction(true);
1622 a->setChecked ( settings.value ("/mainwindow/autosave/use",false).toBool());
1623 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1624 settingsMenu->addAction (a);
1625 actionSettingsAutosaveToggle=a;
1627 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1628 a->setStatusTip( tr( "Autosave time"));
1629 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1630 settingsMenu->addAction (a);
1631 actionSettingsAutosaveTime=a;
1633 a = new QAction( tr( "Write backup file on save","Settings action"), this);
1634 a->setStatusTip( tr( "Write backup file on save"));
1635 a->setToggleAction(true);
1636 a->setChecked ( settings.value ("/mainwindow/writeBackupFile",false).toBool());
1637 connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) );
1638 settingsMenu->addAction (a);
1639 actionSettingsWriteBackupFile=a;
1641 settingsMenu->addSeparator();
1643 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1644 a->setStatusTip( tr( "Edit branch after adding it" ));
1645 a->setToggleAction(true);
1646 a->setChecked ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1647 settingsMenu->addAction (a);
1648 actionSettingsAutoEditNewBranch=a;
1650 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1651 a->setStatusTip( tr( "Select branch after adding it" ));
1652 a->setToggleAction(true);
1653 a->setChecked ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1654 settingsMenu->addAction (a);
1655 actionSettingsAutoSelectNewBranch=a;
1657 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1658 a->setStatusTip( tr( "Select heading before editing" ));
1659 a->setToggleAction(true);
1660 a->setChecked ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1661 settingsMenu->addAction (a);
1662 actionSettingsAutoSelectText=a;
1664 a= new QAction( tr( "Delete key","Settings action" ), this);
1665 a->setStatusTip( tr( "Delete key for deleting branches" ));
1666 a->setToggleAction(true);
1667 a->setChecked ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1668 settingsMenu->addAction (a);
1669 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1670 actionSettingsUseDelKey=a;
1672 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1673 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1674 a->setToggleAction(true);
1675 a->setChecked ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1676 settingsMenu->addAction (a);
1677 actionSettingsUseFlagGroups=a;
1679 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1680 a->setStatusTip( tr( "Use hide flag during exports " ));
1681 a->setToggleAction(true);
1682 a->setChecked ( settings.value ("/export/useHideExport",true).toBool() );
1683 settingsMenu->addAction (a);
1684 actionSettingsUseHideExport=a;
1686 a = new QAction( tr( "Animation","Settings action"), this);
1687 a->setStatusTip( tr( "Animation"));
1688 a->setToggleAction(true);
1689 a->setChecked (settings.value("/animation/use",true).toBool() );
1690 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) );
1691 settingsMenu->addAction (a);
1692 actionSettingsUseAnimation=a;
1696 void Main::setupTestActions()
1698 QMenu *testMenu = menuBar()->addMenu( tr( "Test" ));
1701 a = new QAction( "Test function 1" , this);
1702 a->setStatusTip( "Call test function 1" );
1703 a->setShortcut (Qt::SHIFT + Qt::Key_T); // Test function 1
1704 switchboard.addConnection(a,tr("Test shortcuts","Shortcut group"));
1705 testMenu->addAction (a);
1706 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1708 a = new QAction( "Test function 2" , this);
1709 a->setStatusTip( "Call test function 2" );
1710 a->setShortcut (Qt::ALT + Qt::Key_T); // Test function 2
1711 switchboard.addConnection(a,tr("Test shortcuts","Shortcut group"));
1712 testMenu->addAction (a);
1713 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1715 a = new QAction( "Command" , this);
1716 a->setStatusTip( "Enter command to call in editor" );
1717 switchboard.addConnection(a,tr("Test shortcuts","Shortcut group"));
1718 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1719 testMenu->addAction (a);
1723 void Main::setupHelpActions()
1725 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1728 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1729 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1730 switchboard.addConnection(a,tr("Help shortcuts","Shortcut group"));
1731 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1732 helpMenu->addAction (a);
1734 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1735 a->setStatusTip( tr( "Open VYM example maps " ));
1736 switchboard.addConnection(a,tr("Help shortcuts","Shortcut group"));
1737 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1738 helpMenu->addAction (a);
1740 a = new QAction( tr( "About VYM","Help action" ), this);
1741 a->setStatusTip( tr( "About VYM")+vymName);
1742 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1743 helpMenu->addAction (a);
1745 a = new QAction( tr( "About QT","Help action" ), this);
1746 a->setStatusTip( tr( "Information about QT toolkit" ));
1747 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1748 helpMenu->addAction (a);
1752 void Main::setupContextMenus()
1756 // Context Menu for branch or mapcenter
1757 branchContextMenu =new QMenu (this);
1758 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1759 branchContextMenu->addSeparator();
1762 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1763 branchAddContextMenu->addAction (actionPaste );
1764 branchAddContextMenu->addAction ( actionAddMapCenter );
1765 branchAddContextMenu->addAction ( actionAddBranch );
1766 branchAddContextMenu->addAction ( actionAddBranchBefore );
1767 branchAddContextMenu->addAction ( actionAddBranchAbove);
1768 branchAddContextMenu->addAction ( actionAddBranchBelow );
1769 branchAddContextMenu->addSeparator();
1770 branchAddContextMenu->addAction ( actionImportAdd );
1771 branchAddContextMenu->addAction ( actionImportReplace );
1774 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1775 branchRemoveContextMenu->addAction (actionCut);
1776 branchRemoveContextMenu->addAction ( actionDelete );
1777 branchRemoveContextMenu->addAction ( actionDeleteKeepChildren );
1778 branchRemoveContextMenu->addAction ( actionDeleteChildren );
1781 actionSaveBranch->addTo( branchContextMenu );
1782 actionFileNewCopy->addTo (branchContextMenu );
1783 actionDetach->addTo (branchContextMenu );
1785 branchContextMenu->addSeparator();
1786 branchContextMenu->addAction ( actionLoadImage);
1787 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1788 branchContextMenu->addAction ( actionAddAttribute);
1790 // Submenu for Links (URLs, vymLinks)
1791 branchLinksContextMenu =new QMenu (this);
1793 branchContextMenu->addSeparator();
1794 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1795 branchLinksContextMenu->addAction ( actionOpenURL );
1796 branchLinksContextMenu->addAction ( actionOpenURLTab );
1797 branchLinksContextMenu->addAction ( actionOpenMultipleVisURLTabs );
1798 branchLinksContextMenu->addAction ( actionOpenMultipleURLTabs );
1799 branchLinksContextMenu->addAction ( actionURL );
1800 branchLinksContextMenu->addAction ( actionLocalURL );
1801 branchLinksContextMenu->addAction ( actionHeading2URL );
1802 branchLinksContextMenu->addAction ( actionBugzilla2URL );
1803 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1805 branchLinksContextMenu->addAction ( actionGetBugzillaData );
1806 branchLinksContextMenu->addAction ( actionFATE2URL );
1808 branchLinksContextMenu->addSeparator();
1809 branchLinksContextMenu->addAction ( actionOpenVymLink );
1810 branchLinksContextMenu->addAction ( actionOpenMultipleVymLinks );
1811 branchLinksContextMenu->addAction ( actionVymLink );
1812 branchLinksContextMenu->addAction ( actionDeleteVymLink );
1815 // Context Menu for XLinks in a branch menu
1816 // This will be populated "on demand" in MapEditor::updateActions
1817 branchContextMenu->addSeparator();
1818 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1819 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1822 // Context menu for floatimage
1823 floatimageContextMenu =new QMenu (this);
1824 a= new QAction (tr ("Save image","Context action"),this);
1825 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1826 floatimageContextMenu->addAction (a);
1828 floatimageContextMenu->addSeparator();
1829 actionCopy->addTo( floatimageContextMenu );
1830 actionCut->addTo( floatimageContextMenu );
1832 floatimageContextMenu->addSeparator();
1833 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1836 // Context menu for canvas
1837 canvasContextMenu =new QMenu (this);
1838 actionAddMapCenter->addTo( canvasContextMenu );
1839 actionMapInfo->addTo( canvasContextMenu );
1840 canvasContextMenu->insertSeparator();
1841 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1842 canvasContextMenu->insertSeparator();
1843 actionFormatLinkColorHint->addTo( canvasContextMenu );
1844 actionFormatLinkColor->addTo( canvasContextMenu );
1845 actionFormatSelectionColor->addTo( canvasContextMenu );
1846 actionFormatBackColor->addTo( canvasContextMenu );
1847 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME-4 makes vym too slow: postponed for later version
1849 // Menu for last opened files
1851 for (int i = 0; i < MaxRecentFiles; ++i)
1853 recentFileActions[i] = new QAction(this);
1854 recentFileActions[i]->setVisible(false);
1855 fileLastMapsMenu->addAction(recentFileActions[i]);
1856 connect(recentFileActions[i], SIGNAL(triggered()),
1857 this, SLOT(fileLoadRecent()));
1859 setupRecentMapsMenu();
1862 void Main::setupRecentMapsMenu()
1864 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1866 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1868 for (int i = 0; i < numRecentFiles; ++i) {
1869 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1870 recentFileActions[i]->setText(text);
1871 recentFileActions[i]->setData(files[i]);
1872 recentFileActions[i]->setVisible(true);
1874 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1875 recentFileActions[j]->setVisible(false);
1878 void Main::setupMacros()
1880 for (int i = 0; i <= 11; i++)
1882 macroActions[i] = new QAction(this);
1883 macroActions[i]->setData(i);
1884 addAction (macroActions[i]);
1885 //switchboard.addConnection(macroActions[i],tr("Macro shortcuts","Shortcut group"));
1886 connect(macroActions[i], SIGNAL(triggered()),
1887 this, SLOT(callMacro()));
1889 macroActions[0]->setShortcut ( Qt::Key_F1 );
1890 macroActions[1]->setShortcut ( Qt::Key_F2 );
1891 macroActions[2]->setShortcut ( Qt::Key_F3 );
1892 macroActions[3]->setShortcut ( Qt::Key_F4 );
1893 macroActions[4]->setShortcut ( Qt::Key_F5 );
1894 macroActions[5]->setShortcut ( Qt::Key_F6 );
1895 macroActions[6]->setShortcut ( Qt::Key_F7 );
1896 macroActions[7]->setShortcut ( Qt::Key_F8 );
1897 macroActions[8]->setShortcut ( Qt::Key_F9 );
1898 macroActions[9]->setShortcut ( Qt::Key_F10 );
1899 macroActions[10]->setShortcut ( Qt::Key_F11 );
1900 macroActions[11]->setShortcut ( Qt::Key_F12 );
1903 void Main::hideEvent (QHideEvent * )
1905 if (!textEditor->isMinimized() ) textEditor->hide();
1908 void Main::showEvent (QShowEvent * )
1910 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1914 MapEditor* Main::currentMapEditor() const
1916 if ( tabWidget->currentPage())
1917 return vymViews.at(tabWidget->currentIndex())->getMapEditor();
1921 VymModel* Main::currentModel() const
1923 if ( tabWidget->currentPage())
1924 return vymViews.at(tabWidget->currentIndex())->getModel();
1928 VymModel* Main::getModel(uint id) const //FIXME-2 id not used
1931 if ( tabWidget->currentPage())
1932 return vymViews.at(tabWidget->currentIndex())->getModel();
1937 void Main::editorChanged(QWidget *)
1939 // Unselect all possibly selected objects
1940 // (Important to update note editor)
1942 for (int i=0;i<=tabWidget->count() -1;i++)
1944 m= vymViews.at(i)->getModel();
1945 if (m) m->unselect();
1948 if (m) m->reselect();
1950 // Update actions to in menus and toolbars according to editor
1954 void Main::fileNew()
1956 VymModel *vm=new VymModel;
1958 /////////////////////////////////////
1959 // new ModelTest(vm, this); //FIXME-3
1960 /////////////////////////////////////
1962 VymView *vv=new VymView (vm);
1963 vymViews.append (vv);
1964 tabWidget->addTab (vv,tr("unnamed","MainWindow: name for new and empty file"));
1965 tabWidget->setCurrentIndex (vymViews.count() );
1968 // Create MapCenter for empty map
1972 // For the very first map we do not have flagrows yet...
1976 void Main::fileNewCopy()
1978 QString fn="unnamed";
1979 VymModel *srcModel=currentModel();
1984 VymModel *dstModel=vymViews.last()->getModel();
1985 dstModel->select("mc:");
1986 dstModel->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
1990 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
1992 ErrorCode err=success;
1994 // fn is usually the archive, mapfile the file after uncompressing
1997 // Make fn absolute (needed for unzip)
1998 fn=QDir (fn).absPath();
2004 // Check, if map is already loaded
2006 while (i<=tabWidget->count() -1)
2008 if (vymViews.at(i)->getModel()->getFilePath() == fn)
2010 // Already there, ask for confirmation
2011 QMessageBox mb( vymName,
2012 tr("The map %1\nis already opened."
2013 "Opening the same map in multiple editors may lead \n"
2014 "to confusion when finishing working with vym."
2015 "Do you want to").arg(fn),
2016 QMessageBox::Warning,
2017 QMessageBox::Yes | QMessageBox::Default,
2018 QMessageBox::Cancel | QMessageBox::Escape,
2019 QMessageBox::NoButton);
2020 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
2021 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2024 case QMessageBox::Yes:
2025 // end loop and load anyway
2026 i=tabWidget->count();
2028 case QMessageBox::Cancel:
2038 int tabIndex=tabWidget->currentPageIndex();
2041 if ( !fn.isEmpty() )
2043 vm = currentModel();
2044 // Check first, if mapeditor exists
2045 // If it is not default AND we want a new map,
2046 // create a new mapeditor in a new tab
2047 if ( lmode==NewMap && (!vm || !vm->isDefault() ) )
2050 VymView *vv=new VymView (vm);
2051 vymViews.append (vv);
2052 tabWidget->addTab (vv,fn);
2053 tabIndex=tabWidget->count()-1;
2054 tabWidget->setCurrentPage (tabIndex);
2058 // Check, if file exists (important for creating new files
2059 // from command line
2060 if (!QFile(fn).exists() )
2062 QMessageBox mb( vymName,
2063 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
2064 QMessageBox::Question,
2066 QMessageBox::Cancel | QMessageBox::Default,
2067 QMessageBox::NoButton );
2069 mb.setButtonText( QMessageBox::Yes, tr("Create"));
2070 mb.setButtonText( QMessageBox::No, tr("Cancel"));
2073 case QMessageBox::Yes:
2075 currentMapEditor()->getModel()->setFilePath(fn);
2076 tabWidget->setTabText (tabIndex,
2077 currentMapEditor()->getModel()->getFileName() );
2078 statusBar()->message( "Created " + fn , statusbarTime );
2081 case QMessageBox::Cancel:
2082 // don't create new map
2083 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
2090 //tabWidget->currentPage() won't be NULL here, because of above...
2091 tabWidget->setCurrentIndex (tabIndex);
2092 //FIXME-3 no me anymore... me->viewport()->setFocus();
2096 // Save existing filename in case we import
2097 QString fn_org=vm->getFilePath();
2099 // Finally load map into mapEditor
2100 vm->setFilePath (fn);
2101 err=vm->load(fn,lmode,ftype);
2103 // Restore old (maybe empty) filepath, if this is an import
2105 vm->setFilePath (fn_org);
2108 // Finally check for errors and go home
2111 if (lmode==NewMap) fileCloseMap();
2112 statusBar()->message( "Could not load " + fn, statusbarTime );
2117 vm->setFilePath (fn);
2118 tabWidget->setTabText (tabIndex, vm->getFileName());
2119 if (!isInTmpDir (fn))
2121 // Only append to lastMaps if not loaded from a tmpDir
2122 // e.g. imported bookmarks are in a tmpDir
2123 addRecentMap(vm->getFilePath() );
2125 actionFilePrint->setEnabled (true);
2127 statusBar()->message( "Loaded " + fn, statusbarTime );
2134 void Main::fileLoad(const LoadMode &lmode)
2136 QStringList filters;
2137 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
2138 QFileDialog *fd=new QFileDialog( this);
2139 fd->setDir (lastFileDir);
2140 fd->setFileMode (QFileDialog::ExistingFiles);
2141 fd->setFilters (filters);
2145 fd->setCaption(vymName+ " - " +tr("Load vym map"));
2148 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
2151 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
2157 if ( fd->exec() == QDialog::Accepted )
2159 lastFileDir=fd->directory().path();
2160 QStringList flist = fd->selectedFiles();
2161 QStringList::Iterator it = flist.begin();
2163 progressCounter=flist.count();
2164 progressCounterTotal=flist.count();
2165 while( it != flist.end() )
2168 fileLoad(*it, lmode);
2175 void Main::fileLoad()
2180 void Main::fileLoadRecent()
2182 QAction *action = qobject_cast<QAction *>(sender());
2184 fileLoad (action->data().toString(), NewMap);
2187 void Main::addRecentMap (const QString &fileName)
2190 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
2191 files.removeAll(fileName);
2192 files.prepend(fileName);
2193 while (files.size() > MaxRecentFiles)
2196 settings.setValue("/mainwindow/recentFileList", files);
2198 setupRecentMapsMenu();
2201 void Main::fileSave(VymModel *m, const SaveMode &savemode)
2205 if ( m->getFilePath().isEmpty() )
2207 // We have no filepath yet,
2208 // call fileSaveAs() now, this will call fileSave()
2210 // First switch to editor
2211 //FIXME-3 needed??? tabWidget->setCurrentWidget (m->getMapEditor());
2212 fileSaveAs(savemode);
2215 if (m->save (savemode)==success)
2217 statusBar()->message(
2218 tr("Saved %1").arg(m->getFilePath()),
2220 addRecentMap (m->getFilePath() );
2222 statusBar()->message(
2223 tr("Couldn't save ").arg(m->getFilePath()),
2227 void Main::fileSave()
2229 fileSave (currentModel(), CompleteMap);
2232 void Main::fileSave(VymModel *m)
2234 fileSave (m,CompleteMap);
2237 void Main::fileSaveAs(const SaveMode& savemode)
2241 if (currentMapEditor())
2243 if (savemode==CompleteMap)
2244 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2246 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2247 if ( !fn.isEmpty() )
2249 // Check for existing file
2250 if (QFile (fn).exists())
2252 QMessageBox mb( vymName,
2253 tr("The file %1\nexists already. Do you want to").arg(fn),
2254 QMessageBox::Warning,
2255 QMessageBox::Yes | QMessageBox::Default,
2256 QMessageBox::Cancel | QMessageBox::Escape,
2257 QMessageBox::NoButton);
2258 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2259 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2262 case QMessageBox::Yes:
2265 case QMessageBox::Cancel:
2272 // New file, add extension to filename, if missing
2273 // This is always .vym or .vyp, depending on savemode
2274 if (savemode==CompleteMap)
2276 if (!fn.contains (".vym") && !fn.contains (".xml"))
2280 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2289 VymModel *m=currentModel();
2291 fileSave(m, savemode);
2293 // Set name of tab, assuming current tab is the one we just saved
2294 if (savemode==CompleteMap)
2295 tabWidget->setTabText (tabWidget->currentIndex(), m->getFileName() );
2301 void Main::fileSaveAs()
2303 fileSaveAs (CompleteMap);
2306 void Main::fileImportKDE3Bookmarks()
2308 ImportKDE3Bookmarks im;
2310 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2311 currentMapEditor()->getModel()->setFilePath ("");
2314 void Main::fileImportKDE4Bookmarks()
2316 ImportKDE4Bookmarks im;
2318 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2319 currentMapEditor()->getModel()->setFilePath ("");
2322 void Main::fileImportFirefoxBookmarks()
2324 Q3FileDialog *fd=new Q3FileDialog( this);
2325 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2326 fd->setMode (Q3FileDialog::ExistingFiles);
2327 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2328 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2331 if ( fd->exec() == QDialog::Accepted )
2333 ImportFirefoxBookmarks im;
2334 QStringList flist = fd->selectedFiles();
2335 QStringList::Iterator it = flist.begin();
2336 while( it != flist.end() )
2339 if (im.transform() &&
2340 aborted!=fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2341 currentMapEditor() )
2342 currentMapEditor()->getModel()->setFilePath ("");
2349 void Main::fileImportFreemind()
2351 QStringList filters;
2352 filters <<"Freemind map (*.mm)"<<"All files (*)";
2353 QFileDialog *fd=new QFileDialog( this);
2354 fd->setDir (lastFileDir);
2355 fd->setFileMode (QFileDialog::ExistingFiles);
2356 fd->setFilters (filters);
2357 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2361 if ( fd->exec() == QDialog::Accepted )
2363 lastFileDir=fd->directory().path();
2364 QStringList flist = fd->selectedFiles();
2365 QStringList::Iterator it = flist.begin();
2366 while( it != flist.end() )
2369 if ( fileLoad (fn,NewMap, FreemindMap) )
2371 currentMapEditor()->getModel()->setFilePath ("");
2380 void Main::fileImportMM()
2384 Q3FileDialog *fd=new Q3FileDialog( this);
2385 fd->setDir (lastFileDir);
2386 fd->setMode (Q3FileDialog::ExistingFiles);
2387 fd->addFilter ("Mind Manager (*.mmap)");
2388 fd->setCaption(tr("Import")+" "+"Mind Manager");
2391 if ( fd->exec() == QDialog::Accepted )
2393 lastFileDir=fd->dirPath();
2394 QStringList flist = fd->selectedFiles();
2395 QStringList::Iterator it = flist.begin();
2396 while( it != flist.end() )
2399 if (im.transform() &&
2400 success==fileLoad (im.getTransformedFile(),NewMap) &&
2401 currentMapEditor() )
2402 currentMapEditor()->getModel()->setFilePath ("");
2409 void Main::fileImportDir()
2411 VymModel *m=currentModel();
2412 if (m) m->importDir();
2415 void Main::fileExportXML()
2417 VymModel *m=currentModel();
2418 if (m) m->exportXML();
2421 void Main::fileExportHTML()
2423 VymModel *m=currentModel();
2424 if (m) m->exportHTML();
2428 void Main::fileExportXHTML()
2430 VymModel *m=currentModel();
2431 if (m) m->exportXHTML();
2434 void Main::fileExportImage()
2436 VymModel *m=currentModel();
2437 if (m) m->exportImage();
2440 void Main::fileExportAO()
2442 VymModel *m=currentModel();
2443 if (m) m->exportAO();
2446 void Main::fileExportASCII()
2448 VymModel *m=currentModel();
2449 if (m) m->exportASCII();
2452 void Main::fileExportCSV() //FIXME-3 not scriptable yet
2454 VymModel *m=currentModel();
2459 ex.addFilter ("CSV (*.csv)");
2460 ex.setDir(lastImageDir);
2461 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2462 if (ex.execDialog() )
2464 m->setExportMode(true);
2466 m->setExportMode(false);
2471 void Main::fileExportLaTeX() //FIXME-3 not scriptable yet
2473 VymModel *m=currentModel();
2478 ex.addFilter ("Tex (*.tex)");
2479 ex.setDir(lastImageDir);
2480 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2481 if (ex.execDialog() )
2483 m->setExportMode(true);
2485 m->setExportMode(false);
2490 void Main::fileExportKDE3Bookmarks() //FIXME-3 not scriptable yet
2492 ExportKDE3Bookmarks ex;
2493 VymModel *m=currentModel();
2501 void Main::fileExportKDE4Bookmarks() //FIXME-3 not scriptable yet
2503 ExportKDE4Bookmarks ex;
2504 VymModel *m=currentModel();
2512 void Main::fileExportTaskjuggler() //FIXME-3 not scriptable yet
2514 ExportTaskjuggler ex;
2515 VymModel *m=currentModel();
2519 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2520 ex.setDir(lastImageDir);
2521 ex.addFilter ("Taskjuggler (*.tjp)");
2522 if (ex.execDialog() )
2524 m->setExportMode(true);
2526 m->setExportMode(false);
2531 void Main::fileExportOOPresentation() //FIXME-3 not scriptable yet
2533 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2534 // TODO add preview in dialog
2535 //ImagePreview *p =new ImagePreview (fd);
2536 //fd->setContentsPreviewEnabled( TRUE );
2537 //fd->setContentsPreview( p, p );
2538 //fd->setPreviewMode( QFileDialog::Contents );
2539 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2540 fd->setDir (QDir().current());
2541 if (fd->foundConfig())
2545 if ( fd->exec() == QDialog::Accepted )
2547 QString fn=fd->selectedFile();
2548 if (!fn.contains (".odp"))
2551 //lastImageDir=fn.left(fn.findRev ("/"));
2552 VymModel *m=currentModel();
2553 if (m) m->exportOOPresentation(fn,fd->selectedConfig());
2557 QMessageBox::warning(0,
2559 tr("Couldn't find configuration for export to Open Office\n"));
2563 void Main::fileCloseMap()
2565 VymModel *m=currentModel();
2568 if (m->hasChanged())
2570 QMessageBox mb( vymName,
2571 tr("The map %1 has been modified but not saved yet. Do you want to").arg(m->getFileName()),
2572 QMessageBox::Warning,
2573 QMessageBox::Yes | QMessageBox::Default,
2575 QMessageBox::Cancel | QMessageBox::Escape );
2576 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2577 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2580 case QMessageBox::Yes:
2582 fileSave(m, CompleteMap);
2584 case QMessageBox::No:
2585 // close without saving
2587 case QMessageBox::Cancel:
2592 // And here comes the segfault, because removeTab triggers
2593 // FIXME-3 currentChanged->Main::editorChanged -> updateActions and VM is not NULL yet...
2594 vymViews.removeAt (tabWidget->currentIndex() );
2595 tabWidget->removeTab (tabWidget->currentIndex() );
2597 // Remove mapEditor/model FIXME-3 Huh? seems to work now...
2598 // Better would be delete (me), but then we could have a Qt error:
2599 // "QObject: Do not delete object, 'MapEditor', during its event handler!"
2600 // So we only remove data now and call deconstructor when vym closes later
2601 // this needs to be moved to vymview... me->clear();
2602 // some model->clear is needed to free up memory ...
2604 delete (m->getMapEditor());
2611 void Main::filePrint()
2613 if (currentMapEditor())
2614 currentMapEditor()->print();
2617 void Main::fileExitVYM()
2619 // Check if one or more editors have changed
2621 for (i=0;i<=vymViews.count() -1;i++)
2623 // If something changed, ask what to do
2624 if (vymViews.at(i)->getModel()->hasChanged())
2626 tabWidget->setCurrentPage(i);
2627 QMessageBox mb( vymName,
2628 tr("This map is not saved yet. Do you want to"),
2629 QMessageBox::Warning,
2630 QMessageBox::Yes | QMessageBox::Default,
2632 QMessageBox::Cancel | QMessageBox::Escape );
2633 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2634 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2637 mb.setActiveWindow();
2638 switch( mb.exec() ) {
2639 case QMessageBox::Yes:
2640 // save (the changed editors) and exit
2641 fileSave(currentModel(), CompleteMap);
2643 case QMessageBox::No:
2644 // exit without saving
2646 case QMessageBox::Cancel:
2647 // don't save and don't exit
2651 } // loop over all MEs
2655 void Main::editUndo()
2657 VymModel *m=currentModel();
2661 void Main::editRedo()
2663 VymModel *m=currentModel();
2667 void Main::gotoHistoryStep (int i)
2669 VymModel *m=currentModel();
2670 if (m) m->gotoHistoryStep(i);
2673 void Main::editCopy()
2675 VymModel *m=currentModel();
2679 void Main::editPaste()
2681 VymModel *m=currentModel();
2685 void Main::editCut()
2687 VymModel *m=currentModel();
2691 void Main::editOpenFindWidget()
2693 if (!findWidget->isVisible())
2696 findWidget->setFocus();
2697 } else if (!findResultWidget->parentWidget()->isVisible())
2698 findResultWidget->parentWidget()->show();
2702 findResultWidget->parentWidget()->hide();
2706 void Main::editHideFindWidget()
2708 // findWidget hides itself, but we want
2709 // to have focus back at mapEditor usually
2710 MapEditor *me=currentMapEditor();
2711 if (me) me->setFocus();
2714 void Main::editFindNext(QString s)
2716 Qt::CaseSensitivity cs=Qt::CaseInsensitive;
2718 VymModel *m=currentModel();
2721 m->findAll (findResultWidget->getResultModel(),s,cs);
2723 BranchItem *bi=m->findText(s, cs,cursor);
2726 findWidget->setStatus (FindWidget::Success);
2729 findWidget->setStatus (FindWidget::Failed);
2733 void Main::editFindDuplicateURLs() //FIXME-4 feature: use FindResultWidget for display
2735 VymModel *m=currentModel();
2736 if (m) m->findDuplicateURLs();
2739 void Main::openTabs(QStringList urls)
2741 if (!urls.isEmpty())
2745 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2746 //qDebug ()<<"Services: "<<QDBusConnection::sessionBus().interface()->registeredServiceNames().value();
2747 if (*browserPID==0 ||
2748 (browser.contains("konqueror") &&
2749 !QDBusConnection::sessionBus().interface()->registeredServiceNames().value().contains (QString("org.kde.konqueror-%1").arg(*browserPID)))
2752 // Start a new browser, if there is not one running already or
2753 // if a previously started konqueror is gone.
2754 if (debug) cout <<"Main::openTabs no konqueror-"<<*browserPID<<" found\n";
2755 QString u=urls.takeFirst();
2757 QString workDir=QDir::currentDirPath();
2758 if (!QProcess::startDetached(browser,args,workDir,browserPID))
2760 // try to set path to browser
2761 QMessageBox::warning(0,
2763 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2764 tr("Please use Settings->")+tr("Set application to open an URL"));
2767 if (debug) cout << "Main::openTabs Started konqueror-"<<*browserPID<<endl;
2768 #if defined(Q_OS_WIN32)
2769 // There's no sleep in VCEE, replace it with Qt's QThread::wait().
2770 this->thread()->wait(3000);
2772 sleep (3); //FIXME-3 needed?
2776 if (browser.contains("konqueror"))
2778 for (int i=0; i<urls.size(); i++)
2781 // Try to open new tab in existing konqueror started previously by vym
2785 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2786 "konqueror-mainwindow#1"<<
2790 args<< QString("org.kde.konqueror-%1").arg(*browserPID)<<
2791 "/konqueror/MainWindow_1"<<
2795 if (debug) cout << "MainWindow::openURLs args="<<args.join(" ").toStdString()<<endl;
2796 if (!QProcess::startDetached ("qdbus",args))
2800 QMessageBox::warning(0,
2802 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2804 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2806 for (int i=0; i<urls.size(); i++)
2808 // Try to open new tab in firefox
2809 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2810 if (!QProcess::startDetached (browser,args))
2814 QMessageBox::warning(0,
2816 tr("Couldn't start %1 to open a new tab").arg(browser));
2819 QMessageBox::warning(0,
2821 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2825 void Main::editOpenURL()
2828 VymModel *m=currentModel();
2831 QString url=m->getURL();
2833 if (url=="") return;
2834 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2836 QString workDir=QDir::currentDirPath();
2837 if (!procBrowser->startDetached(browser,args))
2839 // try to set path to browser
2840 QMessageBox::warning(0,
2842 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2843 tr("Please use Settings->")+tr("Set application to open an URL"));
2848 void Main::editOpenURLTab()
2850 VymModel *m=currentModel();
2854 urls.append(m->getURL());
2859 void Main::editOpenMultipleVisURLTabs(bool ignoreScrolled)
2861 VymModel *m=currentModel();
2865 urls=m->getURLs(ignoreScrolled);
2870 void Main::editOpenMultipleURLTabs()
2872 editOpenMultipleVisURLTabs (false);
2876 void Main::editURL()
2878 VymModel *m=currentModel();
2879 if (m) m->editURL();
2882 void Main::editLocalURL()
2884 VymModel *m=currentModel();
2885 if (m) m->editLocalURL();
2888 void Main::editHeading2URL()
2890 VymModel *m=currentModel();
2891 if (m) m->editHeading2URL();
2894 void Main::editBugzilla2URL()
2896 VymModel *m=currentModel();
2897 if (m) m->editBugzilla2URL();
2900 void Main::getBugzillaData()
2902 VymModel *m=currentModel();
2904 QProgressDialog progress ("Doing stuff","cancl",0,10,this);
2905 progress.setWindowModality(Qt::WindowModal);
2906 //progress.setCancelButton (NULL);
2908 progress.setMinimumDuration (0);
2909 progress.setValue (1);
2910 progress.setValue (5);
2914 QProgressBar *pb=new QProgressBar;
2920 if (m) m->getBugzillaData();
2923 void Main::editFATE2URL()
2925 VymModel *m=currentModel();
2926 if (m) m->editFATE2URL();
2929 void Main::editHeadingFinished(VymModel *m)
2933 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2934 !prevSelection.isEmpty())
2935 m->select(prevSelection);
2940 void Main::openVymLinks(const QStringList &vl)
2942 for (int j=0; j<vl.size(); j++)
2944 // compare path with already loaded maps
2947 for (i=0;i<=vymViews.count() -1;i++)
2949 if (vl.at(j)==vymViews.at(i)->getModel()->getFilePath() )
2958 if (!QFile(vl.at(j)).exists() )
2959 QMessageBox::critical( 0, tr( "Critical Error" ),
2960 tr("Couldn't open map %1").arg(vl.at(j)));
2963 fileLoad (vl.at(j), NewMap);
2964 tabWidget->setCurrentIndex (tabWidget->count()-1);
2967 // Go to tab containing the map
2968 tabWidget->setCurrentIndex (index);
2972 void Main::editOpenVymLink()
2974 VymModel *m=currentModel();
2978 vl.append(m->getVymLink());
2983 void Main::editOpenMultipleVymLinks()
2985 QString currentVymLink;
2986 VymModel *m=currentModel();
2989 QStringList vl=m->getVymLinks();
2994 void Main::editVymLink()
2996 VymModel *m=currentModel();
3001 void Main::editDeleteVymLink()
3003 VymModel *m=currentModel();
3004 if (m) m->deleteVymLink();
3007 void Main::editToggleHideExport()
3009 VymModel *m=currentModel();
3010 if (m) m->toggleHideExport();
3013 void Main::editAddTimestamp()
3015 VymModel *m=currentModel();
3016 if (m) m->addTimestamp();
3019 void Main::editMapInfo()
3021 VymModel *m=currentModel();
3024 ExtraInfoDialog dia;
3025 dia.setMapName (m->getFileName() );
3026 dia.setAuthor (m->getAuthor() );
3027 dia.setComment(m->getComment() );
3031 stats+=tr("%1 items on map\n","Info about map").arg (m->getScene()->items().size(),6);
3037 BranchItem *cur=NULL;
3038 BranchItem *prev=NULL;
3039 m->nextBranch(cur,prev);
3042 if (!cur->getNote().isEmpty() ) n++;
3043 f+= cur->imageCount();
3045 xl+=cur->xlinkCount();
3046 m->nextBranch(cur,prev);
3049 stats+=QString ("%1 xLinks \n").arg (xl,6);
3050 stats+=QString ("%1 notes\n").arg (n,6);
3051 stats+=QString ("%1 images\n").arg (f,6);
3052 stats+=QString ("%1 branches\n").arg (m->branchCount(),6);
3053 dia.setStats (stats);
3055 // Finally show dialog
3056 if (dia.exec() == QDialog::Accepted)
3058 m->setAuthor (dia.getAuthor() );
3059 m->setComment (dia.getComment() );
3063 void Main::editMoveUp()
3065 VymModel *m=currentModel();
3069 void Main::editMoveDown()
3071 VymModel *m=currentModel();
3072 if (m) m->moveDown();
3075 void Main::editDetach()
3077 VymModel *m=currentModel();
3081 void Main::editSortChildren()
3083 VymModel *m=currentModel();
3084 if (m) m->sortChildren(false);
3087 void Main::editSortBackChildren()
3089 VymModel *m=currentModel();
3090 if (m) m->sortChildren(true);
3093 void Main::editToggleScroll()
3095 VymModel *m=currentModel();
3096 if (m) m->toggleScroll();
3099 void Main::editExpandAll()
3101 VymModel *m=currentModel();
3102 if (m) m->emitExpandAll();
3105 void Main::editExpandOneLevel()
3107 VymModel *m=currentModel();
3108 if (m) m->emitExpandOneLevel();
3111 void Main::editCollapseOneLevel()
3113 VymModel *m=currentModel();
3114 if (m) m->emitCollapseOneLevel();
3117 void Main::editUnscrollChildren()
3119 VymModel *m=currentModel();
3120 if (m) m->unscrollChildren();
3123 void Main::editAddAttribute()
3125 VymModel *m=currentModel();
3133 void Main::editAddMapCenter()
3135 VymModel *m=currentModel();
3136 if (m) m->addMapCenter ();
3139 void Main::editNewBranch()
3141 VymModel *m=currentModel();
3144 BranchItem *bi=m->addNewBranch();
3147 if (actionSettingsAutoEditNewBranch->isOn()
3148 && !actionSettingsAutoSelectNewBranch->isOn() )
3149 prevSelection=m->getSelectString();
3151 prevSelection=QString();
3153 if (actionSettingsAutoSelectNewBranch->isOn()
3154 || actionSettingsAutoEditNewBranch->isOn())
3157 if (actionSettingsAutoEditNewBranch->isOn())
3158 currentMapEditor()->editHeading();
3163 void Main::editNewBranchBefore()
3165 VymModel *m=currentModel();
3168 BranchItem *bi=m->addNewBranchBefore();
3175 if (actionSettingsAutoEditNewBranch->isOn())
3177 if (!actionSettingsAutoSelectNewBranch->isOn())
3178 prevSelection=m->getSelectString(bi);
3179 currentMapEditor()->editHeading();
3184 void Main::editNewBranchAbove()
3186 VymModel *m=currentModel();
3189 BranchItem *bi=m->addNewBranch (-1);
3197 if (actionSettingsAutoEditNewBranch->isOn())
3199 if (!actionSettingsAutoSelectNewBranch->isOn())
3200 prevSelection=m->getSelectString (bi);
3201 currentMapEditor()->editHeading();
3206 void Main::editNewBranchBelow()
3208 VymModel *m=currentModel();
3211 BranchItem *bi=m->addNewBranch (1);
3218 if (actionSettingsAutoEditNewBranch->isOn())
3220 if (!actionSettingsAutoSelectNewBranch->isOn())
3221 prevSelection=m->getSelectString(bi);
3222 currentMapEditor()->editHeading();
3227 void Main::editImportAdd()
3229 fileLoad (ImportAdd);
3232 void Main::editImportReplace()
3234 fileLoad (ImportReplace);
3237 void Main::editSaveBranch()
3239 fileSaveAs (PartOfMap);
3242 void Main::editDeleteKeepChildren()
3244 VymModel *m=currentModel();
3245 if (m) m->deleteKeepChildren();
3248 void Main::editDeleteChildren()
3250 VymModel *m=currentModel();
3251 if (m) m->deleteChildren();
3254 void Main::editDeleteSelection()
3256 VymModel *m=currentModel();
3257 if (m && actionSettingsUseDelKey->isOn())
3258 m->deleteSelection();
3261 void Main::editLoadImage()
3263 VymModel *m=currentModel();
3264 if (m) m->loadFloatImage();
3267 void Main::editSaveImage()
3269 VymModel *m=currentModel();
3270 if (m) m->saveFloatImage();
3273 void Main::editEditXLink(QAction *a)
3275 VymModel *m=currentModel();
3277 m->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3280 void Main::formatSelectColor()
3282 QColor col = QColorDialog::getColor((currentColor ), this );
3283 if ( !col.isValid() ) return;
3284 colorChanged( col );
3287 void Main::formatPickColor()
3289 VymModel *m=currentModel();
3291 colorChanged( m->getCurrentHeadingColor() );
3294 void Main::colorChanged(QColor c)
3296 QPixmap pix( 16, 16 );
3298 actionFormatColor->setIconSet( pix );
3302 void Main::formatColorBranch()
3304 VymModel *m=currentModel();
3305 if (m) m->colorBranch(currentColor);
3308 void Main::formatColorSubtree()
3310 VymModel *m=currentModel();
3311 if (m) m->colorSubtree (currentColor);
3314 void Main::formatLinkStyleLine()
3316 VymModel *m=currentModel();
3319 m->setMapLinkStyle("StyleLine");
3320 actionFormatLinkStyleLine->setChecked(true);
3324 void Main::formatLinkStyleParabel()
3326 VymModel *m=currentModel();
3329 m->setMapLinkStyle("StyleParabel");
3330 actionFormatLinkStyleParabel->setChecked(true);
3334 void Main::formatLinkStylePolyLine()
3336 VymModel *m=currentModel();
3339 m->setMapLinkStyle("StylePolyLine");
3340 actionFormatLinkStylePolyLine->setChecked(true);
3344 void Main::formatLinkStylePolyParabel()
3346 VymModel *m=currentModel();
3349 m->setMapLinkStyle("StylePolyParabel");
3350 actionFormatLinkStylePolyParabel->setChecked(true);
3354 void Main::formatSelectBackColor()
3356 VymModel *m=currentModel();
3357 if (m) m->selectMapBackgroundColor();
3360 void Main::formatSelectBackImage()
3362 VymModel *m=currentModel();
3364 m->selectMapBackgroundImage();
3367 void Main::formatSelectLinkColor()
3369 VymModel *m=currentModel();
3372 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3373 m->setMapDefLinkColor( col );
3377 void Main::formatSelectSelectionColor()
3379 VymModel *m=currentModel();
3382 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3383 m->setSelectionColor (col);
3388 void Main::formatToggleLinkColorHint()
3390 VymModel *m=currentModel();
3391 if (m) m->toggleMapLinkColorHint();
3395 void Main::formatHideLinkUnselected() //FIXME-3 get rid of this with imagepropertydialog
3397 VymModel *m=currentModel();
3399 m->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3402 void Main::viewZoomReset()
3404 MapEditor *me=currentMapEditor();
3405 if (me) me->setZoomFactorTarget (1);
3408 void Main::viewZoomIn()
3410 MapEditor *me=currentMapEditor();
3411 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*1.25);
3414 void Main::viewZoomOut()
3416 MapEditor *me=currentMapEditor();
3417 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*0.75);
3420 void Main::viewCenter()
3422 VymModel *m=currentModel();
3423 if (m) m->emitShowSelection();
3426 void Main::networkStartServer()
3428 VymModel *m=currentModel();
3429 if (m) m->newServer();
3432 void Main::networkConnect()
3434 VymModel *m=currentModel();
3435 if (m) m->connectToServer();
3438 bool Main::settingsPDF()
3440 // Default browser is set in constructor
3442 QString text = QInputDialog::getText(
3443 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3444 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3446 settings.setValue ("/mainwindow/readerPDF",text);
3451 bool Main::settingsURL()
3453 // Default browser is set in constructor
3455 QString text = QInputDialog::getText(
3456 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3457 settings.value("/mainwindow/readerURL").toString()
3460 settings.setValue ("/mainwindow/readerURL",text);
3464 void Main::settingsMacroDir()
3466 QDir defdir(vymBaseDir.path() + "/macros");
3467 if (!defdir.exists())
3469 QDir dir=QFileDialog::getExistingDirectory (
3471 tr ("Directory with vym macros:"),
3472 settings.value ("/macros/macroDir",defdir.path()).toString()
3475 settings.setValue ("/macros/macroDir",dir.absolutePath());
3478 void Main::settingsUndoLevels()
3481 int i = QInputDialog::getInteger(
3483 tr("QInputDialog::getInteger()"),
3484 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3487 settings.setValue ("/mapeditor/stepsTotal",i);
3488 QMessageBox::information( this, tr( "VYM -Information:" ),
3489 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3493 void Main::settingsAutosaveToggle()
3495 settings.setValue ("/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
3498 void Main::settingsAutosaveTime()
3501 int i = QInputDialog::getInteger(
3503 tr("QInputDialog::getInteger()"),
3504 tr("Number of seconds before autosave:"), settings.value("/mainwindow/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3506 settings.setValue ("/mainwindow/autosave/ms",i * 1000);
3509 void Main::settingsWriteBackupFileToggle()
3511 settings.setValue ("/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
3514 void Main::settingsToggleAnimation()
3516 settings.setValue ("/animation/use",actionSettingsUseAnimation->isOn() );
3519 void Main::settingsToggleDelKey()
3521 if (actionSettingsUseDelKey->isOn())
3523 actionDelete->setAccel (QKeySequence (Qt::Key_Delete));
3526 actionDelete->setAccel (QKeySequence (""));
3530 void Main::windowToggleNoteEditor()
3532 if (textEditor->isVisible() )
3533 windowHideNoteEditor();
3535 windowShowNoteEditor();
3538 void Main::windowToggleTreeEditor()
3540 if ( tabWidget->currentPage())
3541 vymViews.at(tabWidget->currentIndex())->toggleTreeEditor();
3544 void Main::windowToggleHistory()
3546 if (historyWindow->isVisible())
3547 historyWindow->hide();
3549 historyWindow->show();
3553 void Main::windowToggleProperty()
3555 if (branchPropertyWindow->isVisible())
3556 branchPropertyWindow->hide();
3558 branchPropertyWindow->show();
3559 branchPropertyWindow->setModel (currentModel() );
3562 void Main::windowToggleAntiAlias()
3564 bool b=actionViewToggleAntiAlias->isOn();
3566 for (int i=0;i<vymViews.count();i++)
3568 me=vymViews.at(i)->getMapEditor();
3569 if (me) me->setAntiAlias(b);
3574 bool Main::isAliased()
3576 return actionViewToggleAntiAlias->isOn();
3579 bool Main::hasSmoothPixmapTransform()
3581 return actionViewToggleSmoothPixmapTransform->isOn();
3584 void Main::windowToggleSmoothPixmap()
3586 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3588 for (int i=0;i<vymViews.count();i++)
3591 me=vymViews.at(i)->getMapEditor();
3592 if (me) me->setSmoothPixmap(b);
3596 void Main::updateHistory(SimpleSettings &undoSet)
3598 historyWindow->update (undoSet);
3601 void Main::updateNoteFlag()
3603 // this slot is connected to TextEditor::textHasChanged()
3604 VymModel *m=currentModel();
3605 if (m) m->updateNoteFlag();
3608 void Main::updateNoteEditor(QModelIndex index )
3610 TreeItem *ti=((VymModel*) QObject::sender())->getItem(index);
3612 cout << "Main::updateNoteEditor model="<<sender();
3613 cout << " item="<<ti->getHeadingStd()<<" ("<<ti<<")"<<endl;
3615 textEditor->setNote (ti->getNoteObj() );
3618 void Main::changeSelection (VymModel *model, const QItemSelection &newsel, const QItemSelection &oldsel)
3620 branchPropertyWindow->setModel (model ); //FIXME-3 this used to be called from BranchObj::select(). Maybe use signal now...
3622 if (model && model==currentModel() )
3626 if (!oldsel.indexes().isEmpty() )
3628 ti=model->getItem(oldsel.indexes().first());
3630 // Don't update note if both treeItem and textEditor are empty
3631 //if (! (ti->hasEmptyNote() && textEditor->isEmpty() ))
3632 // ti->setNoteObj (textEditor->getNoteObj(),false );
3634 if (!newsel.indexes().isEmpty() )
3636 ti=model->getItem(newsel.indexes().first());
3637 if (!ti->hasEmptyNote() )
3638 textEditor->setNote(ti->getNoteObj() );
3640 textEditor->setNote(NoteObj() ); //FIXME-4 maybe add a clear() to TE
3642 // Show URL and link in statusbar
3644 QString s=ti->getURL();
3645 if (!s.isEmpty() ) status+="URL: "+s+" ";
3647 if (!s.isEmpty() ) status+="Link: "+s;
3648 if (!status.isEmpty() ) statusMessage (status);
3651 textEditor->setInactive();
3657 void Main::updateActions()
3659 // updateActions is also called when satellites are closed //FIXME-2 doesn't update immediatly, e.g. historyWindow is still visible, when "close" is pressed
3660 actionViewToggleNoteEditor->setChecked (textEditor->isVisible());
3661 actionViewToggleHistoryWindow->setChecked (historyWindow->isVisible());
3662 actionViewTogglePropertyWindow->setChecked (branchPropertyWindow->isVisible());
3664 VymModel *m =currentModel();
3668 actionFilePrint->setEnabled (true);
3670 // Link style in context menu
3671 switch (m->getMapLinkStyle())
3673 case LinkableMapObj::Line:
3674 actionFormatLinkStyleLine->setChecked(true);
3676 case LinkableMapObj::Parabel:
3677 actionFormatLinkStyleParabel->setChecked(true);
3679 case LinkableMapObj::PolyLine:
3680 actionFormatLinkStylePolyLine->setChecked(true);
3682 case LinkableMapObj::PolyParabel:
3683 actionFormatLinkStylePolyParabel->setChecked(true);
3690 QPixmap pix( 16, 16 );
3691 pix.fill( m->getMapBackgroundColor() );
3692 actionFormatBackColor->setIconSet( pix );
3693 pix.fill( m->getSelectionColor() );
3694 actionFormatSelectionColor->setIconSet( pix );
3695 pix.fill( m->getMapDefLinkColor() );
3696 actionFormatLinkColor->setIconSet( pix );
3699 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName()));
3702 // Expanding/collapsing
3703 actionExpandAll->setEnabled (true);
3704 actionExpandOneLevel->setEnabled (true);
3705 actionCollapseOneLevel->setEnabled (true);
3709 actionFilePrint->setEnabled (false);
3711 // Expanding/collapsing
3712 actionExpandAll->setEnabled (false);
3713 actionExpandOneLevel->setEnabled (false);
3714 actionCollapseOneLevel->setEnabled (false);
3717 if (m && m->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3718 actionFormatLinkColorHint->setChecked(true);
3720 actionFormatLinkColorHint->setChecked(false);
3723 if (m && m->hasChanged() )
3724 actionFileSave->setEnabled( true);
3726 actionFileSave->setEnabled( false);
3727 if (m && m->isUndoAvailable())
3728 actionUndo->setEnabled( true);
3730 actionUndo->setEnabled( false);
3732 if (m && m->isRedoAvailable())
3733 actionRedo->setEnabled( true);
3735 actionRedo->setEnabled( false);
3739 TreeItem *selti=m->getSelectedItem();
3740 BranchItem *selbi=m->getSelectedBranch();
3743 if (selbi || selti->getType()==TreeItem::Image)
3745 actionFormatHideLinkUnselected->setChecked (((MapItem*)selti)->getHideLinkUnselected());
3746 actionFormatHideLinkUnselected->setEnabled (true);
3751 // Take care of xlinks
3752 branchXLinksContextMenuEdit->clear();
3753 if (selbi->xlinkCount()>0)
3757 for (int i=0; i<selbi->xlinkCount();++i)
3759 bi=selbi->getXLinkNum(i)->getPartnerBranch();
3763 if (s.length()>xLinkMenuWidth)
3764 s=s.left(xLinkMenuWidth)+"...";
3765 branchXLinksContextMenuEdit->addAction (s);
3770 standardFlagsMaster->updateToolBar (selbi->activeStandardFlagNames() );
3773 actionToggleScroll->setEnabled (true);
3774 if ( selbi->isScrolled() )
3775 actionToggleScroll->setChecked(true);
3777 actionToggleScroll->setChecked(false);
3779 if ( selti->getURL().isEmpty() )
3781 actionOpenURL->setEnabled (false);
3782 actionOpenURLTab->setEnabled (false);
3786 actionOpenURL->setEnabled (true);
3787 actionOpenURLTab->setEnabled (true);
3789 if ( selti->getVymLink().isEmpty() )
3791 actionOpenVymLink->setEnabled (false);
3792 actionDeleteVymLink->setEnabled (false);
3795 actionOpenVymLink->setEnabled (true);
3796 actionDeleteVymLink->setEnabled (true);
3799 if (selbi->canMoveUp())
3800 actionMoveUp->setEnabled (true);
3802 actionMoveUp->setEnabled (false);
3803 if (selbi->canMoveDown())
3804 actionMoveDown->setEnabled (true);
3806 actionMoveDown->setEnabled (false);
3808 actionSortChildren->setEnabled (true);
3809 actionSortBackChildren->setEnabled (true);
3811 actionToggleHideExport->setEnabled (true);
3812 actionToggleHideExport->setChecked (selbi->hideInExport() );
3814 actionCopy->setEnabled (true);
3815 actionCut->setEnabled (true);
3816 if (!clipboardEmpty)
3817 actionPaste->setEnabled (true);
3819 actionPaste->setEnabled (false);
3820 for (int i=0; i<actionListBranches.size(); ++i)
3821 actionListBranches.at(i)->setEnabled(true);
3822 actionDelete->setEnabled (true);
3824 if ( selti->getType()==TreeItem::Image)
3826 actionOpenURL->setEnabled (false);
3827 actionOpenVymLink->setEnabled (false);
3828 actionDeleteVymLink->setEnabled (false);
3829 actionToggleHideExport->setEnabled (true);
3830 actionToggleHideExport->setChecked (selti->hideInExport() );
3833 actionCopy->setEnabled (true);
3834 actionCut->setEnabled (true);
3835 actionPaste->setEnabled (false); //FIXME-4 why not allowing copy of images?
3836 for (int i=0; i<actionListBranches.size(); ++i)
3837 actionListBranches.at(i)->setEnabled(false);
3838 actionDelete->setEnabled (true);
3839 actionMoveUp->setEnabled (false);
3840 actionMoveDown->setEnabled (false);
3845 actionCopy->setEnabled (false);
3846 actionCut->setEnabled (false);
3847 actionPaste->setEnabled (false);
3848 for (int i=0; i<actionListBranches.size(); ++i)
3849 actionListBranches.at(i)->setEnabled(false);
3851 actionToggleScroll->setEnabled (false);
3852 actionOpenURL->setEnabled (false);
3853 actionOpenVymLink->setEnabled (false);
3854 actionDeleteVymLink->setEnabled (false);
3855 actionHeading2URL->setEnabled (false);
3856 actionDelete->setEnabled (false);
3857 actionMoveUp->setEnabled (false);
3858 actionMoveDown->setEnabled (false);
3859 actionFormatHideLinkUnselected->setEnabled (false);
3860 actionSortChildren->setEnabled (false);
3861 actionSortBackChildren->setEnabled (false);
3862 actionToggleHideExport->setEnabled (false);
3867 Main::ModMode Main::getModMode()
3869 if (actionModModeColor->isOn()) return ModModeColor;
3870 if (actionModModeCopy->isOn()) return ModModeCopy;
3871 if (actionModModeXLink->isOn()) return ModModeXLink;
3875 bool Main::autoEditNewBranch()
3877 return actionSettingsAutoEditNewBranch->isOn();
3880 bool Main::autoSelectNewBranch()
3882 return actionSettingsAutoSelectNewBranch->isOn();
3885 void Main::windowShowNoteEditor()
3887 textEditor->setShowWithMain(true);
3889 actionViewToggleNoteEditor->setChecked (true);
3892 void Main::windowHideNoteEditor()
3894 textEditor->setShowWithMain(false);
3896 actionViewToggleNoteEditor->setChecked (false);
3899 void Main::setScript (const QString &script)
3901 scriptEditor->setScript (script);
3904 void Main::runScript (const QString &script)
3906 VymModel *m=currentModel();
3907 if (m) m->runScript (script);
3910 void Main::runScriptEverywhere (const QString &script)
3913 for (int i=0;i<=tabWidget->count() -1;i++)
3915 me=(MapEditor*)tabWidget->page(i);
3916 if (me) me->getModel()->runScript (script);
3920 void Main::windowNextEditor()
3922 if (tabWidget->currentIndex() < tabWidget->count())
3923 tabWidget->setCurrentIndex (tabWidget->currentIndex() +1);
3926 void Main::windowPreviousEditor()
3928 if (tabWidget->currentIndex() >0)
3929 tabWidget->setCurrentIndex (tabWidget->currentIndex() -1);
3932 void Main::standardFlagChanged()
3936 if ( actionSettingsUseFlagGroups->isOn() )
3937 currentModel()->toggleStandardFlag(sender()->name(),standardFlagsMaster);
3939 currentModel()->toggleStandardFlag(sender()->name());
3945 #include "attributeitem.h"
3946 void Main::testFunction1()
3948 VymModel *m=currentModel();
3951 BranchItem *selbi=m->getSelectedBranch();
3954 QList<QVariant> cData;
3955 cData << "new ai" << "undef";
3957 AttributeItem *ai=new AttributeItem (cData,selbi);
3958 ai->set ("Key 1","Val a",AttributeItem::FreeString);
3960 m->addAttribute (ai);
3965 if (!currentMapEditor()) return;
3966 currentMapEditor()->testFunction1();
3970 VymModel *m=currentModel();
3974 QString text = QInputDialog::getText(
3975 "VYM", "Enter Filter:", QLineEdit::Normal, // FIXME-3 no translation yet
3976 m->getSortFilter(), &ok, NULL);
3978 // user entered something and pressed OK
3979 m->setSortFilter (text);
3983 void Main::testFunction2()
3985 findResultWidget->setModel (currentModel());
3986 findResultWidget->addResult ("Test",currentModel()->getSelectedItem());
3990 if (!currentMapEditor()) return;
3991 currentMapEditor()->testFunction2();
3994 void Main::testCommand()
3996 if (!currentMapEditor()) return;
3997 scriptEditor->show();
4000 QString com = QInputDialog::getText(
4001 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
4002 if (ok) currentMapEditor()->parseAtom(com);
4006 void Main::helpDoc()
4008 QString locale = QLocale::system().name();
4010 if (locale.left(2)=="es")
4011 docname="vym_es.pdf";
4015 QStringList searchList;
4017 #if defined(Q_OS_MACX)
4018 searchList << "./vym.app/Contents/Resources/doc";
4019 #elif defined(Q_OS_WIN32)
4020 searchList << vymInstallDir.path() + "/share/doc/packages/vym";
4022 #if defined(VYM_DOCDIR)
4023 searchList << VYM_DOCDIR;
4025 // default path in SUSE LINUX
4026 searchList << "/usr/share/doc/packages/vym";
4029 searchList << "doc"; // relative path for easy testing in tarball
4030 searchList << "doc/tex"; // Easy testing working on vym.tex
4031 searchList << "/usr/share/doc/vym"; // Debian
4032 searchList << "/usr/share/doc/packages";// Knoppix
4036 for (int i=0; i<searchList.count(); ++i)
4038 docfile.setFileName(searchList.at(i)+"/"+docname);
4039 if (docfile.exists())
4048 QMessageBox::critical(0,
4049 tr("Critcal error"),
4050 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
4055 Process *pdfProc = new Process();
4056 args << QDir::toNativeSeparators(docfile.fileName());
4058 if (!pdfProc->startDetached( settings.value("/mainwindow/readerPDF").toString(),args) )
4061 QMessageBox::warning(0,
4063 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
4064 tr("Please use Settings->")+tr("Set application to open PDF files"));
4071 void Main::helpDemo()
4073 QStringList filters;
4074 filters <<"VYM example map (*.vym)";
4075 QFileDialog *fd=new QFileDialog( this);
4076 #if defined(Q_OS_MACX)
4077 fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
4079 // default path in SUSE LINUX
4080 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
4083 fd->setFileMode (QFileDialog::ExistingFiles);
4084 fd->setFilters (filters);
4085 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
4089 if ( fd->exec() == QDialog::Accepted )
4091 lastFileDir=fd->directory().path();
4092 QStringList flist = fd->selectedFiles();
4093 QStringList::Iterator it = flist.begin();
4094 while( it != flist.end() )
4097 fileLoad(*it, NewMap);
4105 void Main::helpAbout()
4108 ad.setName ("aboutwindow");
4109 ad.setMinimumSize(500,500);
4110 ad.resize (QSize (500,500));
4114 void Main::helpAboutQT()
4116 QMessageBox::aboutQt( this, "Qt Application Example" );
4119 void Main::callMacro ()
4121 QAction *action = qobject_cast<QAction *>(sender());
4125 i=action->data().toInt();
4126 QString mDir (settings.value ("macros/macroDir").toString() );
4128 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
4130 if ( !f.open( QIODevice::ReadOnly ) )
4132 QMessageBox::warning(0,
4134 tr("Couldn't find a macro at %1.\n").arg(fn)+
4135 tr("Please use Settings->")+tr("Set directory for vym macros"));
4139 QTextStream ts( &f );
4140 QString macro= ts.read();
4142 if (! macro.isEmpty())
4144 VymModel *m=currentModel();
4145 if (m) m->runScript(macro);