mainwindow.cpp
author insilmaril
Thu, 06 Jul 2006 14:47:01 +0000
branchqt4-port
changeset 9 f94317a94db1
parent 8 21379539d952
child 10 e2a80d9b5858
permissions -rw-r--r--
Text Editor now shows states again
     1 #include "mainwindow.h"
     2 
     3 #include <QtGui>
     4 #include <QPainter>
     5 #include <QPrinter>
     6 #include <QFile>
     7 #include <q3filedialog.h>
     8 #include <QColor>
     9 #include <QColorDialog>
    10 #include <QBitmap>
    11 #include <QInputDialog>
    12 //Added by qt3to4:
    13 #include <Q3StrList>
    14 #include <QPixmap>
    15 #include <QCloseEvent>
    16 #include <QShowEvent>
    17 #include <QHideEvent>
    18 #include <Q3PopupMenu>
    19 #include <QActionGroup>
    20 #include <Q3PtrList>
    21 //#include <qdatetime.h>			// for random seed
    22 
    23 #include <iostream>
    24 #include <cstdlib>
    25 #include <typeinfo>
    26 
    27 #include "aboutdialog.h"
    28 #include "exportoofiledialog.h"
    29 #include "exports.h"
    30 #include "exportxhtmldialog.h"
    31 #include "file.h"
    32 #include "flagrowobj.h"
    33 #include "imports.h"
    34 #include "mapeditor.h"
    35 #include "misc.h"
    36 #include "options.h"
    37 #include "process.h"
    38 #include "settings.h"
    39 #include "showtextdialog.h"
    40 #include "texteditor.h"
    41 #include "version.h"
    42 
    43 extern TextEditor *textEditor;
    44 extern Main *mainWindow;
    45 extern QString tmpVymDir;
    46 extern QString clipboardDir;
    47 extern bool clipboardEmpty;
    48 extern int statusbarTime;
    49 extern FlagRowObj* standardFlagsDefault;
    50 extern FlagRowObj* systemFlagsDefault;
    51 
    52 extern Q3PtrList <QAction> actionListBranches;
    53 
    54 extern QAction* actionFileSave;
    55 extern QAction* actionFilePrint;
    56 extern QAction* actionEditUndo;
    57 extern QAction* actionEditRedo;
    58 extern QAction *actionEditCopy;
    59 extern QAction *actionEditCut;
    60 extern QAction *actionEditPaste;
    61 extern QAction *actionEditMoveUp;
    62 extern QAction *actionEditMoveDown;
    63 extern QAction *actionEditToggleScroll;
    64 extern QAction* actionEditOpenURL;
    65 extern QAction* actionEditOpenURLTab;
    66 extern QAction* actionEditURL;
    67 extern QAction* actionEditHeading2URL;
    68 extern QAction* actionEditBugzilla2URL;
    69 extern QAction* actionEditFATE2URL;
    70 extern QAction *actionEditOpenVymLink;
    71 extern QAction *actionEditVymLink;
    72 extern QAction *actionEditDeleteVymLink;
    73 extern QAction *actionEditToggleHideExport;
    74 extern QAction *actionEditMapInfo;
    75 extern QAction *actionEditHeading;
    76 extern QAction *actionEditDelete;
    77 extern QAction *actionEditAddBranch;
    78 extern QAction *actionEditAddBranchHere;
    79 extern QAction *actionEditAddBranchAbove;
    80 extern QAction *actionEditAddBranchBelow;
    81 extern QAction *actionEditRemoveBranchKeepChilds;
    82 extern QAction *actionEditRemoveChilds;
    83 extern QAction *actionEditImportAdd;
    84 extern QAction *actionEditImportReplace;
    85 extern QAction *actionEditSaveBranch;
    86 extern QAction *actionEditSelectFirst;
    87 extern QAction *actionEditSelectLast;
    88 extern QAction *actionEditLoadImage;
    89 
    90 extern QAction* actionFormatColor;
    91 extern QAction* actionFormatPickColor;
    92 extern QAction* actionFormatColorBranch;
    93 extern QAction* actionFormatColorSubtree;
    94 extern QAction* actionFormatLinkColorHint;
    95 extern QAction* actionFormatBackColor;
    96 extern QAction* actionFormatLinkColor;
    97 extern QAction *actionFormatIncludeImagesVer;
    98 extern QAction *actionFormatIncludeImagesHor;
    99 
   100 extern QActionGroup* actionGroupModModes;
   101 extern QAction* actionModModeColor;
   102 extern QAction* actionModModeLink;
   103 extern QAction* actionModModeCopy;
   104 
   105 extern QActionGroup *actionGroupFormatFrameTypes;
   106 extern QAction *actionFormatFrameNone;
   107 extern QAction *actionFormatFrameRectangle;
   108 
   109 extern QActionGroup *actionGroupFormatLinkStyles;
   110 extern QAction *actionFormatLinkStyleLine;
   111 extern QAction *actionFormatLinkStyleParabel;
   112 extern QAction *actionFormatLinkStylePolyLine;
   113 extern QAction *actionFormatLinkStylePolyParabel;
   114 extern QAction *actionFormatHideLinkUnselected;
   115 
   116 extern QAction *actionViewToggleNoteEditor;
   117 extern QAction *actionViewToggleHistoryWindow;
   118 
   119 extern QAction* actionSettingsAutoedit;
   120 extern QAction* actionSettingsAutoselectHeading;
   121 extern QAction* actionSettingsAutoselectHeading;
   122 extern QAction* actionSettingsAutoselectText;
   123 extern QAction* actionSettingsPasteNewHeading;
   124 extern QAction* actionSettingsUseDelKey;
   125 extern QAction* actionSettingsUseFlagGroups;
   126 extern QAction* actionSettingsUseHideExport;
   127 
   128 extern QMenu* branchContextMenu;
   129 extern QMenu* branchAddContextMenu;
   130 extern QMenu* branchRemoveContextMenu;
   131 extern QMenu* branchLinksContextMenuEdit;
   132 extern QMenu* branchLinksContextMenuFollow;
   133 extern QMenu* floatimageContextMenu;
   134 extern QMenu* saveImageFormatMenu;
   135 extern QMenu* canvasContextMenu;
   136 extern QMenu* fileLastMapsMenu;
   137 extern QMenu* fileImportMenu;
   138 extern QMenu* fileExportMenu;
   139 
   140 
   141 extern Settings settings;
   142 extern Options options;
   143 extern ImageIO imageIO;
   144 
   145 extern QDir vymBaseDir;
   146 extern QDir lastImageDir;
   147 extern QString iconPath;
   148 extern QString flagsPath;
   149 
   150 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
   151     QMainWindow(parent,name,f)
   152 {
   153 	mainWindow=this;
   154 
   155 	setCaption ("VYM - View Your Mind");
   156 
   157 	// Load window settings
   158 	resize (settings.readNumEntry( "/vym/mainwindow/geometry/width", 800),
   159 	        settings.readNumEntry( "/vym/mainwindow/geometry/height",600));
   160 	move   (settings.readNumEntry( "/vym/mainwindow/geometry/posX", 100),
   161 	        settings.readNumEntry( "/vym/mainwindow/geometry/posY", 100));
   162 
   163 
   164 	// Create unique temporary directory
   165 	tmpVymDir=makeUniqueDir ("/tmp/vym-XXXXXX");
   166 
   167 	// Create direcctory for clipboard
   168 	clipboardDir=tmpVymDir+"/clipboard";
   169 	QDir d(clipboardDir);
   170 	d.mkdir (clipboardDir,true);
   171 	makeSubDirs (clipboardDir);
   172 	clipboardEmpty=true;
   173 
   174 	procBrowser=NULL;
   175 
   176 	// FIXME not used currently
   177 	// Set random seed (random used for object IDs)
   178     // QTime t = QTime::currentTime();		// set random seed
   179     // srand( t.hour()*12+t.minute()*60+t.second()*60 );
   180 
   181 
   182 	// Initialize some settings, which are platform dependant
   183 	QString p,s;
   184 
   185 		// application to open URLs
   186 		p="/vym/mainwindow/readerURL";
   187 		#if defined(Q_OS_LINUX)
   188 			s=settings.readEntry (p,"konqueror");
   189 		#else
   190 			#if defined(Q_OS_MACX)
   191 				s=settings.readEntry (p,"/usr/bin/open");
   192 			#else
   193 				s=settings.readEntry (p,"mozilla");
   194 			#endif
   195 		#endif
   196 		settings.writeEntry( p,s);
   197 
   198 		// application to open PDFs
   199 		p="/vym/mainwindow/readerPDF";
   200 		#if defined(Q_OS_LINUX)
   201 			s=settings.readEntry (p,"acroread");
   202 		#else
   203 			#if defined(Q_OS_MACX)
   204 				s=settings.readEntry (p,"/usr/bin/open");
   205 			#else
   206 				s=settings.readEntry (p,"acroread");
   207 			#endif
   208 		#endif
   209 		settings.writeEntry( p,s);
   210 
   211 	
   212 	maxLastMaps=9;
   213 
   214 	// Create tab widget which holds the maps
   215 	tabWidget= new QTabWidget (this);
   216 	connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ), 
   217 		this, SLOT( editorChanged( QWidget * ) ) );
   218 
   219 	setCentralWidget(tabWidget);	
   220 
   221     setupFileActions();
   222     setupEditActions();
   223     setupFormatActions();
   224     setupViewActions();
   225     setupModeActions();
   226 	setupFlagActions();
   227     setupSettingsActions();
   228 	setupContextMenus();
   229     if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) setupTestActions();
   230     setupHelpActions();
   231     
   232 	// After menu is created, we can enable some actions
   233 //FIXME  QT3 testing	actionFilePrint->setEnabled (true);
   234 
   235     statusBar();
   236 
   237 
   238 	// Initialize Find window
   239 	findWindow=new FindWindow(NULL,"findwindow");
   240 	connect (findWindow, SIGNAL( findButton(QString) ), 
   241 		this, SLOT(editFind(QString) ) );	
   242 	connect (findWindow, SIGNAL( somethingChanged() ), 
   243 		this, SLOT(editFindChanged() ) );	
   244 
   245 	// Connect TextEditor, so that we can update flags if text changes
   246 	connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
   247 
   248 	updateGeometry();
   249 }
   250 
   251 Main::~Main()
   252 {
   253 	// Save Settings
   254 	settings.writeEntry( "/vym/mainwindow/geometry/width", width() );
   255 	settings.writeEntry( "/vym/mainwindow/geometry/height", height() );
   256 	settings.writeEntry( "/vym/mainwindow/geometry/posX", pos().x() );
   257 	settings.writeEntry( "/vym/mainwindow/geometry/posY", pos().y() );
   258 
   259 	settings.writeEntry( "/vym/version/version", __VYM_VERSION );
   260 	settings.writeEntry( "/vym/version/builddate", __BUILD_DATE );
   261 
   262 	settings.writeEntry( "/vym/mapeditor/editmode/autoselectheading",actionSettingsAutoselectHeading->isOn() );
   263 	settings.writeEntry( "/vym/mapeditor/editmode/autoselecttext",actionSettingsAutoselectText->isOn() );
   264 	settings.writeEntry( "/vym/mapeditor/editmode/pastenewheading",actionSettingsPasteNewHeading->isOn() );
   265 	settings.writeEntry( "/vym/mapeditor/editmode/autoedit",actionSettingsAutoedit->isOn() );
   266 	settings.writeEntry( "/vym/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
   267 	settings.writeEntry( "/vym/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
   268 	settings.writeEntry( "/vym/export/useHideExport",actionSettingsUseHideExport->isOn() );
   269 
   270 	QString s;
   271 	int maps=lastMaps.count();
   272 	settings.writeEntry( "/vym/lastMaps/number",maps );
   273 	for (int i=1;i<=maps;i++)
   274 	{
   275 		s=QString("/vym/lastMaps/map-%1").arg(i);
   276 		if (!s.isEmpty() && i<=maxLastMaps) 
   277 			settings.writeEntry (s, lastMaps.at(i-1));
   278 	}
   279 
   280 
   281 	// To make the texteditor save its settings, call the destructor
   282 	delete (textEditor);
   283 
   284 	// Remove temporary directory
   285 	removeDir (QDir(tmpVymDir));
   286 }
   287 
   288 void Main::loadCmdLine()
   289 {
   290 	/* TODO draw some kind of splashscreen while loading...
   291 	if (qApp->argc()>1)
   292 	{
   293 	}
   294 	*/
   295 	
   296 	QStringList flist=options.getFileList();
   297 	QStringList::Iterator it=flist.begin();
   298 
   299 	while (it !=flist.end() )
   300 	{
   301 		fileLoad (*it, NewMap);
   302 		*it++;
   303 	}	
   304 }
   305 
   306 
   307 void Main::statusMessage(const QString &s)
   308 {
   309 	statusBar()->message (s);
   310 }
   311 
   312 void Main::closeEvent (QCloseEvent* )
   313 {
   314 	fileExitVYM();
   315 }
   316 
   317 // File Actions
   318 void Main::setupFileActions()
   319 {
   320 	QMenu *fileMenu = menuBar()->addMenu ( tr ("&File") );
   321     QToolBar *tb = addToolBar( tr ("&File") );
   322 
   323     QAction *a;
   324     a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New..." ),this);
   325 	a->setStatusTip ( tr( "New map","File menu" ) );
   326 	a->setShortcut ( Qt::CTRL + Qt::Key_N );
   327     a->addTo( tb );
   328 	fileMenu->addAction (a);
   329     connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
   330 	
   331     a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ),this);
   332 	a->setStatusTip (tr( "Open","File menu" ) );
   333 	a->setShortcut ( Qt::CTRL + Qt::Key_O );
   334     a->addTo( tb );
   335 	fileMenu->addAction (a);
   336     connect( a, SIGNAL( activated() ), this, SLOT( fileLoad() ) );
   337 	
   338 	fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent"));
   339 	fileMenu->addSeparator();
   340 	
   341     a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save..." ), this);
   342 	a->setStatusTip ( tr( "Save" ));
   343 	a->setShortcut (Qt::CTRL + Qt::Key_S );
   344     a->addTo( tb );
   345 	fileMenu->addAction (a);
   346     connect( a, SIGNAL( activated() ), this, SLOT( fileSave() ) );
   347 	actionFileSave=a;
   348 	
   349     a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As..." ), this);
   350 	a->setStatusTip (tr( "Save &As" ) );
   351 	fileMenu->addAction (a);
   352     connect( a, SIGNAL( activated() ), this, SLOT( fileSaveAs() ) );
   353 
   354 	fileMenu->addSeparator();
   355 
   356 	fileImportMenu = fileMenu->addMenu (tr("Import"));
   357 
   358 	a = new QAction(tr("KDE Bookmarks"), this);
   359 	a->setStatusTip ( tr( "Import")+" "+tr("KDE Bookmarks" ));
   360 	a->addTo (fileImportMenu);
   361 	connect( a, SIGNAL( activated() ), this, SLOT( fileImportKDEBookmarks() ) );
   362 
   363     if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) 
   364 	{
   365 		a = new QAction( QPixmap(), tr("Firefox Bookmarks"),this);
   366 		a->setStatusTip (tr( "Import")+" "+tr("Firefox Bookmarks" ) );
   367 		a->addTo (fileImportMenu);
   368 		connect( a, SIGNAL( activated() ), this, SLOT( fileImportFirefoxBookmarks() ) );
   369 	}	
   370 
   371 	a = new QAction("Mind Manager...",this);
   372 	a->setStatusTip ( tr( "Import")+" Mind Manager"  );
   373 	fileImportMenu->addAction (a);
   374 	connect( a, SIGNAL( activated() ), this, SLOT( fileImportMM() ) );
   375 
   376     a = new QAction( tr( "Import Dir"+QString("...") ), this);
   377 	a->setStatusTip (tr( "Import directory structure (experimental)" ) );
   378 	fileImportMenu->addAction (a);
   379     connect( a, SIGNAL( activated() ), this, SLOT( fileImportDir() ) );
   380 
   381 	fileExportMenu = fileMenu->addMenu (tr("Export"));
   382 
   383 	a = new QAction( tr("Image")+QString("..."), this);
   384 	a->setStatusTip( tr( "Export map as image" ));
   385 	connect( a, SIGNAL( activated() ), this, SLOT( fileExportImage() ) );
   386 	fileExportMenu->addAction (a);
   387 
   388 	a = new QAction( "Open Office"+QString("..."), this);
   389 	a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office " ));
   390 	connect( a, SIGNAL( activated() ), this, SLOT( fileExportOOPresentation() ) );
   391 	fileExportMenu->addAction (a);
   392 
   393 	a = new QAction(  "Webpage (XHTML)...",this );
   394 	a->setShortcut (Qt::ALT + Qt::Key_X);
   395 	a->setStatusTip ( tr( "Export as")+" webpage (XHTML)");
   396     connect( a, SIGNAL( activated() ), this, SLOT( fileExportXHTML() ) );
   397 	fileExportMenu->addAction (a);
   398 
   399     a = new QAction( "Text (ASCII)...", this);
   400 	a->setStatusTip ( tr( "Export as")+" ASCII"+" "+tr("(still experimental)" ));
   401     connect( a, SIGNAL( activated() ), this, SLOT( fileExportASCII() ) );
   402 	fileExportMenu->addAction (a);
   403 
   404 	a = new QAction( tr("KDE Bookmarks"), this);
   405 	a->setStatusTip( tr( "Export as")+" "+tr("KDE Bookmarks" ));
   406 	connect( a, SIGNAL( activated() ), this, SLOT( fileExportKDEBookmarks() ) );
   407 	fileExportMenu->addAction (a);
   408 
   409     a = new QAction( "Taskjuggler...", this );
   410     a->setStatusTip( tr( "Export as")+" Taskjuggler"+" "+tr("(still experimental)" ));
   411     connect( a, SIGNAL( activated() ), this, SLOT( fileExportTaskjuggler() ) );
   412 	fileExportMenu->addAction (a);
   413 
   414     a = new QAction( "LaTeX...", this);
   415     a->setStatusTip( tr( "Export as")+" LaTeX"+" "+tr("(still experimental)" ));
   416     connect( a, SIGNAL( activated() ), this, SLOT( fileExportLaTeX() ) );
   417 	fileExportMenu->addAction (a);
   418 
   419 	a = new QAction( "XML..." , this );
   420 	a->setStatusTip (tr( "Export as")+" XML");
   421     connect( a, SIGNAL( activated() ), this, SLOT( fileExportXML() ) );
   422 	fileExportMenu->addAction (a);
   423 
   424 	fileMenu->addSeparator();
   425 
   426     a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
   427 	a->setStatusTip ( tr( "Print" ) );
   428 	a->setShortcut (Qt::CTRL + Qt::Key_P );
   429     a->addTo( tb );
   430 	fileMenu->addAction (a);
   431     connect( a, SIGNAL( activated() ), this, SLOT( filePrint() ) );
   432 	actionFilePrint=a;
   433 
   434     a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map" ), this);
   435 	a->setStatusTip (tr( "Close Map" ) );
   436 	a->setShortcut (Qt::ALT + Qt::Key_C );
   437 	fileMenu->addAction (a);
   438     connect( a, SIGNAL( activated() ), this, SLOT( fileCloseMap() ) );
   439 
   440     a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit")+" "+__VYM, this);
   441 	a->setStatusTip ( tr( "Exit")+" "+__VYM );
   442 	a->setShortcut (Qt::CTRL + Qt::Key_Q );
   443 	fileMenu->addAction (a);
   444     connect( a, SIGNAL( activated() ), this, SLOT( fileExitVYM() ) );
   445 }
   446 
   447 
   448 //Edit Actions
   449 void Main::setupEditActions()
   450 {
   451     QToolBar *tb = addToolBar( tr ("&Edit") );
   452     tb->setLabel( "Edit Actions" );
   453     QMenu *editMenu = menuBar()->addMenu( tr("&Edit") );
   454 
   455     QAction *a;
   456 	QAction *alt;
   457     a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo" ),this);
   458     connect( a, SIGNAL( activated() ), this, SLOT( editUndo() ) );
   459 	a->setStatusTip (tr( "Undo" ) );
   460 	a->setShortcut ( Qt::CTRL + Qt::Key_Z );
   461 	a->setEnabled (false);
   462     tb->addAction (a);
   463 	editMenu->addAction (a);
   464 	actionEditUndo=a;
   465     
   466     if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) 
   467 	{
   468 		a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo" ), this); 
   469 		a->setStatusTip (tr( "Redo" ));
   470 		a->setShortcut (Qt::CTRL + Qt::Key_Y );
   471 		editMenu->addAction (a);
   472 		connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) );
   473 	}
   474    
   475 	editMenu->addSeparator();
   476     a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy" ), this);
   477 	a->setStatusTip ( tr( "Copy" ) );
   478 	a->setShortcut (Qt::CTRL + Qt::Key_C );
   479 	a->setEnabled (false);
   480     tb->addAction (a);
   481 	editMenu->addAction (a);
   482     connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
   483 	actionEditCopy=a;
   484 	
   485     a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t" ), this);
   486 	a->setStatusTip ( tr( "Cut" ) );
   487 	a->setShortcut (Qt::CTRL + Qt::Key_X );
   488 	a->setEnabled (false);
   489     tb->addAction (a);
   490 	editMenu->addAction (a);
   491 	actionEditCut=a;
   492     connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
   493 	
   494     a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste" ),this);
   495     connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
   496 	a->setStatusTip ( tr( "Paste" ) );
   497 	a->setShortcut ( Qt::CTRL + Qt::Key_V );
   498 	a->setEnabled (false);
   499     tb->addAction (a);
   500 	editMenu->addAction (a);
   501 	actionEditPaste=a;
   502 
   503     // Shortcuts to modify heading:
   504     a = new QAction(tr( "Edit heading" ),this);
   505 	a->setStatusTip ( tr( "edit Heading" ));
   506 	a->setShortcut ( Qt::Key_Enter);
   507 	a->setShortcutContext (Qt::WindowShortcut);
   508 	addAction (a);
   509     connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
   510 	actionListBranches.append(a);
   511     a = new QAction( tr( "Edit heading" ), this);
   512 	a->setStatusTip (tr( "edit Heading" ));
   513 	a->setShortcut (Qt::Key_Return );
   514 	a->setShortcutContext (Qt::WindowShortcut);
   515 	addAction (a);
   516     connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
   517 	actionListBranches.append(a);
   518 	editMenu->addAction (a);
   519 	actionEditHeading=a;
   520     a = new QAction( tr( "Edit heading" ), this);
   521 	a->setStatusTip (tr( "edit Heading" ));
   522 	a->setShortcut ( Qt::Key_F2 );
   523 	a->setShortcutContext (Qt::WindowShortcut);
   524 	addAction (a);
   525     connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
   526 	actionListBranches.append(a);
   527     
   528     // Shortcut to delete selection
   529     a = new QAction( tr( "Delete Selection" ),this);
   530 	a->setStatusTip (tr( "Delete Selection" ));
   531 	a->setShortcut ( Qt::Key_Delete);
   532 	a->setShortcutContext (Qt::WindowShortcut);
   533 	addAction (a);
   534     connect( a, SIGNAL( activated() ), this, SLOT( editDeleteSelection() ) );
   535 	actionEditDelete=a;
   536     
   537     // Shortcut to add branch
   538 	alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child" ), this);
   539 	alt->setStatusTip ( tr( "Add a branch as child of selection" ));
   540 	alt->setShortcut (Qt::Key_A);
   541 	alt->setShortcutContext (Qt::WindowShortcut);
   542 	addAction (alt);
   543 	connect( alt, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
   544 	a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child" ), this);
   545 	a->setStatusTip ( tr( "Add a branch as child of selection" ));
   546 	a->setShortcut (Qt::Key_Insert);	
   547     connect( a, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
   548 	actionListBranches.append(a);
   549 	#if defined (Q_OS_MACX)
   550 		// In OSX show different shortcut in menues, the keys work indepently always			
   551 		actionEditAddBranch=alt;
   552 	#else	
   553 		actionEditAddBranch=a;
   554 	#endif	
   555 	editMenu->addAction (actionEditAddBranch);
   556 	tb->addAction (actionEditAddBranch);
   557 
   558 
   559     // Add branch by inserting it at selection
   560 	a = new QAction(tr( "Add branch (insert)" ), this);
   561 	a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
   562 	a->setShortcut (Qt::ALT + Qt::Key_Insert );
   563 	a->setShortcutContext (Qt::WindowShortcut);
   564 	addAction (a);
   565     connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
   566 	a->setEnabled (false);
   567 	actionListBranches.append(a);
   568 	actionEditAddBranchHere=a;
   569 	a = new QAction(tr( "Add branch (insert)" ),this);
   570 	a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
   571 	a->setShortcut ( Qt::ALT + Qt::Key_A );
   572 	a->setShortcutContext (Qt::WindowShortcut);
   573 	addAction (a);
   574     connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
   575 	actionListBranches.append(a);
   576 
   577 	// Add branch above
   578     a = new QAction(tr( "Add branch above" ), this);
   579 	a->setStatusTip ( tr( "Add a branch above selection" ));
   580 	a->setShortcut (Qt::SHIFT+Qt::Key_Insert );
   581 	a->setShortcutContext (Qt::WindowShortcut);
   582 	addAction (a);
   583     connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
   584 	a->setEnabled (false);
   585 	actionListBranches.append(a);
   586 	actionEditAddBranchAbove=a;
   587     a = new QAction(tr( "Add branch above" ), this);
   588 	a->setStatusTip ( tr( "Add a branch above selection" ));
   589 	a->setShortcut (Qt::SHIFT+Qt::Key_A );
   590 	a->setShortcutContext (Qt::WindowShortcut);
   591 	addAction (a);
   592     connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
   593 	actionListBranches.append(a);
   594 
   595 	// Add branch below 
   596     a = new QAction(tr( "Add branch below" ), this);
   597 	a->setStatusTip ( tr( "Add a branch below selection" ));
   598 	a->setShortcut (Qt::CTRL +Qt::Key_Insert );
   599 	a->setShortcutContext (Qt::WindowShortcut);
   600 	addAction (a);
   601     connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
   602 	a->setEnabled (false);
   603 	actionListBranches.append(a);
   604 	actionEditAddBranchBelow=a;
   605     a = new QAction(tr( "Add branch below" ), this);
   606 	a->setStatusTip ( tr( "Add a branch below selection" ));
   607 	a->setShortcut (Qt::CTRL +Qt::Key_A );
   608 	a->setShortcutContext (Qt::WindowShortcut);
   609 	addAction (a);
   610     connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
   611 	actionListBranches.append(a);
   612 
   613     a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up" ), this);
   614 	a->setStatusTip ( tr( "Move branch up" ) );
   615 	a->setShortcut (Qt::Key_PageUp );
   616 	a->setEnabled (false);
   617     tb->addAction (a);
   618 	editMenu->addAction (a);
   619     connect( a, SIGNAL( activated() ), this, SLOT( editMoveUp() ) );
   620 	actionEditMoveUp=a;
   621 
   622     a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down" ),this);
   623     connect( a, SIGNAL( activated() ), this, SLOT( editMoveDown() ) );
   624 	a->setStatusTip (tr( "Move branch down" ) );
   625 	a->setShortcut ( Qt::Key_PageDown );
   626 	a->setEnabled (false);
   627     tb->addAction (a);
   628 	editMenu->addAction (a);
   629 	actionEditMoveDown=a;
   630 	
   631 
   632 	a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ),this);
   633 	a->setShortcut ( Qt::Key_ScrollLock );
   634 	a->setStatusTip (tr( "Scroll branch" ) );
   635     connect( a, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
   636 	alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ), this);
   637 	alt->setShortcut ( Qt::Key_S );
   638 	alt->setStatusTip (tr( "Scroll branch" )); 
   639     connect( alt, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
   640 	#if defined(Q_OS_MACX)
   641 		actionEditToggleScroll=alt;
   642 	#else	
   643 		actionEditToggleScroll=a;
   644 	#endif	
   645 	actionEditToggleScroll->setEnabled (false);
   646 	actionEditToggleScroll->setToggleAction(true);
   647     tb->addAction (actionEditToggleScroll);
   648     editMenu->addAction ( actionEditToggleScroll);
   649 	editMenu->addAction (actionEditToggleScroll);
   650 	actionListBranches.append(actionEditToggleScroll);
   651 	
   652     a = new QAction( tr( "Unscroll all scrolled branches" ), this);
   653 	a->setStatusTip (tr( "Unscroll all" ));
   654 	editMenu->addAction (a);
   655     connect( a, SIGNAL( activated() ), this, SLOT( editUnScrollAll() ) );
   656 	
   657 	editMenu->addSeparator();
   658 
   659 	a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find"+QString("...") ), this);
   660 	a->setStatusTip (tr( "Find" ) );
   661 	a->setShortcut (Qt::CTRL + Qt::Key_F );
   662 	editMenu->addAction (a);
   663     connect( a, SIGNAL( activated() ), this, SLOT( editOpenFindWindow() ) );
   664     
   665 	editMenu->addSeparator();
   666 
   667 	a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL" ), this);
   668 	a->setShortcut (Qt::CTRL + Qt::Key_U );
   669 	a->setShortcut (tr( "Open URL" ));
   670     tb->addAction (a);
   671 	a->setEnabled (false);
   672     connect( a, SIGNAL( activated() ), this, SLOT( editOpenURL() ) );
   673 	actionEditOpenURL=a;
   674 
   675 	a = new QAction( tr( "Open URL in new tab" ), this);
   676 	a->setStatusTip (tr( "Open URL in new tab" ));
   677 	a->setShortcut (Qt::CTRL+Qt::Key_U );
   678 	a->setEnabled (false);
   679     connect( a, SIGNAL( activated() ), this, SLOT( editOpenURLTab() ) );
   680 	actionEditOpenURLTab=a;
   681 
   682 	a = new QAction(QPixmap(), tr( "Edit URL"+QString("...") ), this);
   683 	a->setStatusTip ( tr( "Edit URL" ) );
   684 	a->setShortcut (Qt::SHIFT + Qt::CTRL+Qt::Key_U );
   685 	a->setShortcutContext (Qt::WindowShortcut);
   686 	a->setEnabled (false);
   687 	actionListBranches.append(a);
   688     connect( a, SIGNAL( activated() ), this, SLOT( editURL() ) );
   689 	actionEditURL=a;
   690 	
   691 	a = new QAction( tr( "Use heading for URL" ), this);
   692 	a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
   693 	a->setEnabled (false);
   694 	actionListBranches.append(a);
   695     connect( a, SIGNAL( activated() ), this, SLOT( editHeading2URL() ) );
   696 	actionEditHeading2URL=a;
   697     
   698 	a = new QAction(tr( "Create URL to Bugzilla" ), this);
   699 	a->setStatusTip ( tr( "Create URL to Bugzilla" ));
   700 	a->setEnabled (false);
   701 	actionListBranches.append(a);
   702     connect( a, SIGNAL( activated() ), this, SLOT( editBugzilla2URL() ) );
   703 	actionEditBugzilla2URL=a;
   704     
   705 	a = new QAction(tr( "Create URL to FATE" ), this);
   706 	a->setStatusTip ( tr( "Create URL to FATE" ));
   707 	a->setEnabled (false);
   708 	actionListBranches.append(a);
   709     connect( a, SIGNAL( activated() ), this, SLOT( editFATE2URL() ) );
   710 	actionEditFATE2URL=a;
   711 	
   712     a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Jump to map" ), this);
   713 	a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
   714     tb->addAction (a);
   715 	a->setEnabled (false);
   716     connect( a, SIGNAL( activated() ), this, SLOT( editOpenVymLink() ) );
   717 	actionEditOpenVymLink=a;
   718 	
   719     a = new QAction(tr( "Edit vym link"+QString("...") ), this);
   720 	a->setEnabled (false);
   721 	a->setStatusTip ( tr( "Edit link to another vym map" ));
   722     connect( a, SIGNAL( activated() ), this, SLOT( editVymLink() ) );
   723 	actionListBranches.append(a);
   724 	actionEditVymLink=a;
   725 
   726     a = new QAction(tr( "Delete vym link" ),this);
   727 	a->setStatusTip ( tr( "Delete link to another vym map" ));
   728 	a->setEnabled (false);
   729     connect( a, SIGNAL( activated() ), this, SLOT( editDeleteVymLink() ) );
   730 	actionEditDeleteVymLink=a;
   731 
   732     a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports" ), this);
   733 	a->setStatusTip ( tr( "Hide object in exports" ) );
   734 	a->setShortcut (Qt::Key_H );
   735 	a->setToggleAction(true);
   736     tb->addAction (a);
   737 	a->setEnabled (false);
   738     connect( a, SIGNAL( activated() ), this, SLOT( editToggleHideExport() ) );
   739 	actionEditToggleHideExport=a;
   740 
   741     a = new QAction(tr( "Edit Map Info"+QString("...") ),this);
   742 	a->setStatusTip ( tr( "Edit Map Info" ));
   743 	a->setEnabled (true);
   744     connect( a, SIGNAL( activated() ), this, SLOT( editMapInfo() ) );
   745 	actionEditMapInfo=a;
   746 
   747 	editMenu->addSeparator();
   748 
   749 	// Import at selection (adding to selection)
   750     a = new QAction( tr( "Add map (insert)" ),this);
   751 	a->setStatusTip (tr( "Add map at selection" ));
   752     connect( a, SIGNAL( activated() ), this, SLOT( editImportAdd() ) );
   753 	a->setEnabled (false);
   754 	actionListBranches.append(a);
   755 	actionEditImportAdd=a;
   756 
   757 	// Import at selection (replacing selection)
   758     a = new QAction( tr( "Add map (replace)" ), this);
   759 	a->setStatusTip (tr( "Replace selection with map" ));
   760     connect( a, SIGNAL( activated() ), this, SLOT( editImportReplace() ) );
   761 	a->setEnabled (false);
   762 	actionListBranches.append(a);
   763 	actionEditImportReplace=a;
   764 
   765 	// Save selection 
   766     a = new QAction( tr( "Save selection" ), this);
   767 	a->setStatusTip (tr( "Save selection" ));
   768     connect( a, SIGNAL( activated() ), this, SLOT( editSaveBranch() ) );
   769 	a->setEnabled (false);
   770 	actionListBranches.append(a);
   771 	actionEditSaveBranch=a;
   772 
   773 	// Only remove branch, not its childs
   774     a = new QAction(tr( "Remove only branch " ), this);
   775 	a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
   776 	a->setShortcut (Qt::ALT + Qt::Key_Delete );
   777     connect( a, SIGNAL( activated() ), this, SLOT( editRemoveBranchKeepChilds() ) );
   778 	a->setEnabled (false);
   779 	actionListBranches.append(a);
   780 	actionEditRemoveBranchKeepChilds=a;
   781 
   782 	// Only remove childs of a branch
   783     a = new QAction( tr( "Remove childs" ), this);
   784 	a->setStatusTip (tr( "Remove childs of branch" ));
   785 	a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
   786     connect( a, SIGNAL( activated() ), this, SLOT( editRemoveChilds() ) );
   787 	a->setEnabled (false);
   788 	actionListBranches.append(a);
   789 	actionEditRemoveChilds=a;
   790 
   791     // Shortcuts for navigating with cursor:
   792     a = new QAction(tr( "Select upper branch" ), this);
   793 	a->setStatusTip ( tr( "Select upper branch" ));
   794 	a->setShortcut (Qt::Key_Up );
   795 	a->setShortcutContext (Qt::WindowShortcut);
   796 	addAction (a);
   797     connect( a, SIGNAL( activated() ), this, SLOT( editUpperBranch() ) );
   798     a = new QAction( tr( "Select lower branch" ),this);
   799 	a->setStatusTip (tr( "Select lower branch" ));
   800 	a->setShortcut ( Qt::Key_Down );
   801 	a->setShortcutContext (Qt::WindowShortcut);
   802 	addAction (a);
   803     connect( a, SIGNAL( activated() ), this, SLOT( editLowerBranch() ) );
   804     a = new QAction(tr( "Select left branch" ), this);
   805 	a->setStatusTip ( tr( "Select left branch" ));
   806 	a->setShortcut (Qt::Key_Left );
   807 	a->setShortcutContext (Qt::WindowShortcut);
   808 	addAction (a);
   809     connect( a, SIGNAL( activated() ), this, SLOT( editLeftBranch() ) );
   810     a = new QAction( tr( "Select child branch" ), this);
   811 	a->setStatusTip (tr( "Select right branch" ));
   812 	a->setShortcut (Qt::Key_Right);
   813 	a->setShortcutContext (Qt::WindowShortcut);
   814 	addAction (a);
   815     connect( a, SIGNAL( activated() ), this, SLOT( editRightBranch() ) );
   816     a = new QAction( tr( "Select first branch" ), this);
   817 	a->setStatusTip (tr( "Select first branch" ));
   818 	a->setShortcut (Qt::Key_Home );
   819 	a->setShortcutContext (Qt::WindowShortcut);
   820 	addAction (a);
   821 	a->setEnabled (false);
   822 	editMenu->addAction (a);
   823 	actionListBranches.append(a);
   824 	actionEditSelectFirst=a;
   825     connect( a, SIGNAL( activated() ), this, SLOT( editFirstBranch() ) );
   826     a = new QAction( tr( "Select last branch" ),this);
   827 	a->setStatusTip (tr( "Select last branch" ));
   828 	a->setShortcut ( Qt::Key_End );
   829 	a->setShortcutContext (Qt::WindowShortcut);
   830 	addAction (a);
   831     connect( a, SIGNAL( activated() ), this, SLOT( editLastBranch() ) );
   832 	a->setEnabled (false);
   833 	editMenu->addAction (a);
   834 	actionListBranches.append(a);
   835 	actionEditSelectLast=a;
   836 
   837     a = new QAction( tr( "Add Image" )+QString("..."), this);
   838 	a->setStatusTip (tr( "Add Image" ));
   839     connect( a, SIGNAL( activated() ), this, SLOT( editLoadImage() ) );
   840 	actionEditLoadImage=a;
   841 
   842 }
   843 
   844 // Format Actions
   845 void Main::setupFormatActions()
   846 {
   847     QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat"));
   848 
   849     QToolBar *tb = addToolBar( tr("Format Actions","Toolbars"));
   850     QAction *a;
   851     QPixmap pix( 16,16);
   852     pix.fill (Qt::black);
   853     a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
   854 	a->setStatusTip ( tr( "Set Color" ));
   855     connect( a, SIGNAL( activated() ), this, SLOT( formatSelectColor() ) );
   856     a->addTo( tb );
   857 	formatMenu->addAction (a);
   858 	actionFormatColor=a;
   859     a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color" ), this);
   860 	a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
   861 	a->setShortcut (Qt::CTRL + Qt::Key_K );
   862     connect( a, SIGNAL( activated() ), this, SLOT( formatPickColor() ) );
   863 	a->setEnabled (false);
   864     a->addTo( tb );
   865 	formatMenu->addAction (a);
   866 	actionListBranches.append(a);
   867 	actionFormatPickColor=a;
   868 
   869     a= new QAction(QPixmap(iconPath+"formatcoloritem.png"), tr( "Color &branch" ), this);
   870 	a->setStatusTip ( tr( "Color branch" ) );
   871 	a->setShortcut (Qt::CTRL + Qt::Key_I);
   872     connect( a, SIGNAL( activated() ), this, SLOT( formatColorItem() ) );
   873 	a->setEnabled (false);
   874     a->addTo( tb );
   875 	formatMenu->addAction (a);
   876 	actionListBranches.append(a);
   877 	actionFormatColorBranch=a;
   878 
   879     a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color sub&tree" ), this);
   880 	a->setStatusTip ( tr( "Color Subtree" ));
   881 	a->setShortcut (Qt::CTRL + Qt::Key_T);
   882     connect( a, SIGNAL( activated() ), this, SLOT( formatColorBranch() ) );
   883 	a->setEnabled (false);
   884 	formatMenu->addAction (a);
   885     a->addTo( tb );
   886 	actionListBranches.append(a);
   887 	actionFormatColorSubtree=a;
   888 
   889 	formatMenu->addSeparator();
   890 	actionGroupFormatLinkStyles=new QActionGroup ( this);
   891 	actionGroupFormatLinkStyles->setExclusive (true);
   892     a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
   893 	a->setStatusTip (tr( "Line" ));
   894 	a->setToggleAction(true);
   895     connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleLine() ) );
   896 	formatMenu->addAction (a);
   897 	actionFormatLinkStyleLine=a;
   898     a= new QAction( tr( "Linkstyle Parabel" ), actionGroupFormatLinkStyles);
   899 	a->setStatusTip (tr( "Line" ));
   900 	a->setToggleAction(true);
   901     connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleParabel() ) );
   902 	formatMenu->addAction (a);
   903 	actionFormatLinkStyleParabel=a;
   904     a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
   905 	a->setStatusTip (tr( "PolyLine" ));
   906 	a->setToggleAction(true);
   907     connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyLine() ) );
   908 	formatMenu->addAction (a);
   909 	actionFormatLinkStylePolyLine=a;
   910     a= new QAction( tr( "Linkstyle Thick Parabel" ), actionGroupFormatLinkStyles);
   911 	a->setStatusTip (tr( "PolyParabel" ) );
   912 	a->setToggleAction(true);
   913 	a->setChecked (true);
   914     connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyParabel() ) );
   915 	formatMenu->addAction (a);
   916 	actionFormatLinkStylePolyParabel=a;
   917 	
   918 	actionGroupFormatFrameTypes=new QActionGroup ( this);
   919 	actionGroupFormatFrameTypes->setExclusive (true);
   920     a = new QAction( tr( "No Frame" ), actionGroupFormatFrameTypes );
   921 	a->setStatusTip (tr("No Frame"));
   922 	a->setToggleAction(true);
   923     connect( a, SIGNAL( activated() ), this, SLOT( formatFrameNone() ) );
   924 	actionFormatFrameNone=a;
   925     a = new QAction( tr( "Rectangle" ), actionGroupFormatFrameTypes);
   926 	a->setStatusTip (tr( "Rectangle" ));
   927 	a->setToggleAction(true);
   928     connect( a, SIGNAL( activated() ), this, SLOT( formatFrameRectangle() ) );
   929 	actionFormatFrameRectangle=a;
   930 
   931     a = new QAction( tr( "Include images vertically" ),  actionFormatIncludeImagesVer);
   932 	a->setStatusTip ( tr ("Include top and bottom position of images into branch"));
   933 	a->setToggleAction(true);
   934     connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesVer() ) );
   935 	actionFormatIncludeImagesVer=a;
   936 
   937     a = new QAction( tr( "Include images horizontally" ),  actionFormatIncludeImagesHor );
   938 	a->setStatusTip ( tr ("Include left and right position of images into branch"));
   939 	a->setToggleAction(true);
   940     connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesHor() ) );
   941 	actionFormatIncludeImagesHor=a;
   942 
   943     a = new QAction( tr( "Hide link if object is not selected" ), actionFormatHideLinkUnselected);
   944 	a->setStatusTip (tr( "Hide link" ));
   945 	a->setToggleAction(true);
   946     connect( a, SIGNAL( activated() ), this, SLOT( formatHideLinkUnselected() ) );
   947 	actionFormatHideLinkUnselected=a;
   948 
   949 	formatMenu->addSeparator();
   950     a= new QAction( tr( "&Use color of heading for link" ),  this);
   951 	a->setStatusTip (tr( "Use same color for links and headings" ));
   952 	a->setToggleAction(true);
   953     connect( a, SIGNAL( activated() ), this, SLOT( formatToggleLinkColorHint() ) );
   954 	formatMenu->addAction (a);
   955 	actionFormatLinkColorHint=a;
   956 
   957     pix.fill (Qt::white);
   958     a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this  );
   959 	a->setStatusTip (tr( "Set Link Color" ));
   960 	formatMenu->addAction (a);
   961     connect( a, SIGNAL( activated() ), this, SLOT( formatSelectLinkColor() ) );
   962     actionFormatLinkColor=a;
   963 
   964     a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
   965 	a->setStatusTip (tr( "Set Background Color" ));
   966 	formatMenu->addAction (a);
   967     connect( a, SIGNAL( activated() ), this, SLOT( formatSelectBackColor() ) );
   968     actionFormatBackColor=a;
   969 }
   970 
   971 // View Actions
   972 void Main::setupViewActions()
   973 {
   974     QToolBar *tb = addToolBar( tr("View Actions","Toolbars") );
   975     tb->setLabel( "View Actions" );
   976     QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
   977 
   978     QAction *a;
   979     a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom" ), this);
   980 	a->setStatusTip ( tr( "Zoom reset" ) );
   981 	a->setShortcut (Qt::CTRL + Qt::Key_0 );
   982     a->addTo( tb );
   983 	viewMenu->addAction (a);
   984     connect( a, SIGNAL( activated() ), this, SLOT(viewZoomReset() ) );
   985 	
   986     a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in" ), this);
   987 	a->setStatusTip (tr( "Zoom in" ));
   988 	a->setShortcut (Qt::CTRL + Qt::Key_Plus);
   989     a->addTo( tb );
   990 	viewMenu->addAction (a);
   991     connect( a, SIGNAL( activated() ), this, SLOT(viewZoomIn() ) );
   992 	
   993     a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out" ), this);
   994 	a->setStatusTip (tr( "Zoom out" ));
   995 	a->setShortcut (Qt::CTRL + Qt::Key_Minus );
   996     a->addTo( tb );
   997 	viewMenu->addAction (a);
   998     connect( a, SIGNAL( activated() ), this, SLOT( viewZoomOut() ) );
   999 
  1000 
  1001     a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor" ),this);
  1002 	a->setStatusTip ( tr( "Show Note Editor" ));
  1003 	a->setShortcut ( Qt::CTRL + Qt::Key_E );
  1004 	a->setToggleAction(true);
  1005 	if (textEditor->showWithMain())
  1006 		a->setOn(true);
  1007 	else	
  1008 		a->setOn(false);
  1009     a->addTo( tb );
  1010 	viewMenu->addAction (a);
  1011     connect( a, SIGNAL( activated() ), this, SLOT(windowToggleNoteEditor() ) );
  1012 	actionViewToggleNoteEditor=a;
  1013 
  1014     a = new QAction(  tr( "Show history window" ),this );
  1015 	a->setStatusTip ( tr( "Show history window" ));
  1016 	a->setShortcut ( Qt::CTRL + Qt::Key_H  );
  1017 	a->setToggleAction(false);
  1018 	viewMenu->addAction (a);
  1019     connect( a, SIGNAL( activated() ), this, SLOT(windowToggleHistory() ) );
  1020 	actionViewToggleHistoryWindow=a;
  1021 
  1022     a = new QAction(tr( "Next Window" ), this);
  1023 	a->setStatusTip ( tr( "&Next Window" ) );
  1024 	a->setShortcut (Qt::ALT + Qt::Key_N );
  1025 	viewMenu->addAction (a);
  1026     connect( a, SIGNAL( activated() ), this, SLOT(windowNextEditor() ) );
  1027 
  1028     a = new QAction (tr( "Previous Window" ), this );
  1029 	a->setStatusTip (tr( "&Previous Window" ));
  1030 	a->setShortcut (Qt::ALT + Qt::Key_P );
  1031 	viewMenu->addAction (a);
  1032     connect( a, SIGNAL( activated() ), this, SLOT(windowPreviousEditor() ) );
  1033 }
  1034 
  1035 // Mode Actions
  1036 void Main::setupModeActions()
  1037 {
  1038     //QPopupMenu *menu = new QPopupMenu( this );
  1039     //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
  1040 
  1041     QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Toolbars") );
  1042     QAction *a;
  1043 	actionGroupModModes=new QActionGroup ( this);
  1044 	actionGroupModModes->setExclusive (true);
  1045     a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches" ), actionGroupModModes);
  1046 	a->setShortcut (Qt::Key_J);
  1047     a->setStatusTip ( tr( "Use modifier to color branches" ));
  1048 	a->setToggleAction(true);
  1049 	a->addTo (tb);
  1050 	a->setOn(true);
  1051 	actionModModeColor=a;
  1052 	
  1053     a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy" ), actionGroupModModes );
  1054 	a->setShortcut( Qt::Key_K); 
  1055     a->setStatusTip( tr( "Use modifier to copy" ));
  1056 	a->setToggleAction(true);
  1057 	a->addTo (tb);
  1058 	actionModModeCopy=a;
  1059 
  1060     a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks" ), actionGroupModModes );
  1061 	a->setShortcut (Qt::Key_L);
  1062     a->setStatusTip( tr( "Use modifier to draw xLinks" ));
  1063 	a->setToggleAction(true);
  1064 	a->addTo (tb);
  1065 	actionModModeLink=a;
  1066 }
  1067 
  1068 // Flag Actions
  1069 void Main::setupFlagActions()
  1070 {
  1071 	// Create System Flags
  1072 	systemFlagsDefault = new FlagRowObj ();
  1073 	systemFlagsDefault->setVisibility (false);
  1074 	systemFlagsDefault->setName ("systemFlagsDef");
  1075 
  1076 	FlagObj *fo = new FlagObj ();
  1077 	fo->load(QPixmap(flagsPath+"flag-note.png"));
  1078 	fo->setName("note");
  1079 	fo->setToolTip(tr("Note","Systemflag"));
  1080 	systemFlagsDefault->addFlag (fo);	// makes deep copy
  1081 
  1082 	fo->load(QPixmap(flagsPath+"flag-url.png"));
  1083 	fo->setName("url");
  1084 	fo->setToolTip(tr("WWW Document (external)","Systemflag"));
  1085 	systemFlagsDefault->addFlag (fo);
  1086 	
  1087 	fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
  1088 	fo->setName("vymLink");
  1089 	fo->setToolTip(tr("Link to another vym map","Systemflag"));
  1090 	systemFlagsDefault->addFlag (fo);	
  1091 
  1092 	fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
  1093 	fo->setName("scrolledright");
  1094 	fo->setToolTip(tr("subtree is scrolled","Systemflag"));
  1095 	systemFlagsDefault->addFlag (fo);
  1096 	
  1097 	fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
  1098 	fo->setName("tmpUnscrolledright");
  1099 	fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
  1100 	systemFlagsDefault->addFlag (fo);
  1101 
  1102 	fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
  1103 	fo->setName("hideInExport");
  1104 	fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
  1105 	systemFlagsDefault->addFlag (fo);
  1106 
  1107 	// Create Standard Flags
  1108 	QToolBar *tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
  1109 
  1110 	standardFlagsDefault = new FlagRowObj ();
  1111 	standardFlagsDefault->setVisibility (false);
  1112 	standardFlagsDefault->setName ("standardFlagsDef");
  1113 	standardFlagsDefault->setToolBar (tb);
  1114 
  1115 	fo->load(QPixmap(flagsPath+"flag-exclamationmark.png"));
  1116 	fo->setName ("exclamationmark");
  1117 	fo->setGroup("standard-mark");
  1118 	QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
  1119 	tb->addAction (a);
  1120 	fo->setAction (a);
  1121 	a->setCheckable(true);
  1122 	a->setObjectName(fo->getName());
  1123 	a->setToolTip(tr("Take care!","Standardflag"));
  1124 	connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
  1125 	standardFlagsDefault->addFlag (fo);	// makes deep copy
  1126 	
  1127 	fo->load(QPixmap(flagsPath+"flag-questionmark.png"));
  1128 	fo->setName("questionmark");
  1129 	fo->setGroup("standard-mark");
  1130 	a=new QAction (fo->getPixmap(),fo->getName(),this);
  1131 	tb->addAction (a);
  1132 	fo->setAction (a);
  1133 	a->setCheckable(true);
  1134 	a->setObjectName(fo->getName());
  1135 	a->setToolTip(tr("Really?","Standardflag"));
  1136 	connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
  1137 	standardFlagsDefault->addFlag (fo);	
  1138 
  1139 	fo->load(QPixmap(flagsPath+"flag-hook-green.png"));
  1140 	fo->setName("hook-green");
  1141 	fo->setGroup("standard-hook");
  1142 	a=new QAction (fo->getPixmap(),fo->getName(),this);
  1143 	tb->addAction (a);
  1144 	fo->setAction (a);
  1145 	a->setCheckable(true);
  1146 	a->setObjectName(fo->getName());
  1147 	a->setToolTip(tr("ok!","Standardflag"));
  1148 	connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
  1149 	standardFlagsDefault->addFlag (fo);	
  1150 
  1151 	fo->load(QPixmap(flagsPath+"flag-cross-red.png"));
  1152 	fo->setName("cross-red");
  1153 	fo->setGroup("standard-hook");
  1154 	a=new QAction (fo->getPixmap(),fo->getName(),this);
  1155 	tb->addAction (a);
  1156 	fo->setAction (a);
  1157 	a->setCheckable(true);
  1158 	a->setObjectName(fo->getName());
  1159 	a->setToolTip(tr("Not ok!","Standardflag"));
  1160 	connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
  1161 	standardFlagsDefault->addFlag (fo);	
  1162 
  1163 	fo->load(QPixmap(flagsPath+"flag-stopsign.png"));
  1164 	fo->setName("stopsign");
  1165 	a=new QAction (fo->getPixmap(),fo->getName(),this);
  1166 	tb->addAction (a);
  1167 	fo->setAction (a);
  1168 	a->setCheckable(true);
  1169 	a->setObjectName(fo->getName());
  1170 	a->setToolTip(tr("This won't work!","Standardflag"));
  1171 	connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
  1172 	standardFlagsDefault->addFlag (fo);	
  1173 
  1174 	fo->load(QPixmap(flagsPath+"flag-smiley-good.png"));
  1175 	fo->setName("smiley-good");
  1176 	fo->setGroup("standard-smiley");
  1177 	a=new QAction (fo->getPixmap(),fo->getName(),this);
  1178 	tb->addAction (a);
  1179 	fo->setAction (a);
  1180 	a->setCheckable(true);
  1181 	a->setObjectName(fo->getName());
  1182 	a->setToolTip(tr("Good","Standardflag"));
  1183 	connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
  1184 	standardFlagsDefault->addFlag (fo);	
  1185 
  1186 	fo->load(QPixmap(flagsPath+"flag-smiley-sad.png"));
  1187 	fo->setName("smiley-sad");
  1188 	fo->setGroup("standard-smiley");
  1189 	a=new QAction (fo->getPixmap(),fo->getName(),this);
  1190 	tb->addAction (a);
  1191 	fo->setAction (a);
  1192 	a->setCheckable(true);
  1193 	a->setObjectName(fo->getName());
  1194 	a->setToolTip(tr("Bad","Standardflag"));
  1195 	connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
  1196 	standardFlagsDefault->addFlag (fo);	
  1197 
  1198 	fo->load(QPixmap(flagsPath+"flag-smiley-omg.png"));
  1199 	// Original omg.png (in KDE emoticons)
  1200 	fo->setName("smiley-omg");
  1201 	fo->setGroup("standard-smiley");
  1202 	a=new QAction (fo->getPixmap(),fo->getName(),this);
  1203 	tb->addAction (a);
  1204 	fo->setAction (a);
  1205 	a->setCheckable(true);
  1206 	a->setObjectName(fo->getName());
  1207 	a->setToolTip(tr("Oh no!","Standardflag"));
  1208 	connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
  1209 	standardFlagsDefault->addFlag (fo);	
  1210 
  1211 	fo->load(QPixmap(flagsPath+"flag-kalarm.png"));
  1212 	fo->setName("clock");
  1213 	a=new QAction (fo->getPixmap(),fo->getName(),this);
  1214 	tb->addAction (a);
  1215 	fo->setAction (a);
  1216 	a->setCheckable(true);
  1217 	a->setObjectName(fo->getName());
  1218 	a->setToolTip(tr("Time critical","Standardflag"));
  1219 	connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
  1220 	standardFlagsDefault->addFlag (fo);	
  1221 
  1222 	fo->load(QPixmap(flagsPath+"flag-phone.png"));
  1223 	fo->setName("phone");
  1224 	a=new QAction (fo->getPixmap(),fo->getName(),this);
  1225 	tb->addAction (a);
  1226 	fo->setAction (a);
  1227 	a->setCheckable(true);
  1228 	a->setObjectName(fo->getName());
  1229 	a->setToolTip(tr("Call...","Standardflag"));
  1230 	connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
  1231 	standardFlagsDefault->addFlag (fo);	
  1232 
  1233 	fo->load(QPixmap(flagsPath+"flag-lamp.png"));
  1234 	fo->setName("lamp");
  1235 	a=new QAction (fo->getPixmap(),fo->getName(),this);
  1236 	tb->addAction (a);
  1237 	fo->setAction (a);
  1238 	a->setCheckable(true);
  1239 	a->setObjectName(fo->getName());
  1240 	a->setToolTip(tr("Idea!","Standardflag"));
  1241 	connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
  1242 	standardFlagsDefault->addFlag (fo);	
  1243 
  1244 	fo->load(QPixmap(flagsPath+"flag-arrow-up.png"));
  1245 	fo->setName("arrow-up");
  1246 	fo->setGroup("standard-arrow");
  1247 	a=new QAction (fo->getPixmap(),fo->getName(),this);
  1248 	tb->addAction (a);
  1249 	fo->setAction (a);
  1250 	a->setCheckable(true);
  1251 	a->setObjectName(fo->getName());
  1252 	a->setToolTip(tr("Important","Standardflag"));
  1253 	connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
  1254 	standardFlagsDefault->addFlag (fo);	
  1255 
  1256 	fo->load(QPixmap(flagsPath+"flag-arrow-down.png"));
  1257 	fo->setName("arrow-down");
  1258 	fo->setGroup("standard-arrow");
  1259 	a=new QAction (fo->getPixmap(),fo->getName(),this);
  1260 	tb->addAction (a);
  1261 	fo->setAction (a);
  1262 	a->setCheckable(true);
  1263 	a->setObjectName(fo->getName());
  1264 	a->setToolTip(tr("Unimportant","Standardflag"));
  1265 	connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
  1266 	standardFlagsDefault->addFlag (fo);	
  1267 
  1268 	fo->load(QPixmap(flagsPath+"flag-arrow-2up.png"));
  1269 	fo->setName("2arrow-up");
  1270 	fo->setGroup("standard-arrow");
  1271 	a=new QAction (fo->getPixmap(),fo->getName(),this);
  1272 	tb->addAction (a);
  1273 	fo->setAction (a);
  1274 	a->setCheckable(true);
  1275 	a->setObjectName(fo->getName());
  1276 	a->setToolTip(tr("Very important!","Standardflag"));
  1277 	connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
  1278 	standardFlagsDefault->addFlag (fo);	
  1279 
  1280 	fo->load(QPixmap(flagsPath+"flag-arrow-2down.png"));
  1281 	fo->setName("2arrow-down");
  1282 	fo->setGroup("standard-arrow");
  1283 	a=new QAction (fo->getPixmap(),fo->getName(),this);
  1284 	tb->addAction (a);
  1285 	fo->setAction (a);
  1286 	a->setCheckable(true);
  1287 	a->setObjectName(fo->getName());
  1288 	a->setToolTip(tr("Very unimportant!","Standardflag"));
  1289 	connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
  1290 	standardFlagsDefault->addFlag (fo);	
  1291 
  1292 	fo->load(QPixmap(flagsPath+"flag-thumb-up.png"));
  1293 	fo->setName("thumb-up");
  1294 	fo->setGroup("standard-thumb");
  1295 	a=new QAction (fo->getPixmap(),fo->getName(),this);
  1296 	tb->addAction (a);
  1297 	fo->setAction (a);
  1298 	a->setCheckable(true);
  1299 	a->setObjectName(fo->getName());
  1300 	a->setToolTip(tr("I like this","Standardflag"));
  1301 	connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
  1302 	standardFlagsDefault->addFlag (fo);	
  1303 
  1304 	fo->load(QPixmap(flagsPath+"flag-thumb-down.png"));
  1305 	fo->setName("thumb-down");
  1306 	fo->setGroup("standard-thumb");
  1307 	a=new QAction (fo->getPixmap(),fo->getName(),this);
  1308 	tb->addAction (a);
  1309 	fo->setAction (a);
  1310 	a->setCheckable(true);
  1311 	a->setObjectName(fo->getName());
  1312 	a->setToolTip(tr("I do not like this","Standardflag"));
  1313 	connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
  1314 	standardFlagsDefault->addFlag (fo);	
  1315 	
  1316 	fo->load(QPixmap(flagsPath+"flag-rose.png"));
  1317 	fo->setName("rose");
  1318 	a=new QAction (fo->getPixmap(),fo->getName(),this);
  1319 	tb->addAction (a);
  1320 	fo->setAction (a);
  1321 	a->setCheckable(true);
  1322 	a->setObjectName(fo->getName());
  1323 	a->setToolTip(tr("Rose","Standardflag"));
  1324 	connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
  1325 	standardFlagsDefault->addFlag (fo);	
  1326 
  1327 	fo->load(QPixmap(flagsPath+"flag-heart.png"));
  1328 	fo->setName("heart");
  1329 	a=new QAction (fo->getPixmap(),fo->getName(),this);
  1330 	tb->addAction (a);
  1331 	a->setCheckable(true);
  1332 	a->setObjectName(fo->getName());
  1333 	a->setToolTip(tr("I just love... ","Standardflag"));
  1334 	connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
  1335 	standardFlagsDefault->addFlag (fo);	
  1336 
  1337 	fo->load(QPixmap(flagsPath+"flag-present.png"));
  1338 	fo->setName("present");
  1339 	a=new QAction (fo->getPixmap(),fo->getName(),this);
  1340 	tb->addAction (a);
  1341 	fo->setAction (a);
  1342 	a->setCheckable(true);
  1343 	a->setObjectName(fo->getName());
  1344 	a->setToolTip(tr("Surprise!","Standardflag"));
  1345 	connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
  1346 	standardFlagsDefault->addFlag (fo);	
  1347 
  1348 	fo->load(QPixmap(flagsPath+"flag-flash.png"));
  1349 	fo->setName("flash");
  1350 	a=new QAction (fo->getPixmap(),fo->getName(),this);
  1351 	tb->addAction (a);
  1352 	fo->setAction (a);
  1353 	a->setCheckable(true);
  1354 	a->setObjectName(fo->getName());
  1355 	a->setToolTip(tr("Dangerous","Standardflag"));
  1356 	connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
  1357 	standardFlagsDefault->addFlag (fo);	
  1358 	
  1359 	fo->load(QPixmap(flagsPath+"flag-info.png"));
  1360 	// Original: xsldbg_output.png
  1361 	fo->setName("info");
  1362 	a=new QAction (fo->getPixmap(),fo->getName(),this);
  1363 	tb->addAction (a);
  1364 	fo->setAction (a);
  1365 	a->setCheckable(true);
  1366 	a->setObjectName(fo->getName());
  1367 	a->setToolTip(tr("Info","Standardflag"));
  1368 	connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
  1369 	standardFlagsDefault->addFlag (fo);	
  1370 
  1371 	fo->load(QPixmap(flagsPath+"flag-lifebelt.png"));
  1372 	// Original khelpcenter.png
  1373 	fo->setName("lifebelt");
  1374 	a=new QAction (fo->getPixmap(),fo->getName(),this);
  1375 	tb->addAction (a);
  1376 	fo->setAction (a);
  1377 	a->setCheckable(true);
  1378 	a->setObjectName(fo->getName());
  1379 	a->setToolTip(tr("This will help","Standardflag"));
  1380 	connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
  1381 	standardFlagsDefault->addFlag (fo);	
  1382 
  1383 	delete (fo);
  1384 }
  1385 
  1386 // Settings Actions
  1387 void Main::setupSettingsActions()
  1388 {
  1389     QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
  1390 
  1391 	QAction *a;
  1392 
  1393     a = new QAction( tr( "Set application to open pdf files"), this);
  1394     a->setStatusTip ( tr( "Set application to open pdf files"));
  1395     connect( a, SIGNAL( activated() ), this, SLOT( settingsPDF() ) );
  1396 	settingsMenu->addAction (a);
  1397 
  1398     a = new QAction( tr( "Set application to open external links"), this);
  1399     a->setStatusTip( tr( "Set application to open external links"));
  1400     connect( a, SIGNAL( activated() ), this, SLOT( settingsURL() ) );
  1401 	settingsMenu->addAction (a);
  1402 
  1403 	settingsMenu->addSeparator();
  1404     a = new QAction( tr( "Edit branch after adding it" ), this );
  1405     a->setStatusTip( tr( "Edit branch after adding it" ));
  1406 	a->setToggleAction(true);
  1407 	a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoedit",true) );
  1408 	settingsMenu->addAction (a);
  1409 	actionSettingsAutoedit=a;
  1410 
  1411     a= new QAction( tr( "Select branch after adding it" ), this );
  1412     a->setStatusTip( tr( "Select branch after adding it" ));
  1413 	a->setToggleAction(true);
  1414 	a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselect",false) );
  1415 	settingsMenu->addAction (a);
  1416 	actionSettingsAutoselectHeading=a;
  1417 	
  1418     a= new QAction(tr( "Select existing heading" ), this);
  1419     a->setStatusTip( tr( "Select heading before editing" ));
  1420 	a->setToggleAction(true);
  1421 	a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselectexistingtext",true) );
  1422 	settingsMenu->addAction (a);
  1423 	actionSettingsAutoselectText=a;
  1424 	
  1425     a= new QAction(tr( "pasting into new branch" ), this );
  1426     a->setStatusTip( tr( "Pasting into new branch" ));
  1427 	a->setToggleAction(true);
  1428 	a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/newheadingisempty",true) );
  1429 	settingsMenu->addAction (a);
  1430 	actionSettingsPasteNewHeading=a;
  1431 	
  1432     a= new QAction( tr( "Delete key" ), this);
  1433     a->setStatusTip( tr( "Delete key for deleting branches" ));
  1434 	a->setToggleAction(true);
  1435 	a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useDelKey",false) );
  1436 	settingsMenu->addAction (a);
  1437     connect( a, SIGNAL( activated() ), this, SLOT( settingsToggleDelKey() ) );
  1438 	actionSettingsUseDelKey=a;
  1439 
  1440     a= new QAction( tr( "Exclusive flags" ), this);
  1441     a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
  1442 	a->setToggleAction(true);
  1443 	a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useFlagGroups",true) );
  1444 	settingsMenu->addAction (a);
  1445 	actionSettingsUseFlagGroups=a;
  1446 	
  1447     a= new QAction( tr( "Use hide flags" ), this);
  1448     a->setStatusTip( tr( "Use hide flag during exports " ));
  1449 	a->setToggleAction(true);
  1450 	a->setOn ( settings.readBoolEntry ("/vym/export/useHideExport",true) );
  1451 	settingsMenu->addAction (a);
  1452 	actionSettingsUseHideExport=a;
  1453 }
  1454 
  1455 // Test Actions
  1456 void Main::setupTestActions()
  1457 {
  1458     QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
  1459 
  1460     QAction *a;
  1461     a = new QAction( tr( "test flag" ), this);
  1462     a->setStatusTip( tr( "Call test function" ));
  1463     connect( a, SIGNAL( activated() ), this, SLOT( testFunction() ) );
  1464 	testMenu->addAction (a);
  1465 }
  1466 
  1467 // Help Actions
  1468 void Main::setupHelpActions()
  1469 {
  1470     QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help" ));
  1471 
  1472     QAction *a;
  1473     a = new QAction(  tr( "Open VYM Documentation (pdf) " ), this );
  1474     a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
  1475     connect( a, SIGNAL( activated() ), this, SLOT( helpDoc() ) );
  1476 	helpMenu->addAction (a);
  1477 
  1478     a = new QAction( tr( "About VYM" ), this);
  1479     a->setStatusTip( tr( "About VYM")+" "__VYM);
  1480     connect( a, SIGNAL( activated() ), this, SLOT( helpAbout() ) );
  1481 	helpMenu->addAction (a);
  1482 
  1483     a = new QAction( tr( "About QT" ), this);
  1484     a->setStatusTip( tr( "Information about QT toolkit" ));
  1485     connect( a, SIGNAL( activated() ), this, SLOT( helpAboutQT() ) );
  1486 	helpMenu->addAction (a);
  1487 }
  1488 
  1489 // Context Menus
  1490 void Main::setupContextMenus()
  1491 {
  1492 	QAction*a;
  1493 
  1494 	// Context Menu for branch or mapcenter
  1495 	branchContextMenu =new QMenu (this);
  1496 
  1497 		// Submenu "Add"
  1498 		branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
  1499 		branchAddContextMenu->addAction (actionEditPaste );
  1500 		branchAddContextMenu->addAction ( actionEditAddBranch );
  1501 		branchAddContextMenu->addAction ( actionEditAddBranchHere );
  1502 		branchAddContextMenu->addAction ( actionEditAddBranchAbove);
  1503 		branchAddContextMenu->addAction ( actionEditAddBranchBelow );
  1504 		branchAddContextMenu->addSeparator();	
  1505 		branchAddContextMenu->addAction ( actionEditLoadImage);
  1506 		branchAddContextMenu->addSeparator();	
  1507 		branchAddContextMenu->addAction ( actionEditLoadImage);
  1508 		branchAddContextMenu->addAction ( actionEditImportAdd );
  1509 		branchAddContextMenu->addAction ( actionEditImportReplace );
  1510 
  1511 		// Submenu "Remove"
  1512 		branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove"));
  1513 		branchRemoveContextMenu->addAction (actionEditCut);
  1514 		branchRemoveContextMenu->addAction ( actionEditDelete );
  1515 		branchRemoveContextMenu->addAction ( actionEditRemoveBranchKeepChilds );
  1516 		branchRemoveContextMenu->addAction ( actionEditRemoveChilds );
  1517 		
  1518 
  1519 	actionEditSaveBranch->addTo( branchContextMenu );
  1520 
  1521 	branchContextMenu->addSeparator();	
  1522 	branchContextMenu->addAction ( actionEditOpenURL );
  1523 	branchContextMenu->addAction ( actionEditOpenURLTab );
  1524 	branchContextMenu->addAction ( actionEditURL );
  1525 	branchContextMenu->addAction ( actionEditHeading2URL );
  1526 	branchContextMenu->addAction ( actionEditBugzilla2URL );
  1527     if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) 
  1528 	{
  1529 		branchContextMenu->addAction ( actionEditFATE2URL );
  1530 	}	
  1531 	branchContextMenu->addSeparator();	
  1532 	branchContextMenu->addAction ( actionEditOpenVymLink );
  1533 	branchContextMenu->addAction ( actionEditVymLink );
  1534 	branchContextMenu->addAction ( actionEditDeleteVymLink );
  1535 	
  1536 	branchContextMenu->addSeparator();	
  1537 	branchContextMenu->addAction ( actionFormatFrameNone );
  1538 	branchContextMenu->addAction ( actionFormatFrameRectangle);
  1539 
  1540 	branchContextMenu->addSeparator();	
  1541 	branchContextMenu->addAction ( actionFormatIncludeImagesVer );
  1542 	branchContextMenu->addAction ( actionFormatIncludeImagesHor );
  1543 	branchContextMenu->addAction ( actionFormatHideLinkUnselected );
  1544 
  1545 	// Context Menu for links in a branch menu
  1546 	// This will be populated "on demand" in MapEditor::updateActions
  1547 	branchContextMenu->addSeparator();	
  1548 	branchLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink"));
  1549 	branchLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink"));
  1550 	connect( branchLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
  1551 	connect( branchLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
  1552 	
  1553 	// Context menu for floatimage
  1554 	floatimageContextMenu =new QMenu (this);
  1555 	saveImageFormatMenu=floatimageContextMenu->addMenu (tr("Save image"));
  1556 
  1557     foreach (QByteArray format, QImageWriter::supportedImageFormats()) 
  1558 	{
  1559         QString text = tr("%1...").arg(QString(format).toUpper());
  1560 		a= new QAction (text,this);
  1561 		saveImageFormatMenu->addAction ( a );
  1562     }
  1563 
  1564 	floatimageContextMenu->addSeparator();	
  1565 	actionEditCopy->addTo( floatimageContextMenu );
  1566 	actionEditCut->addTo( floatimageContextMenu );
  1567 
  1568 	floatimageContextMenu->addSeparator();	
  1569 	floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
  1570 
  1571 	
  1572 	// Context menu for canvas
  1573 	canvasContextMenu =new QMenu (this);
  1574 	actionEditMapInfo->addTo( canvasContextMenu );
  1575 	canvasContextMenu->insertSeparator();	
  1576 	actionGroupFormatLinkStyles->addTo( canvasContextMenu );
  1577 	canvasContextMenu->insertSeparator();	
  1578 	actionFormatLinkColorHint->addTo( canvasContextMenu );
  1579 	actionFormatLinkColor->addTo( canvasContextMenu );
  1580 	actionFormatBackColor->addTo( canvasContextMenu );
  1581 
  1582 	// Menu for last opened files
  1583 	// Read settings initially
  1584 	QString s;
  1585 	int j=settings.readNumEntry( "/vym/lastMaps/number",0);
  1586 	for (int i=1;i<=j;i++)
  1587 	{
  1588 		s=settings.readEntry(QString("/vym/lastMaps/map-%1").arg(i),"");
  1589 		if (!s.isEmpty() && j<=maxLastMaps) 
  1590 			lastMaps.append(s);
  1591 	}
  1592 	setupLastMapsMenu();
  1593 	connect( fileLastMapsMenu, SIGNAL( triggered(QAction *) ), this, SLOT( fileLoadLast(QAction*) ) );
  1594 }
  1595 
  1596 void Main::setupLastMapsMenu()
  1597 {
  1598 	// Remove double entries
  1599 	QStringList::Iterator it=lastMaps.begin();
  1600 	QStringList::Iterator jt;
  1601 	while (it!=lastMaps.end() )
  1602 	{
  1603 		jt=it;
  1604 		++jt;
  1605 		while (jt!=lastMaps.end() )
  1606 		{
  1607 			if (*it == *jt)		
  1608 				jt=lastMaps.remove(jt);
  1609 			else	
  1610 				jt++;
  1611 		}
  1612 		it++;
  1613 	}	
  1614 
  1615 	// Limit length of list to maxLastMaps
  1616 	while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
  1617 	
  1618 	// build Menu from lastMaps string list
  1619 	fileLastMapsMenu->clear();
  1620 	for (it = lastMaps.begin(); it != lastMaps.end(); ++it ) 
  1621 		fileLastMapsMenu->addAction (*it );
  1622 }
  1623 
  1624 void Main::hideEvent (QHideEvent * )
  1625 {
  1626 	if (!textEditor->isMinimized() ) textEditor->hide();
  1627 }
  1628 
  1629 void Main::showEvent (QShowEvent * )
  1630 {
  1631 	if (textEditor->showWithMain()) textEditor->showNormal();
  1632 }
  1633 
  1634 bool Main::reallyWriteDirectory(const QString &dir)
  1635 {
  1636 	QStringList eList = QDir(dir).entryList();
  1637 	if (eList.first() ==".")  eList.pop_front();	// remove "."
  1638 	if (eList.first() =="..") eList.pop_front();	// remove "."
  1639 	if (!eList.isEmpty())
  1640 	{
  1641 		QMessageBox mb( __VYM,
  1642 			tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?").arg(dir),
  1643 		QMessageBox::Warning,
  1644 		QMessageBox::Yes ,
  1645 		QMessageBox::Cancel | QMessageBox::Default,
  1646 		QMessageBox::QMessageBox::NoButton );
  1647 
  1648 		mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
  1649 		mb.setButtonText( QMessageBox::No, tr("Cancel"));
  1650 		switch( mb.exec() ) 
  1651 		{
  1652 			case QMessageBox::Yes:
  1653 				// save 
  1654 				return true;
  1655 			case QMessageBox::Cancel:
  1656 				// do nothing
  1657 				return false;
  1658 		}
  1659 	}
  1660 	return true;
  1661 }
  1662 
  1663 QString Main::browseDirectory (const QString &caption)
  1664 {
  1665 	Q3FileDialog fd(this,caption);
  1666 	fd.setMode (Q3FileDialog::DirectoryOnly);
  1667 	fd.setCaption(__VYM " - "+caption);
  1668 	fd.show();
  1669 	
  1670 	if ( fd.exec() == QDialog::Accepted )
  1671 		return fd.selectedFile();
  1672 	else
  1673 		return "";
  1674 }
  1675 
  1676 MapEditor* Main::currentMapEditor() const
  1677 {
  1678     if ( tabWidget->currentPage() &&
  1679 	 tabWidget->currentPage()->inherits( "MapEditor" ) )
  1680 		return (MapEditor*)tabWidget->currentPage();
  1681     return NULL;	
  1682 }
  1683 
  1684 //TODO not used now, maybe use this for overview window later
  1685 void Main::newView() 
  1686 {
  1687     // Open a new view... have it delete when closed.
  1688     Main *m = new Main(0, 0, Qt::WDestructiveClose);
  1689     qApp->setMainWidget(m);
  1690     m->show();
  1691     qApp->setMainWidget(0);
  1692 }
  1693 
  1694 void Main::editorChanged(QWidget *)
  1695 {
  1696 	// Unselect all possibly selected objects
  1697 	// (Important to update note editor)
  1698 	int i;
  1699 	MapEditor *me;
  1700 	for (i=0;i<=tabWidget->count() -1;i++)
  1701 	{
  1702 		
  1703 		me=(MapEditor*)tabWidget->page(i);
  1704 		me->unselect();
  1705 	}	
  1706 	currentMapEditor()->reselect();
  1707 
  1708 	// Update actions to in menus and toolbars according to editor
  1709 	currentMapEditor()->updateActions();
  1710 }
  1711 
  1712 void Main::fileNew()
  1713 {
  1714 	QString fn="unnamed";
  1715 	MapEditor* medit = new MapEditor ( NULL,true);
  1716 	tabWidget->addTab (medit,fn);
  1717 	tabWidget->showPage(medit);
  1718 	medit->viewport()->setFocus();
  1719 	// For the very first map we do not have flagrows yet...
  1720 	medit->select("mc:");
  1721 }
  1722 
  1723 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
  1724 {
  1725 	ErrorCode err=success;
  1726 	
  1727 	// fn is usually the archive, mapfile the file after uncompressing
  1728 	QString mapfile;
  1729 
  1730 	// Make fn absolute (needed for unzip)
  1731 	fn=QDir (fn).absPath();
  1732 
  1733 	MapEditor *me;
  1734 
  1735 	if (lmode==NewMap)
  1736 	{
  1737 		// Check, if map is already loaded
  1738 		int i=0;
  1739 		while (i<=tabWidget->count() -1)
  1740 		{
  1741 			me=(MapEditor*)tabWidget->page(i);
  1742 			if (me->getFilePath() == fn)
  1743 			{
  1744 				// Already there, ask for confirmation
  1745 				QMessageBox mb( __VYM,
  1746 					tr("The map %1\nis already opened."
  1747 					"Opening the same map in multiple editors may lead \n"
  1748 					"to confusion when finishing working with vym."
  1749 					"Do you want to").arg(fn),
  1750 					QMessageBox::Warning,
  1751 					QMessageBox::Yes | QMessageBox::Default,
  1752 					QMessageBox::Cancel | QMessageBox::Escape,
  1753 					QMessageBox::NoButton);
  1754 				mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
  1755 				mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
  1756 				switch( mb.exec() ) 
  1757 				{
  1758 					case QMessageBox::Yes:
  1759 						// load anyway
  1760 						i=tabWidget->count();
  1761 						break;
  1762 					case QMessageBox::Cancel:
  1763 						// do nothing
  1764 						return aborted;
  1765 						break;
  1766 				}
  1767 			}
  1768 			i++;
  1769 		}
  1770 	}
  1771 
  1772 
  1773 	// Try to load map
  1774     if ( !fn.isEmpty() )
  1775 	{
  1776 		me = currentMapEditor();
  1777 		int tabIndex=tabWidget->currentPageIndex();
  1778 		// Check first, if mapeditor exists
  1779 		// If it is not default AND we want a new map, 
  1780 		// create a new mapeditor in a new tab
  1781 		if ( lmode==NewMap && (!me || !me->isDefault() ) )
  1782 		{
  1783 			me= new MapEditor ( NULL,true);
  1784 			tabWidget->addTab (me,fn);
  1785 			tabIndex=tabWidget->indexOf (me);
  1786 			tabWidget->setCurrentPage (tabIndex);
  1787 		}
  1788 		
  1789 		// Check, if file exists (important for creating new files
  1790 		// from command line
  1791 		if (!QFile(fn).exists() )
  1792 		{
  1793 			QMessageBox mb( __VYM,
  1794 				tr("This map does not exist:\n  %1\nDo you want to create a new one?").arg(fn),
  1795 				QMessageBox::Question,
  1796 				QMessageBox::Yes ,
  1797 				QMessageBox::Cancel | QMessageBox::Default,
  1798 				QMessageBox::NoButton );
  1799 
  1800 			mb.setButtonText( QMessageBox::Yes, tr("Create"));
  1801 			mb.setButtonText( QMessageBox::No, tr("Cancel"));
  1802 			switch( mb.exec() ) 
  1803 			{
  1804 				case QMessageBox::Yes:
  1805 					// Create new map
  1806 					currentMapEditor()->setFilePath(fn);
  1807 					tabWidget->setTabLabel (currentMapEditor(),
  1808 						currentMapEditor()->getFileName() );
  1809 					statusBar()->message( "Created " + fn , statusbarTime );
  1810 					return success;
  1811 						
  1812 				case QMessageBox::Cancel:
  1813 					// don't create new map
  1814 					statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
  1815 					fileCloseMap();
  1816 					return aborted;
  1817 			}
  1818 		}	
  1819 
  1820 
  1821 		//tabWidget->currentPage() won't be NULL here, because of above...
  1822 		tabWidget->showPage(me);
  1823 		me->viewport()->setFocus();
  1824 
  1825 		// Create temporary directory for packing
  1826 		char tmpdir1[]="/tmp/vym-XXXXXX";	
  1827 		QString tmpMapDir=mkdtemp(tmpdir1);
  1828 
  1829 		// Try to unzip file
  1830 		err=unzipDir (tmpMapDir,fn);
  1831 		if (err==nozip)
  1832 		{
  1833 			mapfile=fn;
  1834 			me->setZipped(false);
  1835 		} else
  1836 		{
  1837 			me->setZipped(true);
  1838 			
  1839 			// Look for mapname.xml
  1840 			mapfile= fn.left(fn.findRev(".",-1,true));
  1841 			mapfile=mapfile.section( '/', -1 );
  1842 			QFile file( tmpMapDir + "/" + mapfile + ".xml");
  1843 			if (!file.exists() )
  1844 			{
  1845 				// mapname.xml does not exist, well, 
  1846 				// maybe some renamed the mapname.vym file...
  1847 				// Try to find any .xml in the toplevel 
  1848 				// directory of the .vym file
  1849 				QStringList flist=QDir (tmpMapDir).entryList("*.xml");
  1850 				if (flist.count()==1) 
  1851 				{
  1852 					// Only one entry, take this one
  1853 					mapfile=tmpMapDir + "/"+flist.first();
  1854 				} else
  1855 				{
  1856 					for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it ) 
  1857 						*it=tmpMapDir + "/" + *it;
  1858 					// TODO Multiple entries, load all (but only the first one into this ME)
  1859 					//mainWindow->fileLoadFromTmp (flist);
  1860 					//returnCode=1;	// Silently forget this attempt to load
  1861 					qWarning ("MainWindow::load (fn)  multimap found...");
  1862 				}	
  1863 					
  1864 				if (flist.isEmpty() )
  1865 				{
  1866 					QMessageBox::critical( 0, tr( "Critical Load Error" ),
  1867 							   tr("Couldn't find a map (*.xml) in .vym archive.\n"));
  1868 					err=aborted;				   
  1869 				}	
  1870 			} //file doesn't exist	
  1871 			else
  1872 				mapfile=file.name();
  1873 		}
  1874 
  1875 		if (err!=aborted)
  1876 		{
  1877 			// Save existing filename in case  we import
  1878 			QString fn_org=me->getFilePath();
  1879 
  1880 			// Finally load map into mapEditor
  1881 			me->setFilePath (mapfile,fn);
  1882 			err=me->load(mapfile,lmode);
  1883 
  1884 			// Restore old (maybe empty) filepath, if this is an import
  1885 			if (lmode!=NewMap)
  1886 				me->setFilePath (fn_org);
  1887 		}	
  1888 
  1889 		// Finally check for errors and go home
  1890 		if (err==aborted) 
  1891 		{
  1892 			if (lmode==NewMap) fileCloseMap();
  1893 			statusBar()->message( "Could not load " + fn, statusbarTime );
  1894 		} else 
  1895 		{
  1896 			if (lmode==NewMap)
  1897 			{
  1898 				me->setFilePath (fn);
  1899 				tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
  1900 				if (fn.left(9)!="/tmp/vym-")
  1901 				{
  1902 					// Only append to lastMaps if not loaded from a tmpDir
  1903 					// e.g. imported bookmarks are in a tmpDir
  1904 					lastMaps.prepend(me->getFilePath() );
  1905 					setupLastMapsMenu();
  1906 				}
  1907 				actionFilePrint->setEnabled (true);
  1908 			}	
  1909 			statusBar()->message( "Loaded " + fn, statusbarTime );
  1910 		}	
  1911 
  1912 		// Delete tmpDir
  1913 		removeDir (QDir(tmpMapDir));
  1914 	}
  1915 	return err;
  1916 }
  1917 
  1918 
  1919 void Main::fileLoad(const LoadMode &lmode)
  1920 {
  1921 	Q3FileDialog *fd=new Q3FileDialog( this);
  1922 	if (!lastFileDir.isEmpty()) 
  1923 		fd->setDir (lastFileDir);
  1924 	fd->setMode (Q3FileDialog::ExistingFiles);
  1925 	fd->addFilter ("XML (*.xml)");
  1926 	fd->addFilter ("VYM map (*.vym *.vyp)");
  1927 	switch (lmode)
  1928 	{
  1929 		case NewMap:
  1930 			fd->setCaption(tr("Load vym map"));
  1931 			break;
  1932 		case ImportAdd:
  1933 			fd->setCaption(tr("Import: Add vym map to selection"));
  1934 			break;
  1935 		case ImportReplace:
  1936 			fd->setCaption(tr("Import: Replace selection with vym map"));
  1937 			break;
  1938 	}
  1939 	fd->show();
  1940 
  1941 	QString fn;
  1942 	if ( fd->exec() == QDialog::Accepted )
  1943 	{
  1944 		lastFileDir=fd->dirPath();
  1945 	    QStringList flist = fd->selectedFiles();
  1946 		QStringList::Iterator it = flist.begin();
  1947 		while( it != flist.end() ) 
  1948 		{
  1949 			fn = *it;
  1950 			fileLoad(*it, lmode);				   
  1951 			++it;
  1952 		}
  1953 	}
  1954 	delete (fd);
  1955 }
  1956 
  1957 void Main::fileLoad()
  1958 {
  1959 	fileLoad (NewMap);
  1960 }
  1961 
  1962 void Main::fileLoadLast(QAction *a)
  1963 {
  1964 	fileLoad(lastMaps.at(fileLastMapsMenu->actions().indexOf(a)) ,NewMap);
  1965 }
  1966 
  1967 void Main::fileSave(const SaveMode &savemode)
  1968 {
  1969 	// tmp dir for zipping 
  1970 	QString tmpMapDir;
  1971 	
  1972 	// Error codes
  1973 	ErrorCode err=success;
  1974 	
  1975 	QString safeFilePath;
  1976 
  1977 	bool saveZipped=currentMapEditor()->saveZipped();
  1978 
  1979 	MapEditor *	me=currentMapEditor();
  1980 	if (me)
  1981 	{
  1982 		QString fn=me->getFilePath();
  1983 		// filename=unnamed, filepath="" in constructor...
  1984 		if ( !fn.isEmpty() ) 
  1985 		{	
  1986 			// We have a filepath, go on saving			
  1987 			// First remove existing file, we 
  1988 			// don't want to add to old zip archives
  1989 			QFile f(fn);
  1990 			if (f.exists() ) 
  1991 				if (!f.remove())
  1992 					QMessageBox::warning( 0, tr( "Save Error" ),
  1993 						fn+   tr("\ncould not be removed before saving"));
  1994 
  1995 			// Look, if we should zip the data:
  1996 			if (!saveZipped)
  1997 			{
  1998 				QMessageBox mb( __VYM,
  1999 					tr("The map %1\ndid not use the compressed "
  2000 					"vym file format.\nWriting it uncompressed will also write images \n"
  2001 					"and flags and thus may overwrite files in the "
  2002 					"given directory\n\nDo you want to write the map").arg(fn),
  2003 					QMessageBox::Warning,
  2004 					QMessageBox::Yes | QMessageBox::Default,
  2005 					QMessageBox::No ,
  2006 					QMessageBox::Cancel | QMessageBox::Escape);
  2007 				mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
  2008 				mb.setButtonText( QMessageBox::No, tr("uncompressed") );
  2009 				mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
  2010 				switch( mb.exec() ) 
  2011 				{
  2012 					case QMessageBox::Yes:
  2013 						// save compressed (default file format)
  2014 						saveZipped=true;
  2015 						break;
  2016 					case QMessageBox::No:
  2017 						// save uncompressed
  2018 						saveZipped=false;
  2019 						break;
  2020 					case QMessageBox::Cancel:
  2021 						// do nothing
  2022 						return;
  2023 						break;
  2024 				}
  2025 			}
  2026 
  2027 			if (saveZipped)
  2028 			{
  2029 				char tmpdir1[]="/tmp/vym-XXXXXX";	
  2030 				tmpMapDir=mkdtemp(tmpdir1);
  2031 			
  2032 				safeFilePath=me->getFilePath();
  2033 				me->setFilePath (tmpMapDir+"/"+
  2034 					me->getMapName()+ ".xml",
  2035 					safeFilePath);
  2036 				me->save (savemode);
  2037 				me->setFilePath (safeFilePath);
  2038 				
  2039 				zipDir (tmpMapDir,fn);
  2040 			} // save zipped
  2041 			else
  2042 			{
  2043 				// Save unzipped. 
  2044 				safeFilePath=me->getFilePath();
  2045 				me->setFilePath (fn, safeFilePath);
  2046 				me->save (savemode);
  2047 				me->setFilePath (safeFilePath);
  2048 			} // save zipped 	
  2049 		} // filepath available
  2050 		else
  2051 		{
  2052 			// We have  no filepath yet,
  2053 			// call fileSaveAs() now, this will call fileSave() 
  2054 			// again.
  2055 			fileSaveAs(savemode);
  2056 		}
  2057     }
  2058 
  2059 	if (saveZipped && !tmpMapDir.isEmpty())
  2060 		// Delete tmpDir
  2061 		removeDir (QDir(tmpMapDir));
  2062 
  2063 	if (err==success)
  2064 	{
  2065 		statusBar()->message( 
  2066 			tr("Saved  %1").arg(me->getFilePath()), 
  2067 			statusbarTime );
  2068 		lastMaps.prepend(me->getFilePath() );
  2069 		setupLastMapsMenu();
  2070 	} else		
  2071 		statusBar()->message( 
  2072 			tr("Couldn't save ").arg(me->getFilePath()), 
  2073 			statusbarTime );
  2074 }
  2075 
  2076 void Main::fileSave()
  2077 {
  2078 	fileSave (CompleteMap);
  2079 }
  2080 
  2081 void Main::fileSaveAs(const SaveMode& savemode)
  2082 {
  2083 	QString fn;
  2084 
  2085 	if (currentMapEditor())
  2086 	{
  2087 		if (savemode==CompleteMap)
  2088 			fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
  2089 		else		
  2090 			fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
  2091 		if ( !fn.isEmpty() ) 
  2092 		{
  2093 			// Check for existing file
  2094 			if (QFile (fn).exists())
  2095 			{
  2096 				QMessageBox mb( __VYM,
  2097 					tr("The file %1\nexists already. Do you want to").arg(fn),
  2098 					QMessageBox::Warning,
  2099 					QMessageBox::Yes | QMessageBox::Default,
  2100 					QMessageBox::Cancel | QMessageBox::Escape,
  2101 					QMessageBox::NoButton);
  2102 				mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
  2103 				mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
  2104 				switch( mb.exec() ) 
  2105 				{
  2106 					case QMessageBox::Yes:
  2107 						// save 
  2108 						break;
  2109 					case QMessageBox::Cancel:
  2110 						// do nothing
  2111 						return;
  2112 						break;
  2113 				}
  2114 			} else
  2115 			{
  2116 				// New file, add extension to filename, if missing
  2117 				// This is always .vym or .vyp, depending on savemode
  2118 				if (savemode==CompleteMap)
  2119 				{
  2120 					if (!fn.contains (".vym") && !fn.contains (".xml"))
  2121 						fn +=".vym";
  2122 				} else		
  2123 				{
  2124 					if (!fn.contains (".vyp") && !fn.contains (".xml"))
  2125 						fn +=".vyp";
  2126 				}
  2127 			}
  2128 	
  2129 
  2130 
  2131 
  2132 			// Save now
  2133 			currentMapEditor()->setFilePath(fn);
  2134 			fileSave(savemode);
  2135 
  2136 			// Set name of tab
  2137 			if (savemode==CompleteMap)
  2138 				tabWidget->setTabLabel (currentMapEditor(),
  2139 					currentMapEditor()->getFileName() );
  2140 			return;
  2141 		} 
  2142 	}
  2143 }
  2144 
  2145 void Main::fileSaveAs()
  2146 {
  2147 	fileSaveAs (CompleteMap);
  2148 }
  2149 
  2150 void Main::fileImportKDEBookmarks()
  2151 {
  2152 	ImportKDEBookmarks im;
  2153 	im.transform();
  2154 	if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
  2155 		currentMapEditor()->setFilePath ("");
  2156 }
  2157 
  2158 void Main::fileImportFirefoxBookmarks()
  2159 {
  2160 	Q3FileDialog *fd=new Q3FileDialog( this);
  2161 	fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
  2162 	fd->setMode (Q3FileDialog::ExistingFiles);
  2163 	fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
  2164 	fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
  2165 	fd->show();
  2166 
  2167 	if ( fd->exec() == QDialog::Accepted )
  2168 	{
  2169 		ImportFirefoxBookmarks im;
  2170 	    QStringList flist = fd->selectedFiles();
  2171 		QStringList::Iterator it = flist.begin();
  2172 		while( it != flist.end() ) 
  2173 		{
  2174 			im.setFile (*it);
  2175 			if (im.transform() && 
  2176 				success==fileLoad (im.getTransformedFile(),NewMap) && 
  2177 				currentMapEditor() )
  2178 				currentMapEditor()->setFilePath ("");
  2179 			++it;
  2180 		}
  2181 	}
  2182 	delete (fd);
  2183 }
  2184 
  2185 void Main::fileImportMM()
  2186 {
  2187 	ImportMM im;
  2188 
  2189 	Q3FileDialog *fd=new Q3FileDialog( this);
  2190 	if (!lastFileDir.isEmpty()) 
  2191 		fd->setDir (lastFileDir);
  2192 	fd->setMode (Q3FileDialog::ExistingFiles);
  2193 	fd->addFilter ("Mind Manager (*.mmap)");
  2194 	fd->setCaption(tr("Import")+" "+"Mind Manager");
  2195 	fd->show();
  2196 
  2197 	if ( fd->exec() == QDialog::Accepted )
  2198 	{
  2199 		lastFileDir=fd->dirPath();
  2200 	    QStringList flist = fd->selectedFiles();
  2201 		QStringList::Iterator it = flist.begin();
  2202 		while( it != flist.end() ) 
  2203 		{
  2204 			im.setFile (*it);
  2205 			if (im.transform() && 
  2206 				success==fileLoad (im.getTransformedFile(),NewMap) && 
  2207 				currentMapEditor() )
  2208 				currentMapEditor()->setFilePath ("");
  2209 
  2210 			++it;
  2211 		}
  2212 	}
  2213 	delete (fd);
  2214 
  2215 }
  2216 
  2217 void Main::fileImportDir()
  2218 {
  2219 	if (currentMapEditor())
  2220 		currentMapEditor()->importDir();	
  2221 }
  2222 
  2223 void Main::fileExportXML()
  2224 {
  2225 	if (currentMapEditor())
  2226 	{
  2227 		QString dir=browseDirectory(tr("Export XML to directory"));
  2228 		if (dir !="" && reallyWriteDirectory(dir) )
  2229 			currentMapEditor()->exportXML(dir);
  2230 	}	
  2231 }
  2232 
  2233 
  2234 void Main::fileExportXHTML()
  2235 {
  2236 	MapEditor *me=currentMapEditor();
  2237 	QString dir;
  2238 	if (me)
  2239 	{
  2240 		ExportXHTMLDialog dia(this);
  2241 		dia.setFilePath (me->getFilePath() );
  2242 		dia.setMapName (me->getMapName() );
  2243 		dia.readSettings();
  2244 		
  2245 		if (dia.exec()==QDialog::Accepted)
  2246 		{
  2247 			QString dir=dia.getDir();
  2248 			// Check, if warnings should be used before overwriting
  2249 			// the output directory
  2250 			bool ok;
  2251 			if (dia.warnings()) 
  2252 				ok=reallyWriteDirectory(dir);
  2253 			else
  2254 				ok=true;
  2255 
  2256 			if (ok)
  2257 			{
  2258 				me->exportXML (dia.getDir() );
  2259 				dia.doExport(me->getMapName() );
  2260 				if (dia.hasChanged())
  2261 					me->setChanged();
  2262 			}	
  2263 		}
  2264 	}	
  2265 }
  2266 
  2267 void Main::fileExportImage()
  2268 {
  2269 	MapEditor *me=currentMapEditor();
  2270 	if (me)
  2271 	{
  2272 		QStringList fl;
  2273 		QFileDialog *fd=new QFileDialog (this);
  2274 		fd->setCaption (tr("Export map as image"));
  2275 		fd->setFileMode(QFileDialog::AnyFile);
  2276 		fd->setFilters  (imageIO.getFilters() );
  2277 		fd->setDirectory (lastImageDir);
  2278 		if (fd->exec())
  2279 		{
  2280 			fl=fd->selectedFiles();
  2281 			qWarning ("Selected "+fl.first()+"  filter: "+fd->selectedFilter());
  2282 			me->exportImage (fl.first(), imageIO.getType (fd->selectedFilter() ) );
  2283 		} 
  2284 	}
  2285 }
  2286 
  2287 void Main::fileExportASCII()
  2288 {
  2289 	MapEditor *me=currentMapEditor();
  2290 	if (me)
  2291 	{
  2292 		ExportASCII ex;
  2293 		ex.setMapCenter(me->getMapCenter());
  2294 		ex.addFilter ("TXT (*.txt)");
  2295 		ex.setCaption(__VYM " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
  2296 		if (ex.execDialog() ) 
  2297 		{
  2298 			me->setExportMode(true);
  2299 			ex.doExport();
  2300 			me->setExportMode(false);
  2301 		}
  2302 	}
  2303 }
  2304 
  2305 void Main::fileExportLaTeX()
  2306 {
  2307 	MapEditor *me=currentMapEditor();
  2308 	if (me)
  2309 	{
  2310 		ExportLaTeX ex;
  2311 		ex.setMapCenter(me->getMapCenter());
  2312 		ex.addFilter ("Tex (*.tex)");
  2313 		ex.setCaption(__VYM " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
  2314 		if (ex.execDialog() ) 
  2315 		{
  2316 			me->setExportMode(true);
  2317 			ex.doExport();
  2318 			me->setExportMode(false);
  2319 		}
  2320 	}
  2321 }
  2322 
  2323 void Main::fileExportKDEBookmarks()
  2324 {
  2325 	ExportKDEBookmarks ex;
  2326 	MapEditor *me=currentMapEditor();
  2327 	if (me)
  2328 	{
  2329 		ex.setMapCenter (me->getMapCenter() );
  2330 		ex.doExport();
  2331 	}	
  2332 }
  2333 
  2334 void Main::fileExportTaskjuggler()
  2335 {
  2336 	ExportTaskjuggler ex;
  2337 	MapEditor *me=currentMapEditor();
  2338 	if (me)
  2339 	{
  2340 		ex.setMapCenter (me->getMapCenter() );
  2341 		ex.setCaption ( __VYM " - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
  2342 		ex.addFilter ("Taskjuggler (*.tjp)");
  2343 		if (ex.execDialog() ) 
  2344 		{
  2345 			me->setExportMode(true);
  2346 			ex.doExport();
  2347 			me->setExportMode(false);
  2348 		}
  2349 	}	
  2350 }
  2351 
  2352 void Main::fileExportOOPresentation()
  2353 {
  2354 	ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to")+" Open Office");
  2355 	// TODO add preview in dialog
  2356 	//ImagePreview *p =new ImagePreview (fd);
  2357 	//fd->setContentsPreviewEnabled( TRUE );
  2358 	//fd->setContentsPreview( p, p );
  2359 	//fd->setPreviewMode( QFileDialog::Contents );
  2360 	fd->setCaption(__VYM " - " +tr("Export to")+" Open Office");
  2361 	fd->setDir (QDir().current());
  2362 	fd->show();
  2363 
  2364 	if ( fd->exec() == QDialog::Accepted )
  2365 	{
  2366 		QString fn=fd->selectedFile();
  2367 		//lastImageDir=fn.left(fn.findRev ("/"));
  2368 		if (currentMapEditor())
  2369 			currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());	
  2370 	}
  2371 }
  2372 
  2373 void Main::fileCloseMap()
  2374 {
  2375 	if (currentMapEditor())
  2376 	{
  2377 		if (currentMapEditor()->hasChanged())
  2378 		{
  2379 			QMessageBox mb( __VYM,
  2380 				tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
  2381 				QMessageBox::Warning,
  2382 				QMessageBox::Yes | QMessageBox::Default,
  2383 				QMessageBox::No,
  2384 				QMessageBox::Cancel | QMessageBox::Escape );
  2385 			mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
  2386 			mb.setButtonText( QMessageBox::No, tr("Discard changes"));
  2387 			switch( mb.exec() ) 
  2388 			{
  2389 				case QMessageBox::Yes:
  2390 					// save and close
  2391 					fileSave(CompleteMap);
  2392 					break;
  2393 				case QMessageBox::No:
  2394 				// close  without saving
  2395 					break;
  2396 				case QMessageBox::Cancel:
  2397 					// do nothing
  2398 				return;
  2399 			}
  2400 		} 
  2401 		currentMapEditor()->closeMap();
  2402 		tabWidget->removePage(currentMapEditor());
  2403 		if (tabWidget->count()==0)
  2404 			actionFilePrint->setEnabled (false);
  2405 	}	
  2406 }
  2407 
  2408 void Main::filePrint()
  2409 {
  2410 	if (currentMapEditor())
  2411 		currentMapEditor()->print();
  2412 }
  2413 
  2414 void Main::fileExitVYM()
  2415 {
  2416 	// Check if one or more editors have changed
  2417 	MapEditor *me;
  2418 	int i;
  2419 	for (i=0;i<=tabWidget->count() -1;i++)
  2420 	{
  2421 		
  2422 		me=(MapEditor*)tabWidget->page(i);
  2423 
  2424 		// If something changed, ask what to do
  2425 		if (me->isUnsaved())
  2426 		{
  2427 			tabWidget->setCurrentPage(i);
  2428 			QMessageBox mb( __VYM,
  2429 				tr("This map is not saved yet. Do you want to"),
  2430 				QMessageBox::Warning,
  2431 				QMessageBox::Yes | QMessageBox::Default,
  2432 				QMessageBox::No,
  2433 				QMessageBox::Cancel | QMessageBox::Escape );
  2434 			mb.setButtonText( QMessageBox::Yes, tr("Save map") );
  2435 			mb.setButtonText( QMessageBox::No, tr("Discard changes") );
  2436 			mb.show();
  2437 			mb.setActiveWindow();
  2438 			switch( mb.exec() ) {
  2439 				case QMessageBox::Yes:
  2440 					// save (the changed editors) and exit
  2441 					fileSave(CompleteMap);
  2442 					break;
  2443 				case QMessageBox::No:
  2444 					// exit without saving
  2445 					break;
  2446 				case QMessageBox::Cancel:
  2447 					// don't save and don't exit
  2448 				return;
  2449 			}
  2450 		}
  2451 	} // loop over all MEs	
  2452     qApp->quit();
  2453 }
  2454 
  2455 void Main::editUndo()
  2456 {
  2457 	if (currentMapEditor())
  2458 		currentMapEditor()->undo();
  2459 }
  2460 
  2461 void Main::editRedo()	   
  2462 {
  2463 	if (currentMapEditor())
  2464 		currentMapEditor()->redo();
  2465 }
  2466 
  2467 void Main::editCopy()
  2468 {
  2469 	if (currentMapEditor())
  2470 		currentMapEditor()->copy();
  2471 }
  2472 
  2473 void Main::editPaste()
  2474 {
  2475 	if (currentMapEditor())
  2476 		currentMapEditor()->paste();
  2477 }
  2478 
  2479 void Main::editCut()
  2480 {
  2481 	if (currentMapEditor())
  2482 		currentMapEditor()->cut();
  2483 }
  2484 
  2485 void Main::editOpenFindWindow()
  2486 {
  2487 	findWindow->popup();
  2488 	findWindow->raise();
  2489 	findWindow->setActiveWindow();
  2490 }
  2491 
  2492 void Main::editFind(QString s)
  2493 {
  2494 	bool cs=false;
  2495 	BranchObj *bo=currentMapEditor()->findText(s, cs);
  2496 	if (bo)
  2497 	{	
  2498 		statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
  2499 	} else
  2500 	{
  2501 		QMessageBox::information( findWindow, tr( "VYM -Information:" ),
  2502 							   tr("No matches found for \"%1\"").arg(s));
  2503 	}	
  2504 }
  2505 
  2506 void Main::editFindChanged()
  2507 {	// Notify editor, to abort the current find process
  2508 	currentMapEditor()->findReset();
  2509 }
  2510 
  2511 void Main::editOpenURL()
  2512 {
  2513 	// Open new browser
  2514 	if (currentMapEditor())
  2515 	{	
  2516 	    QString url=currentMapEditor()->getURL();
  2517 		if (url=="") return;
  2518 		QString browser=settings.readEntry("/vym/mainwindow/readerURL" );
  2519 		procBrowser = new Q3Process( this );
  2520 
  2521 		procBrowser->addArgument( browser);
  2522 		procBrowser->addArgument( url);
  2523 
  2524 		if ( !procBrowser->start() ) 
  2525 		{
  2526 			// try to set path to browser
  2527 			QMessageBox::warning(0, 
  2528 				tr("Warning"),
  2529 				tr("Couldn't find a viewer to open %1.\n").arg(url)+
  2530 				tr("Please use Settings->")+tr("Set application to open an URL"));
  2531 			settingsURL() ; 
  2532 		}	
  2533 	}	
  2534 }
  2535 void Main::editOpenURLTab()
  2536 {
  2537 	if (currentMapEditor())
  2538 	{	
  2539 	    QString url=currentMapEditor()->getURL();
  2540 		if (url=="") return;
  2541 		QString browser=settings.readEntry("/vym/mainwindow/readerURL" );
  2542 		if (procBrowser && procBrowser->isRunning())
  2543 		{
  2544 			if (browser.contains("konqueror"))
  2545 			{
  2546 				// Try to open new tab in existing konqueror started previously by vym
  2547 				Q3Process *p=new Q3Process (this);
  2548 				p->addArgument ("dcop");
  2549 				p->addArgument (QString("konqueror-%1").arg(procBrowser->processIdentifier()));
  2550 				p->addArgument ("konqueror-mainwindow#1");
  2551 				p->addArgument ("newTab");
  2552 				p->addArgument (url);
  2553 				if ( !p->start() ) 
  2554 					// try to set browser
  2555 					QMessageBox::warning(0, 
  2556 						tr("Warning"),
  2557 						tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
  2558 				return;		
  2559 			} else if (browser.contains ("firefox") || browser.contains ("mozilla") )
  2560 			{
  2561 				// Try to open new tab in firefox
  2562 				Q3Process *p=new Q3Process (this);
  2563 				p->addArgument (browser);
  2564 				p->addArgument ("-remote");
  2565 				p->addArgument (QString("openurl(%1,new-tab)").arg(url));
  2566 				if ( !p->start() ) 
  2567 					// try to set browser
  2568 					QMessageBox::warning(0, 
  2569 						tr("Warning"),
  2570 						tr("Couldn't start %1 to open a new tab").arg(browser));
  2571 				return;		
  2572 			}
  2573 		}
  2574 		// Open new browser
  2575 		editOpenURL();
  2576 	}	
  2577 }
  2578 
  2579 void Main::editURL()
  2580 {
  2581 	if (currentMapEditor())
  2582 	    currentMapEditor()->editURL();
  2583 }
  2584 
  2585 void Main::editHeading2URL()
  2586 {
  2587 	if (currentMapEditor())
  2588 	    currentMapEditor()->editHeading2URL();
  2589 }
  2590 
  2591 void Main::editBugzilla2URL()
  2592 {
  2593 	if (currentMapEditor())
  2594 	    currentMapEditor()->editBugzilla2URL();
  2595 }
  2596 
  2597 void Main::editFATE2URL()
  2598 {
  2599 	if (currentMapEditor())
  2600 	    currentMapEditor()->editFATE2URL();
  2601 }
  2602 
  2603 void Main::editOpenVymLink()
  2604 {
  2605 	// Get current path to map
  2606 	QString currentVymLink;
  2607 	if (currentMapEditor())
  2608 	{
  2609 		currentVymLink=currentMapEditor()->getVymLink();	
  2610 		// compare path with already loaded maps
  2611 		int index=-1;
  2612 		int i;
  2613 		MapEditor *me;
  2614 		for (i=0;i<=tabWidget->count() -1;i++)
  2615 		{
  2616 			me=(MapEditor*)tabWidget->page(i);
  2617 			if (currentVymLink==me->getFilePath() )
  2618 			{
  2619 				index=i;
  2620 				break;
  2621 			}
  2622 		}	
  2623 		if (index<0)
  2624 		// Load map
  2625 		{
  2626 			if (!QFile(currentVymLink).exists() )
  2627 				QMessageBox::critical( 0, tr( "Critical Error" ),
  2628 				   tr("Couldn't open map %1").arg(currentVymLink));
  2629 			else
  2630 			{
  2631 				fileLoad (currentVymLink, NewMap);
  2632 				tabWidget->setCurrentPage (tabWidget->count()-1);	
  2633 			}
  2634 		} else
  2635 			// Go to tab containing the map
  2636 			tabWidget->setCurrentPage (index);	
  2637 	}
  2638 }
  2639 
  2640 void Main::editVymLink()
  2641 {
  2642 	if (currentMapEditor())
  2643 		currentMapEditor()->editVymLink();	
  2644 }
  2645 
  2646 void Main::editDeleteVymLink()
  2647 {
  2648 	if (currentMapEditor())
  2649 		currentMapEditor()->deleteVymLink();	
  2650 }
  2651 
  2652 void Main::editToggleHideExport()
  2653 {
  2654 	if (currentMapEditor())
  2655 		currentMapEditor()->toggleHideExport();	
  2656 }
  2657 
  2658 void Main::editMapInfo()
  2659 {
  2660 	if (currentMapEditor())
  2661 		currentMapEditor()->editMapInfo();	
  2662 }
  2663 
  2664 void Main::editMoveUp()
  2665 {
  2666 	if (currentMapEditor())
  2667 	    currentMapEditor()->moveBranchUp();
  2668 }
  2669 
  2670 void Main::editMoveDown()
  2671 {
  2672 	if (currentMapEditor())
  2673 		currentMapEditor()->moveBranchDown();
  2674 }
  2675 
  2676 void Main::editToggleScroll()
  2677 {
  2678 	if (currentMapEditor())
  2679 	{
  2680 		currentMapEditor()->toggleScroll();	
  2681 	}	
  2682 }
  2683 
  2684 void Main::editUnScrollAll()
  2685 {
  2686 	if (currentMapEditor())
  2687 	{
  2688 		currentMapEditor()->unScrollAll();	
  2689 	}	
  2690 }
  2691 
  2692 void Main::editHeading()
  2693 {
  2694 	if (currentMapEditor())
  2695 		currentMapEditor()->editHeading();
  2696 }
  2697 
  2698 void Main::editNewBranch()
  2699 {
  2700 	if (currentMapEditor())
  2701 		currentMapEditor()->addNewBranch(0);
  2702 }
  2703 
  2704 void Main::editNewBranchHere()
  2705 {
  2706 	if (currentMapEditor())
  2707 		currentMapEditor()->addNewBranchHere();
  2708 }
  2709 
  2710 void Main::editNewBranchAbove()
  2711 {
  2712 	if (currentMapEditor())
  2713 		currentMapEditor()->addNewBranch(-1);
  2714 }
  2715 
  2716 void Main::editNewBranchBelow()
  2717 {
  2718 	if (currentMapEditor())
  2719 		currentMapEditor()->addNewBranch(1);
  2720 }
  2721 
  2722 void Main::editImportAdd()
  2723 {
  2724 	fileLoad (ImportAdd);
  2725 }
  2726 
  2727 void Main::editImportReplace()
  2728 {
  2729 	fileLoad (ImportReplace);
  2730 }
  2731 
  2732 void Main::editSaveBranch()
  2733 {
  2734 	fileSaveAs (PartOfMap);
  2735 }
  2736 
  2737 void Main::editRemoveBranchKeepChilds()
  2738 {
  2739 	if (currentMapEditor())
  2740 		currentMapEditor()->removeBranchKeepChilds();
  2741 }
  2742 
  2743 void Main::editRemoveChilds()
  2744 {
  2745 	if (currentMapEditor())
  2746 		currentMapEditor()->removeChilds();
  2747 }
  2748 
  2749 void Main::editDeleteSelection()
  2750 {
  2751 	if (currentMapEditor() && actionSettingsUseDelKey->isOn())
  2752 		currentMapEditor()->deleteSelection();
  2753 }
  2754 
  2755 void Main::editUpperBranch()
  2756 {
  2757 	if (currentMapEditor())
  2758 		currentMapEditor()->selectUpperBranch();
  2759 }
  2760 
  2761 void Main::editLowerBranch()
  2762 {
  2763 	if (currentMapEditor())
  2764 		currentMapEditor()->selectLowerBranch();
  2765 }
  2766 
  2767 void Main::editLeftBranch()
  2768 {
  2769 	if (currentMapEditor())
  2770 		currentMapEditor()->selectLeftBranch();
  2771 }
  2772 
  2773 void Main::editRightBranch()
  2774 {
  2775 	if (currentMapEditor())
  2776 		currentMapEditor()->selectRightBranch();
  2777 }
  2778 
  2779 void Main::editFirstBranch()
  2780 {
  2781 	if (currentMapEditor())
  2782 		currentMapEditor()->selectFirstBranch();
  2783 }
  2784 
  2785 void Main::editLastBranch()
  2786 {
  2787 	if (currentMapEditor())
  2788 		currentMapEditor()->selectLastBranch();
  2789 }
  2790 
  2791 void Main::editLoadImage()
  2792 {
  2793 	if (currentMapEditor())
  2794 		currentMapEditor()->loadFloatImage();
  2795 }
  2796 
  2797 void Main::editSaveImage(int item)
  2798 {
  2799 	if (currentMapEditor())
  2800 		currentMapEditor()->saveFloatImage(item);
  2801 }
  2802 
  2803 void Main::editFollowXLink(QAction *a)
  2804 {
  2805 
  2806 	if (currentMapEditor())
  2807 		currentMapEditor()->followXLink(branchLinksContextMenuFollow->actions().indexOf(a));
  2808 }
  2809 
  2810 void Main::editEditXLink(QAction *a)
  2811 {
  2812 	if (currentMapEditor())
  2813 		currentMapEditor()->editXLink(branchLinksContextMenuEdit->actions().indexOf(a));
  2814 }
  2815 
  2816 void Main::formatSelectColor()
  2817 {
  2818 	if (currentMapEditor())
  2819 	{
  2820 		QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
  2821 		if ( !col.isValid() ) return;
  2822 		currentMapEditor()->setColor( col );
  2823 		colorChanged( col );
  2824 	}	
  2825 }
  2826 
  2827 void Main::formatPickColor()
  2828 {
  2829 	if (currentMapEditor())
  2830 		colorChanged( currentMapEditor()->pickColor() );
  2831 }
  2832 
  2833 void Main::colorChanged(QColor c)
  2834 {
  2835     QPixmap pix( 16, 16 );
  2836     pix.fill( c );
  2837     actionFormatColor->setIconSet( pix );
  2838 }
  2839 
  2840 void Main::formatColorItem()
  2841 {
  2842 	if (currentMapEditor())
  2843 		currentMapEditor()->colorItem();
  2844 }
  2845 
  2846 void Main::formatColorBranch()
  2847 {
  2848 	if (currentMapEditor())
  2849 		currentMapEditor()->colorBranch();
  2850 }
  2851 
  2852 void Main::formatLinkStyleLine()
  2853 {
  2854 	if (currentMapEditor())
  2855 		currentMapEditor()->setLinkStyle(StyleLine);
  2856 }
  2857 
  2858 void Main::formatLinkStyleParabel()
  2859 {
  2860 	if (currentMapEditor())
  2861 		currentMapEditor()->setLinkStyle(StyleParabel);
  2862 }
  2863 
  2864 void Main::formatLinkStylePolyLine()
  2865 {
  2866 	if (currentMapEditor())
  2867 		currentMapEditor()->setLinkStyle(StylePolyLine);
  2868 }
  2869 
  2870 void Main::formatLinkStylePolyParabel()
  2871 {
  2872 	if (currentMapEditor())
  2873 		currentMapEditor()->setLinkStyle(StylePolyParabel);
  2874 }
  2875 
  2876 void Main::formatSelectBackColor()
  2877 {
  2878 	if (currentMapEditor())
  2879 		currentMapEditor()->selectBackgroundColor();
  2880 }
  2881 
  2882 void Main::formatSelectLinkColor()
  2883 {
  2884 	if (currentMapEditor())
  2885 		currentMapEditor()->selectLinkColor();
  2886 }
  2887 
  2888 void Main::formatToggleLinkColorHint()
  2889 {
  2890 	currentMapEditor()->toggleLinkColorHint();
  2891 }
  2892 
  2893 void Main::formatFrameNone()
  2894 {
  2895 	if (currentMapEditor())
  2896 		currentMapEditor()->setFrame(NoFrame);
  2897 }
  2898 
  2899 void Main::formatFrameRectangle()
  2900 {
  2901 	if (currentMapEditor())
  2902 		currentMapEditor()->setFrame(Rectangle);
  2903 }
  2904 
  2905 void Main::formatIncludeImagesVer()
  2906 {
  2907 	if (currentMapEditor())
  2908 		currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
  2909 }
  2910 
  2911 void Main::formatIncludeImagesHor()
  2912 {
  2913 	if (currentMapEditor())
  2914 		currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
  2915 }
  2916 
  2917 void Main::formatHideLinkUnselected()
  2918 {
  2919 	if (currentMapEditor())
  2920 		currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
  2921 }
  2922 
  2923 void Main::viewZoomReset()
  2924 {
  2925 	if (currentMapEditor())
  2926 	{
  2927 		QMatrix m;
  2928 		m.reset();
  2929 		currentMapEditor()->setWorldMatrix( m );
  2930 		currentMapEditor()->setViewCenter();
  2931 		currentMapEditor()->adjustCanvasSize();
  2932 	}	
  2933 }
  2934 
  2935 void Main::viewZoomIn()
  2936 {
  2937 	if (currentMapEditor())
  2938 	{
  2939 		QMatrix m = currentMapEditor()->worldMatrix();
  2940 		m.scale( 1.25, 1.25 );
  2941 		currentMapEditor()->setWorldMatrix( m );
  2942 		currentMapEditor()->setViewCenter();
  2943 		currentMapEditor()->adjustCanvasSize();
  2944 	}	
  2945 }
  2946 
  2947 void Main::viewZoomOut()
  2948 {
  2949 	if (currentMapEditor())
  2950 	{
  2951 		QMatrix m = currentMapEditor()->worldMatrix();
  2952 		m.scale( 0.8, 0.8 );
  2953 		currentMapEditor()->setWorldMatrix( m );
  2954 		currentMapEditor()->setViewCenter();
  2955 		currentMapEditor()->adjustCanvasSize();
  2956 	}	
  2957 }
  2958 
  2959 void Main::modModeColor()
  2960 {
  2961 }
  2962 
  2963 void Main::modModeLink()
  2964 {
  2965 }
  2966 
  2967 bool Main::settingsPDF()
  2968 {
  2969 	// Default browser is set in constructor
  2970 	bool ok;
  2971 	QString text = QInputDialog::getText(
  2972 		"VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
  2973 		settings.readEntry("/vym/mainwindow/readerPDF"), &ok, this );
  2974 	if (ok)
  2975 		settings.writeEntry ("/vym/mainwindow/readerPDF",text);
  2976 	return ok;
  2977 }
  2978 
  2979 
  2980 bool Main::settingsURL()
  2981 {
  2982 	// Default browser is set in constructor
  2983 	bool ok;
  2984 	QString text = QInputDialog::getText(
  2985 		"VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
  2986 		settings.readEntry("/vym/mainwindow/readerURL")
  2987 		, &ok, this );
  2988 	if (ok)
  2989 		settings.writeEntry ("/vym/mainwindow/readerURL",text);
  2990 	return ok;
  2991 }
  2992 
  2993 void Main::settingsToggleDelKey()
  2994 {
  2995 	if (actionSettingsUseDelKey->isOn())
  2996 	{
  2997 		actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
  2998 	} else
  2999 	{
  3000 		actionEditDelete->setAccel (QKeySequence (""));
  3001 	}
  3002 }
  3003 
  3004 void Main::windowToggleNoteEditor()
  3005 {
  3006 	if (textEditor->showWithMain() )
  3007 		windowHideNoteEditor();
  3008 	else	
  3009 		windowShowNoteEditor();
  3010 }
  3011 
  3012 void Main::windowToggleHistory()
  3013 {
  3014 	if (currentMapEditor())
  3015 		currentMapEditor()->toggleHistoryWindow();
  3016 }
  3017 
  3018 void Main::updateNoteFlag()
  3019 {
  3020 	if (currentMapEditor())
  3021 		currentMapEditor()->updateNoteFlag();
  3022 }
  3023 
  3024 void Main::windowShowNoteEditor()
  3025 {
  3026 	textEditor->setShowWithMain(true);
  3027 	textEditor->show();
  3028 	actionViewToggleNoteEditor->setOn (true);
  3029 }
  3030 
  3031 void Main::windowHideNoteEditor()
  3032 {
  3033 	textEditor->setShowWithMain(false);
  3034 	textEditor->hide();
  3035 	actionViewToggleNoteEditor->setOn (false);
  3036 }
  3037 
  3038 void Main::windowNextEditor()
  3039 {
  3040 	if (tabWidget->currentPageIndex() < tabWidget->count())
  3041 		tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
  3042 }
  3043 
  3044 void Main::windowPreviousEditor()
  3045 {
  3046 	if (tabWidget->currentPageIndex() >0)
  3047 		tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
  3048 }
  3049 
  3050 void Main::standardFlagChanged()
  3051 {
  3052 	currentMapEditor()->toggleStandardFlag(sender()->name());
  3053 }
  3054 
  3055 void Main::testFunction()
  3056 {
  3057 	currentMapEditor()->testFunction();
  3058 }
  3059 
  3060 void Main::helpDoc()
  3061 {
  3062 	QString docpath;
  3063 	#if defined(Q_OS_MACX)
  3064 		docpath="./vym.app/Contents/vym.pdf";
  3065 	#else
  3066 		// default path in SUSE LINUX
  3067 		docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
  3068 	#endif
  3069 
  3070 	if (!QFile (docpath).exists() )
  3071 	{
  3072 		// relative path for easy testing in tarball
  3073 		docpath="doc/vym.pdf";
  3074 		if (!QFile (docpath).exists() )
  3075 		{
  3076 			// relative path for testing while still writing vym.tex
  3077 			docpath="doc/tex/vym.pdf";
  3078 			if (!QFile (docpath).exists() )
  3079 			{
  3080 				// Try yet another one for Knoppix
  3081 				docpath="/usr/share/doc/packages/vym/vym.pdf";
  3082 				if (!QFile (docpath).exists() )
  3083 				{
  3084 					QMessageBox::critical(0, 
  3085 					tr("Critcal error"),
  3086 					tr("Couldn't find the documentation\n"
  3087 					"vym.pdf in various places."));
  3088 					return;
  3089 				}	
  3090 			}	
  3091 		}
  3092 	}
  3093 	
  3094 	Process *pdfProc = new Process();
  3095 	pdfProc->clearArguments();
  3096 	pdfProc->addArgument( settings.readEntry("/vym/mainwindow/readerPDF"));
  3097 	pdfProc->addArgument( docpath);
  3098 
  3099 	if ( !pdfProc->start() ) 
  3100 	{
  3101 		// error handling
  3102 		QMessageBox::warning(0, 
  3103 			tr("Warning"),
  3104 			tr("Couldn't find a viewer to open %1.\n").arg("vym.pdf")+
  3105 			tr("Please use Settings->")+tr("Set application to open PDF files"));
  3106 		settingsPDF();	
  3107 		return;
  3108 	}
  3109 }
  3110 
  3111 
  3112 void Main::helpAbout()
  3113 {
  3114 	AboutDialog ad;
  3115 	ad.setName ("aboutwindow");
  3116 	ad.setMinimumSize(500,500);
  3117 	ad.resize (QSize (500,500));
  3118 	ad.exec();
  3119 }
  3120 
  3121 void Main::helpAboutQT()
  3122 {
  3123 	QMessageBox::aboutQt( this, "Qt Application Example" );
  3124 }
  3125