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::Key_Comma); // 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::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::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 flag->setVisible(false);
1455 flag->setGroup ("Freemind-priority");
1456 setupFlag (flag,tb, QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
1459 flag=new Flag(flagsPath+"freemind/back.png");
1460 flag->setVisible(false);
1461 setupFlag (flag,tb,"freemind-back",tr("Back","Freemind-Flag"));
1463 flag=new Flag(flagsPath+"freemind/forward.png");
1464 flag->setVisible(false);
1465 setupFlag (flag,tb,"freemind-forward",tr("forward","Freemind-Flag"));
1467 flag=new Flag(flagsPath+"freemind/attach.png");
1468 flag->setVisible(false);
1469 setupFlag (flag,tb,"freemind-attach",tr("Look here","Freemind-Flag"));
1471 flag=new Flag(flagsPath+"freemind/clanbomber.png");
1472 flag->setVisible(false);
1473 setupFlag (flag,tb,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
1475 flag=new Flag(flagsPath+"freemind/desktopnew.png");
1476 flag->setVisible(false);
1477 setupFlag (flag,tb,"freemind-desktopnew",tr("Don't flagrget","Freemind-Flag"));
1479 flag=new Flag(flagsPath+"freemind/flag.png");
1480 flag->setVisible(false);
1481 setupFlag (flag,tb,"freemind-flag",tr("Flag","Freemind-Flag"));
1484 flag=new Flag(flagsPath+"freemind/gohome.png");
1485 flag->setVisible(false);
1486 setupFlag (flag,tb,"freemind-gohome",tr("Home","Freemind-Flag"));
1488 flag=new Flag(flagsPath+"freemind/kaddressbook.png");
1489 flag->setVisible(false);
1490 setupFlag (flag,tb,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
1492 flag=new Flag(flagsPath+"freemind/knotify.png");
1493 flag->setVisible(false);
1494 setupFlag (flag,tb,"freemind-knotify",tr("Music","Freemind-Flag"));
1496 flag=new Flag(flagsPath+"freemind/korn.png");
1497 flag->setVisible(false);
1498 setupFlag (flag,tb,"freemind-korn",tr("Mailbox","Freemind-Flag"));
1500 flag=new Flag(flagsPath+"freemind/mail.png");
1501 flag->setVisible(false);
1502 setupFlag (flag,tb,"freemind-mail",tr("Maix","Freemind-Flag"));
1504 flag=new Flag(flagsPath+"freemind/password.png");
1505 flag->setVisible(false);
1506 setupFlag (flag,tb,"freemind-password",tr("Password","Freemind-Flag"));
1508 flag=new Flag(flagsPath+"freemind/pencil.png");
1509 flag->setVisible(false);
1510 setupFlag (flag,tb,"freemind-pencil",tr("To be improved","Freemind-Flag"));
1512 flag=new Flag(flagsPath+"freemind/stop.png");
1513 flag->setVisible(false);
1514 setupFlag (flag,tb,"freemind-stop",tr("Stop","Freemind-Flag"));
1516 flag=new Flag(flagsPath+"freemind/wizard.png");
1517 flag->setVisible(false);
1518 setupFlag (flag,tb,"freemind-wizard",tr("Magic","Freemind-Flag"));
1520 flag=new Flag(flagsPath+"freemind/xmag.png");
1521 flag->setVisible(false);
1522 setupFlag (flag,tb,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
1524 flag=new Flag(flagsPath+"freemind/bell.png");
1525 flag->setVisible(false);
1526 setupFlag (flag,tb,"freemind-bell",tr("Reminder","Freemind-Flag"));
1528 flag=new Flag(flagsPath+"freemind/bookmark.png");
1529 flag->setVisible(false);
1530 setupFlag (flag,tb,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
1532 flag= new Flag(flagsPath+"freemind/penguin.png");
1533 flag->setVisible(false);
1534 setupFlag (flag,tb,"freemind-penguin",tr("Linux","Freemind-Flag"));
1536 flag=new Flag (flagsPath+"freemind/licq.png");
1537 flag->setVisible(false);
1538 setupFlag (flag,tb,"freemind-licq",tr("Sweet","Freemind-Flag"));
1541 void Main::setupFlag (Flag *flag, QToolBar *tb, const QString &name, const QString &tooltip)
1543 flag->setName(name);
1544 flag->setToolTip (tooltip);
1548 a=new QAction (flag->getPixmap(),name,this);
1551 flag->setAction (a);
1552 a->setVisible (flag->isVisible());
1553 a->setCheckable(true);
1554 a->setObjectName(name);
1555 a->setToolTip(tooltip);
1556 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1557 standardFlagsMaster->addFlag (flag);
1561 systemFlagsMaster->addFlag (flag);
1566 void Main::setupNetworkActions()
1568 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1570 QMenu *netMenu = menuBar()->addMenu( "Network" );
1574 a = new QAction( "Start TCPserver for MapEditor",this);
1575 //a->setStatusTip ( "Set application to open pdf files"));
1576 //a->setShortcut ( Qt::ALT + Qt::Key_T ); //New TCP server
1577 switchboard.addConnection(a,tr("Network shortcuts","Shortcut group"));
1578 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1579 netMenu->addAction (a);
1581 a = new QAction( "Connect MapEditor to server",this);
1582 //a->setStatusTip ( "Set application to open pdf files"));
1583 a->setShortcut ( Qt::ALT + Qt::Key_C ); // Connect to server
1584 switchboard.addConnection(a,tr("Network shortcuts","Shortcut group"));
1585 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1586 netMenu->addAction (a);
1590 void Main::setupSettingsActions()
1592 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1596 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1597 a->setStatusTip ( tr( "Set application to open pdf files"));
1598 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1599 settingsMenu->addAction (a);
1601 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1602 a->setStatusTip( tr( "Set application to open external links"));
1603 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1604 settingsMenu->addAction (a);
1606 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1607 a->setStatusTip( tr( "Set path for macros"));
1608 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1609 settingsMenu->addAction (a);
1611 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1612 a->setStatusTip( tr( "Set number of undo levels"));
1613 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1614 settingsMenu->addAction (a);
1616 settingsMenu->addSeparator();
1618 a = new QAction( tr( "Autosave","Settings action"), this);
1619 a->setStatusTip( tr( "Autosave"));
1620 a->setToggleAction(true);
1621 a->setChecked ( settings.value ("/mainwindow/autosave/use",false).toBool());
1622 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1623 settingsMenu->addAction (a);
1624 actionSettingsAutosaveToggle=a;
1626 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1627 a->setStatusTip( tr( "Autosave time"));
1628 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1629 settingsMenu->addAction (a);
1630 actionSettingsAutosaveTime=a;
1632 a = new QAction( tr( "Write backup file on save","Settings action"), this);
1633 a->setStatusTip( tr( "Write backup file on save"));
1634 a->setToggleAction(true);
1635 a->setChecked ( settings.value ("/mainwindow/writeBackupFile",false).toBool());
1636 connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) );
1637 settingsMenu->addAction (a);
1638 actionSettingsWriteBackupFile=a;
1640 settingsMenu->addSeparator();
1642 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1643 a->setStatusTip( tr( "Edit branch after adding it" ));
1644 a->setToggleAction(true);
1645 a->setChecked ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1646 settingsMenu->addAction (a);
1647 actionSettingsAutoEditNewBranch=a;
1649 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1650 a->setStatusTip( tr( "Select branch after adding it" ));
1651 a->setToggleAction(true);
1652 a->setChecked ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1653 settingsMenu->addAction (a);
1654 actionSettingsAutoSelectNewBranch=a;
1656 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1657 a->setStatusTip( tr( "Select heading before editing" ));
1658 a->setToggleAction(true);
1659 a->setChecked ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1660 settingsMenu->addAction (a);
1661 actionSettingsAutoSelectText=a;
1663 a= new QAction( tr( "Delete key","Settings action" ), this);
1664 a->setStatusTip( tr( "Delete key for deleting branches" ));
1665 a->setToggleAction(true);
1666 a->setChecked ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1667 settingsMenu->addAction (a);
1668 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1669 actionSettingsUseDelKey=a;
1671 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1672 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1673 a->setToggleAction(true);
1674 a->setChecked ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1675 settingsMenu->addAction (a);
1676 actionSettingsUseFlagGroups=a;
1678 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1679 a->setStatusTip( tr( "Use hide flag during exports " ));
1680 a->setToggleAction(true);
1681 a->setChecked ( settings.value ("/export/useHideExport",true).toBool() );
1682 settingsMenu->addAction (a);
1683 actionSettingsUseHideExport=a;
1685 settingsMenu->addSeparator();
1687 a = new QAction( tr( "Animation","Settings action"), this);
1688 a->setStatusTip( tr( "Animation"));
1689 a->setToggleAction(true);
1690 a->setChecked (settings.value("/animation/use",true).toBool() );
1691 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) );
1692 settingsMenu->addAction (a);
1693 actionSettingsUseAnimation=a;
1695 a = new QAction( tr( "Automatic layout","Settings action"), this);
1696 a->setStatusTip( tr( "Automatic layout"));
1697 a->setToggleAction(true);
1698 a->setChecked ( settings.value ("/mainwindow/autoLayout/use",true).toBool());
1699 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutoLayoutToggle() ) );
1700 settingsMenu->addAction (a);
1701 actionSettingsAutoLayoutToggle=a;
1706 void Main::setupTestActions()
1708 QMenu *testMenu = menuBar()->addMenu( tr( "Test" ));
1711 a = new QAction( "Test function 1" , this);
1712 a->setStatusTip( "Call test function 1" );
1713 a->setShortcut (Qt::SHIFT + Qt::Key_T); // Test function 1
1714 switchboard.addConnection(a,tr("Test shortcuts","Shortcut group"));
1715 testMenu->addAction (a);
1716 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1718 a = new QAction( "Test function 2" , this);
1719 a->setStatusTip( "Call test function 2" );
1720 a->setShortcut (Qt::ALT + Qt::Key_T); // Test function 2
1721 switchboard.addConnection(a,tr("Test shortcuts","Shortcut group"));
1722 testMenu->addAction (a);
1723 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1725 a = new QAction( "Command" , this);
1726 a->setStatusTip( "Enter command to call in editor" );
1727 switchboard.addConnection(a,tr("Test shortcuts","Shortcut group"));
1728 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1729 testMenu->addAction (a);
1733 void Main::setupHelpActions()
1735 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1738 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1739 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1740 switchboard.addConnection(a,tr("Help shortcuts","Shortcut group"));
1741 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1742 helpMenu->addAction (a);
1744 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1745 a->setStatusTip( tr( "Open VYM example maps " ));
1746 switchboard.addConnection(a,tr("Help shortcuts","Shortcut group"));
1747 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1748 helpMenu->addAction (a);
1750 a = new QAction( tr( "About VYM","Help action" ), this);
1751 a->setStatusTip( tr( "About VYM")+vymName);
1752 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1753 helpMenu->addAction (a);
1755 a = new QAction( tr( "About QT","Help action" ), this);
1756 a->setStatusTip( tr( "Information about QT toolkit" ));
1757 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1758 helpMenu->addAction (a);
1762 void Main::setupContextMenus()
1764 // Context Menu for branch or mapcenter
1765 branchContextMenu =new QMenu (this);
1766 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1767 branchContextMenu->addSeparator();
1770 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1771 branchAddContextMenu->addAction (actionPaste );
1772 branchAddContextMenu->addAction ( actionAddMapCenter );
1773 branchAddContextMenu->addAction ( actionAddBranch );
1774 branchAddContextMenu->addAction ( actionAddBranchBefore );
1775 branchAddContextMenu->addAction ( actionAddBranchAbove);
1776 branchAddContextMenu->addAction ( actionAddBranchBelow );
1777 branchAddContextMenu->addSeparator();
1778 branchAddContextMenu->addAction ( actionImportAdd );
1779 branchAddContextMenu->addAction ( actionImportReplace );
1782 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1783 branchRemoveContextMenu->addAction (actionCut);
1784 branchRemoveContextMenu->addAction ( actionDelete );
1785 branchRemoveContextMenu->addAction ( actionDeleteKeepChildren );
1786 branchRemoveContextMenu->addAction ( actionDeleteChildren );
1789 actionSaveBranch->addTo( branchContextMenu );
1790 actionFileNewCopy->addTo (branchContextMenu );
1791 actionDetach->addTo (branchContextMenu );
1793 branchContextMenu->addSeparator();
1794 branchContextMenu->addAction ( actionLoadImage);
1795 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1796 branchContextMenu->addAction ( actionAddAttribute);
1798 // Submenu for Links (URLs, vymLinks)
1799 branchLinksContextMenu =new QMenu (this);
1801 branchContextMenu->addSeparator();
1802 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1803 branchLinksContextMenu->addAction ( actionOpenURL );
1804 branchLinksContextMenu->addAction ( actionOpenURLTab );
1805 branchLinksContextMenu->addAction ( actionOpenMultipleVisURLTabs );
1806 branchLinksContextMenu->addAction ( actionOpenMultipleURLTabs );
1807 branchLinksContextMenu->addAction ( actionURL );
1808 branchLinksContextMenu->addAction ( actionLocalURL );
1809 branchLinksContextMenu->addAction ( actionHeading2URL );
1810 branchLinksContextMenu->addAction ( actionBugzilla2URL );
1811 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1813 branchLinksContextMenu->addAction ( actionGetBugzillaData );
1814 branchLinksContextMenu->addAction ( actionFATE2URL );
1816 branchLinksContextMenu->addSeparator();
1817 branchLinksContextMenu->addAction ( actionOpenVymLink );
1818 branchLinksContextMenu->addAction ( actionOpenMultipleVymLinks );
1819 branchLinksContextMenu->addAction ( actionVymLink );
1820 branchLinksContextMenu->addAction ( actionDeleteVymLink );
1823 // Context Menu for XLinks in a branch menu
1824 // This will be populated "on demand" in MapEditor::updateActions
1825 branchContextMenu->addSeparator();
1826 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1827 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1830 // Context menu for floatimage
1831 floatimageContextMenu =new QMenu (this);
1832 QAction *a= new QAction (tr ("Save image","Context action"),this);
1833 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1834 floatimageContextMenu->addAction (a);
1836 floatimageContextMenu->addSeparator();
1837 actionCopy->addTo( floatimageContextMenu );
1838 actionCut->addTo( floatimageContextMenu );
1840 floatimageContextMenu->addSeparator();
1841 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1844 // Context menu for canvas
1845 canvasContextMenu =new QMenu (this);
1846 actionAddMapCenter->addTo( canvasContextMenu );
1847 actionMapInfo->addTo( canvasContextMenu );
1848 canvasContextMenu->insertSeparator();
1849 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1850 canvasContextMenu->insertSeparator();
1851 actionFormatLinkColorHint->addTo( canvasContextMenu );
1852 actionFormatLinkColor->addTo( canvasContextMenu );
1853 actionFormatSelectionColor->addTo( canvasContextMenu );
1854 actionFormatBackColor->addTo( canvasContextMenu );
1855 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME-4 makes vym too slow: postponed for later version
1857 // Menu for last opened files
1859 for (int i = 0; i < MaxRecentFiles; ++i)
1861 recentFileActions[i] = new QAction(this);
1862 recentFileActions[i]->setVisible(false);
1863 fileLastMapsMenu->addAction(recentFileActions[i]);
1864 connect(recentFileActions[i], SIGNAL(triggered()),
1865 this, SLOT(fileLoadRecent()));
1867 setupRecentMapsMenu();
1870 void Main::setupRecentMapsMenu()
1872 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1874 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1876 for (int i = 0; i < numRecentFiles; ++i) {
1877 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1878 recentFileActions[i]->setText(text);
1879 recentFileActions[i]->setData(files[i]);
1880 recentFileActions[i]->setVisible(true);
1882 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1883 recentFileActions[j]->setVisible(false);
1886 void Main::setupMacros()
1888 for (int i = 0; i <= 11; i++)
1890 macroActions[i] = new QAction(this);
1891 macroActions[i]->setData(i);
1892 addAction (macroActions[i]);
1893 //switchboard.addConnection(macroActions[i],tr("Macro shortcuts","Shortcut group"));
1894 connect(macroActions[i], SIGNAL(triggered()),
1895 this, SLOT(callMacro()));
1897 macroActions[0]->setShortcut ( Qt::Key_F1 );
1898 macroActions[1]->setShortcut ( Qt::Key_F2 );
1899 macroActions[2]->setShortcut ( Qt::Key_F3 );
1900 macroActions[3]->setShortcut ( Qt::Key_F4 );
1901 macroActions[4]->setShortcut ( Qt::Key_F5 );
1902 macroActions[5]->setShortcut ( Qt::Key_F6 );
1903 macroActions[6]->setShortcut ( Qt::Key_F7 );
1904 macroActions[7]->setShortcut ( Qt::Key_F8 );
1905 macroActions[8]->setShortcut ( Qt::Key_F9 );
1906 macroActions[9]->setShortcut ( Qt::Key_F10 );
1907 macroActions[10]->setShortcut ( Qt::Key_F11 );
1908 macroActions[11]->setShortcut ( Qt::Key_F12 );
1911 void Main::hideEvent (QHideEvent * )
1913 if (!textEditor->isMinimized() ) textEditor->hide();
1916 void Main::showEvent (QShowEvent * )
1918 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1922 MapEditor* Main::currentMapEditor() const
1924 if ( tabWidget->currentPage())
1925 return vymViews.at(tabWidget->currentIndex())->getMapEditor();
1929 uint Main::currentModelID() const
1932 return currentModel()->getID();
1936 VymModel* Main::currentModel() const
1938 if ( tabWidget->currentPage())
1939 return vymViews.at(tabWidget->currentIndex())->getModel();
1943 VymModel* Main::getModel(uint id) const
1946 for (int i=0; i<vymViews.count();i++)
1947 if (vymViews.at(i)->getModel()->getID()==id)
1948 return vymViews.at(i)->getModel();
1953 void Main::editorChanged(QWidget *)
1955 // Unselect all possibly selected objects
1956 // (Important to update note editor)
1958 for (int i=0;i<=tabWidget->count() -1;i++)
1960 m= vymViews.at(i)->getModel();
1961 if (m) m->unselect();
1964 if (m) m->reselect();
1966 // Update actions to in menus and toolbars according to editor
1970 void Main::fileNew()
1972 VymModel *vm=new VymModel;
1974 /////////////////////////////////////
1975 // new ModelTest(vm, this); //FIXME-3
1976 /////////////////////////////////////
1978 VymView *vv=new VymView (vm);
1979 vymViews.append (vv);
1980 tabWidget->addTab (vv,tr("unnamed","MainWindow: name for new and empty file"));
1981 tabWidget->setCurrentIndex (vymViews.count() );
1984 // Create MapCenter for empty map
1988 // For the very first map we do not have flagrows yet...
1992 void Main::fileNewCopy()
1994 QString fn="unnamed";
1995 VymModel *srcModel=currentModel();
2000 VymModel *dstModel=vymViews.last()->getModel();
2001 dstModel->select("mc:");
2002 dstModel->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
2006 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
2008 ErrorCode err=success;
2010 // fn is usually the archive, mapfile the file after uncompressing
2013 // Make fn absolute (needed for unzip)
2014 fn=QDir (fn).absPath();
2020 // Check, if map is already loaded
2022 while (i<=tabWidget->count() -1)
2024 if (vymViews.at(i)->getModel()->getFilePath() == fn)
2026 // Already there, ask for confirmation
2027 QMessageBox mb( vymName,
2028 tr("The map %1\nis already opened."
2029 "Opening the same map in multiple editors may lead \n"
2030 "to confusion when finishing working with vym."
2031 "Do you want to").arg(fn),
2032 QMessageBox::Warning,
2033 QMessageBox::Yes | QMessageBox::Default,
2034 QMessageBox::Cancel | QMessageBox::Escape,
2035 QMessageBox::NoButton);
2036 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
2037 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2040 case QMessageBox::Yes:
2041 // end loop and load anyway
2042 i=tabWidget->count();
2044 case QMessageBox::Cancel:
2054 int tabIndex=tabWidget->currentPageIndex();
2057 if ( !fn.isEmpty() )
2059 vm = currentModel();
2060 // Check first, if mapeditor exists
2061 // If it is not default AND we want a new map,
2062 // create a new mapeditor in a new tab
2063 if ( lmode==NewMap && (!vm || !vm->isDefault() ) )
2066 VymView *vv=new VymView (vm);
2067 vymViews.append (vv);
2068 tabWidget->addTab (vv,fn);
2069 tabIndex=tabWidget->count()-1;
2070 tabWidget->setCurrentPage (tabIndex);
2074 // Check, if file exists (important for creating new files
2075 // from command line
2076 if (!QFile(fn).exists() )
2078 QMessageBox mb( vymName,
2079 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
2080 QMessageBox::Question,
2082 QMessageBox::Cancel | QMessageBox::Default,
2083 QMessageBox::NoButton );
2085 mb.setButtonText( QMessageBox::Yes, tr("Create"));
2086 mb.setButtonText( QMessageBox::No, tr("Cancel"));
2089 case QMessageBox::Yes:
2091 currentMapEditor()->getModel()->setFilePath(fn);
2092 tabWidget->setTabText (tabIndex,
2093 currentMapEditor()->getModel()->getFileName() );
2094 statusBar()->message( "Created " + fn , statusbarTime );
2097 case QMessageBox::Cancel:
2098 // don't create new map
2099 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
2106 //tabWidget->currentPage() won't be NULL here, because of above...
2107 tabWidget->setCurrentIndex (tabIndex);
2108 //FIXME-3 no me anymore... me->viewport()->setFocus();
2112 // Save existing filename in case we import
2113 QString fn_org=vm->getFilePath();
2115 // Finally load map into mapEditor
2116 vm->setFilePath (fn);
2117 err=vm->load(fn,lmode,ftype);
2119 // Restore old (maybe empty) filepath, if this is an import
2121 vm->setFilePath (fn_org);
2124 // Finally check for errors and go home
2127 if (lmode==NewMap) fileCloseMap();
2128 statusBar()->message( "Could not load " + fn, statusbarTime );
2133 vm->setFilePath (fn);
2134 tabWidget->setTabText (tabIndex, vm->getFileName());
2135 if (!isInTmpDir (fn))
2137 // Only append to lastMaps if not loaded from a tmpDir
2138 // e.g. imported bookmarks are in a tmpDir
2139 addRecentMap(vm->getFilePath() );
2141 actionFilePrint->setEnabled (true);
2143 statusBar()->message( "Loaded " + fn, statusbarTime );
2150 void Main::fileLoad(const LoadMode &lmode)
2152 QStringList filters;
2153 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
2154 QFileDialog *fd=new QFileDialog( this);
2155 fd->setDir (lastFileDir);
2156 fd->setFileMode (QFileDialog::ExistingFiles);
2157 fd->setFilters (filters);
2161 fd->setCaption(vymName+ " - " +tr("Load vym map"));
2164 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
2167 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
2173 if ( fd->exec() == QDialog::Accepted )
2175 lastFileDir=fd->directory().path();
2176 QStringList flist = fd->selectedFiles();
2177 QStringList::Iterator it = flist.begin();
2179 progressCounter=flist.count();
2180 progressCounterTotal=flist.count();
2181 while( it != flist.end() )
2184 fileLoad(*it, lmode);
2191 void Main::fileLoad()
2196 void Main::fileLoadRecent()
2198 QAction *action = qobject_cast<QAction *>(sender());
2200 fileLoad (action->data().toString(), NewMap);
2203 void Main::addRecentMap (const QString &fileName)
2206 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
2207 files.removeAll(fileName);
2208 files.prepend(fileName);
2209 while (files.size() > MaxRecentFiles)
2212 settings.setValue("/mainwindow/recentFileList", files);
2214 setupRecentMapsMenu();
2217 void Main::fileSave(VymModel *m, const SaveMode &savemode)
2221 if ( m->getFilePath().isEmpty() )
2223 // We have no filepath yet,
2224 // call fileSaveAs() now, this will call fileSave()
2226 // First switch to editor
2227 //FIXME-3 needed??? tabWidget->setCurrentWidget (m->getMapEditor());
2228 fileSaveAs(savemode);
2231 if (m->save (savemode)==success)
2233 statusBar()->message(
2234 tr("Saved %1").arg(m->getFilePath()),
2236 addRecentMap (m->getFilePath() );
2238 statusBar()->message(
2239 tr("Couldn't save ").arg(m->getFilePath()),
2243 void Main::fileSave()
2245 fileSave (currentModel(), CompleteMap);
2248 void Main::fileSave(VymModel *m)
2250 fileSave (m,CompleteMap);
2253 void Main::fileSaveAs(const SaveMode& savemode)
2257 if (currentMapEditor())
2259 if (savemode==CompleteMap)
2260 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2262 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2263 if ( !fn.isEmpty() )
2265 // Check for existing file
2266 if (QFile (fn).exists())
2268 QMessageBox mb( vymName,
2269 tr("The file %1\nexists already. Do you want to").arg(fn),
2270 QMessageBox::Warning,
2271 QMessageBox::Yes | QMessageBox::Default,
2272 QMessageBox::Cancel | QMessageBox::Escape,
2273 QMessageBox::NoButton);
2274 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2275 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2278 case QMessageBox::Yes:
2281 case QMessageBox::Cancel:
2288 // New file, add extension to filename, if missing
2289 // This is always .vym or .vyp, depending on savemode
2290 if (savemode==CompleteMap)
2292 if (!fn.contains (".vym") && !fn.contains (".xml"))
2296 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2305 VymModel *m=currentModel();
2307 fileSave(m, savemode);
2309 // Set name of tab, assuming current tab is the one we just saved
2310 if (savemode==CompleteMap)
2311 tabWidget->setTabText (tabWidget->currentIndex(), m->getFileName() );
2317 void Main::fileSaveAs()
2319 fileSaveAs (CompleteMap);
2322 void Main::fileImportKDE3Bookmarks()
2324 ImportKDE3Bookmarks im;
2326 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2327 currentMapEditor()->getModel()->setFilePath ("");
2330 void Main::fileImportKDE4Bookmarks()
2332 ImportKDE4Bookmarks im;
2334 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2335 currentMapEditor()->getModel()->setFilePath ("");
2338 void Main::fileImportFirefoxBookmarks()
2340 Q3FileDialog *fd=new Q3FileDialog( this);
2341 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2342 fd->setMode (Q3FileDialog::ExistingFiles);
2343 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2344 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2347 if ( fd->exec() == QDialog::Accepted )
2349 ImportFirefoxBookmarks im;
2350 QStringList flist = fd->selectedFiles();
2351 QStringList::Iterator it = flist.begin();
2352 while( it != flist.end() )
2355 if (im.transform() &&
2356 aborted!=fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2357 currentMapEditor() )
2358 currentMapEditor()->getModel()->setFilePath ("");
2365 void Main::fileImportFreemind()
2367 QStringList filters;
2368 filters <<"Freemind map (*.mm)"<<"All files (*)";
2369 QFileDialog *fd=new QFileDialog( this);
2370 fd->setDir (lastFileDir);
2371 fd->setFileMode (QFileDialog::ExistingFiles);
2372 fd->setFilters (filters);
2373 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2377 if ( fd->exec() == QDialog::Accepted )
2379 lastFileDir=fd->directory().path();
2380 QStringList flist = fd->selectedFiles();
2381 QStringList::Iterator it = flist.begin();
2382 while( it != flist.end() )
2385 if ( fileLoad (fn,NewMap, FreemindMap) )
2387 currentMapEditor()->getModel()->setFilePath ("");
2396 void Main::fileImportMM()
2400 Q3FileDialog *fd=new Q3FileDialog( this);
2401 fd->setDir (lastFileDir);
2402 fd->setMode (Q3FileDialog::ExistingFiles);
2403 fd->addFilter ("Mind Manager (*.mmap)");
2404 fd->setCaption(tr("Import")+" "+"Mind Manager");
2407 if ( fd->exec() == QDialog::Accepted )
2409 lastFileDir=fd->dirPath();
2410 QStringList flist = fd->selectedFiles();
2411 QStringList::Iterator it = flist.begin();
2412 while( it != flist.end() )
2415 if (im.transform() &&
2416 success==fileLoad (im.getTransformedFile(),NewMap) &&
2417 currentMapEditor() )
2418 currentMapEditor()->getModel()->setFilePath ("");
2425 void Main::fileImportDir()
2427 VymModel *m=currentModel();
2428 if (m) m->importDir();
2431 void Main::fileExportXML()
2433 VymModel *m=currentModel();
2434 if (m) m->exportXML();
2437 void Main::fileExportHTML()
2439 VymModel *m=currentModel();
2440 if (m) m->exportHTML();
2444 void Main::fileExportXHTML()
2446 VymModel *m=currentModel();
2447 if (m) m->exportXHTML();
2450 void Main::fileExportImage()
2452 VymModel *m=currentModel();
2453 if (m) m->exportImage();
2456 void Main::fileExportAO()
2458 VymModel *m=currentModel();
2459 if (m) m->exportAO();
2462 void Main::fileExportASCII()
2464 VymModel *m=currentModel();
2465 if (m) m->exportASCII();
2468 void Main::fileExportCSV() //FIXME-3 not scriptable yet
2470 VymModel *m=currentModel();
2475 ex.addFilter ("CSV (*.csv)");
2476 ex.setDir(lastImageDir);
2477 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2478 if (ex.execDialog() )
2480 m->setExportMode(true);
2482 m->setExportMode(false);
2487 void Main::fileExportLaTeX() //FIXME-3 not scriptable yet
2489 VymModel *m=currentModel();
2494 ex.addFilter ("Tex (*.tex)");
2495 ex.setDir(lastImageDir);
2496 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2497 if (ex.execDialog() )
2499 m->setExportMode(true);
2501 m->setExportMode(false);
2506 void Main::fileExportKDE3Bookmarks() //FIXME-3 not scriptable yet
2508 ExportKDE3Bookmarks ex;
2509 VymModel *m=currentModel();
2517 void Main::fileExportKDE4Bookmarks() //FIXME-3 not scriptable yet
2519 ExportKDE4Bookmarks ex;
2520 VymModel *m=currentModel();
2528 void Main::fileExportTaskjuggler() //FIXME-3 not scriptable yet
2530 ExportTaskjuggler ex;
2531 VymModel *m=currentModel();
2535 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2536 ex.setDir(lastImageDir);
2537 ex.addFilter ("Taskjuggler (*.tjp)");
2538 if (ex.execDialog() )
2540 m->setExportMode(true);
2542 m->setExportMode(false);
2547 void Main::fileExportOOPresentation() //FIXME-3 not scriptable yet
2549 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2550 // TODO add preview in dialog
2551 //ImagePreview *p =new ImagePreview (fd);
2552 //fd->setContentsPreviewEnabled( TRUE );
2553 //fd->setContentsPreview( p, p );
2554 //fd->setPreviewMode( QFileDialog::Contents );
2555 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2556 fd->setDir (QDir().current());
2557 if (fd->foundConfig())
2561 if ( fd->exec() == QDialog::Accepted )
2563 QString fn=fd->selectedFile();
2564 if (!fn.contains (".odp"))
2567 //lastImageDir=fn.left(fn.findRev ("/"));
2568 VymModel *m=currentModel();
2569 if (m) m->exportOOPresentation(fn,fd->selectedConfig());
2573 QMessageBox::warning(0,
2575 tr("Couldn't find configuration for export to Open Office\n"));
2579 void Main::fileCloseMap()
2581 VymModel *m=currentModel();
2584 if (m->hasChanged())
2586 QMessageBox mb( vymName,
2587 tr("The map %1 has been modified but not saved yet. Do you want to").arg(m->getFileName()),
2588 QMessageBox::Warning,
2589 QMessageBox::Yes | QMessageBox::Default,
2591 QMessageBox::Cancel | QMessageBox::Escape );
2592 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2593 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2596 case QMessageBox::Yes:
2598 fileSave(m, CompleteMap);
2600 case QMessageBox::No:
2601 // close without saving
2603 case QMessageBox::Cancel:
2608 // And here comes the segfault, because removeTab triggers
2609 // FIXME-3 currentChanged->Main::editorChanged -> updateActions and VM is not NULL yet...
2610 vymViews.removeAt (tabWidget->currentIndex() );
2611 tabWidget->removeTab (tabWidget->currentIndex() );
2613 // Remove mapEditor/model FIXME-3 Huh? seems to work now...
2614 // Better would be delete (me), but then we could have a Qt error:
2615 // "QObject: Do not delete object, 'MapEditor', during its event handler!"
2616 // So we only remove data now and call deconstructor when vym closes later
2617 // this needs to be moved to vymview... me->clear();
2618 // some model->clear is needed to free up memory ...
2620 delete (m->getMapEditor());
2627 void Main::filePrint()
2629 if (currentMapEditor())
2630 currentMapEditor()->print();
2633 void Main::fileExitVYM()
2635 // Check if one or more editors have changed
2637 for (i=0;i<=vymViews.count() -1;i++)
2639 // If something changed, ask what to do
2640 if (vymViews.at(i)->getModel()->hasChanged())
2642 tabWidget->setCurrentPage(i);
2643 QMessageBox mb( vymName,
2644 tr("This map is not saved yet. Do you want to"),
2645 QMessageBox::Warning,
2646 QMessageBox::Yes | QMessageBox::Default,
2648 QMessageBox::Cancel | QMessageBox::Escape );
2649 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2650 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2653 mb.setActiveWindow();
2654 switch( mb.exec() ) {
2655 case QMessageBox::Yes:
2656 // save (the changed editors) and exit
2657 fileSave(currentModel(), CompleteMap);
2659 case QMessageBox::No:
2660 // exit without saving
2662 case QMessageBox::Cancel:
2663 // don't save and don't exit
2667 } // loop over all MEs
2671 void Main::editUndo()
2673 VymModel *m=currentModel();
2677 void Main::editRedo()
2679 VymModel *m=currentModel();
2683 void Main::gotoHistoryStep (int i)
2685 VymModel *m=currentModel();
2686 if (m) m->gotoHistoryStep(i);
2689 void Main::editCopy()
2691 VymModel *m=currentModel();
2695 void Main::editPaste()
2697 VymModel *m=currentModel();
2701 void Main::editCut()
2703 VymModel *m=currentModel();
2707 void Main::editOpenFindWidget()
2709 if (!findWidget->isVisible())
2712 findWidget->setFocus();
2713 } else if (!findResultWidget->parentWidget()->isVisible())
2714 findResultWidget->parentWidget()->show();
2718 findResultWidget->parentWidget()->hide();
2722 void Main::editHideFindWidget()
2724 // findWidget hides itself, but we want
2725 // to have focus back at mapEditor usually
2726 MapEditor *me=currentMapEditor();
2727 if (me) me->setFocus();
2730 void Main::editFindNext(QString s)
2732 Qt::CaseSensitivity cs=Qt::CaseInsensitive;
2734 VymModel *m=currentModel();
2737 m->findAll (findResultWidget->getResultModel(),s,cs);
2739 BranchItem *bi=m->findText(s, cs,cursor);
2742 findWidget->setStatus (FindWidget::Success);
2745 findWidget->setStatus (FindWidget::Failed);
2749 void Main::editFindDuplicateURLs() //FIXME-4 feature: use FindResultWidget for display
2751 VymModel *m=currentModel();
2752 if (m) m->findDuplicateURLs();
2755 void Main::openTabs(QStringList urls)
2757 if (!urls.isEmpty())
2761 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2762 //qDebug ()<<"Services: "<<QDBusConnection::sessionBus().interface()->registeredServiceNames().value();
2763 if (*browserPID==0 ||
2764 (browser.contains("konqueror") &&
2765 !QDBusConnection::sessionBus().interface()->registeredServiceNames().value().contains (QString("org.kde.konqueror-%1").arg(*browserPID)))
2768 // Start a new browser, if there is not one running already or
2769 // if a previously started konqueror is gone.
2770 if (debug) cout <<"Main::openTabs no konqueror-"<<*browserPID<<" found\n";
2771 QString u=urls.takeFirst();
2773 QString workDir=QDir::currentDirPath();
2774 if (!QProcess::startDetached(browser,args,workDir,browserPID))
2776 // try to set path to browser
2777 QMessageBox::warning(0,
2779 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2780 tr("Please use Settings->")+tr("Set application to open an URL"));
2783 if (debug) cout << "Main::openTabs Started konqueror-"<<*browserPID<<endl;
2784 #if defined(Q_OS_WIN32)
2785 // There's no sleep in VCEE, replace it with Qt's QThread::wait().
2786 this->thread()->wait(3000);
2788 sleep (3); //FIXME-3 needed?
2792 if (browser.contains("konqueror"))
2794 for (int i=0; i<urls.size(); i++)
2797 // Try to open new tab in existing konqueror started previously by vym
2801 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2802 "konqueror-mainwindow#1"<<
2806 args<< QString("org.kde.konqueror-%1").arg(*browserPID)<<
2807 "/konqueror/MainWindow_1"<<
2811 if (debug) cout << "MainWindow::openURLs args="<<args.join(" ").toStdString()<<endl;
2812 if (!QProcess::startDetached ("qdbus",args))
2816 QMessageBox::warning(0,
2818 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2820 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2822 for (int i=0; i<urls.size(); i++)
2824 // Try to open new tab in firefox
2825 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2826 if (!QProcess::startDetached (browser,args))
2830 QMessageBox::warning(0,
2832 tr("Couldn't start %1 to open a new tab").arg(browser));
2835 QMessageBox::warning(0,
2837 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2841 void Main::editOpenURL()
2844 VymModel *m=currentModel();
2847 QString url=m->getURL();
2849 if (url=="") return;
2850 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2852 QString workDir=QDir::currentDirPath();
2853 if (!procBrowser->startDetached(browser,args))
2855 // try to set path to browser
2856 QMessageBox::warning(0,
2858 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2859 tr("Please use Settings->")+tr("Set application to open an URL"));
2864 void Main::editOpenURLTab()
2866 VymModel *m=currentModel();
2870 urls.append(m->getURL());
2875 void Main::editOpenMultipleVisURLTabs(bool ignoreScrolled)
2877 VymModel *m=currentModel();
2881 urls=m->getURLs(ignoreScrolled);
2886 void Main::editOpenMultipleURLTabs()
2888 editOpenMultipleVisURLTabs (false);
2892 void Main::editURL()
2894 VymModel *m=currentModel();
2895 if (m) m->editURL();
2898 void Main::editLocalURL()
2900 VymModel *m=currentModel();
2901 if (m) m->editLocalURL();
2904 void Main::editHeading2URL()
2906 VymModel *m=currentModel();
2907 if (m) m->editHeading2URL();
2910 void Main::editBugzilla2URL()
2912 VymModel *m=currentModel();
2913 if (m) m->editBugzilla2URL();
2916 void Main::getBugzillaData()
2918 VymModel *m=currentModel();
2920 QProgressDialog progress ("Doing stuff","cancl",0,10,this);
2921 progress.setWindowModality(Qt::WindowModal);
2922 //progress.setCancelButton (NULL);
2924 progress.setMinimumDuration (0);
2925 progress.setValue (1);
2926 progress.setValue (5);
2930 QProgressBar *pb=new QProgressBar;
2936 if (m) m->getBugzillaData();
2939 void Main::editFATE2URL()
2941 VymModel *m=currentModel();
2942 if (m) m->editFATE2URL();
2945 void Main::editHeadingFinished(VymModel *m)
2949 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2950 !prevSelection.isEmpty())
2951 m->select(prevSelection);
2956 void Main::openVymLinks(const QStringList &vl)
2958 for (int j=0; j<vl.size(); j++)
2960 // compare path with already loaded maps
2963 for (i=0;i<=vymViews.count() -1;i++)
2965 if (vl.at(j)==vymViews.at(i)->getModel()->getFilePath() )
2974 if (!QFile(vl.at(j)).exists() )
2975 QMessageBox::critical( 0, tr( "Critical Error" ),
2976 tr("Couldn't open map %1").arg(vl.at(j)));
2979 fileLoad (vl.at(j), NewMap);
2980 tabWidget->setCurrentIndex (tabWidget->count()-1);
2983 // Go to tab containing the map
2984 tabWidget->setCurrentIndex (index);
2988 void Main::editOpenVymLink()
2990 VymModel *m=currentModel();
2994 vl.append(m->getVymLink());
2999 void Main::editOpenMultipleVymLinks()
3001 QString currentVymLink;
3002 VymModel *m=currentModel();
3005 QStringList vl=m->getVymLinks();
3010 void Main::editVymLink()
3012 VymModel *m=currentModel();
3017 void Main::editDeleteVymLink()
3019 VymModel *m=currentModel();
3020 if (m) m->deleteVymLink();
3023 void Main::editToggleHideExport()
3025 VymModel *m=currentModel();
3026 if (m) m->toggleHideExport();
3029 void Main::editAddTimestamp()
3031 VymModel *m=currentModel();
3032 if (m) m->addTimestamp();
3035 void Main::editMapInfo()
3037 VymModel *m=currentModel();
3040 ExtraInfoDialog dia;
3041 dia.setMapName (m->getFileName() );
3042 dia.setAuthor (m->getAuthor() );
3043 dia.setComment(m->getComment() );
3047 stats+=tr("%1 items on map\n","Info about map").arg (m->getScene()->items().size(),6);
3053 BranchItem *cur=NULL;
3054 BranchItem *prev=NULL;
3055 m->nextBranch(cur,prev);
3058 if (!cur->getNote().isEmpty() ) n++;
3059 f+= cur->imageCount();
3061 xl+=cur->xlinkCount();
3062 m->nextBranch(cur,prev);
3065 stats+=QString ("%1 xLinks \n").arg (xl,6);
3066 stats+=QString ("%1 notes\n").arg (n,6);
3067 stats+=QString ("%1 images\n").arg (f,6);
3068 stats+=QString ("%1 branches\n").arg (m->branchCount(),6);
3069 dia.setStats (stats);
3071 // Finally show dialog
3072 if (dia.exec() == QDialog::Accepted)
3074 m->setAuthor (dia.getAuthor() );
3075 m->setComment (dia.getComment() );
3079 void Main::editMoveUp()
3081 VymModel *m=currentModel();
3085 void Main::editMoveDown()
3087 VymModel *m=currentModel();
3088 if (m) m->moveDown();
3091 void Main::editDetach()
3093 VymModel *m=currentModel();
3097 void Main::editSortChildren()
3099 VymModel *m=currentModel();
3100 if (m) m->sortChildren(false);
3103 void Main::editSortBackChildren()
3105 VymModel *m=currentModel();
3106 if (m) m->sortChildren(true);
3109 void Main::editToggleScroll()
3111 VymModel *m=currentModel();
3112 if (m) m->toggleScroll();
3115 void Main::editExpandAll()
3117 VymModel *m=currentModel();
3118 if (m) m->emitExpandAll();
3121 void Main::editExpandOneLevel()
3123 VymModel *m=currentModel();
3124 if (m) m->emitExpandOneLevel();
3127 void Main::editCollapseOneLevel()
3129 VymModel *m=currentModel();
3130 if (m) m->emitCollapseOneLevel();
3133 void Main::editUnscrollChildren()
3135 VymModel *m=currentModel();
3136 if (m) m->unscrollChildren();
3139 void Main::editAddAttribute()
3141 VymModel *m=currentModel();
3149 void Main::editAddMapCenter()
3151 VymModel *m=currentModel();
3152 if (m) m->select (m->addMapCenter ());
3155 void Main::editNewBranch()
3157 VymModel *m=currentModel();
3160 BranchItem *bi=m->addNewBranch();
3163 if (actionSettingsAutoEditNewBranch->isOn()
3164 && !actionSettingsAutoSelectNewBranch->isOn() )
3165 prevSelection=m->getSelectString();
3167 prevSelection=QString();
3169 if (actionSettingsAutoSelectNewBranch->isOn()
3170 || actionSettingsAutoEditNewBranch->isOn())
3173 if (actionSettingsAutoEditNewBranch->isOn())
3174 currentMapEditor()->editHeading();
3179 void Main::editNewBranchBefore()
3181 VymModel *m=currentModel();
3184 BranchItem *bi=m->addNewBranchBefore();
3191 if (actionSettingsAutoEditNewBranch->isOn())
3193 if (!actionSettingsAutoSelectNewBranch->isOn())
3194 prevSelection=m->getSelectString(bi);
3195 currentMapEditor()->editHeading();
3200 void Main::editNewBranchAbove()
3202 VymModel *m=currentModel();
3205 BranchItem *bi=m->addNewBranch (-1);
3213 if (actionSettingsAutoEditNewBranch->isOn())
3215 if (!actionSettingsAutoSelectNewBranch->isOn())
3216 prevSelection=m->getSelectString (bi);
3217 currentMapEditor()->editHeading();
3222 void Main::editNewBranchBelow()
3224 VymModel *m=currentModel();
3227 BranchItem *bi=m->addNewBranch (1);
3234 if (actionSettingsAutoEditNewBranch->isOn())
3236 if (!actionSettingsAutoSelectNewBranch->isOn())
3237 prevSelection=m->getSelectString(bi);
3238 currentMapEditor()->editHeading();
3243 void Main::editImportAdd()
3245 fileLoad (ImportAdd);
3248 void Main::editImportReplace()
3250 fileLoad (ImportReplace);
3253 void Main::editSaveBranch()
3255 fileSaveAs (PartOfMap);
3258 void Main::editDeleteKeepChildren()
3260 VymModel *m=currentModel();
3261 if (m) m->deleteKeepChildren();
3264 void Main::editDeleteChildren()
3266 VymModel *m=currentModel();
3267 if (m) m->deleteChildren();
3270 void Main::editDeleteSelection()
3272 VymModel *m=currentModel();
3273 if (m && actionSettingsUseDelKey->isOn())
3274 m->deleteSelection();
3277 void Main::editLoadImage()
3279 VymModel *m=currentModel();
3280 if (m) m->loadFloatImage();
3283 void Main::editSaveImage()
3285 VymModel *m=currentModel();
3286 if (m) m->saveFloatImage();
3289 void Main::editEditXLink(QAction *a)
3291 VymModel *m=currentModel();
3293 m->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3296 void Main::formatSelectColor()
3298 QColor col = QColorDialog::getColor((currentColor ), this );
3299 if ( !col.isValid() ) return;
3300 colorChanged( col );
3303 void Main::formatPickColor()
3305 VymModel *m=currentModel();
3307 colorChanged( m->getCurrentHeadingColor() );
3310 void Main::colorChanged(QColor c)
3312 QPixmap pix( 16, 16 );
3314 actionFormatColor->setIconSet( pix );
3318 void Main::formatColorBranch()
3320 VymModel *m=currentModel();
3321 if (m) m->colorBranch(currentColor);
3324 void Main::formatColorSubtree()
3326 VymModel *m=currentModel();
3327 if (m) m->colorSubtree (currentColor);
3330 void Main::formatLinkStyleLine()
3332 VymModel *m=currentModel();
3335 m->setMapLinkStyle("StyleLine");
3336 actionFormatLinkStyleLine->setChecked(true);
3340 void Main::formatLinkStyleParabel()
3342 VymModel *m=currentModel();
3345 m->setMapLinkStyle("StyleParabel");
3346 actionFormatLinkStyleParabel->setChecked(true);
3350 void Main::formatLinkStylePolyLine()
3352 VymModel *m=currentModel();
3355 m->setMapLinkStyle("StylePolyLine");
3356 actionFormatLinkStylePolyLine->setChecked(true);
3360 void Main::formatLinkStylePolyParabel()
3362 VymModel *m=currentModel();
3365 m->setMapLinkStyle("StylePolyParabel");
3366 actionFormatLinkStylePolyParabel->setChecked(true);
3370 void Main::formatSelectBackColor()
3372 VymModel *m=currentModel();
3373 if (m) m->selectMapBackgroundColor();
3376 void Main::formatSelectBackImage()
3378 VymModel *m=currentModel();
3380 m->selectMapBackgroundImage();
3383 void Main::formatSelectLinkColor()
3385 VymModel *m=currentModel();
3388 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3389 m->setMapDefLinkColor( col );
3393 void Main::formatSelectSelectionColor()
3395 VymModel *m=currentModel();
3398 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3399 m->setSelectionColor (col);
3404 void Main::formatToggleLinkColorHint()
3406 VymModel *m=currentModel();
3407 if (m) m->toggleMapLinkColorHint();
3411 void Main::formatHideLinkUnselected() //FIXME-3 get rid of this with imagepropertydialog
3413 VymModel *m=currentModel();
3415 m->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3418 void Main::viewZoomReset()
3420 MapEditor *me=currentMapEditor();
3421 if (me) me->setZoomFactorTarget (1);
3424 void Main::viewZoomIn()
3426 MapEditor *me=currentMapEditor();
3427 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*1.15);
3430 void Main::viewZoomOut()
3432 MapEditor *me=currentMapEditor();
3433 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*0.85);
3436 void Main::viewCenter()
3438 VymModel *m=currentModel();
3439 if (m) m->emitShowSelection();
3442 void Main::networkStartServer()
3444 VymModel *m=currentModel();
3445 if (m) m->newServer();
3448 void Main::networkConnect()
3450 VymModel *m=currentModel();
3451 if (m) m->connectToServer();
3454 bool Main::settingsPDF()
3456 // Default browser is set in constructor
3458 QString text = QInputDialog::getText(
3459 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3460 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3462 settings.setValue ("/mainwindow/readerPDF",text);
3467 bool Main::settingsURL()
3469 // Default browser is set in constructor
3471 QString text = QInputDialog::getText(
3472 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3473 settings.value("/mainwindow/readerURL").toString()
3476 settings.setValue ("/mainwindow/readerURL",text);
3480 void Main::settingsMacroDir()
3482 QDir defdir(vymBaseDir.path() + "/macros");
3483 if (!defdir.exists())
3485 QDir dir=QFileDialog::getExistingDirectory (
3487 tr ("Directory with vym macros:"),
3488 settings.value ("/macros/macroDir",defdir.path()).toString()
3491 settings.setValue ("/macros/macroDir",dir.absolutePath());
3494 void Main::settingsUndoLevels()
3497 int i = QInputDialog::getInteger(
3499 tr("QInputDialog::getInteger()"),
3500 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3503 settings.setValue ("/mapeditor/stepsTotal",i);
3504 QMessageBox::information( this, tr( "VYM -Information:" ),
3505 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3509 void Main::settingsAutosaveToggle()
3511 settings.setValue ("/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
3514 void Main::settingsAutosaveTime()
3517 int i = QInputDialog::getInteger(
3519 tr("QInputDialog::getInteger()"),
3520 tr("Number of seconds before autosave:"), settings.value("/mainwindow/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3522 settings.setValue ("/mainwindow/autosave/ms",i * 1000);
3525 void Main::settingsAutoLayoutToggle()
3527 settings.setValue ("/mainwindow/autoLayout/use",actionSettingsAutosaveToggle->isOn() );
3530 void Main::settingsWriteBackupFileToggle()
3532 settings.setValue ("/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
3535 void Main::settingsToggleAnimation()
3537 settings.setValue ("/animation/use",actionSettingsUseAnimation->isOn() );
3540 void Main::settingsToggleDelKey()
3542 if (actionSettingsUseDelKey->isOn())
3544 actionDelete->setAccel (QKeySequence (Qt::Key_Delete));
3547 actionDelete->setAccel (QKeySequence (""));
3551 void Main::windowToggleNoteEditor()
3553 if (textEditor->isVisible() )
3554 windowHideNoteEditor();
3556 windowShowNoteEditor();
3559 void Main::windowToggleTreeEditor()
3561 if ( tabWidget->currentPage())
3562 vymViews.at(tabWidget->currentIndex())->toggleTreeEditor();
3565 void Main::windowToggleHistory()
3567 if (historyWindow->isVisible())
3568 historyWindow->hide();
3570 historyWindow->show();
3574 void Main::windowToggleProperty()
3576 if (branchPropertyWindow->isVisible())
3577 branchPropertyWindow->hide();
3579 branchPropertyWindow->show();
3580 branchPropertyWindow->setModel (currentModel() );
3583 void Main::windowToggleAntiAlias()
3585 bool b=actionViewToggleAntiAlias->isOn();
3587 for (int i=0;i<vymViews.count();i++)
3589 me=vymViews.at(i)->getMapEditor();
3590 if (me) me->setAntiAlias(b);
3595 bool Main::isAliased()
3597 return actionViewToggleAntiAlias->isOn();
3600 bool Main::hasSmoothPixmapTransform()
3602 return actionViewToggleSmoothPixmapTransform->isOn();
3605 void Main::windowToggleSmoothPixmap()
3607 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3609 for (int i=0;i<vymViews.count();i++)
3612 me=vymViews.at(i)->getMapEditor();
3613 if (me) me->setSmoothPixmap(b);
3617 void Main::updateHistory(SimpleSettings &undoSet)
3619 historyWindow->update (undoSet);
3622 void Main::updateNoteFlag()
3624 // this slot is connected to TextEditor::textHasChanged()
3625 VymModel *m=currentModel();
3626 if (m) m->updateNoteFlag();
3629 void Main::updateNoteEditor(QModelIndex index )
3631 TreeItem *ti=((VymModel*) QObject::sender())->getItem(index);
3633 cout << "Main::updateNoteEditor model="<<sender();
3634 cout << " item="<<ti->getHeadingStd()<<" ("<<ti<<")"<<endl;
3636 textEditor->setNote (ti->getNoteObj() );
3639 void Main::changeSelection (VymModel *model, const QItemSelection &newsel, const QItemSelection &oldsel)
3641 branchPropertyWindow->setModel (model ); //FIXME-3 this used to be called from BranchObj::select(). Maybe use signal now...
3643 if (model && model==currentModel() )
3647 if (!oldsel.indexes().isEmpty() )
3649 ti=model->getItem(oldsel.indexes().first());
3651 // Don't update note if both treeItem and textEditor are empty
3652 //if (! (ti->hasEmptyNote() && textEditor->isEmpty() ))
3653 // ti->setNoteObj (textEditor->getNoteObj(),false );
3655 if (!newsel.indexes().isEmpty() )
3657 ti=model->getItem(newsel.indexes().first());
3658 if (!ti->hasEmptyNote() )
3659 textEditor->setNote(ti->getNoteObj() );
3661 textEditor->setNote(NoteObj() ); //FIXME-4 maybe add a clear() to TE
3663 // Show URL and link in statusbar
3665 QString s=ti->getURL();
3666 if (!s.isEmpty() ) status+="URL: "+s+" ";
3668 if (!s.isEmpty() ) status+="Link: "+s;
3669 if (!status.isEmpty() ) statusMessage (status);
3672 textEditor->setInactive();
3678 void Main::updateActions()
3680 // updateActions is also called when satellites are closed //FIXME-2 doesn't update immediatly, e.g. historyWindow is still visible, when "close" is pressed
3681 actionViewToggleNoteEditor->setChecked (textEditor->isVisible());
3682 actionViewToggleHistoryWindow->setChecked (historyWindow->isVisible());
3683 actionViewTogglePropertyWindow->setChecked (branchPropertyWindow->isVisible());
3685 VymModel *m =currentModel();
3689 actionFilePrint->setEnabled (true);
3691 // Link style in context menu
3692 switch (m->getMapLinkStyle())
3694 case LinkableMapObj::Line:
3695 actionFormatLinkStyleLine->setChecked(true);
3697 case LinkableMapObj::Parabel:
3698 actionFormatLinkStyleParabel->setChecked(true);
3700 case LinkableMapObj::PolyLine:
3701 actionFormatLinkStylePolyLine->setChecked(true);
3703 case LinkableMapObj::PolyParabel:
3704 actionFormatLinkStylePolyParabel->setChecked(true);
3711 QPixmap pix( 16, 16 );
3712 pix.fill( m->getMapBackgroundColor() );
3713 actionFormatBackColor->setIconSet( pix );
3714 pix.fill( m->getSelectionColor() );
3715 actionFormatSelectionColor->setIconSet( pix );
3716 pix.fill( m->getMapDefLinkColor() );
3717 actionFormatLinkColor->setIconSet( pix );
3720 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName()));
3723 // Expanding/collapsing
3724 actionExpandAll->setEnabled (true);
3725 actionExpandOneLevel->setEnabled (true);
3726 actionCollapseOneLevel->setEnabled (true);
3730 actionFilePrint->setEnabled (false);
3732 // Expanding/collapsing
3733 actionExpandAll->setEnabled (false);
3734 actionExpandOneLevel->setEnabled (false);
3735 actionCollapseOneLevel->setEnabled (false);
3738 if (m && m->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3739 actionFormatLinkColorHint->setChecked(true);
3741 actionFormatLinkColorHint->setChecked(false);
3744 if (m && m->hasChanged() )
3745 actionFileSave->setEnabled( true);
3747 actionFileSave->setEnabled( false);
3748 if (m && m->isUndoAvailable())
3749 actionUndo->setEnabled( true);
3751 actionUndo->setEnabled( false);
3753 if (m && m->isRedoAvailable())
3754 actionRedo->setEnabled( true);
3756 actionRedo->setEnabled( false);
3760 TreeItem *selti=m->getSelectedItem();
3761 BranchItem *selbi=m->getSelectedBranch();
3764 if (selbi || selti->getType()==TreeItem::Image)
3766 actionFormatHideLinkUnselected->setChecked (((MapItem*)selti)->getHideLinkUnselected());
3767 actionFormatHideLinkUnselected->setEnabled (true);
3772 // Take care of xlinks
3773 branchXLinksContextMenuEdit->clear();
3774 if (selbi->xlinkCount()>0)
3778 for (int i=0; i<selbi->xlinkCount();++i)
3780 bi=selbi->getXLinkNum(i)->getPartnerBranch();
3784 if (s.length()>xLinkMenuWidth)
3785 s=s.left(xLinkMenuWidth)+"...";
3786 branchXLinksContextMenuEdit->addAction (s);
3791 standardFlagsMaster->updateToolBar (selbi->activeStandardFlagNames() );
3794 actionToggleScroll->setEnabled (true);
3795 if ( selbi->isScrolled() )
3796 actionToggleScroll->setChecked(true);
3798 actionToggleScroll->setChecked(false);
3800 if ( selti->getURL().isEmpty() )
3802 actionOpenURL->setEnabled (false);
3803 actionOpenURLTab->setEnabled (false);
3807 actionOpenURL->setEnabled (true);
3808 actionOpenURLTab->setEnabled (true);
3810 if ( selti->getVymLink().isEmpty() )
3812 actionOpenVymLink->setEnabled (false);
3813 actionDeleteVymLink->setEnabled (false);
3816 actionOpenVymLink->setEnabled (true);
3817 actionDeleteVymLink->setEnabled (true);
3820 if (selbi->canMoveUp())
3821 actionMoveUp->setEnabled (true);
3823 actionMoveUp->setEnabled (false);
3824 if (selbi->canMoveDown())
3825 actionMoveDown->setEnabled (true);
3827 actionMoveDown->setEnabled (false);
3829 actionSortChildren->setEnabled (true);
3830 actionSortBackChildren->setEnabled (true);
3832 actionToggleHideExport->setEnabled (true);
3833 actionToggleHideExport->setChecked (selbi->hideInExport() );
3835 actionCopy->setEnabled (true);
3836 actionCut->setEnabled (true);
3837 if (!clipboardEmpty)
3838 actionPaste->setEnabled (true);
3840 actionPaste->setEnabled (false);
3841 for (int i=0; i<actionListBranches.size(); ++i)
3842 actionListBranches.at(i)->setEnabled(true);
3843 actionDelete->setEnabled (true);
3845 if ( selti->getType()==TreeItem::Image)
3847 actionOpenURL->setEnabled (false);
3848 actionOpenVymLink->setEnabled (false);
3849 actionDeleteVymLink->setEnabled (false);
3850 actionToggleHideExport->setEnabled (true);
3851 actionToggleHideExport->setChecked (selti->hideInExport() );
3854 actionCopy->setEnabled (true);
3855 actionCut->setEnabled (true);
3856 actionPaste->setEnabled (false); //FIXME-4 why not allowing copy of images?
3857 for (int i=0; i<actionListBranches.size(); ++i)
3858 actionListBranches.at(i)->setEnabled(false);
3859 actionDelete->setEnabled (true);
3860 actionMoveUp->setEnabled (false);
3861 actionMoveDown->setEnabled (false);
3866 actionCopy->setEnabled (false);
3867 actionCut->setEnabled (false);
3868 actionPaste->setEnabled (false);
3869 for (int i=0; i<actionListBranches.size(); ++i)
3870 actionListBranches.at(i)->setEnabled(false);
3872 actionToggleScroll->setEnabled (false);
3873 actionOpenURL->setEnabled (false);
3874 actionOpenVymLink->setEnabled (false);
3875 actionDeleteVymLink->setEnabled (false);
3876 actionHeading2URL->setEnabled (false);
3877 actionDelete->setEnabled (false);
3878 actionMoveUp->setEnabled (false);
3879 actionMoveDown->setEnabled (false);
3880 actionFormatHideLinkUnselected->setEnabled (false);
3881 actionSortChildren->setEnabled (false);
3882 actionSortBackChildren->setEnabled (false);
3883 actionToggleHideExport->setEnabled (false);
3888 Main::ModMode Main::getModMode()
3890 if (actionModModeColor->isOn()) return ModModeColor;
3891 if (actionModModeCopy->isOn()) return ModModeCopy;
3892 if (actionModModeXLink->isOn()) return ModModeXLink;
3896 bool Main::autoEditNewBranch()
3898 return actionSettingsAutoEditNewBranch->isOn();
3901 bool Main::autoSelectNewBranch()
3903 return actionSettingsAutoSelectNewBranch->isOn();
3906 void Main::windowShowNoteEditor()
3908 textEditor->setShowWithMain(true);
3910 actionViewToggleNoteEditor->setChecked (true);
3913 void Main::windowHideNoteEditor()
3915 textEditor->setShowWithMain(false);
3917 actionViewToggleNoteEditor->setChecked (false);
3920 void Main::setScript (const QString &script)
3922 scriptEditor->setScript (script);
3925 void Main::runScript (const QString &script)
3927 VymModel *m=currentModel();
3928 if (m) m->runScript (script);
3931 void Main::runScriptEverywhere (const QString &script)
3934 for (int i=0;i<=tabWidget->count() -1;i++)
3936 me=(MapEditor*)tabWidget->page(i);
3937 if (me) me->getModel()->runScript (script);
3941 void Main::windowNextEditor()
3943 if (tabWidget->currentIndex() < tabWidget->count())
3944 tabWidget->setCurrentIndex (tabWidget->currentIndex() +1);
3947 void Main::windowPreviousEditor()
3949 if (tabWidget->currentIndex() >0)
3950 tabWidget->setCurrentIndex (tabWidget->currentIndex() -1);
3953 void Main::standardFlagChanged()
3957 if ( actionSettingsUseFlagGroups->isOn() )
3958 currentModel()->toggleStandardFlag(sender()->name(),standardFlagsMaster);
3960 currentModel()->toggleStandardFlag(sender()->name());
3966 void Main::testFunction1()
3969 #include "attributeitem.h"
3970 VymModel *m=currentModel();
3973 BranchItem *selbi=m->getSelectedBranch();
3976 QList<QVariant> cData;
3977 cData << "new ai" << "undef";
3979 AttributeItem *ai=new AttributeItem (cData,selbi);
3980 ai->set ("Key 1","Val a",AttributeItem::FreeString);
3982 m->addAttribute (ai);
3986 if (!currentMapEditor()) return;
3987 currentMapEditor()->testFunction1();
3990 void Main::testFunction2()
3992 if (!currentMapEditor()) return;
3993 currentMapEditor()->testFunction2();
3996 void Main::testCommand()
3998 if (!currentMapEditor()) return;
3999 scriptEditor->show();
4002 QString com = QInputDialog::getText(
4003 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
4004 if (ok) currentMapEditor()->parseAtom(com);
4008 void Main::helpDoc()
4010 QString locale = QLocale::system().name();
4012 if (locale.left(2)=="es")
4013 docname="vym_es.pdf";
4017 QStringList searchList;
4019 #if defined(Q_OS_MACX)
4020 searchList << "./vym.app/Contents/Resources/doc";
4021 #elif defined(Q_OS_WIN32)
4022 searchList << vymInstallDir.path() + "/share/doc/packages/vym";
4024 #if defined(VYM_DOCDIR)
4025 searchList << VYM_DOCDIR;
4027 // default path in SUSE LINUX
4028 searchList << "/usr/share/doc/packages/vym";
4031 searchList << "doc"; // relative path for easy testing in tarball
4032 searchList << "doc/tex"; // Easy testing working on vym.tex
4033 searchList << "/usr/share/doc/vym"; // Debian
4034 searchList << "/usr/share/doc/packages";// Knoppix
4038 for (int i=0; i<searchList.count(); ++i)
4040 docfile.setFileName(searchList.at(i)+"/"+docname);
4041 if (docfile.exists())
4050 QMessageBox::critical(0,
4051 tr("Critcal error"),
4052 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
4057 Process *pdfProc = new Process();
4058 args << QDir::toNativeSeparators(docfile.fileName());
4060 if (!pdfProc->startDetached( settings.value("/mainwindow/readerPDF").toString(),args) )
4063 QMessageBox::warning(0,
4065 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
4066 tr("Please use Settings->")+tr("Set application to open PDF files"));
4073 void Main::helpDemo()
4075 QStringList filters;
4076 filters <<"VYM example map (*.vym)";
4077 QFileDialog *fd=new QFileDialog( this);
4078 #if defined(Q_OS_MACX)
4079 fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
4081 // default path in SUSE LINUX
4082 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
4085 fd->setFileMode (QFileDialog::ExistingFiles);
4086 fd->setFilters (filters);
4087 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
4091 if ( fd->exec() == QDialog::Accepted )
4093 lastFileDir=fd->directory().path();
4094 QStringList flist = fd->selectedFiles();
4095 QStringList::Iterator it = flist.begin();
4096 while( it != flist.end() )
4099 fileLoad(*it, NewMap);
4107 void Main::helpAbout()
4110 ad.setName ("aboutwindow");
4111 ad.setMinimumSize(500,500);
4112 ad.resize (QSize (500,500));
4116 void Main::helpAboutQT()
4118 QMessageBox::aboutQt( this, "Qt Application Example" );
4121 void Main::callMacro ()
4123 QAction *action = qobject_cast<QAction *>(sender());
4127 i=action->data().toInt();
4128 QString mDir (settings.value ("macros/macroDir").toString() );
4130 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
4132 if ( !f.open( QIODevice::ReadOnly ) )
4134 QMessageBox::warning(0,
4136 tr("Couldn't find a macro at %1.\n").arg(fn)+
4137 tr("Please use Settings->")+tr("Set directory for vym macros"));
4141 QTextStream ts( &f );
4142 QString macro= ts.read();
4144 if (! macro.isEmpty())
4146 VymModel *m=currentModel();
4147 if (m) m->runScript(macro);