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