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