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