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