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