mainwindow.cpp
author insilmaril
Tue, 11 Apr 2006 14:34:14 +0000
changeset 294 3492af261af2
parent 269 4c3e9fa0093b
child 301 4258723b534c
permissions -rw-r--r--
added basic history window
     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 	a->addTo (exportMenu);
  1235 
  1236     a = new QAction( tr( "Export as")+" Taskjuggler"+" "+tr("(still experimental)" ), QPixmap(), "Taskjuggler...", 0, this, "exportTJ" );
  1237     connect( a, SIGNAL( activated() ), this, SLOT( fileExportTaskjuggler() ) );
  1238 	a->addTo( exportMenu );
  1239 
  1240     a = new QAction( tr( "Export as")+" LaTeX"+" "+tr("(still experimental)" ), QPixmap(), "LaTeX...", 0, this, "exportLaTeX" );
  1241     connect( a, SIGNAL( activated() ), this, SLOT( fileExportLaTeX() ) );
  1242 	a->addTo( exportMenu );
  1243 
  1244 	a = new QAction( tr( "Export as")+" XML" , QPixmap(), "XML...",  0, this, "exportXML" );
  1245     connect( a, SIGNAL( activated() ), this, SLOT( fileExportXML() ) );
  1246     a->addTo( exportMenu );
  1247 	
  1248 	// Context menu for canvas
  1249 	canvasContextMenu =new QPopupMenu (this);
  1250 	actionEditMapInfo->addTo( canvasContextMenu );
  1251 	canvasContextMenu->insertSeparator();	
  1252 	actionGroupFormatLinkStyles->addTo( canvasContextMenu );
  1253 	canvasContextMenu->insertSeparator();	
  1254 	actionFormatLinkColorHint->addTo( canvasContextMenu );
  1255 	actionFormatLinkColor->addTo( canvasContextMenu );
  1256 	actionFormatBackColor->addTo( canvasContextMenu );
  1257 
  1258 	// Menu for last opened files
  1259 	// Read settings initially
  1260 	QString s;
  1261 	int j=settings.readNumEntry( "/vym/lastMaps/number",0);
  1262 	for (int i=1;i<=j;i++)
  1263 	{
  1264 		s=settings.readEntry(QString("/vym/lastMaps/map-%1").arg(i),"");
  1265 		if (!s.isEmpty() && j<=maxLastMaps) 
  1266 			lastMaps.append(s);
  1267 	}
  1268 	setupLastMapsMenu();
  1269 	connect( lastMapsMenu, SIGNAL( activated(int) ), this, SLOT( fileLoadLast(int ) ) );
  1270 }
  1271 
  1272 void Main::setupLastMapsMenu()
  1273 {
  1274 	// Remove double entries
  1275 	QStringList::Iterator it=lastMaps.begin();
  1276 	QStringList::Iterator jt;
  1277 	while (it!=lastMaps.end() )
  1278 	{
  1279 		jt=it;
  1280 		++jt;
  1281 		while (jt!=lastMaps.end() )
  1282 		{
  1283 			if (*it == *jt)		
  1284 				jt=lastMaps.remove(jt);
  1285 			else	
  1286 				jt++;
  1287 		}
  1288 		it++;
  1289 	}	
  1290 
  1291 	// Limit length of list to maxLastMaps
  1292 	while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
  1293 	
  1294 	// build Menu from lastMaps string list
  1295 	lastMapsMenu->clear();
  1296 	for (it = lastMaps.begin(); it != lastMaps.end(); ++it ) 
  1297 		lastMapsMenu->insertItem (*it );
  1298 		
  1299 }
  1300 
  1301 void Main::hideEvent (QHideEvent * )
  1302 {
  1303 	if (!textEditor->isMinimized() ) textEditor->hide();
  1304 }
  1305 
  1306 void Main::showEvent (QShowEvent * )
  1307 {
  1308 	if (textEditor->showWithMain()) textEditor->showNormal();
  1309 }
  1310 
  1311 bool Main::reallyWriteDirectory(const QString &dir)
  1312 {
  1313 	QStringList eList = QDir(dir).entryList();
  1314 	if (eList.first() ==".")  eList.pop_front();	// remove "."
  1315 	if (eList.first() =="..") eList.pop_front();	// remove "."
  1316 	if (!eList.isEmpty())
  1317 	{
  1318 		QMessageBox mb( __VYM,
  1319 			tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?").arg(dir),
  1320 		QMessageBox::Warning,
  1321 		QMessageBox::Yes ,
  1322 		QMessageBox::Cancel | QMessageBox::Default,
  1323 		QMessageBox::QMessageBox::NoButton );
  1324 
  1325 		mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
  1326 		mb.setButtonText( QMessageBox::No, tr("Cancel"));
  1327 		switch( mb.exec() ) 
  1328 		{
  1329 			case QMessageBox::Yes:
  1330 				// save 
  1331 				return true;
  1332 			case QMessageBox::Cancel:
  1333 				// do nothing
  1334 				return false;
  1335 		}
  1336 	}
  1337 	return true;
  1338 }
  1339 
  1340 QString Main::browseDirectory (const QString &caption)
  1341 {
  1342 	QFileDialog fd(this,caption);
  1343 	fd.setMode (QFileDialog::DirectoryOnly);
  1344 	fd.setCaption(__VYM " - "+caption);
  1345 	fd.show();
  1346 	
  1347 	if ( fd.exec() == QDialog::Accepted )
  1348 		return fd.selectedFile();
  1349 	else
  1350 		return "";
  1351 }
  1352 
  1353 MapEditor* Main::currentMapEditor() const
  1354 {
  1355     if ( tabWidget->currentPage() &&
  1356 	 tabWidget->currentPage()->inherits( "MapEditor" ) )
  1357 		return (MapEditor*)tabWidget->currentPage();
  1358     return NULL;	
  1359 }
  1360 
  1361 //TODO not used now, maybe use this for overview window later
  1362 void Main::newView() 
  1363 {
  1364     // Open a new view... have it delete when closed.
  1365     Main *m = new Main(0, 0, WDestructiveClose);
  1366     qApp->setMainWidget(m);
  1367     m->show();
  1368     qApp->setMainWidget(0);
  1369 }
  1370 
  1371 void Main::editorChanged(QWidget *)
  1372 {
  1373 	// Unselect all possibly selected objects
  1374 	// (Important to update note editor)
  1375 	int i;
  1376 	MapEditor *me;
  1377 	for (i=0;i<=tabWidget->count() -1;i++)
  1378 	{
  1379 		
  1380 		me=(MapEditor*)tabWidget->page(i);
  1381 		me->unselect();
  1382 	}	
  1383 	currentMapEditor()->reselect();
  1384 
  1385 	// Update actions to in menus and toolbars according to editor
  1386 	currentMapEditor()->updateActions();
  1387 }
  1388 
  1389 void Main::fileNew()
  1390 {
  1391 	QString fn="unnamed";
  1392 	MapEditor* medit = new MapEditor (tabWidget, true);
  1393 	tabWidget->addTab (medit,fn);
  1394 	tabWidget->showPage(medit);
  1395 	medit->viewport()->setFocus();
  1396 		// For the very first map we do not have flagrows yet...
  1397 		medit->select("mc:");
  1398 }
  1399 
  1400 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
  1401 {
  1402 	ErrorCode err=success;
  1403 	
  1404 	// fn is usually the archive, mapfile the file after uncompressing
  1405 	QString mapfile;
  1406 
  1407 	// Make fn absolute (needed for unzip)
  1408 	fn=QDir (fn).absPath();
  1409 
  1410 	MapEditor *me;
  1411 
  1412 	if (lmode==NewMap)
  1413 	{
  1414 		// Check, if map is already loaded
  1415 		int i=0;
  1416 		while (i<=tabWidget->count() -1)
  1417 		{
  1418 			me=(MapEditor*)tabWidget->page(i);
  1419 			if (me->getFilePath() == fn)
  1420 			{
  1421 				// Already there, ask for confirmation
  1422 				QMessageBox mb( __VYM,
  1423 					tr("The map %1\nis already opened."
  1424 					"Opening the same map in multiple editors may lead \n"
  1425 					"to confusion when finishing working with vym."
  1426 					"Do you want to").arg(fn),
  1427 					QMessageBox::Warning,
  1428 					QMessageBox::Yes | QMessageBox::Default,
  1429 					QMessageBox::Cancel | QMessageBox::Escape,
  1430 					QMessageBox::QMessageBox::NoButton);
  1431 				mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
  1432 				mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
  1433 				switch( mb.exec() ) 
  1434 				{
  1435 					case QMessageBox::Yes:
  1436 						// load anyway
  1437 						i=tabWidget->count();
  1438 						break;
  1439 					case QMessageBox::Cancel:
  1440 						// do nothing
  1441 						return aborted;
  1442 						break;
  1443 				}
  1444 			}
  1445 			i++;
  1446 		}
  1447 	}
  1448 
  1449 
  1450 	// Try to load map
  1451     if ( !fn.isEmpty() )
  1452 	{
  1453 		me = currentMapEditor();
  1454 		int tabIndex=tabWidget->currentPageIndex();
  1455 		// Check first, if mapeditor exists
  1456 		// If it is not default AND we want a new map, 
  1457 		// create a new mapeditor in a new tab
  1458 		if ( lmode==NewMap && (!me || !me->isDefault() ) )
  1459 		{
  1460 			me = new MapEditor (tabWidget,true);
  1461 			tabWidget->addTab (me,fn);
  1462 			tabIndex=tabWidget->indexOf (me);
  1463 			tabWidget->setCurrentPage (tabIndex);
  1464 		}
  1465 		
  1466 		// Check, if file exists (important for creating new files
  1467 		// from command line
  1468 		if (!QFile(fn).exists() )
  1469 		{
  1470 			QMessageBox mb( __VYM,
  1471 				tr("This map does not exist:\n  %1\nDo you want to create a new one?").arg(fn),
  1472 				QMessageBox::Question,
  1473 				QMessageBox::Yes ,
  1474 				QMessageBox::Cancel | QMessageBox::Default,
  1475 				QMessageBox::QMessageBox::NoButton );
  1476 
  1477 			mb.setButtonText( QMessageBox::Yes, tr("Create"));
  1478 			mb.setButtonText( QMessageBox::No, tr("Cancel"));
  1479 			switch( mb.exec() ) 
  1480 			{
  1481 				case QMessageBox::Yes:
  1482 					// Create new map
  1483 					currentMapEditor()->setFilePath(fn);
  1484 					tabWidget->setTabLabel (currentMapEditor(),
  1485 						currentMapEditor()->getFileName() );
  1486 					statusBar()->message( "Created " + fn , statusbarTime );
  1487 					return success;
  1488 						
  1489 				case QMessageBox::Cancel:
  1490 					// don't create new map
  1491 					statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
  1492 					fileCloseMap();
  1493 					return aborted;
  1494 			}
  1495 		}	
  1496 
  1497 
  1498 		//tabWidget->currentPage() won't be NULL here, because of above...
  1499 		tabWidget->showPage(me);
  1500 		me->viewport()->setFocus();
  1501 
  1502 		// Create temporary directory for packing
  1503 		char tmpdir1[]="/tmp/vym-XXXXXX";	
  1504 		QString tmpMapDir=mkdtemp(tmpdir1);
  1505 
  1506 		// Try to unzip file
  1507 		err=unzipDir (tmpMapDir,fn);
  1508 		if (err==nozip)
  1509 		{
  1510 			mapfile=fn;
  1511 			me->setZipped(false);
  1512 		} else
  1513 		{
  1514 			me->setZipped(true);
  1515 			
  1516 			// Look for mapname.xml
  1517 			mapfile= fn.left(fn.findRev(".",-1,true));
  1518 			mapfile=mapfile.section( '/', -1 );
  1519 			QFile file( tmpMapDir + "/" + mapfile + ".xml");
  1520 			if (!file.exists() )
  1521 			{
  1522 				// mapname.xml does not exist, well, 
  1523 				// maybe some renamed the mapname.vym file...
  1524 				// Try to find any .xml in the toplevel 
  1525 				// directory of the .vym file
  1526 				QStringList flist=QDir (tmpMapDir).entryList("*.xml");
  1527 				if (flist.count()==1) 
  1528 				{
  1529 					// Only one entry, take this one
  1530 					mapfile=tmpMapDir + "/"+flist.first();
  1531 				} else
  1532 				{
  1533 					for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it ) 
  1534 						*it=tmpMapDir + "/" + *it;
  1535 					// TODO Multiple entries, load all (but only the first one into this ME)
  1536 					//mainWindow->fileLoadFromTmp (flist);
  1537 					//returnCode=1;	// Silently forget this attempt to load
  1538 					qWarning ("MainWindow::load (fn)  multimap found...");
  1539 				}	
  1540 					
  1541 				if (flist.isEmpty() )
  1542 				{
  1543 					QMessageBox::critical( 0, tr( "Critical Load Error" ),
  1544 							   tr("Couldn't find a map (*.xml) in .vym archive.\n"));
  1545 					err=aborted;				   
  1546 				}	
  1547 			} //file doesn't exist	
  1548 			else
  1549 				mapfile=file.name();
  1550 		}
  1551 
  1552 		if (err!=aborted)
  1553 		{
  1554 			// Save existing filename in case  we import
  1555 			QString fn_org=me->getFilePath();
  1556 
  1557 			// Finally load map into mapEditor
  1558 			me->setFilePath (mapfile,fn);
  1559 			err=me->load(mapfile,lmode);
  1560 
  1561 			// Restore old (maybe empty) filepath, if this is an import
  1562 			if (lmode!=NewMap)
  1563 				me->setFilePath (fn_org);
  1564 		}	
  1565 
  1566 		// Finally check for errors and go home
  1567 		if (err==aborted) 
  1568 		{
  1569 			if (lmode==NewMap) fileCloseMap();
  1570 			statusBar()->message( "Could not load " + fn, statusbarTime );
  1571 		} else 
  1572 		{
  1573 			if (lmode==NewMap)
  1574 			{
  1575 				me->setFilePath (fn);
  1576 				tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
  1577 				if (fn.left(9)!="/tmp/vym-")
  1578 				{
  1579 					// Only append to lastMaps if not loaded from a tmpDir
  1580 					// e.g. imported bookmarks are in a tmpDir
  1581 					lastMaps.prepend(me->getFilePath() );
  1582 					setupLastMapsMenu();
  1583 				}
  1584 				actionFilePrint->setEnabled (true);
  1585 			}	
  1586 			statusBar()->message( "Loaded " + fn, statusbarTime );
  1587 		}	
  1588 
  1589 		// Delete tmpDir
  1590 		removeDir (QDir(tmpMapDir));
  1591 	}
  1592 	return err;
  1593 }
  1594 
  1595 
  1596 void Main::fileLoad(const LoadMode &lmode)
  1597 {
  1598 	QFileDialog *fd=new QFileDialog( this);
  1599 	if (!lastFileDir.isEmpty()) 
  1600 		fd->setDir (lastFileDir);
  1601 	fd->setMode (QFileDialog::ExistingFiles);
  1602 	fd->addFilter ("XML (*.xml)");
  1603 	fd->addFilter ("VYM map (*.vym *.vyp)");
  1604 	switch (lmode)
  1605 	{
  1606 		case NewMap:
  1607 			fd->setCaption(tr("Load vym map"));
  1608 			break;
  1609 		case ImportAdd:
  1610 			fd->setCaption(tr("Import: Add vym map to selection"));
  1611 			break;
  1612 		case ImportReplace:
  1613 			fd->setCaption(tr("Import: Replace selection with vym map"));
  1614 			break;
  1615 	}
  1616 	fd->show();
  1617 
  1618 	QString fn;
  1619 	if ( fd->exec() == QDialog::Accepted )
  1620 	{
  1621 		lastFileDir=fd->dirPath();
  1622 	    QStringList flist = fd->selectedFiles();
  1623 		QStringList::Iterator it = flist.begin();
  1624 		while( it != flist.end() ) 
  1625 		{
  1626 			fn = *it;
  1627 			fileLoad(*it, lmode);				   
  1628 			++it;
  1629 		}
  1630 	}
  1631 	delete (fd);
  1632 }
  1633 
  1634 void Main::fileLoad()
  1635 {
  1636 	fileLoad (NewMap);
  1637 }
  1638 
  1639 void Main::fileLoadLast(int i)
  1640 {
  1641 	fileLoad(*lastMaps.at(lastMapsMenu->indexOf (i) ),NewMap);			   
  1642 }
  1643 
  1644 void Main::fileSave(const SaveMode &savemode)
  1645 {
  1646 	// tmp dir for zipping 
  1647 	QString tmpMapDir;
  1648 	
  1649 	// Error codes
  1650 	ErrorCode err=success;
  1651 	
  1652 	QString safeFilePath;
  1653 
  1654 	bool saveZipped=currentMapEditor()->saveZipped();
  1655 
  1656 	MapEditor *	me=currentMapEditor();
  1657 	if (me)
  1658 	{
  1659 		QString fn=me->getFilePath();
  1660 		// filename=unnamed, filepath="" in constructor...
  1661 		if ( !fn.isEmpty() ) 
  1662 		{	
  1663 			// We have a filepath, go on saving			
  1664 			// First remove existing file, we 
  1665 			// don't want to add to old zip archives
  1666 			QFile f(fn);
  1667 			if (f.exists() ) 
  1668 				if (!f.remove())
  1669 					QMessageBox::warning( 0, tr( "Save Error" ),
  1670 						fn+   tr("\ncould not be removed before saving"));
  1671 
  1672 			// Look, if we should zip the data:
  1673 			if (!saveZipped)
  1674 			{
  1675 				QMessageBox mb( __VYM,
  1676 					tr("The map %1\ndid not use the compressed "
  1677 					"vym file format.\nWriting it uncompressed will also write images \n"
  1678 					"and flags and thus may overwrite files in the "
  1679 					"given directory\n\nDo you want to write the map").arg(fn),
  1680 					QMessageBox::Warning,
  1681 					QMessageBox::Yes | QMessageBox::Default,
  1682 					QMessageBox::No ,
  1683 					QMessageBox::Cancel | QMessageBox::Escape);
  1684 				mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
  1685 				mb.setButtonText( QMessageBox::No, tr("uncompressed") );
  1686 				mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
  1687 				switch( mb.exec() ) 
  1688 				{
  1689 					case QMessageBox::Yes:
  1690 						// save compressed (default file format)
  1691 						saveZipped=true;
  1692 						break;
  1693 					case QMessageBox::No:
  1694 						// save uncompressed
  1695 						saveZipped=false;
  1696 						break;
  1697 					case QMessageBox::Cancel:
  1698 						// do nothing
  1699 						return;
  1700 						break;
  1701 				}
  1702 			}
  1703 
  1704 			if (saveZipped)
  1705 			{
  1706 				char tmpdir1[]="/tmp/vym-XXXXXX";	
  1707 				tmpMapDir=mkdtemp(tmpdir1);
  1708 			
  1709 				safeFilePath=me->getFilePath();
  1710 				me->setFilePath (tmpMapDir+"/"+
  1711 					me->getMapName()+ ".xml",
  1712 					safeFilePath);
  1713 				me->save (savemode);
  1714 				me->setFilePath (safeFilePath);
  1715 				
  1716 				zipDir (tmpMapDir,fn);
  1717 			} // save zipped
  1718 			else
  1719 			{
  1720 				// Save unzipped. 
  1721 				safeFilePath=me->getFilePath();
  1722 				me->setFilePath (fn, safeFilePath);
  1723 				me->save (savemode);
  1724 				me->setFilePath (safeFilePath);
  1725 			} // save zipped 	
  1726 		} // filepath available
  1727 		else
  1728 		{
  1729 			// We have  no filepath yet,
  1730 			// call fileSaveAs() now, this will call fileSave() 
  1731 			// again.
  1732 			fileSaveAs(savemode);
  1733 		}
  1734     }
  1735 
  1736 	if (saveZipped && !tmpMapDir.isEmpty())
  1737 		// Delete tmpDir
  1738 		removeDir (QDir(tmpMapDir));
  1739 
  1740 	if (err==success)
  1741 	{
  1742 		statusBar()->message( 
  1743 			tr("Saved  %1").arg(me->getFilePath()), 
  1744 			statusbarTime );
  1745 		lastMaps.prepend(me->getFilePath() );
  1746 		setupLastMapsMenu();
  1747 	} else		
  1748 		statusBar()->message( 
  1749 			tr("Couldn't save ").arg(me->getFilePath()), 
  1750 			statusbarTime );
  1751 }
  1752 
  1753 void Main::fileSave()
  1754 {
  1755 	fileSave (CompleteMap);
  1756 }
  1757 
  1758 void Main::fileSaveAs(const SaveMode& savemode)
  1759 {
  1760 	QString fn;
  1761 
  1762 	if (currentMapEditor())
  1763 	{
  1764 		if (savemode==CompleteMap)
  1765 			fn = QFileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
  1766 		else		
  1767 			fn = QFileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
  1768 		if ( !fn.isEmpty() ) 
  1769 		{
  1770 			// Check for existing file
  1771 			if (QFile (fn).exists())
  1772 			{
  1773 				QMessageBox mb( __VYM,
  1774 					tr("The file %1\nexists already. Do you want to").arg(fn),
  1775 					QMessageBox::Warning,
  1776 					QMessageBox::Yes | QMessageBox::Default,
  1777 					QMessageBox::Cancel | QMessageBox::Escape,
  1778 					QMessageBox::QMessageBox::NoButton);
  1779 				mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
  1780 				mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
  1781 				switch( mb.exec() ) 
  1782 				{
  1783 					case QMessageBox::Yes:
  1784 						// save 
  1785 						break;
  1786 					case QMessageBox::Cancel:
  1787 						// do nothing
  1788 						return;
  1789 						break;
  1790 				}
  1791 			} else
  1792 			{
  1793 				// New file, add extension to filename, if missing
  1794 				// This is always .vym or .vyp, depending on savemode
  1795 				if (savemode==CompleteMap)
  1796 				{
  1797 					if (!fn.contains (".vym") && !fn.contains (".xml"))
  1798 						fn +=".vym";
  1799 				} else		
  1800 				{
  1801 					if (!fn.contains (".vyp") && !fn.contains (".xml"))
  1802 						fn +=".vyp";
  1803 				}
  1804 			}
  1805 	
  1806 
  1807 
  1808 
  1809 			// Save now
  1810 			currentMapEditor()->setFilePath(fn);
  1811 			fileSave(savemode);
  1812 
  1813 			// Set name of tab
  1814 			if (savemode==CompleteMap)
  1815 				tabWidget->setTabLabel (currentMapEditor(),
  1816 					currentMapEditor()->getFileName() );
  1817 			return;
  1818 		} 
  1819 	}
  1820 }
  1821 
  1822 void Main::fileSaveAs()
  1823 {
  1824 	fileSaveAs (CompleteMap);
  1825 }
  1826 
  1827 void Main::fileImportKDEBookmarks()
  1828 {
  1829 	ImportKDEBookmarks im;
  1830 	im.transform();
  1831 	if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
  1832 		currentMapEditor()->setFilePath ("");
  1833 }
  1834 
  1835 void Main::fileImportMM()
  1836 {
  1837 	ImportMM im;
  1838 
  1839 	QFileDialog *fd=new QFileDialog( this);
  1840 	if (!lastFileDir.isEmpty()) 
  1841 		fd->setDir (lastFileDir);
  1842 	fd->setMode (QFileDialog::ExistingFiles);
  1843 	fd->addFilter ("Mind Manager (*.mmap)");
  1844 	fd->setCaption(tr("Import")+" "+"Mind Manager");
  1845 	fd->show();
  1846 
  1847 	if ( fd->exec() == QDialog::Accepted )
  1848 	{
  1849 		lastFileDir=fd->dirPath();
  1850 	    QStringList flist = fd->selectedFiles();
  1851 		QStringList::Iterator it = flist.begin();
  1852 		while( it != flist.end() ) 
  1853 		{
  1854 			im.setFile (*it);
  1855 			if (im.transform() && 
  1856 				success==fileLoad (im.getTransformedFile(),NewMap) && 
  1857 				currentMapEditor() )
  1858 				currentMapEditor()->setFilePath ("");
  1859 
  1860 			++it;
  1861 		}
  1862 	}
  1863 	delete (fd);
  1864 
  1865 }
  1866 
  1867 void Main::fileImportDir()
  1868 {
  1869 	if (currentMapEditor())
  1870 		currentMapEditor()->importDir();	
  1871 }
  1872 
  1873 void Main::fileExportXML()
  1874 {
  1875 	if (currentMapEditor())
  1876 	{
  1877 		QString dir=browseDirectory(tr("Export XML to directory"));
  1878 		if (dir !="" && reallyWriteDirectory(dir) )
  1879 			currentMapEditor()->exportXML(dir);
  1880 	}	
  1881 }
  1882 
  1883 
  1884 void Main::fileExportXHTML()
  1885 {
  1886 	MapEditor *me=currentMapEditor();
  1887 	QString dir;
  1888 	if (me)
  1889 	{
  1890 		ExportXHTMLDialog dia(this);
  1891 		dia.setFilePath (me->getFilePath() );
  1892 		dia.setMapName (me->getMapName() );
  1893 		dia.readSettings();
  1894 		
  1895 		if (dia.exec()==QDialog::Accepted)
  1896 		{
  1897 			QString dir=dia.getDir();
  1898 			// Check, if warnings should be used before overwriting
  1899 			// the output directory
  1900 			bool ok;
  1901 			if (dia.warnings()) 
  1902 				ok=reallyWriteDirectory(dir);
  1903 			else
  1904 				ok=true;
  1905 
  1906 			if (ok)
  1907 			{
  1908 				me->exportXML (dia.getDir() );
  1909 				dia.doExport(me->getMapName() );
  1910 				if (dia.hasChanged())
  1911 					me->setChanged();
  1912 			}	
  1913 		}
  1914 	}	
  1915 }
  1916 
  1917 void Main::fileExportImage(int item)
  1918 {
  1919 	MapEditor *me=currentMapEditor();
  1920 	if (me)
  1921 	{
  1922 		QString fn = QFileDialog::getSaveFileName( QString::null, "Image  (*.bmp *.jpg *.pbm *.pgm *.png *.ppm *xbm *.xpm)",
  1923 							   this );
  1924 		if ( !fn.isEmpty() ) 
  1925 			me->exportImage(fn,item);
  1926 		else 
  1927 			statusBar()->message( tr("Couldn't save %1").arg(fn), statusbarTime );
  1928 		
  1929 	}
  1930 }
  1931 
  1932 void Main::fileExportASCII()
  1933 {
  1934 	MapEditor *me=currentMapEditor();
  1935 	if (me)
  1936 	{
  1937 		ExportASCII ex;
  1938 		ex.setMapCenter(me->getMapCenter());
  1939 		ex.addFilter ("TXT (*.txt)");
  1940 		ex.setCaption(__VYM " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
  1941 		if (ex.execDialog() ) 
  1942 		{
  1943 			me->setExportMode(true);
  1944 			ex.doExport();
  1945 			me->setExportMode(false);
  1946 		}
  1947 	}
  1948 }
  1949 
  1950 void Main::fileExportLaTeX()
  1951 {
  1952 	MapEditor *me=currentMapEditor();
  1953 	if (me)
  1954 	{
  1955 		ExportLaTeX ex;
  1956 		ex.setMapCenter(me->getMapCenter());
  1957 		ex.addFilter ("Tex (*.tex)");
  1958 		ex.setCaption(__VYM " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
  1959 		if (ex.execDialog() ) 
  1960 		{
  1961 			me->setExportMode(true);
  1962 			ex.doExport();
  1963 			me->setExportMode(false);
  1964 		}
  1965 	}
  1966 }
  1967 
  1968 void Main::fileExportKDEBookmarks()
  1969 {
  1970 	ExportKDEBookmarks ex;
  1971 	MapEditor *me=currentMapEditor();
  1972 	if (me)
  1973 	{
  1974 		ex.setMapCenter (me->getMapCenter() );
  1975 		ex.doExport();
  1976 	}	
  1977 }
  1978 
  1979 void Main::fileExportTaskjuggler()
  1980 {
  1981 	ExportTaskjuggler ex;
  1982 	MapEditor *me=currentMapEditor();
  1983 	if (me)
  1984 	{
  1985 		ex.setMapCenter (me->getMapCenter() );
  1986 		ex.setCaption ( __VYM " - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
  1987 		ex.addFilter ("Taskjuggler (*.tjp)");
  1988 		if (ex.execDialog() ) 
  1989 		{
  1990 			me->setExportMode(true);
  1991 			ex.doExport();
  1992 			me->setExportMode(false);
  1993 		}
  1994 	}	
  1995 }
  1996 
  1997 void Main::fileExportOOPresentation()
  1998 {
  1999 	ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to")+" Open Office");
  2000 	// FIXME add extra info in dialog
  2001 	//ImagePreview *p =new ImagePreview (fd);
  2002 	//fd->setContentsPreviewEnabled( TRUE );
  2003 	//fd->setContentsPreview( p, p );
  2004 	//fd->setPreviewMode( QFileDialog::Contents );
  2005 	fd->setCaption(__VYM " - " +tr("Export to")+" Open Office");
  2006 	//fd->setDir (lastImageDir);
  2007 	fd->show();
  2008 
  2009 	if ( fd->exec() == QDialog::Accepted )
  2010 	{
  2011 		QString fn=fd->selectedFile();
  2012 		//lastImageDir=fn.left(fn.findRev ("/"));
  2013 		if (currentMapEditor())
  2014 			currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());	
  2015 	}
  2016 }
  2017 
  2018 void Main::fileCloseMap()
  2019 {
  2020 	if (currentMapEditor())
  2021 	{
  2022 		if (currentMapEditor()->hasChanged())
  2023 		{
  2024 			QMessageBox mb( __VYM,
  2025 				tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
  2026 				QMessageBox::Warning,
  2027 				QMessageBox::Yes | QMessageBox::Default,
  2028 				QMessageBox::No,
  2029 				QMessageBox::Cancel | QMessageBox::Escape );
  2030 			mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
  2031 			mb.setButtonText( QMessageBox::No, tr("Discard changes"));
  2032 			switch( mb.exec() ) 
  2033 			{
  2034 				case QMessageBox::Yes:
  2035 					// save and close
  2036 					fileSave(CompleteMap);
  2037 					break;
  2038 				case QMessageBox::No:
  2039 				// close  without saving
  2040 					break;
  2041 				case QMessageBox::Cancel:
  2042 					// do nothing
  2043 				return;
  2044 			}
  2045 		} 
  2046 		currentMapEditor()->closeMap();
  2047 		tabWidget->removePage(currentMapEditor());
  2048 		if (tabWidget->count()==0)
  2049 			actionFilePrint->setEnabled (false);
  2050 	}	
  2051 }
  2052 
  2053 void Main::filePrint()
  2054 {
  2055 	if (currentMapEditor())
  2056 		currentMapEditor()->print();
  2057 }
  2058 
  2059 void Main::fileExitVYM()
  2060 {
  2061 	// Check if one or more editors have changed
  2062 	MapEditor *me;
  2063 	int i;
  2064 	for (i=0;i<=tabWidget->count() -1;i++)
  2065 	{
  2066 		
  2067 		me=(MapEditor*)tabWidget->page(i);
  2068 
  2069 		// If something changed, ask what to do
  2070 		if (me->isUnsaved())
  2071 		{
  2072 			tabWidget->setCurrentPage(i);
  2073 			QMessageBox mb( __VYM,
  2074 				tr("This map is not saved yet. Do you want to"),
  2075 				QMessageBox::Warning,
  2076 				QMessageBox::Yes | QMessageBox::Default,
  2077 				QMessageBox::No,
  2078 				QMessageBox::Cancel | QMessageBox::Escape );
  2079 			mb.setButtonText( QMessageBox::Yes, tr("Save map") );
  2080 			mb.setButtonText( QMessageBox::No, tr("Discard changes") );
  2081 			mb.show();
  2082 			// Call undocumented function: setActiveWindow is only
  2083 			// possible, if widget is visible. This depends on
  2084 			// windowmanager...
  2085 #if defined(Q_OS_LINUX)
  2086 			qt_wait_for_window_manager( this);
  2087 #endif			
  2088 			mb.setActiveWindow();
  2089 			switch( mb.exec() ) {
  2090 				case QMessageBox::Yes:
  2091 					// save (the changed editors) and exit
  2092 					fileSave(CompleteMap);
  2093 					break;
  2094 				case QMessageBox::No:
  2095 					// exit without saving
  2096 					break;
  2097 				case QMessageBox::Cancel:
  2098 					// don't save and don't exit
  2099 				return;
  2100 			}
  2101 		}
  2102 	} // loop over all MEs	
  2103     qApp->quit();
  2104 }
  2105 
  2106 void Main::editUndo()
  2107 {
  2108 	if (currentMapEditor())
  2109 		currentMapEditor()->undo();
  2110 }
  2111 
  2112 void Main::editRedo()	   
  2113 {
  2114 	if (currentMapEditor())
  2115 		currentMapEditor()->redo();
  2116 }
  2117 
  2118 void Main::editCopy()
  2119 {
  2120 	if (currentMapEditor())
  2121 		currentMapEditor()->copy();
  2122 }
  2123 
  2124 void Main::editPaste()
  2125 {
  2126 	if (currentMapEditor())
  2127 		currentMapEditor()->paste();
  2128 }
  2129 
  2130 void Main::editCut()
  2131 {
  2132 	if (currentMapEditor())
  2133 		currentMapEditor()->cut();
  2134 }
  2135 
  2136 void Main::editOpenFindWindow()
  2137 {
  2138 	findWindow->popup();
  2139 	findWindow->raise();
  2140 
  2141 	// Call undocumented function: setActiveWindow is only
  2142 	// possible, if widget is visible. This depends on
  2143 	// windowmanager...
  2144 #if defined(Q_OS_LINUX)
  2145 	qt_wait_for_window_manager( this);
  2146 #endif	
  2147 	findWindow->setActiveWindow();
  2148 }
  2149 
  2150 void Main::editFind(QString s)
  2151 {
  2152 	bool cs=false;
  2153 	BranchObj *bo=currentMapEditor()->findText(s, cs);
  2154 	if (bo)
  2155 	{	
  2156 		statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
  2157 	} else
  2158 	{
  2159 		QMessageBox::information( findWindow, tr( "VYM -Information:" ),
  2160 							   tr("No matches found for <b>%1</b>").arg(s));
  2161 	}	
  2162 }
  2163 
  2164 void Main::editFindChanged()
  2165 {	// Notify editor, to abort the current find process
  2166 	currentMapEditor()->findReset();
  2167 }
  2168 
  2169 void Main::editOpenURL()
  2170 {
  2171 	// Open new browser
  2172 	if (currentMapEditor())
  2173 	{	
  2174 	    QString url=currentMapEditor()->getURL();
  2175 		if (url=="") return;
  2176 		QString browser=settings.readEntry("/vym/mainwindow/readerURL" );
  2177 		procBrowser = new QProcess( this );
  2178 
  2179 		procBrowser->addArgument( browser);
  2180 		procBrowser->addArgument( url);
  2181 
  2182 		if ( !procBrowser->start() ) 
  2183 		{
  2184 			// try to set path to browser
  2185 			QMessageBox::warning(0, 
  2186 				tr("Warning"),
  2187 				tr("Couldn't find a viewer to open %1.\n").arg(url)+
  2188 				tr("Please use Settings->")+tr("Set application to open an URL"));
  2189 			settingsURL() ; 
  2190 		}	
  2191 	}	
  2192 }
  2193 void Main::editOpenURLTab()
  2194 {
  2195 	if (currentMapEditor())
  2196 	{	
  2197 	    QString url=currentMapEditor()->getURL();
  2198 		if (url=="") return;
  2199 		QString browser=settings.readEntry("/vym/mainwindow/readerURL" );
  2200 		if (browser.contains("konqueror") && procBrowser && procBrowser->isRunning())
  2201 		{
  2202 			// Try to open new tab in existing browser
  2203 			QProcess *p=new QProcess (this);
  2204 			p->addArgument ("dcop");
  2205 			p->addArgument (QString("konqueror-%1").arg(procBrowser->processIdentifier()));
  2206 			p->addArgument ("konqueror-mainwindow#1");
  2207 			p->addArgument ("newTab");
  2208 			p->addArgument (url);
  2209 			if ( !p->start() ) 
  2210 				// try to set browser
  2211 				QMessageBox::warning(0, 
  2212 					tr("Warning"),
  2213 					tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
  2214 		} else
  2215 			// Open new browser
  2216 			editOpenURL();
  2217 	}	
  2218 }
  2219 
  2220 void Main::editURL()
  2221 {
  2222 	if (currentMapEditor())
  2223 	    currentMapEditor()->editURL();
  2224 }
  2225 
  2226 void Main::editHeading2URL()
  2227 {
  2228 	if (currentMapEditor())
  2229 	    currentMapEditor()->editHeading2URL();
  2230 }
  2231 
  2232 void Main::editBugzilla2URL()
  2233 {
  2234 	if (currentMapEditor())
  2235 	    currentMapEditor()->editBugzilla2URL();
  2236 }
  2237 
  2238 void Main::editFATE2URL()
  2239 {
  2240 	if (currentMapEditor())
  2241 	    currentMapEditor()->editFATE2URL();
  2242 }
  2243 
  2244 void Main::editOpenVymLink()
  2245 {
  2246 	// Get current path to map
  2247 	QString currentVymLink;
  2248 	if (currentMapEditor())
  2249 	{
  2250 		currentVymLink=currentMapEditor()->getVymLink();	
  2251 		// compare path with already loaded maps
  2252 		int index=-1;
  2253 		int i;
  2254 		MapEditor *me;
  2255 		for (i=0;i<=tabWidget->count() -1;i++)
  2256 		{
  2257 			me=(MapEditor*)tabWidget->page(i);
  2258 			if (currentVymLink==me->getFilePath() )
  2259 			{
  2260 				index=i;
  2261 				break;
  2262 			}
  2263 		}	
  2264 		if (index<0)
  2265 		// Load map
  2266 		{
  2267 			if (!QFile(currentVymLink).exists() )
  2268 				QMessageBox::critical( 0, tr( "Critical Error" ),
  2269 				   tr("Couldn't open map %1").arg(currentVymLink));
  2270 			else
  2271 			{
  2272 				fileLoad (currentVymLink, NewMap);
  2273 				tabWidget->setCurrentPage (tabWidget->count()-1);	
  2274 			}
  2275 		} else
  2276 			// Go to tab containing the map
  2277 			tabWidget->setCurrentPage (index);	
  2278 	}
  2279 }
  2280 
  2281 void Main::editVymLink()
  2282 {
  2283 	if (currentMapEditor())
  2284 		currentMapEditor()->editVymLink();	
  2285 }
  2286 
  2287 void Main::editDeleteVymLink()
  2288 {
  2289 	if (currentMapEditor())
  2290 		currentMapEditor()->deleteVymLink();	
  2291 }
  2292 
  2293 void Main::editToggleHideExport()
  2294 {
  2295 	if (currentMapEditor())
  2296 		currentMapEditor()->toggleHideExport();	
  2297 }
  2298 
  2299 void Main::editMapInfo()
  2300 {
  2301 	if (currentMapEditor())
  2302 		currentMapEditor()->editMapInfo();	
  2303 }
  2304 
  2305 void Main::editMoveUp()
  2306 {
  2307 	if (currentMapEditor())
  2308 	    currentMapEditor()->moveBranchUp();
  2309 }
  2310 
  2311 void Main::editMoveDown()
  2312 {
  2313 	if (currentMapEditor())
  2314 		currentMapEditor()->moveBranchDown();
  2315 }
  2316 
  2317 void Main::editToggleScroll()
  2318 {
  2319 	if (currentMapEditor())
  2320 	{
  2321 		currentMapEditor()->toggleScroll();	
  2322 	}	
  2323 }
  2324 
  2325 void Main::editUnScrollAll()
  2326 {
  2327 	if (currentMapEditor())
  2328 	{
  2329 		currentMapEditor()->unScrollAll();	
  2330 	}	
  2331 }
  2332 
  2333 void Main::editHeading()
  2334 {
  2335 	if (currentMapEditor())
  2336 		currentMapEditor()->editHeading();
  2337 }
  2338 
  2339 void Main::editNewBranch()
  2340 {
  2341 	if (currentMapEditor())
  2342 		currentMapEditor()->addNewBranch(0);
  2343 }
  2344 
  2345 void Main::editNewBranchHere()
  2346 {
  2347 	if (currentMapEditor())
  2348 		currentMapEditor()->addNewBranchHere();
  2349 }
  2350 
  2351 void Main::editNewBranchAbove()
  2352 {
  2353 	if (currentMapEditor())
  2354 		currentMapEditor()->addNewBranch(-1);
  2355 }
  2356 
  2357 void Main::editNewBranchBelow()
  2358 {
  2359 	if (currentMapEditor())
  2360 		currentMapEditor()->addNewBranch(1);
  2361 }
  2362 
  2363 void Main::editImportAdd()
  2364 {
  2365 	fileLoad (ImportAdd);
  2366 }
  2367 
  2368 void Main::editImportReplace()
  2369 {
  2370 	fileLoad (ImportReplace);
  2371 }
  2372 
  2373 void Main::editSaveBranch()
  2374 {
  2375 	fileSaveAs (PartOfMap);
  2376 }
  2377 
  2378 void Main::editRemoveBranchKeepChilds()
  2379 {
  2380 	if (currentMapEditor())
  2381 		currentMapEditor()->removeBranchKeepChilds();
  2382 }
  2383 
  2384 void Main::editRemoveChilds()
  2385 {
  2386 	if (currentMapEditor())
  2387 		currentMapEditor()->removeChilds();
  2388 }
  2389 
  2390 void Main::editDeleteSelection()
  2391 {
  2392 	if (currentMapEditor() && actionSettingsUseDelKey->isOn())
  2393 		currentMapEditor()->deleteSelection();
  2394 }
  2395 
  2396 void Main::editUpperBranch()
  2397 {
  2398 	if (currentMapEditor())
  2399 		currentMapEditor()->selectUpperBranch();
  2400 }
  2401 
  2402 void Main::editLowerBranch()
  2403 {
  2404 	if (currentMapEditor())
  2405 		currentMapEditor()->selectLowerBranch();
  2406 }
  2407 
  2408 void Main::editLeftBranch()
  2409 {
  2410 	if (currentMapEditor())
  2411 		currentMapEditor()->selectLeftBranch();
  2412 }
  2413 
  2414 void Main::editRightBranch()
  2415 {
  2416 	if (currentMapEditor())
  2417 		currentMapEditor()->selectRightBranch();
  2418 }
  2419 
  2420 void Main::editFirstBranch()
  2421 {
  2422 	if (currentMapEditor())
  2423 		currentMapEditor()->selectFirstBranch();
  2424 }
  2425 
  2426 void Main::editLastBranch()
  2427 {
  2428 	if (currentMapEditor())
  2429 		currentMapEditor()->selectLastBranch();
  2430 }
  2431 
  2432 void Main::editLoadImage()
  2433 {
  2434 	if (currentMapEditor())
  2435 		currentMapEditor()->loadFloatImage();
  2436 }
  2437 
  2438 void Main::editSaveImage(int item)
  2439 {
  2440 	if (currentMapEditor())
  2441 		currentMapEditor()->saveFloatImage(item);
  2442 }
  2443 
  2444 void Main::editFollowXLink(int item)
  2445 {
  2446 	if (currentMapEditor())
  2447 		currentMapEditor()->followXLink(branchLinksContextMenu->indexOf(item));
  2448 }
  2449 
  2450 void Main::editEditXLink(int item)
  2451 {
  2452 	if (currentMapEditor())
  2453 		currentMapEditor()->editXLink(branchLinksContextMenuDup->indexOf(item));
  2454 }
  2455 
  2456 void Main::formatSelectColor()
  2457 {
  2458 	if (currentMapEditor())
  2459 	{
  2460 		QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
  2461 		if ( !col.isValid() ) return;
  2462 		currentMapEditor()->setColor( col );
  2463 		colorChanged( col );
  2464 	}	
  2465 }
  2466 
  2467 void Main::formatPickColor()
  2468 {
  2469 	if (currentMapEditor())
  2470 		colorChanged( currentMapEditor()->pickColor() );
  2471 }
  2472 
  2473 void Main::colorChanged(QColor c)
  2474 {
  2475     QPixmap pix( 16, 16 );
  2476     pix.fill( c );
  2477     actionFormatColor->setIconSet( pix );
  2478 }
  2479 
  2480 void Main::formatColorItem()
  2481 {
  2482 	if (currentMapEditor())
  2483 		currentMapEditor()->colorItem();
  2484 }
  2485 
  2486 void Main::formatColorBranch()
  2487 {
  2488 	if (currentMapEditor())
  2489 		currentMapEditor()->colorBranch();
  2490 }
  2491 
  2492 void Main::formatLinkStyleLine()
  2493 {
  2494 	if (currentMapEditor())
  2495 		currentMapEditor()->setLinkStyle(StyleLine);
  2496 }
  2497 
  2498 void Main::formatLinkStyleParabel()
  2499 {
  2500 	if (currentMapEditor())
  2501 		currentMapEditor()->setLinkStyle(StyleParabel);
  2502 }
  2503 
  2504 void Main::formatLinkStylePolyLine()
  2505 {
  2506 	if (currentMapEditor())
  2507 		currentMapEditor()->setLinkStyle(StylePolyLine);
  2508 }
  2509 
  2510 void Main::formatLinkStylePolyParabel()
  2511 {
  2512 	if (currentMapEditor())
  2513 		currentMapEditor()->setLinkStyle(StylePolyParabel);
  2514 }
  2515 
  2516 void Main::formatSelectBackColor()
  2517 {
  2518 	if (currentMapEditor())
  2519 		currentMapEditor()->selectBackgroundColor();
  2520 }
  2521 
  2522 void Main::formatSelectLinkColor()
  2523 {
  2524 	if (currentMapEditor())
  2525 		currentMapEditor()->selectLinkColor();
  2526 }
  2527 
  2528 void Main::formatToggleLinkColorHint()
  2529 {
  2530 	currentMapEditor()->toggleLinkColorHint();
  2531 }
  2532 
  2533 void Main::formatFrameNone()
  2534 {
  2535 	if (currentMapEditor())
  2536 		currentMapEditor()->setFrame(NoFrame);
  2537 }
  2538 
  2539 void Main::formatFrameRectangle()
  2540 {
  2541 	if (currentMapEditor())
  2542 		currentMapEditor()->setFrame(Rectangle);
  2543 }
  2544 
  2545 void Main::formatIncludeImagesVer()
  2546 {
  2547 	if (currentMapEditor())
  2548 		currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
  2549 }
  2550 
  2551 void Main::formatIncludeImagesHor()
  2552 {
  2553 	if (currentMapEditor())
  2554 		currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
  2555 }
  2556 
  2557 void Main::formatHideLinkUnselected()
  2558 {
  2559 	if (currentMapEditor())
  2560 		currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
  2561 }
  2562 
  2563 void Main::viewZoomReset()
  2564 {
  2565 	if (currentMapEditor())
  2566 	{
  2567 		QWMatrix m;
  2568 		m.reset();
  2569 		currentMapEditor()->setWorldMatrix( m );
  2570 		currentMapEditor()->setViewCenter();
  2571 		currentMapEditor()->adjustCanvasSize();
  2572 	}	
  2573 }
  2574 
  2575 void Main::viewZoomIn()
  2576 {
  2577 	if (currentMapEditor())
  2578 	{
  2579 		QWMatrix m = currentMapEditor()->worldMatrix();
  2580 		m.scale( 1.25, 1.25 );
  2581 		currentMapEditor()->setWorldMatrix( m );
  2582 		currentMapEditor()->setViewCenter();
  2583 		currentMapEditor()->adjustCanvasSize();
  2584 	}	
  2585 }
  2586 
  2587 void Main::viewZoomOut()
  2588 {
  2589 	if (currentMapEditor())
  2590 	{
  2591 		QWMatrix m = currentMapEditor()->worldMatrix();
  2592 		m.scale( 0.8, 0.8 );
  2593 		currentMapEditor()->setWorldMatrix( m );
  2594 		currentMapEditor()->setViewCenter();
  2595 		currentMapEditor()->adjustCanvasSize();
  2596 	}	
  2597 }
  2598 
  2599 void Main::modModeColor()
  2600 {
  2601 }
  2602 
  2603 void Main::modModeLink()
  2604 {
  2605 }
  2606 
  2607 bool Main::settingsPDF()
  2608 {
  2609 	// Default browser is set in constructor
  2610 	bool ok;
  2611 	QString text = QInputDialog::getText(
  2612 		"VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
  2613 		settings.readEntry("/vym/mainwindow/readerPDF"), &ok, this );
  2614 	if (ok)
  2615 		settings.writeEntry ("/vym/mainwindow/readerPDF",text);
  2616 	return ok;
  2617 }
  2618 
  2619 
  2620 bool Main::settingsURL()
  2621 {
  2622 	// Default browser is set in constructor
  2623 	bool ok;
  2624 	QString text = QInputDialog::getText(
  2625 		"VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
  2626 		settings.readEntry("/vym/mainwindow/readerURL")
  2627 		, &ok, this );
  2628 	if (ok)
  2629 		settings.writeEntry ("/vym/mainwindow/readerURL",text);
  2630 	return ok;
  2631 }
  2632 
  2633 void Main::windowToggleNoteEditor()
  2634 {
  2635 	if (textEditor->showWithMain() )
  2636 		windowHideNoteEditor();
  2637 	else	
  2638 		windowShowNoteEditor();
  2639 }
  2640 
  2641 void Main::windowToggleHistory()
  2642 {
  2643 	if (currentMapEditor())
  2644 		currentMapEditor()->toggleHistoryWindow();
  2645 }
  2646 
  2647 void Main::updateNoteFlag()
  2648 {
  2649 	if (currentMapEditor())
  2650 		currentMapEditor()->updateNoteFlag();
  2651 }
  2652 
  2653 void Main::windowShowNoteEditor()
  2654 {
  2655 	textEditor->setShowWithMain(true);
  2656 	textEditor->show();
  2657 	actionViewToggleNoteEditor->setOn (true);
  2658 }
  2659 
  2660 void Main::windowHideNoteEditor()
  2661 {
  2662 	textEditor->setShowWithMain(false);
  2663 	textEditor->hide();
  2664 	actionViewToggleNoteEditor->setOn (false);
  2665 }
  2666 
  2667 void Main::windowNextEditor()
  2668 {
  2669 	if (tabWidget->currentPageIndex() < tabWidget->count())
  2670 		tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
  2671 }
  2672 
  2673 void Main::windowPreviousEditor()
  2674 {
  2675 	if (tabWidget->currentPageIndex() >0)
  2676 		tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
  2677 }
  2678 
  2679 void Main::standardFlagChanged()
  2680 {
  2681 	currentMapEditor()->toggleStandardFlag(sender()->name());
  2682 }
  2683 
  2684 void Main::testFunction()
  2685 {
  2686 	currentMapEditor()->testFunction();
  2687 }
  2688 
  2689 void Main::helpDoc()
  2690 {
  2691 	QString docpath;
  2692 	#if defined(Q_OS_MACX)
  2693 		docpath="./vym.app/Contents/vym.pdf";
  2694 	#else
  2695 		// default path in SUSE LINUX
  2696 		docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
  2697 	#endif
  2698 
  2699 	if (!QFile (docpath).exists() )
  2700 	{
  2701 		// relative path for easy testing in tarball
  2702 		docpath="doc/vym.pdf";
  2703 		if (!QFile (docpath).exists() )
  2704 		{
  2705 			// relative path for testing while still writing vym.tex
  2706 			docpath="doc/tex/vym.pdf";
  2707 			if (!QFile (docpath).exists() )
  2708 			{
  2709 				// Try yet another one for Knoppix
  2710 				docpath="/usr/share/doc/packages/vym/vym.pdf";
  2711 				if (!QFile (docpath).exists() )
  2712 				{
  2713 					QMessageBox::critical(0, 
  2714 					tr("Critcal error"),
  2715 					tr("Couldn't find the documentation\n"
  2716 					"vym.pdf in various places."));
  2717 					return;
  2718 				}	
  2719 			}	
  2720 		}
  2721 	}
  2722 	
  2723 	Process *pdfProc = new Process();
  2724 	pdfProc->clearArguments();
  2725 	pdfProc->addArgument( settings.readEntry("/vym/mainwindow/readerPDF"));
  2726 	pdfProc->addArgument( docpath);
  2727 
  2728 	if ( !pdfProc->start() ) 
  2729 	{
  2730 		// error handling
  2731 		QMessageBox::warning(0, 
  2732 			tr("Warning"),
  2733 			tr("Couldn't find a viewer to open %1.\n").arg("vym.pdf")+
  2734 			tr("Please use Settings->")+tr("Set application to open PDF files"));
  2735 		settingsPDF();	
  2736 		return;
  2737 	}
  2738 }
  2739 
  2740 
  2741 void Main::helpAbout()
  2742 {
  2743 	AboutDialog ad;
  2744 	ad.setName ("aboutwindow");
  2745 	ad.setMinimumSize(500,500);
  2746 	ad.resize (QSize (500,500));
  2747 	ad.exec();
  2748 }
  2749 
  2750 void Main::helpAboutQT()
  2751 {
  2752 	QMessageBox::aboutQt( this, "Qt Application Example" );
  2753 }
  2754