mainwindow.cpp
author insilmaril
Wed, 18 May 2005 07:39:51 +0000
changeset 101 1d092be4fe33
parent 98 58adc2d2ed08
child 102 dba9303a1a5c
permissions -rw-r--r--
fixed some bugs in xlinks, more remove/insert functions
     1 #include "mainwindow.h"
     2 
     3 #include <qstatusbar.h>
     4 #include <qmessagebox.h>
     5 #include <qmenubar.h>
     6 #include <qapplication.h>
     7 #include <qpainter.h>
     8 #include <qprinter.h>
     9 #include <qfile.h>
    10 #include <qfiledialog.h>
    11 #include <qcolor.h>
    12 #include <qcolordialog.h>
    13 #include <qbitmap.h>
    14 #include <qinputdialog.h>
    15 #include <qdatetime.h>			// for random seed
    16 
    17 
    18 #include <iostream>
    19 #include <cstdlib>
    20 #include <typeinfo>
    21 
    22 #include "version.h"
    23 
    24 #include "icons/filenew.xpm"
    25 #include "icons/fileopen.xpm"
    26 #include "icons/filesave.xpm"
    27 #include "icons/fileprint.xpm"
    28 #include "icons/editundo.xpm"
    29 //#include "icons/editredo.xpm"	// TODO
    30 #include "icons/editcopy.xpm"
    31 #include "icons/editcut.xpm"
    32 #include "icons/editpaste.xpm"
    33 #include "icons/editmoveup.xpm"
    34 #include "icons/editmovedown.xpm"
    35 #include "icons/formatcoloritem.xpm"
    36 #include "icons/formatcolorbranch.xpm"
    37 #include "icons/formatcolorpicker.xpm"
    38 #include "icons/viewzoomreset.xpm"
    39 #include "icons/viewzoomin.xpm"
    40 #include "icons/viewzoomout.xpm"
    41 #include "icons/modecolor.xpm"
    42 #include "icons/modelink.xpm"
    43 #include "icons/modecopy.xpm"
    44 #include "icons/vym-48x48.xpm"
    45 #include "icons/flag-note.xpm"
    46 #include "icons/flag-url.xpm"
    47 #include "icons/flag-vymlink.xpm"	
    48 #include "icons/flag-scrolled-right.xpm"
    49 
    50 #include "flagrowobj.h"
    51 #include "texteditor.h"
    52 #include "mapeditor.h"
    53 #include "exporthtmldialog.h"
    54 #include "exportxhtmldialog.h"
    55 #include "showtextdialog.h"
    56 #include "process.h"
    57 #include "settings.h"
    58 #include "options.h"
    59 
    60 extern TextEditor *textEditor;
    61 extern Main *mainWindow;
    62 extern int statusbarTime;
    63 extern MapEditor *clipboardME;
    64 extern FlagRowObj* standardFlagsDefault;
    65 
    66 extern QPtrList <QAction> actionListBranches;
    67 
    68 extern QAction* actionFileSave;
    69 extern QAction* actionFilePrint;
    70 extern QAction* actionEditUndo;
    71 extern QAction *actionEditCopy;
    72 extern QAction *actionEditCut;
    73 extern QAction *actionEditPaste;
    74 extern QAction *actionEditMoveUp;
    75 extern QAction *actionEditMoveDown;
    76 extern QAction *actionEditToggleScroll;
    77 extern QAction* actionEditOpenURL;
    78 extern QAction* actionEditURL;
    79 extern QAction* actionEditHeading2URL;
    80 extern QAction* actionEditBugzilla2URL;
    81 extern QAction *actionEditOpenVymLink;
    82 extern QAction *actionEditVymLink;
    83 extern QAction *actionEditDeleteVymLink;
    84 extern QAction *actionEditMapInfo;
    85 extern QAction *actionEditHeading;
    86 extern QAction *actionEditDelete;
    87 extern QAction *actionEditAddBranch;
    88 extern QAction *actionEditAddBranchHere;
    89 extern QAction *actionEditAddBranchAbove;
    90 extern QAction *actionEditAddBranchBelow;
    91 extern QAction *actionEditRemoveBranchHere;
    92 extern QAction *actionEditRemoveChilds;
    93 extern QAction *actionEditImportAdd;
    94 extern QAction *actionEditImportReplace;
    95 extern QAction *actionEditSaveBranch;
    96 extern QAction *actionEditSelectFirst;
    97 extern QAction *actionEditSelectLast;
    98 extern QAction *actionEditLoadImage;
    99 extern QAction *actionEditToggleFloatExport;
   100 
   101 extern QAction* actionFormatColor;
   102 extern QAction* actionFormatPickColor;
   103 extern QAction* actionFormatColorBranch;
   104 extern QAction* actionFormatColorSubtree;
   105 extern QAction* actionFormatLinkColorHint;
   106 extern QAction* actionFormatBackColor;
   107 extern QAction* actionFormatLinkColor;
   108 
   109 extern QActionGroup* actionGroupModModes;
   110 extern QAction* actionModModeColor;
   111 extern QAction* actionModModeLink;
   112 extern QAction* actionModModeCopy;
   113 
   114 extern QActionGroup *actionGroupFormatFrameTypes;
   115 extern QAction *actionFormatFrameNone;
   116 extern QAction *actionFormatFrameRectangle;
   117 
   118 extern QActionGroup *actionGroupFormatLinkStyles;
   119 extern QAction *actionFormatLinkStyleLine;
   120 extern QAction *actionFormatLinkStyleParabel;
   121 extern QAction *actionFormatLinkStylePolyLine;
   122 extern QAction *actionFormatLinkStylePolyParabel;
   123 
   124 extern QAction *actionViewToggleNoteEditor;
   125 
   126 extern QAction* actionSettingsAutoedit;
   127 extern QAction* actionSettingsAutoselectHeading;
   128 extern QAction* actionSettingsAutoselectHeading;
   129 extern QAction* actionSettingsAutoselectText;
   130 extern QAction* actionSettingsPasteNewHeading;
   131 extern QAction* actionSettingsUseDelKey;
   132 
   133 extern QPopupMenu* branchContextMenu;
   134 extern QPopupMenu* branchAddContextMenu;
   135 extern QPopupMenu* branchRemoveContextMenu;
   136 extern QPopupMenu* branchLinksContextMenu;
   137 extern QPopupMenu* branchLinksContextMenuDup;
   138 extern QPopupMenu* floatimageContextMenu;
   139 extern QPopupMenu* saveImageFormatMenu;
   140 extern QPopupMenu* canvasContextMenu;
   141 extern QPopupMenu* lastMapsMenu;
   142 extern QPopupMenu* exportMenu;
   143 extern QPopupMenu* exportImageFormatMenu;
   144 
   145 
   146 extern Settings settings;
   147 extern Options options;
   148 
   149 #if defined(Q_OS_LINUX)
   150 extern void qt_wait_for_window_manager( QWidget* w );
   151 #endif
   152 
   153 Main::Main(QWidget* parent, const char* name, WFlags f) :
   154     QMainWindow(parent,name,f)
   155 {
   156 	mainWindow=this;
   157 
   158 	setCaption ("VYM - View Your Mind");
   159 
   160 	// Load window settings
   161 	resize (settings.readNumEntry( "/vym/mainwindow/geometry/width", 800),
   162 	        settings.readNumEntry( "/vym/mainwindow/geometry/height",600));
   163 	move   (settings.readNumEntry( "/vym/mainwindow/geometry/posX", 100),
   164 	        settings.readNumEntry( "/vym/mainwindow/geometry/posY", 100));
   165 
   166 
   167 	// Set random seed (random used for object IDs)
   168     QTime t = QTime::currentTime();		// set random seed
   169     srand( t.hour()*12+t.minute()*60+t.second()*60 );
   170 
   171 
   172 	// Initialize some settings, which are platform dependant
   173 	QString p,s;
   174 
   175 		// application to open URLs
   176 		p="/vym/mainwindow/readerURL";
   177 		#if defined(Q_OS_LINUX)
   178 			s=settings.readEntry (p,"konqueror");
   179 		#else
   180 			#if defined(Q_OS_MACX)
   181 				s=settings.readEntry (p,"/Applications/Safari.app/Contents/MacOS/Safari");
   182 			#else
   183 				s=settings.readEntry (p,"mozilla");
   184 			#endif
   185 		#endif
   186 		settings.writeEntry( p,s);
   187 
   188 		// application to open PDFs
   189 		p="/vym/mainwindow/readerPDF";
   190 		#if defined(Q_OS_LINUX)
   191 			s=settings.readEntry (p,"acroread");
   192 		#else
   193 			#if defined(Q_OS_MACX)
   194 				s=settings.readEntry (p,"/Applications/Safari.app/Contents/MacOS/Safari");
   195 			#else
   196 				s=settings.readEntry (p,"acroread");
   197 			#endif
   198 		#endif
   199 		settings.writeEntry( p,s);
   200 
   201 	
   202 	maxLastMaps=9;
   203 
   204 	// Create tab widget which holds the maps
   205 	tabWidget= new QTabWidget (this);
   206 	connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ), 
   207 		this, SLOT( editorChanged( QWidget * ) ) );
   208 
   209 	setCentralWidget(tabWidget);	
   210 
   211     setupFileActions();
   212     setupEditActions();
   213     setupFormatActions();
   214     setupViewActions();
   215     setupModeActions();
   216 	setupFlagActions();
   217     setupSettingsActions();
   218 	setupContextMenus();
   219     if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) setupTestActions();
   220     setupHelpActions();
   221     
   222 	// After menu is created, we can enable some actions
   223 	actionFilePrint->setEnabled (true);
   224 
   225     statusBar();
   226 
   227 
   228 	// Initialize Find window
   229 	findWindow=new FindWindow(NULL,"findwindow");
   230 	connect (findWindow, SIGNAL( findButton(QString) ), 
   231 		this, SLOT(editFind(QString) ) );	
   232 	connect (findWindow, SIGNAL( somethingChanged() ), 
   233 		this, SLOT(editFindChanged() ) );	
   234 
   235 	updateGeometry();
   236 
   237 	// Creating  the default map into first tab is done in main.cpp now...
   238 }
   239 
   240 Main::~Main()
   241 {
   242 	// Save Settings
   243 	settings.writeEntry( "/vym/mainwindow/geometry/width", width() );
   244 	settings.writeEntry( "/vym/mainwindow/geometry/height", height() );
   245 	settings.writeEntry( "/vym/mainwindow/geometry/posX", pos().x() );
   246 	settings.writeEntry( "/vym/mainwindow/geometry/posY", pos().y() );
   247 
   248 	settings.writeEntry( "/vym/version/version", __VYM_VERSION__ );
   249 	settings.writeEntry( "/vym/version/builddate", __BUILD_DATE__ );
   250 
   251 	settings.writeEntry( "/vym/mapeditor/editmode/autoselectheading",actionSettingsAutoselectHeading->isOn() );
   252 	settings.writeEntry( "/vym/mapeditor/editmode/autoselecttext",actionSettingsAutoselectText->isOn() );
   253 	settings.writeEntry( "/vym/mapeditor/editmode/pastenewheading",actionSettingsPasteNewHeading->isOn() );
   254 	settings.writeEntry( "/vym/mapeditor/editmode/autoedit",actionSettingsAutoedit->isOn() );
   255 	settings.writeEntry( "/vym/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
   256 
   257 	QString s;
   258 	int maps=lastMaps.count();
   259 	settings.writeEntry( "/vym/lastMaps/number",maps );
   260 	for (int i=1;i<=maps;i++)
   261 	{
   262 		QStringList::Iterator it = lastMaps.at(i-1);
   263 		s=QString("/vym/lastMaps/map-%1").arg(i);
   264 		if (!s.isEmpty() && i<=maxLastMaps) 
   265 			settings.writeEntry (s, *it);
   266 	}
   267 
   268 
   269 	// To make the texteditor save its settings, call the destructor
   270 	delete (textEditor);
   271 }
   272 
   273 void Main::loadCmdLine()
   274 {
   275 	/* TODO draw some kind of splashscreen while loading...
   276 	if (qApp->argc()>1)
   277 	{
   278 	}
   279 	*/
   280 	
   281 	QStringList flist=options.getFileList();
   282 	QStringList::Iterator it=flist.begin();
   283 
   284 	while (it !=flist.end() )
   285 	{
   286 		fileLoad (*it, NewMap);
   287 		*it++;
   288 	}	
   289 }
   290 
   291 
   292 void Main::statusMessage(const QString &s)
   293 {
   294 	statusBar()->message (s);
   295 }
   296 
   297 void Main::closeEvent (QCloseEvent* )
   298 {
   299 	fileExitVYM();
   300 }
   301 
   302 // File Actions
   303 void Main::setupFileActions()
   304 {
   305     QToolBar *tb = new QToolBar( this );
   306     tb->setLabel( "File Actions" );
   307     QPopupMenu *menu = new QPopupMenu( this );
   308     menuBar()->insertItem( tr( "&File" ), menu );
   309 
   310 	// Keycodes:  /usr/lib64/qt3/include/qnamespace.h
   311 
   312     QAction *a;
   313     a = new QAction( tr( "New map","File menu" ), QPixmap( filenew_xpm ), tr( "&New..." ), CTRL + Key_N, this, "fileNew" );
   314     connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
   315     a->addTo( tb );
   316     a->addTo( menu );
   317 	
   318     a = new QAction( tr( "Open","File menu" ), QPixmap( fileopen_xpm), tr( "&Open..." ), CTRL + Key_O, this, "fileOpen" );
   319     connect( a, SIGNAL( activated() ), this, SLOT( fileLoad() ) );
   320     a->addTo( tb );
   321     a->addTo( menu );
   322 	
   323 	lastMapsMenu = new QPopupMenu (this);
   324 
   325     menu->insertItem (tr("Open Recent"),lastMapsMenu );
   326     menu->insertSeparator();
   327 	
   328     a = new QAction( tr( "Save" ), QPixmap( filesave_xpm ), tr( "&Save..." ), CTRL + Key_S, this, "fileSave" );
   329     connect( a, SIGNAL( activated() ), this, SLOT( fileSave() ) );
   330     a->addTo( tb );
   331     a->addTo( menu );
   332 	actionFileSave=a;
   333 	
   334     a = new QAction( tr( "Save &As" ), QPixmap(), tr( "Save &As..." ), 0, this, "fileSaveAs" );
   335     connect( a, SIGNAL( activated() ), this, SLOT( fileSaveAs() ) );
   336     a->addTo( menu );
   337 
   338     menu->insertSeparator();
   339 
   340     a = new QAction( tr( "Import directory structure (experimental)" ), QPixmap(), tr( "Import Dir" ), 0, this, "export" );
   341     connect( a, SIGNAL( activated() ), this, SLOT( fileImportDir() ) );
   342     a->addTo( menu );
   343 
   344 	exportMenu = new QPopupMenu (this);
   345     menu->insertItem (tr("Export"),exportMenu );
   346 
   347     menu->insertSeparator();
   348 
   349 
   350     a = new QAction( tr( "Print" ), QPixmap( fileprint_xpm ), tr( "&Print..." ), CTRL + Key_P, this, "filePrint" );
   351     connect( a, SIGNAL( activated() ), this, SLOT( filePrint() ) );
   352     a->addTo( tb );
   353     a->addTo( menu );
   354 	actionFilePrint=a;
   355 
   356     a = new QAction( tr( "Close Map" ), QPixmap(), tr( "&Close Map" ), ALT + Key_C, this, "fileCloseMap" );
   357     connect( a, SIGNAL( activated() ), this, SLOT( fileCloseMap() ) );
   358     a->addTo( menu );
   359 
   360     a = new QAction( tr( "Exit VYM" ), QPixmap(), tr( "E&xit VYM" ), CTRL + Key_Q, this, "fileExitVYM" );
   361     connect( a, SIGNAL( activated() ), this, SLOT( fileExitVYM() ) );
   362     a->addTo( menu );
   363 }
   364 
   365 
   366 //Edit Actions
   367 void Main::setupEditActions()
   368 {
   369     QToolBar *tb = new QToolBar( this );
   370     tb->setLabel( "Edit Actions" );
   371     QPopupMenu *menu = new QPopupMenu( this );
   372     menuBar()->insertItem( tr( "&Edit" ), menu );
   373 
   374     QAction *a;
   375     a = new QAction( tr( "Undo" ), QPixmap( editundo_xpm ), tr( "&Undo" ), CTRL + Key_Z, this, "editUndo" );
   376     connect( a, SIGNAL( activated() ), this, SLOT( editUndo() ) );
   377 	a->setEnabled (false);
   378     a->addTo( tb );
   379     a->addTo( menu );
   380 	actionEditUndo=a;
   381     /*
   382     a = new QAction( tr( "Redo" ), QPixmap( editredo_xpm ), tr( "&Redo" ), CTRL + Key_Y, this, "editRedo" ); 
   383     connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) );
   384     a->addTo( tb );
   385     a->addTo( menu );
   386     */
   387     menu->insertSeparator();
   388     a = new QAction( tr( "Copy" ), QPixmap( editcopy_xpm ), tr( "&Copy" ), CTRL + Key_C, this, "editCopy" );
   389     connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
   390 	a->setEnabled (false);
   391     a->addTo( tb );
   392     a->addTo( menu );
   393 	actionEditCopy=a;
   394     a = new QAction( tr( "Cut" ), QPixmap( editcut_xpm ), tr( "Cu&t" ), CTRL + Key_X, this, "editCut" );
   395     connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
   396 	a->setEnabled (false);
   397     a->addTo( tb );
   398     a->addTo( menu );
   399 	actionEditCut=a;
   400     a = new QAction( tr( "Paste" ), QPixmap( editpaste_xpm ), tr( "&Paste" ), CTRL + Key_V, this, "editPaste" );
   401     connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
   402 	a->setEnabled (false);
   403     a->addTo( tb );
   404     a->addTo( menu );
   405 	actionEditPaste=a;
   406 
   407     a = new QAction( tr( "Move branch up" ), QPixmap( editmoveup_xpm ), tr( "Move up" ), Key_PageUp, this, "editMoveUp" );
   408     connect( a, SIGNAL( activated() ), this, SLOT( editMoveUp() ) );
   409 	a->setEnabled (false);
   410     a->addTo( tb );
   411     a->addTo( menu );
   412 	actionListBranches.append(a);
   413 	actionEditMoveUp=a;
   414 
   415     a = new QAction( tr( "Move branch down" ), QPixmap( editmovedown_xpm ), tr( "Move down" ), Key_PageDown, this, "editMoveDown" );
   416     connect( a, SIGNAL( activated() ), this, SLOT( editMoveDown() ) );
   417 	a->setEnabled (false);
   418     a->addTo( tb );
   419     a->addTo( menu );
   420 	actionListBranches.append(a);
   421 	actionEditMoveDown=a;
   422 	
   423 
   424     a = new QAction( tr( "Scroll branch" ), QPixmap(flag_scrolled_right_xpm), tr( "Scroll branch" ), Key_ScrollLock, this, "scroll" );
   425     connect( a, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
   426 	a->setEnabled (false);
   427     a->addTo( tb );
   428     a->addTo( menu );
   429 	actionListBranches.append(a);
   430 	actionEditToggleScroll=a;
   431 	
   432     a = new QAction( tr( "Unscroll all" ), QPixmap(), tr( "Unscroll all scrolled branches" ), 0, this, "scroll" );
   433     connect( a, SIGNAL( activated() ), this, SLOT( editUnScrollAll() ) );
   434     a->addTo( menu );
   435 	
   436     menu->insertSeparator();
   437 
   438 	a = new QAction( tr( "Find" ), QPixmap(), tr( "Find" ), CTRL + Key_F, this, "find" );
   439     connect( a, SIGNAL( activated() ), this, SLOT( editOpenFindWindow() ) );
   440     a->addTo( menu );
   441     
   442 	menu->insertSeparator();
   443 
   444 	a = new QAction( tr( "Open URL" ), QPixmap(flag_url_xpm), tr( "Open URL" ), CTRL + Key_U, this, "url" );
   445     connect( a, SIGNAL( activated() ), this, SLOT( editOpenURL() ) );
   446     a->addTo( menu );
   447     a->addTo( tb );
   448 	a->setEnabled (false);
   449 	actionEditOpenURL=a;
   450 
   451 	a = new QAction( tr( "Edit URL" ), QPixmap(), tr( "Edit URL" ), SHIFT + CTRL + Key_U, this, "url" );
   452     connect( a, SIGNAL( activated() ), this, SLOT( editURL() ) );
   453     a->addTo( menu );
   454 	a->setEnabled (false);
   455 	actionListBranches.append(a);
   456 	actionEditURL=a;
   457 	
   458 	a = new QAction( tr( "Use heading of selected branch as URL" ), QPixmap(), tr( "Use heading for URL" ), 0, this, "heading2url" );
   459     connect( a, SIGNAL( activated() ), this, SLOT( editHeading2URL() ) );
   460     a->addTo( menu );
   461 	a->setEnabled (false);
   462 	actionListBranches.append(a);
   463 	actionEditHeading2URL=a;
   464     
   465 	a = new QAction( tr( "Create URL to Bugzilla" ), QPixmap(), tr( "Create URL to Bugzilla" ), 0, this, "bugzilla2url" );
   466     connect( a, SIGNAL( activated() ), this, SLOT( editBugzilla2URL() ) );
   467 	a->setEnabled (false);
   468 	actionListBranches.append(a);
   469 	actionEditBugzilla2URL=a;
   470     
   471 	menu->insertSeparator();
   472 	
   473     a = new QAction( tr( "Jump to another vym map, if needed load it first" ), QPixmap(flag_vymlink_xpm), tr( "Jump to map" ), 0, this, "jumpMap" );
   474     connect( a, SIGNAL( activated() ), this, SLOT( editOpenVymLink() ) );
   475     a->addTo( menu );
   476     a->addTo( tb );
   477 	a->setEnabled (false);
   478 	actionEditOpenVymLink=a;
   479 	
   480     a = new QAction( tr( "Edit link to another vym map" ), QPixmap(), tr( "Edit vym link" ), 0, this, "editLinkMap" );
   481     connect( a, SIGNAL( activated() ), this, SLOT( editVymLink() ) );
   482     a->addTo( menu );
   483 	a->setEnabled (false);
   484 	actionListBranches.append(a);
   485 	actionEditVymLink=a;
   486 
   487     a = new QAction( tr( "Delete link to another vym map" ), QPixmap(), tr( "Delete vym link" ), 0, this, "deleteLinkMap" );
   488     connect( a, SIGNAL( activated() ), this, SLOT( editDeleteVymLink() ) );
   489     a->addTo( menu );
   490 	a->setEnabled (false);
   491 	actionEditDeleteVymLink=a;
   492 
   493 	menu->insertSeparator();
   494 
   495     a = new QAction( tr( "Edit Map Info" ), QPixmap(), tr( "Edit Map Info" ), 0, this, "editMapInfo" );
   496     connect( a, SIGNAL( activated() ), this, SLOT( editMapInfo() ) );
   497     a->addTo( menu );
   498 	a->setEnabled (true);
   499 	actionEditMapInfo=a;
   500 
   501 	menu->insertSeparator();
   502 
   503     // Shortcuts to modify heading:
   504     a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Enter, this, "editHeading" );
   505     connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
   506 	a->setEnabled (false);
   507     a->addTo ( menu );
   508 	actionListBranches.append(a);
   509 	actionEditHeading=a;
   510     a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Return, this, "editHeading" );
   511     connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
   512 	actionListBranches.append(a);
   513 	actionEditHeading=a;
   514     a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_F2, this, "editHeading" );
   515     connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
   516 	actionListBranches.append(a);
   517     
   518     // Shortcut to delete selection
   519     a = new QAction( tr( "Delete Selection" ),tr( "Delete Selection" ), Key_Delete, this, "deleteBranch" );
   520     connect( a, SIGNAL( activated() ), this, SLOT( editDeleteSelection() ) );
   521 	a->setEnabled (false);
   522     a->addTo ( menu );
   523 	actionEditDelete=a;
   524     
   525     // Shortcut to add branch
   526 	#if defined (Q_OS_MACX)
   527 		a = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), CTRL + Key_I, this, "newBranch" );
   528 	#else
   529 		a = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), Key_Insert, this, "newBranch" );
   530 	#endif
   531     connect( a, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
   532 	a->setEnabled (false);
   533 	actionListBranches.append(a);
   534 	actionEditAddBranch=a;
   535 
   536     // Add branch by inserting it at selection
   537 	a = new QAction( tr( "Add a branch by inserting and making selection its child" ),tr( "Add branch (insert)" ), ALT + Key_Insert, this, "newBranchHere" );
   538     connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
   539 	a->setEnabled (false);
   540 	actionListBranches.append(a);
   541 	actionEditAddBranchHere=a;
   542 
   543 	// Add branch above
   544     a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_Insert, this, "newBranch" );
   545     connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
   546 	a->setEnabled (false);
   547 	actionListBranches.append(a);
   548 	actionEditAddBranchAbove=a;
   549 
   550 	// Add branch below 
   551     a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_Insert, this, "newBranch" );
   552     connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
   553 	a->setEnabled (false);
   554 	actionListBranches.append(a);
   555 	actionEditAddBranchBelow=a;
   556 
   557 	// Import at selection (adding to selection)
   558     a = new QAction( tr( "Add map at selection" ),tr( "Import (add)" ), 0, this, "importAdd" );
   559     connect( a, SIGNAL( activated() ), this, SLOT( editImportAdd() ) );
   560 	a->setEnabled (false);
   561 	actionListBranches.append(a);
   562 	actionEditImportAdd=a;
   563 
   564 	// Import at selection (replacing selection)
   565     a = new QAction( tr( "Replace selection with map" ),tr( "Import (replace)" ), 0, this, "importReplace" );
   566     connect( a, SIGNAL( activated() ), this, SLOT( editImportReplace() ) );
   567 	a->setEnabled (false);
   568 	actionListBranches.append(a);
   569 	actionEditImportReplace=a;
   570 
   571 	// Save selection 
   572     a = new QAction( tr( "Save selection" ),tr( "Save selection" ), 0, this, "saveSelection" );
   573     connect( a, SIGNAL( activated() ), this, SLOT( editSaveBranch() ) );
   574 	a->setEnabled (false);
   575 	actionListBranches.append(a);
   576 	actionEditSaveBranch=a;
   577 
   578 	// Only remove branch, not its childs
   579     a = new QAction( tr( "Remove only branch and keep its childs" ),tr( "Remove only branch " ), ALT + Key_Delete, this, "removeBranchHere" );
   580     connect( a, SIGNAL( activated() ), this, SLOT( editRemoveBranchHere() ) );
   581 	a->setEnabled (false);
   582 	actionListBranches.append(a);
   583 	actionEditRemoveBranchHere=a;
   584 
   585 	// Only remove childs of a branch
   586     a = new QAction( tr( "Remove childs of branch" ),tr( "Remove childs" ), SHIFT + Key_Delete, this, "removeBranchChilds" );
   587     connect( a, SIGNAL( activated() ), this, SLOT( editRemoveChilds() ) );
   588 	a->setEnabled (false);
   589 	actionListBranches.append(a);
   590 	actionEditRemoveChilds=a;
   591 
   592     // Shortcuts for navigating with cursor:
   593     a = new QAction( tr( "Select upper branch" ),tr( "Select upper branch" ), Key_Up, this, "upperBranch" );
   594     connect( a, SIGNAL( activated() ), this, SLOT( editUpperBranch() ) );
   595     a = new QAction( tr( "Select lower branch" ),tr( "Select lower branch" ), Key_Down, this, "lowerBranch" );
   596     connect( a, SIGNAL( activated() ), this, SLOT( editLowerBranch() ) );
   597     a = new QAction( tr( "Select left branch" ),tr( "Select left branch" ), Key_Left, this, "upperBranch" );
   598     connect( a, SIGNAL( activated() ), this, SLOT( editLeftBranch() ) );
   599     a = new QAction( tr( "Select right branch" ),tr( "Select child branch" ), Key_Right, this, "rightBranch" );
   600     connect( a, SIGNAL( activated() ), this, SLOT( editRightBranch() ) );
   601     a = new QAction( tr( "Select first branch" ),tr( "Select first branch" ), Key_Home, this, "firstBranch" );
   602 	a->setEnabled (false);
   603     a->addTo ( menu );
   604 	actionListBranches.append(a);
   605 	actionEditSelectFirst=a;
   606     connect( a, SIGNAL( activated() ), this, SLOT( editFirstBranch() ) );
   607     a = new QAction( tr( "Select last branch" ),tr( "Select last branch" ), Key_End, this, "lastBranch" );
   608     connect( a, SIGNAL( activated() ), this, SLOT( editLastBranch() ) );
   609 	a->setEnabled (false);
   610     a->addTo ( menu );
   611 	actionListBranches.append(a);
   612 	actionEditSelectLast=a;
   613 
   614     a = new QAction( tr( "Add Image" ),tr( "Add Image" ), 0, this, "loadImage" );
   615     connect( a, SIGNAL( activated() ), this, SLOT( editLoadImage() ) );
   616 	actionEditLoadImage=a;
   617 
   618 }
   619 
   620 // Format Actions
   621 void Main::setupFormatActions()
   622 {
   623     QPopupMenu *menu = new QPopupMenu( this );
   624     menuBar()->insertItem( tr( "&Format" ), menu );
   625 
   626     QToolBar *tb = new QToolBar( this );
   627     QAction *a;
   628     QPixmap pix( 16,16);
   629     pix.fill (black);
   630     actionFormatColor= new QAction( tr( "Set Color" ), pix, tr( "Set &Color" ), 0, this, "formatColor" );
   631     connect( actionFormatColor, SIGNAL( activated() ), this, SLOT( formatSelectColor() ) );
   632     actionFormatColor->addTo( tb );
   633     actionFormatColor->addTo( menu );
   634     a= new QAction( tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ), QPixmap(formatcolorpicker_xpm), tr( "Pic&k color" ), CTRL + Key_K, this, "pickColor" );
   635     connect( a, SIGNAL( activated() ), this, SLOT( formatPickColor() ) );
   636 	a->setEnabled (false);
   637     a->addTo( tb );
   638     a->addTo( menu );
   639 	actionListBranches.append(a);
   640 	actionFormatPickColor=a;
   641     a= new QAction( tr( "Color branch" ), QPixmap(formatcoloritem_xpm), tr( "Color &branch" ), CTRL + Key_I, this, "colorItem" );
   642     connect( a, SIGNAL( activated() ), this, SLOT( formatColorItem() ) );
   643 	a->setEnabled (false);
   644     a->addTo( tb );
   645     a->addTo( menu );
   646 	actionListBranches.append(a);
   647 	actionFormatColorBranch=a;
   648     a= new QAction( tr( "Color Subtree" ), QPixmap(formatcolorbranch_xpm), tr( "Color sub&tree" ), CTRL + Key_T, this, "colorBranch" );
   649     connect( a, SIGNAL( activated() ), this, SLOT( formatColorBranch() ) );
   650 	a->setEnabled (false);
   651     a->addTo( menu );
   652     a->addTo( tb );
   653 	actionListBranches.append(a);
   654 	actionFormatColorSubtree=a;
   655 
   656     menu->insertSeparator();
   657 	actionGroupFormatLinkStyles=new QActionGroup ( this, "formatLinkStyles");
   658 	actionGroupFormatLinkStyles->setExclusive (true);
   659     a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
   660 	a->setToggleAction(true);
   661     connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleLine() ) );
   662 	actionFormatLinkStyleLine=a;
   663     a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
   664 	a->setToggleAction(true);
   665     connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleParabel() ) );
   666 	actionFormatLinkStyleParabel=a;
   667     a= new QAction( tr( "PolyLine" ), QPixmap(), tr( "Linkstyle Thick Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
   668 	a->setToggleAction(true);
   669     connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyLine() ) );
   670 	actionFormatLinkStylePolyLine=a;
   671     a= new QAction( tr( "PolyParabel" ), QPixmap(), tr( "Linkstyle Thick Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStylePolyParabel" );
   672 	a->setToggleAction(true);
   673     connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyParabel() ) );
   674 	actionFormatLinkStylePolyParabel=a;
   675 	actionGroupFormatLinkStyles->addTo (menu);
   676 	
   677 	actionGroupFormatFrameTypes=new QActionGroup ( this, "formatFrameTypes");
   678 	actionGroupFormatFrameTypes->setExclusive (true);
   679     a = new QAction( tr( "No Frame" ),tr( "No Frame" ), 0, actionGroupFormatFrameTypes, "frameNone" );
   680 	a->setToggleAction(true);
   681     connect( a, SIGNAL( activated() ), this, SLOT( formatFrameNone() ) );
   682 	actionFormatFrameNone=a;
   683     a = new QAction( tr( "Rectangle" ),tr( "Rectangle" ), 0, actionGroupFormatFrameTypes, "frameRectangle" );
   684 	a->setToggleAction(true);
   685     connect( a, SIGNAL( activated() ), this, SLOT( formatFrameRectangle() ) );
   686 	actionFormatFrameRectangle=a;
   687 
   688     menu->insertSeparator();
   689     a= new QAction( tr( "Use same color for links and headings" ), QPixmap(), tr( "&Use color of heading for link" ), 0, this, "formatLinkColorHint" );
   690 	a->setToggleAction(true);
   691     connect( a, SIGNAL( activated() ), this, SLOT( formatToggleLinkColorHint() ) );
   692 	a->addTo( menu );
   693 	actionFormatLinkColorHint=a;
   694     pix.fill (white);
   695     actionFormatLinkColor= new QAction( tr( "Set Link Color" ), pix, tr( "Set &Link Color" ), 0, this, "formatLinkColor" );
   696     connect( actionFormatLinkColor, SIGNAL( activated() ), this, SLOT( formatSelectLinkColor() ) );
   697     actionFormatLinkColor->addTo( menu );
   698     actionFormatBackColor= new QAction( tr( "Set Background Color" ), pix, tr( "Set &Background Color" ), 0, this, "formatBackColor" );
   699     connect( actionFormatBackColor, SIGNAL( activated() ), this, SLOT( formatSelectBackColor() ) );
   700     actionFormatBackColor->addTo( menu );
   701 }
   702 
   703 // View Actions
   704 void Main::setupViewActions()
   705 {
   706     QToolBar *tb = new QToolBar( this );
   707     tb->setLabel( "View Actions" );
   708     QPopupMenu *menu = new QPopupMenu( this );
   709     menuBar()->insertItem( tr( "&View" ), menu );
   710 
   711     QAction *a;
   712     a = new QAction( tr( "Zoom reset" ), QPixmap(viewzoomreset_xpm), tr( "reset Zoom" ), 0, this, "zoomReset" );
   713     connect( a, SIGNAL( activated() ), this, SLOT(viewZoomReset() ) );
   714     a->addTo( tb );
   715     a->addTo( menu );
   716     a = new QAction( tr( "Zoom in" ), QPixmap(viewzoomin_xpm), tr( "Zoom in" ), CTRL + Key_Plus, this, "zoomIn" );
   717     connect( a, SIGNAL( activated() ), this, SLOT(viewZoomIn() ) );
   718     a->addTo( tb );
   719     a->addTo( menu );
   720     a = new QAction( tr( "Zoom out" ), QPixmap(viewzoomout_xpm), tr( "Zoom out" ), CTRL + Key_Minus, this, "zoomOut" );
   721     connect( a, SIGNAL( activated() ), this, SLOT( viewZoomOut() ) );
   722     a->addTo( tb );
   723     a->addTo( menu );
   724     a = new QAction( tr( "Toggle Note Editor" ), QPixmap(flag_note_xpm), tr( "Toggle Note Editor" ), CTRL + Key_E , this, "noteEditor" );
   725     connect( a, SIGNAL( activated() ), this, SLOT(windowToggleNoteEditor() ) );
   726 	a->setToggleAction(true);
   727 	if (textEditor->showWithMain())
   728 		a->setOn(true);
   729 	else	
   730 		a->setOn(false);
   731     a->addTo( tb );
   732     a->addTo( menu );
   733 	actionViewToggleNoteEditor=a;
   734     a = new QAction( tr( "&Next Window" ), QPixmap(), tr( "Next Window" ), ALT + Key_N , this, "nextWindow" );
   735     connect( a, SIGNAL( activated() ), this, SLOT(windowNextEditor() ) );
   736     a->addTo( menu );
   737     a = new QAction( tr( "&Previous Window" ), QPixmap(), tr( "Previous Window" ), ALT + Key_P , this, "previousWindow" );
   738     connect( a, SIGNAL( activated() ), this, SLOT(windowPreviousEditor() ) );
   739     a->addTo( menu );
   740 }
   741 
   742 // Mode Actions
   743 void Main::setupModeActions()
   744 {
   745     //QPopupMenu *menu = new QPopupMenu( this );
   746     //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
   747 
   748     QToolBar *tb = new QToolBar( this );
   749     tb->setLabel( tr ("Modes when using modifiers") );
   750     QAction *a;
   751 	actionGroupModModes=new QActionGroup ( this, "formatLinkStyles");
   752 	actionGroupModModes->setExclusive (true);
   753 	//FIXME Linkstyle line???
   754     a= new QAction( tr( "Use modifier to color branches" ), QPixmap(modecolor_xpm), tr( "Linkstyle Line" ), Key_K, actionGroupModModes, "modModeColor" );
   755 	a->setToggleAction(true);
   756 	a->addTo (tb);
   757 	a->setOn(true);
   758 	actionModModeColor=a;
   759     a= new QAction( tr( "Use modifier to draw links" ), QPixmap(modelink_xpm), tr( "Linkstyle Line" ), Key_L, actionGroupModModes, "modModeLink" );
   760 	//FIXME Linkstyle line???
   761 
   762 	a->setToggleAction(true);
   763 	a->addTo (tb);
   764 	actionModModeLink=a;
   765     a= new QAction( tr( "Use modifier to copy" ), QPixmap(modecopy_xpm), tr( "Linkstyle Line" ), Key_C, actionGroupModModes, "modModeCopy" );
   766 	//FIXME Linkstyle line???
   767 
   768 	a->setToggleAction(true);
   769 	a->addTo (tb);
   770 	actionModModeCopy=a;
   771 }
   772 
   773 // Flag Actions
   774 void Main::setupFlagActions()
   775 {
   776 	standardFlagsDefault->makeToolbar(this, "Standard Flags");
   777 }
   778 
   779 // Settings Actions
   780 void Main::setupSettingsActions()
   781 {
   782     QPopupMenu *menu = new QPopupMenu( this );
   783     menuBar()->insertItem( tr( "&Settings" ), menu );
   784 
   785 	QAction *a;
   786 
   787 
   788     a = new QAction( tr( "Set application to open pdf files" ), QPixmap(), tr( "Set application to open pdf files" ), 0, this, "setPDF" );
   789     connect( a, SIGNAL( activated() ), this, SLOT( settingsPDF() ) );
   790     a->addTo( menu );
   791 
   792     a = new QAction( tr( "Set application to open an URL" ), QPixmap(), tr( "Set application to open an URL" ), 0, this, "setURL" );
   793     connect( a, SIGNAL( activated() ), this, SLOT( settingsURL() ) );
   794     a->addTo( menu );
   795 
   796     menu->insertSeparator();
   797     a = new QAction( tr( "Edit branch after adding it" ), QPixmap(), tr( "Edit branch after adding it" ), 0, this, "autoedit" );
   798 	a->setToggleAction(true);
   799 	a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoedit",true) );
   800     a->addTo( menu );
   801 	actionSettingsAutoedit=a;
   802 
   803     a= new QAction( tr( "Select branch after adding it" ), QPixmap(), tr( "Select branch after adding it" ), 0, this, "autoselectheading" );
   804 	a->setToggleAction(true);
   805 	a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselect",false) );
   806     a->addTo( menu );
   807 	actionSettingsAutoselectHeading=a;
   808 	
   809     a= new QAction( tr( "Select heading before editing" ), QPixmap(), tr( "Select existing heading" ), 0, this, "autoselectexistingtext" );
   810 	a->setToggleAction(true);
   811 	a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselectexistingtext",true) );
   812     a->addTo( menu );
   813 	actionSettingsAutoselectText=a;
   814 	
   815     a= new QAction( tr( "Enable pasting into new branch" ), QPixmap(), tr( "Enable pasting into new branch" ), 0, this, "pastenewheading" );
   816 	a->setToggleAction(true);
   817 	a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/newheadingisempty",true) );
   818     a->addTo( menu );
   819 	actionSettingsPasteNewHeading=a;
   820 	
   821     a= new QAction( tr( "Enable Delete key for deleting branches" ), QPixmap(), tr( "Enable Delete key" ), 0, this, "delkey" );
   822 	a->setToggleAction(true);
   823 	a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useDelKey",false) );
   824     a->addTo( menu );
   825 	actionSettingsUseDelKey=a;
   826 }
   827 
   828 // Test Actions
   829 void Main::setupTestActions()
   830 {
   831     QPopupMenu *menu = new QPopupMenu( this );
   832     menuBar()->insertItem( tr( "&Test" ), menu );
   833 
   834     QAction *a;
   835     a = new QAction( tr( "Test Flag" ), QPixmap(), tr( "test flag" ), 0, this, "flag" );
   836     connect( a, SIGNAL( activated() ), this, SLOT( testFunction() ) );
   837     a->addTo( menu );
   838 
   839 	a = new QAction( tr( "Show Clipboard" ), QPixmap(), tr( "Show clipboard" ), 0, this, "clipboard" );
   840     connect( a, SIGNAL( activated() ), this, SLOT( testShowClipboard() ) );
   841     a->addTo( menu );
   842 }
   843 
   844 // Help Actions
   845 void Main::setupHelpActions()
   846 {
   847     QPopupMenu *menu = new QPopupMenu( this );
   848     menuBar()->insertItem( tr( "&Help" ), menu );
   849 
   850     QAction *a;
   851     a = new QAction( tr( "Open VYM Documentation (pdf)" ), QPixmap(), tr( "Open VYM Documentation (pdf) " ), 0, this, "about" );
   852     connect( a, SIGNAL( activated() ), this, SLOT( helpDoc() ) );
   853     a->addTo( menu );
   854 
   855     a = new QAction( tr( "Information about VYM" ), QPixmap(), tr( "About VYM" ), 0, this, "about" );
   856     connect( a, SIGNAL( activated() ), this, SLOT( helpAbout() ) );
   857     a->addTo( menu );
   858 
   859     a = new QAction( tr( "Information about QT toolkit" ), QPixmap(), tr( "About QT" ), 0, this, "about" );
   860     connect( a, SIGNAL( activated() ), this, SLOT( helpAboutQT() ) );
   861     a->addTo( menu );
   862 }
   863 
   864 // Context Menus
   865 void Main::setupContextMenus()
   866 {
   867 	QAction*a;
   868 
   869 	// Context Menu for branch or mapcenter
   870 	branchContextMenu =new QPopupMenu (this);
   871 
   872 		// Submenu "Add"
   873 		branchAddContextMenu =new QPopupMenu (this);
   874 		actionEditPaste->addTo ( branchAddContextMenu );
   875 		actionEditAddBranch->addTo ( branchAddContextMenu );
   876 		actionEditAddBranchHere->addTo ( branchAddContextMenu );
   877 		actionEditAddBranchAbove->addTo ( branchAddContextMenu );
   878 		actionEditAddBranchBelow->addTo ( branchAddContextMenu );
   879 		branchAddContextMenu->insertSeparator();	
   880 		actionEditLoadImage->addTo( branchAddContextMenu );
   881 		branchAddContextMenu->insertSeparator();	
   882 		actionEditImportAdd->addTo ( branchAddContextMenu );
   883 		actionEditImportReplace->addTo ( branchAddContextMenu );
   884 
   885 		// Submenu "Remove"
   886 		branchRemoveContextMenu =new QPopupMenu (this);
   887 		actionEditCut->addTo ( branchRemoveContextMenu );
   888 		actionEditDelete->addTo ( branchRemoveContextMenu );
   889 		actionEditRemoveBranchHere->addTo( branchRemoveContextMenu );
   890 		actionEditRemoveChilds->addTo( branchRemoveContextMenu );
   891 		
   892 	branchContextMenu->insertItem (tr("Add"),branchAddContextMenu);	
   893 	branchContextMenu->insertItem (tr("Remove"),branchRemoveContextMenu);	
   894 
   895 	actionEditSaveBranch->addTo( branchContextMenu );
   896 
   897 	branchContextMenu->insertSeparator();	
   898 	actionEditOpenURL->addTo ( branchContextMenu );
   899 	actionEditURL->addTo ( branchContextMenu );
   900 	actionEditHeading2URL->addTo ( branchContextMenu );
   901     if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) 
   902 		actionEditBugzilla2URL->addTo( branchContextMenu );
   903 		
   904 	branchContextMenu->insertSeparator();	
   905 	actionEditOpenVymLink->addTo ( branchContextMenu );
   906 	actionEditVymLink->addTo ( branchContextMenu );
   907 	actionEditDeleteVymLink->addTo ( branchContextMenu );
   908 	
   909 	branchContextMenu->insertSeparator();	
   910 	actionGroupFormatFrameTypes->addTo( branchContextMenu );
   911 
   912 	// Context Menu for links in a branch menu
   913 	// This will be populated "on demand" in MapEditor::updateActions
   914 	branchContextMenu->insertSeparator();	
   915 	branchLinksContextMenu =new QPopupMenu (this);
   916 	branchContextMenu->insertItem (tr("Goto XLink"),branchLinksContextMenu);
   917 	connect( branchLinksContextMenu, SIGNAL( activated(int) ), this, SLOT( editFollowXLink(int ) ) );
   918 	
   919 	branchLinksContextMenuDup =new QPopupMenu (this);
   920 	branchContextMenu->insertItem (tr("Edit XLink"),branchLinksContextMenuDup);
   921 	connect( branchLinksContextMenuDup, SIGNAL( activated(int) ), this, SLOT( editEditXLink(int ) ) );
   922 
   923 	// Context menu for floatimage
   924 	floatimageContextMenu =new QPopupMenu (this);
   925 	saveImageFormatMenu=new QPopupMenu (this);
   926 	exportImageFormatMenu=new QPopupMenu (this);
   927 
   928 	QStrList fmt = QImage::outputFormats();
   929 	for (const char* f = fmt.first(); f; f = fmt.next()) 
   930 	{
   931 		saveImageFormatMenu->insertItem( f );
   932 		exportImageFormatMenu->insertItem( f );
   933 	}	
   934 	connect( saveImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( editSaveImage(int ) ) );
   935 	connect( exportImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( fileExportImage(int ) ) );
   936 	floatimageContextMenu->insertItem( tr("Save image"),saveImageFormatMenu );
   937 	
   938 	floatimageContextMenu->insertSeparator();	
   939 	actionEditCopy->addTo( floatimageContextMenu );
   940 	actionEditCut->addTo( floatimageContextMenu );
   941 
   942 	floatimageContextMenu->insertSeparator();	
   943     a = new QAction( tr( "Use for Export" ), QPixmap(), tr( "Use for Export"), 0, this, "useForExport" );
   944 	a->setToggleAction(true);
   945     connect( a, SIGNAL( activated() ), this, SLOT( editToggleFloatExport() ) );
   946     a->addTo( floatimageContextMenu);
   947 	actionEditToggleFloatExport=a;
   948 
   949 
   950 
   951 	// Context menu for exports
   952 	exportMenu->insertItem ( tr("Export map as image"),exportImageFormatMenu);
   953 
   954     a = new QAction( tr( "Export as ASCII (still experimental)" ), QPixmap(), tr( "Export (ASCII)" ), 0, this, "exportASCII" );
   955     connect( a, SIGNAL( activated() ), this, SLOT( fileExportASCII() ) );
   956     a->addTo( exportMenu );
   957 
   958 	a = new QAction( tr( "Export XML" ), QPixmap(), tr( "Export XML" ),  0, this, "exportXML" );
   959     connect( a, SIGNAL( activated() ), this, SLOT( fileExportXML() ) );
   960     a->addTo( exportMenu );
   961 	
   962     if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) 
   963 	{
   964 		a = new QAction( tr( "Export HTML" ), QPixmap(), tr( "Export HTML" ), 0, this, "exportHTML" );
   965 		connect( a, SIGNAL( activated() ), this, SLOT( fileExportHTML() ) );
   966 		a->addTo( exportMenu );
   967 	}
   968 
   969 	a = new QAction( tr( "Export XHTML" ), QPixmap(), tr( "Export XHTML" ), ALT + Key_X, this, "exportXHTML" );
   970     connect( a, SIGNAL( activated() ), this, SLOT( fileExportXHTML() ) );
   971     a->addTo( exportMenu );
   972 
   973 	
   974 	// Context menu for canvas
   975 	canvasContextMenu =new QPopupMenu (this);
   976 	actionEditMapInfo->addTo( canvasContextMenu );
   977 	canvasContextMenu->insertSeparator();	
   978 	actionGroupFormatLinkStyles->addTo( canvasContextMenu );
   979 	canvasContextMenu->insertSeparator();	
   980 	actionFormatLinkColorHint->addTo( canvasContextMenu );
   981 	actionFormatLinkColor->addTo( canvasContextMenu );
   982 	actionFormatBackColor->addTo( canvasContextMenu );
   983 
   984 	// Menu for last opened files
   985 	// Read settings initially
   986 	QString s;
   987 	int j=settings.readNumEntry( "/vym/lastMaps/number",0);
   988 	for (int i=1;i<=j;i++)
   989 	{
   990 		s=settings.readEntry(QString("/vym/lastMaps/map-%1").arg(i),"");
   991 		if (!s.isEmpty() && j<=maxLastMaps) 
   992 			lastMaps.append(s);
   993 	}
   994 	setupLastMapsMenu();
   995 	connect( lastMapsMenu, SIGNAL( activated(int) ), this, SLOT( fileLoadLast(int ) ) );
   996 }
   997 
   998 void Main::setupLastMapsMenu()
   999 {
  1000 	// Remove double entries
  1001 	QStringList::Iterator it=lastMaps.begin();
  1002 	QStringList::Iterator jt;
  1003 	while (it!=lastMaps.end() )
  1004 	{
  1005 		jt=it;
  1006 		++jt;
  1007 		while (jt!=lastMaps.end() )
  1008 		{
  1009 			if (*it == *jt)		
  1010 				jt=lastMaps.remove(jt);
  1011 			else	
  1012 				jt++;
  1013 		}
  1014 		it++;
  1015 	}	
  1016 
  1017 	// Limit length of list to maxLastMaps
  1018 	while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
  1019 	
  1020 	// build Menu from lastMaps string list
  1021 	lastMapsMenu->clear();
  1022 	for (it = lastMaps.begin(); it != lastMaps.end(); ++it ) 
  1023 		lastMapsMenu->insertItem (*it );
  1024 		
  1025 }
  1026 
  1027 void Main::hideEvent (QHideEvent * )
  1028 {
  1029 	if (!textEditor->isMinimized() ) textEditor->hide();
  1030 }
  1031 
  1032 void Main::showEvent (QShowEvent * )
  1033 {
  1034 	if (textEditor->showWithMain()) textEditor->show();
  1035 }
  1036 
  1037 bool Main::reallyWriteDirectory(const QString &dir)
  1038 {
  1039 	QStringList eList = QDir(dir).entryList();
  1040 	if (eList.first() ==".")  eList.pop_front();	// remove "."
  1041 	if (eList.first() =="..") eList.pop_front();	// remove "."
  1042 	if (!eList.isEmpty())
  1043 	{
  1044 		QMessageBox mb( "VYM",
  1045 			tr("The directory ") + dir + 
  1046 			tr(" is not empty. Do you risk to overwrite its contents?"),
  1047 		QMessageBox::Warning,
  1048 		QMessageBox::Yes ,
  1049 		QMessageBox::Cancel | QMessageBox::Default,
  1050 		QMessageBox::QMessageBox::NoButton );
  1051 
  1052 		mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
  1053 		mb.setButtonText( QMessageBox::No, tr("Cancel"));
  1054 		switch( mb.exec() ) 
  1055 		{
  1056 			case QMessageBox::Yes:
  1057 				// save 
  1058 				return true;
  1059 			case QMessageBox::Cancel:
  1060 				// do nothing
  1061 				return false;
  1062 		}
  1063 	}
  1064 	return true;
  1065 }
  1066 
  1067 QString Main::browseDirectory (const QString &caption)
  1068 {
  1069 	QFileDialog fd(this,caption);
  1070 	fd.setMode (QFileDialog::DirectoryOnly);
  1071 	fd.setCaption("VYM - "+caption);
  1072 	fd.show();
  1073 	
  1074 	if ( fd.exec() == QDialog::Accepted )
  1075 		return fd.selectedFile();
  1076 	else
  1077 		return "";
  1078 }
  1079 
  1080 MapEditor* Main::currentMapEditor() const
  1081 {
  1082     if ( tabWidget->currentPage() &&
  1083 	 tabWidget->currentPage()->inherits( "MapEditor" ) )
  1084 		return (MapEditor*)tabWidget->currentPage();
  1085     return NULL;	
  1086 }
  1087 
  1088 //TODO not used now, maybe use this for overview window later
  1089 void Main::newView() 
  1090 {
  1091     // Open a new view... have it delete when closed.
  1092     Main *m = new Main(0, 0, WDestructiveClose);
  1093     qApp->setMainWidget(m);
  1094     m->show();
  1095     qApp->setMainWidget(0);
  1096 }
  1097 
  1098 void Main::editorChanged(QWidget *)
  1099 {
  1100 	// Unselect all possibly selected objects
  1101 	// (Important to update note editor)
  1102 	int i;
  1103 	MapEditor *me;
  1104 	for (i=0;i<=tabWidget->count() -1;i++)
  1105 	{
  1106 		
  1107 		me=(MapEditor*)tabWidget->page(i);
  1108 		me->unselect();
  1109 	}	
  1110 	currentMapEditor()->reselect();
  1111 
  1112 	// Update actions to in menus and toolbars according to editor
  1113 	currentMapEditor()->updateActions();
  1114 }
  1115 
  1116 void Main::fileNew()
  1117 {
  1118 	QString fn="unnamed";
  1119 	MapEditor* medit = new MapEditor (tabWidget, true);
  1120 	tabWidget->addTab (medit,fn);
  1121 	tabWidget->showPage(medit);
  1122 	medit->viewport()->setFocus();
  1123 	medit->select("mc:");
  1124 }
  1125 
  1126 void Main::fileLoad(QString fn, const LoadMode &lmode)
  1127 {
  1128 	// Error codes
  1129 	enum errorCode {success,aborted};
  1130 	errorCode err=success;
  1131 	
  1132 	// fn is usually the archive, mapfile the file after uncompressing
  1133 	QString mapfile;
  1134 
  1135 	// Make fn absolute (needed for unzip)
  1136 	fn=QDir (fn).absPath();
  1137 
  1138 	MapEditor *me;
  1139 
  1140 	if (lmode==NewMap)
  1141 	{
  1142 		// Check, if map is already loaded
  1143 		int i=0;
  1144 		while (i<=tabWidget->count() -1)
  1145 		{
  1146 			me=(MapEditor*)tabWidget->page(i);
  1147 			if (me->getFilePath() == fn)
  1148 			{
  1149 				// Already there, ask for confirmation
  1150 				QMessageBox mb( "VYM",
  1151 					tr("The map ") + fn + tr ("\n is already opened."
  1152 					"Opening the same map in multiple editors may lead \n"
  1153 					"to confusion when finishing working with vym."
  1154 					"Do you want to"),
  1155 					QMessageBox::Warning,
  1156 					QMessageBox::Yes | QMessageBox::Default,
  1157 					QMessageBox::Cancel | QMessageBox::Escape,
  1158 					QMessageBox::QMessageBox::NoButton);
  1159 				mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
  1160 				mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
  1161 				switch( mb.exec() ) 
  1162 				{
  1163 					case QMessageBox::Yes:
  1164 						// load anyway
  1165 						i=tabWidget->count();
  1166 						break;
  1167 					case QMessageBox::Cancel:
  1168 						// do nothing
  1169 						return;
  1170 						break;
  1171 				}
  1172 			}
  1173 			i++;
  1174 		}
  1175 	}
  1176 
  1177 
  1178 	// Try to load map
  1179     if ( !fn.isEmpty() )
  1180 	{
  1181 		me = currentMapEditor();
  1182 		int tabIndex=tabWidget->currentPageIndex();
  1183 		// Check first, if mapeditor exists
  1184 		// If it is not default AND we want a new map, 
  1185 		// create a new mapeditor in a new tab
  1186 		if ( lmode==NewMap && (!me || !me->isDefault() ) )
  1187 		{
  1188 			me = new MapEditor (tabWidget,true);
  1189 			tabWidget->addTab (me,fn);
  1190 			tabIndex=tabWidget->indexOf (me);
  1191 			tabWidget->setCurrentPage (tabIndex);
  1192 		}
  1193 		
  1194 		// Check, if file exists (important for creating new files
  1195 		// from command line
  1196 		if (!QFile(fn).exists() )
  1197 		{
  1198 			QMessageBox mb( "VYM",
  1199 				tr("This map does not exist:\n  ")+fn+tr("\nDo you want to create a new one?"),
  1200 				QMessageBox::Question,
  1201 				QMessageBox::Yes ,
  1202 				QMessageBox::Cancel | QMessageBox::Default,
  1203 				QMessageBox::QMessageBox::NoButton );
  1204 
  1205 			mb.setButtonText( QMessageBox::Yes, tr("Create"));
  1206 			mb.setButtonText( QMessageBox::No, tr("Cancel"));
  1207 			switch( mb.exec() ) 
  1208 			{
  1209 				case QMessageBox::Yes:
  1210 					// Create new map
  1211 					currentMapEditor()->setFilePath(fn);
  1212 					tabWidget->setTabLabel (currentMapEditor(),
  1213 						currentMapEditor()->getFileName() );
  1214 					statusBar()->message( "Created " + fn , statusbarTime );
  1215 					return;
  1216 						
  1217 				case QMessageBox::Cancel:
  1218 					// don't create new map
  1219 					statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
  1220 					fileCloseMap();
  1221 					return;
  1222 			}
  1223 		}	
  1224 
  1225 
  1226 		//tabWidget->currentPage() won't be NULL here, because of above...
  1227 		tabWidget->showPage(me);
  1228 		me->viewport()->setFocus();
  1229 
  1230 		// Create temporary directory for packing
  1231 		char tmpdir1[]="/tmp/vym-XXXXXX";	
  1232 		QString tmpMapDir=mkdtemp(tmpdir1);
  1233 
  1234 		// Try to unzip file
  1235 		Process *zipProc=new Process ();
  1236 		zipProc->clearArguments();
  1237 		zipProc->setWorkingDirectory (QDir(tmpMapDir));
  1238 		zipProc->addArgument ("unzip");
  1239 		zipProc->addArgument (fn );
  1240 		zipProc->addArgument ("-d");
  1241 		zipProc->addArgument (tmpMapDir);
  1242 
  1243 		if (!zipProc->start() )
  1244 		{
  1245 			QMessageBox::critical( 0, tr( "Critical Load Error" ),
  1246 						   tr("Couldn't start unzip to decompress data."));
  1247 			err=aborted;
  1248 			
  1249 		} else
  1250 		{
  1251 			zipProc->waitFinished();
  1252 			if (!zipProc->normalExit() )
  1253 			{
  1254 				QMessageBox::critical( 0, tr( "Critical Load Error" ),
  1255 							   tr("unzip didn't exit normally") +
  1256 							   zipProc->getErrout() );
  1257 				err=aborted;
  1258 			} else
  1259 			{
  1260 				if (zipProc->exitStatus()>0)
  1261 				{
  1262 					if (zipProc->exitStatus()==9)
  1263 					{
  1264 						// no zipped file, but maybe .xml or old version? Try again.
  1265 						mapfile=fn;
  1266 						me->setZipped(false);
  1267 					}	
  1268 					else	
  1269 					{
  1270 						QMessageBox::critical( 0, tr( "Critical Load Error" ),
  1271 									   QString("unzip exit code:  %1").arg(zipProc->exitStatus() ) +
  1272 									   zipProc->getErrout() );
  1273 						err=aborted;
  1274 					}
  1275 				} else
  1276 				{	// Uncompressing was successfull,
  1277 					// load from uncompressed temporary directory
  1278 
  1279 					me->setZipped(true);
  1280 
  1281 					
  1282 					// Look for mapname.xml
  1283 					mapfile= fn.left(fn.findRev(".",-1,true));
  1284 					mapfile=mapfile.section( '/', -1 );
  1285 					QFile file( tmpMapDir + "/" + mapfile + ".xml");
  1286 					if (!file.exists() )
  1287 					{
  1288 						// mapname.xml does not exist, well, 
  1289 						// maybe some renamed the mapname.vym file...
  1290 						// Try to find any .xml in the toplevel 
  1291 						// directory of the .vym file
  1292 						QStringList flist=QDir (tmpMapDir).entryList("*.xml");
  1293 						if (flist.count()==1) 
  1294 						{
  1295 							// Only one entry, take this one
  1296 							mapfile=tmpMapDir + "/"+flist.first();
  1297 						} else
  1298 						{
  1299 							for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it ) 
  1300 								*it=tmpMapDir + "/" + *it;
  1301 							// FIXME	
  1302 							// Multiple entries, load all (but only the first one into this ME)
  1303 							//mainWindow->fileLoadFromTmp (flist);
  1304 							//returnCode=1;	// Silently forget this attempt to load
  1305 							qWarning ("MainWindow::load (fn)  multimap found...");
  1306 						}	
  1307 							
  1308 						if (flist.isEmpty() )
  1309 						{
  1310 							QMessageBox::critical( 0, tr( "Critical Load Error" ),
  1311 									   tr("Couldn't find a map (*.xml) in .vym archive.\n"));
  1312 							err=aborted;				   
  1313 						}	
  1314 					} //file doesn't exist	
  1315 					else
  1316 						mapfile=file.name();
  1317 				} // Uncompressing successfull
  1318 			}
  1319 		}
  1320 
  1321 		// Finally load map into mapEditor
  1322 		me->setFilePath (mapfile,fn);
  1323 		if (me->load(mapfile,lmode))
  1324 			err=aborted;
  1325 
  1326 		// Delete tmpDir
  1327 		system ( "rm -rf "+tmpMapDir);
  1328 
  1329 		// Check for errors
  1330 		if (err==success) 
  1331 		{
  1332 			if (lmode==NewMap)
  1333 			{
  1334 				me->setFilePath (fn);
  1335 				tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
  1336 				lastMaps.prepend(me->getFilePath() );
  1337 				setupLastMapsMenu();
  1338 				actionFilePrint->setEnabled (true);
  1339 			}	
  1340 			statusBar()->message( "Loaded " + fn, statusbarTime );
  1341 			return;
  1342 		} else 
  1343 		{
  1344 			if (lmode==NewMap)
  1345 				fileCloseMap();
  1346 		}	
  1347 
  1348 
  1349 	}
  1350 	statusBar()->message( "Could not load " + fn, statusbarTime );
  1351 }
  1352 
  1353 
  1354 void Main::fileLoad(const LoadMode &lmode)
  1355 {
  1356 	QFileDialog *fd=new QFileDialog( this);
  1357 	if (!lastFileDir.isEmpty()) 
  1358 		fd->setDir (lastFileDir);
  1359 	fd->addFilter ("XML (*.xml)");
  1360 	fd->addFilter ("VYM map (*.vym *.vyp)");
  1361 	switch (lmode)
  1362 	{
  1363 		case NewMap:
  1364 			fd->setCaption(tr("Load vym map"));
  1365 			break;
  1366 		case ImportAdd:
  1367 			fd->setCaption(tr("Import: Add vym map to selection"));
  1368 			break;
  1369 		case ImportReplace:
  1370 			fd->setCaption(tr("Import: Replace selection with vym map"));
  1371 			break;
  1372 	}
  1373 	fd->show();
  1374 
  1375 	QString fn;
  1376 	if ( fd->exec() == QDialog::Accepted )
  1377 	{
  1378 		lastFileDir=fd->dirPath();
  1379         fn = fd->selectedFile();
  1380 		fileLoad(fn, lmode);				   
  1381 	}
  1382 }
  1383 
  1384 void Main::fileLoad()
  1385 {
  1386 	fileLoad (NewMap);
  1387 }
  1388 
  1389 void Main::fileLoadLast(int i)
  1390 {
  1391 	fileLoad(*lastMaps.at(lastMapsMenu->indexOf (i) ),NewMap);			   
  1392 }
  1393 
  1394 void Main::fileSave(const SaveMode &savemode)
  1395 {
  1396 	// tmp dir for zipping 
  1397 	QString tmpMapDir;
  1398 	
  1399 	// Error codes
  1400 	enum errorCode {success,aborted};
  1401 	errorCode err=success;
  1402 	
  1403 	QString safeFilePath;
  1404 
  1405 	bool saveZipped=currentMapEditor()->saveZipped();
  1406 
  1407 	if (currentMapEditor())
  1408 	{
  1409 		QString fn=currentMapEditor()->getFilePath();
  1410 		// filename=unnamed, filepath="" in constructor...
  1411 		if ( !fn.isEmpty() ) 
  1412 		{	
  1413 			// We have a filepath, go on saving			
  1414 			// First remove existing file, we 
  1415 			// don't want to add to old zip archives
  1416 			QFile f(fn);
  1417 			if (f.exists() ) 
  1418 				if (!f.remove())
  1419 					QMessageBox::warning( 0, tr( "Save Error" ),
  1420 						fn+   tr("\ncould not be removed before saving"));
  1421 
  1422 			// Look, if we should zip the data:
  1423 			if (!saveZipped)
  1424 			{
  1425 				QMessageBox mb( "VYM",
  1426 					tr("The map ") + fn + 
  1427 					tr ("\ndid not use the compressed "
  1428 					"vym file format.\nWriting it uncompressed will also write images \n"
  1429 					"and flags and thus may overwrite files in the "
  1430 					"given directory\n\nDo you want to write the map"),
  1431 					QMessageBox::Warning,
  1432 					QMessageBox::Yes | QMessageBox::Default,
  1433 					QMessageBox::No ,
  1434 					QMessageBox::Cancel | QMessageBox::Escape);
  1435 				mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
  1436 				mb.setButtonText( QMessageBox::No, tr("uncompressed") );
  1437 				mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
  1438 				switch( mb.exec() ) 
  1439 				{
  1440 					case QMessageBox::Yes:
  1441 						// save compressed (default file format)
  1442 						saveZipped=true;
  1443 						break;
  1444 					case QMessageBox::No:
  1445 						// save uncompressed
  1446 						saveZipped=false;
  1447 						break;
  1448 					case QMessageBox::Cancel:
  1449 						// do nothing
  1450 						return;
  1451 						break;
  1452 				}
  1453 			}
  1454 
  1455 			if (saveZipped)
  1456 			{
  1457 				char tmpdir1[]="/tmp/vym-XXXXXX";	
  1458 				tmpMapDir=mkdtemp(tmpdir1);
  1459 			
  1460 				safeFilePath=currentMapEditor()->getFilePath();
  1461 				currentMapEditor()->setFilePath (tmpMapDir+"/"+
  1462 					currentMapEditor()->getMapName()+ ".xml",
  1463 					safeFilePath);
  1464 				currentMapEditor()->save (savemode);
  1465 				currentMapEditor()->setFilePath (safeFilePath);
  1466 				
  1467 				// zip the temporary directory
  1468 				Process *zipProc=new Process ();
  1469 				zipProc->clearArguments();
  1470 				zipProc->setWorkingDirectory (QDir(tmpMapDir));
  1471 				zipProc->addArgument ("zip");
  1472 				zipProc->addArgument ("-r");
  1473 				zipProc->addArgument (fn);
  1474 				zipProc->addArgument (".");
  1475 
  1476 				if (!zipProc->start() )
  1477 				{	
  1478 					// zip could not be started
  1479 					QMessageBox::critical( 0, tr( "Critical Save Error" ),
  1480 								   tr("Couldn't start zip to compress data."));
  1481 					err=aborted;
  1482 				} else
  1483 				{
  1484 					// zip could be started
  1485 					zipProc->waitFinished();
  1486 					if (!zipProc->normalExit() )
  1487 					{
  1488 						QMessageBox::critical( 0, tr( "Critical Save Error" ),
  1489 									   tr("zip didn't exit normally")+
  1490 									   "\n" + zipProc->getErrout());
  1491 						err=aborted;
  1492 					} else
  1493 					{
  1494 						if (zipProc->exitStatus()>0)
  1495 						{
  1496 							QMessageBox::critical( 0, tr( "Critical Save Error" ),
  1497 									   QString("zip exit code:  %1").arg(zipProc->exitStatus() )+
  1498 									   "\n" + zipProc->getErrout() );
  1499 							err=aborted;
  1500 						}
  1501 					}
  1502 				}	// zip could be started
  1503 			} // save zipped
  1504 			else
  1505 			{
  1506 				// Save unzipped. 
  1507 				safeFilePath=currentMapEditor()->getFilePath();
  1508 				currentMapEditor()->setFilePath (fn, safeFilePath);
  1509 				currentMapEditor()->save (savemode);
  1510 				currentMapEditor()->setFilePath (safeFilePath);
  1511 			} // save zipped 	
  1512 		} // filepath available
  1513 		else
  1514 		{
  1515 			// We have  no filepath yet,
  1516 			// call fileSaveAs() now, this will call fileSave() 
  1517 			// again.
  1518 			fileSaveAs(savemode);
  1519 		}
  1520     }
  1521 
  1522 	if (currentMapEditor()->saveZipped())
  1523 	{
  1524 		// Delete tmpDir
  1525 		system ( "rm -rf "+ tmpMapDir );
  1526 	} 
  1527 
  1528 	if (err==success)
  1529 		statusBar()->message( 
  1530 			tr("Saved")+" " + currentMapEditor()->getFilePath(), 
  1531 			statusbarTime );
  1532 	else		
  1533 		statusBar()->message( 
  1534 			tr("Couldn't save")+" " + currentMapEditor()->getFilePath(), 
  1535 			statusbarTime );
  1536 }
  1537 
  1538 void Main::fileSave()
  1539 {
  1540 	fileSave (CompleteMap);
  1541 }
  1542 
  1543 void Main::fileSaveAs(const SaveMode& savemode)
  1544 {
  1545 	QString tmpMapDir;
  1546 	QString fn;
  1547 
  1548 	if (currentMapEditor())
  1549 	{
  1550 		if (savemode==CompleteMap)
  1551 			fn = QFileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
  1552 		else		
  1553 			fn = QFileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
  1554 		if ( !fn.isEmpty() ) 
  1555 		{
  1556 			// Check for existing file
  1557 			if (QFile (fn).exists())
  1558 			{
  1559 				QMessageBox mb( "VYM",
  1560 					tr("The file ") + fn + tr ("\nexists already. Do you want to"),
  1561 					QMessageBox::Warning,
  1562 					QMessageBox::Yes | QMessageBox::Default,
  1563 					QMessageBox::Cancel | QMessageBox::Escape,
  1564 					QMessageBox::QMessageBox::NoButton);
  1565 				mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
  1566 				mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
  1567 				switch( mb.exec() ) 
  1568 				{
  1569 					case QMessageBox::Yes:
  1570 						// save 
  1571 						break;
  1572 					case QMessageBox::Cancel:
  1573 						// do nothing
  1574 						return;
  1575 						break;
  1576 				}
  1577 			} else
  1578 			{
  1579 				// New file, add extension to filename, if missing
  1580 				// This is always .vym or .vyp, depending on savemode
  1581 				if (savemode==CompleteMap)
  1582 				{
  1583 					if (!fn.contains (".vym") && !fn.contains (".xml"))
  1584 						fn +=".vym";
  1585 				} else		
  1586 				{
  1587 					if (!fn.contains (".vyp") && !fn.contains (".xml"))
  1588 						fn +=".vyp";
  1589 				}
  1590 			}
  1591 	
  1592 
  1593 
  1594 
  1595 			// Save now
  1596 			currentMapEditor()->setFilePath(fn);
  1597 			fileSave(savemode);
  1598 
  1599 			// Set name of tab
  1600 			if (savemode==CompleteMap)
  1601 				tabWidget->setTabLabel (currentMapEditor(),
  1602 					currentMapEditor()->getFileName() );
  1603 			return;
  1604 		} 
  1605 	}
  1606 }
  1607 
  1608 void Main::fileSaveAs()
  1609 {
  1610 	fileSaveAs (CompleteMap);
  1611 }
  1612 
  1613 void Main::fileImportDir()
  1614 {
  1615 	if (currentMapEditor())
  1616 		currentMapEditor()->importDir();	
  1617 }
  1618 
  1619 void Main::fileExportXML()
  1620 {
  1621 	if (currentMapEditor())
  1622 	{
  1623 		QString dir=browseDirectory(tr("Export XML to directory"));
  1624 		if (dir !="" && reallyWriteDirectory(dir) )
  1625 			currentMapEditor()->exportXML(dir);
  1626 	}	
  1627 }
  1628 
  1629 void Main::fileExportHTML()
  1630 {
  1631 	if (currentMapEditor())
  1632 	{
  1633 		ExportHTMLDialog dia(this);
  1634 		
  1635 		if (dia.exec()==QDialog::Accepted)
  1636 		{
  1637 			QString dir=dia.getDir();
  1638 			if (reallyWriteDirectory(dir) )
  1639 			{
  1640 				currentMapEditor()->exportXML (dia.getDir() );
  1641 				dia.doExport(currentMapEditor()->getMapName() );
  1642 			}	
  1643 		}
  1644 	}	
  1645 }
  1646 
  1647 void Main::fileExportXHTML()
  1648 {
  1649 	QString dir;
  1650 	if (currentMapEditor())
  1651 	{
  1652 		ExportXHTMLDialog dia(this);
  1653 		dia.setFilePath (currentMapEditor()->getFilePath() );
  1654 		dia.setMapName (currentMapEditor()->getMapName() );
  1655 		dia.readSettings();
  1656 		
  1657 		if (dia.exec()==QDialog::Accepted)
  1658 		{
  1659 			QString dir=dia.getDir();
  1660 			// Check, if warnings should be used before overwriting
  1661 			// the output directory
  1662 			bool ok;
  1663 			if (dia.warnings()) 
  1664 				ok=reallyWriteDirectory(dir);
  1665 			else
  1666 				ok=true;
  1667 
  1668 			if (ok)
  1669 			{
  1670 				currentMapEditor()->exportXML (dia.getDir() );
  1671 				dia.doExport(currentMapEditor()->getMapName() );
  1672 				if (dia.hasChanged())
  1673 					currentMapEditor()->setChanged();
  1674 			}	
  1675 		}
  1676 	}	
  1677 }
  1678 
  1679 void Main::fileExportImage(int item)
  1680 {
  1681 	if (currentMapEditor())
  1682 	{
  1683 		QString fn = QFileDialog::getSaveFileName( QString::null, "Image  (*.bmp *.jpg *.pbm *.pgm *.png *.ppm *xbm *.xpm)",
  1684 							   this );
  1685 		if ( !fn.isEmpty() ) 
  1686 		{
  1687 			currentMapEditor()->exportImage(fn,item);
  1688 		} else {
  1689 			statusBar()->message( tr("Couldn't save") + fn, statusbarTime );
  1690 		}
  1691 	}
  1692 }
  1693 
  1694 void Main::fileExportASCII()
  1695 {
  1696 	if (currentMapEditor())
  1697 		currentMapEditor()->exportASCII();	
  1698 }
  1699 
  1700 void Main::fileCloseMap()
  1701 {
  1702 	if (currentMapEditor())
  1703 	{
  1704 		if (currentMapEditor()->hasChanged())
  1705 		{
  1706 			QMessageBox mb( "VYM",
  1707 				tr("The map ") + currentMapEditor()->getFileName() +
  1708 				tr(" has been modified but not saved yet. Do you want to"),
  1709 				QMessageBox::Warning,
  1710 				QMessageBox::Yes | QMessageBox::Default,
  1711 				QMessageBox::No,
  1712 				QMessageBox::Cancel | QMessageBox::Escape );
  1713 			mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
  1714 			mb.setButtonText( QMessageBox::No, tr("Discard changes"));
  1715 			switch( mb.exec() ) 
  1716 			{
  1717 				case QMessageBox::Yes:
  1718 					// save and close
  1719 					fileSave(CompleteMap);
  1720 					break;
  1721 				case QMessageBox::No:
  1722 				// close  without saving
  1723 					break;
  1724 				case QMessageBox::Cancel:
  1725 					// do nothing
  1726 				return;
  1727 			}
  1728 		} 
  1729 		currentMapEditor()->closeMap();
  1730 		tabWidget->removePage(currentMapEditor());
  1731 		if (tabWidget->count()==0)
  1732 			actionFilePrint->setEnabled (false);
  1733 	}	
  1734 }
  1735 
  1736 void Main::filePrint()
  1737 {
  1738 	if (currentMapEditor())
  1739 		currentMapEditor()->print();
  1740 }
  1741 
  1742 void Main::fileExitVYM()
  1743 {
  1744 	// Check if one or more editors have changed
  1745 	MapEditor *me;
  1746 	int i;
  1747 	for (i=0;i<=tabWidget->count() -1;i++)
  1748 	{
  1749 		
  1750 		me=(MapEditor*)tabWidget->page(i);
  1751 
  1752 		// If something changed, ask what to do
  1753 		if (me->isUnsaved())
  1754 		{
  1755 			tabWidget->setCurrentPage(i);
  1756 			QMessageBox mb( "VYM",
  1757 				tr("This map is not saved yet. Do you want to"),
  1758 				QMessageBox::Warning,
  1759 				QMessageBox::Yes | QMessageBox::Default,
  1760 				QMessageBox::No,
  1761 				QMessageBox::Cancel | QMessageBox::Escape );
  1762 			mb.setButtonText( QMessageBox::Yes, tr("Save map") );
  1763 			mb.setButtonText( QMessageBox::No, tr("Discard changes") );
  1764 			mb.show();
  1765 			// Call undocumented function: setActiveWindow is only
  1766 			// possible, if widget is visible. This depends on
  1767 			// windowmanager...
  1768 #if defined(Q_OS_LINUX)
  1769 			qt_wait_for_window_manager( this);
  1770 #endif			
  1771 			mb.setActiveWindow();
  1772 			switch( mb.exec() ) {
  1773 				case QMessageBox::Yes:
  1774 					// save (the changed editors) and exit
  1775 					fileSave(CompleteMap);
  1776 					break;
  1777 				case QMessageBox::No:
  1778 					// exit without saving
  1779 					break;
  1780 				case QMessageBox::Cancel:
  1781 					// don't save and don't exit
  1782 				return;
  1783 			}
  1784 		}
  1785 	} // loop over all MEs	
  1786     qApp->quit();
  1787 }
  1788 
  1789 void Main::editUndo()
  1790 {
  1791 	if (currentMapEditor())
  1792 		currentMapEditor()->undo();
  1793 }
  1794 
  1795 void Main::editRedo()	    // TODO
  1796 {
  1797 }
  1798 
  1799 void Main::editCopy()
  1800 {
  1801 	if (currentMapEditor())
  1802 		currentMapEditor()->copy();
  1803 }
  1804 
  1805 void Main::editPaste()
  1806 {
  1807 	if (currentMapEditor())
  1808 		currentMapEditor()->paste();
  1809 }
  1810 
  1811 void Main::editCut()
  1812 {
  1813 	if (currentMapEditor())
  1814 		currentMapEditor()->cut();
  1815 }
  1816 
  1817 void Main::editOpenFindWindow()
  1818 {
  1819 	findWindow->popup();
  1820 	findWindow->raise();
  1821 
  1822 	// Call undocumented function: setActiveWindow is only
  1823 	// possible, if widget is visible. This depends on
  1824 	// windowmanager...
  1825 #if defined(Q_OS_LINUX)
  1826 	qt_wait_for_window_manager( this);
  1827 #endif	
  1828 	findWindow->setActiveWindow();
  1829 }
  1830 
  1831 void Main::editFind(QString s)
  1832 {
  1833 	bool cs=false;
  1834 	BranchObj *bo=currentMapEditor()->findText(s, cs);
  1835 	if (bo)
  1836 	{	
  1837 		statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
  1838 	} else
  1839 	{
  1840 		QMessageBox::information( findWindow, tr( "VYM -Information:" ),
  1841 							   tr("No matches found for ")+
  1842 							   "'<b>"+s+"</b>'");
  1843 	}	
  1844 }
  1845 
  1846 void Main::editFindChanged()
  1847 {	// Notify editor, to abort the current find process
  1848 	currentMapEditor()->findReset();
  1849 }
  1850 
  1851 void Main::editOpenURL()
  1852 {
  1853 	if (currentMapEditor())
  1854 	    currentMapEditor()->openURL();
  1855 }
  1856 
  1857 void Main::editURL()
  1858 {
  1859 	if (currentMapEditor())
  1860 	    currentMapEditor()->editURL();
  1861 }
  1862 
  1863 void Main::editHeading2URL()
  1864 {
  1865 	if (currentMapEditor())
  1866 	    currentMapEditor()->editHeading2URL();
  1867 }
  1868 
  1869 void Main::editBugzilla2URL()
  1870 {
  1871 	if (currentMapEditor())
  1872 	    currentMapEditor()->editBugzilla2URL();
  1873 }
  1874 
  1875 void Main::editOpenVymLink()
  1876 {
  1877 	// Get current path to map
  1878 	QString currentVymLink;
  1879 	if (currentMapEditor())
  1880 	{
  1881 		currentVymLink=currentMapEditor()->getVymLink();	
  1882 		// compare path with already loaded maps
  1883 		int index=-1;
  1884 		int i;
  1885 		MapEditor *me;
  1886 		for (i=0;i<=tabWidget->count() -1;i++)
  1887 		{
  1888 			me=(MapEditor*)tabWidget->page(i);
  1889 			if (currentVymLink==me->getFilePath() )
  1890 			{
  1891 				index=i;
  1892 				break;
  1893 			}
  1894 		}	
  1895 		if (index<0)
  1896 		// Load map
  1897 		{
  1898 			if (!QFile(currentVymLink).exists() )
  1899 				QMessageBox::critical( 0, tr( "Critical Error" ),
  1900 				   tr("Couldn't open map " +currentVymLink)+".");
  1901 			else
  1902 			{
  1903 				fileLoad (currentVymLink, NewMap);
  1904 				tabWidget->setCurrentPage (tabWidget->count()-1);	
  1905 			}
  1906 		} else
  1907 			// Go to tab containing the map
  1908 			tabWidget->setCurrentPage (index);	
  1909 	}
  1910 }
  1911 
  1912 void Main::editVymLink()
  1913 {
  1914 	if (currentMapEditor())
  1915 		currentMapEditor()->editVymLink();	
  1916 }
  1917 
  1918 void Main::editDeleteVymLink()
  1919 {
  1920 	if (currentMapEditor())
  1921 		currentMapEditor()->deleteVymLink();	
  1922 }
  1923 
  1924 void Main::editMapInfo()
  1925 {
  1926 	if (currentMapEditor())
  1927 		currentMapEditor()->editMapInfo();	
  1928 }
  1929 
  1930 void Main::editMoveUp()
  1931 {
  1932 	if (currentMapEditor())
  1933 	    currentMapEditor()->moveBranchUp();
  1934 }
  1935 
  1936 void Main::editMoveDown()
  1937 {
  1938 	if (currentMapEditor())
  1939 		currentMapEditor()->moveBranchDown();
  1940 }
  1941 
  1942 void Main::editToggleScroll()
  1943 {
  1944 	if (currentMapEditor())
  1945 	{
  1946 		currentMapEditor()->toggleScroll();	
  1947 	}	
  1948 }
  1949 
  1950 void Main::editUnScrollAll()
  1951 {
  1952 	if (currentMapEditor())
  1953 	{
  1954 		currentMapEditor()->unScrollAll();	
  1955 	}	
  1956 }
  1957 
  1958 void Main::editHeading()
  1959 {
  1960 	if (currentMapEditor())
  1961 		currentMapEditor()->editHeading();
  1962 }
  1963 
  1964 void Main::editNewBranch()
  1965 {
  1966 	if (currentMapEditor())
  1967 		currentMapEditor()->addNewBranch(0);
  1968 }
  1969 
  1970 void Main::editNewBranchHere()
  1971 {
  1972 	if (currentMapEditor())
  1973 		currentMapEditor()->addNewBranchHere();
  1974 }
  1975 
  1976 void Main::editNewBranchAbove()
  1977 {
  1978 	if (currentMapEditor())
  1979 		currentMapEditor()->addNewBranch(-1);
  1980 }
  1981 
  1982 void Main::editNewBranchBelow()
  1983 {
  1984 	if (currentMapEditor())
  1985 		currentMapEditor()->addNewBranch(1);
  1986 }
  1987 
  1988 void Main::editImportAdd()
  1989 {
  1990 	fileLoad (ImportAdd);
  1991 }
  1992 
  1993 void Main::editImportReplace()
  1994 {
  1995 	fileLoad (ImportReplace);
  1996 }
  1997 
  1998 void Main::editSaveBranch()
  1999 {
  2000 	fileSaveAs (PartOfMap);
  2001 }
  2002 
  2003 void Main::editRemoveBranchHere()
  2004 {
  2005 	if (currentMapEditor())
  2006 		currentMapEditor()->removeBranchHere();
  2007 }
  2008 
  2009 void Main::editRemoveChilds()
  2010 {
  2011 	if (currentMapEditor())
  2012 		currentMapEditor()->removeChilds();
  2013 }
  2014 
  2015 void Main::editDeleteSelection()
  2016 {
  2017 	if (currentMapEditor())
  2018 		currentMapEditor()->deleteSelection();
  2019 }
  2020 
  2021 void Main::editUpperBranch()
  2022 {
  2023 	if (currentMapEditor())
  2024 		currentMapEditor()->selectUpperBranch();
  2025 }
  2026 
  2027 void Main::editLowerBranch()
  2028 {
  2029 	if (currentMapEditor())
  2030 		currentMapEditor()->selectLowerBranch();
  2031 }
  2032 
  2033 void Main::editLeftBranch()
  2034 {
  2035 	if (currentMapEditor())
  2036 		currentMapEditor()->selectLeftBranch();
  2037 }
  2038 
  2039 void Main::editRightBranch()
  2040 {
  2041 	if (currentMapEditor())
  2042 		currentMapEditor()->selectRightBranch();
  2043 }
  2044 
  2045 void Main::editFirstBranch()
  2046 {
  2047 	if (currentMapEditor())
  2048 		currentMapEditor()->selectFirstBranch();
  2049 }
  2050 
  2051 void Main::editLastBranch()
  2052 {
  2053 	if (currentMapEditor())
  2054 		currentMapEditor()->selectLastBranch();
  2055 }
  2056 
  2057 void Main::editLoadImage()
  2058 {
  2059 	if (currentMapEditor())
  2060 		currentMapEditor()->loadFloatImage();
  2061 }
  2062 
  2063 void Main::editSaveImage(int item)
  2064 {
  2065 	if (currentMapEditor())
  2066 		currentMapEditor()->saveFloatImage(item);
  2067 }
  2068 
  2069 void Main::editToggleFloatExport()
  2070 {
  2071 	if (currentMapEditor())
  2072 		currentMapEditor()->toggleFloatExport();
  2073 }
  2074 
  2075 void Main::editFollowXLink(int item)
  2076 {
  2077 	if (currentMapEditor())
  2078 		currentMapEditor()->followXLink(branchLinksContextMenu->indexOf(item));
  2079 }
  2080 
  2081 void Main::editEditXLink(int item)
  2082 {
  2083 	if (currentMapEditor())
  2084 		currentMapEditor()->editXLink(branchLinksContextMenuDup->indexOf(item));
  2085 }
  2086 
  2087 void Main::formatSelectColor()
  2088 {
  2089 	if (currentMapEditor())
  2090 	{
  2091 		QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
  2092 		if ( !col.isValid() ) return;
  2093 		currentMapEditor()->setColor( col );
  2094 		colorChanged( col );
  2095 	}	
  2096 }
  2097 
  2098 void Main::formatPickColor()
  2099 {
  2100 	if (currentMapEditor())
  2101 		colorChanged( currentMapEditor()->pickColor() );
  2102 }
  2103 
  2104 void Main::colorChanged(QColor c)
  2105 {
  2106     QPixmap pix( 16, 16 );
  2107     pix.fill( c );
  2108     actionFormatColor->setIconSet( pix );
  2109 }
  2110 
  2111 void Main::formatColorItem()
  2112 {
  2113 	if (currentMapEditor())
  2114 		currentMapEditor()->colorItem();
  2115 }
  2116 
  2117 void Main::formatColorBranch()
  2118 {
  2119 	if (currentMapEditor())
  2120 		currentMapEditor()->colorBranch();
  2121 }
  2122 
  2123 void Main::formatLinkStyleLine()
  2124 {
  2125 	if (currentMapEditor())
  2126 		currentMapEditor()->setLinkStyle(StyleLine);
  2127 }
  2128 
  2129 void Main::formatLinkStyleParabel()
  2130 {
  2131 	if (currentMapEditor())
  2132 		currentMapEditor()->setLinkStyle(StyleParabel);
  2133 }
  2134 
  2135 void Main::formatLinkStylePolyLine()
  2136 {
  2137 	if (currentMapEditor())
  2138 		currentMapEditor()->setLinkStyle(StylePolyLine);
  2139 }
  2140 
  2141 void Main::formatLinkStylePolyParabel()
  2142 {
  2143 	if (currentMapEditor())
  2144 		currentMapEditor()->setLinkStyle(StylePolyParabel);
  2145 }
  2146 
  2147 void Main::formatSelectBackColor()
  2148 {
  2149 	if (currentMapEditor())
  2150 		currentMapEditor()->selectBackgroundColor();
  2151 }
  2152 
  2153 void Main::formatSelectLinkColor()
  2154 {
  2155 	if (currentMapEditor())
  2156 		currentMapEditor()->selectLinkColor();
  2157 }
  2158 
  2159 void Main::formatToggleLinkColorHint()
  2160 {
  2161 	currentMapEditor()->toggleLinkColorHint();
  2162 }
  2163 
  2164 void Main::formatFrameNone()
  2165 {
  2166 	if (currentMapEditor())
  2167 		currentMapEditor()->setFrame(NoFrame);
  2168 }
  2169 
  2170 void Main::formatFrameRectangle()
  2171 {
  2172 	if (currentMapEditor())
  2173 		currentMapEditor()->setFrame(Rectangle);
  2174 }
  2175 
  2176 void Main::viewZoomReset()
  2177 {
  2178 	if (currentMapEditor())
  2179 	{
  2180 		QWMatrix m;
  2181 		m.reset();
  2182 		currentMapEditor()->setWorldMatrix( m );
  2183 		currentMapEditor()->setViewCenter();
  2184 		currentMapEditor()->adjustCanvasSize();
  2185 	}	
  2186 }
  2187 
  2188 void Main::viewZoomIn()
  2189 {
  2190 	if (currentMapEditor())
  2191 	{
  2192 		QWMatrix m = currentMapEditor()->worldMatrix();
  2193 		m.scale( 1.25, 1.25 );
  2194 		currentMapEditor()->setWorldMatrix( m );
  2195 		currentMapEditor()->setViewCenter();
  2196 		currentMapEditor()->adjustCanvasSize();
  2197 	}	
  2198 }
  2199 
  2200 void Main::viewZoomOut()
  2201 {
  2202 	if (currentMapEditor())
  2203 	{
  2204 		QWMatrix m = currentMapEditor()->worldMatrix();
  2205 		m.scale( 0.8, 0.8 );
  2206 		currentMapEditor()->setWorldMatrix( m );
  2207 		currentMapEditor()->setViewCenter();
  2208 		currentMapEditor()->adjustCanvasSize();
  2209 	}	
  2210 }
  2211 
  2212 void Main::modModeColor()
  2213 {
  2214 }
  2215 
  2216 void Main::modModeLink()
  2217 {
  2218 }
  2219 
  2220 bool Main::settingsPDF()
  2221 {
  2222 	// Default browser is set in constructor
  2223 	bool ok;
  2224 	QString text = QInputDialog::getText(
  2225 		"VYM", tr("Enter path for pdf reader:"), QLineEdit::Normal,
  2226 		settings.readEntry("/vym/mainwindow/readerPDF"), &ok, this );
  2227 	if (ok)
  2228 		settings.writeEntry ("/vym/mainwindow/readerPDF",text);
  2229 	return ok;
  2230 }
  2231 
  2232 
  2233 bool Main::settingsURL()
  2234 {
  2235 	// Default browser is set in constructor
  2236 	bool ok;
  2237 	QString text = QInputDialog::getText(
  2238 		"VYM", tr("Enter path for application to open an URL:"), QLineEdit::Normal,
  2239 		settings.readEntry("/vym/mainwindow/readerURL")
  2240 		, &ok, this );
  2241 	if (ok)
  2242 		settings.writeEntry ("/vym/mainwindow/readerURL",text);
  2243 	return ok;
  2244 }
  2245 
  2246 void Main::windowToggleNoteEditor()
  2247 {
  2248 	if (textEditor->showWithMain() )
  2249 		windowHideNoteEditor();
  2250 	else	
  2251 		windowShowNoteEditor();
  2252 }
  2253 
  2254 void Main::windowShowNoteEditor()
  2255 {
  2256 	textEditor->setShowWithMain(true);
  2257 	textEditor->show();
  2258 	actionViewToggleNoteEditor->setOn (true);
  2259 }
  2260 
  2261 void Main::windowHideNoteEditor()
  2262 {
  2263 	textEditor->setShowWithMain(false);
  2264 	textEditor->hide();
  2265 	actionViewToggleNoteEditor->setOn (false);
  2266 }
  2267 
  2268 void Main::windowNextEditor()
  2269 {
  2270 	if (tabWidget->currentPageIndex() < tabWidget->count())
  2271 		tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
  2272 }
  2273 
  2274 void Main::windowPreviousEditor()
  2275 {
  2276 	if (tabWidget->currentPageIndex() >0)
  2277 		tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
  2278 }
  2279 
  2280 void Main::standardFlagChanged()
  2281 {
  2282 	currentMapEditor()->toggleStandardFlag(sender()->name());
  2283 }
  2284 
  2285 void Main::testFunction()
  2286 {
  2287 	//textEditor->stackUnder(this);
  2288 	currentMapEditor()->testFunction();
  2289 }
  2290 
  2291 void Main::testShowClipboard()
  2292 {
  2293 	clipboardME->show();
  2294 }
  2295 
  2296 void Main::helpDoc()
  2297 {
  2298 	QString docpath;
  2299 	// default path in SUSE LINUX
  2300 	docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
  2301 
  2302 	if (!QFile (docpath).exists() )
  2303 	{
  2304 		// relative path for easy testing in tarball
  2305 		docpath="doc/vym.pdf";
  2306 		if (!QFile (docpath).exists() )
  2307 		{
  2308 			// relative path for testing while still writing vym.tex
  2309 			docpath="doc/tex/vym.pdf";
  2310 			if (!QFile (docpath).exists() )
  2311 			{
  2312 				QMessageBox::critical(0, 
  2313 				tr("Critcal error"),
  2314 				tr("Couldn't find the documentation\n"
  2315 				"vym.pdf in various places."));
  2316 				return;
  2317 			}	
  2318 		}
  2319 	}
  2320 	
  2321 	Process *pdfProc = new Process();
  2322 	pdfProc->clearArguments();
  2323 	pdfProc->addArgument( settings.readEntry("/vym/mainwindow/readerPDF"));
  2324 	pdfProc->addArgument( docpath);
  2325 
  2326 	if ( !pdfProc->start() ) 
  2327 	{
  2328 		// error handling
  2329 		QMessageBox::critical(0, 
  2330 		tr("Critcal error"),
  2331 		tr("Couldn't find a viewer to read vym.pdf.\n"
  2332 		"Please use Settings->")+tr("Set application to open pdf files"));
  2333 		return;
  2334 	}
  2335 }
  2336 
  2337 
  2338 void Main::helpAbout()
  2339 {
  2340     static QMessageBox* about = new QMessageBox( "VYM",
  2341 			"<h3>VYM - View Your Mind </h3>"
  2342 			"<p> A tool to put the things you have got in your mind into a map.</p>"
  2343 			"<ul>"
  2344 				"<li> (c) by Uwe Drechsel (vym@InSilmaril.de)</li>"
  2345 				"<li> vym is released under the GPL (Gnu General Public License)"
  2346 				", with one exception (see the file \"LICENSE\"which "
  2347 				"comes with vym). This exception is needed to build vym with QT libraries for proprietary operating systems.</li>"
  2348 				"<li> Project homepage <a href=\"http:/www.InSilmaril.de/vym\">"
  2349     					"http:/www.InSilmaril.de/vym</a></li>"
  2350 			"<li> Credits " 
  2351 				"<ul>"
  2352 					"<li>Thomas Schraitle for the stylesheet  used for XHTML-export </li>"
  2353 					"<li>Clemens Kraus for stylesheets and script used for HTML-export "
  2354 					"<a href=\"http://www.clemens-kraus.de\">(www.clemens-kraus.de)</a></li>"
  2355 					"<li>Alexander Johannesen for providing stylesheets from his xsiteable project " 
  2356 					"<a href=\"http://www.shelter.nu/xsiteable/xsiteable.html\">(www.shelter.nu/xsiteable/xsiteable.html)</a>. </li>"
  2357 					"<li>Ken Wimer and Olaf Hering for Mac support</li>"
  2358 				"</ul>"
  2359 			"</li>"
  2360 			"<li> Version "  __VYM_VERSION__  "</li>"
  2361 				"<li> Build date "  __BUILD_DATE__"</li>"
  2362 			"</ul>", QMessageBox::Information, 1, 0, 0, this, 0, FALSE );
  2363     about->setButtonText( 1, "Dismiss" );
  2364     about->setMinimumSize(QSize(300,300));
  2365 	about->setIconPixmap (QPixmap(vym_logo_xpm));
  2366     about->show();
  2367 }
  2368 
  2369 void Main::helpAboutQT()
  2370 {
  2371 	QMessageBox::aboutQt( this, "Qt Application Example" );
  2372 }
  2373