Added dialog for HTML export. Grouping in Switchboard shortcuts
1 #include "mainwindow.h"
8 #include "aboutdialog.h"
9 #include "branchpropwindow.h"
10 #include "branchitem.h"
11 #include "exportoofiledialog.h"
15 #include "historywindow.h"
17 #include "mapeditor.h"
22 #include "shortcuts.h"
23 #include "texteditor.h"
24 #include "warningdialog.h"
25 #include "xlinkitem.h"
27 //#include <modeltest.h> // FIXME-3
29 #if defined(Q_OS_WIN32)
30 // Define only this structure as opposed to
31 // including full 'windows.h'. FindWindow
32 // clashes with the one in Win32 API.
33 typedef struct _PROCESS_INFORMATION
39 } PROCESS_INFORMATION, *LPPROCESS_INFORMATION;
42 extern TextEditor *textEditor;
43 extern Main *mainWindow;
44 extern QString tmpVymDir;
45 extern QString clipboardDir;
46 extern QString clipboardFile;
47 extern bool clipboardEmpty;
48 extern int statusbarTime;
49 extern FlagRow *standardFlagsMaster;
50 extern FlagRow *systemFlagsMaster;
51 extern QString vymName;
52 extern QString vymVersion;
53 extern QString vymBuildDate;
56 QMenu* branchContextMenu;
57 QMenu* branchAddContextMenu;
58 QMenu* branchRemoveContextMenu;
59 QMenu* branchLinksContextMenu;
60 QMenu* branchXLinksContextMenuEdit;
61 QMenu* floatimageContextMenu;
62 QMenu* canvasContextMenu;
63 QMenu* fileLastMapsMenu;
64 QMenu* fileImportMenu;
65 QMenu* fileExportMenu;
68 extern Settings settings;
69 extern Options options;
70 extern ImageIO imageIO;
72 extern QDir vymBaseDir;
73 extern QDir lastImageDir;
74 extern QDir lastFileDir;
75 #if defined(Q_OS_WIN32)
76 extern QDir vymInstallDir;
78 extern QString iconPath;
79 extern QString flagsPath;
82 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
83 QMainWindow(parent,name,f)
87 setCaption ("VYM - View Your Mind");
89 // Load window settings
90 #if defined(Q_OS_WIN32)
91 if (settings.value("/mainwindow/geometry/maximized", false).toBool())
93 setWindowState(Qt::WindowMaximized);
98 resize (settings.value("/mainwindow/geometry/size", QSize (800,600)).toSize());
99 move (settings.value("/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
102 // Sometimes we may need to remember old selections
106 currentColor=Qt::black;
108 // Create unique temporary directory
110 tmpVymDir=makeTmpDir (ok,"vym");
113 qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
116 if (debug) qDebug (QString("vym tmpDir=%1").arg(tmpVymDir) );
118 // Create direcctory for clipboard
119 clipboardDir=tmpVymDir+"/clipboard";
120 clipboardFile="map.xml";
121 QDir d(clipboardDir);
122 d.mkdir (clipboardDir,true);
123 makeSubDirs (clipboardDir);
126 browserPID=new qint64;
129 // Satellite windows //////////////////////////////////////////
131 historyWindow=new HistoryWindow();
132 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
135 branchPropertyWindow = new BranchPropertyWindow();
136 connect (branchPropertyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
138 // Connect TextEditor, so that we can update flags if text changes
139 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
140 connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
142 // Initialize script editor
143 scriptEditor = new SimpleScriptEditor();
144 scriptEditor->move (50,50);
146 connect( scriptEditor, SIGNAL( runScript ( QString ) ),
147 this, SLOT( runScript( QString ) ) );
149 // Initialize some settings, which are platform dependant
152 // application to open URLs
153 p="/mainwindow/readerURL";
154 #if defined(Q_OS_LINUX)
155 s=settings.value (p,"xdg-open").toString();
157 #if defined(Q_OS_MACX)
158 s=settings.value (p,"/usr/bin/open").toString();
161 #if defined(Q_OS_WIN32)
162 // Assume that system has been set up so that
163 // Explorer automagically opens up the URL
164 // in the user's preferred browser.
165 s=settings.value (p,"explorer").toString();
167 s=settings.value (p,"mozilla").toString();
171 settings.setValue( p,s);
173 // application to open PDFs
174 p="/mainwindow/readerPDF";
175 #if defined(Q_OS_LINUX)
176 s=settings.value (p,"xdg-open").toString();
178 #if defined(Q_OS_MACX)
179 s=settings.value (p,"/usr/bin/open").toString();
180 #elif defined(Q_OS_WIN32)
181 s=settings.value (p,"acrord32").toString();
183 s=settings.value (p,"acroread").toString();
186 settings.setValue( p,s);
188 // width of xLinksMenu
191 // Create tab widget which holds the maps
192 tabWidget= new QTabWidget (this);
193 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
194 this, SLOT( editorChanged( QWidget * ) ) );
196 setCentralWidget(tabWidget);
200 setupFormatActions();
204 setupNetworkActions();
205 setupSettingsActions();
208 if (debug) switchboard.print();
210 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
213 // Status bar and progress bar there
217 progressCounterTotal=0;
219 progressDialog.setLabelText (tr("Loading maps","Mainwindow"));
220 progressDialog.setAutoReset(false);
221 progressDialog.setAutoClose(false);
222 //progressDialog.setWindowModality (Qt::WindowModal); // That forces mainwindo to update and slows down
223 //progressDialog.setCancelButton (NULL);
225 restoreState (settings.value("/mainwindow/state",0).toByteArray());
233 #if defined(Q_OS_WIN32)
234 settings.setValue ("/mainwindow/geometry/maximized", isMaximized());
236 settings.setValue ("/mainwindow/geometry/size", size());
237 settings.setValue ("/mainwindow/geometry/pos", pos());
238 settings.setValue ("/mainwindow/state",saveState(0));
240 settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
241 settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
242 settings.setValue( "/version/version", vymVersion );
243 settings.setValue( "/version/builddate", vymBuildDate );
245 settings.setValue( "/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
246 settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isOn() );
247 settings.setValue( "/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
248 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
249 settings.setValue( "/mapeditor/editmode/autoEditNewBranch",actionSettingsAutoEditNewBranch->isOn() );
250 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
251 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
252 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
254 //TODO save scriptEditor settings
256 // call the destructors
258 delete historyWindow;
259 delete branchPropertyWindow;
261 // Remove temporary directory
262 removeDir (QDir(tmpVymDir));
265 void Main::loadCmdLine()
267 /* TODO draw some kind of splashscreen while loading...
273 QStringList flist=options.getFileList();
274 QStringList::Iterator it=flist.begin();
276 progressCounter=flist.count();
277 progressCounterTotal=flist.count();
278 while (it !=flist.end() )
280 fileLoad (*it, NewMap);
286 void Main::statusMessage(const QString &s)
288 // Surpress messages while progressdialog during
291 statusBar()->message( s);
294 void Main::setProgressMaximum (int max)
296 if (progressCounterTotal!=0)
298 progressDialog.setRange (0,progressCounterTotal*1000);
300 progressDialog.setRange (0,max+10);
302 progressDialog.setValue (0);
303 progressMax=max*1000;
304 //cout << "Main max="<<max<<" v="<<progressDialog.value()<<endl;
305 progressDialog.show();
308 void Main::addProgressValue (float v)
310 //cout << "addVal v="<<v*1000<<"/"<<progressMax<<" cur="<<progressDialog.value()<<" counter="<<v+progressCounter<<"/"<<progressCounterTotal<<endl;
311 if (progressCounterTotal!=0)
312 progressDialog.setValue ( (v+progressCounterTotal-progressCounter)*1000 );
314 progressDialog.setValue (v+progressDialog.value());
317 void Main::removeProgressCounter()
321 if (progressCounter<=0)
324 progressCounterTotal=0;
325 progressDialog.reset();
326 progressDialog.hide();
330 void Main::closeEvent (QCloseEvent* )
336 void Main::setupFileActions()
338 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
339 QToolBar *tb = addToolBar( tr ("&Map") );
340 tb->setObjectName ("mapTB");
343 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this);
344 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
345 a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map
346 switchboard.addConnection(a,tr("File","Shortcut group"));
348 fileMenu->addAction (a);
349 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
351 a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this);
352 a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) );
353 a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N ); //New map
354 switchboard.addConnection(a,tr("File","Shortcut group"));
355 fileMenu->addAction (a);
356 connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) );
359 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
360 a->setStatusTip (tr( "Open","Status tip File menu" ) );
361 a->setShortcut ( Qt::CTRL + Qt::Key_O ); //Open map
362 switchboard.addConnection(a,tr("File","Shortcut group"));
364 fileMenu->addAction (a);
365 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
367 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
368 fileMenu->addSeparator();
370 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
371 a->setStatusTip ( tr( "Save","Status tip file menu" ));
372 a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map
373 switchboard.addConnection(a,tr("File","Shortcut group"));
375 fileMenu->addAction (a);
376 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
379 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
380 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
381 switchboard.addConnection(a,tr("File","Shortcut group"));
382 fileMenu->addAction (a);
383 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
385 fileMenu->addSeparator();
387 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
389 a = new QAction(tr("KDE 3 Bookmarks"), this);
390 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 3 bookmarks")));
391 switchboard.addConnection(a,tr("File","Shortcut group"));
392 a->addTo (fileImportMenu);
393 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE3Bookmarks() ) );
395 a = new QAction(tr("KDE 4 Bookmarks"), this);
396 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 4 bookmarks")));
397 a->addTo (fileImportMenu);
398 switchboard.addConnection(a,tr("File","Shortcut group"));
399 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE4Bookmarks() ) );
401 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
403 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
404 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
405 a->addTo (fileImportMenu);
406 switchboard.addConnection(a,tr("File","Shortcut group"));
407 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
410 a = new QAction("Freemind...",this);
411 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Freemind") );
412 switchboard.addConnection(a,tr("File","Shortcut group"));
413 fileImportMenu->addAction (a);
414 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFreemind() ) );
416 a = new QAction("Mind Manager...",this);
417 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
418 switchboard.addConnection(a,tr("File","Shortcut group"));
419 fileImportMenu->addAction (a);
420 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
422 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
423 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
424 switchboard.addConnection(a,tr("File","Shortcut group"));
425 fileImportMenu->addAction (a);
426 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
428 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
430 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
431 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
432 switchboard.addConnection(a,tr("File","Shortcut group"));
433 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
434 fileExportMenu->addAction (a);
436 a = new QAction( "Open Office...", this);
437 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
438 switchboard.addConnection(a,tr("File","Shortcut group"));
439 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
440 fileExportMenu->addAction (a);
442 a = new QAction( "Webpage (HTML)...",this );
443 a->setShortcut (Qt::ALT + Qt::Key_X); //Export HTML
444 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
445 switchboard.addConnection(a,tr("File","Shortcut group"));
446 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportHTML() ) );
447 fileExportMenu->addAction (a);
449 a = new QAction( "Webpage (XHTML)...",this ); //Export XHTML
451 //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")));
452 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
453 fileExportMenu->addAction (a);
455 a = new QAction( "Text (A&O report)...", this);
456 a->setStatusTip ( tr( "Export as %1").arg("A&O report "+tr("(still experimental)" )));
457 switchboard.addConnection(a,tr("File","Shortcut group"));
458 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportAO() ) );
459 fileExportMenu->addAction (a);
461 a = new QAction( "Text (ASCII)...", this);
462 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
463 switchboard.addConnection(a,tr("File","Shortcut group"));
464 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
465 fileExportMenu->addAction (a);
467 a = new QAction( "Spreadsheet (CSV)...", this);
468 a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
469 switchboard.addConnection(a,tr("File","Shortcut group"));
470 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
471 fileExportMenu->addAction (a);
473 a = new QAction( tr("KDE 3 Bookmarks","File menu"), this);
474 a->setStatusTip( tr( "Export as %1").arg(tr("KDE 3 Bookmarks" )));
475 switchboard.addConnection(a,tr("File","Shortcut group"));
476 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE3Bookmarks() ) );
477 fileExportMenu->addAction (a);
479 a = new QAction( tr("KDE 4 Bookmarks","File menu"), this);
480 a->setStatusTip( tr( "Export as %1").arg(tr("KDE 4 Bookmarks" )));
481 switchboard.addConnection(a,tr("File","Shortcut group"));
482 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE4Bookmarks() ) );
483 fileExportMenu->addAction (a);
485 a = new QAction( "Taskjuggler...", this );
486 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
487 switchboard.addConnection(a,tr("File","Shortcut group"));
488 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
489 fileExportMenu->addAction (a);
491 a = new QAction( "LaTeX...", this);
492 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
493 switchboard.addConnection(a,tr("File","Shortcut group"));
494 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
495 fileExportMenu->addAction (a);
497 a = new QAction( "XML..." , this );
498 a->setStatusTip (tr( "Export as %1").arg("XML"));
499 switchboard.addConnection(a,tr("File","Shortcut group"));
500 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
501 fileExportMenu->addAction (a);
503 fileMenu->addSeparator();
505 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
506 a->setStatusTip ( tr( "Print" ,"File menu") );
507 a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map
509 switchboard.addConnection(a,tr("File","Shortcut group"));
510 fileMenu->addAction (a);
511 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
514 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
515 a->setStatusTip (tr( "Close Map" ) );
516 a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map
517 switchboard.addConnection(a,tr("File","Shortcut group"));
518 fileMenu->addAction (a);
519 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
521 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
522 a->setStatusTip ( tr( "Exit")+" "+vymName );
523 a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym
524 switchboard.addConnection(a,tr("File","Shortcut group"));
525 fileMenu->addAction (a);
526 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
531 void Main::setupEditActions()
533 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
534 tb->setLabel( "Edit Actions" );
535 tb->setObjectName ("actionsTB");
536 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
540 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
541 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
542 a->setStatusTip (tr( "Undo" ) );
543 a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action
544 a->setEnabled (false);
545 switchboard.addConnection(a,tr("Edit","Shortcut group"));
547 editMenu->addAction (a);
550 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
551 a->setStatusTip (tr( "Redo" ));
552 a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action
553 switchboard.addConnection(a,tr("Edit","Shortcut group"));
555 editMenu->addAction (a);
556 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
559 editMenu->addSeparator();
560 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
561 a->setStatusTip ( tr( "Copy" ) );
562 a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy
563 a->setEnabled (false);
564 switchboard.addConnection(a,tr("Edit","Shortcut group"));
566 editMenu->addAction (a);
567 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
570 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
571 a->setStatusTip ( tr( "Cut" ) );
572 a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut
573 a->setEnabled (false);
575 switchboard.addConnection(a,tr("Edit","Shortcut group"));
576 editMenu->addAction (a);
578 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
580 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
581 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
582 a->setStatusTip ( tr( "Paste" ) );
583 a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste
584 a->setEnabled (false);
586 switchboard.addConnection(a,tr("Edit","Shortcut group"));
587 editMenu->addAction (a);
590 // Shortcut to delete selection
591 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
592 a->setStatusTip (tr( "Delete Selection" ));
593 a->setShortcut ( Qt::Key_Delete); //Delete selection
594 a->setShortcutContext (Qt::WindowShortcut);
595 switchboard.addConnection(a,tr("Edit","Shortcut group"));
597 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
600 // Shortcut to add attribute
601 a= new QAction(tr( "Add attribute" ), this);
602 a->setShortcut ( Qt::Key_Q);
603 a->setShortcutContext (Qt::WindowShortcut);
604 switchboard.addConnection(a,tr("Edit","Shortcut group"));
606 connect( a, SIGNAL( triggered() ), this, SLOT( editAddAttribute() ) );
607 actionAddAttribute= a;
610 // Shortcut to add mapcenter
611 a= new QAction(QPixmap(iconPath+"newmapcenter.png"),tr( "Add mapcenter","Canvas context menu" ), this);
612 a->setShortcut ( Qt::Key_M);
613 a->setShortcutContext (Qt::WindowShortcut);
614 switchboard.addConnection(a,tr("Edit","Shortcut group"));
615 connect( a, SIGNAL( triggered() ), this, SLOT( editAddMapCenter() ) );
616 //actionListBranches.append(a);
618 actionAddMapCenter = a;
621 // Shortcut to add branch
622 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
623 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
624 alt->setShortcut (Qt::Key_A); //Add branch
625 alt->setShortcutContext (Qt::WindowShortcut);
626 switchboard.addConnection(alt,tr("Edit","Shortcut group"));
628 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
629 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
630 a->setStatusTip ( tr( "Add a branch as child of selection" ));
631 a->setShortcut (Qt::Key_Insert); //Add branch
632 switchboard.addConnection(a,tr("Edit","Shortcut group"));
633 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
634 actionListBranches.append(a);
635 #if defined (Q_OS_MACX)
636 // In OSX show different shortcut in menues, the keys work indepently always
641 editMenu->addAction (actionAddBranch);
642 tb->addAction (actionAddBranch);
645 // Add branch by inserting it at selection
646 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
647 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
648 a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch
649 a->setShortcutContext (Qt::WindowShortcut);
650 switchboard.addConnection(a,tr("Edit","Shortcut group"));
652 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
653 a->setEnabled (false);
654 actionListBranches.append(a);
655 actionAddBranchBefore=a;
656 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
657 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
658 a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch
659 a->setShortcutContext (Qt::WindowShortcut);
660 switchboard.addConnection(a,tr("Edit","Shortcut group"));
662 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
663 actionListBranches.append(a);
666 a = new QAction(tr( "Add branch above","Edit menu" ), this);
667 a->setStatusTip ( tr( "Add a branch above selection" ));
668 a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
669 a->setShortcutContext (Qt::WindowShortcut);
670 switchboard.addConnection(a,tr("Edit","Shortcut group"));
672 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
673 a->setEnabled (false);
674 actionListBranches.append(a);
675 actionAddBranchAbove=a;
676 a = new QAction(tr( "Add branch above","Edit menu" ), this);
677 a->setStatusTip ( tr( "Add a branch above selection" ));
678 a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above
679 a->setShortcutContext (Qt::WindowShortcut);
680 switchboard.addConnection(a,tr("Edit","Shortcut group"));
682 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
683 actionListBranches.append(a);
686 a = new QAction(tr( "Add branch below","Edit menu" ), this);
687 a->setStatusTip ( tr( "Add a branch below selection" ));
688 a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
689 a->setShortcutContext (Qt::WindowShortcut);
690 switchboard.addConnection(a,tr("Edit","Shortcut group"));
692 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
693 a->setEnabled (false);
694 actionListBranches.append(a);
695 actionAddBranchBelow=a;
696 a = new QAction(tr( "Add branch below","Edit menu" ), this);
697 a->setStatusTip ( tr( "Add a branch below selection" ));
698 a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below
699 a->setShortcutContext (Qt::WindowShortcut);
700 switchboard.addConnection(a,tr("Edit","Shortcut group"));
702 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
703 actionListBranches.append(a);
705 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
706 a->setStatusTip ( tr( "Move branch up" ) );
707 a->setShortcut (Qt::Key_PageUp ); // Move branch up
708 a->setEnabled (false);
709 switchboard.addConnection(a,tr("Edit","Shortcut group"));
711 editMenu->addAction (a);
712 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
715 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
716 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
717 a->setStatusTip (tr( "Move branch down" ) );
718 a->setShortcut ( Qt::Key_PageDown ); // Move branch down
719 a->setEnabled (false);
720 switchboard.addConnection(a,tr("Edit","Shortcut group"));
722 editMenu->addAction (a);
725 a = new QAction(QPixmap(), tr( "&Detach","Context menu" ),this);
726 a->setStatusTip ( tr( "Detach branch and use as mapcenter","Context menu" ) );
727 a->setShortcut ( Qt::Key_D ); // Detach branch
728 switchboard.addConnection(a,tr("Edit","Shortcut group"));
729 editMenu->addAction (a);
730 connect( a, SIGNAL( triggered() ), this, SLOT( editDetach() ) );
733 a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this );
734 connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) );
735 a->setEnabled (true);
737 switchboard.addConnection(a,tr("Edit","Shortcut group"));
738 editMenu->addAction (a);
739 actionSortChildren=a;
741 a = new QAction( QPixmap(iconPath+"editsortback.png" ), tr( "Sort children backwards","Edit menu" ), this );
742 connect( a, SIGNAL( activated() ), this, SLOT( editSortBackChildren() ) );
743 a->setEnabled (true);
745 switchboard.addConnection(a,tr("Edit","Shortcut group"));
746 editMenu->addAction (a);
747 actionSortBackChildren=a;
749 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
750 alt->setShortcut ( Qt::Key_S ); // Scroll branch
751 alt->setStatusTip (tr( "Scroll branch" ));
752 switchboard.addConnection(alt,tr("Edit","Shortcut group"));
753 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
754 #if defined(Q_OS_MACX)
755 actionToggleScroll=alt;
757 actionToggleScroll=a;
759 actionToggleScroll->setEnabled (false);
760 actionToggleScroll->setToggleAction(true);
761 tb->addAction (actionToggleScroll);
762 editMenu->addAction ( actionToggleScroll);
763 editMenu->addAction (actionToggleScroll);
766 actionListBranches.append(actionToggleScroll);
768 a = new QAction( QPixmap(), tr( "Expand all branches","Edit menu" ), this);
769 a->setShortcut ( Qt::SHIFT + Qt::Key_X ); // Expand all branches
770 a->setStatusTip (tr( "Expand all branches" ));
771 switchboard.addConnection(a,tr("Edit","Shortcut group"));
772 connect( a, SIGNAL( triggered() ), this, SLOT( editExpandAll() ) );
774 actionExpandAll->setEnabled (false);
775 actionExpandAll->setToggleAction(false);
776 //tb->addAction (actionExpandAll);
777 editMenu->addAction ( actionExpandAll);
779 actionListBranches.append(actionExpandAll);
781 a = new QAction( QPixmap(), tr( "Expand one level","Edit menu" ), this);
782 a->setShortcut ( Qt::Key_Greater ); // Expand one level in tree editor
783 switchboard.addConnection(a,tr("Edit","Shortcut group"));
784 a->setStatusTip (tr( "Expand one level in tree editor" ));
785 connect( a, SIGNAL( triggered() ), this, SLOT( editExpandOneLevel() ) );
786 a->setEnabled (false);
787 a->setToggleAction(false);
788 actionExpandOneLevel=a;
790 editMenu->addAction ( a);
792 actionListBranches.append(a);
794 a = new QAction( QPixmap(), tr( "Collapse one level","Edit menu" ), this);
795 a->setShortcut ( Qt::Key_Less); // Collapse one level in tree editor
796 switchboard.addConnection(a,tr("Edit","Shortcut group"));
797 a->setStatusTip (tr( "Collapse one level in tree editor" ));
798 connect( a, SIGNAL( triggered() ), this, SLOT( editCollapseOneLevel() ) );
799 a->setEnabled (false);
800 a->setToggleAction(false);
801 actionCollapseOneLevel=a;
803 editMenu->addAction ( a);
805 actionListBranches.append(a);
807 a = new QAction( tr( "Unscroll children","Edit menu" ), this);
808 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
809 switchboard.addConnection(a,tr("Edit","Shortcut group"));
810 editMenu->addAction (a);
811 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChildren() ) );
813 editMenu->addSeparator();
815 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
816 a->setStatusTip (tr( "Find" ) );
817 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
818 switchboard.addConnection(a,tr("Edit","Shortcut group"));
819 editMenu->addAction (a);
820 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWidget() ) );
822 a = new QAction( tr( "Find duplicate URLs","Edit menu"), this);
823 //a->setStatusTip (tr( "Find" ) );
824 a->setShortcut (Qt::SHIFT + Qt::Key_F); //Find duplicate URLs
825 switchboard.addConnection(a,tr("Edit","Shortcut group"));
826 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
827 editMenu->addAction (a);
828 connect( a, SIGNAL( triggered() ), this, SLOT( editFindDuplicateURLs() ) );
830 editMenu->addSeparator();
832 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
833 a->setShortcut (Qt::SHIFT + Qt::Key_U );
834 switchboard.addConnection(a,tr("Edit","Shortcut group"));
837 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
840 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
841 a->setStatusTip (tr( "Open URL in new tab" ));
842 //a->setShortcut (Qt::CTRL+Qt::Key_U );
843 switchboard.addConnection(a,tr("Edit","Shortcut group"));
845 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
848 a = new QAction( tr( "Open all URLs in subtree (including scrolled branches)","Edit menu" ), this);
849 a->setStatusTip (tr( "Open all URLs in subtree (including scrolled branches)" ));
850 a->setShortcut ( Qt::CTRL + Qt::Key_U );
851 switchboard.addConnection(a,tr("Edit","Shortcut group"));
853 actionListBranches.append(a);
854 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVisURLTabs() ) );
855 actionOpenMultipleVisURLTabs=a;
857 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
858 a->setStatusTip (tr( "Open all URLs in subtree" ));
859 switchboard.addConnection(a,tr("Edit","Shortcut group"));
861 actionListBranches.append(a);
862 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
863 actionOpenMultipleURLTabs=a;
865 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
866 a->setStatusTip ( tr( "Edit URL" ) );
867 a->setShortcut ( Qt::Key_U );
868 a->setShortcutContext (Qt::WindowShortcut);
869 switchboard.addConnection(a,tr("Edit","Shortcut group"));
870 actionListBranches.append(a);
872 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
875 a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
876 a->setStatusTip ( tr( "Edit local URL" ) );
877 //a->setShortcut (Qt::SHIFT + Qt::Key_U );
878 a->setShortcutContext (Qt::WindowShortcut);
879 switchboard.addConnection(a,tr("Edit","Shortcut group"));
880 actionListBranches.append(a);
882 connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
885 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
886 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
887 a->setEnabled (false);
888 switchboard.addConnection(a,tr("Edit","Shortcut group"));
889 actionListBranches.append(a);
890 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
893 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
894 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
895 a->setEnabled (false);
896 actionListBranches.append(a);
897 a->setShortcut ( Qt::Key_B );
898 a->setShortcutContext (Qt::WindowShortcut);
899 switchboard.addConnection(a,tr("Edit","Shortcut group"));
901 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
902 actionBugzilla2URL=a;
904 a = new QAction(tr( "Get data from Novell Bugzilla","Edit menu" ), this);
905 a->setStatusTip ( tr( "Get data from Novell Bugzilla" ));
906 a->setEnabled (false);
907 actionListBranches.append(a);
908 a->setShortcut ( Qt::Key_B + Qt::SHIFT);
909 a->setShortcutContext (Qt::WindowShortcut);
910 switchboard.addConnection(a,tr("Edit","Shortcut group"));
912 connect( a, SIGNAL( triggered() ), this, SLOT( getBugzillaData() ) );
913 actionGetBugzillaData=a;
915 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
916 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
917 a->setEnabled (false);
918 switchboard.addConnection(a,tr("Edit","Shortcut group"));
919 actionListBranches.append(a);
920 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
923 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
924 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
926 a->setEnabled (false);
927 switchboard.addConnection(a,tr("Edit","Shortcut group"));
928 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
931 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
932 a->setStatusTip ( tr( "Open all vym links in subtree" ));
933 a->setEnabled (false);
934 switchboard.addConnection(a,tr("Edit","Shortcut group"));
935 actionListBranches.append(a);
936 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
937 actionOpenMultipleVymLinks=a;
940 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
941 a->setEnabled (false);
942 a->setStatusTip ( tr( "Edit link to another vym map" ));
943 switchboard.addConnection(a,tr("Edit","Shortcut group"));
944 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
945 actionListBranches.append(a);
948 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
949 a->setStatusTip ( tr( "Delete link to another vym map" ));
950 a->setEnabled (false);
951 switchboard.addConnection(a,tr("Edit","Shortcut group"));
952 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
953 actionDeleteVymLink=a;
955 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
956 a->setStatusTip ( tr( "Hide object in exports" ) );
957 a->setShortcut (Qt::Key_H );
958 a->setToggleAction(true);
960 a->setEnabled (false);
961 switchboard.addConnection(a,tr("Edit","Shortcut group"));
962 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
963 actionToggleHideExport=a;
965 a = new QAction(tr( "Add timestamp","Edit menu" ), this);
966 a->setStatusTip ( tr( "Add timestamp" ));
967 a->setEnabled (false);
968 actionListBranches.append(a);
969 a->setShortcut ( Qt::Key_T ); // Add timestamp
970 a->setShortcutContext (Qt::WindowShortcut);
971 switchboard.addConnection(a,tr("Edit","Shortcut group"));
973 connect( a, SIGNAL( triggered() ), this, SLOT( editAddTimestamp() ) );
974 actionAddTimestamp=a;
976 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
977 a->setStatusTip ( tr( "Edit Map Info" ));
978 a->setEnabled (true);
979 switchboard.addConnection(a,tr("Edit","Shortcut group"));
980 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
983 // Import at selection (adding to selection)
984 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
985 a->setStatusTip (tr( "Add map at selection" ));
986 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
987 a->setEnabled (false);
988 switchboard.addConnection(a,tr("Edit","Shortcut group"));
989 actionListBranches.append(a);
992 // Import at selection (replacing selection)
993 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
994 a->setStatusTip (tr( "Replace selection with map" ));
995 switchboard.addConnection(a,tr("Edit","Shortcut group"));
996 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
997 a->setEnabled (false);
998 actionListBranches.append(a);
999 actionImportReplace=a;
1002 a = new QAction( tr( "Save selection","Edit menu" ), this);
1003 a->setStatusTip (tr( "Save selection" ));
1004 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
1005 a->setEnabled (false);
1006 switchboard.addConnection(a,tr("Edit","Shortcut group"));
1007 actionListBranches.append(a);
1010 // Only remove branch, not its children
1011 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
1012 a->setStatusTip ( tr( "Remove only branch and keep its children" ));
1013 a->setShortcut (Qt::ALT + Qt::Key_Delete );
1014 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChildren() ) );
1015 a->setEnabled (false);
1016 switchboard.addConnection(a,tr("Edit","Shortcut group"));
1018 actionListBranches.append(a);
1019 actionDeleteKeepChildren=a;
1021 // Only remove children of a branch
1022 a = new QAction( tr( "Remove children","Edit menu" ), this);
1023 a->setStatusTip (tr( "Remove children of branch" ));
1024 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
1025 switchboard.addConnection(a,tr("Edit","Shortcut group"));
1026 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChildren() ) );
1027 a->setEnabled (false);
1028 actionListBranches.append(a);
1029 actionDeleteChildren=a;
1031 a = new QAction( tr( "Add Image...","Edit menu" ), this);
1032 a->setStatusTip (tr( "Add Image" ));
1033 switchboard.addConnection(a,tr("Edit","Shortcut group"));
1034 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
1037 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
1038 a->setStatusTip (tr( "Set properties for selection" ));
1039 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
1040 a->setShortcutContext (Qt::WindowShortcut);
1041 a->setToggleAction (true);
1042 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1044 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
1045 actionViewTogglePropertyWindow=a;
1049 void Main::setupFormatActions()
1051 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
1053 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
1054 tb->setObjectName ("formatTB");
1056 QPixmap pix( 16,16);
1057 pix.fill (Qt::black);
1058 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
1059 a->setStatusTip ( tr( "Set Color" ));
1060 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
1062 formatMenu->addAction (a);
1063 actionFormatColor=a;
1064 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
1065 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
1066 a->setShortcut (Qt::CTRL + Qt::Key_K );
1067 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
1068 a->setEnabled (false);
1070 formatMenu->addAction (a);
1071 actionListBranches.append(a);
1072 actionFormatPickColor=a;
1074 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
1075 a->setStatusTip ( tr( "Color branch" ) );
1076 a->setShortcut (Qt::CTRL + Qt::Key_B);
1077 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
1078 a->setEnabled (false);
1080 formatMenu->addAction (a);
1081 actionListBranches.append(a);
1082 actionFormatColorSubtree=a;
1084 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
1085 a->setStatusTip ( tr( "Color Subtree" ));
1086 //FIXME-2 switch back to that a->setShortcut (Qt::CTRL + Qt::Key_T); // Color subtree
1087 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
1088 a->setEnabled (false);
1089 formatMenu->addAction (a);
1091 actionListBranches.append(a);
1092 actionFormatColorSubtree=a;
1094 formatMenu->addSeparator();
1095 actionGroupFormatLinkStyles=new QActionGroup ( this);
1096 actionGroupFormatLinkStyles->setExclusive (true);
1097 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
1098 a->setStatusTip (tr( "Line" ));
1099 a->setToggleAction(true);
1100 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
1101 formatMenu->addAction (a);
1102 actionFormatLinkStyleLine=a;
1103 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
1104 a->setStatusTip (tr( "Line" ));
1105 a->setToggleAction(true);
1106 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
1107 formatMenu->addAction (a);
1108 actionFormatLinkStyleParabel=a;
1109 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
1110 a->setStatusTip (tr( "PolyLine" ));
1111 a->setToggleAction(true);
1112 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
1113 formatMenu->addAction (a);
1114 actionFormatLinkStylePolyLine=a;
1115 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
1116 a->setStatusTip (tr( "PolyParabel" ) );
1117 a->setToggleAction(true);
1118 a->setChecked (true);
1119 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
1120 formatMenu->addAction (a);
1121 actionFormatLinkStylePolyParabel=a;
1123 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
1124 a->setStatusTip (tr( "Hide link" ));
1125 a->setToggleAction(true);
1126 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
1127 actionFormatHideLinkUnselected=a;
1129 formatMenu->addSeparator();
1130 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
1131 a->setStatusTip (tr( "Use same color for links and headings" ));
1132 a->setToggleAction(true);
1133 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
1134 formatMenu->addAction (a);
1135 actionFormatLinkColorHint=a;
1137 pix.fill (Qt::white);
1138 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
1139 a->setStatusTip (tr( "Set Link Color" ));
1140 formatMenu->addAction (a);
1141 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
1142 actionFormatLinkColor=a;
1144 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
1145 a->setStatusTip (tr( "Set Selection Color" ));
1146 formatMenu->addAction (a);
1147 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
1148 actionFormatSelectionColor=a;
1150 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
1151 a->setStatusTip (tr( "Set Background Color" ));
1152 formatMenu->addAction (a);
1153 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
1154 actionFormatBackColor=a;
1156 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
1157 a->setStatusTip (tr( "Set Background image" ));
1158 formatMenu->addAction (a);
1159 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
1160 actionFormatBackImage=a;
1164 void Main::setupViewActions()
1166 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
1167 tb->setLabel( "View Actions" );
1168 tb->setObjectName ("viewTB");
1169 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
1173 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
1174 a->setStatusTip ( tr( "Zoom reset" ) );
1175 a->setShortcut (Qt::CTRL + Qt::Key_0); // Reset zoom
1176 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1178 viewMenu->addAction (a);
1179 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
1181 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
1182 a->setStatusTip (tr( "Zoom in" ));
1183 a->setShortcut(Qt::CTRL + Qt::Key_Plus);
1184 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1186 viewMenu->addAction (a);
1187 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
1189 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
1190 a->setStatusTip (tr( "Zoom out" ));
1191 a->setShortcut(Qt::CTRL + Qt::Key_Minus);
1192 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1194 viewMenu->addAction (a);
1195 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1197 a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
1198 a->setStatusTip (tr( "Show selection" ));
1199 a->setShortcut(Qt::CTRL + Qt::Key_Period);
1200 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1202 viewMenu->addAction (a);
1203 connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
1205 viewMenu->addSeparator();
1207 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
1208 a->setStatusTip ( tr( "Show Note Editor" ));
1209 a->setShortcut ( Qt::CTRL + Qt::Key_E ); // Toggle Note Editor
1210 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1211 a->setToggleAction(true);
1213 viewMenu->addAction (a);
1214 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1215 actionViewToggleNoteEditor=a;
1217 a = new QAction(QPixmap(), tr( "Show tree editor","View action" ),this);
1218 a->setStatusTip ( tr( "Show tree editor" ));
1219 a->setShortcut ( Qt::CTRL + Qt::Key_T ); // Toggle Tree Editor // FIXME-3 originally: color subtree
1220 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1221 a->setToggleAction(true);
1223 viewMenu->addAction (a);
1224 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleTreeEditor() ) );
1225 actionViewToggleTreeEditor=a;
1227 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
1228 a->setStatusTip ( tr( "Show History Window" ));
1229 a->setShortcut ( Qt::CTRL + Qt::Key_H ); // Toggle history window
1230 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1231 a->setToggleAction(true);
1233 viewMenu->addAction (a);
1234 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1235 actionViewToggleHistoryWindow=a;
1237 viewMenu->addAction (actionViewTogglePropertyWindow);
1239 viewMenu->addSeparator();
1241 a = new QAction(tr( "Antialiasing","View action" ),this );
1242 a->setStatusTip ( tr( "Antialiasing" ));
1243 a->setToggleAction(true);
1244 a->setChecked (settings.value("/mainwindow/view/AntiAlias",true).toBool());
1245 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1246 viewMenu->addAction (a);
1247 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
1248 actionViewToggleAntiAlias=a;
1250 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1251 a->setStatusTip (a->text());
1252 a->setToggleAction(true);
1253 a->setChecked (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1254 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1255 viewMenu->addAction (a);
1256 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1257 actionViewToggleSmoothPixmapTransform=a;
1259 a = new QAction(tr( "Next Map","View action" ), this);
1260 a->setStatusTip (a->text());
1261 a->setShortcut (Qt::ALT + Qt::Key_N );
1262 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1263 viewMenu->addAction (a);
1264 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1266 a = new QAction (tr( "Previous Map","View action" ), this );
1267 a->setStatusTip (a->text());
1268 a->setShortcut (Qt::ALT + Qt::Key_P );
1269 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1270 viewMenu->addAction (a);
1271 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1275 void Main::setupModeActions()
1277 //QPopupMenu *menu = new QPopupMenu( this );
1278 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1280 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1281 tb->setObjectName ("modesTB");
1283 actionGroupModModes=new QActionGroup ( this);
1284 actionGroupModModes->setExclusive (true);
1285 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1286 a->setShortcut (Qt::Key_J);
1287 switchboard.addConnection(a,tr("Modes","Shortcut group"));
1288 a->setStatusTip ( tr( "Use modifier to color branches" ));
1289 a->setToggleAction(true);
1291 a->setChecked(true);
1292 actionModModeColor=a;
1294 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1295 a->setShortcut( Qt::Key_K);
1296 switchboard.addConnection(a,tr("Modes","Shortcut group"));
1297 a->setStatusTip( tr( "Use modifier to copy" ));
1298 a->setToggleAction(true);
1300 actionModModeCopy=a;
1302 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1303 a->setShortcut (Qt::Key_L);
1304 switchboard.addConnection(a,tr("Modes","Shortcut group"));
1305 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1306 a->setToggleAction(true);
1308 actionModModeXLink=a;
1312 void Main::setupFlagActions()
1314 // Create System Flags
1317 Flag *flag=new Flag;;
1318 flag->setVisible(true);
1320 flag->load(flagsPath+"flag-note.png");
1321 setupFlag (flag,tb,"system-note",tr("Note","SystemFlag"));
1323 flag->load(flagsPath+"flag-url.png");
1324 setupFlag (flag,tb,"system-url",tr("URL to Document ","SystemFlag"));
1326 flag->load(flagsPath+"flag-url-bugzilla-novell.png");
1327 setupFlag (flag,tb,"system-url-bugzilla-novell",tr("URL to Bugzilla ","SystemFlag"));
1329 flag->load(flagsPath+"flag-vymlink.png");
1330 setupFlag (flag,tb,"system-vymLink",tr("Link to another vym map","SystemFlag"));
1332 flag->load(flagsPath+"flag-scrolled-right.png");
1333 setupFlag (flag,tb,"system-scrolledright",tr("subtree is scrolled","SystemFlag"));
1335 flag->load(flagsPath+"flag-tmpUnscrolled-right.png");
1336 setupFlag (flag,tb,"system-tmpUnscrolledRight",tr("subtree is temporary scrolled","SystemFlag"));
1338 flag->load(flagsPath+"flag-hideexport.png");
1339 setupFlag (flag,tb,"system-hideInExport",tr("Hide object in exported maps","SystemFlag"));
1341 // Create Standard Flags
1342 tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1343 tb->setObjectName ("standardFlagTB");
1344 standardFlagsMaster->setToolBar (tb);
1346 flag->load(flagsPath+"flag-exclamationmark.png");
1347 flag->setGroup("standard-mark");
1348 setupFlag (flag,tb,"exclamationmark",tr("Take care!","Standardflag"));
1350 flag->load(flagsPath+"flag-questionmark.png");
1351 flag->setGroup("standard-mark");
1352 setupFlag (flag,tb,"questionmark",tr("Really?","Standardflag"));
1354 flag->load(flagsPath+"flag-hook-green.png");
1355 flag->setGroup("standard-status");
1356 setupFlag (flag,tb,"hook-green",tr("Status - ok,done","Standardflag"));
1358 flag->load(flagsPath+"flag-wip.png");
1359 flag->setGroup("standard-status");
1360 setupFlag (flag,tb,"wip",tr("Status - work in progress","Standardflag"));
1362 flag->load(flagsPath+"flag-cross-red.png");
1363 flag->setGroup("standard-status");
1364 setupFlag (flag,tb,"cross-red",tr("Status - missing, not started","Standardflag"));
1367 flag->load(flagsPath+"flag-stopsign.png");
1368 setupFlag (flag,tb,"stopsign",tr("This won't work!","Standardflag"));
1370 flag->load(flagsPath+"flag-smiley-good.png");
1371 flag->setGroup("standard-smiley");
1372 setupFlag (flag,tb,"smiley-good",tr("Good","Standardflag"));
1374 flag->load(flagsPath+"flag-smiley-sad.png");
1375 flag->setGroup("standard-smiley");
1376 setupFlag (flag,tb,"smiley-sad",tr("Bad","Standardflag"));
1378 flag->load(flagsPath+"flag-smiley-omg.png");
1379 flag->setGroup("standard-smiley");
1380 setupFlag (flag,tb,"smiley-omb",tr("Oh no!","Standardflag"));
1381 // Original omg.png (in KDE emoticons)
1384 flag->load(flagsPath+"flag-kalarm.png");
1385 setupFlag (flag,tb,"clock",tr("Time critical","Standardflag"));
1387 flag->load(flagsPath+"flag-phone.png");
1388 setupFlag (flag,tb,"phone",tr("Call...","Standardflag"));
1390 flag->load(flagsPath+"flag-lamp.png");
1391 setupFlag (flag,tb,"lamp",tr("Idea!","Standardflag"));
1393 flag->load(flagsPath+"flag-arrow-up.png");
1394 flag->setGroup("standard-arrow");
1395 setupFlag (flag,tb,"arrow-up",tr("Important","Standardflag"));
1397 flag->load(flagsPath+"flag-arrow-down.png");
1398 flag->setGroup("standard-arrow");
1399 setupFlag (flag,tb,"arrow-down",tr("Unimportant","Standardflag"));
1401 flag->load(flagsPath+"flag-arrow-2up.png");
1402 flag->setGroup("standard-arrow");
1403 setupFlag (flag,tb,"2arrow-up",tr("Very important!","Standardflag"));
1405 flag->load(flagsPath+"flag-arrow-2down.png");
1406 flag->setGroup("standard-arrow");
1407 setupFlag (flag,tb,"2arrow-down",tr("Very unimportant!","Standardflag"));
1410 flag->load(flagsPath+"flag-thumb-up.png");
1411 flag->setGroup("standard-thumb");
1412 setupFlag (flag,tb,"thumb-up",tr("I like this","Standardflag"));
1414 flag->load(flagsPath+"flag-thumb-down.png");
1415 flag->setGroup("standard-thumb");
1416 setupFlag (flag,tb,"thumb-down",tr("I do not like this","Standardflag"));
1419 flag->load(flagsPath+"flag-rose.png");
1420 setupFlag (flag,tb,"rose",tr("Rose","Standardflag"));
1422 flag->load(flagsPath+"flag-heart.png");
1423 setupFlag (flag,tb,"heart",tr("I just love...","Standardflag"));
1425 flag->load(flagsPath+"flag-present.png");
1426 setupFlag (flag,tb,"present",tr("Surprise!","Standardflag"));
1428 flag->load(flagsPath+"flag-flash.png");
1429 setupFlag (flag,tb,"flash",tr("Dangerous","Standardflag"));
1431 // Original: xsldbg_output.png
1432 flag->load(flagsPath+"flag-info.png");
1433 setupFlag (flag,tb,"info",tr("Info","Standardflag"));
1435 // Original khelpcenter.png
1436 flag->load(flagsPath+"flag-lifebelt.png");
1437 setupFlag (flag,tb,"lifebelt",tr("This will help","Standardflag"));
1440 flag->setVisible(false);
1441 flag->load(flagsPath+"freemind/warning.png");
1442 setupFlag (flag,tb, "freemind-warning",tr("Important","Freemind-Flag"));
1444 for (int i=1; i<8; i++)
1446 flag->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
1447 setupFlag (flag,tb, QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
1450 flag->load(flagsPath+"freemind/back.png");
1451 setupFlag (flag,tb,"freemind-back",tr("Back","Freemind-Flag"));
1453 flag->load(flagsPath+"freemind/forward.png");
1454 setupFlag (flag,tb,"freemind-forward",tr("forward","Freemind-Flag"));
1456 flag->load(flagsPath+"freemind/attach.png");
1457 setupFlag (flag,tb,"freemind-attach",tr("Look here","Freemind-Flag"));
1459 flag->load(flagsPath+"freemind/clanbomber.png");
1460 setupFlag (flag,tb,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
1462 flag->load(flagsPath+"freemind/desktopnew.png");
1463 setupFlag (flag,tb,"freemind-desktopnew",tr("Don't flagrget","Freemind-Flag"));
1465 flag->load(flagsPath+"freemind/flag.png");
1466 setupFlag (flag,tb,"freemind-flag",tr("Flag","Freemind-Flag"));
1469 flag->load(flagsPath+"freemind/gohome.png");
1470 setupFlag (flag,tb,"freemind-gohome",tr("Home","Freemind-Flag"));
1473 flag->load(flagsPath+"freemind/kaddressbook.png");
1474 setupFlag (flag,tb,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
1476 flag->load(flagsPath+"freemind/knotify.png");
1477 setupFlag (flag,tb,"freemind-knotify",tr("Music","Freemind-Flag"));
1479 flag->load(flagsPath+"freemind/korn.png");
1480 setupFlag (flag,tb,"freemind-korn",tr("Mailbox","Freemind-Flag"));
1482 flag->load(flagsPath+"freemind/mail.png");
1483 setupFlag (flag,tb,"freemind-mail",tr("Maix","Freemind-Flag"));
1485 flag->load(flagsPath+"freemind/password.png");
1486 setupFlag (flag,tb,"freemind-password",tr("Password","Freemind-Flag"));
1488 flag->load(flagsPath+"freemind/pencil.png");
1489 setupFlag (flag,tb,"freemind-pencil",tr("To be improved","Freemind-Flag"));
1491 flag->load(flagsPath+"freemind/stop.png");
1492 setupFlag (flag,tb,"freemind-stop",tr("Stop","Freemind-Flag"));
1494 flag->load(flagsPath+"freemind/wizard.png");
1495 setupFlag (flag,tb,"freemind-wizard",tr("Magic","Freemind-Flag"));
1497 flag->load(flagsPath+"freemind/xmag.png");
1498 setupFlag (flag,tb,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
1500 flag->load(flagsPath+"freemind/bell.png");
1501 setupFlag (flag,tb,"freemind-bell",tr("Reminder","Freemind-Flag"));
1503 flag->load(flagsPath+"freemind/bookmark.png");
1504 setupFlag (flag,tb,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
1506 flag->load(flagsPath+"freemind/penguin.png");
1507 setupFlag (flag,tb,"freemind-penguin",tr("Linux","Freemind-Flag"));
1509 flag->load(flagsPath+"freemind/licq.png");
1510 setupFlag (flag,tb,"freemind-licq",tr("Sweet","Freemind-Flag"));
1513 void Main::setupFlag (Flag *flag, QToolBar *tb, const QString &name, const QString &tooltip)
1515 flag->setName(name);
1516 flag->setToolTip (tooltip);
1520 a=new QAction (flag->getPixmap(),name,this);
1523 flag->setAction (a);
1524 a->setVisible (flag->isVisible());
1525 a->setCheckable(true);
1526 a->setObjectName(name);
1527 a->setToolTip(tooltip);
1528 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1529 standardFlagsMaster->addFlag (flag);
1533 systemFlagsMaster->addFlag (flag);
1538 void Main::setupNetworkActions()
1540 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1542 QMenu *netMenu = menuBar()->addMenu( "Network" );
1546 a = new QAction( "Start TCPserver for MapEditor",this);
1547 //a->setStatusTip ( "Set application to open pdf files"));
1548 //a->setShortcut ( Qt::ALT + Qt::Key_T ); //New TCP server
1549 switchboard.addConnection(a,tr("Network shortcuts","Shortcut group"));
1550 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1551 netMenu->addAction (a);
1553 a = new QAction( "Connect MapEditor to server",this);
1554 //a->setStatusTip ( "Set application to open pdf files"));
1555 a->setShortcut ( Qt::ALT + Qt::Key_C ); // Connect to server
1556 switchboard.addConnection(a,tr("Network shortcuts","Shortcut group"));
1557 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1558 netMenu->addAction (a);
1562 void Main::setupSettingsActions()
1564 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1568 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1569 a->setStatusTip ( tr( "Set application to open pdf files"));
1570 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1571 settingsMenu->addAction (a);
1573 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1574 a->setStatusTip( tr( "Set application to open external links"));
1575 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1576 settingsMenu->addAction (a);
1578 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1579 a->setStatusTip( tr( "Set path for macros"));
1580 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1581 settingsMenu->addAction (a);
1583 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1584 a->setStatusTip( tr( "Set number of undo levels"));
1585 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1586 settingsMenu->addAction (a);
1588 settingsMenu->addSeparator();
1590 a = new QAction( tr( "Autosave","Settings action"), this);
1591 a->setStatusTip( tr( "Autosave"));
1592 a->setToggleAction(true);
1593 a->setChecked ( settings.value ("/mainwindow/autosave/use",false).toBool());
1594 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1595 settingsMenu->addAction (a);
1596 actionSettingsAutosaveToggle=a;
1598 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1599 a->setStatusTip( tr( "Autosave time"));
1600 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1601 settingsMenu->addAction (a);
1602 actionSettingsAutosaveTime=a;
1604 a = new QAction( tr( "Write backup file on save","Settings action"), this);
1605 a->setStatusTip( tr( "Write backup file on save"));
1606 a->setToggleAction(true);
1607 a->setChecked ( settings.value ("/mainwindow/writeBackupFile",false).toBool());
1608 connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) );
1609 settingsMenu->addAction (a);
1610 actionSettingsWriteBackupFile=a;
1612 settingsMenu->addSeparator();
1614 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1615 a->setStatusTip( tr( "Edit branch after adding it" ));
1616 a->setToggleAction(true);
1617 a->setChecked ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1618 settingsMenu->addAction (a);
1619 actionSettingsAutoEditNewBranch=a;
1621 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1622 a->setStatusTip( tr( "Select branch after adding it" ));
1623 a->setToggleAction(true);
1624 a->setChecked ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1625 settingsMenu->addAction (a);
1626 actionSettingsAutoSelectNewBranch=a;
1628 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1629 a->setStatusTip( tr( "Select heading before editing" ));
1630 a->setToggleAction(true);
1631 a->setChecked ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1632 settingsMenu->addAction (a);
1633 actionSettingsAutoSelectText=a;
1635 a= new QAction( tr( "Delete key","Settings action" ), this);
1636 a->setStatusTip( tr( "Delete key for deleting branches" ));
1637 a->setToggleAction(true);
1638 a->setChecked ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1639 settingsMenu->addAction (a);
1640 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1641 actionSettingsUseDelKey=a;
1643 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1644 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1645 a->setToggleAction(true);
1646 a->setChecked ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1647 settingsMenu->addAction (a);
1648 actionSettingsUseFlagGroups=a;
1650 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1651 a->setStatusTip( tr( "Use hide flag during exports " ));
1652 a->setToggleAction(true);
1653 a->setChecked ( settings.value ("/export/useHideExport",true).toBool() );
1654 settingsMenu->addAction (a);
1655 actionSettingsUseHideExport=a;
1657 a = new QAction( tr( "Animation","Settings action"), this);
1658 a->setStatusTip( tr( "Animation"));
1659 a->setToggleAction(true);
1660 a->setChecked (settings.value("/animation/use",true).toBool() );
1661 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) );
1662 settingsMenu->addAction (a);
1663 actionSettingsUseAnimation=a;
1667 void Main::setupTestActions()
1669 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1672 a = new QAction( "Test function 1" , this);
1673 a->setStatusTip( "Call test function 1" );
1674 a->setShortcut (Qt::SHIFT + Qt::Key_T); // Test function 1
1675 switchboard.addConnection(a,tr("Test shortcuts","Shortcut group"));
1676 testMenu->addAction (a);
1677 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1679 a = new QAction( "Test function 2" , this);
1680 a->setStatusTip( "Call test function 2" );
1681 a->setShortcut (Qt::ALT + Qt::Key_T); // Test function 2
1682 switchboard.addConnection(a,tr("Test shortcuts","Shortcut group"));
1683 testMenu->addAction (a);
1684 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1686 a = new QAction( "Command" , this);
1687 a->setStatusTip( "Enter command to call in editor" );
1688 switchboard.addConnection(a,tr("Test shortcuts","Shortcut group"));
1689 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1690 testMenu->addAction (a);
1694 void Main::setupHelpActions()
1696 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1699 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1700 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1701 switchboard.addConnection(a,tr("Help shortcuts","Shortcut group"));
1702 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1703 helpMenu->addAction (a);
1705 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1706 a->setStatusTip( tr( "Open VYM example maps " ));
1707 switchboard.addConnection(a,tr("Help shortcuts","Shortcut group"));
1708 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1709 helpMenu->addAction (a);
1711 a = new QAction( tr( "About VYM","Help action" ), this);
1712 a->setStatusTip( tr( "About VYM")+vymName);
1713 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1714 helpMenu->addAction (a);
1716 a = new QAction( tr( "About QT","Help action" ), this);
1717 a->setStatusTip( tr( "Information about QT toolkit" ));
1718 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1719 helpMenu->addAction (a);
1723 void Main::setupContextMenus()
1727 // Context Menu for branch or mapcenter
1728 branchContextMenu =new QMenu (this);
1729 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1730 branchContextMenu->addSeparator();
1733 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1734 branchAddContextMenu->addAction (actionPaste );
1735 branchAddContextMenu->addAction ( actionAddMapCenter );
1736 branchAddContextMenu->addAction ( actionAddBranch );
1737 branchAddContextMenu->addAction ( actionAddBranchBefore );
1738 branchAddContextMenu->addAction ( actionAddBranchAbove);
1739 branchAddContextMenu->addAction ( actionAddBranchBelow );
1740 branchAddContextMenu->addSeparator();
1741 branchAddContextMenu->addAction ( actionImportAdd );
1742 branchAddContextMenu->addAction ( actionImportReplace );
1745 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1746 branchRemoveContextMenu->addAction (actionCut);
1747 branchRemoveContextMenu->addAction ( actionDelete );
1748 branchRemoveContextMenu->addAction ( actionDeleteKeepChildren );
1749 branchRemoveContextMenu->addAction ( actionDeleteChildren );
1752 actionSaveBranch->addTo( branchContextMenu );
1753 actionFileNewCopy->addTo (branchContextMenu );
1754 actionDetach->addTo (branchContextMenu );
1756 branchContextMenu->addSeparator();
1757 branchContextMenu->addAction ( actionLoadImage);
1758 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1759 branchContextMenu->addAction ( actionAddAttribute);
1761 // Submenu for Links (URLs, vymLinks)
1762 branchLinksContextMenu =new QMenu (this);
1764 branchContextMenu->addSeparator();
1765 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1766 branchLinksContextMenu->addAction ( actionOpenURL );
1767 branchLinksContextMenu->addAction ( actionOpenURLTab );
1768 branchLinksContextMenu->addAction ( actionOpenMultipleVisURLTabs );
1769 branchLinksContextMenu->addAction ( actionOpenMultipleURLTabs );
1770 branchLinksContextMenu->addAction ( actionURL );
1771 branchLinksContextMenu->addAction ( actionLocalURL );
1772 branchLinksContextMenu->addAction ( actionHeading2URL );
1773 branchLinksContextMenu->addAction ( actionBugzilla2URL );
1774 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1776 branchLinksContextMenu->addAction ( actionGetBugzillaData );
1777 branchLinksContextMenu->addAction ( actionFATE2URL );
1779 branchLinksContextMenu->addSeparator();
1780 branchLinksContextMenu->addAction ( actionOpenVymLink );
1781 branchLinksContextMenu->addAction ( actionOpenMultipleVymLinks );
1782 branchLinksContextMenu->addAction ( actionVymLink );
1783 branchLinksContextMenu->addAction ( actionDeleteVymLink );
1786 // Context Menu for XLinks in a branch menu
1787 // This will be populated "on demand" in MapEditor::updateActions
1788 branchContextMenu->addSeparator();
1789 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1790 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1793 // Context menu for floatimage
1794 floatimageContextMenu =new QMenu (this);
1795 a= new QAction (tr ("Save image","Context action"),this);
1796 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1797 floatimageContextMenu->addAction (a);
1799 floatimageContextMenu->addSeparator();
1800 actionCopy->addTo( floatimageContextMenu );
1801 actionCut->addTo( floatimageContextMenu );
1803 floatimageContextMenu->addSeparator();
1804 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1807 // Context menu for canvas
1808 canvasContextMenu =new QMenu (this);
1809 actionAddMapCenter->addTo( canvasContextMenu );
1810 actionMapInfo->addTo( canvasContextMenu );
1811 canvasContextMenu->insertSeparator();
1812 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1813 canvasContextMenu->insertSeparator();
1814 actionFormatLinkColorHint->addTo( canvasContextMenu );
1815 actionFormatLinkColor->addTo( canvasContextMenu );
1816 actionFormatSelectionColor->addTo( canvasContextMenu );
1817 actionFormatBackColor->addTo( canvasContextMenu );
1818 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME-4 makes vym too slow: postponed for later version
1820 // Menu for last opened files
1822 for (int i = 0; i < MaxRecentFiles; ++i)
1824 recentFileActions[i] = new QAction(this);
1825 recentFileActions[i]->setVisible(false);
1826 fileLastMapsMenu->addAction(recentFileActions[i]);
1827 connect(recentFileActions[i], SIGNAL(triggered()),
1828 this, SLOT(fileLoadRecent()));
1830 setupRecentMapsMenu();
1833 void Main::setupRecentMapsMenu()
1835 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1837 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1839 for (int i = 0; i < numRecentFiles; ++i) {
1840 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1841 recentFileActions[i]->setText(text);
1842 recentFileActions[i]->setData(files[i]);
1843 recentFileActions[i]->setVisible(true);
1845 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1846 recentFileActions[j]->setVisible(false);
1849 void Main::setupMacros()
1851 for (int i = 0; i <= 11; i++)
1853 macroActions[i] = new QAction(this);
1854 macroActions[i]->setData(i);
1855 addAction (macroActions[i]);
1856 //switchboard.addConnection(macroActions[i],tr("Macro shortcuts","Shortcut group"));
1857 connect(macroActions[i], SIGNAL(triggered()),
1858 this, SLOT(callMacro()));
1860 macroActions[0]->setShortcut ( Qt::Key_F1 );
1861 macroActions[1]->setShortcut ( Qt::Key_F2 );
1862 macroActions[2]->setShortcut ( Qt::Key_F3 );
1863 macroActions[3]->setShortcut ( Qt::Key_F4 );
1864 macroActions[4]->setShortcut ( Qt::Key_F5 );
1865 macroActions[5]->setShortcut ( Qt::Key_F6 );
1866 macroActions[6]->setShortcut ( Qt::Key_F7 );
1867 macroActions[7]->setShortcut ( Qt::Key_F8 );
1868 macroActions[8]->setShortcut ( Qt::Key_F9 );
1869 macroActions[9]->setShortcut ( Qt::Key_F10 );
1870 macroActions[10]->setShortcut ( Qt::Key_F11 );
1871 macroActions[11]->setShortcut ( Qt::Key_F12 );
1874 void Main::hideEvent (QHideEvent * )
1876 if (!textEditor->isMinimized() ) textEditor->hide();
1879 void Main::showEvent (QShowEvent * )
1881 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1885 MapEditor* Main::currentMapEditor() const
1887 if ( tabWidget->currentPage())
1888 return vymViews.at(tabWidget->currentIndex())->getMapEditor();
1892 VymModel* Main::currentModel() const
1894 if ( tabWidget->currentPage())
1895 return vymViews.at(tabWidget->currentIndex())->getModel();
1899 VymModel* Main::getModel(uint id) const
1901 if ( tabWidget->currentPage())
1902 return vymViews.at(tabWidget->currentIndex())->getModel();
1907 void Main::editorChanged(QWidget *)
1909 // Unselect all possibly selected objects
1910 // (Important to update note editor)
1912 for (int i=0;i<=tabWidget->count() -1;i++)
1914 m= vymViews.at(i)->getModel();
1915 if (m) m->unselect();
1918 if (m) m->reselect();
1920 // Update actions to in menus and toolbars according to editor
1924 void Main::fileNew()
1926 VymModel *vm=new VymModel;
1928 /////////////////////////////////////
1929 // new ModelTest(vm, this); //FIXME-3
1930 /////////////////////////////////////
1932 VymView *vv=new VymView (vm);
1933 vymViews.append (vv);
1934 tabWidget->addTab (vv,tr("unnamed","MainWindow: name for new and empty file"));
1935 tabWidget->setCurrentIndex (vymViews.count() );
1938 // Create MapCenter for empty map
1942 // For the very first map we do not have flagrows yet...
1946 void Main::fileNewCopy()
1948 QString fn="unnamed";
1949 VymModel *srcModel=currentModel();
1954 VymModel *dstModel=vymViews.last()->getModel();
1955 dstModel->select("mc:");
1956 dstModel->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
1960 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
1962 ErrorCode err=success;
1964 // fn is usually the archive, mapfile the file after uncompressing
1967 // Make fn absolute (needed for unzip)
1968 fn=QDir (fn).absPath();
1974 // Check, if map is already loaded
1976 while (i<=tabWidget->count() -1)
1978 if (vymViews.at(i)->getModel()->getFilePath() == fn)
1980 // Already there, ask for confirmation
1981 QMessageBox mb( vymName,
1982 tr("The map %1\nis already opened."
1983 "Opening the same map in multiple editors may lead \n"
1984 "to confusion when finishing working with vym."
1985 "Do you want to").arg(fn),
1986 QMessageBox::Warning,
1987 QMessageBox::Yes | QMessageBox::Default,
1988 QMessageBox::Cancel | QMessageBox::Escape,
1989 QMessageBox::NoButton);
1990 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1991 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1994 case QMessageBox::Yes:
1995 // end loop and load anyway
1996 i=tabWidget->count();
1998 case QMessageBox::Cancel:
2008 int tabIndex=tabWidget->currentPageIndex();
2011 if ( !fn.isEmpty() )
2013 vm = currentModel();
2014 // Check first, if mapeditor exists
2015 // If it is not default AND we want a new map,
2016 // create a new mapeditor in a new tab
2017 if ( lmode==NewMap && (!vm || !vm->isDefault() ) )
2020 VymView *vv=new VymView (vm);
2021 vymViews.append (vv);
2022 tabWidget->addTab (vv,fn);
2023 tabIndex=tabWidget->count()-1;
2024 tabWidget->setCurrentPage (tabIndex);
2028 // Check, if file exists (important for creating new files
2029 // from command line
2030 if (!QFile(fn).exists() )
2032 QMessageBox mb( vymName,
2033 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
2034 QMessageBox::Question,
2036 QMessageBox::Cancel | QMessageBox::Default,
2037 QMessageBox::NoButton );
2039 mb.setButtonText( QMessageBox::Yes, tr("Create"));
2040 mb.setButtonText( QMessageBox::No, tr("Cancel"));
2043 case QMessageBox::Yes:
2045 currentMapEditor()->getModel()->setFilePath(fn);
2046 tabWidget->setTabText (tabIndex,
2047 currentMapEditor()->getModel()->getFileName() );
2048 statusBar()->message( "Created " + fn , statusbarTime );
2051 case QMessageBox::Cancel:
2052 // don't create new map
2053 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
2060 //tabWidget->currentPage() won't be NULL here, because of above...
2061 tabWidget->setCurrentIndex (tabIndex);
2062 //FIXME-3 no me anymore... me->viewport()->setFocus();
2066 // Save existing filename in case we import
2067 QString fn_org=vm->getFilePath();
2069 // Finally load map into mapEditor
2070 vm->setFilePath (fn);
2071 err=vm->load(fn,lmode,ftype);
2073 // Restore old (maybe empty) filepath, if this is an import
2075 vm->setFilePath (fn_org);
2078 // Finally check for errors and go home
2081 if (lmode==NewMap) fileCloseMap();
2082 statusBar()->message( "Could not load " + fn, statusbarTime );
2087 vm->setFilePath (fn);
2088 tabWidget->setTabText (tabIndex, vm->getFileName());
2089 if (!isInTmpDir (fn))
2091 // Only append to lastMaps if not loaded from a tmpDir
2092 // e.g. imported bookmarks are in a tmpDir
2093 addRecentMap(vm->getFilePath() );
2095 actionFilePrint->setEnabled (true);
2097 statusBar()->message( "Loaded " + fn, statusbarTime );
2104 void Main::fileLoad(const LoadMode &lmode)
2106 QStringList filters;
2107 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
2108 QFileDialog *fd=new QFileDialog( this);
2109 fd->setDir (lastFileDir);
2110 fd->setFileMode (QFileDialog::ExistingFiles);
2111 fd->setFilters (filters);
2115 fd->setCaption(vymName+ " - " +tr("Load vym map"));
2118 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
2121 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
2127 if ( fd->exec() == QDialog::Accepted )
2129 lastFileDir=fd->directory().path();
2130 QStringList flist = fd->selectedFiles();
2131 QStringList::Iterator it = flist.begin();
2133 progressCounter=flist.count();
2134 progressCounterTotal=flist.count();
2135 while( it != flist.end() )
2138 fileLoad(*it, lmode);
2145 void Main::fileLoad()
2150 void Main::fileLoadRecent()
2152 QAction *action = qobject_cast<QAction *>(sender());
2154 fileLoad (action->data().toString(), NewMap);
2157 void Main::addRecentMap (const QString &fileName)
2160 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
2161 files.removeAll(fileName);
2162 files.prepend(fileName);
2163 while (files.size() > MaxRecentFiles)
2166 settings.setValue("/mainwindow/recentFileList", files);
2168 setupRecentMapsMenu();
2171 void Main::fileSave(VymModel *m, const SaveMode &savemode)
2175 if ( m->getFilePath().isEmpty() )
2177 // We have no filepath yet,
2178 // call fileSaveAs() now, this will call fileSave()
2180 // First switch to editor
2181 //FIXME-3 needed??? tabWidget->setCurrentWidget (m->getMapEditor());
2182 fileSaveAs(savemode);
2185 if (m->save (savemode)==success)
2187 statusBar()->message(
2188 tr("Saved %1").arg(m->getFilePath()),
2190 addRecentMap (m->getFilePath() );
2192 statusBar()->message(
2193 tr("Couldn't save ").arg(m->getFilePath()),
2197 void Main::fileSave()
2199 fileSave (currentModel(), CompleteMap);
2202 void Main::fileSave(VymModel *m)
2204 fileSave (m,CompleteMap);
2207 void Main::fileSaveAs(const SaveMode& savemode)
2211 if (currentMapEditor())
2213 if (savemode==CompleteMap)
2214 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2216 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2217 if ( !fn.isEmpty() )
2219 // Check for existing file
2220 if (QFile (fn).exists())
2222 QMessageBox mb( vymName,
2223 tr("The file %1\nexists already. Do you want to").arg(fn),
2224 QMessageBox::Warning,
2225 QMessageBox::Yes | QMessageBox::Default,
2226 QMessageBox::Cancel | QMessageBox::Escape,
2227 QMessageBox::NoButton);
2228 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2229 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2232 case QMessageBox::Yes:
2235 case QMessageBox::Cancel:
2242 // New file, add extension to filename, if missing
2243 // This is always .vym or .vyp, depending on savemode
2244 if (savemode==CompleteMap)
2246 if (!fn.contains (".vym") && !fn.contains (".xml"))
2250 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2259 VymModel *m=currentModel();
2261 fileSave(m, savemode);
2263 // Set name of tab, assuming current tab is the one we just saved
2264 if (savemode==CompleteMap)
2265 tabWidget->setTabText (tabWidget->currentIndex(), m->getFileName() );
2271 void Main::fileSaveAs()
2273 fileSaveAs (CompleteMap);
2276 void Main::fileImportKDE3Bookmarks()
2278 ImportKDE3Bookmarks im;
2280 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2281 currentMapEditor()->getModel()->setFilePath ("");
2284 void Main::fileImportKDE4Bookmarks()
2286 ImportKDE4Bookmarks im;
2288 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2289 currentMapEditor()->getModel()->setFilePath ("");
2292 void Main::fileImportFirefoxBookmarks()
2294 Q3FileDialog *fd=new Q3FileDialog( this);
2295 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2296 fd->setMode (Q3FileDialog::ExistingFiles);
2297 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2298 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2301 if ( fd->exec() == QDialog::Accepted )
2303 ImportFirefoxBookmarks im;
2304 QStringList flist = fd->selectedFiles();
2305 QStringList::Iterator it = flist.begin();
2306 while( it != flist.end() )
2309 if (im.transform() &&
2310 aborted!=fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2311 currentMapEditor() )
2312 currentMapEditor()->getModel()->setFilePath ("");
2319 void Main::fileImportFreemind()
2321 QStringList filters;
2322 filters <<"Freemind map (*.mm)"<<"All files (*)";
2323 QFileDialog *fd=new QFileDialog( this);
2324 fd->setDir (lastFileDir);
2325 fd->setFileMode (QFileDialog::ExistingFiles);
2326 fd->setFilters (filters);
2327 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2331 if ( fd->exec() == QDialog::Accepted )
2333 lastFileDir=fd->directory().path();
2334 QStringList flist = fd->selectedFiles();
2335 QStringList::Iterator it = flist.begin();
2336 while( it != flist.end() )
2339 if ( fileLoad (fn,NewMap, FreemindMap) )
2341 currentMapEditor()->getModel()->setFilePath ("");
2350 void Main::fileImportMM()
2354 Q3FileDialog *fd=new Q3FileDialog( this);
2355 fd->setDir (lastFileDir);
2356 fd->setMode (Q3FileDialog::ExistingFiles);
2357 fd->addFilter ("Mind Manager (*.mmap)");
2358 fd->setCaption(tr("Import")+" "+"Mind Manager");
2361 if ( fd->exec() == QDialog::Accepted )
2363 lastFileDir=fd->dirPath();
2364 QStringList flist = fd->selectedFiles();
2365 QStringList::Iterator it = flist.begin();
2366 while( it != flist.end() )
2369 if (im.transform() &&
2370 success==fileLoad (im.getTransformedFile(),NewMap) &&
2371 currentMapEditor() )
2372 currentMapEditor()->getModel()->setFilePath ("");
2379 void Main::fileImportDir()
2381 VymModel *m=currentModel();
2382 if (m) m->importDir();
2385 void Main::fileExportXML()
2387 VymModel *m=currentModel();
2388 if (m) m->exportXML();
2391 void Main::fileExportHTML()
2393 VymModel *m=currentModel();
2394 if (m) m->exportHTML();
2398 void Main::fileExportXHTML()
2400 VymModel *m=currentModel();
2401 if (m) m->exportXHTML();
2404 void Main::fileExportImage()
2406 VymModel *m=currentModel();
2407 if (m) m->exportImage();
2410 void Main::fileExportAO()
2412 VymModel *m=currentModel();
2413 if (m) m->exportAO();
2416 void Main::fileExportASCII()
2418 VymModel *m=currentModel();
2419 if (m) m->exportASCII();
2422 void Main::fileExportCSV() //FIXME-3 not scriptable yet
2424 VymModel *m=currentModel();
2429 ex.addFilter ("CSV (*.csv)");
2430 ex.setDir(lastImageDir);
2431 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2432 if (ex.execDialog() )
2434 m->setExportMode(true);
2436 m->setExportMode(false);
2441 void Main::fileExportLaTeX() //FIXME-3 not scriptable yet
2443 VymModel *m=currentModel();
2448 ex.addFilter ("Tex (*.tex)");
2449 ex.setDir(lastImageDir);
2450 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2451 if (ex.execDialog() )
2453 m->setExportMode(true);
2455 m->setExportMode(false);
2460 void Main::fileExportKDE3Bookmarks() //FIXME-3 not scriptable yet
2462 ExportKDE3Bookmarks ex;
2463 VymModel *m=currentModel();
2471 void Main::fileExportKDE4Bookmarks() //FIXME-3 not scriptable yet
2473 ExportKDE4Bookmarks ex;
2474 VymModel *m=currentModel();
2482 void Main::fileExportTaskjuggler() //FIXME-3 not scriptable yet
2484 ExportTaskjuggler ex;
2485 VymModel *m=currentModel();
2489 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2490 ex.setDir(lastImageDir);
2491 ex.addFilter ("Taskjuggler (*.tjp)");
2492 if (ex.execDialog() )
2494 m->setExportMode(true);
2496 m->setExportMode(false);
2501 void Main::fileExportOOPresentation() //FIXME-3 not scriptable yet
2503 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2504 // TODO add preview in dialog
2505 //ImagePreview *p =new ImagePreview (fd);
2506 //fd->setContentsPreviewEnabled( TRUE );
2507 //fd->setContentsPreview( p, p );
2508 //fd->setPreviewMode( QFileDialog::Contents );
2509 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2510 fd->setDir (QDir().current());
2511 if (fd->foundConfig())
2515 if ( fd->exec() == QDialog::Accepted )
2517 QString fn=fd->selectedFile();
2518 if (!fn.contains (".odp"))
2521 //lastImageDir=fn.left(fn.findRev ("/"));
2522 VymModel *m=currentModel();
2523 if (m) m->exportOOPresentation(fn,fd->selectedConfig());
2527 QMessageBox::warning(0,
2529 tr("Couldn't find configuration for export to Open Office\n"));
2533 void Main::fileCloseMap()
2535 VymModel *m=currentModel();
2538 if (m->hasChanged())
2540 QMessageBox mb( vymName,
2541 tr("The map %1 has been modified but not saved yet. Do you want to").arg(m->getFileName()),
2542 QMessageBox::Warning,
2543 QMessageBox::Yes | QMessageBox::Default,
2545 QMessageBox::Cancel | QMessageBox::Escape );
2546 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2547 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2550 case QMessageBox::Yes:
2552 fileSave(m, CompleteMap);
2554 case QMessageBox::No:
2555 // close without saving
2557 case QMessageBox::Cancel:
2562 // And here comes the segfault, because removeTab triggers
2563 // FIXME-3 currentChanged->Main::editorChanged -> updateActions and VM is not NULL yet...
2564 vymViews.removeAt (tabWidget->currentIndex() );
2565 tabWidget->removeTab (tabWidget->currentIndex() );
2567 // Remove mapEditor/model FIXME-3 Huh? seems to work now...
2568 // Better would be delete (me), but then we could have a Qt error:
2569 // "QObject: Do not delete object, 'MapEditor', during its event handler!"
2570 // So we only remove data now and call deconstructor when vym closes later
2571 // this needs to be moved to vymview... me->clear();
2572 // some model->clear is needed to free up memory ...
2574 delete (m->getMapEditor());
2581 void Main::filePrint()
2583 if (currentMapEditor())
2584 currentMapEditor()->print();
2587 void Main::fileExitVYM()
2589 // Check if one or more editors have changed
2591 for (i=0;i<=vymViews.count() -1;i++)
2593 // If something changed, ask what to do
2594 if (vymViews.at(i)->getModel()->hasChanged())
2596 tabWidget->setCurrentPage(i);
2597 QMessageBox mb( vymName,
2598 tr("This map is not saved yet. Do you want to"),
2599 QMessageBox::Warning,
2600 QMessageBox::Yes | QMessageBox::Default,
2602 QMessageBox::Cancel | QMessageBox::Escape );
2603 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2604 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2607 mb.setActiveWindow();
2608 switch( mb.exec() ) {
2609 case QMessageBox::Yes:
2610 // save (the changed editors) and exit
2611 fileSave(currentModel(), CompleteMap);
2613 case QMessageBox::No:
2614 // exit without saving
2616 case QMessageBox::Cancel:
2617 // don't save and don't exit
2621 } // loop over all MEs
2625 void Main::editUndo()
2627 VymModel *m=currentModel();
2631 void Main::editRedo()
2633 VymModel *m=currentModel();
2637 void Main::gotoHistoryStep (int i)
2639 VymModel *m=currentModel();
2640 if (m) m->gotoHistoryStep(i);
2643 void Main::editCopy()
2645 VymModel *m=currentModel();
2649 void Main::editPaste()
2651 VymModel *m=currentModel();
2655 void Main::editCut()
2657 VymModel *m=currentModel();
2661 void Main::editOpenFindWidget()
2663 VymModel *m=currentModel();
2664 if (m) m->emitShowFindWidget();
2667 void Main::editFindDuplicateURLs()
2669 VymModel *m=currentModel();
2670 if (m) m->findDuplicateURLs();
2673 void Main::openTabs(QStringList urls)
2675 if (!urls.isEmpty())
2679 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2680 //qDebug ()<<"Services: "<<QDBusConnection::sessionBus().interface()->registeredServiceNames().value();
2681 if (*browserPID==0 ||
2682 (browser.contains("konqueror") &&
2683 !QDBusConnection::sessionBus().interface()->registeredServiceNames().value().contains (QString("org.kde.konqueror-%1").arg(*browserPID)))
2686 // Start a new browser, if there is not one running already or
2687 // if a previously started konqueror is gone.
2688 if (debug) cout <<"Main::openTabs no konqueror-"<<*browserPID<<" found\n";
2689 QString u=urls.takeFirst();
2691 QString workDir=QDir::currentDirPath();
2692 if (!QProcess::startDetached(browser,args,workDir,browserPID))
2694 // try to set path to browser
2695 QMessageBox::warning(0,
2697 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2698 tr("Please use Settings->")+tr("Set application to open an URL"));
2701 if (debug) cout << "Main::openTabs Started konqueror-"<<*browserPID<<endl;
2702 #if defined(Q_OS_WIN32)
2703 // There's no sleep in VCEE, replace it with Qt's QThread::wait().
2704 this->thread()->wait(3000);
2706 sleep (3); //FIXME-3 needed?
2710 if (browser.contains("konqueror"))
2712 for (int i=0; i<urls.size(); i++)
2715 // Try to open new tab in existing konqueror started previously by vym
2719 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2720 "konqueror-mainwindow#1"<<
2724 args<< QString("org.kde.konqueror-%1").arg(*browserPID)<<
2725 "/konqueror/MainWindow_1"<<
2729 if (debug) cout << "MainWindow::openURLs args="<<args.join(" ").toStdString()<<endl;
2730 if (!QProcess::startDetached ("qdbus",args))
2734 QMessageBox::warning(0,
2736 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2738 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2740 for (int i=0; i<urls.size(); i++)
2742 // Try to open new tab in firefox
2743 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2744 if (!QProcess::startDetached (browser,args))
2748 QMessageBox::warning(0,
2750 tr("Couldn't start %1 to open a new tab").arg(browser));
2753 QMessageBox::warning(0,
2755 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2759 void Main::editOpenURL()
2762 VymModel *m=currentModel();
2765 QString url=m->getURL();
2767 if (url=="") return;
2768 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2770 QString workDir=QDir::currentDirPath();
2771 if (!procBrowser->startDetached(browser,args))
2773 // try to set path to browser
2774 QMessageBox::warning(0,
2776 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2777 tr("Please use Settings->")+tr("Set application to open an URL"));
2782 void Main::editOpenURLTab()
2784 VymModel *m=currentModel();
2788 urls.append(m->getURL());
2793 void Main::editOpenMultipleVisURLTabs(bool ignoreScrolled)
2795 VymModel *m=currentModel();
2799 urls=m->getURLs(ignoreScrolled);
2804 void Main::editOpenMultipleURLTabs()
2806 editOpenMultipleVisURLTabs (false);
2810 void Main::editURL()
2812 VymModel *m=currentModel();
2813 if (m) m->editURL();
2816 void Main::editLocalURL()
2818 VymModel *m=currentModel();
2819 if (m) m->editLocalURL();
2822 void Main::editHeading2URL()
2824 VymModel *m=currentModel();
2825 if (m) m->editHeading2URL();
2828 void Main::editBugzilla2URL()
2830 VymModel *m=currentModel();
2831 if (m) m->editBugzilla2URL();
2834 void Main::getBugzillaData()
2836 VymModel *m=currentModel();
2838 QProgressDialog progress ("Doing stuff","cancl",0,10,this);
2839 progress.setWindowModality(Qt::WindowModal);
2840 //progress.setCancelButton (NULL);
2842 progress.setMinimumDuration (0);
2843 progress.setValue (1);
2844 progress.setValue (5);
2848 QProgressBar *pb=new QProgressBar;
2854 if (m) m->getBugzillaData();
2857 void Main::editFATE2URL()
2859 VymModel *m=currentModel();
2860 if (m) m->editFATE2URL();
2863 void Main::editHeadingFinished(VymModel *m)
2867 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2868 !prevSelection.isEmpty())
2869 m->select(prevSelection);
2874 void Main::openVymLinks(const QStringList &vl)
2876 for (int j=0; j<vl.size(); j++)
2878 // compare path with already loaded maps
2881 for (i=0;i<=vymViews.count() -1;i++)
2883 if (vl.at(j)==vymViews.at(i)->getModel()->getFilePath() )
2892 if (!QFile(vl.at(j)).exists() )
2893 QMessageBox::critical( 0, tr( "Critical Error" ),
2894 tr("Couldn't open map %1").arg(vl.at(j)));
2897 fileLoad (vl.at(j), NewMap);
2898 tabWidget->setCurrentIndex (tabWidget->count()-1);
2901 // Go to tab containing the map
2902 tabWidget->setCurrentIndex (index);
2906 void Main::editOpenVymLink()
2908 VymModel *m=currentModel();
2912 vl.append(m->getVymLink());
2917 void Main::editOpenMultipleVymLinks()
2919 QString currentVymLink;
2920 VymModel *m=currentModel();
2923 QStringList vl=m->getVymLinks();
2928 void Main::editVymLink()
2930 VymModel *m=currentModel();
2935 void Main::editDeleteVymLink()
2937 VymModel *m=currentModel();
2938 if (m) m->deleteVymLink();
2941 void Main::editToggleHideExport()
2943 VymModel *m=currentModel();
2944 if (m) m->toggleHideExport();
2947 void Main::editAddTimestamp()
2949 VymModel *m=currentModel();
2950 if (m) m->addTimestamp();
2953 void Main::editMapInfo()
2955 VymModel *m=currentModel();
2958 ExtraInfoDialog dia;
2959 dia.setMapName (m->getFileName() );
2960 dia.setAuthor (m->getAuthor() );
2961 dia.setComment(m->getComment() );
2965 stats+=tr("%1 items on map\n","Info about map").arg (m->getScene()->items().size(),6);
2971 BranchItem *cur=NULL;
2972 BranchItem *prev=NULL;
2973 m->nextBranch(cur,prev);
2976 if (!cur->getNote().isEmpty() ) n++;
2977 f+= cur->imageCount();
2979 xl+=cur->xlinkCount();
2980 m->nextBranch(cur,prev);
2983 stats+=QString ("%1 xLinks \n").arg (xl,6);
2984 stats+=QString ("%1 notes\n").arg (n,6);
2985 stats+=QString ("%1 images\n").arg (f,6);
2986 stats+=QString ("%1 branches\n").arg (m->branchCount(),6);
2987 dia.setStats (stats);
2989 // Finally show dialog
2990 if (dia.exec() == QDialog::Accepted)
2992 m->setAuthor (dia.getAuthor() );
2993 m->setComment (dia.getComment() );
2997 void Main::editMoveUp()
2999 VymModel *m=currentModel();
3003 void Main::editMoveDown()
3005 VymModel *m=currentModel();
3006 if (m) m->moveDown();
3009 void Main::editDetach()
3011 VymModel *m=currentModel();
3015 void Main::editSortChildren()
3017 VymModel *m=currentModel();
3018 if (m) m->sortChildren(false);
3021 void Main::editSortBackChildren()
3023 VymModel *m=currentModel();
3024 if (m) m->sortChildren(true);
3027 void Main::editToggleScroll()
3029 VymModel *m=currentModel();
3030 if (m) m->toggleScroll();
3033 void Main::editExpandAll()
3035 VymModel *m=currentModel();
3036 if (m) m->emitExpandAll();
3039 void Main::editExpandOneLevel()
3041 VymModel *m=currentModel();
3042 if (m) m->emitExpandOneLevel();
3045 void Main::editCollapseOneLevel()
3047 VymModel *m=currentModel();
3048 if (m) m->emitCollapseOneLevel();
3051 void Main::editUnscrollChildren()
3053 VymModel *m=currentModel();
3054 if (m) m->unscrollChildren();
3057 void Main::editAddAttribute()
3059 VymModel *m=currentModel();
3067 void Main::editAddMapCenter()
3069 VymModel *m=currentModel();
3070 if (m) m->addMapCenter ();
3073 void Main::editNewBranch()
3075 VymModel *m=currentModel();
3078 BranchItem *bi=m->addNewBranch();
3081 if (actionSettingsAutoEditNewBranch->isOn()
3082 && !actionSettingsAutoSelectNewBranch->isOn() )
3083 prevSelection=m->getSelectString();
3085 prevSelection=QString();
3087 if (actionSettingsAutoSelectNewBranch->isOn()
3088 || actionSettingsAutoEditNewBranch->isOn())
3091 if (actionSettingsAutoEditNewBranch->isOn())
3092 currentMapEditor()->editHeading();
3097 void Main::editNewBranchBefore()
3099 VymModel *m=currentModel();
3102 BranchItem *bi=m->addNewBranchBefore();
3109 if (actionSettingsAutoEditNewBranch->isOn())
3111 if (!actionSettingsAutoSelectNewBranch->isOn())
3112 prevSelection=m->getSelectString(bi);
3113 currentMapEditor()->editHeading();
3118 void Main::editNewBranchAbove()
3120 VymModel *m=currentModel();
3123 BranchItem *bi=m->addNewBranch (-1);
3131 if (actionSettingsAutoEditNewBranch->isOn())
3133 if (!actionSettingsAutoSelectNewBranch->isOn())
3134 prevSelection=m->getSelectString (bi);
3135 currentMapEditor()->editHeading();
3140 void Main::editNewBranchBelow()
3142 VymModel *m=currentModel();
3145 BranchItem *bi=m->addNewBranch (1);
3152 if (actionSettingsAutoEditNewBranch->isOn())
3154 if (!actionSettingsAutoSelectNewBranch->isOn())
3155 prevSelection=m->getSelectString(bi);
3156 currentMapEditor()->editHeading();
3161 void Main::editImportAdd()
3163 fileLoad (ImportAdd);
3166 void Main::editImportReplace()
3168 fileLoad (ImportReplace);
3171 void Main::editSaveBranch()
3173 fileSaveAs (PartOfMap);
3176 void Main::editDeleteKeepChildren()
3178 VymModel *m=currentModel();
3179 if (m) m->deleteKeepChildren();
3182 void Main::editDeleteChildren()
3184 VymModel *m=currentModel();
3185 if (m) m->deleteChildren();
3188 void Main::editDeleteSelection()
3190 VymModel *m=currentModel();
3191 if (m && actionSettingsUseDelKey->isOn())
3192 m->deleteSelection();
3195 void Main::editLoadImage()
3197 VymModel *m=currentModel();
3198 if (m) m->loadFloatImage();
3201 void Main::editSaveImage()
3203 VymModel *m=currentModel();
3204 if (m) m->saveFloatImage();
3207 void Main::editEditXLink(QAction *a)
3209 VymModel *m=currentModel();
3211 m->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3214 void Main::formatSelectColor()
3216 QColor col = QColorDialog::getColor((currentColor ), this );
3217 if ( !col.isValid() ) return;
3218 colorChanged( col );
3221 void Main::formatPickColor()
3223 VymModel *m=currentModel();
3225 colorChanged( m->getCurrentHeadingColor() );
3228 void Main::colorChanged(QColor c)
3230 QPixmap pix( 16, 16 );
3232 actionFormatColor->setIconSet( pix );
3236 void Main::formatColorBranch()
3238 VymModel *m=currentModel();
3239 if (m) m->colorBranch(currentColor);
3242 void Main::formatColorSubtree()
3244 VymModel *m=currentModel();
3245 if (m) m->colorSubtree (currentColor);
3248 void Main::formatLinkStyleLine()
3250 VymModel *m=currentModel();
3253 m->setMapLinkStyle("StyleLine");
3254 actionFormatLinkStyleLine->setChecked(true);
3258 void Main::formatLinkStyleParabel()
3260 VymModel *m=currentModel();
3263 m->setMapLinkStyle("StyleParabel");
3264 actionFormatLinkStyleParabel->setChecked(true);
3268 void Main::formatLinkStylePolyLine()
3270 VymModel *m=currentModel();
3273 m->setMapLinkStyle("StylePolyLine");
3274 actionFormatLinkStylePolyLine->setChecked(true);
3278 void Main::formatLinkStylePolyParabel()
3280 VymModel *m=currentModel();
3283 m->setMapLinkStyle("StylePolyParabel");
3284 actionFormatLinkStylePolyParabel->setChecked(true);
3288 void Main::formatSelectBackColor()
3290 VymModel *m=currentModel();
3291 if (m) m->selectMapBackgroundColor();
3294 void Main::formatSelectBackImage()
3296 VymModel *m=currentModel();
3298 m->selectMapBackgroundImage();
3301 void Main::formatSelectLinkColor()
3303 VymModel *m=currentModel();
3306 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3307 m->setMapDefLinkColor( col );
3311 void Main::formatSelectSelectionColor()
3313 VymModel *m=currentModel();
3316 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3317 m->setSelectionColor (col);
3322 void Main::formatToggleLinkColorHint()
3324 VymModel *m=currentModel();
3325 if (m) m->toggleMapLinkColorHint();
3329 void Main::formatHideLinkUnselected() //FIXME-3 get rid of this with imagepropertydialog
3331 VymModel *m=currentModel();
3333 m->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3336 void Main::viewZoomReset()
3338 MapEditor *me=currentMapEditor();
3339 if (me) me->setZoomFactorTarget (1);
3342 void Main::viewZoomIn()
3344 MapEditor *me=currentMapEditor();
3345 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*1.25);
3348 void Main::viewZoomOut()
3350 MapEditor *me=currentMapEditor();
3351 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*0.75);
3354 void Main::viewCenter()
3356 VymModel *m=currentModel();
3357 if (m) m->emitShowSelection();
3360 void Main::networkStartServer()
3362 VymModel *m=currentModel();
3363 if (m) m->newServer();
3366 void Main::networkConnect()
3368 VymModel *m=currentModel();
3369 if (m) m->connectToServer();
3372 bool Main::settingsPDF()
3374 // Default browser is set in constructor
3376 QString text = QInputDialog::getText(
3377 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3378 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3380 settings.setValue ("/mainwindow/readerPDF",text);
3385 bool Main::settingsURL()
3387 // Default browser is set in constructor
3389 QString text = QInputDialog::getText(
3390 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3391 settings.value("/mainwindow/readerURL").toString()
3394 settings.setValue ("/mainwindow/readerURL",text);
3398 void Main::settingsMacroDir()
3400 QDir defdir(vymBaseDir.path() + "/macros");
3401 if (!defdir.exists())
3403 QDir dir=QFileDialog::getExistingDirectory (
3405 tr ("Directory with vym macros:"),
3406 settings.value ("/macros/macroDir",defdir.path()).toString()
3409 settings.setValue ("/macros/macroDir",dir.absolutePath());
3412 void Main::settingsUndoLevels()
3415 int i = QInputDialog::getInteger(
3417 tr("QInputDialog::getInteger()"),
3418 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3421 settings.setValue ("/mapeditor/stepsTotal",i);
3422 QMessageBox::information( this, tr( "VYM -Information:" ),
3423 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3427 void Main::settingsAutosaveToggle()
3429 settings.setValue ("/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
3432 void Main::settingsAutosaveTime()
3435 int i = QInputDialog::getInteger(
3437 tr("QInputDialog::getInteger()"),
3438 tr("Number of seconds before autosave:"), settings.value("/mainwindow/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3440 settings.setValue ("/mainwindow/autosave/ms",i * 1000);
3443 void Main::settingsWriteBackupFileToggle()
3445 settings.setValue ("/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
3448 void Main::settingsToggleAnimation()
3450 settings.setValue ("/animation/use",actionSettingsUseAnimation->isOn() );
3453 void Main::settingsToggleDelKey()
3455 if (actionSettingsUseDelKey->isOn())
3457 actionDelete->setAccel (QKeySequence (Qt::Key_Delete));
3460 actionDelete->setAccel (QKeySequence (""));
3464 void Main::windowToggleNoteEditor()
3466 if (textEditor->isVisible() )
3467 windowHideNoteEditor();
3469 windowShowNoteEditor();
3472 void Main::windowToggleTreeEditor()
3474 if ( tabWidget->currentPage())
3475 vymViews.at(tabWidget->currentIndex())->toggleTreeEditor();
3478 void Main::windowToggleHistory()
3480 if (historyWindow->isVisible())
3481 historyWindow->hide();
3483 historyWindow->show();
3487 void Main::windowToggleProperty()
3489 if (branchPropertyWindow->isVisible())
3490 branchPropertyWindow->hide();
3492 branchPropertyWindow->show();
3493 branchPropertyWindow->setModel (currentModel() );
3496 void Main::windowToggleAntiAlias()
3498 bool b=actionViewToggleAntiAlias->isOn();
3500 for (int i=0;i<vymViews.count();i++)
3502 me=vymViews.at(i)->getMapEditor();
3503 if (me) me->setAntiAlias(b);
3508 bool Main::isAliased()
3510 return actionViewToggleAntiAlias->isOn();
3513 bool Main::hasSmoothPixmapTransform()
3515 return actionViewToggleSmoothPixmapTransform->isOn();
3518 void Main::windowToggleSmoothPixmap()
3520 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3522 for (int i=0;i<vymViews.count();i++)
3525 me=vymViews.at(i)->getMapEditor();
3526 if (me) me->setSmoothPixmap(b);
3530 void Main::updateHistory(SimpleSettings &undoSet)
3532 historyWindow->update (undoSet);
3535 void Main::updateNoteFlag()
3537 // this slot is connected to TextEditor::textHasChanged()
3538 VymModel *m=currentModel();
3539 if (m) m->updateNoteFlag();
3542 void Main::updateNoteEditor(QModelIndex index )
3544 TreeItem *ti=((VymModel*) QObject::sender())->getItem(index);
3546 cout << "Main::updateNoteEditor model="<<sender();
3547 cout << " item="<<ti->getHeadingStd()<<" ("<<ti<<")"<<endl;
3549 textEditor->setNote (ti->getNoteObj() );
3552 void Main::changeSelection (VymModel *model, const QItemSelection &newsel, const QItemSelection &oldsel)
3554 branchPropertyWindow->setModel (model ); //FIXME-3 this used to be called from BranchObj::select(). Maybe use signal now...
3556 if (model && model==currentModel() )
3560 if (!oldsel.indexes().isEmpty() )
3562 ti=model->getItem(oldsel.indexes().first());
3564 // Don't update note if both treeItem and textEditor are empty
3565 //if (! (ti->hasEmptyNote() && textEditor->isEmpty() ))
3566 // ti->setNoteObj (textEditor->getNoteObj(),false );
3568 if (!newsel.indexes().isEmpty() )
3570 ti=model->getItem(newsel.indexes().first());
3571 if (!ti->hasEmptyNote() )
3572 textEditor->setNote(ti->getNoteObj() );
3574 textEditor->setNote(NoteObj() ); //FIXME-4 maybe add a clear() to TE
3576 // Show URL and link in statusbar
3578 QString s=ti->getURL();
3579 if (!s.isEmpty() ) status+="URL: "+s+" ";
3581 if (!s.isEmpty() ) status+="Link: "+s;
3582 if (!status.isEmpty() ) statusMessage (status);
3585 textEditor->setInactive();
3591 void Main::updateActions()
3593 // updateActions is also called when satellites are closed //FIXME-2 doesn't update immediatly, e.g. historyWindow is still visible, when "close" is pressed
3594 actionViewToggleNoteEditor->setChecked (textEditor->isVisible());
3595 actionViewToggleHistoryWindow->setChecked (historyWindow->isVisible());
3596 actionViewTogglePropertyWindow->setChecked (branchPropertyWindow->isVisible());
3598 VymModel *m =currentModel();
3602 actionFilePrint->setEnabled (true);
3604 // Link style in context menu
3605 switch (m->getMapLinkStyle())
3607 case LinkableMapObj::Line:
3608 actionFormatLinkStyleLine->setChecked(true);
3610 case LinkableMapObj::Parabel:
3611 actionFormatLinkStyleParabel->setChecked(true);
3613 case LinkableMapObj::PolyLine:
3614 actionFormatLinkStylePolyLine->setChecked(true);
3616 case LinkableMapObj::PolyParabel:
3617 actionFormatLinkStylePolyParabel->setChecked(true);
3624 QPixmap pix( 16, 16 );
3625 pix.fill( m->getMapBackgroundColor() );
3626 actionFormatBackColor->setIconSet( pix );
3627 pix.fill( m->getSelectionColor() );
3628 actionFormatSelectionColor->setIconSet( pix );
3629 pix.fill( m->getMapDefLinkColor() );
3630 actionFormatLinkColor->setIconSet( pix );
3633 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName()));
3636 // Expanding/collapsing
3637 actionExpandAll->setEnabled (true);
3638 actionExpandOneLevel->setEnabled (true);
3639 actionCollapseOneLevel->setEnabled (true);
3643 actionFilePrint->setEnabled (false);
3645 // Expanding/collapsing
3646 actionExpandAll->setEnabled (false);
3647 actionExpandOneLevel->setEnabled (false);
3648 actionCollapseOneLevel->setEnabled (false);
3651 if (m && m->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3652 actionFormatLinkColorHint->setChecked(true);
3654 actionFormatLinkColorHint->setChecked(false);
3657 if (m && m->hasChanged() )
3658 actionFileSave->setEnabled( true);
3660 actionFileSave->setEnabled( false);
3661 if (m && m->isUndoAvailable())
3662 actionUndo->setEnabled( true);
3664 actionUndo->setEnabled( false);
3666 if (m && m->isRedoAvailable())
3667 actionRedo->setEnabled( true);
3669 actionRedo->setEnabled( false);
3673 TreeItem *selti=m->getSelectedItem();
3674 BranchItem *selbi=m->getSelectedBranch();
3677 if (selbi || selti->getType()==TreeItem::Image)
3679 actionFormatHideLinkUnselected->setChecked (((MapItem*)selti)->getHideLinkUnselected());
3680 actionFormatHideLinkUnselected->setEnabled (true);
3685 // Take care of xlinks
3686 branchXLinksContextMenuEdit->clear();
3687 if (selbi->xlinkCount()>0)
3691 for (int i=0; i<selbi->xlinkCount();++i)
3693 bi=selbi->getXLinkNum(i)->getPartnerBranch();
3697 if (s.length()>xLinkMenuWidth)
3698 s=s.left(xLinkMenuWidth)+"...";
3699 branchXLinksContextMenuEdit->addAction (s);
3704 standardFlagsMaster->updateToolBar (selbi->activeStandardFlagNames() );
3707 actionToggleScroll->setEnabled (true);
3708 if ( selbi->isScrolled() )
3709 actionToggleScroll->setChecked(true);
3711 actionToggleScroll->setChecked(false);
3713 if ( selti->getURL().isEmpty() )
3715 actionOpenURL->setEnabled (false);
3716 actionOpenURLTab->setEnabled (false);
3720 actionOpenURL->setEnabled (true);
3721 actionOpenURLTab->setEnabled (true);
3723 if ( selti->getVymLink().isEmpty() )
3725 actionOpenVymLink->setEnabled (false);
3726 actionDeleteVymLink->setEnabled (false);
3729 actionOpenVymLink->setEnabled (true);
3730 actionDeleteVymLink->setEnabled (true);
3733 if (selbi->canMoveUp())
3734 actionMoveUp->setEnabled (true);
3736 actionMoveUp->setEnabled (false);
3737 if (selbi->canMoveDown())
3738 actionMoveDown->setEnabled (true);
3740 actionMoveDown->setEnabled (false);
3742 actionSortChildren->setEnabled (true);
3743 actionSortBackChildren->setEnabled (true);
3745 actionToggleHideExport->setEnabled (true);
3746 actionToggleHideExport->setChecked (selbi->hideInExport() );
3748 actionCopy->setEnabled (true);
3749 actionCut->setEnabled (true);
3750 if (!clipboardEmpty)
3751 actionPaste->setEnabled (true);
3753 actionPaste->setEnabled (false);
3754 for (int i=0; i<actionListBranches.size(); ++i)
3755 actionListBranches.at(i)->setEnabled(true);
3756 actionDelete->setEnabled (true);
3758 if ( selti->getType()==TreeItem::Image)
3760 actionOpenURL->setEnabled (false);
3761 actionOpenVymLink->setEnabled (false);
3762 actionDeleteVymLink->setEnabled (false);
3763 actionToggleHideExport->setEnabled (true);
3764 actionToggleHideExport->setChecked (selti->hideInExport() );
3767 actionCopy->setEnabled (true);
3768 actionCut->setEnabled (true);
3769 actionPaste->setEnabled (false); //FIXME-4 why not allowing copy of images?
3770 for (int i=0; i<actionListBranches.size(); ++i)
3771 actionListBranches.at(i)->setEnabled(false);
3772 actionDelete->setEnabled (true);
3773 actionMoveUp->setEnabled (false);
3774 actionMoveDown->setEnabled (false);
3779 actionCopy->setEnabled (false);
3780 actionCut->setEnabled (false);
3781 actionPaste->setEnabled (false);
3782 for (int i=0; i<actionListBranches.size(); ++i)
3783 actionListBranches.at(i)->setEnabled(false);
3785 actionToggleScroll->setEnabled (false);
3786 actionOpenURL->setEnabled (false);
3787 actionOpenVymLink->setEnabled (false);
3788 actionDeleteVymLink->setEnabled (false);
3789 actionHeading2URL->setEnabled (false);
3790 actionDelete->setEnabled (false);
3791 actionMoveUp->setEnabled (false);
3792 actionMoveDown->setEnabled (false);
3793 actionFormatHideLinkUnselected->setEnabled (false);
3794 actionSortChildren->setEnabled (false);
3795 actionSortBackChildren->setEnabled (false);
3796 actionToggleHideExport->setEnabled (false);
3801 Main::ModMode Main::getModMode()
3803 if (actionModModeColor->isOn()) return ModModeColor;
3804 if (actionModModeCopy->isOn()) return ModModeCopy;
3805 if (actionModModeXLink->isOn()) return ModModeXLink;
3809 bool Main::autoEditNewBranch()
3811 return actionSettingsAutoEditNewBranch->isOn();
3814 bool Main::autoSelectNewBranch()
3816 return actionSettingsAutoSelectNewBranch->isOn();
3819 void Main::windowShowNoteEditor()
3821 textEditor->setShowWithMain(true);
3823 actionViewToggleNoteEditor->setChecked (true);
3826 void Main::windowHideNoteEditor()
3828 textEditor->setShowWithMain(false);
3830 actionViewToggleNoteEditor->setChecked (false);
3833 void Main::setScript (const QString &script)
3835 scriptEditor->setScript (script);
3838 void Main::runScript (const QString &script)
3840 VymModel *m=currentModel();
3841 if (m) m->runScript (script);
3844 void Main::runScriptEverywhere (const QString &script)
3847 for (int i=0;i<=tabWidget->count() -1;i++)
3849 me=(MapEditor*)tabWidget->page(i);
3850 if (me) me->getModel()->runScript (script);
3854 void Main::windowNextEditor()
3856 if (tabWidget->currentIndex() < tabWidget->count())
3857 tabWidget->setCurrentIndex (tabWidget->currentIndex() +1);
3860 void Main::windowPreviousEditor()
3862 if (tabWidget->currentIndex() >0)
3863 tabWidget->setCurrentIndex (tabWidget->currentIndex() -1);
3866 void Main::standardFlagChanged()
3870 if ( actionSettingsUseFlagGroups->isOn() )
3871 currentModel()->toggleStandardFlag(sender()->name(),standardFlagsMaster);
3873 currentModel()->toggleStandardFlag(sender()->name());
3879 #include "attributeitem.h"
3880 void Main::testFunction1()
3882 VymModel *m=currentModel();
3885 BranchItem *selbi=m->getSelectedBranch();
3888 QList<QVariant> cData;
3889 cData << "new ai" << "undef";
3891 AttributeItem *ai=new AttributeItem (cData,selbi);
3892 ai->set ("Key 1","Val a",AttributeItem::FreeString);
3894 m->addAttribute (ai);
3899 if (!currentMapEditor()) return;
3900 currentMapEditor()->testFunction1();
3904 VymModel *m=currentModel();
3908 QString text = QInputDialog::getText(
3909 "VYM", "Enter Filter:", QLineEdit::Normal, // FIXME-3 no translation yet
3910 m->getSortFilter(), &ok, NULL);
3912 // user entered something and pressed OK
3913 m->setSortFilter (text);
3917 void Main::testFunction2()
3919 if (!currentMapEditor()) return;
3920 currentMapEditor()->testFunction2();
3923 void Main::testCommand()
3925 if (!currentMapEditor()) return;
3926 scriptEditor->show();
3929 QString com = QInputDialog::getText(
3930 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3931 if (ok) currentMapEditor()->parseAtom(com);
3935 void Main::helpDoc()
3937 QString locale = QLocale::system().name();
3939 if (locale.left(2)=="es")
3940 docname="vym_es.pdf";
3944 QStringList searchList;
3946 #if defined(Q_OS_MACX)
3947 searchList << "./vym.app/Contents/Resources/doc";
3948 #elif defined(Q_OS_WIN32)
3949 searchList << vymInstallDir.path() + "/share/doc/packages/vym";
3951 #if defined(VYM_DOCDIR)
3952 searchList << VYM_DOCDIR;
3954 // default path in SUSE LINUX
3955 searchList << "/usr/share/doc/packages/vym";
3958 searchList << "doc"; // relative path for easy testing in tarball
3959 searchList << "doc/tex"; // Easy testing working on vym.tex
3960 searchList << "/usr/share/doc/vym"; // Debian
3961 searchList << "/usr/share/doc/packages";// Knoppix
3965 for (int i=0; i<searchList.count(); ++i)
3967 docfile.setFileName(searchList.at(i)+"/"+docname);
3968 if (docfile.exists())
3977 QMessageBox::critical(0,
3978 tr("Critcal error"),
3979 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3984 Process *pdfProc = new Process();
3985 args << QDir::toNativeSeparators(docfile.fileName());
3987 if (!pdfProc->startDetached( settings.value("/mainwindow/readerPDF").toString(),args) )
3990 QMessageBox::warning(0,
3992 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3993 tr("Please use Settings->")+tr("Set application to open PDF files"));
4000 void Main::helpDemo()
4002 QStringList filters;
4003 filters <<"VYM example map (*.vym)";
4004 QFileDialog *fd=new QFileDialog( this);
4005 #if defined(Q_OS_MACX)
4006 fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
4008 // default path in SUSE LINUX
4009 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
4012 fd->setFileMode (QFileDialog::ExistingFiles);
4013 fd->setFilters (filters);
4014 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
4018 if ( fd->exec() == QDialog::Accepted )
4020 lastFileDir=fd->directory().path();
4021 QStringList flist = fd->selectedFiles();
4022 QStringList::Iterator it = flist.begin();
4023 while( it != flist.end() )
4026 fileLoad(*it, NewMap);
4034 void Main::helpAbout()
4037 ad.setName ("aboutwindow");
4038 ad.setMinimumSize(500,500);
4039 ad.resize (QSize (500,500));
4043 void Main::helpAboutQT()
4045 QMessageBox::aboutQt( this, "Qt Application Example" );
4048 void Main::callMacro ()
4050 QAction *action = qobject_cast<QAction *>(sender());
4054 i=action->data().toInt();
4055 QString mDir (settings.value ("macros/macroDir").toString() );
4057 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
4059 if ( !f.open( QIODevice::ReadOnly ) )
4061 QMessageBox::warning(0,
4063 tr("Couldn't find a macro at %1.\n").arg(fn)+
4064 tr("Please use Settings->")+tr("Set directory for vym macros"));
4068 QTextStream ts( &f );
4069 QString macro= ts.read();
4071 if (! macro.isEmpty())
4073 VymModel *m=currentModel();
4074 if (m) m->runScript(macro);