mainwindow.cpp
author insilmaril
Thu, 21 Apr 2005 19:14:38 +0000
changeset 97 0b048b6bb6f4
parent 95 f688a9913724
child 98 58adc2d2ed08
permissions -rw-r--r--
xlink color, width and defaults can be saved/ restored now
     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 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 XLink"),branchLinksContextMenu);
   856 	connect( branchLinksContextMenu, SIGNAL( activated(int) ), this, SLOT( editFollowXLink(int ) ) );
   857 	
   858 	branchLinksContextMenuDup =new QPopupMenu (this);
   859 	branchContextMenu->insertItem (tr("Edit XLink"),branchLinksContextMenuDup);
   860 	connect( branchLinksContextMenuDup, SIGNAL( activated(int) ), this, SLOT( editEditXLink(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("This map does not exist:\n  ")+fn+tr("\nDo you want to create a new one?"),
  1139 				QMessageBox::Question,
  1140 				QMessageBox::Yes ,
  1141 				QMessageBox::Cancel | QMessageBox::Default,
  1142 				QMessageBox::QMessageBox::NoButton );
  1143 
  1144 			mb.setButtonText( QMessageBox::Yes, tr("Create"));
  1145 			mb.setButtonText( QMessageBox::No, tr("Cancel"));
  1146 			switch( mb.exec() ) 
  1147 			{
  1148 				case QMessageBox::Yes:
  1149 					// Create new map
  1150 					currentMapEditor()->setFilePath(fn);
  1151 					tabWidget->setTabLabel (currentMapEditor(),
  1152 						currentMapEditor()->getFileName() );
  1153 					statusBar()->message( "Created " + fn , statusbarTime );
  1154 					return;
  1155 						
  1156 				case QMessageBox::Cancel:
  1157 					// don't create new map
  1158 					statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
  1159 					fileCloseMap();
  1160 					return;
  1161 			}
  1162 		}	
  1163 
  1164 
  1165 		//tabWidget->currentPage() won't be NULL here, because of above...
  1166 		tabWidget->showPage(me);
  1167 		me->viewport()->setFocus();
  1168 
  1169 		// Create temporary directory for packing
  1170 		char tmpdir1[]="/tmp/vym-XXXXXX";	
  1171 		QString tmpMapDir=mkdtemp(tmpdir1);
  1172 
  1173 		// Try to unzip file
  1174 		Process *zipProc=new Process ();
  1175 		zipProc->clearArguments();
  1176 		zipProc->setWorkingDirectory (QDir(tmpMapDir));
  1177 		zipProc->addArgument ("unzip");
  1178 		zipProc->addArgument (fn );
  1179 		zipProc->addArgument ("-d");
  1180 		zipProc->addArgument (tmpMapDir);
  1181 
  1182 		if (!zipProc->start() )
  1183 		{
  1184 			QMessageBox::critical( 0, tr( "Critical Load Error" ),
  1185 						   tr("Couldn't start unzip to decompress data."));
  1186 			err=aborted;
  1187 			
  1188 		} else
  1189 		{
  1190 			zipProc->waitFinished();
  1191 			if (!zipProc->normalExit() )
  1192 			{
  1193 				QMessageBox::critical( 0, tr( "Critical Load Error" ),
  1194 							   tr("unzip didn't exit normally") +
  1195 							   zipProc->getErrout() );
  1196 				err=aborted;
  1197 			} else
  1198 			{
  1199 				if (zipProc->exitStatus()>0)
  1200 				{
  1201 					if (zipProc->exitStatus()==9)
  1202 					{
  1203 						// no zipped file, but maybe .xml or old version? Try again.
  1204 						mapfile=fn;
  1205 						me->setZipped(false);
  1206 					}	
  1207 					else	
  1208 					{
  1209 						QMessageBox::critical( 0, tr( "Critical Load Error" ),
  1210 									   QString("unzip exit code:  %1").arg(zipProc->exitStatus() ) +
  1211 									   zipProc->getErrout() );
  1212 						err=aborted;
  1213 					}
  1214 				} else
  1215 				{	// Uncompressing was successfull,
  1216 					// load from uncompressed temporary directory
  1217 
  1218 					me->setZipped(true);
  1219 
  1220 					
  1221 					// Look for mapname.xml
  1222 					mapfile= fn.left(fn.findRev(".",-1,true));
  1223 					mapfile=mapfile.section( '/', -1 );
  1224 					QFile file( tmpMapDir + "/" + mapfile + ".xml");
  1225 					if (!file.exists() )
  1226 					{
  1227 						// mapname.xml does not exist, well, 
  1228 						// maybe some renamed the mapname.vym file...
  1229 						// Try to find any .xml in the toplevel 
  1230 						// directory of the .vym file
  1231 						QStringList flist=QDir (tmpMapDir).entryList("*.xml");
  1232 						if (flist.count()==1) 
  1233 						{
  1234 							// Only one entry, take this one
  1235 							mapfile=tmpMapDir + "/"+flist.first();
  1236 						} else
  1237 						{
  1238 							for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it ) 
  1239 								*it=tmpMapDir + "/" + *it;
  1240 							// FIXME	
  1241 							// Multiple entries, load all (but only the first one into this ME)
  1242 							//mainWindow->fileLoadFromTmp (flist);
  1243 							//returnCode=1;	// Silently forget this attempt to load
  1244 							qWarning ("MainWindow::load (fn)  multimap found...");
  1245 						}	
  1246 							
  1247 						if (flist.isEmpty() )
  1248 						{
  1249 							QMessageBox::critical( 0, tr( "Critical Load Error" ),
  1250 									   tr("Couldn't find a map (*.xml) in .vym archive.\n"));
  1251 							err=aborted;				   
  1252 						}	
  1253 					} //file doesn't exist	
  1254 					else
  1255 						mapfile=file.name();
  1256 				} // Uncompressing successfull
  1257 			}
  1258 		}
  1259 
  1260 		// Finally load map into mapEditor
  1261 		me->setFilePath (mapfile,fn);
  1262 		if (me->load(mapfile,lmode))
  1263 			err=aborted;
  1264 
  1265 		// Delete tmpDir
  1266 		system ( "rm -rf "+tmpMapDir);
  1267 
  1268 		// Check for errors
  1269 		if (err==success) 
  1270 		{
  1271 			if (lmode==NewMap)
  1272 			{
  1273 				me->setFilePath (fn);
  1274 				tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
  1275 				lastMaps.prepend(me->getFilePath() );
  1276 				setupLastMapsMenu();
  1277 				actionFilePrint->setEnabled (true);
  1278 			}	
  1279 			statusBar()->message( "Loaded " + fn, statusbarTime );
  1280 			return;
  1281 		} else 
  1282 		{
  1283 			if (lmode==NewMap)
  1284 				fileCloseMap();
  1285 		}	
  1286 
  1287 
  1288 	}
  1289 	statusBar()->message( "Could not load " + fn, statusbarTime );
  1290 }
  1291 
  1292 
  1293 void Main::fileLoad(const LoadMode &lmode)
  1294 {
  1295 	QFileDialog *fd=new QFileDialog( this);
  1296 	if (!lastFileDir.isEmpty()) 
  1297 		fd->setDir (lastFileDir);
  1298 	fd->addFilter ("XML (*.xml)");
  1299 	fd->addFilter ("VYM map (*.vym *.vyp)");
  1300 	switch (lmode)
  1301 	{
  1302 		case NewMap:
  1303 			fd->setCaption(tr("Load vym map"));
  1304 			break;
  1305 		case ImportAdd:
  1306 			fd->setCaption(tr("Import: Add vym map to selection"));
  1307 			break;
  1308 		case ImportReplace:
  1309 			fd->setCaption(tr("Import: Replace selection with vym map"));
  1310 			break;
  1311 	}
  1312 	fd->show();
  1313 
  1314 	QString fn;
  1315 	if ( fd->exec() == QDialog::Accepted )
  1316 	{
  1317 		lastFileDir=fd->dirPath();
  1318         fn = fd->selectedFile();
  1319 		fileLoad(fn, lmode);				   
  1320 	}
  1321 }
  1322 
  1323 void Main::fileLoad()
  1324 {
  1325 	fileLoad (NewMap);
  1326 }
  1327 
  1328 void Main::fileLoadLast(int i)
  1329 {
  1330 	fileLoad(*lastMaps.at(lastMapsMenu->indexOf (i) ),NewMap);			   
  1331 }
  1332 
  1333 void Main::fileSave(const SaveMode &savemode)
  1334 {
  1335 	// tmp dir for zipping 
  1336 	QString tmpMapDir;
  1337 	
  1338 	// Error codes
  1339 	enum errorCode {success,aborted};
  1340 	errorCode err=success;
  1341 	
  1342 	QString safeFilePath;
  1343 
  1344 	bool saveZipped=currentMapEditor()->saveZipped();
  1345 
  1346 	if (currentMapEditor())
  1347 	{
  1348 		QString fn=currentMapEditor()->getFilePath();
  1349 		// filename=unnamed, filepath="" in constructor...
  1350 		if ( !fn.isEmpty() ) 
  1351 		{	
  1352 			// We have a filepath, go on saving			
  1353 			// First remove existing file, we 
  1354 			// don't want to add to old zip archives
  1355 			QFile f(fn);
  1356 			if (f.exists() ) 
  1357 				if (!f.remove())
  1358 					QMessageBox::warning( 0, tr( "Save Error" ),
  1359 						fn+   tr("\ncould not be removed before saving"));
  1360 
  1361 			// Look, if we should zip the data:
  1362 			if (!saveZipped)
  1363 			{
  1364 				QMessageBox mb( "VYM",
  1365 					tr("The map ") + fn + 
  1366 					tr ("\ndid not use the compressed "
  1367 					"vym file format.\nWriting it uncompressed will also write images \n"
  1368 					"and flags and thus may overwrite files in the "
  1369 					"given directory\n\nDo you want to write the map"),
  1370 					QMessageBox::Warning,
  1371 					QMessageBox::Yes | QMessageBox::Default,
  1372 					QMessageBox::No ,
  1373 					QMessageBox::Cancel | QMessageBox::Escape);
  1374 				mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
  1375 				mb.setButtonText( QMessageBox::No, tr("uncompressed") );
  1376 				mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
  1377 				switch( mb.exec() ) 
  1378 				{
  1379 					case QMessageBox::Yes:
  1380 						// save compressed (default file format)
  1381 						saveZipped=true;
  1382 						break;
  1383 					case QMessageBox::No:
  1384 						// save uncompressed
  1385 						saveZipped=false;
  1386 						break;
  1387 					case QMessageBox::Cancel:
  1388 						// do nothing
  1389 						return;
  1390 						break;
  1391 				}
  1392 			}
  1393 
  1394 			if (saveZipped)
  1395 			{
  1396 				char tmpdir1[]="/tmp/vym-XXXXXX";	
  1397 				tmpMapDir=mkdtemp(tmpdir1);
  1398 			
  1399 				safeFilePath=currentMapEditor()->getFilePath();
  1400 				currentMapEditor()->setFilePath (tmpMapDir+"/"+
  1401 					currentMapEditor()->getMapName()+ ".xml",
  1402 					safeFilePath);
  1403 				currentMapEditor()->save (savemode);
  1404 				currentMapEditor()->setFilePath (safeFilePath);
  1405 				
  1406 				// zip the temporary directory
  1407 				Process *zipProc=new Process ();
  1408 				zipProc->clearArguments();
  1409 				zipProc->setWorkingDirectory (QDir(tmpMapDir));
  1410 				zipProc->addArgument ("zip");
  1411 				zipProc->addArgument ("-r");
  1412 				zipProc->addArgument (fn);
  1413 				zipProc->addArgument (".");
  1414 
  1415 				if (!zipProc->start() )
  1416 				{	
  1417 					// zip could not be started
  1418 					QMessageBox::critical( 0, tr( "Critical Save Error" ),
  1419 								   tr("Couldn't start zip to compress data."));
  1420 					err=aborted;
  1421 				} else
  1422 				{
  1423 					// zip could be started
  1424 					zipProc->waitFinished();
  1425 					if (!zipProc->normalExit() )
  1426 					{
  1427 						QMessageBox::critical( 0, tr( "Critical Save Error" ),
  1428 									   tr("zip didn't exit normally")+
  1429 									   "\n" + zipProc->getErrout());
  1430 						err=aborted;
  1431 					} else
  1432 					{
  1433 						if (zipProc->exitStatus()>0)
  1434 						{
  1435 							QMessageBox::critical( 0, tr( "Critical Save Error" ),
  1436 									   QString("zip exit code:  %1").arg(zipProc->exitStatus() )+
  1437 									   "\n" + zipProc->getErrout() );
  1438 							err=aborted;
  1439 						}
  1440 					}
  1441 				}	// zip could be started
  1442 			} // save zipped
  1443 			else
  1444 			{
  1445 				// Save unzipped. 
  1446 				safeFilePath=currentMapEditor()->getFilePath();
  1447 				currentMapEditor()->setFilePath (fn, safeFilePath);
  1448 				currentMapEditor()->save (savemode);
  1449 				currentMapEditor()->setFilePath (safeFilePath);
  1450 			} // save zipped 	
  1451 		} // filepath available
  1452 		else
  1453 		{
  1454 			// We have  no filepath yet,
  1455 			// call fileSaveAs() now, this will call fileSave() 
  1456 			// again.
  1457 			fileSaveAs(savemode);
  1458 		}
  1459     }
  1460 
  1461 	if (currentMapEditor()->saveZipped())
  1462 	{
  1463 		// Delete tmpDir
  1464 		system ( "rm -rf "+ tmpMapDir );
  1465 	} 
  1466 
  1467 	if (err==success)
  1468 		statusBar()->message( 
  1469 			tr("Saved")+" " + currentMapEditor()->getFilePath(), 
  1470 			statusbarTime );
  1471 	else		
  1472 		statusBar()->message( 
  1473 			tr("Couldn't save")+" " + currentMapEditor()->getFilePath(), 
  1474 			statusbarTime );
  1475 }
  1476 
  1477 void Main::fileSave()
  1478 {
  1479 	fileSave (CompleteMap);
  1480 }
  1481 
  1482 void Main::fileSaveAs(const SaveMode& savemode)
  1483 {
  1484 	QString tmpMapDir;
  1485 	QString fn;
  1486 
  1487 	if (currentMapEditor())
  1488 	{
  1489 		if (savemode==CompleteMap)
  1490 			fn = QFileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
  1491 		else		
  1492 			fn = QFileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
  1493 		if ( !fn.isEmpty() ) 
  1494 		{
  1495 			// Check for existing file
  1496 			if (QFile (fn).exists())
  1497 			{
  1498 				QMessageBox mb( "VYM",
  1499 					tr("The file ") + fn + tr ("\nexists already. Do you want to"),
  1500 					QMessageBox::Warning,
  1501 					QMessageBox::Yes | QMessageBox::Default,
  1502 					QMessageBox::Cancel | QMessageBox::Escape,
  1503 					QMessageBox::QMessageBox::NoButton);
  1504 				mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
  1505 				mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
  1506 				switch( mb.exec() ) 
  1507 				{
  1508 					case QMessageBox::Yes:
  1509 						// save 
  1510 						break;
  1511 					case QMessageBox::Cancel:
  1512 						// do nothing
  1513 						return;
  1514 						break;
  1515 				}
  1516 			} else
  1517 			{
  1518 				// New file, add extension to filename, if missing
  1519 				// This is always .vym or .vyp, depending on savemode
  1520 				if (savemode==CompleteMap)
  1521 				{
  1522 					if (!fn.contains (".vym") && !fn.contains (".xml"))
  1523 						fn +=".vym";
  1524 				} else		
  1525 				{
  1526 					if (!fn.contains (".vyp") && !fn.contains (".xml"))
  1527 						fn +=".vyp";
  1528 				}
  1529 			}
  1530 	
  1531 
  1532 
  1533 
  1534 			// Save now
  1535 			currentMapEditor()->setFilePath(fn);
  1536 			fileSave(savemode);
  1537 
  1538 			// Set name of tab
  1539 			if (savemode==CompleteMap)
  1540 				tabWidget->setTabLabel (currentMapEditor(),
  1541 					currentMapEditor()->getFileName() );
  1542 			return;
  1543 		} 
  1544 	}
  1545 }
  1546 
  1547 void Main::fileSaveAs()
  1548 {
  1549 	fileSaveAs (CompleteMap);
  1550 }
  1551 
  1552 void Main::fileImportDir()
  1553 {
  1554 	if (currentMapEditor())
  1555 		currentMapEditor()->importDir();	
  1556 }
  1557 
  1558 void Main::fileExportXML()
  1559 {
  1560 	if (currentMapEditor())
  1561 	{
  1562 		QString dir=browseDirectory(tr("Export XML to directory"));
  1563 		if (dir !="" && reallyWriteDirectory(dir) )
  1564 			currentMapEditor()->exportXML(dir);
  1565 	}	
  1566 }
  1567 
  1568 void Main::fileExportHTML()
  1569 {
  1570 	if (currentMapEditor())
  1571 	{
  1572 		ExportHTMLDialog dia(this);
  1573 		
  1574 		if (dia.exec()==QDialog::Accepted)
  1575 		{
  1576 			QString dir=dia.getDir();
  1577 			if (reallyWriteDirectory(dir) )
  1578 			{
  1579 				currentMapEditor()->exportXML (dia.getDir() );
  1580 				dia.doExport(currentMapEditor()->getMapName() );
  1581 			}	
  1582 		}
  1583 	}	
  1584 }
  1585 
  1586 void Main::fileExportXHTML()
  1587 {
  1588 	QString dir;
  1589 	if (currentMapEditor())
  1590 	{
  1591 		ExportXHTMLDialog dia(this);
  1592 		dia.setFilePath (currentMapEditor()->getFilePath() );
  1593 		dia.setMapName (currentMapEditor()->getMapName() );
  1594 		dia.readSettings();
  1595 		
  1596 		if (dia.exec()==QDialog::Accepted)
  1597 		{
  1598 			QString dir=dia.getDir();
  1599 			// Check, if warnings should be used before overwriting
  1600 			// the output directory
  1601 			bool ok;
  1602 			if (dia.warnings()) 
  1603 				ok=reallyWriteDirectory(dir);
  1604 			else
  1605 				ok=true;
  1606 
  1607 			if (ok)
  1608 			{
  1609 				currentMapEditor()->exportXML (dia.getDir() );
  1610 				dia.doExport(currentMapEditor()->getMapName() );
  1611 				if (dia.hasChanged())
  1612 					currentMapEditor()->setChanged();
  1613 			}	
  1614 		}
  1615 	}	
  1616 }
  1617 
  1618 void Main::fileExportImage(int item)
  1619 {
  1620 	if (currentMapEditor())
  1621 	{
  1622 		QString fn = QFileDialog::getSaveFileName( QString::null, "Image  (*.bmp *.jpg *.pbm *.pgm *.png *.ppm *xbm *.xpm)",
  1623 							   this );
  1624 		if ( !fn.isEmpty() ) 
  1625 		{
  1626 			currentMapEditor()->exportImage(fn,item);
  1627 		} else {
  1628 			statusBar()->message( tr("Couldn't save") + fn, statusbarTime );
  1629 		}
  1630 	}
  1631 }
  1632 
  1633 void Main::fileExportASCII()
  1634 {
  1635 	if (currentMapEditor())
  1636 		currentMapEditor()->exportASCII();	
  1637 }
  1638 
  1639 void Main::fileCloseMap()
  1640 {
  1641 	if (currentMapEditor())
  1642 	{
  1643 		if (currentMapEditor()->hasChanged())
  1644 		{
  1645 			QMessageBox mb( "VYM",
  1646 				tr("The map ") + currentMapEditor()->getFileName() +
  1647 				tr(" has been modified but not saved yet. Do you want to"),
  1648 				QMessageBox::Warning,
  1649 				QMessageBox::Yes | QMessageBox::Default,
  1650 				QMessageBox::No,
  1651 				QMessageBox::Cancel | QMessageBox::Escape );
  1652 			mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
  1653 			mb.setButtonText( QMessageBox::No, tr("Discard changes"));
  1654 			switch( mb.exec() ) 
  1655 			{
  1656 				case QMessageBox::Yes:
  1657 					// save and close
  1658 					fileSave(CompleteMap);
  1659 					break;
  1660 				case QMessageBox::No:
  1661 				// close  without saving
  1662 					break;
  1663 				case QMessageBox::Cancel:
  1664 					// do nothing
  1665 				return;
  1666 			}
  1667 		} 
  1668 		currentMapEditor()->closeMap();
  1669 		tabWidget->removePage(currentMapEditor());
  1670 		if (tabWidget->count()==0)
  1671 			actionFilePrint->setEnabled (false);
  1672 	}	
  1673 }
  1674 
  1675 void Main::filePrint()
  1676 {
  1677 	if (currentMapEditor())
  1678 		currentMapEditor()->print();
  1679 }
  1680 
  1681 void Main::fileExitVYM()
  1682 {
  1683 	// Check if one or more editors have changed
  1684 	MapEditor *me;
  1685 	int i;
  1686 	for (i=0;i<=tabWidget->count() -1;i++)
  1687 	{
  1688 		
  1689 		me=(MapEditor*)tabWidget->page(i);
  1690 
  1691 		// If something changed, ask what to do
  1692 		if (me->isUnsaved())
  1693 		{
  1694 			tabWidget->setCurrentPage(i);
  1695 			QMessageBox mb( "VYM",
  1696 				tr("This map is not saved yet. Do you want to"),
  1697 				QMessageBox::Warning,
  1698 				QMessageBox::Yes | QMessageBox::Default,
  1699 				QMessageBox::No,
  1700 				QMessageBox::Cancel | QMessageBox::Escape );
  1701 			mb.setButtonText( QMessageBox::Yes, tr("Save map") );
  1702 			mb.setButtonText( QMessageBox::No, tr("Discard changes") );
  1703 			mb.show();
  1704 			// Call undocumented function: setActiveWindow is only
  1705 			// possible, if widget is visible. This depends on
  1706 			// windowmanager...
  1707 #if defined(Q_OS_LINUX)
  1708 			qt_wait_for_window_manager( this);
  1709 #endif			
  1710 			mb.setActiveWindow();
  1711 			switch( mb.exec() ) {
  1712 				case QMessageBox::Yes:
  1713 					// save (the changed editors) and exit
  1714 					fileSave(CompleteMap);
  1715 					break;
  1716 				case QMessageBox::No:
  1717 					// exit without saving
  1718 					break;
  1719 				case QMessageBox::Cancel:
  1720 					// don't save and don't exit
  1721 				return;
  1722 			}
  1723 		}
  1724 	} // loop over all MEs	
  1725     qApp->quit();
  1726 }
  1727 
  1728 void Main::editUndo()
  1729 {
  1730 	if (currentMapEditor())
  1731 		currentMapEditor()->undo();
  1732 }
  1733 
  1734 void Main::editRedo()	    // TODO
  1735 {
  1736 }
  1737 
  1738 void Main::editCopy()
  1739 {
  1740 	if (currentMapEditor())
  1741 		currentMapEditor()->copy();
  1742 }
  1743 
  1744 void Main::editPaste()
  1745 {
  1746 	if (currentMapEditor())
  1747 		currentMapEditor()->paste();
  1748 }
  1749 
  1750 void Main::editCut()
  1751 {
  1752 	if (currentMapEditor())
  1753 		currentMapEditor()->cut();
  1754 }
  1755 
  1756 void Main::editOpenFindWindow()
  1757 {
  1758 	findWindow->popup();
  1759 	findWindow->raise();
  1760 
  1761 	// Call undocumented function: setActiveWindow is only
  1762 	// possible, if widget is visible. This depends on
  1763 	// windowmanager...
  1764 #if defined(Q_OS_LINUX)
  1765 	qt_wait_for_window_manager( this);
  1766 #endif	
  1767 	findWindow->setActiveWindow();
  1768 }
  1769 
  1770 void Main::editFind(QString s)
  1771 {
  1772 	bool cs=false;
  1773 	BranchObj *bo=currentMapEditor()->findText(s, cs);
  1774 	if (bo)
  1775 	{	
  1776 		statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
  1777 	} else
  1778 	{
  1779 		QMessageBox::information( findWindow, tr( "VYM -Information:" ),
  1780 							   tr("No matches found for ")+
  1781 							   "'<b>"+s+"</b>'");
  1782 	}	
  1783 }
  1784 
  1785 void Main::editFindChanged()
  1786 {	// Notify editor, to abort the current find process
  1787 	currentMapEditor()->findReset();
  1788 }
  1789 
  1790 void Main::editOpenURL()
  1791 {
  1792 	if (currentMapEditor())
  1793 	    currentMapEditor()->openURL();
  1794 }
  1795 
  1796 void Main::editURL()
  1797 {
  1798 	if (currentMapEditor())
  1799 	    currentMapEditor()->editURL();
  1800 }
  1801 
  1802 void Main::editHeading2URL()
  1803 {
  1804 	if (currentMapEditor())
  1805 	    currentMapEditor()->editHeading2URL();
  1806 }
  1807 
  1808 void Main::editBugzilla2URL()
  1809 {
  1810 	if (currentMapEditor())
  1811 	    currentMapEditor()->editBugzilla2URL();
  1812 }
  1813 
  1814 void Main::editOpenVymLink()
  1815 {
  1816 	// Get current path to map
  1817 	QString currentVymLink;
  1818 	if (currentMapEditor())
  1819 	{
  1820 		currentVymLink=currentMapEditor()->getVymLink();	
  1821 		// compare path with already loaded maps
  1822 		int index=-1;
  1823 		int i;
  1824 		MapEditor *me;
  1825 		for (i=0;i<=tabWidget->count() -1;i++)
  1826 		{
  1827 			me=(MapEditor*)tabWidget->page(i);
  1828 			if (currentVymLink==me->getFilePath() )
  1829 			{
  1830 				index=i;
  1831 				break;
  1832 			}
  1833 		}	
  1834 		if (index<0)
  1835 		// Load map
  1836 		{
  1837 			if (!QFile(currentVymLink).exists() )
  1838 				QMessageBox::critical( 0, tr( "Critical Error" ),
  1839 				   tr("Couldn't open map " +currentVymLink)+".");
  1840 			else
  1841 			{
  1842 				fileLoad (currentVymLink, NewMap);
  1843 				tabWidget->setCurrentPage (tabWidget->count()-1);	
  1844 			}
  1845 		} else
  1846 			// Go to tab containing the map
  1847 			tabWidget->setCurrentPage (index);	
  1848 	}
  1849 }
  1850 
  1851 void Main::editVymLink()
  1852 {
  1853 	if (currentMapEditor())
  1854 		currentMapEditor()->editVymLink();	
  1855 }
  1856 
  1857 void Main::editDeleteVymLink()
  1858 {
  1859 	if (currentMapEditor())
  1860 		currentMapEditor()->deleteVymLink();	
  1861 }
  1862 
  1863 void Main::editMapInfo()
  1864 {
  1865 	if (currentMapEditor())
  1866 		currentMapEditor()->editMapInfo();	
  1867 }
  1868 
  1869 void Main::editMoveUp()
  1870 {
  1871 	if (currentMapEditor())
  1872 	    currentMapEditor()->moveBranchUp();
  1873 }
  1874 
  1875 void Main::editMoveDown()
  1876 {
  1877 	if (currentMapEditor())
  1878 		currentMapEditor()->moveBranchDown();
  1879 }
  1880 
  1881 void Main::editToggleScroll()
  1882 {
  1883 	if (currentMapEditor())
  1884 	{
  1885 		currentMapEditor()->toggleScroll();	
  1886 	}	
  1887 }
  1888 
  1889 void Main::editUnScrollAll()
  1890 {
  1891 	if (currentMapEditor())
  1892 	{
  1893 		currentMapEditor()->unScrollAll();	
  1894 	}	
  1895 }
  1896 
  1897 void Main::editHeading()
  1898 {
  1899 	if (currentMapEditor())
  1900 		currentMapEditor()->editHeading();
  1901 }
  1902 
  1903 void Main::editNewBranch()
  1904 {
  1905 	if (currentMapEditor())
  1906 		currentMapEditor()->addNewBranch(0);
  1907 }
  1908 
  1909 void Main::editNewBranchAbove()
  1910 {
  1911 	if (currentMapEditor())
  1912 		currentMapEditor()->addNewBranch(-1);
  1913 }
  1914 
  1915 void Main::editNewBranchBelow()
  1916 {
  1917 	if (currentMapEditor())
  1918 		currentMapEditor()->addNewBranch(1);
  1919 }
  1920 
  1921 void Main::editImportAdd()
  1922 {
  1923 	fileLoad (ImportAdd);
  1924 }
  1925 
  1926 void Main::editImportReplace()
  1927 {
  1928 	fileLoad (ImportReplace);
  1929 }
  1930 
  1931 void Main::editSaveBranch()
  1932 {
  1933 	fileSaveAs (PartOfMap);
  1934 }
  1935 
  1936 void Main::editDeleteSelection()
  1937 {
  1938 	if (currentMapEditor())
  1939 		currentMapEditor()->deleteSelection();
  1940 }
  1941 
  1942 void Main::editUpperBranch()
  1943 {
  1944 	if (currentMapEditor())
  1945 		currentMapEditor()->selectUpperBranch();
  1946 }
  1947 
  1948 void Main::editLowerBranch()
  1949 {
  1950 	if (currentMapEditor())
  1951 		currentMapEditor()->selectLowerBranch();
  1952 }
  1953 
  1954 void Main::editLeftBranch()
  1955 {
  1956 	if (currentMapEditor())
  1957 		currentMapEditor()->selectLeftBranch();
  1958 }
  1959 
  1960 void Main::editRightBranch()
  1961 {
  1962 	if (currentMapEditor())
  1963 		currentMapEditor()->selectRightBranch();
  1964 }
  1965 
  1966 void Main::editFirstBranch()
  1967 {
  1968 	if (currentMapEditor())
  1969 		currentMapEditor()->selectFirstBranch();
  1970 }
  1971 
  1972 void Main::editLastBranch()
  1973 {
  1974 	if (currentMapEditor())
  1975 		currentMapEditor()->selectLastBranch();
  1976 }
  1977 
  1978 void Main::editLoadImage()
  1979 {
  1980 	if (currentMapEditor())
  1981 		currentMapEditor()->loadFloatImage();
  1982 }
  1983 
  1984 void Main::editSaveImage(int item)
  1985 {
  1986 	if (currentMapEditor())
  1987 		currentMapEditor()->saveFloatImage(item);
  1988 }
  1989 
  1990 void Main::editToggleFloatExport()
  1991 {
  1992 	if (currentMapEditor())
  1993 		currentMapEditor()->toggleFloatExport();
  1994 }
  1995 
  1996 void Main::editFollowXLink(int item)
  1997 {
  1998 	if (currentMapEditor())
  1999 		currentMapEditor()->followXLink(branchLinksContextMenu->indexOf(item));
  2000 }
  2001 
  2002 void Main::editEditXLink(int item)
  2003 {
  2004 	if (currentMapEditor())
  2005 		currentMapEditor()->editXLink(branchLinksContextMenuDup->indexOf(item));
  2006 }
  2007 
  2008 void Main::formatSelectColor()
  2009 {
  2010 	if (currentMapEditor())
  2011 	{
  2012 		QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
  2013 		if ( !col.isValid() ) return;
  2014 		currentMapEditor()->setColor( col );
  2015 		colorChanged( col );
  2016 	}	
  2017 }
  2018 
  2019 void Main::formatPickColor()
  2020 {
  2021 	if (currentMapEditor())
  2022 		colorChanged( currentMapEditor()->pickColor() );
  2023 }
  2024 
  2025 void Main::colorChanged(QColor c)
  2026 {
  2027     QPixmap pix( 16, 16 );
  2028     pix.fill( c );
  2029     actionFormatColor->setIconSet( pix );
  2030 }
  2031 
  2032 void Main::formatColorItem()
  2033 {
  2034 	if (currentMapEditor())
  2035 		currentMapEditor()->colorItem();
  2036 }
  2037 
  2038 void Main::formatColorBranch()
  2039 {
  2040 	if (currentMapEditor())
  2041 		currentMapEditor()->colorBranch();
  2042 }
  2043 
  2044 void Main::formatLinkStyleLine()
  2045 {
  2046 	if (currentMapEditor())
  2047 		currentMapEditor()->setLinkStyle(StyleLine);
  2048 }
  2049 
  2050 void Main::formatLinkStyleParabel()
  2051 {
  2052 	if (currentMapEditor())
  2053 		currentMapEditor()->setLinkStyle(StyleParabel);
  2054 }
  2055 
  2056 void Main::formatLinkStylePolyLine()
  2057 {
  2058 	if (currentMapEditor())
  2059 		currentMapEditor()->setLinkStyle(StylePolyLine);
  2060 }
  2061 
  2062 void Main::formatLinkStylePolyParabel()
  2063 {
  2064 	if (currentMapEditor())
  2065 		currentMapEditor()->setLinkStyle(StylePolyParabel);
  2066 }
  2067 
  2068 void Main::formatSelectBackColor()
  2069 {
  2070 	if (currentMapEditor())
  2071 		currentMapEditor()->selectBackgroundColor();
  2072 }
  2073 
  2074 void Main::formatSelectLinkColor()
  2075 {
  2076 	if (currentMapEditor())
  2077 		currentMapEditor()->selectLinkColor();
  2078 }
  2079 
  2080 void Main::formatToggleLinkColorHint()
  2081 {
  2082 	currentMapEditor()->toggleLinkColorHint();
  2083 }
  2084 
  2085 void Main::formatFrameNone()
  2086 {
  2087 	if (currentMapEditor())
  2088 		currentMapEditor()->setFrame(NoFrame);
  2089 }
  2090 
  2091 void Main::formatFrameRectangle()
  2092 {
  2093 	if (currentMapEditor())
  2094 		currentMapEditor()->setFrame(Rectangle);
  2095 }
  2096 
  2097 void Main::viewZoomReset()
  2098 {
  2099 	if (currentMapEditor())
  2100 	{
  2101 		QWMatrix m;
  2102 		m.reset();
  2103 		currentMapEditor()->setWorldMatrix( m );
  2104 		currentMapEditor()->setViewCenter();
  2105 		currentMapEditor()->adjustCanvasSize();
  2106 	}	
  2107 }
  2108 
  2109 void Main::viewZoomIn()
  2110 {
  2111 	if (currentMapEditor())
  2112 	{
  2113 		QWMatrix m = currentMapEditor()->worldMatrix();
  2114 		m.scale( 1.25, 1.25 );
  2115 		currentMapEditor()->setWorldMatrix( m );
  2116 		currentMapEditor()->setViewCenter();
  2117 		currentMapEditor()->adjustCanvasSize();
  2118 	}	
  2119 }
  2120 
  2121 void Main::viewZoomOut()
  2122 {
  2123 	if (currentMapEditor())
  2124 	{
  2125 		QWMatrix m = currentMapEditor()->worldMatrix();
  2126 		m.scale( 0.8, 0.8 );
  2127 		currentMapEditor()->setWorldMatrix( m );
  2128 		currentMapEditor()->setViewCenter();
  2129 		currentMapEditor()->adjustCanvasSize();
  2130 	}	
  2131 }
  2132 
  2133 void Main::modModeColor()
  2134 {
  2135 }
  2136 
  2137 void Main::modModeLink()
  2138 {
  2139 }
  2140 
  2141 bool Main::settingsPDF()
  2142 {
  2143 	// Default browser is set in constructor
  2144 	bool ok;
  2145 	QString text = QInputDialog::getText(
  2146 		"VYM", tr("Enter path for pdf reader:"), QLineEdit::Normal,
  2147 		settings.readEntry("/vym/mainwindow/readerPDF"), &ok, this );
  2148 	if (ok)
  2149 		settings.writeEntry ("/vym/mainwindow/readerPDF",text);
  2150 	return ok;
  2151 }
  2152 
  2153 
  2154 bool Main::settingsURL()
  2155 {
  2156 	// Default browser is set in constructor
  2157 	bool ok;
  2158 	QString text = QInputDialog::getText(
  2159 		"VYM", tr("Enter path for application to open an URL:"), QLineEdit::Normal,
  2160 		settings.readEntry("/vym/mainwindow/readerURL")
  2161 		, &ok, this );
  2162 	if (ok)
  2163 		settings.writeEntry ("/vym/mainwindow/readerURL",text);
  2164 	return ok;
  2165 }
  2166 
  2167 void Main::windowToggleNoteEditor()
  2168 {
  2169 	if (textEditor->showWithMain() )
  2170 		windowHideNoteEditor();
  2171 	else	
  2172 		windowShowNoteEditor();
  2173 }
  2174 
  2175 void Main::windowShowNoteEditor()
  2176 {
  2177 	textEditor->setShowWithMain(true);
  2178 	textEditor->show();
  2179 	actionViewToggleNoteEditor->setOn (true);
  2180 }
  2181 
  2182 void Main::windowHideNoteEditor()
  2183 {
  2184 	textEditor->setShowWithMain(false);
  2185 	textEditor->hide();
  2186 	actionViewToggleNoteEditor->setOn (false);
  2187 }
  2188 
  2189 void Main::windowNextEditor()
  2190 {
  2191 	if (tabWidget->currentPageIndex() < tabWidget->count())
  2192 		tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
  2193 }
  2194 
  2195 void Main::windowPreviousEditor()
  2196 {
  2197 	if (tabWidget->currentPageIndex() >0)
  2198 		tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
  2199 }
  2200 
  2201 void Main::standardFlagChanged()
  2202 {
  2203 	currentMapEditor()->toggleStandardFlag(sender()->name());
  2204 }
  2205 
  2206 void Main::testFunction()
  2207 {
  2208 	//textEditor->stackUnder(this);
  2209 	currentMapEditor()->testFunction();
  2210 }
  2211 
  2212 void Main::testShowClipboard()
  2213 {
  2214 	clipboardME->show();
  2215 }
  2216 
  2217 void Main::helpDoc()
  2218 {
  2219 	QString docpath;
  2220 	// default path in SUSE LINUX
  2221 	docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
  2222 
  2223 	if (!QFile (docpath).exists() )
  2224 	{
  2225 		// relative path for easy testing in tarball
  2226 		docpath="doc/vym.pdf";
  2227 		if (!QFile (docpath).exists() )
  2228 		{
  2229 			// relative path for testing while still writing vym.tex
  2230 			docpath="doc/tex/vym.pdf";
  2231 			if (!QFile (docpath).exists() )
  2232 			{
  2233 				QMessageBox::critical(0, 
  2234 				tr("Critcal error"),
  2235 				tr("Couldn't find the documentation\n"
  2236 				"vym.pdf in various places."));
  2237 				return;
  2238 			}	
  2239 		}
  2240 	}
  2241 	
  2242 	Process *pdfProc = new Process();
  2243 	pdfProc->clearArguments();
  2244 	pdfProc->addArgument( settings.readEntry("/vym/mainwindow/readerPDF"));
  2245 	pdfProc->addArgument( docpath);
  2246 
  2247 	if ( !pdfProc->start() ) 
  2248 	{
  2249 		// error handling
  2250 		QMessageBox::critical(0, 
  2251 		tr("Critcal error"),
  2252 		tr("Couldn't find a viewer to read vym.pdf.\n"
  2253 		"Please use Settings->")+tr("Set application to open pdf files"));
  2254 		return;
  2255 	}
  2256 }
  2257 
  2258 
  2259 void Main::helpAbout()
  2260 {
  2261     static QMessageBox* about = new QMessageBox( "VYM",
  2262 			"<h3>VYM - View Your Mind </h3>"
  2263 			"<p> A tool to put the things you have got in your mind into a map.</p>"
  2264 			"<ul>"
  2265 				"<li> (c) by Uwe Drechsel (vym@InSilmaril.de)</li>"
  2266 				"<li> vym is released under the GPL (Gnu General Public License)"
  2267 				", with one exception (see the file \"LICENSE\"which "
  2268 				"comes with vym). This exception is needed to build vym with QT libraries for proprietary operating systems.</li>"
  2269 				"<li> Project homepage <a href=\"http:/www.InSilmaril.de/vym\">"
  2270     					"http:/www.InSilmaril.de/vym</a></li>"
  2271 			"<li> Credits " 
  2272 				"<ul>"
  2273 					"<li>Thomas Schraitle for the stylesheet  used for XHTML-export </li>"
  2274 					"<li>Clemens Kraus for stylesheets and script used for HTML-export "
  2275 					"<a href=\"http://www.clemens-kraus.de\">(www.clemens-kraus.de)</a></li>"
  2276 					"<li>Alexander Johannesen for providing stylesheets from his xsiteable project " 
  2277 					"<a href=\"http://www.shelter.nu/xsiteable/xsiteable.html\">(www.shelter.nu/xsiteable/xsiteable.html)</a>. </li>"
  2278 					"<li>Ken Wimer and Olaf Hering for Mac support</li>"
  2279 				"</ul>"
  2280 			"</li>"
  2281 			"<li> Version "  __VYM_VERSION__  "</li>"
  2282 				"<li> Build date "  __BUILD_DATE__"</li>"
  2283 			"</ul>", QMessageBox::Information, 1, 0, 0, this, 0, FALSE );
  2284     about->setButtonText( 1, "Dismiss" );
  2285     about->setMinimumSize(QSize(300,300));
  2286 	about->setIconPixmap (QPixmap(vym_logo_xpm));
  2287     about->show();
  2288 }
  2289 
  2290 void Main::helpAboutQT()
  2291 {
  2292 	QMessageBox::aboutQt( this, "Qt Application Example" );
  2293 }
  2294