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