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