1 #include "mainwindow.h"
8 #include "aboutdialog.h"
9 #include "branchpropwindow.h"
10 #include "branchitem.h"
11 #include "exportoofiledialog.h"
14 #include "findresultwidget.h"
15 #include "findwidget.h"
17 #include "historywindow.h"
19 #include "mapeditor.h"
24 #include "shortcuts.h"
25 #include "texteditor.h"
26 #include "warningdialog.h"
27 #include "xlinkitem.h"
29 //#include <modeltest.h> // FIXME-3
31 #if defined(Q_OS_WIN32)
32 // Define only this structure as opposed to
33 // including full 'windows.h'. FindWindow
34 // clashes with the one in Win32 API.
35 typedef struct _PROCESS_INFORMATION
41 } PROCESS_INFORMATION, *LPPROCESS_INFORMATION;
44 extern TextEditor *textEditor;
45 extern Main *mainWindow;
46 extern FindWidget *findWidget;
47 extern FindResultWidget *findResultWidget;
48 extern QString tmpVymDir;
49 extern QString clipboardDir;
50 extern QString clipboardFile;
51 extern bool clipboardEmpty;
52 extern int statusbarTime;
53 extern FlagRow *standardFlagsMaster;
54 extern FlagRow *systemFlagsMaster;
55 extern QString vymName;
56 extern QString vymVersion;
57 extern QString vymBuildDate;
60 QMenu* branchContextMenu;
61 QMenu* branchAddContextMenu;
62 QMenu* branchRemoveContextMenu;
63 QMenu* branchLinksContextMenu;
64 QMenu* branchXLinksContextMenuEdit;
65 QMenu* floatimageContextMenu;
66 QMenu* canvasContextMenu;
67 QMenu* fileLastMapsMenu;
68 QMenu* fileImportMenu;
69 QMenu* fileExportMenu;
72 extern Settings settings;
73 extern Options options;
74 extern ImageIO imageIO;
76 extern QDir vymBaseDir;
77 extern QDir lastImageDir;
78 extern QDir lastFileDir;
79 #if defined(Q_OS_WIN32)
80 extern QDir vymInstallDir;
82 extern QString iconPath;
83 extern QString flagsPath;
86 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
87 QMainWindow(parent,name,f)
91 setCaption ("VYM - View Your Mind");
93 // Load window settings
94 #if defined(Q_OS_WIN32)
95 if (settings.value("/mainwindow/geometry/maximized", false).toBool())
97 setWindowState(Qt::WindowMaximized);
102 resize (settings.value("/mainwindow/geometry/size", QSize (800,600)).toSize());
103 move (settings.value("/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
106 // Sometimes we may need to remember old selections
110 currentColor=Qt::black;
112 // Create unique temporary directory
114 tmpVymDir=makeTmpDir (ok,"vym");
117 qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
120 if (debug) qDebug (QString("vym tmpDir=%1").arg(tmpVymDir) );
122 // Create direcctory for clipboard
123 clipboardDir=tmpVymDir+"/clipboard";
124 clipboardFile="map.xml";
125 QDir d(clipboardDir);
126 d.mkdir (clipboardDir,true);
127 makeSubDirs (clipboardDir);
130 // Remember PID of our friendly webbrowser
131 browserPID=new qint64;
135 findResultWidget=new FindResultWidget ();
136 QDockWidget *dw= new QDockWidget (tr ("Search results","FindResultWidget"),this);
137 dw->setWidget (findResultWidget);
138 dw->setObjectName ("FindResultWidget");
140 addDockWidget (Qt::RightDockWidgetArea,dw);
142 // Satellite windows //////////////////////////////////////////
144 historyWindow=new HistoryWindow();
145 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
148 branchPropertyWindow = new BranchPropertyWindow();
149 connect (branchPropertyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
151 // Connect TextEditor, so that we can update flags if text changes
152 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
153 connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
155 // Initialize script editor
156 scriptEditor = new SimpleScriptEditor();
157 scriptEditor->move (50,50);
159 connect( scriptEditor, SIGNAL( runScript ( QString ) ),
160 this, SLOT( runScript( QString ) ) );
162 // Initialize some settings, which are platform dependant
165 // application to open URLs
166 p="/mainwindow/readerURL";
167 #if defined(Q_OS_LINUX)
168 s=settings.value (p,"xdg-open").toString();
170 #if defined(Q_OS_MACX)
171 s=settings.value (p,"/usr/bin/open").toString();
174 #if defined(Q_OS_WIN32)
175 // Assume that system has been set up so that
176 // Explorer automagically opens up the URL
177 // in the user's preferred browser.
178 s=settings.value (p,"explorer").toString();
180 s=settings.value (p,"mozilla").toString();
184 settings.setValue( p,s);
186 // application to open PDFs
187 p="/mainwindow/readerPDF";
188 #if defined(Q_OS_LINUX)
189 s=settings.value (p,"xdg-open").toString();
191 #if defined(Q_OS_MACX)
192 s=settings.value (p,"/usr/bin/open").toString();
193 #elif defined(Q_OS_WIN32)
194 s=settings.value (p,"acrord32").toString();
196 s=settings.value (p,"acroread").toString();
199 settings.setValue( p,s);
201 // width of xLinksMenu
205 QWidget* centralWidget = new QWidget (this);
206 QVBoxLayout *layout=new QVBoxLayout (centralWidget);
207 setCentralWidget(centralWidget);
209 // Create tab widget which holds the maps
210 tabWidget= new QTabWidget (centralWidget);
211 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
212 this, SLOT( editorChanged( QWidget * ) ) );
215 findWidget = new FindWidget (centralWidget);
217 layout->addWidget (tabWidget);
218 layout->addWidget (findWidget);
221 findWidget, SIGNAL (nextButton (QString) ),
222 this, SLOT (editFindNext(QString) ) );
224 findWidget , SIGNAL (hideFindWidget() ),
225 this, SLOT (editHideFindWidget() ) );
229 setupFormatActions();
233 setupNetworkActions();
234 setupSettingsActions();
237 if (debug) switchboard.print();
239 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
242 // Status bar and progress bar there
246 progressCounterTotal=0;
248 progressDialog.setLabelText (tr("Loading maps","Mainwindow"));
249 progressDialog.setAutoReset(false);
250 progressDialog.setAutoClose(false);
251 //progressDialog.setWindowModality (Qt::WindowModal); // That forces mainwindo to update and slows down
252 //progressDialog.setCancelButton (NULL);
254 restoreState (settings.value("/mainwindow/state",0).toByteArray());
262 #if defined(Q_OS_WIN32)
263 settings.setValue ("/mainwindow/geometry/maximized", isMaximized());
265 settings.setValue ("/mainwindow/geometry/size", size());
266 settings.setValue ("/mainwindow/geometry/pos", pos());
267 settings.setValue ("/mainwindow/state",saveState(0));
269 settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
270 settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
271 settings.setValue( "/version/version", vymVersion );
272 settings.setValue( "/version/builddate", vymBuildDate );
274 settings.setValue( "/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
275 settings.setValue ("/mainwindow/autoLayout/use",actionSettingsAutoLayoutToggle->isOn() );
276 settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isOn() );
277 settings.setValue( "/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
278 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
279 settings.setValue( "/mapeditor/editmode/autoEditNewBranch",actionSettingsAutoEditNewBranch->isOn() );
280 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
281 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
282 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
284 //TODO save scriptEditor settings
286 // call the destructors
288 delete historyWindow;
289 delete branchPropertyWindow;
291 // Remove temporary directory
292 removeDir (QDir(tmpVymDir));
295 void Main::loadCmdLine()
297 /* TODO draw some kind of splashscreen while loading...
303 QStringList flist=options.getFileList();
304 QStringList::Iterator it=flist.begin();
306 progressCounter=flist.count();
307 progressCounterTotal=flist.count();
308 while (it !=flist.end() )
310 fileLoad (*it, NewMap);
316 void Main::statusMessage(const QString &s)
318 // Surpress messages while progressdialog during
321 statusBar()->message( s);
324 void Main::setProgressMaximum (int max)
326 if (progressCounterTotal!=0)
328 progressDialog.setRange (0,progressCounterTotal*1000);
330 progressDialog.setRange (0,max+10);
332 progressDialog.setValue (0);
333 progressMax=max*1000;
334 //cout << "Main max="<<max<<" v="<<progressDialog.value()<<endl;
335 progressDialog.show();
338 void Main::addProgressValue (float v)
340 //cout << "addVal v="<<v*1000<<"/"<<progressMax<<" cur="<<progressDialog.value()<<" counter="<<v+progressCounter<<"/"<<progressCounterTotal<<endl;
341 if (progressCounterTotal!=0)
342 progressDialog.setValue ( (v+progressCounterTotal-progressCounter)*1000 );
344 progressDialog.setValue (v+progressDialog.value());
347 void Main::removeProgressCounter()
351 if (progressCounter<=0)
354 progressCounterTotal=0;
355 progressDialog.reset();
356 progressDialog.hide();
360 void Main::closeEvent (QCloseEvent* )
366 void Main::setupFileActions()
368 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
369 QToolBar *tb = addToolBar( tr ("&Map") );
370 tb->setObjectName ("mapTB");
373 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this);
374 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
375 a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map
376 switchboard.addConnection(a,tr("File","Shortcut group"));
378 fileMenu->addAction (a);
379 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
381 a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this);
382 a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) );
383 a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N ); //New map
384 switchboard.addConnection(a,tr("File","Shortcut group"));
385 fileMenu->addAction (a);
386 connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) );
389 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
390 a->setStatusTip (tr( "Open","Status tip File menu" ) );
391 a->setShortcut ( Qt::CTRL + Qt::Key_O ); //Open map
392 switchboard.addConnection(a,tr("File","Shortcut group"));
394 fileMenu->addAction (a);
395 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
397 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
398 fileMenu->addSeparator();
400 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
401 a->setStatusTip ( tr( "Save","Status tip file menu" ));
402 a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map
403 switchboard.addConnection(a,tr("File","Shortcut group"));
405 fileMenu->addAction (a);
406 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
409 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
410 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
411 switchboard.addConnection(a,tr("File","Shortcut group"));
412 fileMenu->addAction (a);
413 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
415 fileMenu->addSeparator();
417 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
419 a = new QAction(tr("KDE 3 Bookmarks"), this);
420 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 3 bookmarks")));
421 switchboard.addConnection(a,tr("File","Shortcut group"));
422 a->addTo (fileImportMenu);
423 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE3Bookmarks() ) );
425 a = new QAction(tr("KDE 4 Bookmarks"), this);
426 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 4 bookmarks")));
427 a->addTo (fileImportMenu);
428 switchboard.addConnection(a,tr("File","Shortcut group"));
429 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE4Bookmarks() ) );
431 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
433 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
434 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
435 a->addTo (fileImportMenu);
436 switchboard.addConnection(a,tr("File","Shortcut group"));
437 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
440 a = new QAction("Freemind...",this);
441 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Freemind") );
442 switchboard.addConnection(a,tr("File","Shortcut group"));
443 fileImportMenu->addAction (a);
444 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFreemind() ) );
446 a = new QAction("Mind Manager...",this);
447 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
448 switchboard.addConnection(a,tr("File","Shortcut group"));
449 fileImportMenu->addAction (a);
450 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
452 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
453 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
454 switchboard.addConnection(a,tr("File","Shortcut group"));
455 fileImportMenu->addAction (a);
456 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
458 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
460 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
461 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
462 switchboard.addConnection(a,tr("File","Shortcut group"));
463 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
464 fileExportMenu->addAction (a);
466 a = new QAction( "Open Office...", this);
467 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
468 switchboard.addConnection(a,tr("File","Shortcut group"));
469 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
470 fileExportMenu->addAction (a);
472 a = new QAction( "Webpage (HTML)...",this );
473 a->setShortcut (Qt::ALT + Qt::Key_X); //Export HTML
474 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
475 switchboard.addConnection(a,tr("File","Shortcut group"));
476 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportHTML() ) );
477 fileExportMenu->addAction (a);
479 a = new QAction( "Webpage (XHTML)...",this ); //Export XHTML
481 //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")));
482 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
483 fileExportMenu->addAction (a);
485 a = new QAction( "Text (A&O report)...", this);
486 a->setStatusTip ( tr( "Export as %1").arg("A&O report "+tr("(still experimental)" )));
487 switchboard.addConnection(a,tr("File","Shortcut group"));
488 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportAO() ) );
489 fileExportMenu->addAction (a);
491 a = new QAction( "Text (ASCII)...", this);
492 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
493 switchboard.addConnection(a,tr("File","Shortcut group"));
494 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
495 fileExportMenu->addAction (a);
497 a = new QAction( "Spreadsheet (CSV)...", this);
498 a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
499 switchboard.addConnection(a,tr("File","Shortcut group"));
500 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
501 fileExportMenu->addAction (a);
503 a = new QAction( tr("KDE 3 Bookmarks","File menu"), this);
504 a->setStatusTip( tr( "Export as %1").arg(tr("KDE 3 Bookmarks" )));
505 switchboard.addConnection(a,tr("File","Shortcut group"));
506 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE3Bookmarks() ) );
507 fileExportMenu->addAction (a);
509 a = new QAction( tr("KDE 4 Bookmarks","File menu"), this);
510 a->setStatusTip( tr( "Export as %1").arg(tr("KDE 4 Bookmarks" )));
511 switchboard.addConnection(a,tr("File","Shortcut group"));
512 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE4Bookmarks() ) );
513 fileExportMenu->addAction (a);
515 a = new QAction( "Taskjuggler...", this );
516 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
517 switchboard.addConnection(a,tr("File","Shortcut group"));
518 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
519 fileExportMenu->addAction (a);
521 a = new QAction( "LaTeX...", this);
522 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
523 switchboard.addConnection(a,tr("File","Shortcut group"));
524 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
525 fileExportMenu->addAction (a);
527 a = new QAction( "XML..." , this );
528 a->setStatusTip (tr( "Export as %1").arg("XML"));
529 switchboard.addConnection(a,tr("File","Shortcut group"));
530 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
531 fileExportMenu->addAction (a);
533 fileMenu->addSeparator();
535 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
536 a->setStatusTip ( tr( "Print" ,"File menu") );
537 a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map
539 switchboard.addConnection(a,tr("File","Shortcut group"));
540 fileMenu->addAction (a);
541 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
544 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
545 a->setStatusTip (tr( "Close Map" ) );
546 a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map
547 switchboard.addConnection(a,tr("File","Shortcut group"));
548 fileMenu->addAction (a);
549 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
551 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
552 a->setStatusTip ( tr( "Exit")+" "+vymName );
553 a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym
554 switchboard.addConnection(a,tr("File","Shortcut group"));
555 fileMenu->addAction (a);
556 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
561 void Main::setupEditActions()
563 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
564 tb->setLabel( "Edit Actions" );
565 tb->setObjectName ("actionsTB");
566 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
569 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
570 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
571 a->setStatusTip (tr( "Undo" ) );
572 a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action
573 a->setEnabled (false);
574 switchboard.addConnection(a,tr("Edit","Shortcut group"));
576 editMenu->addAction (a);
579 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
580 a->setStatusTip (tr( "Redo" ));
581 a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action
582 switchboard.addConnection(a,tr("Edit","Shortcut group"));
584 editMenu->addAction (a);
585 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
588 editMenu->addSeparator();
589 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
590 a->setStatusTip ( tr( "Copy" ) );
591 a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy
592 a->setEnabled (false);
593 switchboard.addConnection(a,tr("Edit","Shortcut group"));
595 editMenu->addAction (a);
596 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
599 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
600 a->setStatusTip ( tr( "Cut" ) );
601 a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut
602 a->setEnabled (false);
604 switchboard.addConnection(a,tr("Edit","Shortcut group"));
605 editMenu->addAction (a);
607 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
609 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
610 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
611 a->setStatusTip ( tr( "Paste" ) );
612 a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste
613 a->setEnabled (false);
615 switchboard.addConnection(a,tr("Edit","Shortcut group"));
616 editMenu->addAction (a);
619 // Shortcut to delete selection
620 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
621 a->setStatusTip (tr( "Delete Selection" ));
622 a->setShortcut ( Qt::Key_Delete); //Delete selection
623 a->setShortcutContext (Qt::WindowShortcut);
624 switchboard.addConnection(a,tr("Edit","Shortcut group"));
626 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
629 // Shortcut to add attribute
630 a= new QAction(tr( "Add attribute" ), this);
631 a->setShortcut ( Qt::Key_Q);
632 a->setShortcutContext (Qt::WindowShortcut);
633 switchboard.addConnection(a,tr("Edit","Shortcut group"));
635 connect( a, SIGNAL( triggered() ), this, SLOT( editAddAttribute() ) );
636 actionAddAttribute= a;
639 // Shortcut to add mapcenter
640 a= new QAction(QPixmap(iconPath+"newmapcenter.png"),tr( "Add mapcenter","Canvas context menu" ), this);
641 a->setShortcut ( Qt::Key_M);
642 a->setShortcutContext (Qt::WindowShortcut);
643 switchboard.addConnection(a,tr("Edit","Shortcut group"));
644 connect( a, SIGNAL( triggered() ), this, SLOT( editAddMapCenter() ) );
645 //actionListBranches.append(a);
647 actionAddMapCenter = a;
650 // Shortcut to add branch
651 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
652 a->setStatusTip ( tr( "Add a branch as child of selection" ));
653 a->setShortcut (Qt::Key_A); //Add branch
654 a->setShortcutContext (Qt::WindowShortcut);
655 switchboard.addConnection(a,tr("Edit","Shortcut group"));
657 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
658 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
659 a->setStatusTip ( tr( "Add a branch as child of selection" ));
660 a->setShortcut (Qt::Key_Insert); //Add branch
661 switchboard.addConnection(a,tr("Edit","Shortcut group"));
662 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
663 actionListBranches.append(a);
665 editMenu->addAction (actionAddBranch);
666 tb->addAction (actionAddBranch);
669 // Add branch by inserting it at selection
670 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
671 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
672 a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch
673 a->setShortcutContext (Qt::WindowShortcut);
674 switchboard.addConnection(a,tr("Edit","Shortcut group"));
676 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
677 actionListBranches.append(a);
678 actionAddBranchBefore=a;
681 a = new QAction(tr( "Add branch above","Edit menu" ), this);
682 a->setStatusTip ( tr( "Add a branch above selection" ));
683 a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
684 a->setShortcutContext (Qt::WindowShortcut);
685 switchboard.addConnection(a,tr("Edit","Shortcut group"));
687 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
688 a->setEnabled (false);
689 actionListBranches.append(a);
690 actionAddBranchAbove=a;
691 a = new QAction(tr( "Add branch above","Edit menu" ), this);
692 a->setStatusTip ( tr( "Add a branch above selection" ));
693 a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above
694 a->setShortcutContext (Qt::WindowShortcut);
695 switchboard.addConnection(a,tr("Edit","Shortcut group"));
697 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
698 actionListBranches.append(a);
701 a = new QAction(tr( "Add branch below","Edit menu" ), this);
702 a->setStatusTip ( tr( "Add a branch below selection" ));
703 a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
704 a->setShortcutContext (Qt::WindowShortcut);
705 switchboard.addConnection(a,tr("Edit","Shortcut group"));
707 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
708 a->setEnabled (false);
709 actionListBranches.append(a);
710 actionAddBranchBelow=a;
711 a = new QAction(tr( "Add branch below","Edit menu" ), this);
712 a->setStatusTip ( tr( "Add a branch below selection" ));
713 a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below
714 a->setShortcutContext (Qt::WindowShortcut);
715 switchboard.addConnection(a,tr("Edit","Shortcut group"));
717 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
718 actionListBranches.append(a);
720 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
721 a->setStatusTip ( tr( "Move branch up" ) );
722 a->setShortcut (Qt::Key_PageUp ); // Move branch up
723 a->setEnabled (false);
724 switchboard.addConnection(a,tr("Edit","Shortcut group"));
726 editMenu->addAction (a);
727 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
730 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
731 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
732 a->setStatusTip (tr( "Move branch down" ) );
733 a->setShortcut ( Qt::Key_PageDown ); // Move branch down
734 a->setEnabled (false);
735 switchboard.addConnection(a,tr("Edit","Shortcut group"));
737 editMenu->addAction (a);
740 a = new QAction(QPixmap(), tr( "&Detach","Context menu" ),this);
741 a->setStatusTip ( tr( "Detach branch and use as mapcenter","Context menu" ) );
742 a->setShortcut ( Qt::Key_D ); // Detach branch
743 switchboard.addConnection(a,tr("Edit","Shortcut group"));
744 editMenu->addAction (a);
745 connect( a, SIGNAL( triggered() ), this, SLOT( editDetach() ) );
748 a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this );
749 connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) );
750 a->setEnabled (true);
752 switchboard.addConnection(a,tr("Edit","Shortcut group"));
753 editMenu->addAction (a);
754 actionSortChildren=a;
756 a = new QAction( QPixmap(iconPath+"editsortback.png" ), tr( "Sort children backwards","Edit menu" ), this );
757 connect( a, SIGNAL( activated() ), this, SLOT( editSortBackChildren() ) );
758 a->setEnabled (true);
760 switchboard.addConnection(a,tr("Edit","Shortcut group"));
761 editMenu->addAction (a);
762 actionSortBackChildren=a;
764 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
765 a->setShortcut ( Qt::Key_S ); // Scroll branch
766 a->setStatusTip (tr( "Scroll branch" ));
767 switchboard.addConnection(a,tr("Edit","Shortcut group"));
768 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
769 a->setEnabled (false);
770 a->setToggleAction(true);
771 actionToggleScroll=a;
772 tb->addAction (actionToggleScroll);
773 editMenu->addAction ( actionToggleScroll);
774 editMenu->addAction (actionToggleScroll);
776 actionListBranches.append(actionToggleScroll);
778 a = new QAction( QPixmap(), tr( "Expand all branches","Edit menu" ), this);
779 a->setShortcut ( Qt::SHIFT + Qt::Key_X ); // Expand all branches
780 a->setStatusTip (tr( "Expand all branches" ));
781 switchboard.addConnection(a,tr("Edit","Shortcut group"));
782 connect( a, SIGNAL( triggered() ), this, SLOT( editExpandAll() ) );
784 actionExpandAll->setEnabled (false);
785 actionExpandAll->setToggleAction(false);
786 //tb->addAction (actionExpandAll);
787 editMenu->addAction ( actionExpandAll);
789 actionListBranches.append(actionExpandAll);
791 a = new QAction( QPixmap(), tr( "Expand one level","Edit menu" ), this);
792 a->setShortcut ( Qt::Key_Greater ); // Expand one level in tree editor
793 switchboard.addConnection(a,tr("Edit","Shortcut group"));
794 a->setStatusTip (tr( "Expand one level in tree editor" ));
795 connect( a, SIGNAL( triggered() ), this, SLOT( editExpandOneLevel() ) );
796 a->setEnabled (false);
797 a->setToggleAction(false);
798 actionExpandOneLevel=a;
800 editMenu->addAction ( a);
802 actionListBranches.append(a);
804 a = new QAction( QPixmap(), tr( "Collapse one level","Edit menu" ), this);
805 a->setShortcut ( Qt::Key_Less); // Collapse one level in tree editor
806 switchboard.addConnection(a,tr("Edit","Shortcut group"));
807 a->setStatusTip (tr( "Collapse one level in tree editor" ));
808 connect( a, SIGNAL( triggered() ), this, SLOT( editCollapseOneLevel() ) );
809 a->setEnabled (false);
810 a->setToggleAction(false);
811 actionCollapseOneLevel=a;
813 editMenu->addAction ( a);
815 actionListBranches.append(a);
817 a = new QAction( tr( "Unscroll children","Edit menu" ), this);
818 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
819 switchboard.addConnection(a,tr("Edit","Shortcut group"));
820 editMenu->addAction (a);
821 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChildren() ) );
823 editMenu->addSeparator();
825 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
826 a->setStatusTip (tr( "Find" ) );
827 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
828 switchboard.addConnection(a,tr("Edit","Shortcut group"));
829 editMenu->addAction (a);
830 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWidget() ) );
832 a = new QAction( tr( "Find duplicate URLs","Edit menu"), this);
833 //a->setStatusTip (tr( "Find" ) );
834 a->setShortcut (Qt::SHIFT + Qt::Key_F); //Find duplicate URLs
835 switchboard.addConnection(a,tr("Edit","Shortcut group"));
836 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
837 editMenu->addAction (a);
838 connect( a, SIGNAL( triggered() ), this, SLOT( editFindDuplicateURLs() ) );
840 editMenu->addSeparator();
842 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
843 a->setShortcut (Qt::SHIFT + Qt::Key_U );
844 switchboard.addConnection(a,tr("Edit","Shortcut group"));
847 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
850 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
851 a->setStatusTip (tr( "Open URL in new tab" ));
852 //a->setShortcut (Qt::CTRL+Qt::Key_U );
853 switchboard.addConnection(a,tr("Edit","Shortcut group"));
855 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
858 a = new QAction( tr( "Open all URLs in subtree (including scrolled branches)","Edit menu" ), this);
859 a->setStatusTip (tr( "Open all URLs in subtree (including scrolled branches)" ));
860 a->setShortcut ( Qt::CTRL + Qt::Key_U );
861 switchboard.addConnection(a,tr("Edit","Shortcut group"));
863 actionListBranches.append(a);
864 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVisURLTabs() ) );
865 actionOpenMultipleVisURLTabs=a;
867 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
868 a->setStatusTip (tr( "Open all URLs in subtree" ));
869 switchboard.addConnection(a,tr("Edit","Shortcut group"));
871 actionListBranches.append(a);
872 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
873 actionOpenMultipleURLTabs=a;
875 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
876 a->setStatusTip ( tr( "Edit URL" ) );
877 a->setShortcut ( 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( editURL() ) );
885 a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
886 a->setStatusTip ( tr( "Edit local URL" ) );
887 //a->setShortcut (Qt::SHIFT + Qt::Key_U );
888 a->setShortcutContext (Qt::WindowShortcut);
889 switchboard.addConnection(a,tr("Edit","Shortcut group"));
890 actionListBranches.append(a);
892 connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
895 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
896 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
897 a->setEnabled (false);
898 switchboard.addConnection(a,tr("Edit","Shortcut group"));
899 actionListBranches.append(a);
900 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
903 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
904 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
905 a->setEnabled (false);
906 actionListBranches.append(a);
907 a->setShortcut ( Qt::Key_B );
908 a->setShortcutContext (Qt::WindowShortcut);
909 switchboard.addConnection(a,tr("Edit","Shortcut group"));
911 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
912 actionBugzilla2URL=a;
914 a = new QAction(tr( "Get data from Novell Bugzilla","Edit menu" ), this);
915 a->setStatusTip ( tr( "Get data from Novell Bugzilla" ));
916 a->setEnabled (false);
917 actionListBranches.append(a);
918 a->setShortcut ( Qt::Key_B + Qt::SHIFT);
919 a->setShortcutContext (Qt::WindowShortcut);
920 switchboard.addConnection(a,tr("Edit","Shortcut group"));
922 connect( a, SIGNAL( triggered() ), this, SLOT( getBugzillaData() ) );
923 actionGetBugzillaData=a;
925 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
926 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
927 a->setEnabled (false);
928 switchboard.addConnection(a,tr("Edit","Shortcut group"));
929 actionListBranches.append(a);
930 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
933 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
934 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
936 a->setEnabled (false);
937 switchboard.addConnection(a,tr("Edit","Shortcut group"));
938 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
941 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
942 a->setStatusTip ( tr( "Open all vym links in subtree" ));
943 a->setEnabled (false);
944 switchboard.addConnection(a,tr("Edit","Shortcut group"));
945 actionListBranches.append(a);
946 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
947 actionOpenMultipleVymLinks=a;
950 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
951 a->setEnabled (false);
952 a->setStatusTip ( tr( "Edit link to another vym map" ));
953 switchboard.addConnection(a,tr("Edit","Shortcut group"));
954 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
955 actionListBranches.append(a);
958 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
959 a->setStatusTip ( tr( "Delete link to another vym map" ));
960 a->setEnabled (false);
961 switchboard.addConnection(a,tr("Edit","Shortcut group"));
962 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
963 actionDeleteVymLink=a;
965 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
966 a->setStatusTip ( tr( "Hide object in exports" ) );
967 a->setShortcut (Qt::Key_H );
968 a->setToggleAction(true);
970 a->setEnabled (false);
971 switchboard.addConnection(a,tr("Edit","Shortcut group"));
972 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
973 actionToggleHideExport=a;
975 a = new QAction(tr( "Add timestamp","Edit menu" ), this);
976 a->setStatusTip ( tr( "Add timestamp" ));
977 a->setEnabled (false);
978 actionListBranches.append(a);
979 a->setShortcut ( Qt::Key_T ); // Add timestamp
980 a->setShortcutContext (Qt::WindowShortcut);
981 switchboard.addConnection(a,tr("Edit","Shortcut group"));
983 connect( a, SIGNAL( triggered() ), this, SLOT( editAddTimestamp() ) );
984 actionAddTimestamp=a;
986 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
987 a->setStatusTip ( tr( "Edit Map Info" ));
988 a->setEnabled (true);
989 switchboard.addConnection(a,tr("Edit","Shortcut group"));
990 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
993 // Import at selection (adding to selection)
994 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
995 a->setStatusTip (tr( "Add map at selection" ));
996 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
997 a->setEnabled (false);
998 switchboard.addConnection(a,tr("Edit","Shortcut group"));
999 actionListBranches.append(a);
1002 // Import at selection (replacing selection)
1003 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
1004 a->setStatusTip (tr( "Replace selection with map" ));
1005 switchboard.addConnection(a,tr("Edit","Shortcut group"));
1006 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
1007 a->setEnabled (false);
1008 actionListBranches.append(a);
1009 actionImportReplace=a;
1012 a = new QAction( tr( "Save selection","Edit menu" ), this);
1013 a->setStatusTip (tr( "Save selection" ));
1014 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
1015 a->setEnabled (false);
1016 switchboard.addConnection(a,tr("Edit","Shortcut group"));
1017 actionListBranches.append(a);
1020 // Only remove branch, not its children
1021 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
1022 a->setStatusTip ( tr( "Remove only branch and keep its children" ));
1023 a->setShortcut (Qt::ALT + Qt::Key_Delete );
1024 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChildren() ) );
1025 a->setEnabled (false);
1026 switchboard.addConnection(a,tr("Edit","Shortcut group"));
1028 actionListBranches.append(a);
1029 actionDeleteKeepChildren=a;
1031 // Only remove children of a branch
1032 a = new QAction( tr( "Remove children","Edit menu" ), this);
1033 a->setStatusTip (tr( "Remove children of branch" ));
1034 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
1035 switchboard.addConnection(a,tr("Edit","Shortcut group"));
1036 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChildren() ) );
1037 a->setEnabled (false);
1038 actionListBranches.append(a);
1039 actionDeleteChildren=a;
1041 a = new QAction( tr( "Add Image...","Edit menu" ), this);
1042 a->setStatusTip (tr( "Add Image" ));
1043 switchboard.addConnection(a,tr("Edit","Shortcut group"));
1044 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
1047 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
1048 a->setStatusTip (tr( "Set properties for selection" ));
1049 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
1050 a->setShortcutContext (Qt::WindowShortcut);
1051 a->setToggleAction (true);
1052 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1054 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
1055 actionViewTogglePropertyWindow=a;
1059 void Main::setupFormatActions()
1061 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
1063 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
1064 tb->setObjectName ("formatTB");
1066 QPixmap pix( 16,16);
1067 pix.fill (Qt::black);
1068 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
1069 a->setStatusTip ( tr( "Set Color" ));
1070 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
1072 formatMenu->addAction (a);
1073 actionFormatColor=a;
1074 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
1075 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
1076 a->setShortcut (Qt::CTRL + Qt::Key_K );
1077 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
1078 a->setEnabled (false);
1080 formatMenu->addAction (a);
1081 actionListBranches.append(a);
1082 actionFormatPickColor=a;
1084 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
1085 a->setStatusTip ( tr( "Color branch" ) );
1086 a->setShortcut (Qt::CTRL + Qt::Key_B + Qt::SHIFT);
1087 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
1088 a->setEnabled (false);
1090 formatMenu->addAction (a);
1091 actionListBranches.append(a);
1092 actionFormatColorSubtree=a;
1094 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
1095 a->setStatusTip ( tr( "Color Subtree" ));
1096 a->setShortcut (Qt::CTRL + Qt::Key_B); // Color subtree
1097 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
1098 a->setEnabled (false);
1099 formatMenu->addAction (a);
1101 actionListBranches.append(a);
1102 actionFormatColorSubtree=a;
1104 formatMenu->addSeparator();
1105 actionGroupFormatLinkStyles=new QActionGroup ( this);
1106 actionGroupFormatLinkStyles->setExclusive (true);
1107 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
1108 a->setStatusTip (tr( "Line" ));
1109 a->setToggleAction(true);
1110 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
1111 formatMenu->addAction (a);
1112 actionFormatLinkStyleLine=a;
1113 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
1114 a->setStatusTip (tr( "Line" ));
1115 a->setToggleAction(true);
1116 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
1117 formatMenu->addAction (a);
1118 actionFormatLinkStyleParabel=a;
1119 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
1120 a->setStatusTip (tr( "PolyLine" ));
1121 a->setToggleAction(true);
1122 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
1123 formatMenu->addAction (a);
1124 actionFormatLinkStylePolyLine=a;
1125 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
1126 a->setStatusTip (tr( "PolyParabel" ) );
1127 a->setToggleAction(true);
1128 a->setChecked (true);
1129 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
1130 formatMenu->addAction (a);
1131 actionFormatLinkStylePolyParabel=a;
1133 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
1134 a->setStatusTip (tr( "Hide link" ));
1135 a->setToggleAction(true);
1136 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
1137 actionFormatHideLinkUnselected=a;
1139 formatMenu->addSeparator();
1140 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
1141 a->setStatusTip (tr( "Use same color for links and headings" ));
1142 a->setToggleAction(true);
1143 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
1144 formatMenu->addAction (a);
1145 actionFormatLinkColorHint=a;
1147 pix.fill (Qt::white);
1148 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
1149 a->setStatusTip (tr( "Set Link Color" ));
1150 formatMenu->addAction (a);
1151 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
1152 actionFormatLinkColor=a;
1154 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
1155 a->setStatusTip (tr( "Set Selection Color" ));
1156 formatMenu->addAction (a);
1157 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
1158 actionFormatSelectionColor=a;
1160 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
1161 a->setStatusTip (tr( "Set Background Color" ));
1162 formatMenu->addAction (a);
1163 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
1164 actionFormatBackColor=a;
1166 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
1167 a->setStatusTip (tr( "Set Background image" ));
1168 formatMenu->addAction (a);
1169 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
1170 actionFormatBackImage=a;
1174 void Main::setupViewActions()
1176 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
1177 tb->setLabel( "View Actions" );
1178 tb->setObjectName ("viewTB");
1179 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
1183 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
1184 a->setStatusTip ( tr( "Zoom reset" ) );
1185 a->setShortcut (Qt::CTRL + Qt::Key_0); // Reset zoom
1186 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1188 viewMenu->addAction (a);
1189 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
1191 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
1192 a->setStatusTip (tr( "Zoom in" ));
1193 a->setShortcut(Qt::CTRL + Qt::Key_Plus);
1194 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1196 viewMenu->addAction (a);
1197 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
1199 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
1200 a->setStatusTip (tr( "Zoom out" ));
1201 a->setShortcut(Qt::CTRL + Qt::Key_Minus);
1202 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1204 viewMenu->addAction (a);
1205 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1207 a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
1208 a->setStatusTip (tr( "Show selection" ));
1209 a->setShortcut(Qt::Key_Period);
1210 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1212 viewMenu->addAction (a);
1213 connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
1215 viewMenu->addSeparator();
1217 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
1218 a->setStatusTip ( tr( "Show Note Editor" ));
1219 a->setShortcut ( Qt::CTRL + Qt::Key_E ); // Toggle Note Editor
1220 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1221 a->setToggleAction(true);
1223 viewMenu->addAction (a);
1224 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1225 actionViewToggleNoteEditor=a;
1227 a = new QAction(QPixmap(), tr( "Show tree editor","View action" ),this);
1228 a->setStatusTip ( tr( "Show tree editor" ));
1229 a->setShortcut ( Qt::CTRL + Qt::Key_T ); // Toggle Tree Editor // FIXME-3 originally: color subtree
1230 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1231 a->setToggleAction(true);
1233 viewMenu->addAction (a);
1234 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleTreeEditor() ) );
1235 actionViewToggleTreeEditor=a;
1237 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
1238 a->setStatusTip ( tr( "Show History Window" ));
1239 a->setShortcut ( Qt::CTRL + Qt::Key_H ); // Toggle history window
1240 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1241 a->setToggleAction(true);
1243 viewMenu->addAction (a);
1244 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1245 actionViewToggleHistoryWindow=a;
1247 viewMenu->addAction (actionViewTogglePropertyWindow);
1249 viewMenu->addSeparator();
1251 a = new QAction(tr( "Antialiasing","View action" ),this );
1252 a->setStatusTip ( tr( "Antialiasing" ));
1253 a->setToggleAction(true);
1254 a->setChecked (settings.value("/mainwindow/view/AntiAlias",true).toBool());
1255 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1256 viewMenu->addAction (a);
1257 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
1258 actionViewToggleAntiAlias=a;
1260 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1261 a->setStatusTip (a->text());
1262 a->setToggleAction(true);
1263 a->setChecked (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1264 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1265 viewMenu->addAction (a);
1266 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1267 actionViewToggleSmoothPixmapTransform=a;
1269 a = new QAction(tr( "Next Map","View action" ), this);
1270 a->setStatusTip (a->text());
1271 a->setShortcut (Qt::ALT + Qt::Key_N );
1272 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1273 viewMenu->addAction (a);
1274 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1276 a = new QAction (tr( "Previous Map","View action" ), this );
1277 a->setStatusTip (a->text());
1278 a->setShortcut (Qt::ALT + Qt::Key_P );
1279 switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
1280 viewMenu->addAction (a);
1281 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1285 void Main::setupModeActions()
1287 //QPopupMenu *menu = new QPopupMenu( this );
1288 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1290 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1291 tb->setObjectName ("modesTB");
1293 actionGroupModModes=new QActionGroup ( this);
1294 actionGroupModModes->setExclusive (true);
1295 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1296 a->setShortcut (Qt::Key_J);
1297 switchboard.addConnection(a,tr("Modes","Shortcut group"));
1298 a->setStatusTip ( tr( "Use modifier to color branches" ));
1299 a->setToggleAction(true);
1301 a->setChecked(true);
1302 actionModModeColor=a;
1304 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1305 a->setShortcut( Qt::Key_K);
1306 switchboard.addConnection(a,tr("Modes","Shortcut group"));
1307 a->setStatusTip( tr( "Use modifier to copy" ));
1308 a->setToggleAction(true);
1310 actionModModeCopy=a;
1312 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1313 a->setShortcut (Qt::Key_L);
1314 switchboard.addConnection(a,tr("Modes","Shortcut group"));
1315 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1316 a->setToggleAction(true);
1318 actionModModeXLink=a;
1322 void Main::setupFlagActions()
1324 // Create System Flags
1327 Flag *flag=new Flag(flagsPath+"flag-note.png");
1328 setupFlag (flag,tb,"system-note",tr("Note","SystemFlag"));
1330 flag=new Flag(flagsPath+"flag-url.png");
1331 setupFlag (flag,tb,"system-url",tr("URL to Document ","SystemFlag"));
1333 flag=new Flag(flagsPath+"flag-url-bugzilla-novell.png");
1334 setupFlag (flag,tb,"system-url-bugzilla-novell",tr("URL to Bugzilla ","SystemFlag"));
1336 flag=new Flag(flagsPath+"flag-vymlink.png");
1337 setupFlag (flag,tb,"system-vymLink",tr("Link to another vym map","SystemFlag"));
1339 flag=new Flag(flagsPath+"flag-scrolled-right.png");
1340 setupFlag (flag,tb,"system-scrolledright",tr("subtree is scrolled","SystemFlag"));
1342 flag=new Flag(flagsPath+"flag-tmpUnscrolled-right.png");
1343 setupFlag (flag,tb,"system-tmpUnscrolledRight",tr("subtree is temporary scrolled","SystemFlag"));
1345 flag=new Flag(flagsPath+"flag-hideexport.png");
1346 setupFlag (flag,tb,"system-hideInExport",tr("Hide object in exported maps","SystemFlag"));
1348 // Create Standard Flags
1349 tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1350 tb->setObjectName ("standardFlagTB");
1351 standardFlagsMaster->setToolBar (tb);
1353 flag=new Flag(flagsPath+"flag-exclamationmark.png");
1354 flag->setGroup("standard-mark");
1355 setupFlag (flag,tb,"exclamationmark",tr("Take care!","Standardflag"));
1357 flag=new Flag(flagsPath+"flag-questionmark.png");
1358 flag->setGroup("standard-mark");
1359 setupFlag (flag,tb,"questionmark",tr("Really?","Standardflag"));
1361 flag=new Flag(flagsPath+"flag-hook-green.png");
1362 flag->setGroup("standard-status");
1363 setupFlag (flag,tb,"hook-green",tr("Status - ok,done","Standardflag"));
1365 flag=new Flag(flagsPath+"flag-wip.png");
1366 flag->setGroup("standard-status");
1367 setupFlag (flag,tb,"wip",tr("Status - work in progress","Standardflag"));
1369 flag=new Flag(flagsPath+"flag-cross-red.png");
1370 flag->setGroup("standard-status");
1371 setupFlag (flag,tb,"cross-red",tr("Status - missing, not started","Standardflag"));
1374 flag=new Flag(flagsPath+"flag-stopsign.png");
1375 setupFlag (flag,tb,"stopsign",tr("This won't work!","Standardflag"));
1377 flag=new Flag(flagsPath+"flag-smiley-good.png");
1378 flag->setGroup("standard-smiley");
1379 setupFlag (flag,tb,"smiley-good",tr("Good","Standardflag"));
1381 flag=new Flag(flagsPath+"flag-smiley-sad.png");
1382 flag->setGroup("standard-smiley");
1383 setupFlag (flag,tb,"smiley-sad",tr("Bad","Standardflag"));
1385 flag=new Flag(flagsPath+"flag-smiley-omg.png");
1386 flag->setGroup("standard-smiley");
1387 setupFlag (flag,tb,"smiley-omb",tr("Oh no!","Standardflag"));
1388 // Original omg.png (in KDE emoticons)
1391 flag=new Flag(flagsPath+"flag-kalarm.png");
1392 setupFlag (flag,tb,"clock",tr("Time critical","Standardflag"));
1394 flag=new Flag(flagsPath+"flag-phone.png");
1395 setupFlag (flag,tb,"phone",tr("Call...","Standardflag"));
1397 flag=new Flag(flagsPath+"flag-lamp.png");
1398 setupFlag (flag,tb,"lamp",tr("Idea!","Standardflag"));
1400 flag=new Flag(flagsPath+"flag-arrow-up.png");
1401 flag->setGroup("standard-arrow");
1402 setupFlag (flag,tb,"arrow-up",tr("Important","Standardflag"));
1404 flag=new Flag(flagsPath+"flag-arrow-down.png");
1405 flag->setGroup("standard-arrow");
1406 setupFlag (flag,tb,"arrow-down",tr("Unimportant","Standardflag"));
1408 flag=new Flag(flagsPath+"flag-arrow-2up.png");
1409 flag->setGroup("standard-arrow");
1410 setupFlag (flag,tb,"2arrow-up",tr("Very important!","Standardflag"));
1412 flag=new Flag(flagsPath+"flag-arrow-2down.png");
1413 flag->setGroup("standard-arrow");
1414 setupFlag (flag,tb,"2arrow-down",tr("Very unimportant!","Standardflag"));
1417 flag=new Flag(flagsPath+"flag-thumb-up.png");
1418 flag->setGroup("standard-thumb");
1419 setupFlag (flag,tb,"thumb-up",tr("I like this","Standardflag"));
1421 flag=new Flag(flagsPath+"flag-thumb-down.png");
1422 flag->setGroup("standard-thumb");
1423 setupFlag (flag,tb,"thumb-down",tr("I do not like this","Standardflag"));
1426 flag=new Flag(flagsPath+"flag-rose.png");
1427 setupFlag (flag,tb,"rose",tr("Rose","Standardflag"));
1429 flag=new Flag(flagsPath+"flag-heart.png");
1430 setupFlag (flag,tb,"heart",tr("I just love...","Standardflag"));
1432 flag=new Flag(flagsPath+"flag-present.png");
1433 setupFlag (flag,tb,"present",tr("Surprise!","Standardflag"));
1435 flag=new Flag(flagsPath+"flag-flash.png");
1436 setupFlag (flag,tb,"flash",tr("Dangerous","Standardflag"));
1438 // Original: xsldbg_output.png
1439 flag=new Flag(flagsPath+"flag-info.png");
1440 setupFlag (flag,tb,"info",tr("Info","Standardflag"));
1442 // Original khelpcenter.png
1443 flag=new Flag(flagsPath+"flag-lifebelt.png");
1444 setupFlag (flag,tb,"lifebelt",tr("This will help","Standardflag"));
1447 flag=new Flag(flagsPath+"freemind/warning.png");
1448 flag->setVisible(false);
1449 setupFlag (flag,tb, "freemind-warning",tr("Important","Freemind-Flag"));
1451 for (int i=1; i<8; i++)
1453 flag=new Flag(flagsPath+QString("freemind/priority-%1.png").arg(i));
1454 setupFlag (flag,tb, QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
1457 flag=new Flag(flagsPath+"freemind/back.png");
1458 flag->setVisible(false);
1459 setupFlag (flag,tb,"freemind-back",tr("Back","Freemind-Flag"));
1461 flag=new Flag(flagsPath+"freemind/forward.png");
1462 flag->setVisible(false);
1463 setupFlag (flag,tb,"freemind-forward",tr("forward","Freemind-Flag"));
1465 flag=new Flag(flagsPath+"freemind/attach.png");
1466 flag->setVisible(false);
1467 setupFlag (flag,tb,"freemind-attach",tr("Look here","Freemind-Flag"));
1469 flag=new Flag(flagsPath+"freemind/clanbomber.png");
1470 flag->setVisible(false);
1471 setupFlag (flag,tb,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
1473 flag=new Flag(flagsPath+"freemind/desktopnew.png");
1474 flag->setVisible(false);
1475 setupFlag (flag,tb,"freemind-desktopnew",tr("Don't flagrget","Freemind-Flag"));
1477 flag=new Flag(flagsPath+"freemind/flag.png");
1478 flag->setVisible(false);
1479 setupFlag (flag,tb,"freemind-flag",tr("Flag","Freemind-Flag"));
1482 flag=new Flag(flagsPath+"freemind/gohome.png");
1483 flag->setVisible(false);
1484 setupFlag (flag,tb,"freemind-gohome",tr("Home","Freemind-Flag"));
1486 flag=new Flag(flagsPath+"freemind/kaddressbook.png");
1487 flag->setVisible(false);
1488 setupFlag (flag,tb,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
1490 flag=new Flag(flagsPath+"freemind/knotify.png");
1491 flag->setVisible(false);
1492 setupFlag (flag,tb,"freemind-knotify",tr("Music","Freemind-Flag"));
1494 flag=new Flag(flagsPath+"freemind/korn.png");
1495 flag->setVisible(false);
1496 setupFlag (flag,tb,"freemind-korn",tr("Mailbox","Freemind-Flag"));
1498 flag=new Flag(flagsPath+"freemind/mail.png");
1499 flag->setVisible(false);
1500 setupFlag (flag,tb,"freemind-mail",tr("Maix","Freemind-Flag"));
1502 flag=new Flag(flagsPath+"freemind/password.png");
1503 flag->setVisible(false);
1504 setupFlag (flag,tb,"freemind-password",tr("Password","Freemind-Flag"));
1506 flag=new Flag(flagsPath+"freemind/pencil.png");
1507 flag->setVisible(false);
1508 setupFlag (flag,tb,"freemind-pencil",tr("To be improved","Freemind-Flag"));
1510 flag=new Flag(flagsPath+"freemind/stop.png");
1511 flag->setVisible(false);
1512 setupFlag (flag,tb,"freemind-stop",tr("Stop","Freemind-Flag"));
1514 flag=new Flag(flagsPath+"freemind/wizard.png");
1515 flag->setVisible(false);
1516 setupFlag (flag,tb,"freemind-wizard",tr("Magic","Freemind-Flag"));
1518 flag=new Flag(flagsPath+"freemind/xmag.png");
1519 flag->setVisible(false);
1520 setupFlag (flag,tb,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
1522 flag=new Flag(flagsPath+"freemind/bell.png");
1523 flag->setVisible(false);
1524 setupFlag (flag,tb,"freemind-bell",tr("Reminder","Freemind-Flag"));
1526 flag=new Flag(flagsPath+"freemind/bookmark.png");
1527 flag->setVisible(false);
1528 setupFlag (flag,tb,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
1530 flag= new Flag(flagsPath+"freemind/penguin.png");
1531 flag->setVisible(false);
1532 setupFlag (flag,tb,"freemind-penguin",tr("Linux","Freemind-Flag"));
1534 flag=new Flag (flagsPath+"freemind/licq.png");
1535 flag->setVisible(false);
1536 setupFlag (flag,tb,"freemind-licq",tr("Sweet","Freemind-Flag"));
1539 void Main::setupFlag (Flag *flag, QToolBar *tb, const QString &name, const QString &tooltip)
1541 flag->setName(name);
1542 flag->setToolTip (tooltip);
1546 a=new QAction (flag->getPixmap(),name,this);
1549 flag->setAction (a);
1550 a->setVisible (flag->isVisible());
1551 a->setCheckable(true);
1552 a->setObjectName(name);
1553 a->setToolTip(tooltip);
1554 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1555 standardFlagsMaster->addFlag (flag);
1559 systemFlagsMaster->addFlag (flag);
1564 void Main::setupNetworkActions()
1566 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1568 QMenu *netMenu = menuBar()->addMenu( "Network" );
1572 a = new QAction( "Start TCPserver for MapEditor",this);
1573 //a->setStatusTip ( "Set application to open pdf files"));
1574 //a->setShortcut ( Qt::ALT + Qt::Key_T ); //New TCP server
1575 switchboard.addConnection(a,tr("Network shortcuts","Shortcut group"));
1576 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1577 netMenu->addAction (a);
1579 a = new QAction( "Connect MapEditor to server",this);
1580 //a->setStatusTip ( "Set application to open pdf files"));
1581 a->setShortcut ( Qt::ALT + Qt::Key_C ); // Connect to server
1582 switchboard.addConnection(a,tr("Network shortcuts","Shortcut group"));
1583 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1584 netMenu->addAction (a);
1588 void Main::setupSettingsActions()
1590 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1594 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1595 a->setStatusTip ( tr( "Set application to open pdf files"));
1596 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1597 settingsMenu->addAction (a);
1599 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1600 a->setStatusTip( tr( "Set application to open external links"));
1601 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1602 settingsMenu->addAction (a);
1604 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1605 a->setStatusTip( tr( "Set path for macros"));
1606 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1607 settingsMenu->addAction (a);
1609 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1610 a->setStatusTip( tr( "Set number of undo levels"));
1611 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1612 settingsMenu->addAction (a);
1614 settingsMenu->addSeparator();
1616 a = new QAction( tr( "Autosave","Settings action"), this);
1617 a->setStatusTip( tr( "Autosave"));
1618 a->setToggleAction(true);
1619 a->setChecked ( settings.value ("/mainwindow/autosave/use",false).toBool());
1620 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1621 settingsMenu->addAction (a);
1622 actionSettingsAutosaveToggle=a;
1624 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1625 a->setStatusTip( tr( "Autosave time"));
1626 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1627 settingsMenu->addAction (a);
1628 actionSettingsAutosaveTime=a;
1630 a = new QAction( tr( "Write backup file on save","Settings action"), this);
1631 a->setStatusTip( tr( "Write backup file on save"));
1632 a->setToggleAction(true);
1633 a->setChecked ( settings.value ("/mainwindow/writeBackupFile",false).toBool());
1634 connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) );
1635 settingsMenu->addAction (a);
1636 actionSettingsWriteBackupFile=a;
1638 settingsMenu->addSeparator();
1640 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1641 a->setStatusTip( tr( "Edit branch after adding it" ));
1642 a->setToggleAction(true);
1643 a->setChecked ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1644 settingsMenu->addAction (a);
1645 actionSettingsAutoEditNewBranch=a;
1647 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1648 a->setStatusTip( tr( "Select branch after adding it" ));
1649 a->setToggleAction(true);
1650 a->setChecked ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1651 settingsMenu->addAction (a);
1652 actionSettingsAutoSelectNewBranch=a;
1654 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1655 a->setStatusTip( tr( "Select heading before editing" ));
1656 a->setToggleAction(true);
1657 a->setChecked ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1658 settingsMenu->addAction (a);
1659 actionSettingsAutoSelectText=a;
1661 a= new QAction( tr( "Delete key","Settings action" ), this);
1662 a->setStatusTip( tr( "Delete key for deleting branches" ));
1663 a->setToggleAction(true);
1664 a->setChecked ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1665 settingsMenu->addAction (a);
1666 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1667 actionSettingsUseDelKey=a;
1669 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1670 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1671 a->setToggleAction(true);
1672 a->setChecked ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1673 settingsMenu->addAction (a);
1674 actionSettingsUseFlagGroups=a;
1676 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1677 a->setStatusTip( tr( "Use hide flag during exports " ));
1678 a->setToggleAction(true);
1679 a->setChecked ( settings.value ("/export/useHideExport",true).toBool() );
1680 settingsMenu->addAction (a);
1681 actionSettingsUseHideExport=a;
1683 settingsMenu->addSeparator();
1685 a = new QAction( tr( "Animation","Settings action"), this);
1686 a->setStatusTip( tr( "Animation"));
1687 a->setToggleAction(true);
1688 a->setChecked (settings.value("/animation/use",true).toBool() );
1689 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) );
1690 settingsMenu->addAction (a);
1691 actionSettingsUseAnimation=a;
1693 a = new QAction( tr( "Automatic layout","Settings action"), this);
1694 a->setStatusTip( tr( "Automatic layout"));
1695 a->setToggleAction(true);
1696 a->setChecked ( settings.value ("/mainwindow/autoLayout/use",true).toBool());
1697 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutoLayoutToggle() ) );
1698 settingsMenu->addAction (a);
1699 actionSettingsAutoLayoutToggle=a;
1704 void Main::setupTestActions()
1706 QMenu *testMenu = menuBar()->addMenu( tr( "Test" ));
1709 a = new QAction( "Test function 1" , this);
1710 a->setStatusTip( "Call test function 1" );
1711 a->setShortcut (Qt::SHIFT + Qt::Key_T); // Test function 1
1712 switchboard.addConnection(a,tr("Test shortcuts","Shortcut group"));
1713 testMenu->addAction (a);
1714 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1716 a = new QAction( "Test function 2" , this);
1717 a->setStatusTip( "Call test function 2" );
1718 a->setShortcut (Qt::ALT + Qt::Key_T); // Test function 2
1719 switchboard.addConnection(a,tr("Test shortcuts","Shortcut group"));
1720 testMenu->addAction (a);
1721 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1723 a = new QAction( "Command" , this);
1724 a->setStatusTip( "Enter command to call in editor" );
1725 switchboard.addConnection(a,tr("Test shortcuts","Shortcut group"));
1726 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1727 testMenu->addAction (a);
1731 void Main::setupHelpActions()
1733 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1736 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1737 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1738 switchboard.addConnection(a,tr("Help shortcuts","Shortcut group"));
1739 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1740 helpMenu->addAction (a);
1742 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1743 a->setStatusTip( tr( "Open VYM example maps " ));
1744 switchboard.addConnection(a,tr("Help shortcuts","Shortcut group"));
1745 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1746 helpMenu->addAction (a);
1748 a = new QAction( tr( "About VYM","Help action" ), this);
1749 a->setStatusTip( tr( "About VYM")+vymName);
1750 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1751 helpMenu->addAction (a);
1753 a = new QAction( tr( "About QT","Help action" ), this);
1754 a->setStatusTip( tr( "Information about QT toolkit" ));
1755 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1756 helpMenu->addAction (a);
1760 void Main::setupContextMenus()
1762 // Context Menu for branch or mapcenter
1763 branchContextMenu =new QMenu (this);
1764 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1765 branchContextMenu->addSeparator();
1768 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1769 branchAddContextMenu->addAction (actionPaste );
1770 branchAddContextMenu->addAction ( actionAddMapCenter );
1771 branchAddContextMenu->addAction ( actionAddBranch );
1772 branchAddContextMenu->addAction ( actionAddBranchBefore );
1773 branchAddContextMenu->addAction ( actionAddBranchAbove);
1774 branchAddContextMenu->addAction ( actionAddBranchBelow );
1775 branchAddContextMenu->addSeparator();
1776 branchAddContextMenu->addAction ( actionImportAdd );
1777 branchAddContextMenu->addAction ( actionImportReplace );
1780 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1781 branchRemoveContextMenu->addAction (actionCut);
1782 branchRemoveContextMenu->addAction ( actionDelete );
1783 branchRemoveContextMenu->addAction ( actionDeleteKeepChildren );
1784 branchRemoveContextMenu->addAction ( actionDeleteChildren );
1787 actionSaveBranch->addTo( branchContextMenu );
1788 actionFileNewCopy->addTo (branchContextMenu );
1789 actionDetach->addTo (branchContextMenu );
1791 branchContextMenu->addSeparator();
1792 branchContextMenu->addAction ( actionLoadImage);
1793 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1794 branchContextMenu->addAction ( actionAddAttribute);
1796 // Submenu for Links (URLs, vymLinks)
1797 branchLinksContextMenu =new QMenu (this);
1799 branchContextMenu->addSeparator();
1800 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1801 branchLinksContextMenu->addAction ( actionOpenURL );
1802 branchLinksContextMenu->addAction ( actionOpenURLTab );
1803 branchLinksContextMenu->addAction ( actionOpenMultipleVisURLTabs );
1804 branchLinksContextMenu->addAction ( actionOpenMultipleURLTabs );
1805 branchLinksContextMenu->addAction ( actionURL );
1806 branchLinksContextMenu->addAction ( actionLocalURL );
1807 branchLinksContextMenu->addAction ( actionHeading2URL );
1808 branchLinksContextMenu->addAction ( actionBugzilla2URL );
1809 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1811 branchLinksContextMenu->addAction ( actionGetBugzillaData );
1812 branchLinksContextMenu->addAction ( actionFATE2URL );
1814 branchLinksContextMenu->addSeparator();
1815 branchLinksContextMenu->addAction ( actionOpenVymLink );
1816 branchLinksContextMenu->addAction ( actionOpenMultipleVymLinks );
1817 branchLinksContextMenu->addAction ( actionVymLink );
1818 branchLinksContextMenu->addAction ( actionDeleteVymLink );
1821 // Context Menu for XLinks in a branch menu
1822 // This will be populated "on demand" in MapEditor::updateActions
1823 branchContextMenu->addSeparator();
1824 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1825 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1828 // Context menu for floatimage
1829 floatimageContextMenu =new QMenu (this);
1830 QAction *a= new QAction (tr ("Save image","Context action"),this);
1831 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1832 floatimageContextMenu->addAction (a);
1834 floatimageContextMenu->addSeparator();
1835 actionCopy->addTo( floatimageContextMenu );
1836 actionCut->addTo( floatimageContextMenu );
1838 floatimageContextMenu->addSeparator();
1839 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1842 // Context menu for canvas
1843 canvasContextMenu =new QMenu (this);
1844 actionAddMapCenter->addTo( canvasContextMenu );
1845 actionMapInfo->addTo( canvasContextMenu );
1846 canvasContextMenu->insertSeparator();
1847 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1848 canvasContextMenu->insertSeparator();
1849 actionFormatLinkColorHint->addTo( canvasContextMenu );
1850 actionFormatLinkColor->addTo( canvasContextMenu );
1851 actionFormatSelectionColor->addTo( canvasContextMenu );
1852 actionFormatBackColor->addTo( canvasContextMenu );
1853 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME-4 makes vym too slow: postponed for later version
1855 // Menu for last opened files
1857 for (int i = 0; i < MaxRecentFiles; ++i)
1859 recentFileActions[i] = new QAction(this);
1860 recentFileActions[i]->setVisible(false);
1861 fileLastMapsMenu->addAction(recentFileActions[i]);
1862 connect(recentFileActions[i], SIGNAL(triggered()),
1863 this, SLOT(fileLoadRecent()));
1865 setupRecentMapsMenu();
1868 void Main::setupRecentMapsMenu()
1870 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1872 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1874 for (int i = 0; i < numRecentFiles; ++i) {
1875 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1876 recentFileActions[i]->setText(text);
1877 recentFileActions[i]->setData(files[i]);
1878 recentFileActions[i]->setVisible(true);
1880 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1881 recentFileActions[j]->setVisible(false);
1884 void Main::setupMacros()
1886 for (int i = 0; i <= 11; i++)
1888 macroActions[i] = new QAction(this);
1889 macroActions[i]->setData(i);
1890 addAction (macroActions[i]);
1891 //switchboard.addConnection(macroActions[i],tr("Macro shortcuts","Shortcut group"));
1892 connect(macroActions[i], SIGNAL(triggered()),
1893 this, SLOT(callMacro()));
1895 macroActions[0]->setShortcut ( Qt::Key_F1 );
1896 macroActions[1]->setShortcut ( Qt::Key_F2 );
1897 macroActions[2]->setShortcut ( Qt::Key_F3 );
1898 macroActions[3]->setShortcut ( Qt::Key_F4 );
1899 macroActions[4]->setShortcut ( Qt::Key_F5 );
1900 macroActions[5]->setShortcut ( Qt::Key_F6 );
1901 macroActions[6]->setShortcut ( Qt::Key_F7 );
1902 macroActions[7]->setShortcut ( Qt::Key_F8 );
1903 macroActions[8]->setShortcut ( Qt::Key_F9 );
1904 macroActions[9]->setShortcut ( Qt::Key_F10 );
1905 macroActions[10]->setShortcut ( Qt::Key_F11 );
1906 macroActions[11]->setShortcut ( Qt::Key_F12 );
1909 void Main::hideEvent (QHideEvent * )
1911 if (!textEditor->isMinimized() ) textEditor->hide();
1914 void Main::showEvent (QShowEvent * )
1916 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1920 MapEditor* Main::currentMapEditor() const
1922 if ( tabWidget->currentPage())
1923 return vymViews.at(tabWidget->currentIndex())->getMapEditor();
1927 uint Main::currentModelID() const
1930 return currentModel()->getID();
1934 VymModel* Main::currentModel() const
1936 if ( tabWidget->currentPage())
1937 return vymViews.at(tabWidget->currentIndex())->getModel();
1941 VymModel* Main::getModel(uint id) const
1944 for (int i=0; i<vymViews.count();i++)
1945 if (vymViews.at(i)->getModel()->getID()==id)
1946 return vymViews.at(i)->getModel();
1951 void Main::editorChanged(QWidget *)
1953 // Unselect all possibly selected objects
1954 // (Important to update note editor)
1956 for (int i=0;i<=tabWidget->count() -1;i++)
1958 m= vymViews.at(i)->getModel();
1959 if (m) m->unselect();
1962 if (m) m->reselect();
1964 // Update actions to in menus and toolbars according to editor
1968 void Main::fileNew()
1970 VymModel *vm=new VymModel;
1972 /////////////////////////////////////
1973 // new ModelTest(vm, this); //FIXME-3
1974 /////////////////////////////////////
1976 VymView *vv=new VymView (vm);
1977 vymViews.append (vv);
1978 tabWidget->addTab (vv,tr("unnamed","MainWindow: name for new and empty file"));
1979 tabWidget->setCurrentIndex (vymViews.count() );
1982 // Create MapCenter for empty map
1986 // For the very first map we do not have flagrows yet...
1990 void Main::fileNewCopy()
1992 QString fn="unnamed";
1993 VymModel *srcModel=currentModel();
1998 VymModel *dstModel=vymViews.last()->getModel();
1999 dstModel->select("mc:");
2000 dstModel->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
2004 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
2006 ErrorCode err=success;
2008 // fn is usually the archive, mapfile the file after uncompressing
2011 // Make fn absolute (needed for unzip)
2012 fn=QDir (fn).absPath();
2018 // Check, if map is already loaded
2020 while (i<=tabWidget->count() -1)
2022 if (vymViews.at(i)->getModel()->getFilePath() == fn)
2024 // Already there, ask for confirmation
2025 QMessageBox mb( vymName,
2026 tr("The map %1\nis already opened."
2027 "Opening the same map in multiple editors may lead \n"
2028 "to confusion when finishing working with vym."
2029 "Do you want to").arg(fn),
2030 QMessageBox::Warning,
2031 QMessageBox::Yes | QMessageBox::Default,
2032 QMessageBox::Cancel | QMessageBox::Escape,
2033 QMessageBox::NoButton);
2034 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
2035 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2038 case QMessageBox::Yes:
2039 // end loop and load anyway
2040 i=tabWidget->count();
2042 case QMessageBox::Cancel:
2052 int tabIndex=tabWidget->currentPageIndex();
2055 if ( !fn.isEmpty() )
2057 vm = currentModel();
2058 // Check first, if mapeditor exists
2059 // If it is not default AND we want a new map,
2060 // create a new mapeditor in a new tab
2061 if ( lmode==NewMap && (!vm || !vm->isDefault() ) )
2064 VymView *vv=new VymView (vm);
2065 vymViews.append (vv);
2066 tabWidget->addTab (vv,fn);
2067 tabIndex=tabWidget->count()-1;
2068 tabWidget->setCurrentPage (tabIndex);
2072 // Check, if file exists (important for creating new files
2073 // from command line
2074 if (!QFile(fn).exists() )
2076 QMessageBox mb( vymName,
2077 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
2078 QMessageBox::Question,
2080 QMessageBox::Cancel | QMessageBox::Default,
2081 QMessageBox::NoButton );
2083 mb.setButtonText( QMessageBox::Yes, tr("Create"));
2084 mb.setButtonText( QMessageBox::No, tr("Cancel"));
2087 case QMessageBox::Yes:
2089 currentMapEditor()->getModel()->setFilePath(fn);
2090 tabWidget->setTabText (tabIndex,
2091 currentMapEditor()->getModel()->getFileName() );
2092 statusBar()->message( "Created " + fn , statusbarTime );
2095 case QMessageBox::Cancel:
2096 // don't create new map
2097 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
2104 //tabWidget->currentPage() won't be NULL here, because of above...
2105 tabWidget->setCurrentIndex (tabIndex);
2106 //FIXME-3 no me anymore... me->viewport()->setFocus();
2110 // Save existing filename in case we import
2111 QString fn_org=vm->getFilePath();
2113 // Finally load map into mapEditor
2114 vm->setFilePath (fn);
2115 err=vm->load(fn,lmode,ftype);
2117 // Restore old (maybe empty) filepath, if this is an import
2119 vm->setFilePath (fn_org);
2122 // Finally check for errors and go home
2125 if (lmode==NewMap) fileCloseMap();
2126 statusBar()->message( "Could not load " + fn, statusbarTime );
2131 vm->setFilePath (fn);
2132 tabWidget->setTabText (tabIndex, vm->getFileName());
2133 if (!isInTmpDir (fn))
2135 // Only append to lastMaps if not loaded from a tmpDir
2136 // e.g. imported bookmarks are in a tmpDir
2137 addRecentMap(vm->getFilePath() );
2139 actionFilePrint->setEnabled (true);
2141 statusBar()->message( "Loaded " + fn, statusbarTime );
2148 void Main::fileLoad(const LoadMode &lmode)
2150 QStringList filters;
2151 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
2152 QFileDialog *fd=new QFileDialog( this);
2153 fd->setDir (lastFileDir);
2154 fd->setFileMode (QFileDialog::ExistingFiles);
2155 fd->setFilters (filters);
2159 fd->setCaption(vymName+ " - " +tr("Load vym map"));
2162 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
2165 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
2171 if ( fd->exec() == QDialog::Accepted )
2173 lastFileDir=fd->directory().path();
2174 QStringList flist = fd->selectedFiles();
2175 QStringList::Iterator it = flist.begin();
2177 progressCounter=flist.count();
2178 progressCounterTotal=flist.count();
2179 while( it != flist.end() )
2182 fileLoad(*it, lmode);
2189 void Main::fileLoad()
2194 void Main::fileLoadRecent()
2196 QAction *action = qobject_cast<QAction *>(sender());
2198 fileLoad (action->data().toString(), NewMap);
2201 void Main::addRecentMap (const QString &fileName)
2204 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
2205 files.removeAll(fileName);
2206 files.prepend(fileName);
2207 while (files.size() > MaxRecentFiles)
2210 settings.setValue("/mainwindow/recentFileList", files);
2212 setupRecentMapsMenu();
2215 void Main::fileSave(VymModel *m, const SaveMode &savemode)
2219 if ( m->getFilePath().isEmpty() )
2221 // We have no filepath yet,
2222 // call fileSaveAs() now, this will call fileSave()
2224 // First switch to editor
2225 //FIXME-3 needed??? tabWidget->setCurrentWidget (m->getMapEditor());
2226 fileSaveAs(savemode);
2229 if (m->save (savemode)==success)
2231 statusBar()->message(
2232 tr("Saved %1").arg(m->getFilePath()),
2234 addRecentMap (m->getFilePath() );
2236 statusBar()->message(
2237 tr("Couldn't save ").arg(m->getFilePath()),
2241 void Main::fileSave()
2243 fileSave (currentModel(), CompleteMap);
2246 void Main::fileSave(VymModel *m)
2248 fileSave (m,CompleteMap);
2251 void Main::fileSaveAs(const SaveMode& savemode)
2255 if (currentMapEditor())
2257 if (savemode==CompleteMap)
2258 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2260 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2261 if ( !fn.isEmpty() )
2263 // Check for existing file
2264 if (QFile (fn).exists())
2266 QMessageBox mb( vymName,
2267 tr("The file %1\nexists already. Do you want to").arg(fn),
2268 QMessageBox::Warning,
2269 QMessageBox::Yes | QMessageBox::Default,
2270 QMessageBox::Cancel | QMessageBox::Escape,
2271 QMessageBox::NoButton);
2272 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2273 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2276 case QMessageBox::Yes:
2279 case QMessageBox::Cancel:
2286 // New file, add extension to filename, if missing
2287 // This is always .vym or .vyp, depending on savemode
2288 if (savemode==CompleteMap)
2290 if (!fn.contains (".vym") && !fn.contains (".xml"))
2294 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2303 VymModel *m=currentModel();
2305 fileSave(m, savemode);
2307 // Set name of tab, assuming current tab is the one we just saved
2308 if (savemode==CompleteMap)
2309 tabWidget->setTabText (tabWidget->currentIndex(), m->getFileName() );
2315 void Main::fileSaveAs()
2317 fileSaveAs (CompleteMap);
2320 void Main::fileImportKDE3Bookmarks()
2322 ImportKDE3Bookmarks im;
2324 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2325 currentMapEditor()->getModel()->setFilePath ("");
2328 void Main::fileImportKDE4Bookmarks()
2330 ImportKDE4Bookmarks im;
2332 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2333 currentMapEditor()->getModel()->setFilePath ("");
2336 void Main::fileImportFirefoxBookmarks()
2338 Q3FileDialog *fd=new Q3FileDialog( this);
2339 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2340 fd->setMode (Q3FileDialog::ExistingFiles);
2341 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2342 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2345 if ( fd->exec() == QDialog::Accepted )
2347 ImportFirefoxBookmarks im;
2348 QStringList flist = fd->selectedFiles();
2349 QStringList::Iterator it = flist.begin();
2350 while( it != flist.end() )
2353 if (im.transform() &&
2354 aborted!=fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2355 currentMapEditor() )
2356 currentMapEditor()->getModel()->setFilePath ("");
2363 void Main::fileImportFreemind()
2365 QStringList filters;
2366 filters <<"Freemind map (*.mm)"<<"All files (*)";
2367 QFileDialog *fd=new QFileDialog( this);
2368 fd->setDir (lastFileDir);
2369 fd->setFileMode (QFileDialog::ExistingFiles);
2370 fd->setFilters (filters);
2371 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2375 if ( fd->exec() == QDialog::Accepted )
2377 lastFileDir=fd->directory().path();
2378 QStringList flist = fd->selectedFiles();
2379 QStringList::Iterator it = flist.begin();
2380 while( it != flist.end() )
2383 if ( fileLoad (fn,NewMap, FreemindMap) )
2385 currentMapEditor()->getModel()->setFilePath ("");
2394 void Main::fileImportMM()
2398 Q3FileDialog *fd=new Q3FileDialog( this);
2399 fd->setDir (lastFileDir);
2400 fd->setMode (Q3FileDialog::ExistingFiles);
2401 fd->addFilter ("Mind Manager (*.mmap)");
2402 fd->setCaption(tr("Import")+" "+"Mind Manager");
2405 if ( fd->exec() == QDialog::Accepted )
2407 lastFileDir=fd->dirPath();
2408 QStringList flist = fd->selectedFiles();
2409 QStringList::Iterator it = flist.begin();
2410 while( it != flist.end() )
2413 if (im.transform() &&
2414 success==fileLoad (im.getTransformedFile(),NewMap) &&
2415 currentMapEditor() )
2416 currentMapEditor()->getModel()->setFilePath ("");
2423 void Main::fileImportDir()
2425 VymModel *m=currentModel();
2426 if (m) m->importDir();
2429 void Main::fileExportXML()
2431 VymModel *m=currentModel();
2432 if (m) m->exportXML();
2435 void Main::fileExportHTML()
2437 VymModel *m=currentModel();
2438 if (m) m->exportHTML();
2442 void Main::fileExportXHTML()
2444 VymModel *m=currentModel();
2445 if (m) m->exportXHTML();
2448 void Main::fileExportImage()
2450 VymModel *m=currentModel();
2451 if (m) m->exportImage();
2454 void Main::fileExportAO()
2456 VymModel *m=currentModel();
2457 if (m) m->exportAO();
2460 void Main::fileExportASCII()
2462 VymModel *m=currentModel();
2463 if (m) m->exportASCII();
2466 void Main::fileExportCSV() //FIXME-3 not scriptable yet
2468 VymModel *m=currentModel();
2473 ex.addFilter ("CSV (*.csv)");
2474 ex.setDir(lastImageDir);
2475 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2476 if (ex.execDialog() )
2478 m->setExportMode(true);
2480 m->setExportMode(false);
2485 void Main::fileExportLaTeX() //FIXME-3 not scriptable yet
2487 VymModel *m=currentModel();
2492 ex.addFilter ("Tex (*.tex)");
2493 ex.setDir(lastImageDir);
2494 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2495 if (ex.execDialog() )
2497 m->setExportMode(true);
2499 m->setExportMode(false);
2504 void Main::fileExportKDE3Bookmarks() //FIXME-3 not scriptable yet
2506 ExportKDE3Bookmarks ex;
2507 VymModel *m=currentModel();
2515 void Main::fileExportKDE4Bookmarks() //FIXME-3 not scriptable yet
2517 ExportKDE4Bookmarks ex;
2518 VymModel *m=currentModel();
2526 void Main::fileExportTaskjuggler() //FIXME-3 not scriptable yet
2528 ExportTaskjuggler ex;
2529 VymModel *m=currentModel();
2533 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2534 ex.setDir(lastImageDir);
2535 ex.addFilter ("Taskjuggler (*.tjp)");
2536 if (ex.execDialog() )
2538 m->setExportMode(true);
2540 m->setExportMode(false);
2545 void Main::fileExportOOPresentation() //FIXME-3 not scriptable yet
2547 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2548 // TODO add preview in dialog
2549 //ImagePreview *p =new ImagePreview (fd);
2550 //fd->setContentsPreviewEnabled( TRUE );
2551 //fd->setContentsPreview( p, p );
2552 //fd->setPreviewMode( QFileDialog::Contents );
2553 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2554 fd->setDir (QDir().current());
2555 if (fd->foundConfig())
2559 if ( fd->exec() == QDialog::Accepted )
2561 QString fn=fd->selectedFile();
2562 if (!fn.contains (".odp"))
2565 //lastImageDir=fn.left(fn.findRev ("/"));
2566 VymModel *m=currentModel();
2567 if (m) m->exportOOPresentation(fn,fd->selectedConfig());
2571 QMessageBox::warning(0,
2573 tr("Couldn't find configuration for export to Open Office\n"));
2577 void Main::fileCloseMap()
2579 VymModel *m=currentModel();
2582 if (m->hasChanged())
2584 QMessageBox mb( vymName,
2585 tr("The map %1 has been modified but not saved yet. Do you want to").arg(m->getFileName()),
2586 QMessageBox::Warning,
2587 QMessageBox::Yes | QMessageBox::Default,
2589 QMessageBox::Cancel | QMessageBox::Escape );
2590 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2591 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2594 case QMessageBox::Yes:
2596 fileSave(m, CompleteMap);
2598 case QMessageBox::No:
2599 // close without saving
2601 case QMessageBox::Cancel:
2606 // And here comes the segfault, because removeTab triggers
2607 // FIXME-3 currentChanged->Main::editorChanged -> updateActions and VM is not NULL yet...
2608 vymViews.removeAt (tabWidget->currentIndex() );
2609 tabWidget->removeTab (tabWidget->currentIndex() );
2611 // Remove mapEditor/model FIXME-3 Huh? seems to work now...
2612 // Better would be delete (me), but then we could have a Qt error:
2613 // "QObject: Do not delete object, 'MapEditor', during its event handler!"
2614 // So we only remove data now and call deconstructor when vym closes later
2615 // this needs to be moved to vymview... me->clear();
2616 // some model->clear is needed to free up memory ...
2618 delete (m->getMapEditor());
2625 void Main::filePrint()
2627 if (currentMapEditor())
2628 currentMapEditor()->print();
2631 void Main::fileExitVYM()
2633 // Check if one or more editors have changed
2635 for (i=0;i<=vymViews.count() -1;i++)
2637 // If something changed, ask what to do
2638 if (vymViews.at(i)->getModel()->hasChanged())
2640 tabWidget->setCurrentPage(i);
2641 QMessageBox mb( vymName,
2642 tr("This map is not saved yet. Do you want to"),
2643 QMessageBox::Warning,
2644 QMessageBox::Yes | QMessageBox::Default,
2646 QMessageBox::Cancel | QMessageBox::Escape );
2647 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2648 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2651 mb.setActiveWindow();
2652 switch( mb.exec() ) {
2653 case QMessageBox::Yes:
2654 // save (the changed editors) and exit
2655 fileSave(currentModel(), CompleteMap);
2657 case QMessageBox::No:
2658 // exit without saving
2660 case QMessageBox::Cancel:
2661 // don't save and don't exit
2665 } // loop over all MEs
2669 void Main::editUndo()
2671 VymModel *m=currentModel();
2675 void Main::editRedo()
2677 VymModel *m=currentModel();
2681 void Main::gotoHistoryStep (int i)
2683 VymModel *m=currentModel();
2684 if (m) m->gotoHistoryStep(i);
2687 void Main::editCopy()
2689 VymModel *m=currentModel();
2693 void Main::editPaste()
2695 VymModel *m=currentModel();
2699 void Main::editCut()
2701 VymModel *m=currentModel();
2705 void Main::editOpenFindWidget()
2707 if (!findWidget->isVisible())
2710 findWidget->setFocus();
2711 } else if (!findResultWidget->parentWidget()->isVisible())
2712 findResultWidget->parentWidget()->show();
2716 findResultWidget->parentWidget()->hide();
2720 void Main::editHideFindWidget()
2722 // findWidget hides itself, but we want
2723 // to have focus back at mapEditor usually
2724 MapEditor *me=currentMapEditor();
2725 if (me) me->setFocus();
2728 void Main::editFindNext(QString s)
2730 Qt::CaseSensitivity cs=Qt::CaseInsensitive;
2732 VymModel *m=currentModel();
2735 m->findAll (findResultWidget->getResultModel(),s,cs);
2737 BranchItem *bi=m->findText(s, cs,cursor);
2740 findWidget->setStatus (FindWidget::Success);
2743 findWidget->setStatus (FindWidget::Failed);
2747 void Main::editFindDuplicateURLs() //FIXME-4 feature: use FindResultWidget for display
2749 VymModel *m=currentModel();
2750 if (m) m->findDuplicateURLs();
2753 void Main::openTabs(QStringList urls)
2755 if (!urls.isEmpty())
2759 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2760 //qDebug ()<<"Services: "<<QDBusConnection::sessionBus().interface()->registeredServiceNames().value();
2761 if (*browserPID==0 ||
2762 (browser.contains("konqueror") &&
2763 !QDBusConnection::sessionBus().interface()->registeredServiceNames().value().contains (QString("org.kde.konqueror-%1").arg(*browserPID)))
2766 // Start a new browser, if there is not one running already or
2767 // if a previously started konqueror is gone.
2768 if (debug) cout <<"Main::openTabs no konqueror-"<<*browserPID<<" found\n";
2769 QString u=urls.takeFirst();
2771 QString workDir=QDir::currentDirPath();
2772 if (!QProcess::startDetached(browser,args,workDir,browserPID))
2774 // try to set path to browser
2775 QMessageBox::warning(0,
2777 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2778 tr("Please use Settings->")+tr("Set application to open an URL"));
2781 if (debug) cout << "Main::openTabs Started konqueror-"<<*browserPID<<endl;
2782 #if defined(Q_OS_WIN32)
2783 // There's no sleep in VCEE, replace it with Qt's QThread::wait().
2784 this->thread()->wait(3000);
2786 sleep (3); //FIXME-3 needed?
2790 if (browser.contains("konqueror"))
2792 for (int i=0; i<urls.size(); i++)
2795 // Try to open new tab in existing konqueror started previously by vym
2799 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2800 "konqueror-mainwindow#1"<<
2804 args<< QString("org.kde.konqueror-%1").arg(*browserPID)<<
2805 "/konqueror/MainWindow_1"<<
2809 if (debug) cout << "MainWindow::openURLs args="<<args.join(" ").toStdString()<<endl;
2810 if (!QProcess::startDetached ("qdbus",args))
2814 QMessageBox::warning(0,
2816 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2818 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2820 for (int i=0; i<urls.size(); i++)
2822 // Try to open new tab in firefox
2823 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2824 if (!QProcess::startDetached (browser,args))
2828 QMessageBox::warning(0,
2830 tr("Couldn't start %1 to open a new tab").arg(browser));
2833 QMessageBox::warning(0,
2835 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2839 void Main::editOpenURL()
2842 VymModel *m=currentModel();
2845 QString url=m->getURL();
2847 if (url=="") return;
2848 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2850 QString workDir=QDir::currentDirPath();
2851 if (!procBrowser->startDetached(browser,args))
2853 // try to set path to browser
2854 QMessageBox::warning(0,
2856 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2857 tr("Please use Settings->")+tr("Set application to open an URL"));
2862 void Main::editOpenURLTab()
2864 VymModel *m=currentModel();
2868 urls.append(m->getURL());
2873 void Main::editOpenMultipleVisURLTabs(bool ignoreScrolled)
2875 VymModel *m=currentModel();
2879 urls=m->getURLs(ignoreScrolled);
2884 void Main::editOpenMultipleURLTabs()
2886 editOpenMultipleVisURLTabs (false);
2890 void Main::editURL()
2892 VymModel *m=currentModel();
2893 if (m) m->editURL();
2896 void Main::editLocalURL()
2898 VymModel *m=currentModel();
2899 if (m) m->editLocalURL();
2902 void Main::editHeading2URL()
2904 VymModel *m=currentModel();
2905 if (m) m->editHeading2URL();
2908 void Main::editBugzilla2URL()
2910 VymModel *m=currentModel();
2911 if (m) m->editBugzilla2URL();
2914 void Main::getBugzillaData()
2916 VymModel *m=currentModel();
2918 QProgressDialog progress ("Doing stuff","cancl",0,10,this);
2919 progress.setWindowModality(Qt::WindowModal);
2920 //progress.setCancelButton (NULL);
2922 progress.setMinimumDuration (0);
2923 progress.setValue (1);
2924 progress.setValue (5);
2928 QProgressBar *pb=new QProgressBar;
2934 if (m) m->getBugzillaData();
2937 void Main::editFATE2URL()
2939 VymModel *m=currentModel();
2940 if (m) m->editFATE2URL();
2943 void Main::editHeadingFinished(VymModel *m)
2947 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2948 !prevSelection.isEmpty())
2949 m->select(prevSelection);
2954 void Main::openVymLinks(const QStringList &vl)
2956 for (int j=0; j<vl.size(); j++)
2958 // compare path with already loaded maps
2961 for (i=0;i<=vymViews.count() -1;i++)
2963 if (vl.at(j)==vymViews.at(i)->getModel()->getFilePath() )
2972 if (!QFile(vl.at(j)).exists() )
2973 QMessageBox::critical( 0, tr( "Critical Error" ),
2974 tr("Couldn't open map %1").arg(vl.at(j)));
2977 fileLoad (vl.at(j), NewMap);
2978 tabWidget->setCurrentIndex (tabWidget->count()-1);
2981 // Go to tab containing the map
2982 tabWidget->setCurrentIndex (index);
2986 void Main::editOpenVymLink()
2988 VymModel *m=currentModel();
2992 vl.append(m->getVymLink());
2997 void Main::editOpenMultipleVymLinks()
2999 QString currentVymLink;
3000 VymModel *m=currentModel();
3003 QStringList vl=m->getVymLinks();
3008 void Main::editVymLink()
3010 VymModel *m=currentModel();
3015 void Main::editDeleteVymLink()
3017 VymModel *m=currentModel();
3018 if (m) m->deleteVymLink();
3021 void Main::editToggleHideExport()
3023 VymModel *m=currentModel();
3024 if (m) m->toggleHideExport();
3027 void Main::editAddTimestamp()
3029 VymModel *m=currentModel();
3030 if (m) m->addTimestamp();
3033 void Main::editMapInfo()
3035 VymModel *m=currentModel();
3038 ExtraInfoDialog dia;
3039 dia.setMapName (m->getFileName() );
3040 dia.setAuthor (m->getAuthor() );
3041 dia.setComment(m->getComment() );
3045 stats+=tr("%1 items on map\n","Info about map").arg (m->getScene()->items().size(),6);
3051 BranchItem *cur=NULL;
3052 BranchItem *prev=NULL;
3053 m->nextBranch(cur,prev);
3056 if (!cur->getNote().isEmpty() ) n++;
3057 f+= cur->imageCount();
3059 xl+=cur->xlinkCount();
3060 m->nextBranch(cur,prev);
3063 stats+=QString ("%1 xLinks \n").arg (xl,6);
3064 stats+=QString ("%1 notes\n").arg (n,6);
3065 stats+=QString ("%1 images\n").arg (f,6);
3066 stats+=QString ("%1 branches\n").arg (m->branchCount(),6);
3067 dia.setStats (stats);
3069 // Finally show dialog
3070 if (dia.exec() == QDialog::Accepted)
3072 m->setAuthor (dia.getAuthor() );
3073 m->setComment (dia.getComment() );
3077 void Main::editMoveUp()
3079 VymModel *m=currentModel();
3083 void Main::editMoveDown()
3085 VymModel *m=currentModel();
3086 if (m) m->moveDown();
3089 void Main::editDetach()
3091 VymModel *m=currentModel();
3095 void Main::editSortChildren()
3097 VymModel *m=currentModel();
3098 if (m) m->sortChildren(false);
3101 void Main::editSortBackChildren()
3103 VymModel *m=currentModel();
3104 if (m) m->sortChildren(true);
3107 void Main::editToggleScroll()
3109 VymModel *m=currentModel();
3110 if (m) m->toggleScroll();
3113 void Main::editExpandAll()
3115 VymModel *m=currentModel();
3116 if (m) m->emitExpandAll();
3119 void Main::editExpandOneLevel()
3121 VymModel *m=currentModel();
3122 if (m) m->emitExpandOneLevel();
3125 void Main::editCollapseOneLevel()
3127 VymModel *m=currentModel();
3128 if (m) m->emitCollapseOneLevel();
3131 void Main::editUnscrollChildren()
3133 VymModel *m=currentModel();
3134 if (m) m->unscrollChildren();
3137 void Main::editAddAttribute()
3139 VymModel *m=currentModel();
3147 void Main::editAddMapCenter()
3149 VymModel *m=currentModel();
3150 if (m) m->select (m->addMapCenter ());
3153 void Main::editNewBranch()
3155 VymModel *m=currentModel();
3158 BranchItem *bi=m->addNewBranch();
3161 if (actionSettingsAutoEditNewBranch->isOn()
3162 && !actionSettingsAutoSelectNewBranch->isOn() )
3163 prevSelection=m->getSelectString();
3165 prevSelection=QString();
3167 if (actionSettingsAutoSelectNewBranch->isOn()
3168 || actionSettingsAutoEditNewBranch->isOn())
3171 if (actionSettingsAutoEditNewBranch->isOn())
3172 currentMapEditor()->editHeading();
3177 void Main::editNewBranchBefore()
3179 VymModel *m=currentModel();
3182 BranchItem *bi=m->addNewBranchBefore();
3189 if (actionSettingsAutoEditNewBranch->isOn())
3191 if (!actionSettingsAutoSelectNewBranch->isOn())
3192 prevSelection=m->getSelectString(bi);
3193 currentMapEditor()->editHeading();
3198 void Main::editNewBranchAbove()
3200 VymModel *m=currentModel();
3203 BranchItem *bi=m->addNewBranch (-1);
3211 if (actionSettingsAutoEditNewBranch->isOn())
3213 if (!actionSettingsAutoSelectNewBranch->isOn())
3214 prevSelection=m->getSelectString (bi);
3215 currentMapEditor()->editHeading();
3220 void Main::editNewBranchBelow()
3222 VymModel *m=currentModel();
3225 BranchItem *bi=m->addNewBranch (1);
3232 if (actionSettingsAutoEditNewBranch->isOn())
3234 if (!actionSettingsAutoSelectNewBranch->isOn())
3235 prevSelection=m->getSelectString(bi);
3236 currentMapEditor()->editHeading();
3241 void Main::editImportAdd()
3243 fileLoad (ImportAdd);
3246 void Main::editImportReplace()
3248 fileLoad (ImportReplace);
3251 void Main::editSaveBranch()
3253 fileSaveAs (PartOfMap);
3256 void Main::editDeleteKeepChildren()
3258 VymModel *m=currentModel();
3259 if (m) m->deleteKeepChildren();
3262 void Main::editDeleteChildren()
3264 VymModel *m=currentModel();
3265 if (m) m->deleteChildren();
3268 void Main::editDeleteSelection()
3270 VymModel *m=currentModel();
3271 if (m && actionSettingsUseDelKey->isOn())
3272 m->deleteSelection();
3275 void Main::editLoadImage()
3277 VymModel *m=currentModel();
3278 if (m) m->loadFloatImage();
3281 void Main::editSaveImage()
3283 VymModel *m=currentModel();
3284 if (m) m->saveFloatImage();
3287 void Main::editEditXLink(QAction *a)
3289 VymModel *m=currentModel();
3291 m->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3294 void Main::formatSelectColor()
3296 QColor col = QColorDialog::getColor((currentColor ), this );
3297 if ( !col.isValid() ) return;
3298 colorChanged( col );
3301 void Main::formatPickColor()
3303 VymModel *m=currentModel();
3305 colorChanged( m->getCurrentHeadingColor() );
3308 void Main::colorChanged(QColor c)
3310 QPixmap pix( 16, 16 );
3312 actionFormatColor->setIconSet( pix );
3316 void Main::formatColorBranch()
3318 VymModel *m=currentModel();
3319 if (m) m->colorBranch(currentColor);
3322 void Main::formatColorSubtree()
3324 VymModel *m=currentModel();
3325 if (m) m->colorSubtree (currentColor);
3328 void Main::formatLinkStyleLine()
3330 VymModel *m=currentModel();
3333 m->setMapLinkStyle("StyleLine");
3334 actionFormatLinkStyleLine->setChecked(true);
3338 void Main::formatLinkStyleParabel()
3340 VymModel *m=currentModel();
3343 m->setMapLinkStyle("StyleParabel");
3344 actionFormatLinkStyleParabel->setChecked(true);
3348 void Main::formatLinkStylePolyLine()
3350 VymModel *m=currentModel();
3353 m->setMapLinkStyle("StylePolyLine");
3354 actionFormatLinkStylePolyLine->setChecked(true);
3358 void Main::formatLinkStylePolyParabel()
3360 VymModel *m=currentModel();
3363 m->setMapLinkStyle("StylePolyParabel");
3364 actionFormatLinkStylePolyParabel->setChecked(true);
3368 void Main::formatSelectBackColor()
3370 VymModel *m=currentModel();
3371 if (m) m->selectMapBackgroundColor();
3374 void Main::formatSelectBackImage()
3376 VymModel *m=currentModel();
3378 m->selectMapBackgroundImage();
3381 void Main::formatSelectLinkColor()
3383 VymModel *m=currentModel();
3386 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3387 m->setMapDefLinkColor( col );
3391 void Main::formatSelectSelectionColor()
3393 VymModel *m=currentModel();
3396 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3397 m->setSelectionColor (col);
3402 void Main::formatToggleLinkColorHint()
3404 VymModel *m=currentModel();
3405 if (m) m->toggleMapLinkColorHint();
3409 void Main::formatHideLinkUnselected() //FIXME-3 get rid of this with imagepropertydialog
3411 VymModel *m=currentModel();
3413 m->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3416 void Main::viewZoomReset()
3418 MapEditor *me=currentMapEditor();
3419 if (me) me->setZoomFactorTarget (1);
3422 void Main::viewZoomIn()
3424 MapEditor *me=currentMapEditor();
3425 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*1.15);
3428 void Main::viewZoomOut()
3430 MapEditor *me=currentMapEditor();
3431 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*0.85);
3434 void Main::viewCenter()
3436 VymModel *m=currentModel();
3437 if (m) m->emitShowSelection();
3440 void Main::networkStartServer()
3442 VymModel *m=currentModel();
3443 if (m) m->newServer();
3446 void Main::networkConnect()
3448 VymModel *m=currentModel();
3449 if (m) m->connectToServer();
3452 bool Main::settingsPDF()
3454 // Default browser is set in constructor
3456 QString text = QInputDialog::getText(
3457 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3458 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3460 settings.setValue ("/mainwindow/readerPDF",text);
3465 bool Main::settingsURL()
3467 // Default browser is set in constructor
3469 QString text = QInputDialog::getText(
3470 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3471 settings.value("/mainwindow/readerURL").toString()
3474 settings.setValue ("/mainwindow/readerURL",text);
3478 void Main::settingsMacroDir()
3480 QDir defdir(vymBaseDir.path() + "/macros");
3481 if (!defdir.exists())
3483 QDir dir=QFileDialog::getExistingDirectory (
3485 tr ("Directory with vym macros:"),
3486 settings.value ("/macros/macroDir",defdir.path()).toString()
3489 settings.setValue ("/macros/macroDir",dir.absolutePath());
3492 void Main::settingsUndoLevels()
3495 int i = QInputDialog::getInteger(
3497 tr("QInputDialog::getInteger()"),
3498 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3501 settings.setValue ("/mapeditor/stepsTotal",i);
3502 QMessageBox::information( this, tr( "VYM -Information:" ),
3503 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3507 void Main::settingsAutosaveToggle()
3509 settings.setValue ("/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
3512 void Main::settingsAutosaveTime()
3515 int i = QInputDialog::getInteger(
3517 tr("QInputDialog::getInteger()"),
3518 tr("Number of seconds before autosave:"), settings.value("/mainwindow/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3520 settings.setValue ("/mainwindow/autosave/ms",i * 1000);
3523 void Main::settingsAutoLayoutToggle()
3525 settings.setValue ("/mainwindow/autoLayout/use",actionSettingsAutosaveToggle->isOn() );
3528 void Main::settingsWriteBackupFileToggle()
3530 settings.setValue ("/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
3533 void Main::settingsToggleAnimation()
3535 settings.setValue ("/animation/use",actionSettingsUseAnimation->isOn() );
3538 void Main::settingsToggleDelKey()
3540 if (actionSettingsUseDelKey->isOn())
3542 actionDelete->setAccel (QKeySequence (Qt::Key_Delete));
3545 actionDelete->setAccel (QKeySequence (""));
3549 void Main::windowToggleNoteEditor()
3551 if (textEditor->isVisible() )
3552 windowHideNoteEditor();
3554 windowShowNoteEditor();
3557 void Main::windowToggleTreeEditor()
3559 if ( tabWidget->currentPage())
3560 vymViews.at(tabWidget->currentIndex())->toggleTreeEditor();
3563 void Main::windowToggleHistory()
3565 if (historyWindow->isVisible())
3566 historyWindow->hide();
3568 historyWindow->show();
3572 void Main::windowToggleProperty()
3574 if (branchPropertyWindow->isVisible())
3575 branchPropertyWindow->hide();
3577 branchPropertyWindow->show();
3578 branchPropertyWindow->setModel (currentModel() );
3581 void Main::windowToggleAntiAlias()
3583 bool b=actionViewToggleAntiAlias->isOn();
3585 for (int i=0;i<vymViews.count();i++)
3587 me=vymViews.at(i)->getMapEditor();
3588 if (me) me->setAntiAlias(b);
3593 bool Main::isAliased()
3595 return actionViewToggleAntiAlias->isOn();
3598 bool Main::hasSmoothPixmapTransform()
3600 return actionViewToggleSmoothPixmapTransform->isOn();
3603 void Main::windowToggleSmoothPixmap()
3605 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3607 for (int i=0;i<vymViews.count();i++)
3610 me=vymViews.at(i)->getMapEditor();
3611 if (me) me->setSmoothPixmap(b);
3615 void Main::updateHistory(SimpleSettings &undoSet)
3617 historyWindow->update (undoSet);
3620 void Main::updateNoteFlag()
3622 // this slot is connected to TextEditor::textHasChanged()
3623 VymModel *m=currentModel();
3624 if (m) m->updateNoteFlag();
3627 void Main::updateNoteEditor(QModelIndex index )
3629 TreeItem *ti=((VymModel*) QObject::sender())->getItem(index);
3631 cout << "Main::updateNoteEditor model="<<sender();
3632 cout << " item="<<ti->getHeadingStd()<<" ("<<ti<<")"<<endl;
3634 textEditor->setNote (ti->getNoteObj() );
3637 void Main::changeSelection (VymModel *model, const QItemSelection &newsel, const QItemSelection &oldsel)
3639 branchPropertyWindow->setModel (model ); //FIXME-3 this used to be called from BranchObj::select(). Maybe use signal now...
3641 if (model && model==currentModel() )
3645 if (!oldsel.indexes().isEmpty() )
3647 ti=model->getItem(oldsel.indexes().first());
3649 // Don't update note if both treeItem and textEditor are empty
3650 //if (! (ti->hasEmptyNote() && textEditor->isEmpty() ))
3651 // ti->setNoteObj (textEditor->getNoteObj(),false );
3653 if (!newsel.indexes().isEmpty() )
3655 ti=model->getItem(newsel.indexes().first());
3656 if (!ti->hasEmptyNote() )
3657 textEditor->setNote(ti->getNoteObj() );
3659 textEditor->setNote(NoteObj() ); //FIXME-4 maybe add a clear() to TE
3661 // Show URL and link in statusbar
3663 QString s=ti->getURL();
3664 if (!s.isEmpty() ) status+="URL: "+s+" ";
3666 if (!s.isEmpty() ) status+="Link: "+s;
3667 if (!status.isEmpty() ) statusMessage (status);
3670 textEditor->setInactive();
3676 void Main::updateActions()
3678 // updateActions is also called when satellites are closed //FIXME-2 doesn't update immediatly, e.g. historyWindow is still visible, when "close" is pressed
3679 actionViewToggleNoteEditor->setChecked (textEditor->isVisible());
3680 actionViewToggleHistoryWindow->setChecked (historyWindow->isVisible());
3681 actionViewTogglePropertyWindow->setChecked (branchPropertyWindow->isVisible());
3683 VymModel *m =currentModel();
3687 actionFilePrint->setEnabled (true);
3689 // Link style in context menu
3690 switch (m->getMapLinkStyle())
3692 case LinkableMapObj::Line:
3693 actionFormatLinkStyleLine->setChecked(true);
3695 case LinkableMapObj::Parabel:
3696 actionFormatLinkStyleParabel->setChecked(true);
3698 case LinkableMapObj::PolyLine:
3699 actionFormatLinkStylePolyLine->setChecked(true);
3701 case LinkableMapObj::PolyParabel:
3702 actionFormatLinkStylePolyParabel->setChecked(true);
3709 QPixmap pix( 16, 16 );
3710 pix.fill( m->getMapBackgroundColor() );
3711 actionFormatBackColor->setIconSet( pix );
3712 pix.fill( m->getSelectionColor() );
3713 actionFormatSelectionColor->setIconSet( pix );
3714 pix.fill( m->getMapDefLinkColor() );
3715 actionFormatLinkColor->setIconSet( pix );
3718 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName()));
3721 // Expanding/collapsing
3722 actionExpandAll->setEnabled (true);
3723 actionExpandOneLevel->setEnabled (true);
3724 actionCollapseOneLevel->setEnabled (true);
3728 actionFilePrint->setEnabled (false);
3730 // Expanding/collapsing
3731 actionExpandAll->setEnabled (false);
3732 actionExpandOneLevel->setEnabled (false);
3733 actionCollapseOneLevel->setEnabled (false);
3736 if (m && m->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3737 actionFormatLinkColorHint->setChecked(true);
3739 actionFormatLinkColorHint->setChecked(false);
3742 if (m && m->hasChanged() )
3743 actionFileSave->setEnabled( true);
3745 actionFileSave->setEnabled( false);
3746 if (m && m->isUndoAvailable())
3747 actionUndo->setEnabled( true);
3749 actionUndo->setEnabled( false);
3751 if (m && m->isRedoAvailable())
3752 actionRedo->setEnabled( true);
3754 actionRedo->setEnabled( false);
3758 TreeItem *selti=m->getSelectedItem();
3759 BranchItem *selbi=m->getSelectedBranch();
3762 if (selbi || selti->getType()==TreeItem::Image)
3764 actionFormatHideLinkUnselected->setChecked (((MapItem*)selti)->getHideLinkUnselected());
3765 actionFormatHideLinkUnselected->setEnabled (true);
3770 // Take care of xlinks
3771 branchXLinksContextMenuEdit->clear();
3772 if (selbi->xlinkCount()>0)
3776 for (int i=0; i<selbi->xlinkCount();++i)
3778 bi=selbi->getXLinkNum(i)->getPartnerBranch();
3782 if (s.length()>xLinkMenuWidth)
3783 s=s.left(xLinkMenuWidth)+"...";
3784 branchXLinksContextMenuEdit->addAction (s);
3789 standardFlagsMaster->updateToolBar (selbi->activeStandardFlagNames() );
3792 actionToggleScroll->setEnabled (true);
3793 if ( selbi->isScrolled() )
3794 actionToggleScroll->setChecked(true);
3796 actionToggleScroll->setChecked(false);
3798 if ( selti->getURL().isEmpty() )
3800 actionOpenURL->setEnabled (false);
3801 actionOpenURLTab->setEnabled (false);
3805 actionOpenURL->setEnabled (true);
3806 actionOpenURLTab->setEnabled (true);
3808 if ( selti->getVymLink().isEmpty() )
3810 actionOpenVymLink->setEnabled (false);
3811 actionDeleteVymLink->setEnabled (false);
3814 actionOpenVymLink->setEnabled (true);
3815 actionDeleteVymLink->setEnabled (true);
3818 if (selbi->canMoveUp())
3819 actionMoveUp->setEnabled (true);
3821 actionMoveUp->setEnabled (false);
3822 if (selbi->canMoveDown())
3823 actionMoveDown->setEnabled (true);
3825 actionMoveDown->setEnabled (false);
3827 actionSortChildren->setEnabled (true);
3828 actionSortBackChildren->setEnabled (true);
3830 actionToggleHideExport->setEnabled (true);
3831 actionToggleHideExport->setChecked (selbi->hideInExport() );
3833 actionCopy->setEnabled (true);
3834 actionCut->setEnabled (true);
3835 if (!clipboardEmpty)
3836 actionPaste->setEnabled (true);
3838 actionPaste->setEnabled (false);
3839 for (int i=0; i<actionListBranches.size(); ++i)
3840 actionListBranches.at(i)->setEnabled(true);
3841 actionDelete->setEnabled (true);
3843 if ( selti->getType()==TreeItem::Image)
3845 actionOpenURL->setEnabled (false);
3846 actionOpenVymLink->setEnabled (false);
3847 actionDeleteVymLink->setEnabled (false);
3848 actionToggleHideExport->setEnabled (true);
3849 actionToggleHideExport->setChecked (selti->hideInExport() );
3852 actionCopy->setEnabled (true);
3853 actionCut->setEnabled (true);
3854 actionPaste->setEnabled (false); //FIXME-4 why not allowing copy of images?
3855 for (int i=0; i<actionListBranches.size(); ++i)
3856 actionListBranches.at(i)->setEnabled(false);
3857 actionDelete->setEnabled (true);
3858 actionMoveUp->setEnabled (false);
3859 actionMoveDown->setEnabled (false);
3864 actionCopy->setEnabled (false);
3865 actionCut->setEnabled (false);
3866 actionPaste->setEnabled (false);
3867 for (int i=0; i<actionListBranches.size(); ++i)
3868 actionListBranches.at(i)->setEnabled(false);
3870 actionToggleScroll->setEnabled (false);
3871 actionOpenURL->setEnabled (false);
3872 actionOpenVymLink->setEnabled (false);
3873 actionDeleteVymLink->setEnabled (false);
3874 actionHeading2URL->setEnabled (false);
3875 actionDelete->setEnabled (false);
3876 actionMoveUp->setEnabled (false);
3877 actionMoveDown->setEnabled (false);
3878 actionFormatHideLinkUnselected->setEnabled (false);
3879 actionSortChildren->setEnabled (false);
3880 actionSortBackChildren->setEnabled (false);
3881 actionToggleHideExport->setEnabled (false);
3886 Main::ModMode Main::getModMode()
3888 if (actionModModeColor->isOn()) return ModModeColor;
3889 if (actionModModeCopy->isOn()) return ModModeCopy;
3890 if (actionModModeXLink->isOn()) return ModModeXLink;
3894 bool Main::autoEditNewBranch()
3896 return actionSettingsAutoEditNewBranch->isOn();
3899 bool Main::autoSelectNewBranch()
3901 return actionSettingsAutoSelectNewBranch->isOn();
3904 void Main::windowShowNoteEditor()
3906 textEditor->setShowWithMain(true);
3908 actionViewToggleNoteEditor->setChecked (true);
3911 void Main::windowHideNoteEditor()
3913 textEditor->setShowWithMain(false);
3915 actionViewToggleNoteEditor->setChecked (false);
3918 void Main::setScript (const QString &script)
3920 scriptEditor->setScript (script);
3923 void Main::runScript (const QString &script)
3925 VymModel *m=currentModel();
3926 if (m) m->runScript (script);
3929 void Main::runScriptEverywhere (const QString &script)
3932 for (int i=0;i<=tabWidget->count() -1;i++)
3934 me=(MapEditor*)tabWidget->page(i);
3935 if (me) me->getModel()->runScript (script);
3939 void Main::windowNextEditor()
3941 if (tabWidget->currentIndex() < tabWidget->count())
3942 tabWidget->setCurrentIndex (tabWidget->currentIndex() +1);
3945 void Main::windowPreviousEditor()
3947 if (tabWidget->currentIndex() >0)
3948 tabWidget->setCurrentIndex (tabWidget->currentIndex() -1);
3951 void Main::standardFlagChanged()
3955 if ( actionSettingsUseFlagGroups->isOn() )
3956 currentModel()->toggleStandardFlag(sender()->name(),standardFlagsMaster);
3958 currentModel()->toggleStandardFlag(sender()->name());
3964 #include "attributeitem.h"
3965 void Main::testFunction1()
3967 VymModel *m=currentModel();
3970 BranchItem *selbi=m->getSelectedBranch();
3973 QList<QVariant> cData;
3974 cData << "new ai" << "undef";
3976 AttributeItem *ai=new AttributeItem (cData,selbi);
3977 ai->set ("Key 1","Val a",AttributeItem::FreeString);
3979 m->addAttribute (ai);
3984 if (!currentMapEditor()) return;
3985 currentMapEditor()->testFunction1();
3989 void Main::testFunction2()
3991 if (!currentMapEditor()) return;
3992 currentMapEditor()->testFunction2();
3995 void Main::testCommand()
3997 if (!currentMapEditor()) return;
3998 scriptEditor->show();
4001 QString com = QInputDialog::getText(
4002 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
4003 if (ok) currentMapEditor()->parseAtom(com);
4007 void Main::helpDoc()
4009 QString locale = QLocale::system().name();
4011 if (locale.left(2)=="es")
4012 docname="vym_es.pdf";
4016 QStringList searchList;
4018 #if defined(Q_OS_MACX)
4019 searchList << "./vym.app/Contents/Resources/doc";
4020 #elif defined(Q_OS_WIN32)
4021 searchList << vymInstallDir.path() + "/share/doc/packages/vym";
4023 #if defined(VYM_DOCDIR)
4024 searchList << VYM_DOCDIR;
4026 // default path in SUSE LINUX
4027 searchList << "/usr/share/doc/packages/vym";
4030 searchList << "doc"; // relative path for easy testing in tarball
4031 searchList << "doc/tex"; // Easy testing working on vym.tex
4032 searchList << "/usr/share/doc/vym"; // Debian
4033 searchList << "/usr/share/doc/packages";// Knoppix
4037 for (int i=0; i<searchList.count(); ++i)
4039 docfile.setFileName(searchList.at(i)+"/"+docname);
4040 if (docfile.exists())
4049 QMessageBox::critical(0,
4050 tr("Critcal error"),
4051 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
4056 Process *pdfProc = new Process();
4057 args << QDir::toNativeSeparators(docfile.fileName());
4059 if (!pdfProc->startDetached( settings.value("/mainwindow/readerPDF").toString(),args) )
4062 QMessageBox::warning(0,
4064 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
4065 tr("Please use Settings->")+tr("Set application to open PDF files"));
4072 void Main::helpDemo()
4074 QStringList filters;
4075 filters <<"VYM example map (*.vym)";
4076 QFileDialog *fd=new QFileDialog( this);
4077 #if defined(Q_OS_MACX)
4078 fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
4080 // default path in SUSE LINUX
4081 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
4084 fd->setFileMode (QFileDialog::ExistingFiles);
4085 fd->setFilters (filters);
4086 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
4090 if ( fd->exec() == QDialog::Accepted )
4092 lastFileDir=fd->directory().path();
4093 QStringList flist = fd->selectedFiles();
4094 QStringList::Iterator it = flist.begin();
4095 while( it != flist.end() )
4098 fileLoad(*it, NewMap);
4106 void Main::helpAbout()
4109 ad.setName ("aboutwindow");
4110 ad.setMinimumSize(500,500);
4111 ad.resize (QSize (500,500));
4115 void Main::helpAboutQT()
4117 QMessageBox::aboutQt( this, "Qt Application Example" );
4120 void Main::callMacro ()
4122 QAction *action = qobject_cast<QAction *>(sender());
4126 i=action->data().toInt();
4127 QString mDir (settings.value ("macros/macroDir").toString() );
4129 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
4131 if ( !f.open( QIODevice::ReadOnly ) )
4133 QMessageBox::warning(0,
4135 tr("Couldn't find a macro at %1.\n").arg(fn)+
4136 tr("Please use Settings->")+tr("Set directory for vym macros"));
4140 QTextStream ts( &f );
4141 QString macro= ts.read();
4143 if (! macro.isEmpty())
4145 VymModel *m=currentModel();
4146 if (m) m->runScript(macro);