mainwindow.cpp
author insilmaril
Tue, 23 Jan 2007 11:50:53 +0000
changeset 422 07a2f3f31101
parent 421 5522d1da7e37
child 424 d886c77ac0fe
permissions -rw-r--r--
1.8.65 Various fixes
     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 some 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.setCaption(vymName+ " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
  2253 		if (ex.execDialog() ) 
  2254 		{
  2255 			me->setExportMode(true);
  2256 			ex.doExport();
  2257 			me->setExportMode(false);
  2258 		}
  2259 	}
  2260 }
  2261 
  2262 void Main::fileExportLaTeX()
  2263 {
  2264 	MapEditor *me=currentMapEditor();
  2265 	if (me)
  2266 	{
  2267 		ExportLaTeX ex;
  2268 		ex.setMapCenter(me->getMapCenter());
  2269 		ex.addFilter ("Tex (*.tex)");
  2270 		ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
  2271 		if (ex.execDialog() ) 
  2272 		{
  2273 			me->setExportMode(true);
  2274 			ex.doExport();
  2275 			me->setExportMode(false);
  2276 		}
  2277 	}
  2278 }
  2279 
  2280 void Main::fileExportKDEBookmarks()
  2281 {
  2282 	ExportKDEBookmarks ex;
  2283 	MapEditor *me=currentMapEditor();
  2284 	if (me)
  2285 	{
  2286 		ex.setMapCenter (me->getMapCenter() );
  2287 		ex.doExport();
  2288 	}	
  2289 }
  2290 
  2291 void Main::fileExportTaskjuggler()
  2292 {
  2293 	ExportTaskjuggler ex;
  2294 	MapEditor *me=currentMapEditor();
  2295 	if (me)
  2296 	{
  2297 		ex.setMapCenter (me->getMapCenter() );
  2298 		ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
  2299 		ex.addFilter ("Taskjuggler (*.tjp)");
  2300 		if (ex.execDialog() ) 
  2301 		{
  2302 			me->setExportMode(true);
  2303 			ex.doExport();
  2304 			me->setExportMode(false);
  2305 		}
  2306 	}	
  2307 }
  2308 
  2309 void Main::fileExportOOPresentation()
  2310 {
  2311 	ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
  2312 	// TODO add preview in dialog
  2313 	//ImagePreview *p =new ImagePreview (fd);
  2314 	//fd->setContentsPreviewEnabled( TRUE );
  2315 	//fd->setContentsPreview( p, p );
  2316 	//fd->setPreviewMode( QFileDialog::Contents );
  2317 	fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
  2318 	fd->setDir (QDir().current());
  2319 	if (fd->foundConfig())
  2320 	{
  2321 		fd->show();
  2322 
  2323 		if ( fd->exec() == QDialog::Accepted )
  2324 		{
  2325 			QString fn=fd->selectedFile();
  2326 			if (!fn.contains (".odp"))
  2327 				fn +=".odp";
  2328 
  2329 			//lastImageDir=fn.left(fn.findRev ("/"));
  2330 			if (currentMapEditor())
  2331 				currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());	
  2332 		}
  2333 	} else
  2334 	{
  2335 		QMessageBox::warning(0, 
  2336 		tr("Warning"),
  2337 		tr("Couldn't find configuration for export to Open Office\n"));
  2338 	}
  2339 }
  2340 
  2341 void Main::fileCloseMap()
  2342 {
  2343 	if (currentMapEditor())
  2344 	{
  2345 		if (currentMapEditor()->hasChanged())
  2346 		{
  2347 			QMessageBox mb( vymName,
  2348 				tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
  2349 				QMessageBox::Warning,
  2350 				QMessageBox::Yes | QMessageBox::Default,
  2351 				QMessageBox::No,
  2352 				QMessageBox::Cancel | QMessageBox::Escape );
  2353 			mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
  2354 			mb.setButtonText( QMessageBox::No, tr("Discard changes"));
  2355 			switch( mb.exec() ) 
  2356 			{
  2357 				case QMessageBox::Yes:
  2358 					// save and close
  2359 					fileSave(CompleteMap);
  2360 					break;
  2361 				case QMessageBox::No:
  2362 				// close  without saving
  2363 					break;
  2364 				case QMessageBox::Cancel:
  2365 					// do nothing
  2366 				return;
  2367 			}
  2368 		} 
  2369 		currentMapEditor()->closeMap();
  2370 		tabWidget->removePage(currentMapEditor());
  2371 		if (tabWidget->count()==0)
  2372 			actionFilePrint->setEnabled (false);
  2373 	}	
  2374 }
  2375 
  2376 void Main::filePrint()
  2377 {
  2378 	if (currentMapEditor())
  2379 		currentMapEditor()->print();
  2380 }
  2381 
  2382 void Main::fileExitVYM()
  2383 {
  2384 	// Check if one or more editors have changed
  2385 	MapEditor *me;
  2386 	int i;
  2387 	for (i=0;i<=tabWidget->count() -1;i++)
  2388 	{
  2389 		
  2390 		me=(MapEditor*)tabWidget->page(i);
  2391 
  2392 		// If something changed, ask what to do
  2393 		if (me->isUnsaved())
  2394 		{
  2395 			tabWidget->setCurrentPage(i);
  2396 			QMessageBox mb( vymName,
  2397 				tr("This map is not saved yet. Do you want to"),
  2398 				QMessageBox::Warning,
  2399 				QMessageBox::Yes | QMessageBox::Default,
  2400 				QMessageBox::No,
  2401 				QMessageBox::Cancel | QMessageBox::Escape );
  2402 			mb.setButtonText( QMessageBox::Yes, tr("Save map") );
  2403 			mb.setButtonText( QMessageBox::No, tr("Discard changes") );
  2404 			mb.setModal (true);
  2405 			mb.show();
  2406 			mb.setActiveWindow();
  2407 			switch( mb.exec() ) {
  2408 				case QMessageBox::Yes:
  2409 					// save (the changed editors) and exit
  2410 					fileSave(CompleteMap);
  2411 					break;
  2412 				case QMessageBox::No:
  2413 					// exit without saving
  2414 					break;
  2415 				case QMessageBox::Cancel:
  2416 					// don't save and don't exit
  2417 				return;
  2418 			}
  2419 		}
  2420 	} // loop over all MEs	
  2421     qApp->quit();
  2422 }
  2423 
  2424 void Main::editUndo()
  2425 {
  2426 	if (currentMapEditor())
  2427 		currentMapEditor()->undo();
  2428 }
  2429 
  2430 void Main::editRedo()	   
  2431 {
  2432 	if (currentMapEditor())
  2433 		currentMapEditor()->redo();
  2434 }
  2435 
  2436 void Main::gotoHistoryStep (int i)	   
  2437 {
  2438 	if (currentMapEditor())
  2439 		currentMapEditor()->gotoHistoryStep (i);
  2440 }
  2441 
  2442 void Main::editCopy()
  2443 {
  2444 	if (currentMapEditor())
  2445 		currentMapEditor()->copy();
  2446 }
  2447 
  2448 void Main::editPaste()
  2449 {
  2450 	if (currentMapEditor())
  2451 		currentMapEditor()->paste();
  2452 }
  2453 
  2454 void Main::editCut()
  2455 {
  2456 	if (currentMapEditor())
  2457 		currentMapEditor()->cut();
  2458 }
  2459 
  2460 void Main::editOpenFindWindow()
  2461 {
  2462 	findWindow->popup();
  2463 	findWindow->raise();
  2464 	findWindow->setActiveWindow();
  2465 }
  2466 
  2467 void Main::editFind(QString s)
  2468 {
  2469 	bool cs=false;
  2470 	BranchObj *bo=currentMapEditor()->findText(s, cs);
  2471 	if (bo)
  2472 	{	
  2473 		statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
  2474 	} else
  2475 	{
  2476 		QMessageBox::information( findWindow, tr( "VYM -Information:" ),
  2477 							   tr("No matches found for \"%1\"").arg(s));
  2478 	}	
  2479 }
  2480 
  2481 void Main::editFindChanged()
  2482 {	// Notify editor, to abort the current find process
  2483 	currentMapEditor()->findReset();
  2484 }
  2485 
  2486 void Main::openTabs(QStringList urls)
  2487 {
  2488 	if (!urls.isEmpty())
  2489 	{	
  2490 		bool success=true;
  2491 		QStringList args;
  2492 		QString browser=settings.value("/mainwindow/readerURL" ).toString();
  2493 		QProcess *p;
  2494 		if (!procBrowser ||  procBrowser->state()!=QProcess::Running)
  2495 		{
  2496 			QString u=urls.takeFirst();
  2497 			procBrowser = new QProcess( this );
  2498 			args<<u;
  2499 			procBrowser->start(browser,args);
  2500 			if ( !procBrowser->waitForStarted())
  2501 			{
  2502 				// try to set path to browser
  2503 				QMessageBox::warning(0, 
  2504 					tr("Warning"),
  2505 					tr("Couldn't find a viewer to open %1.\n").arg(u)+
  2506 					tr("Please use Settings->")+tr("Set application to open an URL"));
  2507 				return;
  2508 			}
  2509 			sleep (3);
  2510 		}
  2511 		if (browser.contains("konqueror"))
  2512 		{
  2513 			for (int i=0; i<urls.size(); i++)
  2514 			{
  2515 				// Open new browser
  2516 				// Try to open new tab in existing konqueror started previously by vym
  2517 				p=new QProcess (this);
  2518 				args.clear();
  2519 				args<< QString("konqueror-%1").arg(procBrowser->pid())<< 
  2520 					"konqueror-mainwindow#1"<< 
  2521 					"newTab" << 
  2522 					urls.at(i);
  2523 				p->start ("dcop",args);
  2524 				if ( !p->waitForStarted() ) success=false;
  2525 			}
  2526 			if (!success)
  2527 				QMessageBox::warning(0, 
  2528 					tr("Warning"),
  2529 					tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
  2530 			return;		
  2531 		} else if (browser.contains ("firefox") || browser.contains ("mozilla") )
  2532 		{
  2533 			for (int i=0; i<urls.size(); i++)
  2534 			{
  2535 				// Try to open new tab in firefox
  2536 				p=new QProcess (this);
  2537 				args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
  2538 				p->start (browser,args);
  2539 				if ( !p->waitForStarted() ) success=false;
  2540 			}			
  2541 			if (!success)
  2542 				QMessageBox::warning(0, 
  2543 					tr("Warning"),
  2544 					tr("Couldn't start %1 to open a new tab").arg(browser));
  2545 			return;		
  2546 		}			
  2547 		QMessageBox::warning(0, 
  2548 			tr("Warning"),
  2549 			tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
  2550 	}	
  2551 }
  2552 
  2553 void Main::editOpenURL()
  2554 {
  2555 	// Open new browser
  2556 	if (currentMapEditor())
  2557 	{	
  2558 	    QString url=currentMapEditor()->getURL();
  2559 		QStringList args;
  2560 		if (url=="") return;
  2561 		QString browser=settings.value("/mainwindow/readerURL" ).toString();
  2562 		procBrowser = new QProcess( this );
  2563 		args<<url;
  2564 		procBrowser->start(browser,args);
  2565 		if ( !procBrowser->waitForStarted())
  2566 		{
  2567 			// try to set path to browser
  2568 			QMessageBox::warning(0, 
  2569 				tr("Warning"),
  2570 				tr("Couldn't find a viewer to open %1.\n").arg(url)+
  2571 				tr("Please use Settings->")+tr("Set application to open an URL"));
  2572 			settingsURL() ; 
  2573 		}	
  2574 	}	
  2575 }
  2576 void Main::editOpenURLTab()
  2577 {
  2578 	if (currentMapEditor())
  2579 	{	
  2580 	    QStringList urls;
  2581 		urls.append(currentMapEditor()->getURL());
  2582 		openTabs (urls);
  2583 	}	
  2584 }
  2585 void Main::editOpenMultipleURLTabs()
  2586 {
  2587 	if (currentMapEditor())
  2588 	{	
  2589 	    QStringList urls;
  2590 		urls=currentMapEditor()->getURLs();
  2591 		openTabs (urls);
  2592 	}	
  2593 }
  2594 
  2595 
  2596 void Main::editURL()
  2597 {
  2598 	if (currentMapEditor())
  2599 	    currentMapEditor()->editURL();
  2600 }
  2601 
  2602 void Main::editHeading2URL()
  2603 {
  2604 	if (currentMapEditor())
  2605 	    currentMapEditor()->editHeading2URL();
  2606 }
  2607 
  2608 void Main::editBugzilla2URL()
  2609 {
  2610 	if (currentMapEditor())
  2611 	    currentMapEditor()->editBugzilla2URL();
  2612 }
  2613 
  2614 void Main::editFATE2URL()
  2615 {
  2616 	if (currentMapEditor())
  2617 	    currentMapEditor()->editFATE2URL();
  2618 }
  2619 
  2620 void Main::editHeadingFinished()
  2621 {
  2622 	// only called from editHeading(), so there is a currentME
  2623 	MapEditor *me=currentMapEditor();
  2624 	if (me)
  2625 	{
  2626 		QPoint p;	//Not used here, only to find out pos of branch
  2627 		bool ok;
  2628 		QString s=me->getHeading(ok,p);
  2629 
  2630 #if defined(Q_OS_MACX)
  2631 #else
  2632 		if (ok && s!=lineedit->text())
  2633 			me->setHeading(lineedit->text());
  2634 			
  2635 		lineedit->releaseKeyboard();
  2636 		lineedit->hide();
  2637 		setFocus();
  2638 #endif	
  2639 		if (!prevSelection.isEmpty()) me->select(prevSelection);
  2640 		prevSelection="";
  2641 	}
  2642 }
  2643 
  2644 void Main::editHeading()
  2645 {
  2646 	if (currentMapEditor())
  2647 	{
  2648 		MapEditor *me=currentMapEditor();
  2649 		QString oldSel=me->getSelectString();
  2650 
  2651 		if (lineedit->isVisible())
  2652 			editHeadingFinished();
  2653 		else
  2654 		{
  2655 			bool ok;
  2656 			QPoint p;
  2657 			QString s=currentMapEditor()->getHeading(ok,p);
  2658 
  2659 			if (ok)
  2660 			{
  2661 #if defined(Q_OS_MACX)
  2662 				p=currentMapEditor()->mapTo (this,p);
  2663 				QDialog *d =new QDialog(NULL);
  2664 				QLineEdit *le=new QLineEdit (d);
  2665 				d->setWindowFlags (Qt::FramelessWindowHint);
  2666 				d->setGeometry(p.x(),p.y(),230,25);
  2667 				le->resize (d->width()-10,d->height());
  2668 				le->setText (s);
  2669 				le->selectAll();
  2670 				connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
  2671 				d->activateWindow();
  2672 				d->exec();
  2673 				currentMapEditor()->setHeading (le->text());
  2674 				delete (le);
  2675 				delete (d);
  2676 				editHeadingFinished();
  2677 #else
  2678 				p=currentMapEditor()->mapTo (this,p);
  2679 				lineedit->setGeometry(p.x(),p.y(),230,25);
  2680 				lineedit->setText(s);
  2681 				lineedit->setCursorPosition(1);
  2682 				lineedit->selectAll();
  2683 				lineedit->show();
  2684 				lineedit->grabKeyboard();
  2685 				lineedit->setFocus();
  2686 #endif
  2687 			}
  2688 		}
  2689 	} // currentMapEditor()	
  2690 }
  2691 
  2692 void Main::openVymLinks(const QStringList &vl)
  2693 {
  2694 	for (int j=0; j<vl.size(); j++)
  2695 	{
  2696 		// compare path with already loaded maps
  2697 		int index=-1;
  2698 		int i;
  2699 		MapEditor *me;
  2700 		for (i=0;i<=tabWidget->count() -1;i++)
  2701 		{
  2702 			me=(MapEditor*)tabWidget->page(i);
  2703 			if (vl.at(j)==me->getFilePath() )
  2704 			{
  2705 				index=i;
  2706 				break;
  2707 			}
  2708 		}	
  2709 		if (index<0)
  2710 		// Load map
  2711 		{
  2712 			if (!QFile(vl.at(j)).exists() )
  2713 				QMessageBox::critical( 0, tr( "Critical Error" ),
  2714 				   tr("Couldn't open map %1").arg(vl.at(j)));
  2715 			else
  2716 			{
  2717 				fileLoad (vl.at(j), NewMap);
  2718 				tabWidget->setCurrentPage (tabWidget->count()-1);	
  2719 			}
  2720 		} else
  2721 			// Go to tab containing the map
  2722 			tabWidget->setCurrentPage (index);	
  2723 	}
  2724 }
  2725 
  2726 void Main::editOpenVymLink()
  2727 {
  2728 	if (currentMapEditor())
  2729 	{
  2730 		QStringList vl;
  2731 		vl.append(currentMapEditor()->getVymLink());	
  2732 		openVymLinks (vl);
  2733 	}
  2734 }
  2735 
  2736 void Main::editOpenMultipleVymLinks()
  2737 {
  2738 	QString currentVymLink;
  2739 	if (currentMapEditor())
  2740 	{
  2741 		QStringList vl=currentMapEditor()->getVymLinks();
  2742 		openVymLinks (vl);
  2743 	}
  2744 }
  2745 
  2746 void Main::editVymLink()
  2747 {
  2748 	if (currentMapEditor())
  2749 		currentMapEditor()->editVymLink();	
  2750 }
  2751 
  2752 void Main::editDeleteVymLink()
  2753 {
  2754 	if (currentMapEditor())
  2755 		currentMapEditor()->deleteVymLink();	
  2756 }
  2757 
  2758 void Main::editToggleHideExport()
  2759 {
  2760 	if (currentMapEditor())
  2761 		currentMapEditor()->toggleHideExport();	
  2762 }
  2763 
  2764 void Main::editMapInfo()
  2765 {
  2766 	if (currentMapEditor())
  2767 		currentMapEditor()->editMapInfo();	
  2768 }
  2769 
  2770 void Main::editMoveUp()
  2771 {
  2772 	if (currentMapEditor())
  2773 	    currentMapEditor()->moveBranchUp();
  2774 }
  2775 
  2776 void Main::editMoveDown()
  2777 {
  2778 	if (currentMapEditor())
  2779 		currentMapEditor()->moveBranchDown();
  2780 }
  2781 
  2782 void Main::editToggleScroll()
  2783 {
  2784 	if (currentMapEditor())
  2785 	{
  2786 		currentMapEditor()->toggleScroll();	
  2787 	}	
  2788 }
  2789 
  2790 void Main::editUnScrollAll()
  2791 {
  2792 	if (currentMapEditor())
  2793 		currentMapEditor()->unScrollAll();	
  2794 }
  2795 
  2796 void Main::editNewBranch()
  2797 {
  2798 	MapEditor *me=currentMapEditor();
  2799 	if (!lineedit->isVisible() && me)
  2800 	{
  2801 		BranchObj *bo=(BranchObj*)me->getSelection();
  2802 		BranchObj *newbo=me->addNewBranch(0);
  2803 
  2804 		if (newbo) 
  2805 			me->select (newbo->getSelectString());
  2806 		else
  2807 			return;
  2808 
  2809 		if (actionSettingsAutoEdit->isOn())
  2810 		{
  2811 			if (!actionSettingsAutoSelectHeading->isOn())
  2812 				prevSelection=bo->getSelectString();
  2813 			editHeading();
  2814 		}
  2815 	}	
  2816 }
  2817 
  2818 void Main::editNewBranchBefore()
  2819 {
  2820 	MapEditor *me=currentMapEditor();
  2821 	if (!lineedit->isVisible() && me)
  2822 	{
  2823 		BranchObj *bo=(BranchObj*)me->getSelection();
  2824 		BranchObj *newbo=me->addNewBranchBefore();
  2825 
  2826 		if (newbo) 
  2827 			me->select (newbo->getSelectString());
  2828 		else
  2829 			return;
  2830 
  2831 		if (actionSettingsAutoEdit->isOn())
  2832 		{
  2833 			if (!actionSettingsAutoSelectHeading->isOn())
  2834 				prevSelection=bo->getSelectString();
  2835 			editHeading();
  2836 		}
  2837 	}	
  2838 }
  2839 
  2840 void Main::editNewBranchAbove()
  2841 {
  2842 	MapEditor *me=currentMapEditor();
  2843 	if (!lineedit->isVisible() && me)
  2844 	{
  2845 		BranchObj *bo=(BranchObj*)me->getSelection();
  2846 		BranchObj *newbo=me->addNewBranch (-1);
  2847 
  2848 		if (newbo) 
  2849 			me->select (newbo->getSelectString());
  2850 		else
  2851 			return;
  2852 
  2853 		if (actionSettingsAutoEdit->isOn())
  2854 		{
  2855 			if (!actionSettingsAutoSelectHeading->isOn())
  2856 				prevSelection=bo->getSelectString();
  2857 			editHeading();
  2858 		}
  2859 	}	
  2860 }
  2861 
  2862 void Main::editNewBranchBelow()
  2863 {
  2864 	MapEditor *me=currentMapEditor();
  2865 	if (!lineedit->isVisible() && me)
  2866 	{
  2867 		BranchObj *bo=(BranchObj*)me->getSelection();
  2868 		BranchObj *newbo=me->addNewBranch (1);
  2869 
  2870 		if (newbo) 
  2871 			me->select (newbo->getSelectString());
  2872 		else
  2873 			return;
  2874 
  2875 		if (actionSettingsAutoEdit->isOn())
  2876 		{
  2877 			if (!actionSettingsAutoSelectHeading->isOn())
  2878 				prevSelection=bo->getSelectString();
  2879 			editHeading();
  2880 		}
  2881 	}	
  2882 }
  2883 
  2884 void Main::editImportAdd()
  2885 {
  2886 	fileLoad (ImportAdd);
  2887 }
  2888 
  2889 void Main::editImportReplace()
  2890 {
  2891 	fileLoad (ImportReplace);
  2892 }
  2893 
  2894 void Main::editSaveBranch()
  2895 {
  2896 	fileSaveAs (PartOfMap);
  2897 }
  2898 
  2899 void Main::editDeleteKeepChilds()
  2900 {
  2901 	if (currentMapEditor())
  2902 		currentMapEditor()->deleteKeepChilds();
  2903 }
  2904 
  2905 void Main::editDeleteChilds()
  2906 {
  2907 	if (currentMapEditor())
  2908 		currentMapEditor()->deleteChilds();
  2909 }
  2910 
  2911 void Main::editDeleteSelection()
  2912 {
  2913 	if (currentMapEditor() && actionSettingsUseDelKey->isOn())
  2914 		currentMapEditor()->deleteSelection();
  2915 }
  2916 
  2917 void Main::editUpperBranch()
  2918 {
  2919 	if (currentMapEditor())
  2920 		currentMapEditor()->selectUpperBranch();
  2921 }
  2922 
  2923 void Main::editLowerBranch()
  2924 {
  2925 	if (currentMapEditor())
  2926 		currentMapEditor()->selectLowerBranch();
  2927 }
  2928 
  2929 void Main::editLeftBranch()
  2930 {
  2931 	if (currentMapEditor())
  2932 		currentMapEditor()->selectLeftBranch();
  2933 }
  2934 
  2935 void Main::editRightBranch()
  2936 {
  2937 	if (currentMapEditor())
  2938 		currentMapEditor()->selectRightBranch();
  2939 }
  2940 
  2941 void Main::editFirstBranch()
  2942 {
  2943 	if (currentMapEditor())
  2944 		currentMapEditor()->selectFirstBranch();
  2945 }
  2946 
  2947 void Main::editLastBranch()
  2948 {
  2949 	if (currentMapEditor())
  2950 		currentMapEditor()->selectLastBranch();
  2951 }
  2952 
  2953 void Main::editLoadImage()
  2954 {
  2955 	if (currentMapEditor())
  2956 		currentMapEditor()->loadFloatImage();
  2957 }
  2958 
  2959 void Main::editSaveImage()
  2960 {
  2961 	if (currentMapEditor())
  2962 		currentMapEditor()->saveFloatImage();
  2963 }
  2964 
  2965 void Main::editFollowXLink(QAction *a)
  2966 {
  2967 
  2968 	if (currentMapEditor())
  2969 		currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
  2970 }
  2971 
  2972 void Main::editEditXLink(QAction *a)
  2973 {
  2974 	if (currentMapEditor())
  2975 		currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
  2976 }
  2977 
  2978 void Main::formatSelectColor()
  2979 {
  2980 	if (currentMapEditor())
  2981 	{
  2982 		QColor col = QColorDialog::getColor((currentColor ), this );
  2983 		if ( !col.isValid() ) return;
  2984 		colorChanged( col );
  2985 	}	
  2986 }
  2987 
  2988 void Main::formatPickColor()
  2989 {
  2990 	if (currentMapEditor())
  2991 		colorChanged( currentMapEditor()->getCurrentHeadingColor() );
  2992 }
  2993 
  2994 void Main::colorChanged(QColor c)
  2995 {
  2996     QPixmap pix( 16, 16 );
  2997     pix.fill( c );
  2998     actionFormatColor->setIconSet( pix );
  2999 	currentColor=c;
  3000 }
  3001 
  3002 void Main::formatColorBranch()
  3003 {
  3004 	if (currentMapEditor())
  3005 		currentMapEditor()->colorBranch(currentColor);
  3006 }
  3007 
  3008 void Main::formatColorSubtree()
  3009 {
  3010 	if (currentMapEditor())
  3011 		currentMapEditor()->colorSubtree (currentColor);
  3012 }
  3013 
  3014 void Main::formatLinkStyleLine()
  3015 {
  3016 	if (currentMapEditor())
  3017 		currentMapEditor()->setMapLinkStyle("StyleLine");
  3018 }
  3019 
  3020 void Main::formatLinkStyleParabel()
  3021 {
  3022 	if (currentMapEditor())
  3023 		currentMapEditor()->setMapLinkStyle("StyleParabel");
  3024 }
  3025 
  3026 void Main::formatLinkStylePolyLine()
  3027 {
  3028 	if (currentMapEditor())
  3029 		currentMapEditor()->setMapLinkStyle("StylePolyLine");
  3030 }
  3031 
  3032 void Main::formatLinkStylePolyParabel()
  3033 {
  3034 	if (currentMapEditor())
  3035 		currentMapEditor()->setMapLinkStyle("StylePolyParabel");
  3036 }
  3037 
  3038 void Main::formatSelectBackColor()
  3039 {
  3040 	if (currentMapEditor())
  3041 		currentMapEditor()->selectMapBackgroundColor();
  3042 }
  3043 
  3044 void Main::formatSelectBackImage()
  3045 {
  3046 	if (currentMapEditor())
  3047 		currentMapEditor()->selectMapBackgroundImage();
  3048 }
  3049 
  3050 void Main::formatSelectLinkColor()
  3051 {
  3052 	if (currentMapEditor())
  3053 		currentMapEditor()->selectMapLinkColor();
  3054 }
  3055 
  3056 void Main::formatToggleLinkColorHint()
  3057 {
  3058 	currentMapEditor()->toggleMapLinkColorHint();
  3059 }
  3060 
  3061 
  3062 void Main::formatIncludeImagesVer()
  3063 {
  3064 	if (currentMapEditor())
  3065 		currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
  3066 }
  3067 
  3068 void Main::formatIncludeImagesHor()
  3069 {
  3070 	if (currentMapEditor())
  3071 		currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
  3072 }
  3073 
  3074 void Main::formatHideLinkUnselected()	//FIXME get rid of this with imagepropertydialog
  3075 {
  3076 	if (currentMapEditor())
  3077 		currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
  3078 }
  3079 
  3080 void Main::viewZoomReset()
  3081 {
  3082 	if (currentMapEditor())
  3083 	{
  3084 		QMatrix m;
  3085 		m.reset();
  3086 		currentMapEditor()->setMatrix( m );
  3087 	}	
  3088 }
  3089 
  3090 void Main::viewZoomIn()
  3091 {
  3092 	if (currentMapEditor())
  3093 	{
  3094 		QMatrix m = currentMapEditor()->matrix();
  3095 		m.scale( 1.25, 1.25 );
  3096 		currentMapEditor()->setMatrix( m );
  3097 	}	
  3098 }
  3099 
  3100 void Main::viewZoomOut()
  3101 {
  3102 	if (currentMapEditor())
  3103 	{
  3104 		QMatrix m = currentMapEditor()->matrix();
  3105 		m.scale( 0.8, 0.8 );
  3106 		currentMapEditor()->setMatrix( m );
  3107 	}	
  3108 }
  3109 
  3110 bool Main::settingsPDF()
  3111 {
  3112 	// Default browser is set in constructor
  3113 	bool ok;
  3114 	QString text = QInputDialog::getText(
  3115 		"VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
  3116 		settings.value("/mainwindow/readerPDF").toString(), &ok, this );
  3117 	if (ok)
  3118 		settings.setValue ("/mainwindow/readerPDF",text);
  3119 	return ok;
  3120 }
  3121 
  3122 
  3123 bool Main::settingsURL()
  3124 {
  3125 	// Default browser is set in constructor
  3126 	bool ok;
  3127 	QString text = QInputDialog::getText(
  3128 		"VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
  3129 		settings.value("/mainwindow/readerURL").toString()
  3130 		, &ok, this );
  3131 	if (ok)
  3132 		settings.setValue ("/mainwindow/readerURL",text);
  3133 	return ok;
  3134 }
  3135 
  3136 void Main::settingsToggleDelKey()
  3137 {
  3138 	if (actionSettingsUseDelKey->isOn())
  3139 	{
  3140 		actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
  3141 	} else
  3142 	{
  3143 		actionEditDelete->setAccel (QKeySequence (""));
  3144 	}
  3145 }
  3146 
  3147 void Main::windowToggleNoteEditor()
  3148 {
  3149 	if (textEditor->showWithMain() )
  3150 		windowHideNoteEditor();
  3151 	else	
  3152 		windowShowNoteEditor();
  3153 }
  3154 
  3155 void Main::windowToggleHistory()
  3156 {
  3157 	if (historyWindow->isVisible())
  3158 		historyWindow->hide();
  3159 	else	
  3160 		historyWindow->show();
  3161 
  3162 }
  3163 
  3164 void Main::windowToggleAntiAlias()
  3165 {
  3166 	bool b=actionViewToggleAntiAlias->isOn();
  3167 	MapEditor *me;
  3168 	for (int i=0;i<tabWidget->count();i++)
  3169 	{
  3170 		
  3171 		me=(MapEditor*)tabWidget->page(i);
  3172 		me->setAntiAlias(b);
  3173 	}	
  3174 
  3175 }
  3176 
  3177 void Main::windowToggleSmoothPixmap()
  3178 {
  3179 	bool b=actionViewToggleSmoothPixmapTransform->isOn();
  3180 	MapEditor *me;
  3181 	for (int i=0;i<tabWidget->count();i++)
  3182 	{
  3183 		
  3184 		me=(MapEditor*)tabWidget->page(i);
  3185 		me->setSmoothPixmap(b);
  3186 	}	
  3187 }
  3188 
  3189 void Main::updateHistory(SimpleSettings &undoSet)
  3190 {
  3191 	historyWindow->update (undoSet);
  3192 }
  3193 
  3194 void Main::updateNoteFlag()
  3195 {
  3196 	if (currentMapEditor())
  3197 		currentMapEditor()->updateNoteFlag();
  3198 }
  3199 
  3200 void Main::updateActions()
  3201 {
  3202 	MapEditor *me=currentMapEditor();
  3203 	if (!me) return;
  3204 
  3205 	historyWindow->setCaption (tr("History for %1").arg(currentMapEditor()->getFileName()));
  3206 
  3207 	// updateActions is also called when NoteEditor is closed
  3208 	actionViewToggleNoteEditor->setOn (textEditor->showWithMain());
  3209 
  3210 	if (me->getMapLinkColorHint()==HeadingColor) 
  3211 		actionFormatLinkColorHint->setOn(true);
  3212 	else	
  3213 		actionFormatLinkColorHint->setOn(false);
  3214 
  3215 	switch (me->getMapLinkStyle())
  3216 	{
  3217 		case StyleLine: 
  3218 			actionFormatLinkStyleLine->setOn(true);
  3219 			break;
  3220 		case StyleParabel:
  3221 			actionFormatLinkStyleParabel->setOn(true);
  3222 			break;
  3223 		case StylePolyLine:	
  3224 			actionFormatLinkStylePolyLine->setOn(true);
  3225 			break;
  3226 		case StylePolyParabel:	
  3227 			actionFormatLinkStylePolyParabel->setOn(true);
  3228 			break;
  3229 		default:
  3230 			break;
  3231 	}	
  3232 
  3233 	QPixmap pix( 16, 16 );
  3234     pix.fill( me->getMapBackgroundColor() );
  3235     actionFormatBackColor->setIconSet( pix );
  3236     pix.fill( me->getMapDefLinkColor() );
  3237     actionFormatLinkColor->setIconSet( pix );
  3238 
  3239 	actionFileSave->setEnabled( me->isUnsaved() );
  3240 	if (me->isUndoAvailable())
  3241 		actionEditUndo->setEnabled( true);
  3242 	else	
  3243 		actionEditUndo->setEnabled( false);
  3244 
  3245 	if (me->isRedoAvailable())
  3246 		actionEditRedo->setEnabled( true);
  3247 	else	
  3248 		actionEditRedo->setEnabled( false);
  3249 
  3250 	LinkableMapObj *selection=me->getSelection();
  3251 	if (selection)
  3252 	{
  3253 		if ( (typeid(*selection) == typeid(BranchObj)) || 
  3254 			(typeid(*selection) == typeid(MapCenterObj))  )
  3255 		{
  3256 			BranchObj *bo=(BranchObj*)selection;
  3257 			// Take care of links
  3258 			if (bo->countXLinks()==0)
  3259 			{
  3260 				branchXLinksContextMenuEdit->clear();
  3261 				branchXLinksContextMenuFollow->clear();
  3262 			} else
  3263 			{
  3264 				BranchObj *bot;
  3265 				QString s;
  3266 				branchXLinksContextMenuEdit->clear();
  3267 				branchXLinksContextMenuFollow->clear();
  3268 				for (int i=0; i<=bo->countXLinks();i++)
  3269 				{
  3270 					bot=bo->XLinkTargetAt(i);
  3271 					if (bot)
  3272 					{
  3273 						s=bot->getHeading();
  3274 						if (s.length()>25)
  3275 							s=s.left(25)+"...";
  3276 						branchXLinksContextMenuFollow->addAction (s);
  3277 						branchXLinksContextMenuEdit->addAction (s);
  3278 					}	
  3279 				}
  3280 			}
  3281 
  3282 			standardFlagsDefault->setEnabled (true);
  3283 
  3284 			actionEditToggleScroll->setEnabled (true);
  3285 			if ( bo->isScrolled() )
  3286 				actionEditToggleScroll->setOn(true);
  3287 			else	
  3288 				actionEditToggleScroll->setOn(false);
  3289 
  3290 			if ( bo->getURL().isEmpty() )
  3291 			{
  3292 				actionEditOpenURL->setEnabled (false);
  3293 				actionEditOpenURLTab->setEnabled (false);
  3294 			}	
  3295 			else	
  3296 			{
  3297 				actionEditOpenURL->setEnabled (true);
  3298 				actionEditOpenURLTab->setEnabled (true);
  3299 			}
  3300 			if ( bo->getVymLink().isEmpty() )
  3301 			{
  3302 				actionEditOpenVymLink->setEnabled (false);
  3303 				actionEditDeleteVymLink->setEnabled (false);
  3304 			} else	
  3305 			{
  3306 				actionEditOpenVymLink->setEnabled (true);
  3307 				actionEditDeleteVymLink->setEnabled (true);
  3308 			}	
  3309 
  3310 			if (bo->canMoveBranchUp()) 
  3311 				actionEditMoveUp->setEnabled (true);
  3312 			else	
  3313 				actionEditMoveUp->setEnabled (false);
  3314 			if (bo->canMoveBranchDown()) 
  3315 				actionEditMoveDown->setEnabled (true);
  3316 			else	
  3317 				actionEditMoveDown->setEnabled (false);
  3318 
  3319 
  3320 			actionEditToggleHideExport->setEnabled (true);	
  3321 			actionEditToggleHideExport->setOn (bo->hideInExport() );	
  3322 
  3323 			actionEditCopy->setEnabled (true);	
  3324 			actionEditCut->setEnabled (true);	
  3325 			if (!clipboardEmpty)
  3326 				actionEditPaste->setEnabled (true);	
  3327 			else	
  3328 				actionEditPaste->setEnabled (false);	
  3329 			for (int i=0; i<actionListBranches.size(); ++i)	
  3330 				actionListBranches.at(i)->setEnabled(true);
  3331 			actionEditDelete->setEnabled (true);
  3332 			actionFormatIncludeImagesVer->setOn
  3333 				( ((BranchObj*)selection)->getIncludeImagesVer());
  3334 			actionFormatIncludeImagesHor->setOn
  3335 				( ((BranchObj*)selection)->getIncludeImagesHor());
  3336 			actionFormatHideLinkUnselected->setOn
  3337 				(selection->getHideLinkUnselected());
  3338 		}
  3339 		if ( (typeid(*selection) == typeid(FloatImageObj)) )
  3340 		{
  3341 			FloatObj *fo=(FloatImageObj*)selection;
  3342 
  3343 			actionEditOpenURL->setEnabled (false);
  3344 			actionEditOpenVymLink->setEnabled (false);
  3345 			actionEditDeleteVymLink->setEnabled (false);	
  3346 			actionEditToggleHideExport->setEnabled (true);	
  3347 			actionEditToggleHideExport->setOn (fo->hideInExport() );	
  3348 
  3349 
  3350 			actionEditCopy->setEnabled (true);
  3351 			actionEditCut->setEnabled (true);	
  3352 			actionEditPaste->setEnabled (false);
  3353 			for (int i=0; i<actionListBranches.size(); ++i)	
  3354 				actionListBranches.at(i)->setEnabled(false);
  3355 			actionEditDelete->setEnabled (true);
  3356 			actionFormatHideLinkUnselected->setOn
  3357 				( selection->getHideLinkUnselected());
  3358 			actionEditMoveUp->setEnabled (false);
  3359 			actionEditMoveDown->setEnabled (false);
  3360 		}
  3361 
  3362 	} else
  3363 	{
  3364 		actionEditCopy->setEnabled (false);	
  3365 		actionEditCut->setEnabled (false);	
  3366 		actionEditPaste->setEnabled (false);	
  3367 		for (int i=0; i<actionListBranches.size(); ++i)	
  3368 			actionListBranches.at(i)->setEnabled(false);
  3369 
  3370 		actionEditToggleScroll->setEnabled (false);
  3371 		actionEditOpenURL->setEnabled (false);
  3372 		actionEditOpenVymLink->setEnabled (false);
  3373 		actionEditDeleteVymLink->setEnabled (false);	
  3374 		actionEditHeading2URL->setEnabled (false);	
  3375 		actionEditDelete->setEnabled (false);
  3376 		actionEditMoveUp->setEnabled (false);
  3377 		actionEditMoveDown->setEnabled (false);
  3378 		actionEditToggleHideExport->setEnabled (false);	
  3379 	}	
  3380 }
  3381 
  3382 ModMode Main::getModMode()
  3383 {
  3384 	if (actionModModeColor->isOn()) return ModModeColor;
  3385 	if (actionModModeCopy->isOn()) return ModModeCopy;
  3386 	if (actionModModeXLink->isOn()) return ModModeXLink;
  3387 	return ModModeNone;
  3388 }
  3389 
  3390 bool Main::autoEdit()
  3391 {
  3392 	return actionSettingsAutoEdit->isOn();
  3393 }
  3394 
  3395 bool Main::autoSelectHeading()
  3396 {
  3397 	return actionSettingsAutoSelectHeading->isOn();
  3398 }
  3399 
  3400 bool Main::useFlagGroups()
  3401 {
  3402 	return actionSettingsUseFlagGroups->isOn();
  3403 }
  3404 
  3405 void Main::windowShowNoteEditor()
  3406 {
  3407 	textEditor->setShowWithMain(true);
  3408 	textEditor->show();
  3409 	actionViewToggleNoteEditor->setOn (true);
  3410 }
  3411 
  3412 void Main::windowHideNoteEditor()
  3413 {
  3414 	textEditor->setShowWithMain(false);
  3415 	textEditor->hide();
  3416 	actionViewToggleNoteEditor->setOn (false);
  3417 }
  3418 
  3419 void Main::showPropertyDialog()
  3420 {
  3421 	if(currentMapEditor())
  3422 	{
  3423 		LinkableMapObj *sel=currentMapEditor()->getSelection();
  3424 		if (sel && typeid(*sel) == typeid(BranchObj))
  3425 		{
  3426 			branchPropertyWindow->show();
  3427 			branchPropertyWindow->setMapEditor(currentMapEditor());
  3428 			branchPropertyWindow->setBranch((BranchObj*)sel);
  3429 			return;
  3430 		}
  3431 		
  3432 	}	
  3433 	branchPropertyWindow->setBranch(NULL);
  3434 }
  3435 
  3436 void Main::windowNextEditor()
  3437 {
  3438 	if (tabWidget->currentPageIndex() < tabWidget->count())
  3439 		tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
  3440 }
  3441 
  3442 void Main::windowPreviousEditor()
  3443 {
  3444 	if (tabWidget->currentPageIndex() >0)
  3445 		tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
  3446 }
  3447 
  3448 void Main::standardFlagChanged()
  3449 {
  3450 	if (currentMapEditor())
  3451 		currentMapEditor()->toggleStandardFlag(sender()->name());
  3452 }
  3453 
  3454 void Main::testFunction()
  3455 {
  3456 	if (!currentMapEditor()) return;
  3457 	currentMapEditor()->testFunction();
  3458 }
  3459 
  3460 void Main::testCommand()
  3461 {
  3462 	if (!currentMapEditor()) return;
  3463 	bool ok;
  3464 	QString com = QInputDialog::getText(
  3465 			vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
  3466 	if (ok) currentMapEditor()->parseAtom(com);
  3467 }
  3468 
  3469 void Main::helpDoc()
  3470 {
  3471 	QString locale = QLocale::system().name();
  3472 	QString docname;
  3473 	if (locale.left(2)=="es")
  3474 		docname="vym_es.pdf";
  3475 	else	
  3476 		docname="vym.pdf";
  3477 
  3478 	QStringList searchList;
  3479 	QDir docdir;
  3480 	#if defined(Q_OS_MACX)
  3481 		searchList << "./vym.app/Contents";
  3482 	#else
  3483 		// default path in SUSE LINUX
  3484 		searchList <<"/usr/share/doc/packages/vym/doc";
  3485 	#endif
  3486 
  3487 	searchList << "doc";	// relative path for easy testing in tarball
  3488 	searchList << "doc/tex";	// Easy testing working on vym.tex
  3489 	searchList << "/usr/share/doc/vym";	// Debian
  3490 	searchList << "/usr/share/doc/packages";// Knoppix
  3491 
  3492 	bool found=false;
  3493 	QFile docfile;
  3494 	for (int i=0; i<searchList.count(); ++i)
  3495 	{
  3496 		docfile.setFileName(QDir::convertSeparators(searchList.at(i)+"/"+docname));
  3497 		if (docfile.exists() )
  3498 		{
  3499 			found=true;
  3500 			break;
  3501 		}	
  3502 
  3503 	}
  3504 	if (!found)
  3505 	{
  3506 		QMessageBox::critical(0, 
  3507 			tr("Critcal error"),
  3508 			tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
  3509 		return;
  3510 	}	
  3511 
  3512 	QStringList args;
  3513 	Process *pdfProc = new Process();
  3514 	args <<docfile.fileName();
  3515 
  3516 	pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
  3517 	if ( !pdfProc->waitForStarted() ) 
  3518 	{
  3519 		// error handling
  3520 		QMessageBox::warning(0, 
  3521 			tr("Warning"),
  3522 			tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
  3523 			tr("Please use Settings->")+tr("Set application to open PDF files"));
  3524 		settingsPDF();	
  3525 		return;
  3526 	}
  3527 }
  3528 
  3529 
  3530 void Main::helpAbout()
  3531 {
  3532 	AboutDialog ad;
  3533 	ad.setName ("aboutwindow");
  3534 	ad.setMinimumSize(500,500);
  3535 	ad.resize (QSize (500,500));
  3536 	ad.exec();
  3537 }
  3538 
  3539 void Main::helpAboutQT()
  3540 {
  3541 	QMessageBox::aboutQt( this, "Qt Application Example" );
  3542 }
  3543