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