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