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