1 #include "mainwindow.h"
11 #include "adaptorvym.h"
14 #include <QColorDialog>
15 #include <QDockWidget>
16 #include <QFontDialog>
17 #include <QInputDialog>
21 #include <QTextStream>
23 #include "aboutdialog.h"
24 #include "branchpropeditor.h"
25 #include "branchitem.h"
27 #include "downloadagent.h"
28 #include "exportoofiledialog.h"
31 #include "findresultwidget.h"
32 #include "findresultmodel.h"
34 #include "headingeditor.h"
35 #include "historywindow.h"
37 #include "lineeditdialog.h"
39 #include "mapeditor.h"
42 #include "vymprocess.h"
43 #include "scripteditor.h"
45 #include "shortcuts.h"
46 #include "noteeditor.h"
48 #include "taskeditor.h"
49 #include "taskmodel.h"
50 #include "treeeditor.h"
52 #include "warningdialog.h"
53 #include "xlinkitem.h"
57 //#include <modeltest.h>
60 #include <QDBusConnection>
63 extern NoteEditor *noteEditor;
64 extern HeadingEditor *headingEditor;
65 extern ScriptEditor *scriptEditor;
66 extern Main *mainWindow;
67 extern FindResultWidget *findResultWidget;
68 extern TaskEditor *taskEditor;
69 extern TaskModel *taskModel;
71 extern QString tmpVymDir;
72 extern QString clipboardDir;
73 extern QString clipboardFile;
74 extern bool clipboardEmpty;
75 extern int statusbarTime;
76 extern FlagRow *standardFlagsMaster;
77 extern FlagRow *systemFlagsMaster;
78 extern QString vymName;
79 extern QString vymVersion;
80 extern QString vymPlatform;
81 extern QString vymBuildDate;
82 extern QString localeName;
85 extern QTextStream vout;
86 extern bool bugzillaClientAvailable;
87 extern Switchboard switchboard;
90 extern QList <Command*> modelCommands;
92 QMenu* branchAddContextMenu;
93 QMenu* branchContextMenu;
94 QMenu* branchLinksContextMenu;
95 QMenu* branchRemoveContextMenu;
96 QMenu* branchXLinksContextMenuEdit;
97 QMenu* branchXLinksContextMenuFollow;
98 QMenu* canvasContextMenu;
99 QMenu* floatimageContextMenu;
100 QMenu* targetsContextMenu;
101 QMenu* taskContextMenu;
102 QMenu* fileLastMapsMenu;
103 QMenu* fileImportMenu;
104 QMenu* fileExportMenu;
106 extern Settings settings;
107 extern Options options;
108 extern ImageIO imageIO;
110 extern QDir vymBaseDir;
111 extern QDir lastImageDir;
112 extern QDir lastMapDir;
113 #if defined(Q_OS_WIN32)
114 extern QDir vymInstallDir;
116 extern QString zipToolPath;
118 Main::Main(QWidget* parent, Qt::WindowFlags f) : QMainWindow(parent,f)
122 setWindowTitle ("VYM - View Your Mind");
124 shortcutScope = tr("Main window","Shortcut scope");
126 // Load window settings
127 #if defined(Q_OS_WIN32)
128 if (settings.value("/mainwindow/geometry/maximized", false).toBool())
130 setWindowState(Qt::WindowMaximized);
135 resize (settings.value("/mainwindow/geometry/size", QSize (1024,900)).toSize());
136 move (settings.value("/mainwindow/geometry/pos", QPoint(50,50)).toPoint());
139 // Sometimes we may need to remember old selections
143 currentColor=Qt::black;
145 // Create unique temporary directory
147 tmpVymDir=makeTmpDir (ok,"vym");
150 qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
153 if (debug) qDebug ()<<"tmpDir="<<tmpVymDir;
155 // Create direcctory for clipboard
156 clipboardDir=tmpVymDir+"/clipboard";
157 clipboardFile="map.xml";
158 QDir d(clipboardDir);
159 d.mkdir (clipboardDir);
160 makeSubDirs (clipboardDir);
163 // Remember PID of our friendly webbrowser
164 browserPID=new qint64;
167 // Define commands in API (used globally)
170 // Initialize some settings, which are platform dependant
173 // application to open URLs
174 p="/system/readerURL";
175 #if defined(Q_OS_WIN)
176 // Assume that system has been set up so that
177 // Explorer automagically opens up the URL
178 // in the user's preferred browser.
179 s=settings.value (p,"explorer").toString();
180 #elif defined(Q_OS_MACX)
181 s=settings.value (p,"/usr/bin/open").toString();
183 s=settings.value (p,"xdg-open").toString();
185 settings.setValue( p,s);
187 // application to open PDFs
188 p="/system/readerPDF";
189 #if defined(Q_OS_WIN)
190 s=settings.value (p,"explorer").toString();
191 #elif defined(Q_OS_MACX)
192 s=settings.value (p,"/usr/bin/open").toString();
194 s=settings.value (p,"xdg-open").toString();
196 settings.setValue( p,s);
198 // width of xLinksMenu
202 QWidget* centralWidget = new QWidget (this);
203 QVBoxLayout *layout=new QVBoxLayout (centralWidget);
204 setCentralWidget(centralWidget);
206 // Create tab widget which holds the maps
207 tabWidget= new QTabWidget (centralWidget);
208 connect(tabWidget, SIGNAL( currentChanged( int ) ),
209 this, SLOT( editorChanged( ) ) );
211 // Allow closing of tabs (introduced in Qt 4.5)
212 tabWidget->setTabsClosable( true );
213 connect(tabWidget, SIGNAL(tabCloseRequested(int)),
214 this, SLOT( fileCloseMap(int) ));
216 layout->addWidget (tabWidget);
218 switchboard.addGroup("MainWindow",tr("Main window","Shortcut group"));
219 switchboard.addGroup("MapEditor",tr("Map Editors","Shortcut group"));
220 switchboard.addGroup("TextEditor",tr("Text Editors","Shortcut group"));
225 setupSelectActions();
226 setupFormatActions();
229 setupNetworkActions();
230 setupSettingsActions();
236 // Dock widgets ///////////////////////////////////////////////
238 dw = new QDockWidget ();
239 dw->setWidget (noteEditor);
240 dw->setObjectName ("NoteEditor");
241 dw->setWindowTitle(noteEditor->getEditorTitle() );
244 addDockWidget (Qt::LeftDockWidgetArea,dw);
246 dw = new QDockWidget ();
247 dw->setWidget (headingEditor);
248 dw->setObjectName ("HeadingEditor");
249 dw->setWindowTitle(headingEditor->getEditorTitle() );
252 addDockWidget (Qt::BottomDockWidgetArea,dw);
254 dw = new QDockWidget (tr("Script Editor"));
255 dw->setWidget (scriptEditor);
256 dw->setObjectName ("ScriptEditor");
259 addDockWidget (Qt::LeftDockWidgetArea,dw);
261 findResultWidget=new FindResultWidget ();
262 dw= new QDockWidget (tr ("Search results list","FindResultWidget"));
263 dw->setWidget (findResultWidget);
264 dw->setObjectName ("FindResultWidget");
266 addDockWidget (Qt::RightDockWidgetArea,dw);
268 findResultWidget, SIGNAL (noteSelected (QString, int)),
269 this, SLOT (selectInNoteEditor (QString, int)));
271 findResultWidget, SIGNAL (findPressed (QString) ),
272 this, SLOT (editFindNext(QString) ) );
274 scriptEditor = new ScriptEditor(this);
275 dw= new QDockWidget (tr ("Script Editor","ScriptEditor"));
276 dw->setWidget (scriptEditor);
277 dw->setObjectName ("ScriptEditor");
279 addDockWidget (Qt::LeftDockWidgetArea,dw);
281 branchPropertyEditor = new BranchPropertyEditor();
282 dw = new QDockWidget (tr("Property Editor","PropertyEditor"));
283 dw->setWidget (branchPropertyEditor);
284 dw->setObjectName ("PropertyEditor");
286 addDockWidget (Qt::LeftDockWidgetArea,dw);
288 historyWindow=new HistoryWindow();
289 dw = new QDockWidget (tr("History window","HistoryWidget"));
290 dw->setWidget (historyWindow);
291 dw->setObjectName ("HistoryWidget");
293 addDockWidget (Qt::RightDockWidgetArea,dw);
294 connect (dw, SIGNAL (visibilityChanged(bool ) ), this, SLOT (updateActions()));
296 // Connect NoteEditor, so that we can update flags if text changes
297 connect (noteEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
298 connect (noteEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
300 // Connect heading editor
301 connect (headingEditor, SIGNAL (textHasChanged() ), this, SLOT (updateHeading()));
303 connect( scriptEditor, SIGNAL( runScript ( QString ) ), this, SLOT( execute( QString ) ) );
305 // Switch back to MapEditor using Esc
306 QAction* a = new QAction(this);
307 a->setShortcut (Qt::Key_Escape);
308 a->setShortcutContext (Qt::ApplicationShortcut);
309 a->setCheckable(false);
310 a->setEnabled (true);
312 connect (a , SIGNAL (triggered() ), this, SLOT (setFocusMapEditor()));
314 // Create TaskEditor after setting up above actions, allow cloning
315 taskEditor = new TaskEditor ();
316 dw= new QDockWidget (tr ("Task list","TaskEditor"));
317 dw->setWidget (taskEditor);
318 dw->setObjectName ("TaskEditor");
320 addDockWidget (Qt::TopDockWidgetArea,dw);
321 connect (dw, SIGNAL (visibilityChanged(bool ) ), this, SLOT (updateActions()));
322 //FIXME -0 connect (taskEditor, SIGNAL (focusReleased() ), this, SLOT (setFocusMapEditor()));
324 if (options.isOn("shortcutsLaTeX")) switchboard.printLaTeX();
326 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
329 // Status bar and progress bar there
333 progressCounterTotal=0;
335 progressDialog.setAutoReset(false);
336 progressDialog.setAutoClose(false);
337 progressDialog.setMinimumWidth (600);
338 //progressDialog.setWindowModality (Qt::WindowModal); // That forces mainwindo to update and slows down
339 progressDialog.setCancelButton (NULL);
341 restoreState (settings.value("/mainwindow/state",0).toByteArray());
344 printer=new QPrinter (QPrinter::HighResolution );
347 //settings.setValue( "mainwindow/showTestMenu", true);
350 #if defined(VYM_DBUS)
351 // Announce myself on DBUS
352 new AdaptorVym (this); // Created and not deleted as documented in Qt
353 if (!QDBusConnection::sessionBus().registerObject ("/vym",this))
354 qWarning ("MainWindow: Couldn't register DBUS object!");
361 // qDebug()<<"Destr Mainwindow"<<flush;
367 #if defined(Q_OS_WIN32)
368 settings.setValue ("/mainwindow/geometry/maximized", isMaximized());
370 settings.setValue ("/mainwindow/geometry/size", size());
371 settings.setValue ("/mainwindow/geometry/pos", pos());
372 settings.setValue ("/mainwindow/state",saveState(0));
374 settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isChecked());
375 settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isChecked());
376 settings.setValue( "/system/autosave/use",actionSettingsToggleAutosave->isChecked() );
377 settings.setValue ("/system/autosave/ms", settings.value("/system/autosave/ms",60000));
378 settings.setValue ("/mainwindow/autoLayout/use",actionSettingsToggleAutoLayout->isChecked() );
379 settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isChecked() );
380 settings.setValue( "/system/writeBackupFile",actionSettingsWriteBackupFile->isChecked() );
382 settings.setValue("/system/printerName",printer->printerName());
383 settings.setValue("/system/printerFormat",printer->outputFormat());
384 settings.setValue("/system/printerFileName",printer->outputFileName());
385 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isChecked() );
386 settings.setValue( "/mapeditor/editmode/autoEditNewBranch",actionSettingsAutoEditNewBranch->isChecked() );
387 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isChecked() );
388 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isChecked() );
389 settings.setValue( "/system/version", vymVersion );
390 settings.setValue( "/system/builddate", vymBuildDate );
393 // call the destructors
395 delete historyWindow;
396 delete branchPropertyEditor;
398 // Remove temporary directory
399 removeDir (QDir(tmpVymDir));
402 void Main::loadCmdLine()
404 QStringList flist=options.getFileList();
405 QStringList::Iterator it=flist.begin();
407 initProgressCounter (flist.count());
408 while (it !=flist.end() )
410 FileType type=getMapType (*it);
411 fileLoad (*it, NewMap,type);
414 removeProgressCounter();
418 void Main::statusMessage(const QString &s)
420 // Surpress messages while progressdialog during
422 statusBar()->showMessage( s,statusbarTime);
425 void Main::setProgressMaximum (int max) {
426 if (progressCounter==0)
428 // Init range only on first time, when progressCounter still 0
429 // Normalize range to 1000
430 progressDialog.setRange (0,1000);
431 progressDialog.setValue (1);
433 progressCounter++; // Another map is loaded
435 progressMax=max*1000;
436 QApplication::processEvents();
439 void Main::addProgressValue (float v)
442 int progress_value= (v + progressCounter -1)*1000/progressCounterTotal;
444 qDebug() << "addVal v="<<v
445 <<" cur="<<progressDialog.value()
446 <<" pCounter="<<progressCounter
447 <<" pCounterTotal="<<progressCounterTotal
448 <<" newv="<< progress_value
452 // Make sure the progress dialog shows, even if value == 0
453 if (progress_value < 1) progress_value = 1;
454 progressDialog.setValue ( progress_value );
455 if (progress_value == 1) QApplication::processEvents();
458 void Main::initProgressCounter(uint n)
460 progressCounterTotal=n;
463 void Main::removeProgressCounter()
467 progressCounterTotal=0;
468 progressDialog.reset();
469 progressDialog.hide();
472 void Main::closeEvent (QCloseEvent* event)
480 // Define commands for models
481 void Main::setupAPI()
483 Command *c = new Command ("addBranch",Command::Branch);
484 c->addPar (Command::Int, true, "Index of new branch");
485 modelCommands.append(c);
487 c=new Command ("addBranchBefore",Command::Branch);
488 modelCommands.append(c);
490 c=new Command ("addMapCenter",Command::Any);
491 c->addPar (Command::Double,false, "Position x");
492 c->addPar (Command::Double,false, "Position y");
493 modelCommands.append(c);
495 c=new Command ("addMapInsert",Command::Any);
496 c->addPar (Command::String,false, "Filename of map to load");
497 c->addPar (Command::Int,true, "Index where map is inserted");
498 c->addPar (Command::Int,true, "Content filter");
499 modelCommands.append(c);
501 c=new Command ("addMapReplace",Command::Branch);
502 c->addPar (Command::String,false, "Filename of map to load");
503 modelCommands.append(c);
505 c=new Command ("addSlide",Command::Branch);
506 modelCommands.append(c);
508 c=new Command ("addXLink",Command::BranchLike);
509 c->addPar (Command::String, false, "Begin of XLink");
510 c->addPar (Command::String, false, "End of XLink");
511 c->addPar (Command::Int, true, "Width of XLink");
512 c->addPar (Command::Color, true, "Color of XLink");
513 c->addPar (Command::String, true, "Penstyle of XLink");
514 modelCommands.append(c);
516 c=new Command ("branchCount",Command::Any);
517 modelCommands.append(c);
519 c=new Command ("centerCount",Command::BranchLike);
520 modelCommands.append(c);
522 c=new Command ("centerOnID",Command::Any);
523 c->addPar (Command::String,false, "UUID of object to center on");
524 modelCommands.append(c);
526 c=new Command ("clearFlags",Command::BranchLike);
527 modelCommands.append(c);
529 c=new Command ("colorBranch",Command::Branch);
530 c->addPar (Command::Color,true, "New color");
531 modelCommands.append(c);
533 c=new Command ("colorSubtree",Command::Branch);
534 c->addPar (Command::Color,true, "New color");
535 modelCommands.append(c);
537 c=new Command ("copy",Command::BranchOrImage);
538 modelCommands.append(c);
540 c=new Command ("cut",Command::BranchOrImage);
541 modelCommands.append(c);
543 c=new Command ("cycleTask",Command::BranchOrImage);
544 c->addPar (Command::Bool,true, "True, if cycling in reverse order");
545 modelCommands.append(c);
547 c=new Command ("delete",Command::TreeItem);
548 modelCommands.append(c);
550 c=new Command ("deleteChildren",Command::Branch);
551 modelCommands.append(c);
553 c=new Command ("deleteKeepChildren",Command::Branch);
554 modelCommands.append(c);
556 c=new Command ("deleteSlide",Command::Any);
557 c->addPar (Command::Int,false,"Index of slide to delete");
558 modelCommands.append(c);
560 c=new Command ("exportAO",Command::Any);
561 c->addPar (Command::String,false,"Filename for export");
562 modelCommands.append(c);
564 c=new Command ("exportASCII",Command::Any);
565 c->addPar (Command::String,false,"Filename for export");
566 c->addPar (Command::Bool,false,"Flag, if tasks should be appended");
567 modelCommands.append(c);
569 c=new Command ("exportCSV",Command::Any);
570 c->addPar (Command::String,false,"Filename for export");
571 modelCommands.append(c);
573 c=new Command ("exportHTML",Command::Any);
574 c->addPar (Command::String,false,"Path used for export");
575 c->addPar (Command::String,false,"Filename for export");
576 modelCommands.append(c);
578 c=new Command ("exportImage",Command::Any);
579 c->addPar (Command::String,false,"Filename for export");
580 c->addPar (Command::String,true,"Image format");
581 modelCommands.append(c);
583 c=new Command ("exportImpress",Command::Any);
584 c->addPar (Command::String,false,"Filename for export");
585 c->addPar (Command::String,false,"Configuration file for export");
586 modelCommands.append(c);
588 c=new Command ("exportLast",Command::Any);
589 modelCommands.append(c);
591 c=new Command ("exportLaTeX",Command::Any);
592 c->addPar (Command::String,false,"Filename for export");
593 modelCommands.append(c);
595 c=new Command ("exportOrgMode",Command::Any);
596 c->addPar (Command::String,false,"Filename for export");
597 modelCommands.append(c);
599 modelCommands.append(c);
601 c=new Command ("exportPDF",Command::Any);
602 c->addPar (Command::String,false,"Filename for export");
603 modelCommands.append(c);
605 c=new Command ("exportPDF",Command::Any);
606 c->addPar (Command::String,false,"Filename for export");
607 modelCommands.append(c);
609 c=new Command ("exportSVG",Command::Any);
610 c->addPar (Command::String,false,"Filename for export");
611 modelCommands.append(c);
613 c=new Command ("exportXML",Command::Any);
614 c->addPar (Command::String,false,"Path used for export");
615 c->addPar (Command::String,false,"Filename for export");
616 modelCommands.append(c);
618 c=new Command ("getDestPath",Command::Any);
619 modelCommands.append(c);
621 c=new Command ("getFileDir",Command::Any);
622 modelCommands.append(c);
624 c=new Command ("getFrameType",Command::Branch);
625 modelCommands.append(c);
627 c=new Command ("getHeadingPlainText",Command::TreeItem);
628 modelCommands.append(c);
630 c=new Command ("getHeadingXML",Command::TreeItem);
631 modelCommands.append(c);
633 c=new Command ("getMapAuthor",Command::Any);
634 modelCommands.append(c);
636 c=new Command ("getMapComment",Command::Any);
637 modelCommands.append(c);
639 c=new Command ("getMapTitle",Command::Any);
640 modelCommands.append(c);
642 c=new Command ("getNotePlainText",Command::TreeItem);
643 modelCommands.append(c);
645 c=new Command ("getNoteXML",Command::TreeItem);
646 modelCommands.append(c);
648 c=new Command ("getSelectString",Command::TreeItem);
649 modelCommands.append(c);
651 c=new Command ("getTaskSleepDays",Command::Branch);
652 modelCommands.append(c);
654 c=new Command ("getURL",Command::TreeItem);
655 modelCommands.append(c);
657 c=new Command ("getVymLink",Command::Branch);
658 modelCommands.append(c);
660 c=new Command ("getXLinkColor",Command::XLink);
661 modelCommands.append(c);
663 c=new Command ("getXLinkWidth",Command::XLink);
664 modelCommands.append(c);
666 c=new Command ("getXLinkPenStyle",Command::XLink);
667 modelCommands.append(c);
669 c=new Command ("getXLinkStyleBegin",Command::XLink);
670 modelCommands.append(c);
672 c=new Command ("getXLinkStyleEnd",Command::XLink);
673 modelCommands.append(c);
675 c=new Command ("hasActiveFlag",Command::TreeItem);
676 c->addPar (Command::String,false,"Name of flag");
677 modelCommands.append(c);
679 c=new Command ("hasNote",Command::Branch);
680 modelCommands.append(c);
682 c=new Command ("hasRichTextNote",Command::Branch);
683 modelCommands.append(c);
685 c=new Command ("hasTask",Command::Branch);
686 modelCommands.append(c);
688 c=new Command ("importDir",Command::Branch);
689 c->addPar (Command::String,false,"Directory name to import");
690 modelCommands.append(c);
692 c=new Command ("isScrolled",Command::Branch);
693 modelCommands.append(c);
695 c=new Command ("loadImage",Command::Branch);
696 c->addPar (Command::String,false,"Filename of image");
697 modelCommands.append(c);
699 c=new Command ("loadNote",Command::Branch);
700 c->addPar (Command::String,false,"Filename of note");
701 modelCommands.append(c);
703 c=new Command ("moveDown",Command::Branch);
704 modelCommands.append(c);
706 c=new Command ("moveUp",Command::Branch);
707 modelCommands.append(c);
709 c=new Command ("moveSlideDown",Command::Any);
710 modelCommands.append(c);
712 c=new Command ("moveSlideUp",Command::Any);
713 modelCommands.append(c);
715 c=new Command ("move",Command::BranchOrImage);
716 c->addPar (Command::Double,false,"Position x");
717 c->addPar (Command::Double,false,"Position y");
718 modelCommands.append(c);
720 c=new Command ("moveRel",Command::BranchOrImage);
721 c->addPar (Command::Double,false,"Position x");
722 c->addPar (Command::Double,false,"Position y");
723 modelCommands.append(c);
725 c=new Command ("nop",Command::Any);
726 modelCommands.append(c);
728 c=new Command ("note2URLs",Command::Branch);
729 modelCommands.append(c);
731 //internally required for undo/redo of changing VymText:
732 c=new Command ("parseVymText",Command::Branch);
733 c->addPar (Command::String,false,"parse XML of VymText, e.g for Heading or VymNote");
734 modelCommands.append(c);
736 c=new Command ("paste",Command::Branch);
737 modelCommands.append(c);
739 c=new Command ("redo",Command::Any);
740 modelCommands.append(c);
742 c=new Command ("relinkTo",Command::TreeItem); // FIXME different number of parameters for Image or Branch
743 c->addPar (Command::String,false,"Selection string of parent");
744 c->addPar (Command::Int,false,"Index position");
745 c->addPar (Command::Double,true,"Position x");
746 c->addPar (Command::Double,true,"Position y");
747 modelCommands.append(c);
749 c=new Command ("saveImage",Command::Image);
750 c->addPar (Command::String,false,"Filename of image to save");
751 c->addPar (Command::String,false,"Format of image to save");
752 modelCommands.append(c);
754 c=new Command ("saveNote",Command::Branch);
755 c->addPar (Command::String,false,"Filename of note to save");
756 modelCommands.append(c);
758 c=new Command ("scroll",Command::Branch);
759 modelCommands.append(c);
761 c=new Command ("select",Command::Any);
762 c->addPar (Command::String,false,"Selection string");
763 modelCommands.append(c);
765 c=new Command ("selectID",Command::Any);
766 c->addPar (Command::String,false,"Unique ID");
767 modelCommands.append(c);
769 c=new Command ("selectLastBranch",Command::Branch);
770 modelCommands.append(c);
772 c=new Command ("selectLastImage",Command::Branch);
773 modelCommands.append(c);
775 c=new Command ("selectLatestAdded",Command::Any);
776 modelCommands.append(c);
778 c=new Command ("selectParent",Command::Branch);
779 modelCommands.append(c);
781 c=new Command ("setFlag",Command::TreeItem);
782 c->addPar (Command::String,false,"Name of flag");
783 modelCommands.append(c);
785 c=new Command ("setTaskSleep",Command::Branch);
786 c->addPar (Command::String,false,"Days to sleep");
787 modelCommands.append(c);
789 c=new Command ("setFrameIncludeChildren",Command::BranchOrImage);
790 c->addPar (Command::Bool,false,"Include or don't include children in frame");
791 modelCommands.append(c);
793 c=new Command ("setFrameType",Command::BranchOrImage);
794 c->addPar (Command::String,false,"Type of frame");
795 modelCommands.append(c);
797 c=new Command ("setFramePenColor",Command::BranchOrImage);
798 c->addPar (Command::Color,false,"Color of frame border line");
799 modelCommands.append(c);
801 c=new Command ("setFrameBrushColor",Command::BranchOrImage);
802 c->addPar (Command::Color,false,"Color of frame background");
803 modelCommands.append(c);
805 c=new Command ("setFramePadding",Command::BranchOrImage);
806 c->addPar (Command::Int,false,"Padding around frame");
807 modelCommands.append(c);
809 c=new Command ("setFrameBorderWidth",Command::BranchOrImage);
810 c->addPar (Command::Int,false,"Width of frame borderline");
811 modelCommands.append(c);
813 c=new Command ("setHeadingPlainText",Command::TreeItem);
814 c->addPar (Command::String,false,"New heading");
815 modelCommands.append(c);
817 c=new Command ("setHideExport",Command::BranchOrImage);
818 c->addPar (Command::Bool,false,"Set if item should be visible in export");
819 modelCommands.append(c);
821 c=new Command ("setIncludeImagesHorizontally",Command::Branch);
822 c->addPar (Command::Bool,false,"Set if images should be included horizontally in parent branch");
823 modelCommands.append(c);
825 c=new Command ("setIncludeImagesVertically",Command::Branch);
826 c->addPar (Command::Bool,false,"Set if images should be included vertically in parent branch");
827 modelCommands.append(c);
829 c=new Command ("setHideLinksUnselected",Command::BranchOrImage);
830 c->addPar (Command::Bool,false,"Set if links of items should be visible for unselected items");
831 modelCommands.append(c);
833 c=new Command ("setMapAnimCurve",Command::Any);
834 c->addPar (Command::Int,false,"EasingCurve used in animation in MapEditor");
835 modelCommands.append(c);
837 c=new Command ("setMapAuthor",Command::Any);
838 c->addPar (Command::String,false,"");
839 modelCommands.append(c);
841 c=new Command ("setMapAnimDuration",Command::Any);
842 c->addPar (Command::Int,false,"Duration of animation in MapEditor in milliseconds");
843 modelCommands.append(c);
845 c=new Command ("setMapBackgroundColor",Command::Any);
846 c->addPar (Command::Color,false,"Color of map background");
847 modelCommands.append(c);
849 c=new Command ("setMapComment",Command::Any);
850 c->addPar (Command::String,false,"");
851 modelCommands.append(c);
853 c=new Command ("setMapTitle",Command::Any);
854 c->addPar (Command::String,false,"");
855 modelCommands.append(c);
857 c=new Command ("setMapDefLinkColor",Command::Any);
858 c->addPar (Command::Color,false,"Default color of links");
859 modelCommands.append(c);
861 c=new Command ("setMapLinkStyle",Command::Any);
862 c->addPar (Command::String,false,"Link style in map");
863 modelCommands.append(c);
865 c=new Command ("setMapRotation",Command::Any);
866 c->addPar (Command::Double,false,"Rotation of map");
867 modelCommands.append(c);
869 c=new Command ("setMapTitle",Command::Any);
870 c->addPar (Command::String,false,"");
871 modelCommands.append(c);
873 c=new Command ("setMapZoom",Command::Any);
874 c->addPar (Command::Double,false,"Zoomfactor of map");
875 modelCommands.append(c);
877 c=new Command ("setNotePlainText",Command::Branch);
878 c->addPar (Command::String,false,"Note of branch");
879 modelCommands.append(c);
881 c=new Command ("setScale",Command::Image);
882 c->addPar (Command::Double,false,"Scale image x");
883 c->addPar (Command::Double,false,"Scale image y");
884 modelCommands.append(c);
886 c=new Command ("setSelectionColor",Command::Any);
887 c->addPar (Command::Color,false,"Color of selection box");
888 modelCommands.append(c);
890 c=new Command ("setURL",Command::TreeItem);
891 c->addPar (Command::String,false,"URL of TreeItem");
892 modelCommands.append(c);
894 c=new Command ("setVymLink",Command::Branch);
895 c->addPar (Command::String,false,"Vymlink of branch");
896 modelCommands.append(c);
898 c=new Command ("setXLinkColor", Command::XLink);
899 c->addPar (Command::String,false,"Color of xlink");
900 modelCommands.append(c);
902 c=new Command ("setXLinkLineStyle", Command::XLink);
903 c->addPar (Command::String,false,"Style of xlink");
904 modelCommands.append(c);
906 c=new Command ("setXLinkStyleBegin", Command::XLink);
907 c->addPar (Command::String,false,"Style of xlink begin");
908 modelCommands.append(c);
910 c=new Command ("setXLinkStyleEnd", Command::XLink);
911 c->addPar (Command::String,false,"Style of xlink end");
912 modelCommands.append(c);
914 c=new Command ("setXLinkWidth", Command::XLink);
915 c->addPar (Command::Int,false,"Width of xlink");
916 modelCommands.append(c);
918 c=new Command ("sleep",Command::Any);
919 c->addPar (Command::Int,false,"Sleep (seconds)");
920 modelCommands.append(c);
922 c=new Command ("sortChildren",Command::Branch);
923 c->addPar (Command::Bool,true,"Sort children of branch in revers order if set");
924 modelCommands.append(c);
926 c=new Command ("toggleFlag",Command::Branch);
927 c->addPar (Command::String,false,"Name of flag to toggle");
928 modelCommands.append(c);
930 c=new Command ("toggleFrameIncludeChildren",Command::Branch);
931 modelCommands.append(c);
933 c=new Command ("toggleScroll",Command::Branch);
934 modelCommands.append(c);
936 c=new Command ("toggleTarget",Command::Branch);
937 modelCommands.append(c);
939 c=new Command ("toggleTask",Command::Branch);
940 modelCommands.append(c);
942 c=new Command ("undo",Command::Any);
943 modelCommands.append(c);
945 c=new Command ("unscroll",Command::Branch);
946 modelCommands.append(c);
948 c=new Command ("unscrollChildren",Command::Branch);
949 modelCommands.append(c);
951 c=new Command ("unselectAll",Command::Any);
952 modelCommands.append(c);
954 c=new Command ("unsetFlag",Command::Branch);
955 c->addPar (Command::String,false,"Name of flag to unset");
956 modelCommands.append(c);
959 void Main::cloneActionMapEditor( QAction *a, QKeySequence ks)
961 a->setShortcut ( ks );
962 a->setShortcutContext ( Qt::WidgetShortcut );
963 mapEditorActions.append ( a );
967 void Main::setupFileActions()
969 QString tag = tr ("&Map","Menu for file actions");
970 QMenu *fileMenu = menuBar()->addMenu ( tag );
973 a = new QAction(QPixmap( ":/filenew.png"), tr( "&New map","File menu" ),this);
974 switchboard.addSwitch ("fileMapNew", shortcutScope, a, tag);
975 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
976 cloneActionMapEditor( a, Qt::CTRL + Qt::Key_N);
977 fileMenu->addAction(a);
980 a = new QAction(QPixmap( ":/filenewcopy.png"), tr( "&Copy to new map","File menu" ),this);
981 switchboard.addSwitch ("fileMapNewCopy", shortcutScope, a, tag);
982 connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) );
983 cloneActionMapEditor( a, Qt::CTRL + Qt::SHIFT + Qt::Key_C);
984 fileMenu->addAction(a);
987 a = new QAction( QPixmap( ":/fileopen.png"), tr( "&Open..." ,"File menu"),this);
988 switchboard.addSwitch ("fileMapOpen", shortcutScope, a, tag);
989 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
990 cloneActionMapEditor( a, Qt::CTRL + Qt::Key_L);
991 fileMenu->addAction(a);
994 a = new QAction(tr( "&Restore last session","Edit menu" ), this);
995 a->setShortcut (Qt::ALT + Qt::Key_R );
996 switchboard.addSwitch ("fileMapRestore", shortcutScope, a, tag);
997 connect( a, SIGNAL( triggered() ), this, SLOT( fileRestoreSession() ) );
998 fileMenu->addAction(a);
999 actionListFiles.append(a);
1002 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
1003 fileMenu->addSeparator();
1005 a = new QAction( QPixmap( ":/filesave.png"), tr( "&Save...","File menu" ), this);
1006 switchboard.addSwitch ("fileMapSave", shortcutScope, a, tag);
1007 cloneActionMapEditor( a, Qt::CTRL + Qt::Key_S);
1008 fileMenu->addAction(a);
1009 restrictedMapActions.append( a );
1010 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
1013 a = new QAction( QPixmap(":/filesaveas.png"), tr( "Save &As...","File menu" ), this);
1014 fileMenu->addAction(a);
1015 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
1017 fileMenu->addSeparator();
1019 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
1021 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
1023 a = new QAction( QPixmap(), tr("Firefox Bookmarks","Import filters"),this);
1024 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
1025 fileImportMenu->addAction(a);
1028 a = new QAction("Freemind...",this);
1029 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFreemind() ) );
1030 fileImportMenu->addAction(a);
1032 a = new QAction("Mind Manager...",this);
1033 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
1034 fileImportMenu->addAction(a);
1036 a = new QAction( tr( "Import Dir%1","Import Filters").arg("..." + tr("(still experimental)") ), this);
1037 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
1038 fileImportMenu->addAction(a);
1040 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
1042 a = new QAction( QPixmap(":/file-document-export.png"),tr("Repeat last export (%1)").arg("-"), this);
1043 switchboard.addSwitch ("fileExportLast", shortcutScope, a, tag);
1044 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLast() ) );
1045 cloneActionMapEditor( a, Qt::ALT + Qt::Key_E );
1046 fileExportMenu->addAction(a);
1047 actionFileExportLast=a;
1049 a = new QAction( tr("Webpage (HTML)...","File export menu"),this );
1050 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportHTML() ) );
1051 fileExportMenu->addAction(a);
1053 a = new QAction( tr("Text (ASCII)...","File export menu"), this);
1054 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
1055 fileExportMenu->addAction(a);
1057 a = new QAction( tr("Text with tasks","File export menu") + " (ASCII)... " + tr("(still experimental)"), this);
1058 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCIITasks() ) );
1059 fileExportMenu->addAction(a);
1061 a = new QAction( tr("Text (A&O report)...","Export format"), this);
1062 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportAO() ) );
1063 fileExportMenu->addAction(a);
1065 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
1066 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
1067 fileExportMenu->addAction(a);
1069 a = new QAction( tr("PDF%1","File export menu").arg("..."), this);
1070 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportPDF() ) );
1071 fileExportMenu->addAction(a);
1073 a = new QAction( tr("SVG%1","File export menu").arg("..."), this);
1074 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportSVG() ) );
1075 fileExportMenu->addAction(a);
1077 a = new QAction( "LibreOffice...", this);
1078 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImpress() ) );
1079 fileExportMenu->addAction(a);
1081 a = new QAction( "XML..." , this );
1082 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
1083 fileExportMenu->addAction(a);
1085 a = new QAction( tr("Spreadsheet") + " (CSV)... " + tr("(still experimental)"), this);
1086 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
1087 fileExportMenu->addAction(a);
1089 a = new QAction( "Taskjuggler... " + tr("(still experimental)"), this );
1090 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
1091 fileExportMenu->addAction(a);
1093 a = new QAction( "OrgMode... " + tr("(still experimental)"), this);
1094 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOrgMode() ) );
1095 fileExportMenu->addAction(a);
1097 a = new QAction( "LaTeX... " + tr("(still experimental)"), this);
1098 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
1099 fileExportMenu->addAction(a);
1101 fileMenu->addSeparator();
1103 a = new QAction( tr( "Properties"), this);
1104 switchboard.addSwitch ("editMapProperties", shortcutScope, a, tag);
1105 connect( a, SIGNAL( triggered() ), this, SLOT( editMapProperties() ) );
1106 fileMenu->addAction(a);
1107 actionListFiles.append (a);
1108 actionMapProperties = a;
1110 fileMenu->addSeparator();
1112 a = new QAction(QPixmap( ":/fileprint.png"), tr( "&Print")+QString("..."), this);
1113 a->setShortcut ( Qt::CTRL + Qt::Key_P);
1114 switchboard.addSwitch ("fileMapPrint", shortcutScope, a, tag);
1115 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
1116 fileMenu->addAction(a);
1117 unrestrictedMapActions.append (a);
1120 a = new QAction( QPixmap(":/fileclose.png"), tr( "&Close Map","File menu" ), this);
1121 a->setShortcut (Qt::CTRL + Qt::Key_W );
1122 switchboard.addSwitch ("fileMapClose", shortcutScope, a, tag);
1123 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
1124 fileMenu->addAction(a);
1126 a = new QAction(QPixmap(":/exit.png"), tr( "E&xit","File menu"), this);
1127 a->setShortcut (Qt::CTRL + Qt::Key_Q );
1128 switchboard.addSwitch ("fileExit", shortcutScope, a, tag);
1129 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
1130 fileMenu->addAction(a);
1135 void Main::setupEditActions()
1137 QString tag = tr("E&dit","Edit menu") ;
1138 QMenu *editMenu = menuBar()->addMenu( tag );
1141 a = new QAction( QPixmap( ":/undo.png"), tr( "&Undo","Edit menu" ),this);
1142 a->setShortcut (Qt::CTRL + Qt::Key_Z);
1143 a->setShortcutContext (Qt::WidgetShortcut);
1144 a->setEnabled (false);
1145 editMenu->addAction(a);
1146 mapEditorActions.append( a );
1147 restrictedMapActions.append( a );
1148 switchboard.addSwitch ("mapUndo", shortcutScope, a, tag);
1149 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
1152 a = new QAction( QPixmap( ":/redo.png"), tr( "&Redo","Edit menu" ), this);
1153 a->setShortcut (Qt::CTRL + Qt::Key_Y);
1154 a->setShortcutContext (Qt::WidgetShortcut);
1155 editMenu->addAction(a);
1156 restrictedMapActions.append( a );
1157 mapEditorActions.append( a );
1158 switchboard.addSwitch ("mapRedo", shortcutScope, a, tag);
1159 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
1162 editMenu->addSeparator();
1163 a = new QAction(QPixmap( ":/editcopy.png"), tr( "&Copy","Edit menu" ), this);
1164 a->setShortcut (Qt::CTRL + Qt::Key_C );
1165 a->setShortcutContext (Qt::WidgetShortcut);
1166 a->setEnabled (false);
1167 editMenu->addAction(a);
1168 unrestrictedMapActions.append ( a );
1169 mapEditorActions.append( a );
1170 switchboard.addSwitch ("mapCopy", shortcutScope, a, tag);
1171 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
1174 a = new QAction(QPixmap( ":/editcut.png" ), tr( "Cu&t","Edit menu" ), this);
1175 a->setShortcut (Qt::CTRL + Qt::Key_X );
1176 a->setEnabled (false);
1177 a->setShortcutContext (Qt::WidgetShortcut);
1178 editMenu->addAction(a);
1179 restrictedMapActions.append( a );
1180 mapEditorActions.append( a );
1181 restrictedMapActions.append( a );
1182 switchboard.addSwitch ("mapCut", shortcutScope, a, tag);
1183 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
1187 a = new QAction(QPixmap( ":/editpaste.png"), tr( "&Paste","Edit menu" ),this);
1188 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
1189 a->setShortcut (Qt::CTRL + Qt::Key_V );
1190 a->setShortcutContext (Qt::WidgetShortcut);
1191 a->setEnabled (false);
1192 editMenu->addAction(a);
1193 restrictedMapActions.append( a );
1194 mapEditorActions.append( a );
1195 switchboard.addSwitch ("mapPaste", shortcutScope, a, tag);
1198 // Shortcut to delete selection
1199 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
1200 a->setShortcut ( Qt::Key_Delete);
1201 a->setShortcutContext (Qt::WindowShortcut);
1202 switchboard.addSwitch ("mapDelete", shortcutScope, a, tag);
1204 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
1205 editMenu->addAction(a);
1206 actionListItems.append (a);
1209 // Shortcut to add attribute
1210 a= new QAction(tr( "Add attribute" ), this);
1211 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1213 //a->setShortcut ( Qt::Key_Q);
1214 a->setShortcutContext (Qt::WindowShortcut);
1215 switchboard.addSwitch ("mapAddAttribute", shortcutScope, a, tag);
1217 connect( a, SIGNAL( triggered() ), this, SLOT( editAddAttribute() ) );
1218 editMenu->addAction(a);
1219 actionAddAttribute= a;
1222 // Shortcut to add mapcenter
1223 a= new QAction(QPixmap(":/newmapcenter.png"),tr( "Add mapcenter","Canvas context menu" ), this);
1224 a->setShortcut ( Qt::Key_C);
1225 a->setShortcutContext (Qt::WindowShortcut);
1226 switchboard.addSwitch ("mapAddCenter", shortcutScope, a, tag);
1227 connect( a, SIGNAL( triggered() ), this, SLOT( editAddMapCenter() ) );
1228 editMenu->addAction(a);
1229 actionListFiles.append (a);
1230 actionAddMapCenter = a;
1233 // Shortcut to add branch
1234 a = new QAction(QPixmap(":/newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
1235 switchboard.addSwitch ("mapEditNewBranch", shortcutScope, a, tag);
1236 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
1237 cloneActionMapEditor( a, Qt::Key_A );
1238 taskEditorActions.append( a );
1239 actionListBranches.append(a);
1243 // Add branch by inserting it at selection
1244 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
1245 a->setShortcut ( Qt::ALT + Qt::Key_A );
1246 a->setShortcutContext (Qt::WindowShortcut);
1247 switchboard.addSwitch ("mapEditAddBranchBefore", shortcutScope, a, tag);
1248 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
1249 editMenu->addAction(a);
1250 actionListBranches.append(a);
1251 actionAddBranchBefore=a;
1254 a = new QAction(tr( "Add branch above","Edit menu" ), this);
1255 a->setShortcut (Qt::SHIFT+Qt::Key_Insert );
1256 a->setShortcutContext (Qt::WindowShortcut);
1257 switchboard.addSwitch ("mapEditAddBranchAbove", shortcutScope, a, tag);
1259 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
1260 a->setEnabled (false);
1261 actionListBranches.append(a);
1262 actionAddBranchAbove=a;
1264 a = new QAction(tr( "Add branch above","Edit menu" ), this);
1265 a->setShortcut (Qt::SHIFT+Qt::Key_A );
1266 a->setShortcutContext (Qt::WindowShortcut);
1267 switchboard.addSwitch ("mapEditAddBranchAboveAlt", shortcutScope, a, tag);
1269 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
1270 actionListBranches.append(a);
1271 editMenu->addAction(a);
1274 a = new QAction(tr( "Add branch below","Edit menu" ), this);
1275 a->setShortcut (Qt::CTRL +Qt::Key_Insert );
1276 a->setShortcutContext (Qt::WindowShortcut);
1277 switchboard.addSwitch ("mapEditAddBranchBelow", shortcutScope, a, tag);
1279 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
1280 a->setEnabled (false);
1281 actionListBranches.append(a);
1283 a = new QAction(tr( "Add branch below","Edit menu" ), this);
1284 a->setShortcut (Qt::CTRL +Qt::Key_A );
1285 a->setShortcutContext (Qt::WindowShortcut);
1286 switchboard.addSwitch ("mapEditAddBranchBelowAlt", shortcutScope, a, tag);
1288 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
1289 actionListBranches.append(a);
1290 actionAddBranchBelow=a;
1292 a = new QAction(QPixmap(":/up.png" ), tr( "Move branch up","Edit menu" ), this);
1293 a->setShortcut (Qt::Key_PageUp );
1294 a->setShortcutContext (Qt::WidgetShortcut);
1295 //a->setEnabled (false);
1296 mapEditorActions.append( a );
1297 taskEditorActions.append( a );
1298 restrictedMapActions.append( a );
1299 actionListBranches.append (a);
1300 editMenu->addAction(a);
1301 switchboard.addSwitch ("mapEditMoveBranchUp", shortcutScope, a, tag);
1302 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
1305 a = new QAction( QPixmap( ":/down.png"), tr( "Move branch down","Edit menu" ),this);
1306 a->setShortcut ( Qt::Key_PageDown );
1307 a->setShortcutContext (Qt::WidgetShortcut);
1308 //a->setEnabled (false);
1309 mapEditorActions.append( a );
1310 taskEditorActions.append( a );
1311 restrictedMapActions.append( a );
1312 actionListBranches.append (a);
1313 editMenu->addAction(a);
1314 switchboard.addSwitch ("mapEditMoveBranchDown", shortcutScope, a, tag);
1315 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
1318 a = new QAction(QPixmap(), tr( "&Detach","Context menu" ),this);
1319 a->setStatusTip ( tr( "Detach branch and use as mapcenter","Context menu" ) );
1320 a->setShortcut ( Qt::Key_D );
1321 switchboard.addSwitch ("mapDetachBranch", shortcutScope, a, tag);
1322 connect( a, SIGNAL( triggered() ), this, SLOT( editDetach() ) );
1323 editMenu->addAction(a);
1324 actionListBranches.append (a);
1327 a = new QAction( QPixmap(":/editsort.png" ), tr( "Sort children","Edit menu" ), this );
1328 a->setEnabled (true);
1329 a->setShortcut ( Qt::Key_O );
1330 switchboard.addSwitch ("mapSortBranches", shortcutScope, a, tag);
1331 connect( a, SIGNAL( triggered() ), this, SLOT( editSortChildren() ) );
1332 editMenu->addAction(a);
1333 actionListBranches.append (a);
1334 actionSortChildren=a;
1336 a = new QAction( QPixmap(":/editsortback.png" ), tr( "Sort children backwards","Edit menu" ), this );
1337 a->setEnabled (true);
1338 a->setShortcut ( Qt::SHIFT + Qt::Key_O );
1339 switchboard.addSwitch ("mapSortBranchesReverse", shortcutScope, a, tag);
1340 connect( a, SIGNAL( triggered() ), this, SLOT( editSortBackChildren() ) );
1341 editMenu->addAction(a);
1342 actionListBranches.append (a);
1343 actionSortBackChildren=a;
1345 a = new QAction( QPixmap(":/flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
1346 a->setShortcut ( Qt::Key_S );
1347 switchboard.addSwitch ("mapToggleScroll", shortcutScope, a, tag);
1348 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
1349 editMenu->addAction(a);
1350 actionListBranches.append (a);
1351 a->setEnabled (false);
1352 a->setCheckable(true);
1354 actionListBranches.append(a);
1355 actionToggleScroll=a;
1357 a = new QAction( tr( "Unscroll children","Edit menu" ), this);
1358 editMenu->addAction(a);
1359 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChildren() ) );
1360 actionListBranches.append (a);
1362 a = new QAction( tr( "Grow selection","Edit menu" ), this);
1363 a->setShortcut ( Qt::CTRL + Qt::Key_Plus);
1364 switchboard.addSwitch ("mapGrowSelection", shortcutScope, a, tag);
1365 connect( a, SIGNAL( triggered() ), this, SLOT( editGrowSelectionSize() ) );
1366 editMenu->addAction(a);
1367 actionListBranches.append (a);
1368 actionListItems.append (a);
1369 actionGrowSelectionSize=a;
1371 a = new QAction( tr( "Shrink selection","Edit menu" ), this);
1372 a->setShortcut ( Qt::CTRL + Qt::Key_Minus);
1373 switchboard.addSwitch ("mapShrinkSelection", shortcutScope, a, tag);
1374 connect( a, SIGNAL( triggered() ), this, SLOT( editShrinkSelectionSize() ) );
1375 editMenu->addAction(a);
1376 actionListBranches.append (a);
1377 actionListItems.append (a);
1378 actionShrinkSelectionSize=a;
1380 a = new QAction( tr( "Reset selection size","Edit menu" ), this);
1381 a->setShortcut ( Qt::CTRL + Qt::Key_0);
1382 switchboard.addSwitch ("mapResetSelectionSize", shortcutScope, a, tag);
1383 connect( a, SIGNAL( triggered() ), this, SLOT( editResetSelectionSize() ) );
1384 editMenu->addAction(a);
1385 actionListBranches.append (a);
1386 actionListItems.append (a);
1387 actionResetSelectionSize=a;
1389 editMenu->addSeparator();
1391 a = new QAction( QPixmap(), "TE: " + tr( "Collapse one level","Edit menu" ), this);
1392 a->setShortcut ( Qt::Key_Less + Qt::CTRL);
1393 switchboard.addSwitch ("mapCollapseOneLevel", shortcutScope, a, tag);
1394 connect( a, SIGNAL( triggered() ), this, SLOT( editCollapseOneLevel() ) );
1395 editMenu->addAction(a);
1396 a->setEnabled (false);
1397 a->setCheckable(false);
1398 actionListBranches.append(a);
1400 actionCollapseOneLevel=a;
1402 a = new QAction( QPixmap(), "TE: " + tr( "Collapse unselected levels","Edit menu" ), this);
1403 a->setShortcut ( Qt::Key_Less);
1404 switchboard.addSwitch ("mapCollapseUnselectedLevels", shortcutScope, a, tag);
1405 connect( a, SIGNAL( triggered() ), this, SLOT( editCollapseUnselected() ) );
1406 editMenu->addAction(a);
1407 a->setEnabled (false);
1408 a->setCheckable(false);
1409 actionListBranches.append(a);
1411 actionCollapseUnselected=a;
1413 a = new QAction( QPixmap(), tr( "Expand all branches","Edit menu" ), this);
1414 connect( a, SIGNAL( triggered() ), this, SLOT( editExpandAll() ) );
1416 actionExpandAll->setEnabled (false);
1417 actionExpandAll->setCheckable(false);
1418 actionListBranches.append(actionExpandAll);
1421 a = new QAction( QPixmap(), tr( "Expand one level","Edit menu" ), this);
1422 a->setShortcut ( Qt::Key_Greater );
1423 switchboard.addSwitch ("mapExpandOneLevel", shortcutScope, a, tag);
1424 connect( a, SIGNAL( triggered() ), this, SLOT( editExpandOneLevel() ) );
1425 a->setEnabled (false);
1426 a->setCheckable(false);
1428 actionListBranches.append(a);
1429 actionExpandOneLevel=a;
1431 tag = tr("References Context menu","Shortcuts");
1432 a = new QAction( QPixmap(":/flag-url.png"), tr( "Open URL","Edit menu" ), this);
1433 a->setShortcut (Qt::SHIFT + Qt::Key_U );
1434 switchboard.addSwitch ("mapOpenUrl", shortcutScope, a, tag);
1436 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
1437 actionListBranches.append (a);
1440 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
1441 //a->setShortcut (Qt::CTRL+Qt::Key_U );
1442 switchboard.addSwitch ("mapOpenUrlTab", shortcutScope, a, tag);
1444 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
1445 actionListBranches.append (a);
1448 a = new QAction( tr( "Open all URLs in subtree (including scrolled branches)","Edit menu" ), this);
1449 a->setShortcut ( Qt::CTRL + Qt::Key_U );
1450 switchboard.addSwitch ("mapOpenUrlsSubTree", shortcutScope, a, tag);
1452 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVisURLTabs() ) );
1453 actionListBranches.append(a);
1454 actionOpenMultipleVisURLTabs=a;
1456 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
1457 switchboard.addSwitch ("mapOpenMultipleUrlTabs", shortcutScope, a, tag);
1459 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
1460 actionListBranches.append(a);
1461 actionOpenMultipleURLTabs=a;
1463 a = new QAction(QPixmap(), tr( "Extract URLs from note","Edit menu"), this);
1464 a->setShortcut ( Qt::SHIFT + Qt::Key_N );
1465 a->setShortcutContext (Qt::WindowShortcut);
1466 switchboard.addSwitch ("mapUrlsFromNote", shortcutScope, a, tag);
1468 connect( a, SIGNAL( triggered() ), this, SLOT( editNote2URLs() ) );
1469 actionListBranches.append(a);
1470 actionGetURLsFromNote=a;
1472 a = new QAction(QPixmap(":/flag-urlnew.png"), tr( "Edit URL...","Edit menu"), this);
1473 a->setShortcut ( Qt::Key_U );
1474 a->setShortcutContext (Qt::WindowShortcut);
1475 switchboard.addSwitch ("mapEditURL", shortcutScope, a, tag);
1477 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
1478 actionListBranches.append(a);
1481 a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
1482 //a->setShortcut (Qt::SHIFT + Qt::Key_U );
1483 a->setShortcutContext (Qt::WindowShortcut);
1484 switchboard.addSwitch ("mapEditLocalURL", shortcutScope, a, tag);
1486 connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
1487 actionListBranches.append(a);
1490 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
1491 a->setShortcut ( Qt::ALT + Qt::Key_U );
1492 a->setShortcutContext (Qt::ApplicationShortcut);
1493 a->setEnabled (false);
1494 switchboard.addSwitch ("mapHeading2URL", shortcutScope, a, tag);
1496 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
1497 actionListBranches.append(a);
1498 actionHeading2URL=a;
1500 tag = tr("Bugzilla handling","Shortcuts");
1501 a = new QAction(tr( "Create URL to SUSE Bugzilla","Edit menu" ), this);
1502 a->setEnabled (false);
1503 actionListBranches.append(a);
1504 a->setShortcut ( Qt::Key_B );
1505 a->setShortcutContext (Qt::WindowShortcut);
1506 switchboard.addSwitch ("mapUseHeadingForURL", shortcutScope, a, tag);
1508 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
1509 actionListBranches.append(a);
1510 actionBugzilla2URL=a;
1512 a = new QAction(tr( "Get data from SUSE Bugzilla","Edit menu" ), this);
1513 a->setShortcut ( Qt::Key_B + Qt::SHIFT);
1514 a->setShortcutContext (Qt::WindowShortcut);
1515 switchboard.addSwitch ("mapUpdateFromBugzilla", shortcutScope, a, tag);
1517 connect( a, SIGNAL( triggered() ), this, SLOT( getBugzillaData() ) );
1518 actionListBranches.append(a);
1519 actionGetBugzillaData=a;
1521 a = new QAction(tr( "Get data from SUSE Bugzilla for subtree","Edit menu" ), this);
1522 a->setShortcut ( Qt::Key_B + Qt::CTRL);
1523 a->setShortcutContext (Qt::WindowShortcut);
1524 switchboard.addSwitch ("mapUpdateSubTreeFromBugzilla", shortcutScope, a, tag);
1526 connect( a, SIGNAL( triggered() ), this, SLOT( getBugzillaDataSubtree() ) );
1527 actionListBranches.append(a);
1528 actionGetBugzillaDataSubtree=a;
1530 tag = tr("SUSE Fate tool handling","Shortcuts");
1531 a = new QAction(tr( "Create URL to SUSE FATE tool","Edit menu" ), this);
1532 a->setEnabled (false);
1533 switchboard.addSwitch ("mapFate2URL", shortcutScope, a, tag);
1534 actionListBranches.append(a);
1535 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
1536 actionListBranches.append(a);
1539 tag = tr("vymlinks - linking maps","Shortcuts");
1540 a = new QAction(QPixmap(":/flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
1541 a->setEnabled (false);
1542 switchboard.addSwitch ("mapOpenVymLink", shortcutScope, a, tag);
1543 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
1544 actionListBranches.append (a);
1545 actionOpenVymLink=a;
1547 a = new QAction(QPixmap(":/flag-vymlink.png"), tr( "Open linked map in background tab","Edit menu" ), this);
1548 a->setEnabled (false);
1549 switchboard.addSwitch ("mapOpenVymLink", shortcutScope, a, tag);
1550 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLinkBackground() ) );
1551 actionListBranches.append (a);
1552 actionOpenVymLinkBackground=a;
1554 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
1555 a->setEnabled (false);
1556 switchboard.addSwitch ("mapOpenMultipleVymLinks", shortcutScope, a, tag);
1557 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
1558 actionListBranches.append(a);
1559 actionOpenMultipleVymLinks=a;
1562 a = new QAction(QPixmap(":/flag-vymlinknew.png"), tr( "Edit vym link...","Edit menu" ), this);
1563 a->setEnabled (false);
1564 switchboard.addSwitch ("mapEditVymLink", shortcutScope, a, tag);
1565 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
1566 actionListBranches.append(a);
1567 actionEditVymLink=a;
1569 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
1570 a->setEnabled (false);
1571 switchboard.addSwitch ("mapDeleteVymLink", shortcutScope, a, tag);
1572 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
1573 actionListBranches.append(a);
1574 actionDeleteVymLink=a;
1576 tag = tr("Exports","Shortcuts");
1577 a = new QAction(QPixmap(":/flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
1578 a->setShortcut (Qt::Key_H );
1579 a->setShortcutContext (Qt::WindowShortcut);
1580 a->setCheckable(true);
1581 a->setEnabled (false);
1583 switchboard.addSwitch ("mapToggleHideExport", shortcutScope, a, tag);
1584 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
1585 actionListItems.append (a);
1586 actionToggleHideExport=a;
1588 tag = tr("Tasks","Shortcuts");
1589 a = new QAction(QPixmap(":/flag-task.png"), tr( "Toggle task","Edit menu" ), this);
1590 a->setShortcut (Qt::Key_W + Qt::SHIFT);
1591 a->setShortcutContext (Qt::WindowShortcut);
1592 a->setCheckable(true);
1593 a->setEnabled (false);
1595 switchboard.addSwitch ("mapToggleTask", shortcutScope, a, tag);
1596 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleTask() ) );
1597 actionListBranches.append (a);
1600 a = new QAction(QPixmap(), tr( "Cycle task status","Edit menu" ), this);
1601 a->setShortcut (Qt::Key_W );
1602 a->setShortcutContext (Qt::WindowShortcut);
1603 a->setCheckable(false);
1604 a->setEnabled (false);
1606 switchboard.addSwitch ("mapCycleTaskStatus", shortcutScope, a, tag);
1607 connect( a, SIGNAL( triggered() ), this, SLOT( editCycleTaskStatus() ) );
1608 actionListBranches.append (a);
1609 actionCycleTaskStatus=a;
1611 a = new QAction(QPixmap(), tr( "Reset sleep","Task sleep" ), this);
1612 a->setShortcutContext (Qt::WindowShortcut);
1613 a->setCheckable(false);
1614 a->setEnabled (false);
1617 switchboard.addSwitch ("mapResetSleep", shortcutScope, a, tag);
1618 connect( a, SIGNAL( triggered() ), this, SLOT( editTaskSleepN() ) );
1619 actionListBranches.append (a);
1622 a = new QAction(QPixmap(), tr( "Sleep %1 days","Task sleep" ).arg("n")+"...", this);
1623 a->setShortcutContext (Qt::WindowShortcut);
1624 a->setShortcut (Qt::Key_Q + Qt::SHIFT);
1625 a->setCheckable(false);
1626 a->setEnabled (false);
1629 switchboard.addSwitch ("mapTaskSleepN", shortcutScope, a, tag);
1630 connect( a, SIGNAL( triggered() ), this, SLOT( editTaskSleepN() ) );
1631 actionListBranches.append (a);
1634 a = new QAction(QPixmap(), tr( "Sleep %1 day","Task sleep" ).arg(1), this);
1635 a->setShortcutContext (Qt::WindowShortcut);
1636 a->setCheckable(false);
1637 a->setEnabled (false);
1640 switchboard.addSwitch ("mapTaskSleep1", shortcutScope, a, tag);
1641 connect( a, SIGNAL( triggered() ), this, SLOT( editTaskSleepN() ) );
1642 actionListBranches.append (a);
1645 a = new QAction(QPixmap(), tr( "Sleep %1 days","Task sleep" ).arg(2), this);
1646 a->setShortcutContext (Qt::WindowShortcut);
1647 a->setCheckable(false);
1648 a->setEnabled (false);
1651 switchboard.addSwitch ("mapTaskSleep2", shortcutScope, a, tag);
1652 connect( a, SIGNAL( triggered() ), this, SLOT( editTaskSleepN() ) );
1653 actionListBranches.append (a);
1656 a = new QAction(QPixmap(), tr( "Sleep %1 days","Task sleep" ).arg(3), this);
1657 a->setShortcutContext (Qt::WindowShortcut);
1658 a->setCheckable(false);
1659 a->setEnabled (false);
1662 switchboard.addSwitch ("mapTaskSleep3", shortcutScope, a, tag);
1663 connect( a, SIGNAL( triggered() ), this, SLOT( editTaskSleepN() ) );
1664 actionListBranches.append (a);
1667 a = new QAction(QPixmap(), tr( "Sleep %1 days","Task sleep" ).arg(5), this);
1668 a->setShortcutContext (Qt::WindowShortcut);
1669 a->setCheckable(false);
1670 a->setEnabled (false);
1673 switchboard.addSwitch ("mapTaskSleep5", shortcutScope, a, tag);
1674 connect( a, SIGNAL( triggered() ), this, SLOT( editTaskSleepN() ) );
1675 actionListBranches.append (a);
1678 a = new QAction(QPixmap(), tr( "Sleep %1 days","Task sleep" ).arg(7), this);
1679 a->setShortcutContext (Qt::WindowShortcut);
1680 a->setCheckable(false);
1681 a->setEnabled (false);
1684 switchboard.addSwitch ("mapTaskSleep7", shortcutScope, a, tag);
1685 connect( a, SIGNAL( triggered() ), this, SLOT( editTaskSleepN() ) );
1686 actionListBranches.append (a);
1689 a = new QAction(QPixmap(), tr( "Sleep %1 weeks","Task sleep" ).arg(2), this);
1690 a->setShortcutContext (Qt::WindowShortcut);
1691 a->setCheckable(false);
1692 a->setEnabled (false);
1695 switchboard.addSwitch ("mapTaskSleep14", shortcutScope, a, tag);
1696 connect( a, SIGNAL( triggered() ), this, SLOT( editTaskSleepN() ) );
1697 actionListBranches.append (a);
1698 actionTaskSleep14=a;
1700 a = new QAction(QPixmap(), tr( "Sleep %1 weeks","Task sleep" ).arg(4), this);
1701 a->setShortcutContext (Qt::WindowShortcut);
1702 a->setCheckable(false);
1703 a->setEnabled (false);
1706 switchboard.addSwitch ("mapTaskSleep28", shortcutScope, a, tag);
1707 connect( a, SIGNAL( triggered() ), this, SLOT( editTaskSleepN() ) );
1708 actionListBranches.append (a);
1709 actionTaskSleep28=a;
1711 // Import at selection (adding to selection)
1712 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
1713 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
1714 a->setEnabled (false);
1715 actionListBranches.append(a);
1718 // Import at selection (replacing selection)
1719 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
1720 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
1721 a->setEnabled (false);
1722 actionListBranches.append(a);
1723 actionImportReplace=a;
1726 a = new QAction( tr( "Save selection","Edit menu" ), this);
1727 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
1728 a->setEnabled (false);
1729 actionListBranches.append(a);
1732 tag = tr("Removing parts of a map","Shortcuts");
1734 // Only remove branch, not its children
1735 a = new QAction(tr( "Remove only branch and keep its children ","Edit menu" ), this);
1736 a->setShortcut (Qt::ALT + Qt::Key_X );
1737 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChildren() ) );
1738 a->setEnabled (false);
1740 switchboard.addSwitch ("mapDeleteKeepChildren", shortcutScope, a, tag);
1741 actionListBranches.append(a);
1742 actionDeleteKeepChildren=a;
1744 // Only remove children of a branch
1745 a = new QAction( tr( "Remove children","Edit menu" ), this);
1746 a->setShortcut (Qt::SHIFT + Qt::Key_X );
1748 switchboard.addSwitch ("mapDeleteChildren", shortcutScope, a, tag);
1749 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChildren() ) );
1750 a->setEnabled (false);
1752 actionListBranches.append(a);
1753 actionDeleteChildren=a;
1755 tag = tr("Various","Shortcuts");
1756 a = new QAction(tr( "Add timestamp","Edit menu" ), this);
1757 a->setEnabled (false);
1758 actionListBranches.append(a);
1759 a->setShortcut ( Qt::Key_T );
1760 a->setShortcutContext (Qt::WindowShortcut);
1762 switchboard.addSwitch ("mapAddTimestamp", shortcutScope, a, tag);
1763 connect( a, SIGNAL( triggered() ), this, SLOT( editAddTimestamp() ) );
1764 actionListBranches.append (a);
1765 actionAddTimestamp=a;
1767 a = new QAction(tr( "Map properties...","Edit menu" ),this);
1768 a->setEnabled (true);
1769 connect( a, SIGNAL( triggered() ), this, SLOT( editMapProperties() ) );
1770 actionListFiles.append (a);
1773 a = new QAction( tr( "Add ...","Edit menu" ), this);
1774 a->setShortcutContext (Qt::WindowShortcut);
1775 a->setShortcut (Qt::Key_I + Qt::SHIFT);
1777 switchboard.addSwitch ("mapLoadImage", shortcutScope, a, tag);
1778 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
1781 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
1782 a->setShortcut ( Qt::Key_P );
1783 a->setShortcutContext (Qt::WindowShortcut);
1784 a->setCheckable (true);
1786 switchboard.addSwitch ("mapTogglePropertEditor", shortcutScope, a, tag);
1787 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
1788 actionViewTogglePropertyEditor=a;
1792 void Main::setupSelectActions()
1794 QString tag = tr("Selections","Shortcuts");
1795 QMenu *selectMenu = menuBar()->addMenu( tr("Select","Select menu") );
1797 a = new QAction( QPixmap(":/flag-target.png"), tr( "Toggle target...","Edit menu"), this);
1798 a->setShortcut (Qt::SHIFT + Qt::Key_T );
1799 a->setCheckable(true);
1800 selectMenu->addAction(a);
1801 switchboard.addSwitch ("mapToggleTarget", shortcutScope, a, tag);
1802 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleTarget() ) );
1803 actionListBranches.append (a);
1804 actionToggleTarget=a;
1806 a = new QAction( QPixmap(":/flag-target.png"), tr( "Goto target...","Edit menu"), this);
1807 a->setShortcut (Qt::Key_G );
1808 selectMenu->addAction(a);
1809 switchboard.addSwitch ("mapGotoTarget", shortcutScope, a, tag);
1810 connect( a, SIGNAL( triggered() ), this, SLOT( editGoToTarget() ) );
1811 actionListBranches.append (a);
1814 a = new QAction( QPixmap(":/flag-target.png"), tr( "Move to target...","Edit menu"), this);
1815 a->setShortcut (Qt::Key_M );
1816 selectMenu->addAction(a);
1817 switchboard.addSwitch ("mapMoveToTarget", shortcutScope, a, tag);
1818 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveToTarget() ) );
1819 actionListBranches.append (a);
1820 actionMoveToTarget=a;
1822 a = new QAction( QPixmap(":/selectprevious.png"), tr( "Select previous","Edit menu"), this);
1823 a->setShortcut (Qt::CTRL+ Qt::Key_O );
1824 a->setShortcutContext (Qt::WidgetShortcut);
1825 selectMenu->addAction(a);
1826 actionListFiles.append (a);
1827 mapEditorActions.append ( a );
1828 switchboard.addSwitch ("mapSelectPrevious", shortcutScope, a, tag);
1829 connect( a, SIGNAL( triggered() ), this, SLOT( editSelectPrevious() ) );
1830 actionSelectPrevious=a;
1832 a = new QAction( QPixmap(":/selectnext.png"), tr( "Select next","Edit menu"), this);
1833 a->setShortcut (Qt::CTRL + Qt::Key_I );
1834 a->setShortcutContext (Qt::WidgetShortcut);
1835 selectMenu->addAction(a);
1836 actionListFiles.append (a);
1837 mapEditorActions.append ( a );
1838 switchboard.addSwitch ("mapSelectNext", shortcutScope, a, tag);
1839 connect( a, SIGNAL( triggered() ), this, SLOT( editSelectNext() ) );
1842 a = new QAction( tr( "Unselect all","Edit menu"), this);
1843 //a->setShortcut (Qt::CTRL + Qt::Key_I );
1844 selectMenu->addAction(a);
1845 switchboard.addSwitch ("mapSelectNothing", shortcutScope, a, tag);
1846 connect( a, SIGNAL( triggered() ), this, SLOT( editSelectNothing() ) );
1847 actionListFiles.append (a);
1848 actionSelectNothing=a;
1850 tag = tr("Search functions","Shortcuts");
1851 a = new QAction( QPixmap(":/find.png"), tr( "Find...","Edit menu"), this);
1852 a->setShortcut (Qt::CTRL + Qt::Key_F );
1853 selectMenu->addAction(a);
1854 switchboard.addSwitch ("mapFind", shortcutScope, a, tag);
1855 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindResultWidget() ) );
1856 actionListFiles.append(a);
1859 a = new QAction( QPixmap(":/find.png"), tr( "Find...","Edit menu"), this);
1860 a->setShortcut (Qt::Key_Slash );
1861 selectMenu->addAction(a);
1862 switchboard.addSwitch ("mapFindAlt", shortcutScope, a, tag);
1863 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindResultWidget() ) );
1864 actionListFiles.append(a);
1866 a = new QAction( tr( "Find duplicate URLs","Edit menu"), this);
1867 a->setShortcut (Qt::SHIFT + Qt::Key_F);
1868 switchboard.addSwitch ("mapFindDuplicates", shortcutScope, a, tag);
1869 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1870 selectMenu->addAction (a);
1871 connect( a, SIGNAL( triggered() ), this, SLOT( editFindDuplicateURLs() ) );
1876 void Main::setupFormatActions()
1878 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
1880 QString tag = tr("Formatting","Shortcuts");
1883 QPixmap pix( 16,16);
1884 pix.fill (Qt::black);
1885 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
1886 formatMenu->addAction(a);
1887 switchboard.addSwitch ("mapFormatColor", shortcutScope, a, tag);
1888 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
1889 actionFormatColor=a;
1891 a= new QAction( QPixmap(":/formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
1892 a->setShortcut (Qt::CTRL + Qt::Key_K );
1893 formatMenu->addAction(a);
1894 switchboard.addSwitch ("mapFormatColorPicker", shortcutScope, a, tag);
1895 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
1896 a->setEnabled (false);
1897 actionListBranches.append(a);
1898 actionFormatPickColor=a;
1900 a= new QAction(QPixmap(":/formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
1901 //a->setShortcut (Qt::CTRL + Qt::Key_B + Qt::SHIFT);
1902 formatMenu->addAction(a);
1903 switchboard.addSwitch ("mapFormatColorBranch", shortcutScope, a, tag);
1904 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
1905 a->setEnabled (false);
1906 actionListBranches.append(a);
1907 actionFormatColorBranch=a;
1909 a= new QAction(QPixmap(":/formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
1910 //a->setShortcut (Qt::CTRL + Qt::Key_B); // Color subtree
1911 formatMenu->addAction(a);
1912 switchboard.addSwitch ("mapFormatColorSubtree", shortcutScope, a, tag);
1913 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
1914 a->setEnabled (false);
1915 actionListBranches.append(a);
1916 actionFormatColorSubtree=a;
1918 formatMenu->addSeparator();
1920 a= new QAction( tr( "Select default font","Branch attribute" )+"...", this);
1921 a->setCheckable(false);
1922 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectFont() ) );
1923 formatMenu->addAction (a);
1926 formatMenu->addSeparator();
1928 actionGroupFormatLinkStyles=new QActionGroup ( this);
1929 actionGroupFormatLinkStyles->setExclusive (true);
1930 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
1931 a->setCheckable(true);
1932 restrictedMapActions.append( a );
1933 formatMenu->addAction (a);
1934 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
1935 actionFormatLinkStyleLine=a;
1937 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
1938 a->setCheckable(true);
1939 restrictedMapActions.append( a );
1940 formatMenu->addAction (a);
1941 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
1942 actionFormatLinkStyleParabel=a;
1944 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
1945 a->setCheckable(true);
1946 restrictedMapActions.append( a );
1947 formatMenu->addAction (a);
1948 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
1949 actionFormatLinkStylePolyLine=a;
1951 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
1952 a->setCheckable(true);
1953 a->setChecked (true);
1954 restrictedMapActions.append( a );
1955 formatMenu->addAction (a);
1956 formatMenu->addSeparator();
1957 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
1958 actionFormatLinkStylePolyParabel=a;
1960 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
1961 a->setCheckable(true);
1962 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
1963 actionListBranches.append (a);
1964 actionFormatHideLinkUnselected=a;
1966 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
1967 a->setCheckable(true);
1968 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
1969 formatMenu->addAction (a);
1970 actionFormatLinkColorHint=a;
1972 pix.fill (Qt::white);
1973 a= new QAction( pix, tr( "Set &Link Color")+"..." , this );
1974 formatMenu->addAction (a);
1975 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
1976 actionFormatLinkColor=a;
1978 a= new QAction( pix, tr( "Set &Selection Color")+"...", this );
1979 formatMenu->addAction (a);
1980 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
1981 actionFormatSelectionColor=a;
1983 a= new QAction( pix, tr( "Set &Background Color" )+"...", this );
1984 formatMenu->addAction (a);
1985 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
1986 actionFormatBackColor=a;
1988 a= new QAction( pix, tr( "Set &Background image" )+"...", this );
1989 formatMenu->addAction (a);
1990 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
1991 actionFormatBackImage=a;
1995 void Main::setupViewActions()
1997 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
1998 toolbarsMenu=viewMenu->addMenu (tr("Toolbars","Toolbars overview in view menu") );
1999 QString tag = tr("Views","Shortcuts");
2001 viewMenu->addSeparator();
2004 a = new QAction( QPixmap(":/viewmag+.png"), tr( "Zoom in","View action" ), this);
2005 a->setShortcut(Qt::Key_Plus);
2006 viewMenu->addAction (a);
2007 switchboard.addSwitch ("mapZoomIn", shortcutScope, a, tag);
2008 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
2009 actionListFiles.append (a);
2012 a = new QAction( QPixmap(":/viewmag-.png"), tr( "Zoom out","View action" ), this);
2013 a->setShortcut(Qt::Key_Minus);
2014 viewMenu->addAction (a);
2015 switchboard.addSwitch ("mapZoomOut", shortcutScope, a, tag);
2016 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
2017 actionListFiles.append (a);
2020 a = new QAction( QPixmap(":/rotate-ccw.png"), tr( "Rotate counterclockwise","View action" ), this);
2021 a->setShortcut( Qt::SHIFT + Qt::Key_R);
2022 viewMenu->addAction (a);
2023 switchboard.addSwitch ("mapRotateCounterClockwise", shortcutScope, a, tag);
2024 connect( a, SIGNAL( triggered() ), this, SLOT( viewRotateCounterClockwise() ) );
2025 actionListFiles.append (a);
2026 actionRotateCounterClockwise=a;
2028 a = new QAction( QPixmap(":/rotate-cw.png"), tr( "Rotate rclockwise","View action" ), this);
2029 a->setShortcut(Qt::Key_R);
2030 viewMenu->addAction (a);
2031 switchboard.addSwitch ("mapRotateClockwise", shortcutScope, a, tag);
2032 connect( a, SIGNAL( triggered() ), this, SLOT( viewRotateClockwise() ) );
2033 actionListFiles.append (a);
2034 actionRotateClockwise=a;
2036 a = new QAction(QPixmap(":/viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
2037 a->setShortcut (Qt::Key_Comma);
2038 switchboard.addSwitch ("mapZoomReset", shortcutScope, a, tag);
2039 viewMenu->addAction (a);
2040 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
2041 actionListFiles.append (a);
2044 a = new QAction( QPixmap(":/viewshowsel.png"), tr( "Center on selection","View action" ), this);
2045 a->setShortcut(Qt::Key_Period);
2046 viewMenu->addAction (a);
2047 switchboard.addSwitch ("mapCenterOn", shortcutScope, a, tag);
2048 connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
2049 actionListFiles.append (a);
2052 viewMenu->addSeparator();
2054 //a=noteEditorDW->toggleViewAction();
2055 a = new QAction(QPixmap(":/flag-note.png"), tr( "Note editor","View action" ),this);
2056 a->setShortcut ( Qt::Key_N );
2057 a->setShortcutContext (Qt::WidgetShortcut);
2058 a->setCheckable(true);
2059 viewMenu->addAction (a);
2060 mapEditorActions.append( a );
2061 switchboard.addSwitch ("mapToggleNoteEditor", shortcutScope, a, tag);
2062 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
2063 actionViewToggleNoteEditor=a;
2065 //a=headingEditorDW->toggleViewAction();
2066 a = new QAction(QPixmap(":/headingeditor.png"), tr( "Heading editor","View action" ),this);
2067 a->setCheckable(true);
2068 a->setIcon (QPixmap(":/headingeditor.png"));
2069 a->setShortcut ( Qt::Key_E );
2070 a->setShortcutContext (Qt::WidgetShortcut);
2071 mapEditorActions.append( a );
2072 viewMenu->addAction (a);
2073 switchboard.addSwitch ("mapToggleHeadingEditor", shortcutScope, a, tag);
2074 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHeadingEditor() ) );
2075 actionViewToggleHeadingEditor=a;
2077 // Original icon is "category" from KDE
2078 a = new QAction(QPixmap(":/treeeditor.png"), tr( "Tree editor","View action" ),this);
2079 a->setShortcut ( Qt::CTRL + Qt::Key_T );
2080 a->setCheckable(true);
2081 viewMenu->addAction (a);
2082 switchboard.addSwitch ("mapToggleTreeEditor", shortcutScope, a, tag);
2083 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleTreeEditor() ) );
2084 actionViewToggleTreeEditor=a;
2086 a = new QAction(QPixmap(":/taskeditor.png"), tr( "Task editor","View action" ),this);
2087 a->setCheckable(true);
2088 a->setShortcut ( Qt::Key_Q );
2089 a->setShortcutContext (Qt::WidgetShortcut);
2090 mapEditorActions.append( a );
2091 viewMenu->addAction (a);
2092 switchboard.addSwitch ("mapToggleTaskEditor", shortcutScope, a, tag);
2093 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleTaskEditor() ) );
2094 actionViewToggleTaskEditor=a;
2096 a = new QAction(QPixmap(":/slideeditor.png"), tr( "Slide editor","View action" ),this);
2097 a->setShortcut ( Qt::SHIFT + Qt::Key_S );
2098 a->setCheckable(true);
2099 viewMenu->addAction (a);
2100 switchboard.addSwitch ("mapToggleSlideEditor", shortcutScope, a, tag);
2101 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSlideEditor() ) );
2102 actionViewToggleSlideEditor=a;
2104 a = new QAction(QPixmap(":/scripteditor.png"), tr("Script editor","View action"), this);
2105 a->setShortcut ( Qt::ALT + Qt::Key_S );
2106 a->setCheckable(true);
2107 viewMenu->addAction (a);
2108 switchboard.addSwitch ("mapToggleScriptEditor", shortcutScope, a, tag);
2109 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleScriptEditor() ) );
2110 actionViewToggleScriptEditor=a;
2112 a = new QAction(QPixmap(":/history.png"), tr( "History Window","View action" ),this );
2113 a->setShortcut ( Qt::CTRL + Qt::Key_H );
2114 a->setShortcutContext (Qt::WidgetShortcut);
2115 a->setCheckable(true);
2116 viewMenu->addAction (a);
2117 mapEditorActions.append( a );
2118 switchboard.addSwitch ("mapToggleHistoryWindow", shortcutScope, a, tag);
2119 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
2120 actionViewToggleHistoryWindow=a;
2122 viewMenu->addAction (actionViewTogglePropertyEditor);
2124 viewMenu->addSeparator();
2126 a = new QAction(tr( "Antialiasing","View action" ),this );
2127 a->setCheckable(true);
2128 a->setChecked (settings.value("/mainwindow/view/AntiAlias",true).toBool());
2129 viewMenu->addAction (a);
2130 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
2131 actionViewToggleAntiAlias=a;
2133 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
2134 a->setStatusTip (a->text());
2135 a->setCheckable(true);
2136 a->setChecked (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
2137 viewMenu->addAction (a);
2138 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
2139 actionViewToggleSmoothPixmapTransform=a;
2141 a = new QAction(tr( "Next Map","View action" ), this);
2142 a->setStatusTip (a->text());
2143 a->setShortcut (Qt::SHIFT+ Qt::Key_Right );
2144 viewMenu->addAction (a);
2145 switchboard.addSwitch ("mapPrevious", shortcutScope, a, tag);
2146 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
2148 a = new QAction (tr( "Previous Map","View action" ), this );
2149 a->setStatusTip (a->text());
2150 a->setShortcut (Qt::SHIFT+ Qt::Key_Left );
2151 viewMenu->addAction (a);
2152 switchboard.addSwitch ("mapNext", shortcutScope, a, tag);
2153 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
2155 a = new QAction (tr( "Next slide","View action" ), this );
2156 a->setStatusTip (a->text());
2157 a->setShortcut (Qt::Key_Space);
2158 viewMenu->addAction (a);
2159 switchboard.addSwitch ("mapNextSlide", shortcutScope, a, tag);
2160 connect( a, SIGNAL( triggered() ), this, SLOT(nextSlide() ) );
2162 a = new QAction (tr( "Previous slide","View action" ), this );
2163 a->setStatusTip (a->text());
2164 a->setShortcut (Qt::Key_Backspace);
2165 viewMenu->addAction (a);
2166 switchboard.addSwitch ("mapPreviousSlide", shortcutScope, a, tag);
2167 connect( a, SIGNAL( triggered() ), this, SLOT(previousSlide() ) );
2171 void Main::setupModeActions()
2173 //QPopupMenu *menu = new QPopupMenu( this );
2174 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
2176 QString tag = tr("Modifier modes","Shortcuts");
2178 actionGroupModModes=new QActionGroup ( this);
2179 actionGroupModModes->setExclusive (true);
2180 a= new QAction( QPixmap(":/modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
2181 a->setShortcut (Qt::Key_J);
2183 switchboard.addSwitch ("mapModModeColor", shortcutScope, a, tag);
2184 a->setCheckable(true);
2185 a->setChecked(true);
2186 actionListFiles.append (a);
2187 actionModModeColor=a;
2189 a->setShortcut( Qt::Key_K);
2191 switchboard.addSwitch ("mapModModeCopy", shortcutScope, a, tag);
2192 a->setCheckable(true);
2193 actionListFiles.append (a);
2194 actionModModeCopy=a;
2196 a= new QAction(QPixmap(":/modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
2197 a->setShortcut (Qt::Key_L);
2199 switchboard.addSwitch ("mapModModeXLink", shortcutScope, a, tag);
2200 a->setCheckable(true);
2201 actionListFiles.append (a);
2202 actionModModeXLink=a;
2206 void Main::setupFlagActions()
2208 // Create System Flags
2212 // Origin: ./share/icons/oxygen/48x48/status/task-reject.png
2213 flag=new Flag(":/flag-task-new.png");
2214 flag->setGroup("system-tasks");
2215 setupFlag (flag,NULL,"system-task-new",tr("Note","SystemFlag"));
2216 flag=new Flag(":/flag-task-new-morning.png");
2217 flag->setGroup("system-tasks");
2218 setupFlag (flag,NULL,"system-task-new-morning",tr("Note","SystemFlag"));
2219 flag=new Flag(":/flag-task-new-sleeping.png");
2220 flag->setGroup("system-tasks");
2221 setupFlag (flag,NULL,"system-task-new-sleeping",tr("Note","SystemFlag"));
2222 // Origin: ./share/icons/oxygen/48x48/status/task-reject.png
2223 flag=new Flag(":/flag-task-wip.png");
2224 flag->setGroup("system-tasks");
2225 setupFlag (flag,NULL,"system-task-wip",tr("Note","SystemFlag"));
2226 flag=new Flag(":/flag-task-wip-morning.png");
2227 flag->setGroup("system-tasks");
2228 setupFlag (flag,NULL,"system-task-wip-morning",tr("Note","SystemFlag"));
2229 flag=new Flag(":/flag-task-wip-sleeping.png");
2230 flag->setGroup("system-tasks");
2231 setupFlag (flag,NULL,"system-task-wip-sleeping",tr("Note","SystemFlag"));
2232 // Origin: ./share/icons/oxygen/48x48/status/task-complete.png
2233 flag=new Flag(":/flag-task-finished.png");
2234 flag->setGroup("system-tasks");
2235 setupFlag (flag,NULL,"system-task-finished",tr("Note","SystemFlag"));
2237 flag=new Flag(":/flag-note.png");
2238 setupFlag (flag,NULL,"system-note",tr("Note","SystemFlag"));
2240 flag=new Flag(":/flag-url.png");
2241 setupFlag (flag,NULL,"system-url",tr("URL to Document ","SystemFlag"));
2243 flag=new Flag(":/flag-url-bugzilla-novell.png");
2244 setupFlag (flag,NULL,"system-url-bugzilla-novell",tr("URL to Bugzilla ","SystemFlag"));
2246 flag=new Flag(":/flag-url-bugzilla-novell-closed.png");
2247 setupFlag (flag,NULL,"system-url-bugzilla-novell-closed",tr("URL to Bugzilla ","SystemFlag"));
2249 flag=new Flag(":/flag-target.png");
2250 setupFlag (flag,NULL,"system-target",tr("Map target","SystemFlag"));
2252 flag=new Flag(":/flag-vymlink.png");
2253 setupFlag (flag,NULL,"system-vymLink",tr("Link to another vym map","SystemFlag"));
2255 flag=new Flag(":/flag-scrolled-right.png");
2256 setupFlag (flag,NULL,"system-scrolledright",tr("subtree is scrolled","SystemFlag"));
2258 flag=new Flag(":/flag-tmpUnscrolled-right.png");
2259 setupFlag (flag,NULL,"system-tmpUnscrolledRight",tr("subtree is temporary scrolled","SystemFlag"));
2261 flag=new Flag(":/flag-hideexport.png");
2262 setupFlag (flag,NULL,"system-hideInExport",tr("Hide object in exported maps","SystemFlag"));
2266 // Create Standard Flags
2267 standardFlagsToolbar=addToolBar (tr ("Standard Flags toolbar","Standard Flag Toolbar"));
2268 standardFlagsToolbar->setObjectName ("standardFlagTB");
2269 standardFlagsMaster->setToolBar (standardFlagsToolbar);
2271 // Add entry now, to avoid chicken and egg problem and position toolbar
2272 // after all others:
2273 toolbarsMenu->addAction (standardFlagsToolbar->toggleViewAction() );
2275 flag=new Flag(":/flag-stopsign.png");
2276 setupFlag (flag,standardFlagsToolbar,"stopsign",tr("This won't work!","Standardflag"),Qt::Key_1);
2279 flag=new Flag(":/flag-hook-green.png");
2280 flag->setGroup("standard-status");
2281 setupFlag (flag,standardFlagsToolbar,"hook-green",tr("Status - ok,done","Standardflag"),Qt::Key_2);
2283 flag=new Flag(":/flag-wip.png");
2284 flag->setGroup("standard-status");
2285 setupFlag (flag,standardFlagsToolbar,"wip",tr("Status - work in progress","Standardflag"),Qt::Key_3);
2287 flag=new Flag(":/flag-cross-red.png");
2288 flag->setGroup("standard-status");
2289 setupFlag (flag,standardFlagsToolbar,"cross-red",tr("Status - missing, not started","Standardflag"),Qt::Key_4);
2291 flag=new Flag(":/flag-exclamationmark.png");
2292 flag->setGroup("standard-mark");
2293 setupFlag (flag,standardFlagsToolbar,"exclamationmark",tr("Take care!","Standardflag"),Qt::Key_Exclam);
2295 flag=new Flag(":/flag-questionmark.png");
2296 flag->setGroup("standard-mark");
2297 setupFlag (flag,standardFlagsToolbar,"questionmark",tr("Really?","Standardflag"),Qt::Key_Question);
2299 flag=new Flag(":/flag-smiley-good.png");
2300 flag->setGroup("standard-smiley");
2301 setupFlag (flag,standardFlagsToolbar,"smiley-good",tr("Good","Standardflag"),Qt::Key_ParenRight);
2303 flag=new Flag(":/flag-smiley-sad.png");
2304 flag->setGroup("standard-smiley");
2305 setupFlag (flag,standardFlagsToolbar,"smiley-sad",tr("Bad","Standardflag"),Qt::Key_ParenLeft);
2307 flag=new Flag(":/flag-smiley-omb.png");
2308 flag->setGroup("standard-smiley");
2309 setupFlag (flag,standardFlagsToolbar,"smiley-omb",tr("Oh no!","Standardflag"));
2310 // Original omg.png (in KDE emoticons)
2313 flag=new Flag(":/flag-clock.png");
2314 setupFlag (flag,standardFlagsToolbar,"clock",tr("Time critical","Standardflag"));
2316 flag=new Flag(":/flag-phone.png");
2317 setupFlag (flag,standardFlagsToolbar,"phone",tr("Call...","Standardflag"));
2319 flag=new Flag(":/flag-lamp.png");
2320 setupFlag (flag,standardFlagsToolbar,"lamp",tr("Idea!","Standardflag"),Qt::Key_Asterisk);
2322 flag=new Flag(":/flag-arrow-up.png");
2323 flag->setGroup("standard-arrow");
2324 setupFlag (flag,standardFlagsToolbar,"arrow-up",tr("Important","Standardflag"),Qt::SHIFT + Qt::Key_PageUp);
2326 flag=new Flag(":/flag-arrow-down.png");
2327 flag->setGroup("standard-arrow");
2328 setupFlag (flag,standardFlagsToolbar,"arrow-down",tr("Unimportant","Standardflag"),Qt::SHIFT + Qt::Key_PageDown);
2330 flag=new Flag(":/flag-2arrow-up.png");
2331 flag->setGroup("standard-arrow");
2332 setupFlag (flag,standardFlagsToolbar,"2arrow-up",tr("Very important!","Standardflag"),Qt::SHIFT + +Qt::CTRL + Qt::Key_PageUp);
2334 flag=new Flag(":/flag-2arrow-down.png");
2335 flag->setGroup("standard-arrow");
2336 setupFlag (flag,standardFlagsToolbar,"2arrow-down",tr("Very unimportant!","Standardflag"),Qt::SHIFT + Qt::CTRL + Qt::Key_PageDown);
2339 flag=new Flag(":/flag-thumb-up.png");
2340 flag->setGroup("standard-thumb");
2341 setupFlag (flag,standardFlagsToolbar,"thumb-up",tr("I like this","Standardflag"));
2343 flag=new Flag(":/flag-thumb-down.png");
2344 flag->setGroup("standard-thumb");
2345 setupFlag (flag,standardFlagsToolbar,"thumb-down",tr("I do not like this","Standardflag"));
2348 flag=new Flag(":/flag-rose.png");
2349 setupFlag (flag,standardFlagsToolbar,"rose",tr("Rose","Standardflag"));
2351 flag=new Flag(":/flag-heart.png");
2352 setupFlag (flag,standardFlagsToolbar,"heart",tr("I just love...","Standardflag"));
2354 flag=new Flag(":/flag-present.png");
2355 setupFlag (flag,standardFlagsToolbar,"present",tr("Surprise!","Standardflag"));
2357 flag=new Flag(":/flag-flash.png");
2358 setupFlag (flag,standardFlagsToolbar,"flash",tr("Dangerous","Standardflag"));
2360 // Original: xsldbg_output.png
2361 flag=new Flag(":/flag-info.png");
2362 setupFlag (flag,standardFlagsToolbar,"info",tr("Info","Standardflag"),Qt::Key_I);
2364 // Original khelpcenter.png
2365 flag=new Flag(":/flag-lifebelt.png");
2366 setupFlag (flag,standardFlagsToolbar,"lifebelt",tr("This will help","Standardflag"));
2369 flag=new Flag(":/freemind/warning.png");
2370 flag->setVisible(false);
2371 setupFlag (flag,standardFlagsToolbar, "freemind-warning",tr("Important","Freemind-Flag"));
2373 for (int i=1; i<8; i++)
2375 flag=new Flag(QString(":/freemind/priority-%1.png").arg(i));
2376 flag->setVisible(false);
2377 flag->setGroup ("Freemind-priority");
2378 setupFlag (flag,standardFlagsToolbar, QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
2381 flag=new Flag(":/freemind/back.png");
2382 flag->setVisible(false);
2383 setupFlag (flag,standardFlagsToolbar,"freemind-back",tr("Back","Freemind-Flag"));
2385 flag=new Flag(":/freemind/forward.png");
2386 flag->setVisible(false);
2387 setupFlag (flag,standardFlagsToolbar,"freemind-forward",tr("forward","Freemind-Flag"));
2389 flag=new Flag(":/freemind/attach.png");
2390 flag->setVisible(false);
2391 setupFlag (flag,standardFlagsToolbar,"freemind-attach",tr("Look here","Freemind-Flag"));
2393 flag=new Flag(":/freemind/clanbomber.png");
2394 flag->setVisible(false);
2395 setupFlag (flag,standardFlagsToolbar,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
2397 flag=new Flag(":/freemind/desktopnew.png");
2398 flag->setVisible(false);
2399 setupFlag (flag,standardFlagsToolbar,"freemind-desktopnew",tr("Don't flagrget","Freemind-Flag"));
2401 flag=new Flag(":/freemind/flag.png");
2402 flag->setVisible(false);
2403 setupFlag (flag,standardFlagsToolbar,"freemind-flag",tr("Flag","Freemind-Flag"));
2406 flag=new Flag(":/freemind/gohome.png");
2407 flag->setVisible(false);
2408 setupFlag (flag,standardFlagsToolbar,"freemind-gohome",tr("Home","Freemind-Flag"));
2410 flag=new Flag(":/freemind/kaddressbook.png");
2411 flag->setVisible(false);
2412 setupFlag (flag,standardFlagsToolbar,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
2414 flag=new Flag(":/freemind/knotify.png");
2415 flag->setVisible(false);
2416 setupFlag (flag,standardFlagsToolbar,"freemind-knotify",tr("Music","Freemind-Flag"));
2418 flag=new Flag(":/freemind/korn.png");
2419 flag->setVisible(false);
2420 setupFlag (flag,standardFlagsToolbar,"freemind-korn",tr("Mailbox","Freemind-Flag"));
2422 flag=new Flag(":/freemind/mail.png");
2423 flag->setVisible(false);
2424 setupFlag (flag,standardFlagsToolbar,"freemind-mail",tr("Maix","Freemind-Flag"));
2426 flag=new Flag(":/freemind/password.png");
2427 flag->setVisible(false);
2428 setupFlag (flag,standardFlagsToolbar,"freemind-password",tr("Password","Freemind-Flag"));
2430 flag=new Flag(":/freemind/pencil.png");
2431 flag->setVisible(false);
2432 setupFlag (flag,standardFlagsToolbar,"freemind-pencil",tr("To be improved","Freemind-Flag"));
2434 flag=new Flag(":/freemind/stop.png");
2435 flag->setVisible(false);
2436 setupFlag (flag,standardFlagsToolbar,"freemind-stop",tr("Stop","Freemind-Flag"));
2438 flag=new Flag(":/freemind/wizard.png");
2439 flag->setVisible(false);
2440 setupFlag (flag,standardFlagsToolbar,"freemind-wizard",tr("Magic","Freemind-Flag"));
2442 flag=new Flag(":/freemind/xmag.png");
2443 flag->setVisible(false);
2444 setupFlag (flag,standardFlagsToolbar,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
2446 flag=new Flag(":/freemind/bell.png");
2447 flag->setVisible(false);
2448 setupFlag (flag,standardFlagsToolbar,"freemind-bell",tr("Reminder","Freemind-Flag"));
2450 flag=new Flag(":/freemind/bookmark.png");
2451 flag->setVisible(false);
2452 setupFlag (flag,standardFlagsToolbar,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
2454 flag= new Flag(":/freemind/penguin.png");
2455 flag->setVisible(false);
2456 setupFlag (flag,standardFlagsToolbar,"freemind-penguin",tr("Linux","Freemind-Flag"));
2458 flag=new Flag (":/freemind/licq.png");
2459 flag->setVisible(false);
2460 setupFlag (flag,standardFlagsToolbar,"freemind-licq",tr("Sweet","Freemind-Flag"));
2463 void Main::setupFlag (Flag *flag, QToolBar *tb, const QString &name, const QString &tooltip, const QKeySequence &keyseq)
2465 flag->setName(name);
2466 flag->setToolTip (tooltip);
2470 a=new QAction (flag->getPixmap(),name,this);
2472 flag->setAction (a);
2473 a->setVisible (flag->isVisible());
2474 a->setCheckable(true);
2475 a->setObjectName(name);
2476 a->setToolTip(tooltip);
2479 a->setShortcut (keyseq);
2480 a->setShortcutContext (Qt::WidgetShortcut);
2482 // Allow mapEditors to actually trigger this action
2483 mapEditorActions.append( a );
2484 taskEditorActions.append( a );
2488 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
2489 standardFlagsMaster->addFlag (flag);
2493 systemFlagsMaster->addFlag (flag);
2498 void Main::setupNetworkActions()
2500 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() ) return;
2504 a = new QAction( "Start TCPserver for MapEditor",this);
2505 //a->setShortcut ( Qt::ALT + Qt::Key_T );
2506 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
2508 a = new QAction( "Connect MapEditor to server",this);
2509 //a->setShortcut ( Qt::ALT + Qt::Key_C );
2510 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
2514 void Main::setupSettingsActions()
2516 QMenu *settingsMenu = menuBar()->addMenu( tr( "Settings" ));
2520 a = new QAction( tr( "Check for release notes and updates","Settings action"), this);
2521 a->setCheckable(true);
2522 a->setChecked ( settings.value ("/downloads/enabled",true).toBool());
2523 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDownloads() ) );
2524 settingsMenu->addAction (a);
2525 actionSettingsToggleDownloads = a;
2527 a = new QAction( tr( "Set author for new maps","Settings action"), this);
2528 connect( a, SIGNAL( triggered() ), this, SLOT( settingsDefaultMapAuthor() ) );
2529 settingsMenu->addAction (a);
2531 settingsMenu->addSeparator();
2533 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
2534 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
2535 settingsMenu->addAction (a);
2537 a = new QAction( tr( "Set application to open external links","Settings action"), this);
2538 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
2539 settingsMenu->addAction (a);
2541 a = new QAction( tr( "Set application to zip/unzip files","Settings action"), this);
2542 connect( a, SIGNAL( triggered() ), this, SLOT( settingsZipTool() ) );
2543 settingsMenu->addAction (a);
2545 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
2546 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
2547 settingsMenu->addAction (a);
2549 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
2550 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
2551 settingsMenu->addAction (a);
2553 settingsMenu->addSeparator();
2555 a = new QAction( tr( "Autosave","Settings action"), this);
2556 a->setCheckable(true);
2557 a->setChecked ( settings.value ("/system/autosave/use",true).toBool());
2558 settingsMenu->addAction (a);
2559 actionSettingsToggleAutosave=a;
2561 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
2562 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
2563 settingsMenu->addAction (a);
2564 actionSettingsAutosaveTime=a;
2566 // Disable certain actions during testing
2569 actionSettingsToggleAutosave->setChecked (false);
2570 actionSettingsToggleAutosave->setEnabled (false);
2571 actionSettingsAutosaveTime->setEnabled (false);
2574 a = new QAction( tr( "Write backup file on save","Settings action"), this);
2575 a->setCheckable(true);
2576 a->setChecked ( settings.value ("/system/writeBackupFile",false).toBool());
2577 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleWriteBackupFile() ) );
2578 settingsMenu->addAction (a);
2579 actionSettingsWriteBackupFile=a;
2581 settingsMenu->addSeparator();
2583 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
2584 a->setCheckable(true);
2585 a->setChecked ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
2586 settingsMenu->addAction (a);
2587 actionSettingsAutoEditNewBranch=a;
2589 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
2590 a->setCheckable(true);
2591 a->setChecked ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
2592 settingsMenu->addAction (a);
2593 actionSettingsAutoSelectNewBranch=a;
2595 a= new QAction(tr( "Select existing heading","Settings action" ), this);
2596 a->setCheckable(true);
2597 a->setChecked ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
2598 settingsMenu->addAction (a);
2599 actionSettingsAutoSelectText=a;
2601 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
2602 a->setCheckable(true);
2603 a->setChecked ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
2604 settingsMenu->addAction (a);
2605 actionSettingsUseFlagGroups=a;
2607 a= new QAction( tr( "Use hide flags","Settings action" ), this);
2608 a->setCheckable(true);
2609 a->setChecked ( settings.value ("/export/useHideExport",true).toBool() );
2610 settingsMenu->addAction (a);
2611 actionSettingsUseHideExport=a;
2613 settingsMenu->addSeparator();
2615 a = new QAction( tr( "Number of visible parents in task editor","Settings action"), this);
2616 connect( a, SIGNAL( triggered() ), this, SLOT( settingsShowParentsLevelTasks() ) );
2617 settingsMenu->addAction (a);
2618 actionSettingsShowParentsLevelTasks=a;
2620 a = new QAction( tr( "Number of visible parents in find results window","Settings action"), this);
2621 connect( a, SIGNAL( triggered() ), this, SLOT( settingsShowParentsLevelFindResults() ) );
2622 settingsMenu->addAction (a);
2623 actionSettingsShowParentsLevelFindResults=a;
2625 a = new QAction( tr( "Animation","Settings action"), this);
2626 a->setCheckable(true);
2627 a->setChecked (settings.value("/animation/use",true).toBool() );
2628 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) );
2629 settingsMenu->addAction (a);
2630 actionSettingsUseAnimation=a;
2632 a = new QAction( tr( "Automatic layout","Settings action"), this);
2633 a->setCheckable(true);
2634 a->setChecked ( settings.value ("/mainwindow/autoLayout/use",true).toBool());
2635 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAutoLayout() ) );
2636 settingsMenu->addAction (a);
2637 actionSettingsToggleAutoLayout=a;
2641 void Main::setupTestActions()
2643 QMenu *testMenu = menuBar()->addMenu( tr( "Test" ));
2645 QString tag = "Testing";
2647 a = new QAction( "Test function 1" , this);
2648 a->setShortcut (Qt::ALT + Qt::Key_T);
2649 testMenu->addAction(a);
2650 switchboard.addSwitch ("mapTest1", shortcutScope, a, tag);
2651 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
2653 a = new QAction( "Test function 2" , this);
2654 testMenu->addAction(a);
2655 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
2657 a = new QAction( "Toggle hide export mode" , this);
2658 a->setCheckable (true);
2659 a->setChecked (false);
2660 testMenu->addAction(a);
2661 connect( a, SIGNAL( triggered() ), this, SLOT( toggleHideExport() ) );
2662 actionToggleHideMode=a;
2664 a = new QAction( "Toggle winter mode" , this);
2665 a->setShortcut (Qt::ALT + Qt::Key_Asterisk);
2666 testMenu->addAction(a);
2667 switchboard.addSwitch ("mapWinterMode", shortcutScope, a, tag);
2668 connect( a, SIGNAL( triggered() ), this, SLOT( toggleWinter() ) );
2669 actionToggleWinter=a;
2673 void Main::setupHelpActions()
2675 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
2678 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
2679 helpMenu->addAction(a);
2680 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
2682 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
2683 helpMenu->addAction(a);
2684 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
2685 helpMenu->addSeparator();
2687 a = new QAction( tr( "Download and show release notes","Help action" ), this );
2688 helpMenu->addAction(a);
2689 connect( a, SIGNAL( triggered() ), this, SLOT( checkReleaseNotes() ) );
2691 a = new QAction( tr( "Check, if updates are available","Help action" ), this );
2692 helpMenu->addAction(a);
2693 connect( a, SIGNAL( triggered() ), this, SLOT( checkUpdates() ) );
2694 helpMenu->addSeparator();
2696 a = new QAction( tr( "Show keyboard shortcuts","Help action" ), this );
2697 helpMenu->addAction(a);
2698 connect( a, SIGNAL( triggered() ), this, SLOT( helpShortcuts() ) );
2700 a = new QAction( tr("Debug info","Option to show debugging info") , this);
2701 helpMenu->addAction(a);
2702 connect( a, SIGNAL( triggered() ), this, SLOT( debugInfo() ) );
2704 a = new QAction( tr( "About VYM","Help action" ), this);
2705 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
2706 helpMenu->addAction (a);
2708 a = new QAction( tr( "About QT","Help action" ), this);
2709 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
2710 helpMenu->addAction (a);
2714 void Main::setupContextMenus()
2716 // Context menu for goto/move targets (populated on demand)
2717 targetsContextMenu = new QMenu (this);
2719 // Context Menu for branch or mapcenter
2720 branchContextMenu =new QMenu (this);
2721 branchContextMenu->addAction (actionViewTogglePropertyEditor);
2722 branchContextMenu->addSeparator();
2725 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
2726 branchAddContextMenu->addAction (actionPaste );
2727 branchAddContextMenu->addAction ( actionAddMapCenter );
2728 branchAddContextMenu->addAction ( actionAddBranch );
2729 branchAddContextMenu->addAction ( actionAddBranchBefore );
2730 branchAddContextMenu->addAction ( actionAddBranchAbove);
2731 branchAddContextMenu->addAction ( actionAddBranchBelow );
2732 branchAddContextMenu->addSeparator();
2733 branchAddContextMenu->addAction ( actionImportAdd );
2734 branchAddContextMenu->addAction ( actionImportReplace );
2737 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
2738 branchRemoveContextMenu->addAction (actionCut);
2739 branchRemoveContextMenu->addAction ( actionDelete );
2740 branchRemoveContextMenu->addAction ( actionDeleteKeepChildren );
2741 branchRemoveContextMenu->addAction ( actionDeleteChildren );
2744 branchContextMenu->addAction(actionSaveBranch);
2745 branchContextMenu->addAction( actionFileNewCopy);
2746 branchContextMenu->addAction(actionDetach);
2748 branchContextMenu->addSeparator();
2749 branchContextMenu->addAction ( actionLoadImage);
2750 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
2751 branchContextMenu->addAction ( actionAddAttribute);
2754 branchContextMenu->addSeparator();
2756 // Context menu for tasks
2757 taskContextMenu = branchContextMenu->addMenu (tr("Tasks","Context menu"));
2758 taskContextMenu->addAction (actionToggleTask);
2759 taskContextMenu->addAction (actionCycleTaskStatus);
2760 taskContextMenu->addSeparator();
2761 taskContextMenu->addAction (actionTaskSleep0);
2762 taskContextMenu->addAction (actionTaskSleepN);
2763 taskContextMenu->addAction (actionTaskSleep1);
2764 taskContextMenu->addAction (actionTaskSleep2);
2765 taskContextMenu->addAction (actionTaskSleep3);
2766 taskContextMenu->addAction (actionTaskSleep5);
2767 taskContextMenu->addAction (actionTaskSleep7);
2768 taskContextMenu->addAction (actionTaskSleep14);
2769 taskContextMenu->addAction (actionTaskSleep28);
2771 // Submenu for Links (URLs, vymLinks)
2772 branchLinksContextMenu =new QMenu (this);
2774 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
2775 branchLinksContextMenu->addAction ( actionOpenURL );
2776 branchLinksContextMenu->addAction ( actionOpenURLTab );
2777 branchLinksContextMenu->addAction ( actionOpenMultipleVisURLTabs );
2778 branchLinksContextMenu->addAction ( actionOpenMultipleURLTabs );
2779 branchLinksContextMenu->addAction ( actionURLNew );
2780 branchLinksContextMenu->addAction ( actionLocalURL );
2781 branchLinksContextMenu->addAction ( actionGetURLsFromNote );
2782 branchLinksContextMenu->addAction ( actionHeading2URL );
2783 branchLinksContextMenu->addAction ( actionBugzilla2URL );
2784 branchLinksContextMenu->addAction ( actionGetBugzillaData );
2785 branchLinksContextMenu->addAction ( actionGetBugzillaDataSubtree );
2786 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
2787 branchLinksContextMenu->addAction ( actionFATE2URL );
2788 branchLinksContextMenu->addSeparator();
2789 branchLinksContextMenu->addAction ( actionOpenVymLink );
2790 branchLinksContextMenu->addAction ( actionOpenVymLinkBackground );
2791 branchLinksContextMenu->addAction ( actionOpenMultipleVymLinks );
2792 branchLinksContextMenu->addAction ( actionEditVymLink );
2793 branchLinksContextMenu->addAction ( actionDeleteVymLink );
2796 // Context Menu for XLinks in a branch menu
2797 // This will be populated "on demand" in updateActions
2798 QString tag = tr ("XLinks","Menu for file actions");
2799 branchContextMenu->addSeparator();
2800 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
2802 branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ),
2803 this, SLOT( editEditXLink(QAction * ) ) );
2805 a = new QAction( tr("Follow XLink","Context menu") , this);
2806 a->setShortcut (Qt::Key_F);
2808 switchboard.addSwitch ("mapFollowXLink", shortcutScope, a, tag);
2809 connect( a, SIGNAL( triggered() ), this, SLOT( popupFollowXLink() ) );
2811 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
2813 branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ),
2814 this, SLOT( editFollowXLink(QAction * ) ) );
2818 // Context menu for floatimage
2819 floatimageContextMenu =new QMenu (this);
2820 a= new QAction (tr ("Save image","Context action"),this);
2821 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
2822 floatimageContextMenu->addAction (a);
2824 floatimageContextMenu->addSeparator();
2825 floatimageContextMenu->addAction(actionCopy);
2826 floatimageContextMenu->addAction(actionCut);
2828 floatimageContextMenu->addSeparator();
2829 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
2831 // Context menu for canvas
2832 canvasContextMenu =new QMenu (this);
2834 canvasContextMenu->addAction (actionAddMapCenter);
2836 canvasContextMenu->addSeparator();
2838 canvasContextMenu->addAction(actionMapProperties);
2839 canvasContextMenu->addAction(actionFormatFont);
2841 canvasContextMenu->addSeparator();
2843 canvasContextMenu->addActions(actionGroupFormatLinkStyles->actions() );
2845 canvasContextMenu->addSeparator();
2847 canvasContextMenu->addAction(actionFormatLinkColorHint);
2849 canvasContextMenu->addSeparator();
2851 canvasContextMenu->addAction(actionFormatLinkColor);
2852 canvasContextMenu->addAction(actionFormatSelectionColor);
2853 canvasContextMenu->addAction(actionFormatBackColor);
2854 //if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
2855 // canvasContextMenu->addAction( actionFormatBackImage ); //FIXME-3 makes vym too slow: postponed for later version
2858 // Menu for last opened files
2860 for (int i = 0; i < MaxRecentFiles; ++i)
2862 recentFileActions[i] = new QAction(this);
2863 recentFileActions[i]->setVisible(false);
2864 fileLastMapsMenu->addAction(recentFileActions[i]);
2865 connect(recentFileActions[i], SIGNAL(triggered()),
2866 this, SLOT(fileLoadRecent()));
2868 setupRecentMapsMenu();
2871 void Main::setupRecentMapsMenu()
2873 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
2875 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
2877 for (int i = 0; i < numRecentFiles; ++i) {
2878 QString text = QString("&%1 %2").arg(i + 1).arg(files[i]);
2879 recentFileActions[i]->setText(text);
2880 recentFileActions[i]->setData(files[i]);
2881 recentFileActions[i]->setVisible(true);
2883 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
2884 recentFileActions[j]->setVisible(false);
2887 void Main::setupMacros()
2889 for (int i = 0; i <= 12; i++)
2891 macroActions[i] = new QAction(this);
2892 macroActions[i]->setData(i);
2893 addAction (macroActions[i]);
2894 connect(macroActions[i], SIGNAL(triggered()), this, SLOT(callMacro()));
2896 macroActions[0]->setShortcut ( Qt::Key_F1 );
2897 macroActions[1]->setShortcut ( Qt::Key_F2 );
2898 macroActions[2]->setShortcut ( Qt::Key_F3 );
2899 macroActions[3]->setShortcut ( Qt::Key_F4 );
2900 macroActions[4]->setShortcut ( Qt::Key_F5 );
2901 macroActions[5]->setShortcut ( Qt::Key_F6 );
2902 macroActions[6]->setShortcut ( Qt::Key_F7 );
2903 macroActions[7]->setShortcut ( Qt::Key_F8 );
2904 macroActions[8]->setShortcut ( Qt::Key_F9 );
2905 macroActions[9]->setShortcut ( Qt::Key_F10 );
2906 macroActions[10]->setShortcut ( Qt::Key_F11 );
2907 macroActions[11]->setShortcut ( Qt::Key_F12 );
2909 macroActions[12]->setShortcut ( Qt::Key_F1 + Qt::SHIFT);
2912 void Main::setupToolbars()
2915 fileToolbar = addToolBar( tr ("File actions toolbar","Toolbar for file actions"));
2916 fileToolbar->setObjectName ("fileTB");
2917 fileToolbar->addAction(actionFileNew);
2918 fileToolbar->addAction(actionFileOpen);
2919 fileToolbar->addAction(actionFileSave);
2920 fileToolbar->addAction(actionFileExportLast);
2921 fileToolbar->addAction(actionFilePrint);
2923 // Undo/Redo and clipboard
2924 clipboardToolbar =addToolBar( tr ("Undo and clipboard toolbar","Toolbar for redo/undo and clipboard"));
2925 clipboardToolbar->setObjectName ("clipboard toolbar");
2926 clipboardToolbar->addAction (actionUndo);
2927 clipboardToolbar->addAction (actionRedo);
2928 clipboardToolbar->addAction (actionCopy);
2929 clipboardToolbar->addAction (actionCut);
2930 clipboardToolbar->addAction (actionPaste);
2933 editActionsToolbar = addToolBar( tr ("Edit actions toolbar","Toolbar name") );
2934 editActionsToolbar->setObjectName ("basic edit actions TB");
2935 editActionsToolbar->addAction (actionAddMapCenter);
2936 editActionsToolbar->addAction (actionAddBranch);
2937 editActionsToolbar->addAction (actionMoveUp);
2938 editActionsToolbar->addAction (actionMoveDown);
2939 editActionsToolbar->addAction (actionSortChildren);
2940 editActionsToolbar->addAction (actionSortBackChildren);
2941 editActionsToolbar->addAction (actionToggleScroll);
2942 editActionsToolbar->addAction (actionToggleHideExport);
2943 editActionsToolbar->addAction (actionToggleTask);
2944 //editActionsToolbar->addAction (actionExpandAll);
2945 //editActionsToolbar->addAction (actionExpandOneLevel);
2946 //editActionsToolbar->addAction (actionCollapseOneLevel);
2947 //editActionsToolbar->addAction (actionCollapseUnselected);
2950 selectionToolbar = addToolBar( tr ("Selection toolbar","Toolbar name") );
2951 selectionToolbar->setObjectName ("toolbar for selecting items");
2952 selectionToolbar->addAction (actionToggleTarget);
2953 selectionToolbar->addAction (actionSelectPrevious);
2954 selectionToolbar->addAction (actionSelectNext);
2955 selectionToolbar->addAction (actionFind);
2957 // URLs and vymLinks
2958 referencesToolbar=addToolBar( tr ("URLs and vymLinks toolbar","Toolbar for URLs and vymlinks"));
2959 referencesToolbar->setObjectName ("URLs and vymlinks toolbar");
2960 //referencesToolbar->addAction (actionOpenURL); //FIXME-4 removed 2015-06-22
2961 referencesToolbar->addAction (actionURLNew);
2962 //referencesToolbar->addAction (actionOpenVymLink)//FIXME-4 removed 2015-06-22;
2963 referencesToolbar->addAction (actionEditVymLink);
2965 // Format and colors
2966 colorsToolbar = addToolBar( tr("Colors toolbar","Colors toolbar name"));
2967 colorsToolbar->setObjectName ("colorsTB");
2968 colorsToolbar->addAction(actionFormatColor);
2969 colorsToolbar->addAction(actionFormatPickColor);
2970 colorsToolbar->addAction(actionFormatColorBranch);
2971 colorsToolbar->addAction(actionFormatColorSubtree);
2974 zoomToolbar = addToolBar( tr("Zoom toolbar","View Toolbar name") );
2975 zoomToolbar->setObjectName ("viewTB");
2976 zoomToolbar->addAction(actionZoomIn);
2977 zoomToolbar->addAction(actionZoomOut);
2978 zoomToolbar->addAction(actionZoomReset);
2979 zoomToolbar->addAction(actionCenterOn);
2980 zoomToolbar->addAction(actionRotateCounterClockwise);
2981 zoomToolbar->addAction(actionRotateClockwise);
2984 editorsToolbar = addToolBar( tr("Editors toolbar","Editor Toolbar name") );
2985 editorsToolbar->setObjectName ("editorsTB");
2986 editorsToolbar->addAction (actionViewToggleNoteEditor);
2987 editorsToolbar->addAction (actionViewToggleHeadingEditor);
2988 editorsToolbar->addAction (actionViewToggleTreeEditor);
2989 editorsToolbar->addAction (actionViewToggleTaskEditor);
2990 editorsToolbar->addAction (actionViewToggleSlideEditor);
2991 editorsToolbar->addAction (actionViewToggleScriptEditor);
2992 editorsToolbar->addAction (actionViewToggleHistoryWindow);
2996 modModesToolbar = addToolBar( tr ("Modifier modes toolbar","Modifier Toolbar name") );
2997 modModesToolbar->setObjectName ("modesTB");
2998 modModesToolbar->addAction(actionModModeColor);
2999 modModesToolbar->addAction(actionModModeCopy);
3000 modModesToolbar->addAction(actionModModeXLink);
3002 // Add all toolbars to View menu
3003 toolbarsMenu->addAction (fileToolbar->toggleViewAction() );
3004 toolbarsMenu->addAction (clipboardToolbar->toggleViewAction() );
3005 toolbarsMenu->addAction (editActionsToolbar->toggleViewAction() );
3006 toolbarsMenu->addAction (selectionToolbar->toggleViewAction() );
3007 toolbarsMenu->addAction (colorsToolbar->toggleViewAction() );
3008 toolbarsMenu->addAction (zoomToolbar->toggleViewAction() );
3009 toolbarsMenu->addAction (modModesToolbar->toggleViewAction() );
3010 toolbarsMenu->addAction (referencesToolbar->toggleViewAction() );
3011 toolbarsMenu->addAction (editorsToolbar->toggleViewAction() );
3013 // Default visibility to not overload new users
3014 fileToolbar->show();
3015 clipboardToolbar->show();
3016 editActionsToolbar->show();
3017 selectionToolbar->hide();
3018 colorsToolbar->show();
3019 zoomToolbar->show();
3020 modModesToolbar->hide();
3021 referencesToolbar->hide();
3022 editorsToolbar->hide();
3026 VymView* Main::currentView() const
3028 if ( tabWidget->currentWidget() )
3030 int i=tabWidget->currentIndex();
3031 if (i>=0 && i< vymViews.count() ) return vymViews.at(i);
3036 MapEditor* Main::currentMapEditor() const
3038 if ( tabWidget->currentWidget())
3039 return vymViews.at(tabWidget->currentIndex())->getMapEditor();
3043 uint Main::currentModelID() const
3045 VymModel *m=currentModel();
3047 return m->getModelID();
3052 VymModel* Main::currentModel() const
3054 VymView *vv=currentView();
3056 return vv->getModel();
3061 VymModel* Main::getModel(uint id) const
3063 if (id <=0) return NULL;
3066 for (int i=0; i<vymViews.count();i++)
3067 if (vymViews.at(i)->getModel()->getModelID()==id)
3068 return vymViews.at(i)->getModel();
3072 void Main::gotoModel (VymModel *m)
3074 for (int i=0; i<vymViews.count();i++)
3075 if (vymViews.at(i)->getModel()==m)
3077 tabWidget->setCurrentIndex (i);
3082 int Main::modelCount()
3084 return vymViews.count();
3087 void Main::updateTabName( VymModel *vm)
3089 for( int i = 0; i < vymViews.count(); i++)
3091 if (vymViews.at(i)->getModel() == vm )
3093 if ( vm->isReadOnly() )
3094 tabWidget->setTabText( i, vm->getFileName() + " " + tr("(readonly)") );
3096 tabWidget->setTabText( i, vm->getFileName() );
3102 void Main::editorChanged()
3104 VymModel *vm=currentModel();
3107 updateNoteEditor (vm->getSelectedIndex() );
3110 taskEditor->setMapName (vm->getMapName() );
3113 // Update actions to in menus and toolbars according to editor
3117 void Main::fileNew()
3119 VymModel *vm=new VymModel;
3121 /////////////////////////////////////
3122 // new ModelTest(vm, this);
3123 /////////////////////////////////////
3125 VymView *vv=new VymView (vm);
3126 vymViews.append (vv);
3128 tabWidget->addTab (vv,tr("unnamed","MainWindow: name for new and empty file"));
3129 tabWidget->setCurrentIndex (vymViews.count() );
3132 // Create MapCenter for empty map
3133 vm->addMapCenter(false);
3136 // For the very first map we do not have flagrows yet...
3139 // Switch to new tab
3140 tabWidget->setCurrentIndex (tabWidget->count() -1);
3143 void Main::fileNewCopy()
3145 QString fn="unnamed";
3146 VymModel *srcModel=currentModel();
3151 VymModel *dstModel=vymViews.last()->getModel();
3152 if (dstModel->select("mc:0"))
3153 dstModel->loadMap (clipboardDir+"/"+clipboardFile,ImportReplace);
3155 qWarning ()<<"Main::fileNewCopy couldn't select mapcenter";
3159 File::ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
3161 File::ErrorCode err=File::Success;
3163 // fn is usually the archive, mapfile the file after uncompressing
3166 // Make fn absolute (needed for unzip)
3167 fn=QDir (fn).absolutePath();
3173 // Check, if map is already loaded
3175 while (i<=tabWidget->count() -1)
3177 if (vymViews.at(i)->getModel()->getFilePath() == fn)
3179 // Already there, ask for confirmation
3180 QMessageBox mb( vymName,
3181 tr("The map %1\nis already opened."
3182 "Opening the same map in multiple editors may lead \n"
3183 "to confusion when finishing working with vym."
3184 "Do you want to").arg(fn),
3185 QMessageBox::Warning,
3186 QMessageBox::Yes | QMessageBox::Default,
3187 QMessageBox::Cancel | QMessageBox::Escape,
3188 QMessageBox::NoButton);
3189 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
3190 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
3193 case QMessageBox::Yes:
3194 // end loop and load anyway
3195 i=tabWidget->count();
3197 case QMessageBox::Cancel:
3199 return File::Aborted;
3209 if ( !fn.isEmpty() )
3211 vm = currentModel();
3212 // Check first, if mapeditor exists
3213 // If it is not default AND we want a new map,
3214 // create a new mapeditor in a new tab
3215 if ( lmode==NewMap && (!vm || !vm->isDefault() ) )
3218 VymView *vv=new VymView (vm);
3219 vymViews.append (vv);
3221 tabWidget->addTab (vv,fn);
3225 // Check, if file exists (important for creating new files
3226 // from command line
3227 if (!QFile(fn).exists() )
3229 QMessageBox mb( vymName,
3230 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
3231 QMessageBox::Question,
3233 QMessageBox::Cancel | QMessageBox::Default,
3234 QMessageBox::NoButton );
3236 mb.setButtonText( QMessageBox::Yes, tr("Create"));
3237 mb.setButtonText( QMessageBox::No, tr("Cancel"));
3239 VymModel *vm = currentMapEditor()->getModel();
3242 case QMessageBox::Yes:
3244 vm->setFilePath(fn);
3245 updateTabName( vm );
3246 statusBar()->showMessage( "Created " + fn , statusbarTime );
3247 return File::Success;
3249 case QMessageBox::Cancel:
3250 // don't create new map
3251 statusBar()->showMessage( "Loading " + fn + " failed!", statusbarTime );
3252 int cur=tabWidget->currentIndex();
3253 tabWidget->setCurrentIndex (tabWidget->count()-1);
3255 tabWidget->setCurrentIndex (cur);
3256 return File::Aborted;
3260 if (err!=File::Aborted)
3262 // Save existing filename in case we import
3263 QString fn_org = vm->getFilePath();
3265 // Finally load map into mapEditor
3266 progressDialog.setLabelText (tr("Loading: %1","Progress dialog while loading maps").arg(fn));
3267 vm->setFilePath (fn);
3268 vm->saveStateBeforeLoad (lmode,fn);
3269 err = vm->loadMap(fn,lmode,ftype);
3271 // Restore old (maybe empty) filepath, if this is an import
3272 if (lmode != NewMap)
3273 vm->setFilePath (fn_org);
3276 // Finally check for errors and go home
3277 if (err == File::Aborted)
3279 if (lmode == NewMap) fileCloseMap();
3280 statusBar()->showMessage( "Could not load " + fn, statusbarTime );
3283 if (lmode == NewMap)
3285 vm->setFilePath (fn);
3286 updateTabName( vm );
3287 actionFilePrint->setEnabled (true);
3290 vm->emitShowSelection();
3292 statusBar()->showMessage( "Loaded " + fn, statusbarTime );
3299 void Main::fileLoad(const LoadMode &lmode)
3305 caption=vymName+ " - " +tr("Load vym map");
3308 caption=vymName+ " - " +tr("Import: Add vym map to selection");
3311 caption=vymName+ " - " +tr("Import: Replace selection with vym map");
3316 filter+="VYM map " + tr("or","File Dialog") +" Freemind map" + " (*.xml *.vym *.vyp *.mm);;";
3317 filter+="VYM map (*.vym *.vyp);;";
3318 filter+="VYM Backups (*.vym~);;";
3319 filter+="Freemind map (*.mm);;";
3320 filter+="XML (*.xml);;";
3321 filter+="All (* *.*)";
3322 QStringList fns=QFileDialog::getOpenFileNames(
3328 if (!fns.isEmpty() )
3330 initProgressCounter (fns.count() );
3331 lastMapDir.setPath(fns.first().left(fns.first().lastIndexOf ("/")) );
3332 foreach (QString fn, fns)
3333 fileLoad(fn, lmode, getMapType (fn) );
3335 removeProgressCounter();
3340 void Main::fileLoad()
3343 tabWidget->setCurrentIndex (tabWidget->count()-1);
3346 void Main::fileSaveSession()
3349 for (int i=0;i<vymViews.count(); i++)
3350 flist.append (vymViews.at(i)->getModel()->getFilePath() );
3351 settings.setValue("/mainwindow/sessionFileList", flist);
3354 void Main::fileRestoreSession()
3356 QStringList flist= settings.value("/mainwindow/sessionFileList").toStringList();
3357 QStringList::Iterator it=flist.begin();
3359 initProgressCounter (flist.count());
3360 while (it !=flist.end() )
3362 FileType type=getMapType (*it);
3363 fileLoad (*it, NewMap,type);
3366 removeProgressCounter();
3369 void Main::fileLoadRecent()
3371 QAction *action = qobject_cast<QAction *>(sender());
3374 initProgressCounter ();
3375 QString fn=action->data().toString();
3376 FileType type=getMapType (fn);
3377 fileLoad (fn, NewMap,type);
3378 removeProgressCounter();
3379 tabWidget->setCurrentIndex (tabWidget->count()-1);
3383 void Main::addRecentMap (const QString &fileName)
3386 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
3387 files.removeAll(fileName);
3388 files.prepend(fileName);
3389 while (files.size() > MaxRecentFiles)
3392 settings.setValue("/mainwindow/recentFileList", files);
3394 setupRecentMapsMenu();
3397 void Main::fileSave(VymModel *m, const SaveMode &savemode)
3401 if (m->isReadOnly() ) return;
3403 if ( m->getFilePath().isEmpty() )
3405 // We have no filepath yet,
3406 // call fileSaveAs() now, this will call fileSave()
3408 // First switch to editor
3409 fileSaveAs(savemode);
3410 return; // avoid saving twice...
3413 if (m->save (savemode)==File::Success)
3415 statusBar()->showMessage(
3416 tr("Saved %1").arg(m->getFilePath()),
3419 statusBar()->showMessage(
3420 tr("Couldn't save ").arg(m->getFilePath()),
3424 void Main::fileSave()
3426 fileSave (currentModel(), CompleteMap);
3429 void Main::fileSave(VymModel *m)
3431 fileSave (m,CompleteMap);
3434 void Main::fileSaveAs(const SaveMode& savemode)
3436 if (currentMapEditor())
3439 if (savemode == CompleteMap)
3440 filter = "VYM map (*.vym)";
3442 filter = "VYM part of map (*vyp)";
3443 filter += ";;All (* *.*)";
3445 QString fn = QFileDialog::getSaveFileName (
3451 QFileDialog::DontConfirmOverwrite);
3454 // Check for existing file
3455 if (QFile (fn).exists())
3457 QMessageBox mb( vymName,
3458 tr("The file %1\nexists already. Do you want to").arg(fn),
3459 QMessageBox::Warning,
3460 QMessageBox::Yes | QMessageBox::Default,
3461 QMessageBox::Cancel | QMessageBox::Escape,
3462 QMessageBox::NoButton);
3463 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
3464 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
3467 case QMessageBox::Yes:
3470 case QMessageBox::Cancel:
3475 lastMapDir.setPath(fn.left(fn.lastIndexOf ("/")) );
3478 // New file, add extension to filename, if missing
3479 // This is always .vym or .vyp, depending on savemode
3480 if (savemode == CompleteMap)
3482 if (!fn.contains (".vym") && !fn.contains (".xml"))
3486 if (!fn.contains (".vyp") && !fn.contains (".xml"))
3492 VymModel *m = currentModel();
3493 QString fn_org = m->getFilePath(); // Restore fn later, if savemode != CompleteMap
3494 if (savemode == CompleteMap )
3496 // Check for existing lockfile
3497 QFile lockFile( fn + ".lock" );
3498 if (lockFile.exists() )
3500 QMessageBox::critical( 0, tr( "Critical Error" ), tr("Couldn't save %1,\nbecause of existing lockfile:\n\n%2").arg(fn).arg( lockFile.fileName() ));
3504 if ( !m->renameMap( fn ) )
3506 QMessageBox::critical( 0, tr( "Critical Error" ), tr("Couldn't save %1").arg( fn ));
3510 fileSave(m, savemode);
3513 if (savemode == CompleteMap)
3516 { // Renaming map to original name, because we only saved the selected part of it
3517 m->setFilePath (fn_org);
3525 void Main::fileSaveAs()
3527 fileSaveAs (CompleteMap);
3530 void Main::fileImportFirefoxBookmarks()
3533 fd.setDirectory (vymBaseDir.homePath()+"/.mozilla/firefox");
3534 fd.setFileMode (QFileDialog::ExistingFiles);
3535 QStringList filters;
3536 filters<<"Firefox "+tr("Bookmarks")+" (*.html)";
3537 fd.setNameFilters(filters);
3538 fd.setAcceptMode (QFileDialog::AcceptOpen);
3539 fd.setWindowTitle(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
3541 if ( fd.exec() == QDialog::Accepted )
3543 ImportFirefoxBookmarks im;
3544 QStringList flist = fd.selectedFiles();
3545 QStringList::Iterator it = flist.begin();
3546 while( it != flist.end() )
3549 if (im.transform() &&
3550 File::Aborted!=fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
3551 currentMapEditor() )
3552 currentMapEditor()->getModel()->setFilePath ("");
3558 void Main::fileImportFreemind()
3560 QStringList filters;
3561 filters <<"Freemind map (*.mm)"<<"All files (*)";
3563 fd.setDirectory (lastMapDir);
3564 fd.setFileMode (QFileDialog::ExistingFiles);
3565 fd.setNameFilters (filters);
3566 fd.setWindowTitle(vymName+ " - " +tr("Load Freemind map"));
3567 fd.setAcceptMode (QFileDialog::AcceptOpen);
3570 if ( fd.exec() == QDialog::Accepted )
3572 lastMapDir=fd.directory().path();
3573 QStringList flist = fd.selectedFiles();
3574 QStringList::Iterator it = flist.begin();
3575 while( it != flist.end() )
3578 if ( fileLoad (fn,NewMap, FreemindMap) )
3580 currentMapEditor()->getModel()->setFilePath ("");
3588 void Main::fileImportMM()
3593 fd.setDirectory (lastMapDir);
3594 fd.setFileMode (QFileDialog::ExistingFiles);
3595 QStringList filters;
3596 filters<<"Mind Manager (*.mmap)";
3597 fd.setNameFilters (filters);
3598 fd.setAcceptMode (QFileDialog::AcceptOpen);
3599 fd.setWindowTitle(tr("Import")+" "+"Mind Manager");
3601 if ( fd.exec() == QDialog::Accepted )
3603 lastMapDir=fd.directory();
3604 QStringList flist = fd.selectedFiles();
3605 QStringList::Iterator it = flist.begin();
3606 while( it != flist.end() )
3609 if (im.transform() &&
3610 File::Success==fileLoad (im.getTransformedFile(),NewMap,VymMap) &&
3611 currentMapEditor() )
3612 currentMapEditor()->getModel()->setFilePath ("");
3618 void Main::fileImportDir()
3620 VymModel *m=currentModel();
3621 if (m) m->importDir();
3624 void Main::fileExportXML()
3626 VymModel *m=currentModel();
3627 if (m) m->exportXML();
3630 void Main::fileExportHTML()
3632 VymModel *m=currentModel();
3633 if (m) m->exportHTML();
3636 void Main::fileExportImage()
3638 VymModel *m=currentModel();
3639 if (m) m->exportImage();
3642 void Main::fileExportPDF()
3644 VymModel *m=currentModel();
3645 if (m) m->exportPDF();
3648 void Main::fileExportSVG()
3650 VymModel *m=currentModel();
3651 if (m) m->exportSVG();
3654 void Main::fileExportAO()
3656 VymModel *m=currentModel();
3657 if (m) m->exportAO();
3660 void Main::fileExportASCII()
3662 VymModel *m=currentModel();
3663 if (m) m->exportASCII();
3666 void Main::fileExportASCIITasks()
3668 VymModel *m=currentModel();
3669 if (m) m->exportASCII(true);
3672 void Main::fileExportCSV() //FIXME-3 not scriptable yet
3674 VymModel *m=currentModel();
3679 ex.addFilter ("CSV (*.csv)");
3680 ex.setDirPath(lastImageDir.absolutePath());
3681 ex.setWindowTitle(vymName+ " -" + tr("Export as CSV") + " " + tr("(still experimental)"));
3682 if (ex.execDialog() )
3684 m->setExportMode(true);
3686 m->setExportMode(false);
3691 void Main::fileExportLaTeX()
3693 VymModel *m=currentModel();
3694 if (m) m->exportLaTeX();
3697 void Main::fileExportOrgMode()
3699 VymModel *m=currentModel();
3700 if (m) m->exportOrgMode();
3703 void Main::fileExportTaskjuggler() //FIXME-3 not scriptable yet
3705 ExportTaskjuggler ex;
3706 VymModel *m=currentModel();
3710 ex.setWindowTitle ( vymName + " - " + tr("Export to") + " Taskjuggler" + tr("(still experimental)"));
3711 ex.setDirPath (lastImageDir.absolutePath());
3712 ex.addFilter ("Taskjuggler (*.tjp)");
3714 if (ex.execDialog() )
3716 m->setExportMode(true);
3718 m->setExportMode(false);
3723 void Main::fileExportImpress()
3725 ExportOOFileDialog fd;
3726 // TODO add preview in dialog
3727 fd.setWindowTitle(vymName+" - "+tr("Export to")+" LibreOffice");
3728 fd.setDirectory (QDir().current());
3729 fd.setAcceptMode (QFileDialog::AcceptSave);
3730 fd.setFileMode (QFileDialog::AnyFile);
3731 if (fd.foundConfig())
3733 if ( fd.exec() == QDialog::Accepted )
3735 if (!fd.selectedFiles().isEmpty())
3737 QString fn=fd.selectedFiles().first();
3738 if (!fn.contains (".odp")) fn +=".odp";
3740 //lastImageDir=fn.left(fn.findRev ("/"));
3741 VymModel *m=currentModel();
3742 if (m) m->exportImpress (fn,fd.selectedConfig());
3747 QMessageBox::warning(0,
3749 tr("Couldn't find configuration for export to LibreOffice\n"));
3753 void Main::fileExportLast()
3755 VymModel *m=currentModel();
3756 if (m) m->exportLast();
3759 bool Main::fileCloseMap(int i)
3763 if ( i<0) i = tabWidget->currentIndex();
3765 vv = vymViews.at(i);
3770 if (m->hasChanged())
3772 QMessageBox mb( vymName,
3773 tr("The map %1 has been modified but not saved yet. Do you want to").arg(m->getFileName()),
3774 QMessageBox::Warning,
3775 QMessageBox::Yes | QMessageBox::Default,
3777 QMessageBox::Cancel | QMessageBox::Escape );
3778 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
3779 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
3784 case QMessageBox::Yes:
3786 fileSave(m, CompleteMap);
3788 case QMessageBox::No:
3789 // close without saving
3791 case QMessageBox::Cancel:
3797 vymViews.removeAt (i);
3798 tabWidget->removeTab (i);
3800 // Destroy stuff, order is important
3801 delete (m->getMapEditor());
3808 return true; // Better don't exit vym if there is no currentModel()...
3811 void Main::filePrint()
3813 if (currentMapEditor())
3814 currentMapEditor()->print();
3817 bool Main::fileExitVYM()
3821 // Check if one or more editors have changed
3822 while (vymViews.count()>0)
3824 tabWidget->setCurrentIndex(0);
3825 if (fileCloseMap()) return true;
3831 void Main::editUndo()
3833 VymModel *m=currentModel();
3837 void Main::editRedo()
3839 VymModel *m=currentModel();
3843 void Main::gotoHistoryStep (int i)
3845 VymModel *m=currentModel();
3846 if (m) m->gotoHistoryStep(i);
3849 void Main::editCopy()
3851 VymModel *m=currentModel();
3855 void Main::editPaste()
3857 VymModel *m=currentModel();
3861 void Main::editCut()
3863 VymModel *m=currentModel();
3867 bool Main::openURL(const QString &url)
3869 if (url.isEmpty()) return false;
3871 QString browser=settings.value("/system/readerURL" ).toString();
3874 if (!QProcess::startDetached(browser,args,QDir::currentPath(),browserPID))
3876 // try to set path to browser
3877 QMessageBox::warning(0,
3879 tr("Couldn't find a viewer to open %1.\n").arg(url)+
3880 tr("Please use Settings->")+tr("Set application to open an URL"));
3887 void Main::openTabs(QStringList urls)
3889 if (urls.isEmpty()) return;
3892 QString browser=settings.value("/system/readerURL" ).toString();
3893 #if defined(VYM_DBUS)
3894 if ( browser.contains("konqueror") &&
3895 (browserPID==0 || !QDBusConnection::sessionBus().interface()->registeredServiceNames().value().contains (QString("org.kde.konqueror-%1").arg(*browserPID)))
3898 // Start a new browser, if there is not one running already or
3899 // if a previously started konqueror is gone.
3900 if (debug) qDebug() <<"Main::openTabs no konqueror with PID "<<*browserPID<<" found";
3901 openURL(urls.takeFirst());
3902 if (debug) qDebug() << "Main::openTabs Started konqueror, new PID is "<<*browserPID;
3905 if (browser.contains("konqueror"))
3907 foreach (QString u, urls)
3910 // Try to open new tab in existing konqueror started previously by vym
3913 args<< QString("org.kde.konqueror-%1").arg(*browserPID)<<
3914 "/konqueror/MainWindow_1"<<
3918 if (!QProcess::startDetached ("qdbus",args))
3920 QMessageBox::warning(0,
3922 tr("Couldn't start %1 to open a new tab in %2.").arg("qdbus").arg("konqueror"));
3930 // Other browser, e.g. xdg-open
3931 // Just open all urls and leave it to the system to cope with it
3932 foreach (QString u, urls)
3936 // Now give the browser some time before opening the next tab
3937 #if defined(Q_OS_WIN32)
3938 // There's no sleep in VCEE, replace it with Qt's QThread::wait().
3939 this->thread()->wait(1000);
3947 void Main::editOpenURL()
3950 VymModel *m=currentModel();
3953 QString url=m->getURL();
3954 if (url=="") return;
3958 void Main::editOpenURLTab()
3960 VymModel *m=currentModel();
3964 urls.append(m->getURL());
3969 void Main::editOpenMultipleVisURLTabs(bool ignoreScrolled)
3971 VymModel *m=currentModel();
3975 urls=m->getURLs(ignoreScrolled);
3980 void Main::editOpenMultipleURLTabs()
3982 editOpenMultipleVisURLTabs (false);
3985 void Main::editNote2URLs()
3987 VymModel *m=currentModel();
3988 if (m) m->note2URLs();
3991 void Main::editURL()
3993 VymModel *m=currentModel();
3996 QInputDialog *dia=new QInputDialog (this);
3997 dia->setLabelText (tr("Enter URL:"));
3998 dia->setWindowTitle (vymName);
3999 dia->setInputMode (QInputDialog::TextInput);
4000 TreeItem *selti=m->getSelectedItem();
4001 if (selti) dia->setTextValue (selti->getURL());
4002 dia->resize(width()*0.6,80);
4005 if ( dia->exec() ) m->setURL (dia->textValue() );
4010 void Main::editLocalURL()
4012 VymModel *m=currentModel();
4015 TreeItem *selti=m->getSelectedItem();
4019 filter+="All files (*);;";
4020 filter+=tr("HTML","Filedialog") + " (*.html,*.htm);;";
4021 filter+=tr("Text","Filedialog") + " (*.txt);;";
4022 filter+=tr("Spreadsheet","Filedialog") + " (*.odp,*.sxc);;";
4023 filter+=tr("Textdocument","Filedialog") +" (*.odw,*.sxw);;";
4024 filter+=tr("Images","Filedialog") + " (*.png *.bmp *.xbm *.jpg *.png *.xpm *.gif *.pnm)";
4026 QString fn=QFileDialog::getOpenFileName(
4028 vymName+" - " +tr("Set URL to a local file"),
4034 lastMapDir.setPath(fn.left(fn.lastIndexOf ("/")) );
4035 if (!fn.startsWith("file://") )
4043 void Main::editHeading2URL()
4045 VymModel *m=currentModel();
4046 if (m) m->editHeading2URL();
4049 void Main::editBugzilla2URL()
4051 VymModel *m=currentModel();
4052 if (m) m->editBugzilla2URL();
4055 void Main::getBugzillaData()
4057 VymModel *m=currentModel();
4059 QProgressDialog progress ("Doing stuff","cancl",0,10,this);
4060 progress.setWindowModality(Qt::WindowModal);
4061 //progress.setCancelButton (NULL);
4063 progress.setMinimumDuration (0);
4064 progress.setValue (1);
4065 progress.setValue (5);
4069 QProgressBar *pb=new QProgressBar;
4075 if (m) m->getBugzillaData(false);
4078 void Main::getBugzillaDataSubtree()
4080 VymModel *m=currentModel();
4081 if (m) m->getBugzillaData(true);
4084 void Main::editFATE2URL()
4086 VymModel *m=currentModel();
4087 if (m) m->editFATE2URL();
4090 void Main::editHeading()
4092 MapEditor *me=currentMapEditor();
4093 if (me) me->editHeading();
4096 void Main::editHeadingFinished(VymModel *m)
4100 if (!actionSettingsAutoSelectNewBranch->isChecked() &&
4101 !prevSelection.isEmpty())
4102 m->select(prevSelection);
4107 void Main::openVymLinks(const QStringList &vl, bool background)
4111 for (int j = 0; j < vl.size(); ++j)
4113 // compare path with already loaded maps
4114 QString absPath = QFileInfo(vl.at(j)).absoluteFilePath();
4116 for (int i = 0;i <= vymViews.count() -1; i++)
4118 if ( absPath == vymViews.at(i)->getModel()->getFilePath() )
4124 if (index < 0) vlmin.append ( absPath );
4128 progressCounterTotal = vlmin.size();
4129 for (int j = 0; j < vlmin.size(); j++)
4132 if (!QFile(vlmin.at(j)).exists() )
4133 QMessageBox::critical( 0, tr( "Critical Error" ),
4134 tr("Couldn't open map %1").arg(vlmin.at(j)));
4137 fileLoad (vlmin.at(j), NewMap,VymMap);
4139 tabWidget->setCurrentIndex (tabWidget->count()-1);
4142 // Go to tab containing the map
4144 tabWidget->setCurrentIndex (index);
4145 removeProgressCounter();
4148 void Main::editOpenVymLink(bool background)
4150 VymModel *m = currentModel();
4154 vl.append(m->getVymLink());
4155 openVymLinks (vl, background);
4159 void Main::editOpenVymLinkBackground()
4161 editOpenVymLink (true);
4164 void Main::editOpenMultipleVymLinks()
4166 QString currentVymLink;
4167 VymModel *m = currentModel();
4170 QStringList vl = m->getVymLinks();
4171 openVymLinks (vl, true);
4175 void Main::editVymLink()
4177 VymModel *m = currentModel();
4180 BranchItem *bi = m->getSelectedBranch();
4183 QStringList filters;
4184 filters <<"VYM map (*.vym)";
4186 fd.setWindowTitle (vymName+" - " +tr("Link to another map"));
4187 fd.setNameFilters (filters);
4188 fd.setWindowTitle(vymName+" - " +tr("Link to another map"));
4189 fd.setDirectory (lastMapDir);
4190 fd.setAcceptMode (QFileDialog::AcceptOpen);
4191 if (! bi->getVymLink().isEmpty() )
4192 fd.selectFile( bi->getVymLink() );
4196 if ( fd.exec() == QDialog::Accepted &&!fd.selectedFiles().isEmpty() )
4198 QString fn = fd.selectedFiles().first();
4199 lastMapDir = QDir (fd.directory().path());
4206 void Main::editDeleteVymLink()
4208 VymModel *m=currentModel();
4209 if (m) m->deleteVymLink();
4212 void Main::editToggleHideExport()
4214 VymModel *m=currentModel();
4215 if (m) m->toggleHideExport();
4218 void Main::editToggleTask()
4220 VymModel *m=currentModel();
4221 if (m) m->toggleTask();
4224 void Main::editCycleTaskStatus()
4226 VymModel *m=currentModel();
4227 if (m) m->cycleTaskStatus();
4230 void Main::editTaskSleepN()
4232 VymModel *m=currentModel();
4235 int n=((QAction*)sender())->data().toInt();
4236 Task *task=m->getSelectedTask();
4243 n=task->getDaysSleep();
4246 LineEditDialog *dia=new LineEditDialog(this);
4247 dia->setLabel(tr("Enter sleep time (number of days or date YYYY-MM-DD or DD.MM[.YYYY]","task sleep time dialog"));
4248 dia->setText(QString("%1").arg(n));
4250 if (dia->exec() == QDialog::Accepted)
4259 s=QString("%1").arg(n);
4261 if (ok && !m->setTaskSleep(s) )
4262 QMessageBox::warning(0,
4264 tr("Couldn't set sleep time to %1.\n").arg(s));
4269 void Main::editAddTimestamp()
4271 VymModel *m=currentModel();
4272 if (m) m->addTimestamp();
4275 void Main::editMapProperties()
4277 VymModel *m = currentModel();
4280 ExtraInfoDialog dia;
4281 dia.setMapName ( m->getFileName() );
4282 dia.setMapTitle ( m->getTitle() );
4283 dia.setAuthor ( m->getAuthor() );
4284 dia.setComment ( m->getComment() );
4285 dia.setReadOnly ( m->isReadOnly() );
4289 stats += tr("%1 items on map\n","Info about map").arg (m->getScene()->items().size(),6);
4295 BranchItem *cur = NULL;
4296 BranchItem *prev = NULL;
4297 m->nextBranch(cur, prev);
4300 if (!cur->getNote().isEmpty() ) n++;
4301 f += cur->imageCount();
4303 xl += cur->xlinkCount();
4304 m->nextBranch(cur,prev);
4307 stats += QString ("%1 %2\n").arg (m->branchCount(),6).arg(tr("branches","Info about map") );
4308 stats += QString ("%1 %2\n").arg (n,6).arg(tr("notes","Info about map") );
4309 stats += QString ("%1 %2\n").arg (f,6).arg(tr("images","Info about map") );
4310 stats += QString ("%1 %2\n").arg (m->taskCount(),6 ).arg(tr("tasks","Info about map") );
4311 stats += QString ("%1 %2\n").arg (m->slideCount(),6 ).arg(tr("slides","Info about map") );
4312 stats += QString ("%1 %2\n").arg (xl/2,6).arg(tr("xLinks","Info about map") );
4313 dia.setStats (stats);
4315 // Finally show dialog
4316 if (dia.exec() == QDialog::Accepted)
4318 m->setAuthor (dia.getAuthor() );
4319 m->setComment (dia.getComment() );
4320 m->setTitle (dia.getMapTitle() );
4324 void Main::editMoveUp()
4326 MapEditor *me = currentMapEditor();
4327 VymModel *m = currentModel();
4328 if (me && m && me->getState() != MapEditor::EditingHeading) m->moveUp();
4331 void Main::editMoveDown()
4333 MapEditor *me = currentMapEditor();
4334 VymModel *m = currentModel();
4335 if (me && m && me->getState() != MapEditor::EditingHeading) m->moveDown();
4338 void Main::editDetach()
4340 VymModel *m=currentModel();
4344 void Main::editSortChildren()
4346 VymModel *m=currentModel();
4347 if (m) m->sortChildren(false);
4350 void Main::editSortBackChildren()
4352 VymModel *m=currentModel();
4353 if (m) m->sortChildren(true);
4356 void Main::editToggleScroll()
4358 VymModel *m=currentModel();
4359 if (m) m->toggleScroll();
4362 void Main::editExpandAll()
4364 VymModel *m=currentModel();
4365 if (m) m->emitExpandAll();
4368 void Main::editExpandOneLevel()
4370 VymModel *m=currentModel();
4371 if (m) m->emitExpandOneLevel();
4374 void Main::editCollapseOneLevel()
4376 VymModel *m=currentModel();
4377 if (m) m->emitCollapseOneLevel();
4380 void Main::editCollapseUnselected()
4382 VymModel *m=currentModel();
4383 if (m) m->emitCollapseUnselected();
4386 void Main::editUnscrollChildren()
4388 VymModel *m=currentModel();
4389 if (m) m->unscrollChildren();
4392 void Main::editGrowSelectionSize()
4394 VymModel *m=currentModel();
4395 if (m) m->growSelectionSize();
4398 void Main::editShrinkSelectionSize()
4400 VymModel *m=currentModel();
4401 if (m) m->shrinkSelectionSize();
4404 void Main::editResetSelectionSize()
4406 VymModel *m=currentModel();
4407 if (m) m->resetSelectionSize();
4410 void Main::editAddAttribute()
4412 VymModel *m=currentModel();
4420 void Main::editAddMapCenter()
4422 VymModel *m=currentModel();
4425 m->select (m->addMapCenter ());
4426 MapEditor *me=currentMapEditor();
4429 m->setHeadingPlainText("");
4435 void Main::editNewBranch()
4437 VymModel *m=currentModel();
4440 BranchItem *bi=m->addNewBranch();
4443 if (actionSettingsAutoEditNewBranch->isChecked()
4444 && !actionSettingsAutoSelectNewBranch->isChecked() )
4445 prevSelection=m->getSelectString();
4447 prevSelection=QString();
4449 if (actionSettingsAutoSelectNewBranch->isChecked()
4450 || actionSettingsAutoEditNewBranch->isChecked())
4453 if (actionSettingsAutoEditNewBranch->isChecked())
4454 currentMapEditor()->editHeading();
4459 void Main::editNewBranchBefore()
4461 VymModel *m=currentModel();
4464 BranchItem *bi=m->addNewBranchBefore();
4471 if (actionSettingsAutoEditNewBranch->isChecked())
4473 if (!actionSettingsAutoSelectNewBranch->isChecked())
4474 prevSelection=m->getSelectString(bi);
4475 currentMapEditor()->editHeading();
4480 void Main::editNewBranchAbove()
4482 VymModel *m=currentModel();
4485 BranchItem *selbi=m->getSelectedBranch();
4488 BranchItem *bi=m->addNewBranch(selbi,-3);
4495 if (actionSettingsAutoEditNewBranch->isChecked())
4497 if (!actionSettingsAutoSelectNewBranch->isChecked())
4498 prevSelection=m->getSelectString (bi);
4499 currentMapEditor()->editHeading();
4505 void Main::editNewBranchBelow()
4507 VymModel *m=currentModel();
4510 BranchItem *selbi=m->getSelectedBranch();
4513 BranchItem *bi=m->addNewBranch(selbi,-1);
4520 if (actionSettingsAutoEditNewBranch->isChecked())
4522 if (!actionSettingsAutoSelectNewBranch->isChecked())
4523 prevSelection=m->getSelectString(bi);
4524 currentMapEditor()->editHeading();
4530 void Main::editImportAdd()
4532 fileLoad (ImportAdd);
4535 void Main::editImportReplace()
4537 fileLoad (ImportReplace);
4540 void Main::editSaveBranch()
4542 fileSaveAs (PartOfMap);
4545 void Main::editDeleteKeepChildren()
4547 VymModel *m=currentModel();
4548 if (m) m->deleteKeepChildren();
4551 void Main::editDeleteChildren()
4553 VymModel *m=currentModel();
4554 if (m) m->deleteChildren();
4557 void Main::editDeleteSelection()
4559 VymModel *m=currentModel();
4560 if (m) m->deleteSelection();
4563 void Main::editLoadImage()
4565 VymModel *m=currentModel();
4566 if (m) m->loadImage();
4569 void Main::editSaveImage()
4571 VymModel *m=currentModel();
4572 if (m) m->saveImage();
4575 void Main::editEditXLink(QAction *a)
4577 VymModel *m=currentModel();
4580 BranchItem *selbi=m->getSelectedBranch();
4583 Link *l=selbi->getXLinkItemNum(branchXLinksContextMenuEdit->actions().indexOf(a))->getLink();
4584 if (l && m->select (l->getBeginLinkItem() ) )
4590 void Main::popupFollowXLink()
4592 branchXLinksContextMenuFollow->exec( QCursor::pos());
4595 void Main::editFollowXLink(QAction *a)
4597 VymModel *m=currentModel();
4600 m->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
4603 void Main::editToggleTarget()
4605 VymModel *m=currentModel();
4606 if (m) m->toggleTarget();
4609 bool Main::initTargetsMenu( VymModel *model, QMenu *menu)
4613 ItemList targets = model->getTargets();
4617 QStringList targetNames;
4618 QList <uint> targetIDs;
4620 // Build QStringList with all names of targets
4621 QMap<uint,QString>::const_iterator i;
4622 i = targets.constBegin();
4623 while (i != targets.constEnd())
4625 targetNames.append( i.value() );
4626 targetIDs.append( i.key() );
4630 // Sort list of names
4631 targetNames.sort( Qt::CaseInsensitive );
4633 // Build menu based on sorted names
4634 while ( !targetNames.isEmpty() )
4636 // Find target by value
4637 i = targets.constBegin();
4638 while (i != targets.constEnd())
4640 if ( i.value() == targetNames.first() ) break;
4644 menu->addAction( targetNames.first() )->setData( i.key() );
4645 targetNames.removeFirst();
4646 targets.remove( i.key() );
4653 void Main::editGoToTarget()
4655 VymModel *model = currentModel();
4656 if (initTargetsMenu( model, targetsContextMenu ) )
4658 QAction *a = targetsContextMenu->exec (QCursor::pos());
4659 if (a) model->select (model->findID (a->data().toUInt() ) );
4663 void Main::editMoveToTarget()
4665 VymModel *model = currentModel();
4666 if (initTargetsMenu( model, targetsContextMenu ) )
4668 QAction *a = targetsContextMenu->exec (QCursor::pos());
4671 TreeItem *ti = model->findID ( a->data().toUInt() );
4672 BranchItem *selbi = model->getSelectedBranch();
4675 if (ti && ti->isBranchLikeType() && selbi)
4677 BranchItem *pi = selbi->parentBranch();
4678 // If branch below exists, select that one
4679 // Makes it easier to quickly resort using the MoveTo function
4680 BranchItem *below = pi->getBranchNum( selbi->num() + 1 );
4681 LinkableMapObj *lmo = selbi->getLMO();
4683 if (lmo) orgPos = lmo->getAbsPos();
4685 if (model->relinkBranch ( selbi, (BranchItem*)ti, -1, true, orgPos) )
4688 model->select (below);
4690 if (pi) model->select (pi);
4697 void Main::editSelectPrevious()
4699 VymModel *m=currentModel();
4700 if (m) m->selectPrevious();
4703 void Main::editSelectNext()
4705 VymModel *m=currentModel();
4706 if (m) m->selectNext();
4709 void Main::editSelectNothing()
4711 VymModel *m=currentModel();
4712 if (m) m->unselectAll();
4715 void Main::editOpenFindResultWidget()
4717 if (!findResultWidget->parentWidget()->isVisible())
4719 // findResultWidget->parentWidget()->show();
4720 findResultWidget->popup();
4722 findResultWidget->parentWidget()->hide();
4725 #include "findwidget.h" // FIXME-4 Integrated FRW and FW
4726 void Main::editFindNext(QString s)
4728 Qt::CaseSensitivity cs=Qt::CaseInsensitive;
4729 VymModel *m=currentModel();
4732 if (m->findAll (findResultWidget->getResultModel(),s,cs) )
4733 findResultWidget->setStatus (FindWidget::Success);
4735 findResultWidget->setStatus (FindWidget::Failed);
4739 void Main::editFindDuplicateURLs() //FIXME-4 feature: use FindResultWidget for display
4741 VymModel *m=currentModel();
4742 if (m) m->findDuplicateURLs();
4745 void Main::updateQueries (VymModel* ) //FIXME-4 disabled for now to avoid selection in FRW
4749 qDebug() << "MW::updateQueries m="<<m<<" cM="<<currentModel();
4750 if (m && currentModel()==m)
4752 QString s=findResultWidget->getFindText();
4753 if (!s.isEmpty() ) editFindNext (s);
4758 void Main::formatPickColor()
4760 VymModel *m=currentModel();
4762 setCurrentColor ( m->getCurrentHeadingColor() );
4765 QColor Main::getCurrentColor()
4767 return currentColor;
4770 void Main::setCurrentColor(QColor c)
4772 QPixmap pix( 16, 16 );
4774 actionFormatColor->setIcon( pix );
4778 void Main::formatSelectColor()
4780 QColor col = QColorDialog::getColor((currentColor ), this );
4781 if ( !col.isValid() ) return;
4782 setCurrentColor( col );
4785 void Main::formatColorBranch()
4787 VymModel *m=currentModel();
4788 if (m) m->colorBranch(currentColor);
4791 void Main::formatColorSubtree()
4793 VymModel *m=currentModel();
4794 if (m) m->colorSubtree (currentColor);
4797 void Main::formatLinkStyleLine()
4799 VymModel *m=currentModel();
4802 m->setMapLinkStyle("StyleLine");
4803 actionFormatLinkStyleLine->setChecked(true);
4807 void Main::formatLinkStyleParabel()
4809 VymModel *m=currentModel();
4812 m->setMapLinkStyle("StyleParabel");
4813 actionFormatLinkStyleParabel->setChecked(true);
4817 void Main::formatLinkStylePolyLine()
4819 VymModel *m=currentModel();
4822 m->setMapLinkStyle("StylePolyLine");
4823 actionFormatLinkStylePolyLine->setChecked(true);
4827 void Main::formatLinkStylePolyParabel()
4829 VymModel *m=currentModel();
4832 m->setMapLinkStyle("StylePolyParabel");
4833 actionFormatLinkStylePolyParabel->setChecked(true);
4837 void Main::formatSelectBackColor()
4839 VymModel *m=currentModel();
4840 if (m) m->selectMapBackgroundColor();
4843 void Main::formatSelectBackImage()
4845 VymModel *m=currentModel();
4847 m->selectMapBackgroundImage();
4850 void Main::formatSelectLinkColor()
4852 VymModel *m=currentModel();
4855 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
4856 m->setMapDefLinkColor( col );
4860 void Main::formatSelectSelectionColor()
4862 VymModel *m=currentModel();
4865 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
4866 m->setSelectionColor (col);
4871 void Main::formatSelectFont()
4873 VymModel *m=currentModel();
4877 QFont font = QFontDialog::getFont( &ok, m->getMapDefaultFont(), this);
4878 if (ok) m->setMapDefaultFont (font);
4882 void Main::formatToggleLinkColorHint()
4884 VymModel *m=currentModel();
4885 if (m) m->toggleMapLinkColorHint();
4888 void Main::formatHideLinkUnselected() //FIXME-4 get rid of this with imagepropertydialog
4890 VymModel *m=currentModel();
4892 m->setHideLinkUnselected(actionFormatHideLinkUnselected->isChecked());
4895 void Main::viewZoomReset()
4897 MapEditor *me=currentMapEditor();
4898 if (me) me->setViewCenterTarget();
4901 void Main::viewZoomIn()
4903 MapEditor *me=currentMapEditor();
4904 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*1.15);
4907 void Main::viewZoomOut()
4909 MapEditor *me=currentMapEditor();
4910 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*0.85);
4913 void Main::viewRotateCounterClockwise()
4915 MapEditor *me=currentMapEditor();
4916 if (me) me->setAngleTarget (me->getAngleTarget()-10);
4919 void Main::viewRotateClockwise()
4921 MapEditor *me=currentMapEditor();
4922 if (me) me->setAngleTarget (me->getAngleTarget()+10);
4925 void Main::viewCenter()
4927 VymModel *m=currentModel();
4928 if (m) m->emitShowSelection();
4931 void Main::networkStartServer()
4933 VymModel *m=currentModel();
4934 if (m) m->newServer();
4937 void Main::networkConnect()
4939 VymModel *m=currentModel();
4940 if (m) m->connectToServer();
4943 void Main::downloadFinished() // only used for drop events in mapeditor and VM::downloadImage
4946 DownloadAgent *agent = static_cast<DownloadAgent*>(sender());
4947 agent->isSuccess() ? s="Success" : s="Error ";
4950 qDebug()<<"Main::downloadFinished ";
4951 qDebug()<<" result" << s;
4952 qDebug()<<" msg" << agent->getResultMessage();
4955 QString script = agent->getFinishedScript();
4956 VymModel *model=getModel (agent->getFinishedScriptModelID());
4957 if (!script.isEmpty() && model)
4959 script.replace("$TMPFILE",agent->getDestination());
4960 model->execute(script);
4964 bool Main::settingsPDF()
4966 // Default browser is set in constructor
4968 QString text = QInputDialog::getText(
4970 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
4971 settings.value("/system/readerPDF").toString(), &ok);
4973 settings.setValue ("/system/readerPDF",text);
4978 bool Main::settingsURL()
4980 // Default browser is set in constructor
4982 QString text = QInputDialog::getText(
4984 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
4985 settings.value("/system/readerURL").toString()
4988 settings.setValue ("/system/readerURL",text);
4992 void Main::settingsZipTool()
4994 // Default zip tool is 7z on windows, zip/unzip elsewhere
4997 #if defined(Q_OS_WIN32)
4999 filter = "Windows executable (*.exe);;";
5001 QString fn = QFileDialog::getOpenFileName(
5003 vymName + " - " + tr("Set application to zip/unzip files") + ":",
5007 if (!fn.isEmpty() ) ok = true;
5011 QString fn = QInputDialog::getText(
5013 vymName, tr("Set application to zip/unzip files")+":", QLineEdit::Normal,
5020 settings.setValue ("/system/zipToolPath", zipToolPath);
5024 void Main::settingsMacroDir()
5026 QDir defdir(vymBaseDir.path() + "/macros");
5027 if (!defdir.exists())
5029 QDir dir=QFileDialog::getExistingDirectory (
5031 tr ("Directory with vym macros:"),
5032 settings.value ("/macros/macroDir",defdir.path()).toString()
5035 settings.setValue ("/macros/macroDir",dir.absolutePath());
5038 void Main::settingsUndoLevels()
5041 int i = QInputDialog::getInt(
5043 "QInputDialog::getInt()",
5044 tr("Number of undo/redo levels:"), settings.value("/history/stepsTotal",1000).toInt(), 0, 100000, 1, &ok);
5047 settings.setValue ("/history/stepsTotal",i);
5048 QMessageBox::information( this, tr( "VYM -Information:" ),
5049 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
5053 bool Main::useAutosave()
5055 return actionSettingsToggleAutosave->isChecked();
5058 void Main::setAutosave(bool b)
5060 actionSettingsToggleAutosave->setChecked(b);
5063 void Main::settingsAutosaveTime()
5066 int i = QInputDialog::getInt(
5069 tr("Number of seconds before autosave:"), settings.value("/system/autosave/ms").toInt() / 1000, 10, 60000, 1, &ok);
5071 settings.setValue ("/system/autosave/ms",i * 1000);
5074 void Main::settingsDefaultMapAuthor()
5077 QString s = QInputDialog::getText(
5079 vymName, tr("Set author for new maps (used in lockfile)") + ":", QLineEdit::Normal,
5080 settings.value("/user/name", tr("unknown user","default name for map author in settings")).toString(),
5082 if (ok) settings.setValue("/user/name", s);
5085 void Main::settingsShowParentsLevelFindResults()
5088 int i = QInputDialog::getInt(
5091 tr("Number of parents shown in find results:"), findResultWidget->getResultModel()->getShowParentsLevel(), 0, 10, 0, &ok);
5092 if (ok) findResultWidget->getResultModel()->setShowParentsLevel(i);
5095 void Main::settingsShowParentsLevelTasks()
5098 int i = QInputDialog::getInt(
5101 tr("Number of parents shown for a task:"), taskModel->getShowParentsLevel(), 0, 10, 0, &ok);
5102 if (ok) taskModel->setShowParentsLevel(i);
5105 void Main::settingsToggleAutoLayout()
5107 settings.setValue ("/mainwindow/autoLayout/use",actionSettingsToggleAutoLayout->isChecked() );
5110 void Main::settingsToggleWriteBackupFile()
5112 settings.setValue ("/system/writeBackupFile",actionSettingsWriteBackupFile->isChecked() );
5115 void Main::settingsToggleAnimation()
5117 settings.setValue ("/animation/use",actionSettingsUseAnimation->isChecked() );
5120 void Main::settingsToggleDownloads()
5122 downloadsEnabled(true);
5125 void Main::windowToggleNoteEditor()
5127 if (noteEditor->parentWidget()->isVisible() )
5128 noteEditor->parentWidget()->hide();
5131 noteEditor->parentWidget()->show();
5132 noteEditor->setFocus();
5136 void Main::windowToggleTreeEditor()
5138 if ( tabWidget->currentWidget())
5139 vymViews.at(tabWidget->currentIndex())->toggleTreeEditor();
5142 void Main::windowToggleTaskEditor()
5144 if (taskEditor->parentWidget()->isVisible() )
5146 taskEditor->parentWidget()->hide();
5147 actionViewToggleTaskEditor->setChecked (false);
5150 taskEditor->parentWidget()->show();
5151 actionViewToggleTaskEditor->setChecked (true);
5155 void Main::windowToggleSlideEditor()
5157 if ( tabWidget->currentWidget())
5158 vymViews.at(tabWidget->currentIndex())->toggleSlideEditor();
5161 void Main::windowToggleScriptEditor()
5163 if (scriptEditor->parentWidget()->isVisible() )
5165 scriptEditor->parentWidget()->hide();
5166 actionViewToggleScriptEditor->setChecked (false);
5169 scriptEditor->parentWidget()->show();
5170 actionViewToggleScriptEditor->setChecked (true);
5174 void Main::windowToggleHistory()
5176 if (historyWindow->isVisible())
5177 historyWindow->parentWidget()->hide();
5179 historyWindow->parentWidget()->show();
5182 void Main::windowToggleProperty()
5184 if (branchPropertyEditor->parentWidget()->isVisible())
5185 branchPropertyEditor->parentWidget()->hide();
5187 branchPropertyEditor->parentWidget()->show();
5188 branchPropertyEditor->setModel (currentModel() );
5191 void Main::windowShowHeadingEditor()
5193 headingEditorDW->show();
5196 void Main::windowToggleHeadingEditor()
5198 if (headingEditor->parentWidget()->isVisible() )
5199 headingEditor->parentWidget()->hide();
5202 headingEditor->parentWidget()->show();
5203 headingEditor->setFocus();
5207 void Main::windowToggleAntiAlias()
5209 bool b=actionViewToggleAntiAlias->isChecked();
5211 for (int i=0;i<vymViews.count();i++)
5213 me=vymViews.at(i)->getMapEditor();
5214 if (me) me->setAntiAlias(b);
5219 bool Main::isAliased()
5221 return actionViewToggleAntiAlias->isChecked();
5224 bool Main::hasSmoothPixmapTransform()
5226 return actionViewToggleSmoothPixmapTransform->isChecked();
5229 void Main::windowToggleSmoothPixmap()
5231 bool b=actionViewToggleSmoothPixmapTransform->isChecked();
5233 for (int i=0;i<vymViews.count();i++)
5236 me=vymViews.at(i)->getMapEditor();
5237 if (me) me->setSmoothPixmap(b);
5241 void Main::updateHistory(SimpleSettings &undoSet)
5243 historyWindow->update (undoSet);
5246 void Main::updateHeading()
5248 VymModel *m=currentModel();
5249 if (m) m->setHeading (headingEditor->getVymText() );
5252 void Main::updateNoteFlag()
5254 // this slot is connected to noteEditor::textHasChanged()
5255 VymModel *m=currentModel();
5256 if (m) m->updateNoteFlag();
5259 void Main::updateNoteEditor(QModelIndex index ) //FIXME-4 maybe change to TreeItem as parameter?
5261 if (index.isValid() )
5263 TreeItem *ti=((VymModel*) QObject::sender())->getItem(index);
5265 qDebug()<< "Main::updateNoteEditor model="<<sender()
5266 << " item="<<ti->getHeading()<<" ("<<ti<<")";
5267 qDebug()<< "RT="<<ti->getNote().isRichText();
5270 noteEditor->setNote (ti->getNote() );
5271 updateDockWidgetTitles( ti->getModel());
5275 void Main::selectInNoteEditor(QString s,int i)
5277 // TreeItem is already selected at this time, therefor
5278 // the note is already in the editor
5279 noteEditor->findText (s,0,i);
5282 void Main::setFocusMapEditor()
5284 VymView *vv=currentView();
5285 if (vv) vv->setFocusMapEditor();
5288 void Main::changeSelection (VymModel *model, const QItemSelection &newsel, const QItemSelection &)
5290 branchPropertyEditor->setModel (model );
5292 if (model && model == currentModel() )
5295 if (!newsel.indexes().isEmpty() )
5297 ti = model->getItem(newsel.indexes().first());
5299 // Update note editor
5300 if (!ti->hasEmptyNote() )
5301 noteEditor->setNote(ti->getNote() );
5303 noteEditor->setNote(VymNote() );
5304 // Show URL and link in statusbar
5306 QString s = ti->getURL();
5307 if (!s.isEmpty() ) status += "URL: " + s + " ";
5308 s = ti->getVymLink();
5309 if (!s.isEmpty() ) status += "Link: " + s;
5310 if (!status.isEmpty() ) statusMessage (status);
5312 headingEditor->setVymText (ti->getHeading() );
5314 // Select in TaskEditor, if necessary
5316 if (ti->isBranchLikeType() )
5317 t = ((BranchItem*)ti)->getTask();
5320 taskEditor->select (t);
5322 taskEditor->clearSelection();
5324 noteEditor->setInactive();
5330 void Main::updateDockWidgetTitles( VymModel *model)
5333 if (model && !model->isRepositionBlocked() )
5335 BranchItem *bi = model->getSelectedBranch();
5336 if (bi) s = bi->getHeadingPlain();
5338 noteEditor->setEditorTitle(s);
5339 noteEditorDW->setWindowTitle (noteEditor->getEditorTitle() );
5343 void Main::updateActions()
5345 // updateActions is also called when satellites are closed
5346 actionViewToggleNoteEditor->setChecked (noteEditor->parentWidget()->isVisible());
5347 actionViewToggleTaskEditor->setChecked (taskEditor->parentWidget()->isVisible());
5348 actionViewToggleHistoryWindow->setChecked (historyWindow->parentWidget()->isVisible());
5349 actionViewTogglePropertyEditor->setChecked (branchPropertyEditor->parentWidget()->isVisible());
5350 actionViewToggleScriptEditor->setChecked (scriptEditor->parentWidget()->isVisible());
5352 VymView *vv=currentView();
5355 actionViewToggleTreeEditor->setChecked ( vv->treeEditorIsVisible() );
5356 actionViewToggleSlideEditor->setChecked( vv->slideEditorIsVisible() );
5359 actionViewToggleTreeEditor->setChecked ( false );
5360 actionViewToggleSlideEditor->setChecked ( false );
5363 VymModel *m =currentModel();
5367 if (m->isReadOnly() )
5370 standardFlagsMaster->setEnabled (false);
5372 // Disable map related actions
5373 foreach (QAction *a, restrictedMapActions)
5374 a->setEnabled( false );
5376 // FIXME-2 updateactions: refactor actionListFiles: probably not needed, wrong actions there atm
5378 { // not readonly // FIXME-2 updateactions: maybe only required in testing, as mode should not change
5381 standardFlagsMaster->setEnabled (true);
5383 // Enable map related actions
5384 foreach (QAction *a, restrictedMapActions)
5385 a->setEnabled( true );
5388 // Enable all files actions first
5389 for (int i=0; i<actionListFiles.size(); ++i)
5390 actionListFiles.at(i)->setEnabled(true);
5392 foreach (QAction *a, unrestrictedMapActions)
5393 a->setEnabled( true );
5395 // Disable other actions for now
5396 for (int i=0; i<actionListBranches.size(); ++i)
5397 actionListBranches.at(i)->setEnabled(false);
5399 for (int i=0; i<actionListItems.size(); ++i)
5400 actionListItems.at(i)->setEnabled(false);
5402 // Link style in context menu
5403 switch (m->getMapLinkStyle())
5405 case LinkableMapObj::Line:
5406 actionFormatLinkStyleLine->setChecked(true);
5408 case LinkableMapObj::Parabel:
5409 actionFormatLinkStyleParabel->setChecked(true);
5411 case LinkableMapObj::PolyLine:
5412 actionFormatLinkStylePolyLine->setChecked(true);
5414 case LinkableMapObj::PolyParabel:
5415 actionFormatLinkStylePolyParabel->setChecked(true);
5422 QPixmap pix( 16, 16 );
5423 pix.fill( m->getMapBackgroundColor() );
5424 actionFormatBackColor->setIcon( pix );
5425 pix.fill( m->getSelectionColor() );
5426 actionFormatSelectionColor->setIcon( pix );
5427 pix.fill( m->getMapDefLinkColor() );
5428 actionFormatLinkColor->setIcon( pix );
5430 // Selection history
5431 if (!m->canSelectPrevious() )
5432 actionSelectPrevious->setEnabled(false);
5434 if (!m->canSelectNext() )
5435 actionSelectNext->setEnabled(false);
5437 if (!m->getSelectedItem() )
5438 actionSelectNothing->setEnabled (false);
5441 if (! m->hasChanged() )
5442 actionFileSave->setEnabled( false);
5445 if (! m->isUndoAvailable())
5446 actionUndo->setEnabled( false);
5448 if (! m->isRedoAvailable())
5449 actionRedo->setEnabled( false);
5452 historyWindow->setWindowTitle (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName()));
5454 // Expanding/collapsing
5455 actionExpandAll->setEnabled (true);
5456 actionExpandOneLevel->setEnabled (true);
5457 actionCollapseOneLevel->setEnabled (true);
5458 actionCollapseUnselected->setEnabled (true);
5460 if (m->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
5461 actionFormatLinkColorHint->setChecked(true);
5463 actionFormatLinkColorHint->setChecked(false);
5467 if (m && m->exportLastAvailable(s,t,u, v) )
5468 actionFileExportLast->setEnabled (true);
5471 actionFileExportLast->setEnabled (false);
5475 actionFileExportLast->setText( tr( "Export in last used format (%1) to: %2","status tip" ).arg(s).arg(u));
5477 TreeItem *selti=m->getSelectedItem();
5478 BranchItem *selbi=m->getSelectedBranch();
5481 { // Tree Item selected
5482 actionToggleTarget->setChecked (selti->isTarget() );
5483 actionDelete->setEnabled (true);
5484 actionDeleteChildren->setEnabled (true);
5486 if (selbi || selti->getType()==TreeItem::Image)
5488 actionFormatHideLinkUnselected->setChecked (((MapItem*)selti)->getHideLinkUnselected());
5489 actionFormatHideLinkUnselected->setEnabled (true);
5493 { // Branch Item selected
5494 for (int i=0; i<actionListBranches.size(); ++i)
5495 actionListBranches.at(i)->setEnabled(true);
5497 actionHeading2URL->setEnabled (true);
5500 actionGetURLsFromNote->setEnabled (!selbi->getNote().isEmpty());
5502 // Take care of xlinks
5503 // FIXME-4 similar code in mapeditor mousePressEvent
5504 int b=selbi->xlinkCount();
5505 branchXLinksContextMenuEdit->setEnabled(b);
5506 branchXLinksContextMenuFollow->setEnabled(b);
5507 branchXLinksContextMenuEdit->clear();
5508 branchXLinksContextMenuFollow->clear();
5513 for (int i=0; i<selbi->xlinkCount();++i)
5515 bi=selbi->getXLinkItemNum(i)->getPartnerBranch();
5518 s=bi->getHeadingPlain();
5519 if (s.length()>xLinkMenuWidth)
5520 s=s.left(xLinkMenuWidth)+"...";
5521 branchXLinksContextMenuEdit->addAction (s);
5522 branchXLinksContextMenuFollow->addAction (s);
5527 standardFlagsMaster->updateToolBar (selbi->activeStandardFlagNames() );
5530 actionToggleScroll->setEnabled (true);
5531 if ( selbi->isScrolled() )
5532 actionToggleScroll->setChecked(true);
5534 actionToggleScroll->setChecked(false);
5536 actionGetBugzillaDataSubtree->setEnabled (bugzillaClientAvailable);
5537 if ( selti->getURL().isEmpty() )
5539 actionOpenURL->setEnabled (false);
5540 actionOpenURLTab->setEnabled (false);
5541 actionGetBugzillaData->setEnabled (false);
5545 actionOpenURL->setEnabled (true);
5546 actionOpenURLTab->setEnabled (true);
5547 actionGetBugzillaData->setEnabled (
5548 selti->getURL().contains("bugzilla") && bugzillaClientAvailable);
5550 if ( selti->getVymLink().isEmpty() )
5552 actionOpenVymLink->setEnabled (false);
5553 actionOpenVymLinkBackground->setEnabled (false);
5554 actionDeleteVymLink->setEnabled (false);
5557 actionOpenVymLink->setEnabled (true);
5558 actionOpenVymLinkBackground->setEnabled (true);
5559 actionDeleteVymLink->setEnabled (true);
5562 if (!selbi->canMoveUp())
5563 actionMoveUp->setEnabled (false);
5565 if (!selbi->canMoveDown())
5566 actionMoveDown->setEnabled (false);
5568 if (selbi->branchCount() <2 )
5570 actionSortChildren->setEnabled (false);
5571 actionSortBackChildren->setEnabled (false);
5574 actionToggleHideExport->setEnabled (true);
5575 actionToggleHideExport->setChecked (selbi->hideInExport() );
5577 actionToggleTask->setEnabled (true);
5578 if (!selbi->getTask() )
5579 actionToggleTask->setChecked (false);
5581 actionToggleTask->setChecked (true);
5583 if (!clipboardEmpty)
5584 actionPaste->setEnabled (true);
5586 actionPaste->setEnabled (false);
5588 actionToggleTarget->setEnabled (true);
5589 } // end of BranchItem
5591 if ( selti->getType()==TreeItem::Image)
5593 for (int i=0; i<actionListBranches.size(); ++i)
5594 actionListBranches.at(i)->setEnabled(false);
5596 standardFlagsMaster->setEnabled (false);
5598 actionOpenURL->setEnabled (false);
5599 actionOpenVymLink->setEnabled (false);
5600 actionOpenVymLinkBackground->setEnabled (false);
5601 actionDeleteVymLink->setEnabled (false);
5602 actionToggleHideExport->setEnabled (true);
5603 actionToggleHideExport->setChecked (selti->hideInExport() );
5605 actionToggleTarget->setEnabled (true);
5607 actionPaste->setEnabled (false);
5608 actionDelete->setEnabled (true);
5610 actionGrowSelectionSize->setEnabled (true);
5611 actionShrinkSelectionSize->setEnabled (true);
5612 actionResetSelectionSize->setEnabled (true);
5616 // Check (at least for some) multiple selection //FIXME-4
5617 QList <TreeItem*> selItems=m->getSelectedItems();
5618 if (selItems.count()>0 )
5620 actionDelete->setEnabled (true);
5621 actionToggleHideExport->setEnabled (true);
5622 actionToggleHideExport->setChecked (false);
5625 QList <BranchItem*> selbis=m->getSelectedBranches();
5626 if (selbis.count()>0 )
5627 actionFormatColorBranch->setEnabled (true);
5632 for (int i=0; i<actionListFiles.size(); ++i)
5633 actionListFiles.at(i)->setEnabled(false);
5635 foreach (QAction *a, unrestrictedMapActions)
5636 a->setEnabled( false );
5639 standardFlagsMaster->setEnabled (false);
5643 Main::ModMode Main::getModMode()
5645 if (actionModModeColor->isChecked()) return ModModeColor;
5646 if (actionModModeCopy->isChecked()) return ModModeCopy;
5647 if (actionModModeXLink->isChecked()) return ModModeXLink;
5651 bool Main::autoEditNewBranch()
5653 return actionSettingsAutoEditNewBranch->isChecked();
5656 bool Main::autoSelectNewBranch()
5658 return actionSettingsAutoSelectNewBranch->isChecked();
5661 void Main::setScriptFile (const QString &fn)
5663 scriptEditor->setScriptFile (fn);
5666 QVariant Main::execute (const QString &script)
5668 VymModel *m=currentModel();
5669 if (m) return m->execute (script);
5673 void Main::executeEverywhere (const QString &script)
5675 foreach (VymView *vv,vymViews)
5677 VymModel *m=vv->getModel();
5678 if (m) m->execute (script);
5682 void Main::gotoWindow (const int &n)
5684 if (n < tabWidget->count() && n>=0 )
5685 tabWidget->setCurrentIndex (n);
5688 void Main::windowNextEditor()
5690 if (tabWidget->currentIndex() < tabWidget->count())
5691 tabWidget->setCurrentIndex (tabWidget->currentIndex() +1);
5694 void Main::windowPreviousEditor()
5696 if (tabWidget->currentIndex() >0)
5697 tabWidget->setCurrentIndex (tabWidget->currentIndex() -1);
5700 void Main::nextSlide()
5702 VymView *cv=currentView();
5703 if (cv) cv->nextSlide();
5707 void Main::previousSlide()
5709 VymView *cv=currentView();
5710 if (cv) cv->previousSlide();
5713 void Main::standardFlagChanged()
5715 MapEditor *me = currentMapEditor();
5716 VymModel *m = currentModel();
5717 if (me && m && me->getState() != MapEditor::EditingHeading)
5719 if ( actionSettingsUseFlagGroups->isChecked() )
5720 m->toggleStandardFlag(sender()->objectName(),standardFlagsMaster);
5722 m->toggleStandardFlag(sender()->objectName());
5727 void Main::testFunction1()
5730 VymModel *m = currentModel();
5733 m->getMapEditor()->minimizeView();
5738 QString zp = "c:\\Program Files\\7-Zip\\7z.exe";
5739 QString zipName = "c:\\Users\\uwdr9542\\x\\ü1.vym";
5740 QString zipDir = "c:\\Users\\uwdr9542\\x\\y\\";
5742 QString zp = "c:/Program Files/7-Zip/7z.exe";
5743 QString zipName = "c:/Users/uwdr9542/x/ü1.vym";
5744 QString zipDir = "c:/Users/uwdr9542/x/y/";
5746 zp = QDir::toNativeSeparators(zp);
5747 zipName = QDir::toNativeSeparators(zipName);
5748 zipDir = QDir::toNativeSeparators(zipDir);
5750 args << "a" << zipName << "-tzip" << "-scsUTF-8" << "-sccUTF-8" << "*" ;
5752 VymProcess *zipProc=new VymProcess ();
5753 zipProc->setWorkingDirectory (zipDir);
5755 zipProc->start(zipToolPath, args);
5756 qDebug() << "7z:" << zp;
5757 qDebug() << "7z started in dir: " << zipProc->workingDirectory();
5758 qDebug() << "args:" << args;
5759 qDebug() << zipProc->getStdout()<<flush;
5762 void Main::testFunction2()
5766 void Main::toggleWinter()
5768 if (!currentMapEditor()) return;
5769 currentMapEditor()->toggleWinter();
5772 void Main::toggleHideExport()
5774 VymModel *m=currentModel();
5776 if (actionToggleHideMode->isChecked() )
5777 m->setHideTmpMode (TreeItem::HideExport);
5779 m->setHideTmpMode (TreeItem::HideNone);
5782 void Main::testCommand()
5784 if (!currentMapEditor()) return;
5785 scriptEditor->show();
5788 void Main::helpDoc()
5790 QString locale = QLocale::system().name();
5792 if (locale.left(2)=="es")
5793 docname="vym_es.pdf";
5797 QStringList searchList;
5799 #if defined(Q_OS_MACX)
5800 searchList << vymBaseDir.path() + "/doc";
5801 #elif defined(Q_OS_WIN32)
5802 searchList << vymInstallDir.path() + "doc/" + docname;
5804 #if defined(VYM_DOCDIR)
5805 searchList << VYM_DOCDIR;
5807 // default path in SUSE LINUX
5808 searchList << "/usr/share/doc/packages/vym";
5811 searchList << "doc"; // relative path for easy testing in tarball
5812 searchList << "/usr/share/doc/vym"; // Debian
5813 searchList << "/usr/share/doc/packages";// Knoppix
5817 for (int i=0; i<searchList.count(); ++i)
5819 docfile.setFileName(searchList.at(i)+"/"+docname);
5820 if (docfile.exists())
5829 QMessageBox::critical(0,
5830 tr("Critcal error"),
5831 tr("Couldn't find the documentation %1 in:\n%2").arg(docname).arg(searchList.join("\n")));
5836 VymProcess *pdfProc = new VymProcess();
5837 args << QDir::toNativeSeparators(docfile.fileName());
5839 if (!pdfProc->startDetached( settings.value("/system/readerPDF").toString(),args) )
5842 QMessageBox::warning(0,
5844 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
5845 tr("Please use Settings->")+tr("Set application to open PDF files"));
5851 void Main::helpDemo()
5853 QStringList filters;
5854 filters <<"VYM example map (*.vym)";
5856 fd.setDirectory (vymBaseDir.path() + "/demos");
5857 fd.setFileMode (QFileDialog::ExistingFiles);
5858 fd.setNameFilters (filters);
5859 fd.setWindowTitle (vymName+ " - " +tr("Load vym example map"));
5860 fd.setAcceptMode (QFileDialog::AcceptOpen);
5863 if ( fd.exec() == QDialog::Accepted )
5865 lastMapDir=fd.directory().path();
5866 QStringList flist = fd.selectedFiles();
5867 QStringList::Iterator it = flist.begin();
5868 initProgressCounter( flist.count());
5869 while( it != flist.end() )
5872 fileLoad(*it, NewMap,VymMap);
5875 removeProgressCounter();
5879 void Main::helpShortcuts()
5882 dia.useFixedFont (true);
5883 dia.setText( switchboard.getASCII() );
5887 void Main::debugInfo()
5890 s = QString ("Platform: %1\n").arg(vymPlatform);
5891 s += QString ("localeName: %1\nPath: %2\n")
5893 .arg(vymBaseDir.path() + "/lang");
5894 s += QString("vymBaseDir: %1\n").arg(vymBaseDir.path());
5895 s += QString("currentPath: %1\n").arg(QDir::currentPath());
5896 s += QString("appDirPath: %1\n").arg(QCoreApplication::applicationDirPath());
5902 void Main::helpAbout()
5905 ad.setMinimumSize(500,500);
5906 ad.resize (QSize (500,500));
5910 void Main::helpAboutQT()
5912 QMessageBox::aboutQt( this, "Qt Application Example" );
5915 void Main::callMacro ()
5917 QAction *action = qobject_cast<QAction *>(sender());
5921 i=action->data().toInt();
5922 QString s=macros.getMacro (i+1);
5925 VymModel *m=currentModel();
5926 if (m) m->execute(s);
5931 void Main::downloadReleaseNotesFinished()
5933 DownloadAgent *agent = static_cast<DownloadAgent*>(sender());
5936 if (agent->isSuccess() )
5939 if (agent->isSuccess() )
5941 if ( loadStringFromDisk(agent->getDestination(), page) )
5943 ShowTextDialog dia(this);
5947 // Don't load the release notes automatically again
5948 settings.setValue("/downloads/releaseNotes/shownVersion", __VYM_VERSION);
5955 qDebug()<<"Main::downloadReleaseNotesFinished ";
5956 qDebug()<<" result: failed";
5957 qDebug()<<" msg: " << agent->getResultMessage();
5962 void Main::checkReleaseNotes()
5965 if (qobject_cast<QAction *>(sender()) )
5966 userTriggered = true;
5968 userTriggered = false;
5970 if (downloadsEnabled())
5972 if ( userTriggered ||
5973 versionLowerThanVym( settings.value("/downloads/releaseNotes/shownVersion", "0.0.1").toString() ) )
5975 QUrl releaseNotesUrl(
5976 //QString("http://localhost/release-notes.php?vymVersion=%1") /
5977 QString("http://www.insilmaril.de/vym/release-notes.php?vymVersion=%1")
5980 DownloadAgent *agent = new DownloadAgent(releaseNotesUrl);
5981 connect (agent, SIGNAL( downloadFinished()), this, SLOT(downloadReleaseNotesFinished()));
5982 QTimer::singleShot(0, agent, SLOT(execute()));
5986 // No downloads enabled
5989 // Notification: vym could not download release notes
5990 QMessageBox::warning(0, tr("Warning"), tr("Please allow vym to download release notes!"));
5991 if (downloadsEnabled(userTriggered)) checkUpdates();
5996 bool Main::downloadsEnabled (bool userTriggered)
5999 if (!userTriggered && settings.value("/downloads/enabled", false).toBool())
6004 QDate lastAsked = settings.value("/downloads/permissionLastAsked", QDate(1970,1,1) ).toDate();
6005 if (userTriggered ||
6006 !settings.contains("/downloads/permissionLastAsked") ||
6007 lastAsked.daysTo( QDate::currentDate()) > 7
6011 infotext = tr("<html>"
6012 "<h3>Do you allow vym to check online for updates or release notes?</h3>"
6013 "If you allow, vym will "
6015 "<li>check once for release notes</li>"
6016 "<li>check regulary for updates and notify you in case you should update, e.g. if there are "
6017 "important bug fixes available</li>"
6018 "<li>receive a cookie with a random ID and send vym version and platform name and the ID "
6019 "(e.g. \"Windows\" or \"Linux\") back to me, Uwe Drechsel."
6020 "<p>As vym developer I am motivated to see "
6021 "many people using vym. Of course I am curious to see, on which system vym is used. Maintaining each "
6022 "of the systems requires a lot of my (spare) time.</p> "
6023 "<p>No other data than above will be sent, especially no private data will be collected or sent."
6024 "(Check the source code, if you don't believe.)"
6028 "If you do not allow, "
6030 "<li>nothing will be downloaded and especially I will <b>not be motivated</b> "
6031 "to spend some more thousands of hours on developing a free software tool."
6033 "Please allow vym to check for updates :-)"
6035 QMessageBox mb( vymName, infotext,
6036 QMessageBox::Information,
6037 QMessageBox::Yes | QMessageBox::Default,
6038 QMessageBox::Cancel | QMessageBox::Escape,
6039 QMessageBox::NoButton);
6040 mb.setButtonText( QMessageBox::Yes, tr("Allow") );
6041 mb.setButtonText( QMessageBox::Cancel, tr("Do not allow"));
6044 case QMessageBox::Yes:
6046 QMessageBox::information(0, vymName,
6047 tr("Thank you for enabling downloads!"));
6055 actionSettingsToggleDownloads->setChecked( result );
6056 settings.setValue("/downloads/enabled", result);
6057 settings.setValue("/downloads/permissionLastAsked", QDate::currentDate().toString(Qt::ISODate));
6062 void Main::downloadUpdatesFinished(bool userTriggered)
6064 DownloadAgent *agent = static_cast<DownloadAgent*>(sender());
6067 if (agent->isSuccess() )
6070 dia.setWindowTitle( vymName + " - " + tr("Update information") );
6072 if (loadStringFromDisk(agent->getDestination(), page) )
6074 if (page.contains("vymisuptodate"))
6076 statusMessage( tr("vym is up to date.","MainWindow"));
6079 // Notification: vym is up to date!
6080 dia.setHtml( page );
6083 } else if (page.contains("vymneedsupdate"))
6085 // Notification: updates available
6086 dia.setHtml( page );
6090 // Notification: Unknown version found
6091 dia.setHtml( page );
6095 // Prepare to check again later
6096 settings.setValue("/downloads/updates/lastChecked", QDate::currentDate().toString(Qt::ISODate));
6098 statusMessage( "Couldn't load update page from " + agent->getDestination());
6102 statusMessage( "Check for updates failed.");
6105 qDebug()<<"Main::downloadUpdatesFinished ";
6106 qDebug()<<" result: failed";
6107 qDebug()<<" msg: " << agent->getResultMessage();
6111 void Main::downloadUpdatesFinishedInt()
6113 downloadUpdatesFinished(true);
6116 void Main::downloadUpdates(bool userTriggered)
6119 QString("http://www.insilmaril.de/vym/updates.php?vymVersion=%1")
6122 DownloadAgent *agent = new DownloadAgent(updatesUrl);
6124 connect (agent, SIGNAL( downloadFinished()), this, SLOT(downloadUpdatesFinishedInt()));
6126 connect (agent, SIGNAL( downloadFinished()), this, SLOT(downloadUpdatesFinished()));
6127 statusMessage( tr("Checking for updates...","MainWindow"));
6128 QTimer::singleShot(0, agent, SLOT(execute()));
6131 void Main::checkUpdates()
6134 if (qobject_cast<QAction *>(sender()) )
6135 userTriggered = true;
6137 userTriggered = false;
6139 if (downloadsEnabled())
6141 // Too much time passed since last update check?
6142 QDate lastChecked = settings.value("/downloads/updates/lastChecked", QDate(1970,1,1) ).toDate();
6143 if ( !lastChecked.isValid()) lastChecked = QDate(1970,1,1);
6144 if ( lastChecked.daysTo( QDate::currentDate()) > settings.value("/downloads/updates/checkInterval",3).toInt() ||
6145 userTriggered == true)
6147 downloadUpdates( userTriggered );
6151 // No downloads enabled
6154 // Notification: vym could not check for updates
6155 QMessageBox::warning(0, tr("Warning"), tr("Please allow vym to check for updates!"));
6156 if (downloadsEnabled(userTriggered)) checkUpdates();