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