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