Bugfix: Serious bug related to autosave fixed. release-1-12-maintained
authorinsilmaril
Tue, 10 Mar 2009 11:27:17 +0000
branchrelease-1-12-maintained
changeset 591c550f80c43b
parent 58 89dd2219982f
child 60 50c2fb829193
Bugfix: Serious bug related to autosave fixed.
demos/lifeforms.vym
mainwindow.cpp
mapeditor.cpp
tex/vym.changelog
version.h
vymmodel.cpp
     1.1 Binary file demos/lifeforms.vym has changed
     2.1 --- a/mainwindow.cpp	Thu Mar 05 09:33:30 2009 +0000
     2.2 +++ b/mainwindow.cpp	Tue Mar 10 11:27:17 2009 +0000
     2.3 @@ -1,251 +1,267 @@
     2.4  #include "mainwindow.h"
     2.5  
     2.6 -#include <qstatusbar.h>
     2.7 -#include <qmessagebox.h>
     2.8 -#include <qmenubar.h>
     2.9 -#include <qapplication.h>
    2.10 -#include <qpainter.h>
    2.11 -#include <qprinter.h>
    2.12 -#include <qfile.h>
    2.13 -#include <qfiledialog.h>
    2.14 -#include <qcolor.h>
    2.15 -#include <qcolordialog.h>
    2.16 -#include <qbitmap.h>
    2.17 -#include <qinputdialog.h>
    2.18 -
    2.19 +#include <QtGui>
    2.20  
    2.21  #include <iostream>
    2.22 -#include <stdlib.h>
    2.23  #include <typeinfo>
    2.24  
    2.25 -#include "version.h"
    2.26 -
    2.27 -#include "icons/filenew.xpm"
    2.28 -#include "icons/fileopen.xpm"
    2.29 -#include "icons/filesave.xpm"
    2.30 -#include "icons/fileprint.xpm"
    2.31 -#include "icons/editundo.xpm"
    2.32 -//#include "icons/editredo.xpm"	// TODO
    2.33 -#include "icons/editcopy.xpm"
    2.34 -#include "icons/editcut.xpm"
    2.35 -#include "icons/editpaste.xpm"
    2.36 -#include "icons/editmoveup.xpm"
    2.37 -#include "icons/editmovedown.xpm"
    2.38 -#include "icons/formatcoloritem.xpm"
    2.39 -#include "icons/formatcolorbranch.xpm"
    2.40 -#include "icons/formatcolorpicker.xpm"
    2.41 -#include "icons/viewzoomreset.xpm"
    2.42 -#include "icons/viewzoomin.xpm"
    2.43 -#include "icons/viewzoomout.xpm"
    2.44 -#include "icons/vym-48x48.xpm"
    2.45 -#include "icons/flag-note.xpm"
    2.46 -#include "icons/flag-url.xpm"
    2.47 -#include "icons/flag-vymlink.xpm"	
    2.48 -#include "icons/flag-scrolled-right.xpm"
    2.49 -
    2.50 +#include "aboutdialog.h"
    2.51 +#include "branchpropwindow.h"
    2.52 +#include "exportoofiledialog.h"
    2.53 +#include "exports.h"
    2.54 +#include "file.h"
    2.55  #include "flagrowobj.h"
    2.56 -#include "texteditor.h"
    2.57 +#include "historywindow.h"
    2.58 +#include "imports.h"
    2.59  #include "mapeditor.h"
    2.60 -#include "exporthtmldialog.h"
    2.61 -#include "exportxhtmldialog.h"
    2.62 -#include "showtextdialog.h"
    2.63 +#include "misc.h"
    2.64 +#include "options.h"
    2.65  #include "process.h"
    2.66  #include "settings.h"
    2.67 -#include "options.h"
    2.68 +#include "texteditor.h"
    2.69 +#include "warningdialog.h"
    2.70 +
    2.71 +#if defined(Q_OS_WIN32)
    2.72 +// Define only this structure as opposed to
    2.73 +// including full 'windows.h'. FindWindow
    2.74 +// clashes with the one in Win32 API.
    2.75 +typedef struct _PROCESS_INFORMATION
    2.76 +{
    2.77 +  long hProcess;
    2.78 +  long hThread;
    2.79 +  long dwProcessId;
    2.80 +  long dwThreadId;
    2.81 +} PROCESS_INFORMATION, *LPPROCESS_INFORMATION;
    2.82 +#endif
    2.83  
    2.84  extern TextEditor *textEditor;
    2.85  extern Main *mainWindow;
    2.86 +extern QString tmpVymDir;
    2.87 +extern QString clipboardDir;
    2.88 +extern QString clipboardFile;
    2.89 +extern bool clipboardEmpty;
    2.90  extern int statusbarTime;
    2.91 -extern MapEditor *clipboardME;
    2.92  extern FlagRowObj* standardFlagsDefault;
    2.93 -
    2.94 -extern QAction* actionFileSave;
    2.95 -extern QAction* actionFilePrint;
    2.96 -extern QAction* actionEditUndo;
    2.97 -extern QAction *actionEditCopy;
    2.98 -extern QAction *actionEditCut;
    2.99 -extern QAction *actionEditPaste;
   2.100 -extern QAction *actionEditMoveUp;
   2.101 -extern QAction *actionEditMoveDown;
   2.102 -extern QAction *actionEditToggleScroll;
   2.103 -extern QAction* actionEditOpenURL;
   2.104 -extern QAction* actionEditURL;
   2.105 -extern QAction* actionEditHeading2URL;
   2.106 -extern QAction* actionEditBugzilla2URL;
   2.107 -extern QAction *actionEditOpenVymLink;
   2.108 -extern QAction *actionEditVymLink;
   2.109 -extern QAction *actionEditDeleteVymLink;
   2.110 -extern QAction *actionEditMapInfo;
   2.111 -extern QAction *actionEditHeading;
   2.112 -extern QAction *actionEditDelete;
   2.113 -extern QAction *actionEditAddBranch;
   2.114 -extern QAction *actionEditAddBranchAbove;
   2.115 -extern QAction *actionEditAddBranchBelow;
   2.116 -extern QAction *actionEditImportAdd;
   2.117 -extern QAction *actionEditImportReplace;
   2.118 -extern QAction *actionEditSaveBranch;
   2.119 -extern QAction *actionEditSelectFirst;
   2.120 -extern QAction *actionEditSelectLast;
   2.121 -extern QAction *actionEditLoadImage;
   2.122 -extern QAction *actionEditToggleFloatExport;
   2.123 -
   2.124 -extern QAction* actionFormatColor;
   2.125 -extern QAction* actionFormatPickColor;
   2.126 -extern QAction* actionFormatColorBranch;
   2.127 -extern QAction* actionFormatColorSubtree;
   2.128 -extern QAction* actionFormatLinkColorHint;
   2.129 -extern QAction* actionFormatBackColor;
   2.130 -extern QAction* actionFormatLinkColor;
   2.131 -
   2.132 -extern QActionGroup *actionGroupFormatFrameTypes;
   2.133 -extern QAction *actionFormatFrameNone;
   2.134 -extern QAction *actionFormatFrameRectangle;
   2.135 -
   2.136 -extern QActionGroup *actionGroupFormatLinkStyles;
   2.137 -extern QAction *actionFormatLinkStyleLine;
   2.138 -extern QAction *actionFormatLinkStyleParabel;
   2.139 -extern QAction *actionFormatLinkStylePolyLine;
   2.140 -extern QAction *actionFormatLinkStylePolyParabel;
   2.141 -
   2.142 -extern QAction *actionViewToggleNoteEditor;
   2.143 -
   2.144 -extern QAction* actionSettingsAutoedit;
   2.145 -extern QAction* actionSettingsAutoselectHeading;
   2.146 -extern QAction* actionSettingsAutoselectHeading;
   2.147 -extern QAction* actionSettingsAutoselectText;
   2.148 -extern QAction* actionSettingsPasteNewHeading;
   2.149 -extern QAction* actionSettingsUseDelKey;
   2.150 -
   2.151 -extern QPopupMenu* branchContextMenu;
   2.152 -extern QPopupMenu* floatimageContextMenu;
   2.153 -extern QPopupMenu* saveImageFormatMenu;
   2.154 -extern QPopupMenu* canvasContextMenu;
   2.155 -extern QPopupMenu* lastMapsMenu;
   2.156 -extern QPopupMenu* exportMenu;
   2.157 -extern QPopupMenu* exportImageFormatMenu;
   2.158 +extern FlagRowObj* systemFlagsDefault;
   2.159 +extern QString vymName;
   2.160 +extern QString vymVersion;
   2.161 +extern QString vymBuildDate;
   2.162 +extern bool debug;
   2.163 +
   2.164 +QMenu* branchContextMenu;
   2.165 +QMenu* branchAddContextMenu;
   2.166 +QMenu* branchRemoveContextMenu;
   2.167 +QMenu* branchLinksContextMenu;
   2.168 +QMenu* branchXLinksContextMenuEdit;
   2.169 +QMenu* branchXLinksContextMenuFollow;
   2.170 +QMenu* floatimageContextMenu;
   2.171 +QMenu* canvasContextMenu;
   2.172 +QMenu* fileLastMapsMenu;
   2.173 +QMenu* fileImportMenu;
   2.174 +QMenu* fileExportMenu;
   2.175  
   2.176  
   2.177  extern Settings settings;
   2.178  extern Options options;
   2.179 -
   2.180 -#if defined(Q_OS_LINUX)
   2.181 -extern void qt_wait_for_window_manager( QWidget* w );
   2.182 +extern ImageIO imageIO;
   2.183 +
   2.184 +extern QDir vymBaseDir;
   2.185 +extern QDir lastImageDir;
   2.186 +extern QDir lastFileDir;
   2.187 +#if defined(Q_OS_WIN32)
   2.188 +extern QDir vymInstallDir;
   2.189  #endif
   2.190 -
   2.191 -Main::Main(QWidget* parent, const char* name, WFlags f) :
   2.192 +extern QString iconPath;
   2.193 +extern QString flagsPath;
   2.194 +
   2.195 +Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
   2.196      QMainWindow(parent,name,f)
   2.197  {
   2.198  	mainWindow=this;
   2.199  
   2.200 +	setObjectName ("MainWindow");
   2.201 +
   2.202  	setCaption ("VYM - View Your Mind");
   2.203  
   2.204  	// Load window settings
   2.205 -	resize (settings.readNumEntry( "/vym/mainwindow/geometry/width", 800),
   2.206 -	        settings.readNumEntry( "/vym/mainwindow/geometry/height",600));
   2.207 -	move   (settings.readNumEntry( "/vym/mainwindow/geometry/posX", 100),
   2.208 -	        settings.readNumEntry( "/vym/mainwindow/geometry/posY", 100));
   2.209 -
   2.210 +#if defined(Q_OS_WIN32)
   2.211 +    if (settings.value("/mainwindow/geometry/maximized", false).toBool())
   2.212 +    {
   2.213 +        setWindowState(Qt::WindowMaximized);
   2.214 +    }
   2.215 +    else
   2.216 +#endif
   2.217 +    {
   2.218 +        resize (settings.value("/mainwindow/geometry/size", QSize (800,600)).toSize());
   2.219 +        move   (settings.value("/mainwindow/geometry/pos",  QPoint(300,100)).toPoint());
   2.220 +    }
   2.221 +
   2.222 +	// Sometimes we may need to remember old selections
   2.223 +	prevSelection="";
   2.224 +
   2.225 +	// Default color
   2.226 +	currentColor=Qt::black;
   2.227 +
   2.228 +	// Create unique temporary directory
   2.229 +	bool ok;
   2.230 +	tmpVymDir=makeTmpDir (ok,"vym");
   2.231 +	if (!ok)
   2.232 +	{
   2.233 +		qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
   2.234 +		exit (1);
   2.235 +	}
   2.236 +	if (debug) qDebug (QString("vym tmpDir=%1").arg(tmpVymDir) );
   2.237 +
   2.238 +	// Create direcctory for clipboard
   2.239 +	clipboardDir=tmpVymDir+"/clipboard";
   2.240 +	clipboardFile="map.xml";
   2.241 +	QDir d(clipboardDir);
   2.242 +	d.mkdir (clipboardDir,true);
   2.243 +	makeSubDirs (clipboardDir);
   2.244 +	clipboardEmpty=true;
   2.245 +
   2.246 +	procBrowser=NULL;
   2.247 +
   2.248 +	// Satellite windows //////////////////////////////////////////
   2.249 +
   2.250 +	// history window
   2.251 +	historyWindow=new HistoryWindow();
   2.252 +	connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
   2.253 +
   2.254 +	// properties window
   2.255 +	branchPropertyWindow = new BranchPropertyWindow();
   2.256 +	connect (branchPropertyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
   2.257 +
   2.258 +	// Connect TextEditor, so that we can update flags if text changes
   2.259 +	connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
   2.260 +	connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
   2.261 +
   2.262 +	// Connect HistoryWindow, so that we can update flags
   2.263 +	connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
   2.264 +
   2.265 +
   2.266 +	// Initialize script editor
   2.267 +	scriptEditor = new SimpleScriptEditor();
   2.268 +	scriptEditor->move (50,50);
   2.269 +
   2.270 +	connect( scriptEditor, SIGNAL( runScript ( QString ) ), 
   2.271 +		this, SLOT( runScript( QString ) ) );
   2.272 +	
   2.273 +
   2.274 +	// Initialize Find window
   2.275 +	findWindow=new FindWindow(NULL);
   2.276 +	findWindow->move (x(),y()+70);
   2.277 +	connect (findWindow, SIGNAL( findButton(QString) ), 
   2.278 +		this, SLOT(editFind(QString) ) );	
   2.279 +	connect (findWindow, SIGNAL( somethingChanged() ), 
   2.280 +		this, SLOT(editFindChanged() ) );	
   2.281  
   2.282  	// Initialize some settings, which are platform dependant
   2.283  	QString p,s;
   2.284  
   2.285  		// application to open URLs
   2.286 -		p="/vym/mainwindow/readerURL";
   2.287 +		p="/mainwindow/readerURL";
   2.288  		#if defined(Q_OS_LINUX)
   2.289 -			s=settings.readEntry (p,"konqueror");
   2.290 +			s=settings.value (p,"xdg-open").toString();
   2.291  		#else
   2.292  			#if defined(Q_OS_MACX)
   2.293 -				s=settings.readEntry (p,"/Applications/Safari.app/Contents/MacOS/Safari");
   2.294 -			#else
   2.295 -				s=settings.readEntry (p,"mozilla");
   2.296 +				s=settings.value (p,"/usr/bin/open").toString();
   2.297 +
   2.298 +            #else
   2.299 +                #if defined(Q_OS_WIN32)
   2.300 +                    // Assume that system has been set up so that
   2.301 +                    // Explorer automagically opens up the URL
   2.302 +                    // in the user's preferred browser.
   2.303 +                    s=settings.value (p,"explorer").toString();
   2.304 +                #else
   2.305 +					s=settings.value (p,"mozilla").toString();
   2.306 +				#endif
   2.307  			#endif
   2.308  		#endif
   2.309 -		settings.writeEntry( p,s);
   2.310 +		settings.setValue( p,s);
   2.311  
   2.312  		// application to open PDFs
   2.313 -		p="/vym/mainwindow/readerPDF";
   2.314 +		p="/mainwindow/readerPDF";
   2.315  		#if defined(Q_OS_LINUX)
   2.316 -			s=settings.readEntry (p,"acroread");
   2.317 +			s=settings.value (p,"xdg-open").toString();
   2.318  		#else
   2.319  			#if defined(Q_OS_MACX)
   2.320 -				s=settings.readEntry (p,"/Applications/Safari.app/Contents/MacOS/Safari");
   2.321 +				s=settings.value (p,"/usr/bin/open").toString();
   2.322 +            #elif defined(Q_OS_WIN32)
   2.323 +                s=settings.value (p,"acrord32").toString();
   2.324  			#else
   2.325 -				s=settings.readEntry (p,"acroread");
   2.326 +				s=settings.value (p,"acroread").toString();
   2.327  			#endif
   2.328  		#endif
   2.329 -		settings.writeEntry( p,s);
   2.330 -
   2.331 +		settings.setValue( p,s);
   2.332 +
   2.333 +	// width of xLinksMenu
   2.334 +	xLinkMenuWidth=60;
   2.335  	
   2.336 -	maxLastMaps=9;
   2.337 -
   2.338  	// Create tab widget which holds the maps
   2.339  	tabWidget= new QTabWidget (this);
   2.340  	connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ), 
   2.341  		this, SLOT( editorChanged( QWidget * ) ) );
   2.342  
   2.343 +	lineedit=new QLineEdit (this);
   2.344 +	lineedit->hide();
   2.345 +
   2.346  	setCentralWidget(tabWidget);	
   2.347  
   2.348      setupFileActions();
   2.349      setupEditActions();
   2.350      setupFormatActions();
   2.351      setupViewActions();
   2.352 +    setupModeActions();
   2.353  	setupFlagActions();
   2.354 +    setupNetworkActions();
   2.355      setupSettingsActions();
   2.356  	setupContextMenus();
   2.357 -    if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) setupTestActions();
   2.358 +	setupMacros();
   2.359 +    if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
   2.360      setupHelpActions();
   2.361      
   2.362 -	// After menu is created, we can enable some actions
   2.363 -	actionFilePrint->setEnabled (true);
   2.364 -
   2.365      statusBar();
   2.366  
   2.367 -	// Create the default map into first tab
   2.368 -//	fileNew();
   2.369 -//	tabWidget->addTab (new MapEditor(tabWidget,true), "unnamed");
   2.370 -//	currentMapEditor()->show();
   2.371 -
   2.372 -	// Initialize Find window
   2.373 -	findWindow=new FindWindow(NULL,"findwindow");
   2.374 -	connect (findWindow, SIGNAL( findButton(QString) ), 
   2.375 -		this, SLOT(editFind(QString) ) );	
   2.376 -	connect (findWindow, SIGNAL( somethingChanged() ), 
   2.377 -		this, SLOT(editFindChanged() ) );	
   2.378 +	restoreState (settings.value("/mainwindow/state",0).toByteArray());
   2.379  
   2.380  	updateGeometry();
   2.381  }
   2.382  
   2.383  Main::~Main()
   2.384  {
   2.385 +	//cout << "Destr MainWindow\n";
   2.386  	// Save Settings
   2.387 -	settings.writeEntry( "/vym/mainwindow/geometry/width", width() );
   2.388 -	settings.writeEntry( "/vym/mainwindow/geometry/height", height() );
   2.389 -	settings.writeEntry( "/vym/mainwindow/geometry/posX", pos().x() );
   2.390 -	settings.writeEntry( "/vym/mainwindow/geometry/posY", pos().y() );
   2.391 -
   2.392 -	settings.writeEntry( "/vym/version/version", __VYM_VERSION__ );
   2.393 -	settings.writeEntry( "/vym/version/builddate", __BUILD_DATE__ );
   2.394 -
   2.395 -	settings.writeEntry( "/vym/mapeditor/editmode/autoselectheading",actionSettingsAutoselectHeading->isOn() );
   2.396 -	settings.writeEntry( "/vym/mapeditor/editmode/autoselecttext",actionSettingsAutoselectText->isOn() );
   2.397 -	settings.writeEntry( "/vym/mapeditor/editmode/pastenewheading",actionSettingsPasteNewHeading->isOn() );
   2.398 -	settings.writeEntry( "/vym/mapeditor/editmode/autoedit",actionSettingsAutoedit->isOn() );
   2.399 -	settings.writeEntry( "/vym/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
   2.400 -
   2.401 -	QString s;
   2.402 -	int maps=lastMaps.count();
   2.403 -	settings.writeEntry( "/vym/lastMaps/number",maps );
   2.404 -	for (int i=1;i<=maps;i++)
   2.405 -	{
   2.406 -		QStringList::Iterator it = lastMaps.at(i-1);
   2.407 -		s=QString("/vym/lastMaps/map-%1").arg(i);
   2.408 -		if (!s.isEmpty() && i<=maxLastMaps) 
   2.409 -			settings.writeEntry (s, *it);
   2.410 -	}
   2.411 -
   2.412 -
   2.413 -	// To make the texteditor save its settings, call the destructor
   2.414 -	delete (textEditor);
   2.415 +#if defined(Q_OS_WIN32)
   2.416 +    settings.setValue ("/mainwindow/geometry/maximized", isMaximized());
   2.417 +#endif
   2.418 +	settings.setValue ("/mainwindow/geometry/size", size());
   2.419 +	settings.setValue ("/mainwindow/geometry/pos", pos());
   2.420 +	settings.setValue ("/mainwindow/state",saveState(0));
   2.421 +
   2.422 +	settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
   2.423 +	settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
   2.424 +	settings.setValue( "/version/version", vymVersion );
   2.425 +	settings.setValue( "/version/builddate", vymBuildDate );
   2.426 +
   2.427 +	settings.setValue( "/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
   2.428 +	settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isOn() );
   2.429 +	settings.setValue( "/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
   2.430 +	settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
   2.431 +	settings.setValue( "/mapeditor/editmode/autoEditNewBranch",actionSettingsAutoEditNewBranch->isOn() );
   2.432 +	settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
   2.433 +	settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
   2.434 +	settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
   2.435 +
   2.436 +	//TODO save scriptEditor settings
   2.437 +
   2.438 +	// call the destructors
   2.439 +	delete textEditor;
   2.440 +	delete historyWindow;
   2.441 +	delete branchPropertyWindow;
   2.442 +
   2.443 +	// Remove temporary directory
   2.444 +	removeDir (QDir(tmpVymDir));
   2.445  }
   2.446  
   2.447  void Main::loadCmdLine()
   2.448 @@ -269,7 +285,7 @@
   2.449  
   2.450  void Main::statusMessage(const QString &s)
   2.451  {
   2.452 -	statusBar()->message (s);
   2.453 +	statusBar()->message( s);
   2.454  }
   2.455  
   2.456  void Main::closeEvent (QCloseEvent* )
   2.457 @@ -280,490 +296,1238 @@
   2.458  // File Actions
   2.459  void Main::setupFileActions()
   2.460  {
   2.461 -    QToolBar *tb = new QToolBar( this );
   2.462 -    tb->setLabel( "File Actions" );
   2.463 -    QPopupMenu *menu = new QPopupMenu( this );
   2.464 -    menuBar()->insertItem( tr( "&File" ), menu );
   2.465 -
   2.466 -	// Keycodes:  /usr/lib64/qt3/include/qnamespace.h
   2.467 +	QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
   2.468 +    QToolBar *tb = addToolBar( tr ("&Map") );
   2.469 +	tb->setObjectName ("mapTB");
   2.470  
   2.471      QAction *a;
   2.472 -    a = new QAction( tr( "New map" ), QPixmap( filenew_xpm ), tr( "&New..." ), CTRL + Key_N, this, "fileNew" );
   2.473 -    connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
   2.474 +    a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this);
   2.475 +	a->setStatusTip ( tr( "New map","Status tip File menu" ) );
   2.476 +	a->setShortcut ( Qt::CTRL + Qt::Key_N );		//New map
   2.477      a->addTo( tb );
   2.478 -    a->addTo( menu );
   2.479 +	fileMenu->addAction (a);
   2.480 +    connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
   2.481  	
   2.482 -    a = new QAction( tr( "Open" ), QPixmap( fileopen_xpm), tr( "&Open..." ), CTRL + Key_O, this, "fileOpen" );
   2.483 -    connect( a, SIGNAL( activated() ), this, SLOT( fileLoad() ) );
   2.484 +    a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this);
   2.485 +	a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) );
   2.486 +	a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N );		//New map
   2.487 +	fileMenu->addAction (a);
   2.488 +    connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) );
   2.489 +	actionFileNewCopy=a;
   2.490 +	
   2.491 +    a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
   2.492 +	a->setStatusTip (tr( "Open","Status tip File menu" ) );
   2.493 +	a->setShortcut ( Qt::CTRL + Qt::Key_O );		//Open map
   2.494      a->addTo( tb );
   2.495 -    a->addTo( menu );
   2.496 +	fileMenu->addAction (a);
   2.497 +    connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
   2.498  	
   2.499 -	lastMapsMenu = new QPopupMenu (this);
   2.500 -
   2.501 -    menu->insertItem (tr("Open Recent"),lastMapsMenu );
   2.502 -    menu->insertSeparator();
   2.503 +	fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
   2.504 +	fileMenu->addSeparator();
   2.505  	
   2.506 -    a = new QAction( tr( "Save" ), QPixmap( filesave_xpm ), tr( "&Save..." ), CTRL + Key_S, this, "fileSave" );
   2.507 -    connect( a, SIGNAL( activated() ), this, SLOT( fileSave() ) );
   2.508 +    a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
   2.509 +	a->setStatusTip ( tr( "Save","Status tip file menu" ));
   2.510 +	a->setShortcut (Qt::CTRL + Qt::Key_S );			//Save map
   2.511      a->addTo( tb );
   2.512 -    a->addTo( menu );
   2.513 +	fileMenu->addAction (a);
   2.514 +    connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
   2.515  	actionFileSave=a;
   2.516  	
   2.517 -    a = new QAction( tr( "Save &As" ), QPixmap(), tr( "Save &As..." ), 0, this, "fileSaveAs" );
   2.518 -    connect( a, SIGNAL( activated() ), this, SLOT( fileSaveAs() ) );
   2.519 -    a->addTo( menu );
   2.520 -
   2.521 -    menu->insertSeparator();
   2.522 -
   2.523 -    a = new QAction( tr( "Import directory structure (experimental)" ), QPixmap(), tr( "Import Dir" ), 0, this, "export" );
   2.524 -    connect( a, SIGNAL( activated() ), this, SLOT( fileImportDir() ) );
   2.525 -    a->addTo( menu );
   2.526 -
   2.527 -	exportMenu = new QPopupMenu (this);
   2.528 -    menu->insertItem (tr("Export"),exportMenu );
   2.529 -
   2.530 -    menu->insertSeparator();
   2.531 -
   2.532 -
   2.533 -    a = new QAction( tr( "Print" ), QPixmap( fileprint_xpm ), tr( "&Print..." ), CTRL + Key_P, this, "filePrint" );
   2.534 -    connect( a, SIGNAL( activated() ), this, SLOT( filePrint() ) );
   2.535 +    a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
   2.536 +	a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
   2.537 +	fileMenu->addAction (a);
   2.538 +    connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
   2.539 +
   2.540 +	fileMenu->addSeparator();
   2.541 +
   2.542 +	fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
   2.543 +
   2.544 +	a = new QAction(tr("KDE Bookmarks"), this);
   2.545 +	a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE bookmarks")));
   2.546 +	a->addTo (fileImportMenu);
   2.547 +	connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) );
   2.548 +
   2.549 +    if (settings.value( "/mainwindow/showTestMenu",false).toBool()) 
   2.550 +	{
   2.551 +		a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
   2.552 +		a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
   2.553 +		a->addTo (fileImportMenu);
   2.554 +		connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
   2.555 +	}	
   2.556 +
   2.557 +	a = new QAction("Freemind...",this);
   2.558 +	a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Freemind")  );
   2.559 +	fileImportMenu->addAction (a);
   2.560 +	connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFreemind() ) );
   2.561 +
   2.562 +	a = new QAction("Mind Manager...",this);
   2.563 +	a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager")  );
   2.564 +	fileImportMenu->addAction (a);
   2.565 +	connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
   2.566 +
   2.567 +    a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
   2.568 +	a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
   2.569 +	fileImportMenu->addAction (a);
   2.570 +    connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
   2.571 +
   2.572 +	fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
   2.573 +
   2.574 +	a = new QAction( tr("Image%1","File export menu").arg("..."), this);
   2.575 +	a->setStatusTip( tr( "Export map as image","status tip file menu" ));
   2.576 +	connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
   2.577 +	fileExportMenu->addAction (a);
   2.578 +
   2.579 +	a = new QAction( "Open Office...", this);
   2.580 +	a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
   2.581 +	connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
   2.582 +	fileExportMenu->addAction (a);
   2.583 +
   2.584 +	a = new QAction(  "Webpage (XHTML)...",this );
   2.585 +	a->setShortcut (Qt::ALT + Qt::Key_X);			//Export XHTML
   2.586 +	a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
   2.587 +    connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
   2.588 +	fileExportMenu->addAction (a);
   2.589 +
   2.590 +    a = new QAction( "Text (ASCII)...", this);
   2.591 +	a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
   2.592 +    connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
   2.593 +	fileExportMenu->addAction (a);
   2.594 +
   2.595 +    a = new QAction( "Spreadsheet (CSV)...", this);
   2.596 +	a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
   2.597 +    connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
   2.598 +	fileExportMenu->addAction (a);
   2.599 +
   2.600 +	a = new QAction( tr("KDE Bookmarks","File menu"), this);
   2.601 +	a->setStatusTip( tr( "Export as %1").arg(tr("KDE Bookmarks" )));
   2.602 +	connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
   2.603 +	fileExportMenu->addAction (a);
   2.604 +
   2.605 +    a = new QAction( "Taskjuggler...", this );
   2.606 +    a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
   2.607 +    connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
   2.608 +	fileExportMenu->addAction (a);
   2.609 +
   2.610 +    a = new QAction( "LaTeX...", this);
   2.611 +    a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
   2.612 +    connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
   2.613 +	fileExportMenu->addAction (a);
   2.614 +
   2.615 +	a = new QAction( "XML..." , this );
   2.616 +	a->setStatusTip (tr( "Export as %1").arg("XML"));
   2.617 +    connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
   2.618 +	fileExportMenu->addAction (a);
   2.619 +
   2.620 +	fileMenu->addSeparator();
   2.621 +
   2.622 +    a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
   2.623 +	a->setStatusTip ( tr( "Print" ,"File menu") );
   2.624 +	a->setShortcut (Qt::CTRL + Qt::Key_P );			//Print map
   2.625      a->addTo( tb );
   2.626 -    a->addTo( menu );
   2.627 +	fileMenu->addAction (a);
   2.628 +    connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
   2.629  	actionFilePrint=a;
   2.630  
   2.631 -    a = new QAction( tr( "Close Map" ), QPixmap(), tr( "&Close Map" ), ALT + Key_C, this, "fileCloseMap" );
   2.632 -    connect( a, SIGNAL( activated() ), this, SLOT( fileCloseMap() ) );
   2.633 -    a->addTo( menu );
   2.634 -
   2.635 -    a = new QAction( tr( "Exit VYM" ), QPixmap(), tr( "E&xit VYM" ), CTRL + Key_Q, this, "fileExitVYM" );
   2.636 -    connect( a, SIGNAL( activated() ), this, SLOT( fileExitVYM() ) );
   2.637 -    a->addTo( menu );
   2.638 +    a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
   2.639 +	a->setStatusTip (tr( "Close Map" ) );
   2.640 +	a->setShortcut (Qt::CTRL + Qt::Key_W );			//Close map
   2.641 +	fileMenu->addAction (a);
   2.642 +    connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
   2.643 +
   2.644 +    a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
   2.645 +	a->setStatusTip ( tr( "Exit")+" "+vymName );
   2.646 +	a->setShortcut (Qt::CTRL + Qt::Key_Q );			//Quit vym
   2.647 +	fileMenu->addAction (a);
   2.648 +    connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
   2.649  }
   2.650  
   2.651  
   2.652  //Edit Actions
   2.653  void Main::setupEditActions()
   2.654  {
   2.655 -    QToolBar *tb = new QToolBar( this );
   2.656 +    QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
   2.657      tb->setLabel( "Edit Actions" );
   2.658 -    QPopupMenu *menu = new QPopupMenu( this );
   2.659 -    menuBar()->insertItem( tr( "&Edit" ), menu );
   2.660 +	tb->setObjectName ("actionsTB");
   2.661 +    QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
   2.662  
   2.663      QAction *a;
   2.664 -    a = new QAction( tr( "Undo" ), QPixmap( editundo_xpm ), tr( "&Undo" ), CTRL + Key_Z, this, "editUndo" );
   2.665 -    connect( a, SIGNAL( activated() ), this, SLOT( editUndo() ) );
   2.666 +	QAction *alt;
   2.667 +    a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
   2.668 +    connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
   2.669 +	a->setStatusTip (tr( "Undo" ) );
   2.670 +	a->setShortcut ( Qt::CTRL + Qt::Key_Z );		//Undo last action
   2.671  	a->setEnabled (false);
   2.672 -    a->addTo( tb );
   2.673 -    a->addTo( menu );
   2.674 +    tb->addAction (a);
   2.675 +	editMenu->addAction (a);
   2.676  	actionEditUndo=a;
   2.677 -    /*
   2.678 -    a = new QAction( tr( "Redo" ), QPixmap( editredo_xpm ), tr( "&Redo" ), CTRL + Key_Y, this, "editRedo" ); 
   2.679 -    connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) );
   2.680 -    a->addTo( tb );
   2.681 -    a->addTo( menu );
   2.682 -    */
   2.683 -    menu->insertSeparator();
   2.684 -    a = new QAction( tr( "Copy" ), QPixmap( editcopy_xpm ), tr( "&Copy" ), CTRL + Key_C, this, "editCopy" );
   2.685 -    connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
   2.686 +    
   2.687 +	a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this); 
   2.688 +	a->setStatusTip (tr( "Redo" ));
   2.689 +	a->setShortcut (Qt::CTRL + Qt::Key_Y );			//Redo last action
   2.690 +    tb->addAction (a);
   2.691 +	editMenu->addAction (a);
   2.692 +	connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
   2.693 +	actionEditRedo=a;
   2.694 +   
   2.695 +	editMenu->addSeparator();
   2.696 +    a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
   2.697 +	a->setStatusTip ( tr( "Copy" ) );
   2.698 +	a->setShortcut (Qt::CTRL + Qt::Key_C );			//Copy
   2.699  	a->setEnabled (false);
   2.700 -    a->addTo( tb );
   2.701 -    a->addTo( menu );
   2.702 +    tb->addAction (a);
   2.703 +	editMenu->addAction (a);
   2.704 +    connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
   2.705  	actionEditCopy=a;
   2.706 -    a = new QAction( tr( "Cut" ), QPixmap( editcut_xpm ), tr( "Cu&t" ), CTRL + Key_X, this, "editCut" );
   2.707 -    connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
   2.708 +	
   2.709 +    a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
   2.710 +	a->setStatusTip ( tr( "Cut" ) );
   2.711 +	a->setShortcut (Qt::CTRL + Qt::Key_X );			//Cut
   2.712  	a->setEnabled (false);
   2.713 -    a->addTo( tb );
   2.714 -    a->addTo( menu );
   2.715 +    tb->addAction (a);
   2.716 +	editMenu->addAction (a);
   2.717  	actionEditCut=a;
   2.718 -    a = new QAction( tr( "Paste" ), QPixmap( editpaste_xpm ), tr( "&Paste" ), CTRL + Key_V, this, "editPaste" );
   2.719 -    connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
   2.720 +    connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
   2.721 +	
   2.722 +    a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
   2.723 +    connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
   2.724 +	a->setStatusTip ( tr( "Paste" ) );
   2.725 +	a->setShortcut ( Qt::CTRL + Qt::Key_V );		//Paste
   2.726  	a->setEnabled (false);
   2.727 -    a->addTo( tb );
   2.728 -    a->addTo( menu );
   2.729 +    tb->addAction (a);
   2.730 +	editMenu->addAction (a);
   2.731  	actionEditPaste=a;
   2.732 -    a = new QAction( tr( "Move branch up" ), QPixmap( editmoveup_xpm ), tr( "Move up" ), Key_PageUp, this, "editMoveUp" );
   2.733 -    connect( a, SIGNAL( activated() ), this, SLOT( editMoveUp() ) );
   2.734 +
   2.735 +    // Shortcuts to modify heading:
   2.736 +    a = new QAction(tr( "Edit heading","Edit menu" ),this);
   2.737 +	a->setStatusTip ( tr( "edit Heading" ));
   2.738 +	a->setShortcut ( Qt::Key_Enter);				//Edit heading
   2.739 +//	a->setShortcutContext (Qt::WindowShortcut);
   2.740 +	addAction (a);
   2.741 +    connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
   2.742 +	actionListBranches.append(a);
   2.743 +    a = new QAction( tr( "Edit heading","Edit menu" ), this);
   2.744 +	a->setStatusTip (tr( "edit Heading" ));
   2.745 +	a->setShortcut (Qt::Key_Return );				//Edit heading
   2.746 +	//a->setShortcutContext (Qt::WindowShortcut);
   2.747 +	addAction (a);
   2.748 +    connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
   2.749 +	actionListBranches.append(a);
   2.750 +	editMenu->addAction (a);
   2.751 +	actionEditHeading=a;
   2.752 +    a = new QAction( tr( "Edit heading","Edit menu" ), this);
   2.753 +	a->setStatusTip (tr( "edit Heading" ));
   2.754 +	//a->setShortcut ( Qt::Key_F2 );					//Edit heading
   2.755 +	a->setShortcutContext (Qt::WindowShortcut);
   2.756 +	addAction (a);
   2.757 +    connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
   2.758 +	actionListBranches.append(a);
   2.759 +    
   2.760 +    // Shortcut to delete selection
   2.761 +    a = new QAction( tr( "Delete Selection","Edit menu" ),this);
   2.762 +	a->setStatusTip (tr( "Delete Selection" ));
   2.763 +	a->setShortcut ( Qt::Key_Delete);				//Delete selection
   2.764 +	a->setShortcutContext (Qt::WindowShortcut);
   2.765 +	addAction (a);
   2.766 +    connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
   2.767 +	actionEditDelete=a;
   2.768 +    
   2.769 +    // Shortcut to add mapcenter
   2.770 +	a= new QAction(tr( "Add mapcenter","Canvas context menu" ), this);
   2.771 +    connect( a, SIGNAL( triggered() ), this, SLOT( editAddMapCenter() ) );
   2.772 +	actionEditAddMapCenter = a;
   2.773 +
   2.774 +
   2.775 +    // Shortcut to add branch
   2.776 +	alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
   2.777 +	alt->setStatusTip ( tr( "Add a branch as child of selection" ));
   2.778 +	alt->setShortcut (Qt::Key_A);					//Add branch
   2.779 +	alt->setShortcutContext (Qt::WindowShortcut);
   2.780 +	addAction (alt);
   2.781 +	connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
   2.782 +	a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
   2.783 +	a->setStatusTip ( tr( "Add a branch as child of selection" ));
   2.784 +	a->setShortcut (Qt::Key_Insert);				//Add branch
   2.785 +	connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
   2.786 +	actionListBranches.append(a);
   2.787 +	#if defined (Q_OS_MACX)
   2.788 +		// In OSX show different shortcut in menues, the keys work indepently always			
   2.789 +		actionEditAddBranch=alt;
   2.790 +	#else	
   2.791 +		actionEditAddBranch=a;
   2.792 +	#endif	
   2.793 +	editMenu->addAction (actionEditAddBranch);
   2.794 +	tb->addAction (actionEditAddBranch);
   2.795 +
   2.796 +
   2.797 +    // Add branch by inserting it at selection
   2.798 +	a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
   2.799 +	a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
   2.800 +	a->setShortcut (Qt::ALT + Qt::Key_Insert );		//Insert branch
   2.801 +	a->setShortcutContext (Qt::WindowShortcut);
   2.802 +	addAction (a);
   2.803 +    connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
   2.804  	a->setEnabled (false);
   2.805 -    a->addTo( tb );
   2.806 -    a->addTo( menu );
   2.807 +	actionListBranches.append(a);
   2.808 +	actionEditAddBranchBefore=a;
   2.809 +	a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
   2.810 +	a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
   2.811 +	a->setShortcut ( Qt::ALT + Qt::Key_A );			//Insert branch
   2.812 +	a->setShortcutContext (Qt::WindowShortcut);
   2.813 +	addAction (a);
   2.814 +    connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
   2.815 +	actionListBranches.append(a);
   2.816 +
   2.817 +	// Add branch above
   2.818 +    a = new QAction(tr( "Add branch above","Edit menu" ), this);
   2.819 +	a->setStatusTip ( tr( "Add a branch above selection" ));
   2.820 +	a->setShortcut (Qt::SHIFT+Qt::Key_Insert );		//Add branch above
   2.821 +	a->setShortcutContext (Qt::WindowShortcut);
   2.822 +	addAction (a);
   2.823 +    connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
   2.824 +	a->setEnabled (false);
   2.825 +	actionListBranches.append(a);
   2.826 +	actionEditAddBranchAbove=a;
   2.827 +    a = new QAction(tr( "Add branch above","Edit menu" ), this);
   2.828 +	a->setStatusTip ( tr( "Add a branch above selection" ));
   2.829 +	a->setShortcut (Qt::SHIFT+Qt::Key_A );			//Add branch above
   2.830 +	a->setShortcutContext (Qt::WindowShortcut);
   2.831 +	addAction (a);
   2.832 +    connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
   2.833 +	actionListBranches.append(a);
   2.834 +
   2.835 +	// Add branch below 
   2.836 +    a = new QAction(tr( "Add branch below","Edit menu" ), this);
   2.837 +	a->setStatusTip ( tr( "Add a branch below selection" ));
   2.838 +	a->setShortcut (Qt::CTRL +Qt::Key_Insert );		//Add branch below
   2.839 +	a->setShortcutContext (Qt::WindowShortcut);
   2.840 +	addAction (a);
   2.841 +    connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
   2.842 +	a->setEnabled (false);
   2.843 +	actionListBranches.append(a);
   2.844 +	actionEditAddBranchBelow=a;
   2.845 +    a = new QAction(tr( "Add branch below","Edit menu" ), this);
   2.846 +	a->setStatusTip ( tr( "Add a branch below selection" ));
   2.847 +	a->setShortcut (Qt::CTRL +Qt::Key_A );			// Add branch below
   2.848 +	a->setShortcutContext (Qt::WindowShortcut);
   2.849 +	addAction (a);
   2.850 +    connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
   2.851 +	actionListBranches.append(a);
   2.852 +
   2.853 +    a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
   2.854 +	a->setStatusTip ( tr( "Move branch up" ) );
   2.855 +	a->setShortcut (Qt::Key_PageUp );				// Move branch up
   2.856 +	a->setEnabled (false);
   2.857 +    tb->addAction (a);
   2.858 +	editMenu->addAction (a);
   2.859 +    connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
   2.860  	actionEditMoveUp=a;
   2.861 -    a = new QAction( tr( "Move branch down" ), QPixmap( editmovedown_xpm ), tr( "Move down" ), Key_PageDown, this, "editMoveDown" );
   2.862 -    connect( a, SIGNAL( activated() ), this, SLOT( editMoveDown() ) );
   2.863 +
   2.864 +    a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
   2.865 +    connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
   2.866 +	a->setStatusTip (tr( "Move branch down" ) );
   2.867 +	a->setShortcut ( Qt::Key_PageDown );			// Move branch down
   2.868  	a->setEnabled (false);
   2.869 -    a->addTo( tb );
   2.870 -    a->addTo( menu );
   2.871 +    tb->addAction (a);
   2.872 +	editMenu->addAction (a);
   2.873  	actionEditMoveDown=a;
   2.874 -
   2.875 -    a = new QAction( tr( "Scroll branch" ), QPixmap(flag_scrolled_right_xpm), tr( "Scroll branch" ), Key_ScrollLock, this, "scroll" );
   2.876 -    connect( a, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
   2.877 -	a->setEnabled (false);
   2.878 -    a->addTo( tb );
   2.879 -    a->addTo( menu );
   2.880 -	actionEditToggleScroll=a;
   2.881  	
   2.882 -    a = new QAction( tr( "Unscroll all" ), QPixmap(), tr( "Unscroll all scrolled branches" ), 0, this, "scroll" );
   2.883 -    connect( a, SIGNAL( activated() ), this, SLOT( editUnScrollAll() ) );
   2.884 -    a->addTo( menu );
   2.885 +	a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this );
   2.886 +	connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) );
   2.887 +	a->setEnabled (true);
   2.888 +	a->addTo( tb );
   2.889 +	editMenu->addAction (a);
   2.890 +	actionEditSortChildren=a;
   2.891 +
   2.892 +	a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this);
   2.893 +	a->setShortcut ( Qt::Key_ScrollLock );
   2.894 +	a->setStatusTip (tr( "Scroll branch" ) );
   2.895 +    connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
   2.896 +
   2.897 +	alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
   2.898 +	alt->setShortcut ( Qt::Key_S );					// Scroll branch
   2.899 +	alt->setStatusTip (tr( "Scroll branch" )); 
   2.900 +    connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
   2.901 +	#if defined(Q_OS_MACX)
   2.902 +		actionEditToggleScroll=alt;
   2.903 +	#else	
   2.904 +		actionEditToggleScroll=a;
   2.905 +	#endif	
   2.906 +	actionEditToggleScroll->setEnabled (false);
   2.907 +	actionEditToggleScroll->setToggleAction(true);
   2.908 +    tb->addAction (actionEditToggleScroll);
   2.909 +    editMenu->addAction ( actionEditToggleScroll);
   2.910 +	editMenu->addAction (actionEditToggleScroll);
   2.911 +	addAction (a);
   2.912 +	addAction (alt);
   2.913 +	actionListBranches.append(actionEditToggleScroll);
   2.914  	
   2.915 -    menu->insertSeparator();
   2.916 -
   2.917 -	a = new QAction( tr( "Find" ), QPixmap(), tr( "Find" ), CTRL + Key_F, this, "find" );
   2.918 -    connect( a, SIGNAL( activated() ), this, SLOT( editOpenFindWindow() ) );
   2.919 -    a->addTo( menu );
   2.920 +    a = new QAction( tr( "Unscroll childs","Edit menu" ), this);
   2.921 +	a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
   2.922 +	editMenu->addAction (a);
   2.923 +    connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChilds() ) );
   2.924 +	
   2.925 +	editMenu->addSeparator();
   2.926 +
   2.927 +	a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
   2.928 +	a->setStatusTip (tr( "Find" ) );
   2.929 +	a->setShortcut (Qt::CTRL + Qt::Key_F );				//Find
   2.930 +	editMenu->addAction (a);
   2.931 +    connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
   2.932      
   2.933 -	menu->insertSeparator();
   2.934 -
   2.935 -	a = new QAction( tr( "Open URL" ), QPixmap(flag_url_xpm), tr( "Open URL" ), CTRL + Key_U, this, "url" );
   2.936 -    connect( a, SIGNAL( activated() ), this, SLOT( editOpenURL() ) );
   2.937 -    a->addTo( menu );
   2.938 -    a->addTo( tb );
   2.939 -	a->setEnabled (false);
   2.940 +	editMenu->addSeparator();
   2.941 +
   2.942 +	a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
   2.943 +	a->setShortcut (Qt::CTRL + Qt::Key_U );
   2.944 +	a->setShortcut (tr( "Open URL" ));
   2.945 +    tb->addAction (a);
   2.946 +	addAction(a);
   2.947 +    connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
   2.948  	actionEditOpenURL=a;
   2.949  
   2.950 -	a = new QAction( tr( "Edit URL" ), QPixmap(), tr( "Edit URL" ), SHIFT + CTRL + Key_U, this, "url" );
   2.951 -    connect( a, SIGNAL( activated() ), this, SLOT( editURL() ) );
   2.952 -    a->addTo( menu );
   2.953 -	a->setEnabled (false);
   2.954 +	a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
   2.955 +	a->setStatusTip (tr( "Open URL in new tab" ));
   2.956 +	//a->setShortcut (Qt::CTRL+Qt::Key_U );
   2.957 +	addAction(a);
   2.958 +    connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
   2.959 +	actionEditOpenURLTab=a;
   2.960 +
   2.961 +	a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
   2.962 +	a->setStatusTip (tr( "Open all URLs in subtree" ));
   2.963 +	addAction(a);
   2.964 +	actionListBranches.append(a);
   2.965 +    connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
   2.966 +	actionEditOpenMultipleURLTabs=a;
   2.967 +
   2.968 +	a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
   2.969 +	a->setStatusTip ( tr( "Edit URL" ) );
   2.970 +	a->setShortcut ( Qt::Key_U );
   2.971 +	a->setShortcutContext (Qt::WindowShortcut);
   2.972 +	actionListBranches.append(a);
   2.973 +	addAction(a);
   2.974 +    connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
   2.975  	actionEditURL=a;
   2.976  	
   2.977 -	a = new QAction( tr( "Use heading of selected branch as URL" ), QPixmap(), tr( "Use heading for URL" ), 0, this, "heading2url" );
   2.978 -    connect( a, SIGNAL( activated() ), this, SLOT( editHeading2URL() ) );
   2.979 -    a->addTo( menu );
   2.980 +	a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
   2.981 +	a->setStatusTip ( tr( "Edit local URL" ) );
   2.982 +	a->setShortcut (Qt::SHIFT +  Qt::Key_U );
   2.983 +	a->setShortcutContext (Qt::WindowShortcut);
   2.984 +	actionListBranches.append(a);
   2.985 +	addAction(a);
   2.986 +    connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
   2.987 +	actionEditLocalURL=a;
   2.988 +	
   2.989 +	a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
   2.990 +	a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
   2.991  	a->setEnabled (false);
   2.992 +	actionListBranches.append(a);
   2.993 +    connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
   2.994  	actionEditHeading2URL=a;
   2.995      
   2.996 -	a = new QAction( tr( "Create URL to Bugzilla" ), QPixmap(), tr( "Create URL to Bugzilla" ), 0, this, "bugzilla2url" );
   2.997 -    connect( a, SIGNAL( activated() ), this, SLOT( editBugzilla2URL() ) );
   2.998 +	a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
   2.999 +	a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
  2.1000  	a->setEnabled (false);
  2.1001 +	actionListBranches.append(a);
  2.1002 +    connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
  2.1003  	actionEditBugzilla2URL=a;
  2.1004      
  2.1005 -	menu->insertSeparator();
  2.1006 +	a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
  2.1007 +	a->setStatusTip ( tr( "Create URL to Novell FATE" ));
  2.1008 +	a->setEnabled (false);
  2.1009 +	actionListBranches.append(a);
  2.1010 +    connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
  2.1011 +	actionEditFATE2URL=a;
  2.1012  	
  2.1013 -    a = new QAction( tr( "Jump to another vym map, if needed load it first" ), QPixmap(flag_vymlink_xpm), tr( "Jump to map" ), 0, this, "jumpMap" );
  2.1014 -    connect( a, SIGNAL( activated() ), this, SLOT( editOpenVymLink() ) );
  2.1015 -    a->addTo( menu );
  2.1016 -    a->addTo( tb );
  2.1017 +    a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
  2.1018 +	a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
  2.1019 +    tb->addAction (a);
  2.1020  	a->setEnabled (false);
  2.1021 +    connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
  2.1022  	actionEditOpenVymLink=a;
  2.1023  	
  2.1024 -    a = new QAction( tr( "Edit link to another vym map" ), QPixmap(), tr( "Edit vym link" ), 0, this, "editLinkMap" );
  2.1025 -    connect( a, SIGNAL( activated() ), this, SLOT( editVymLink() ) );
  2.1026 -    a->addTo( menu );
  2.1027 +    a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
  2.1028 +	a->setStatusTip ( tr( "Open all vym links in subtree" ));
  2.1029  	a->setEnabled (false);
  2.1030 +	actionListBranches.append(a);
  2.1031 +    connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
  2.1032 +	actionEditOpenMultipleVymLinks=a;
  2.1033 +	
  2.1034 +
  2.1035 +    a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
  2.1036 +	a->setEnabled (false);
  2.1037 +	a->setStatusTip ( tr( "Edit link to another vym map" ));
  2.1038 +    connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
  2.1039 +	actionListBranches.append(a);
  2.1040  	actionEditVymLink=a;
  2.1041  
  2.1042 -    a = new QAction( tr( "Delete link to another vym map" ), QPixmap(), tr( "Delete vym link" ), 0, this, "deleteLinkMap" );
  2.1043 -    connect( a, SIGNAL( activated() ), this, SLOT( editDeleteVymLink() ) );
  2.1044 -    a->addTo( menu );
  2.1045 +    a = new QAction(tr( "Delete vym link","Edit menu" ),this);
  2.1046 +	a->setStatusTip ( tr( "Delete link to another vym map" ));
  2.1047  	a->setEnabled (false);
  2.1048 +    connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
  2.1049  	actionEditDeleteVymLink=a;
  2.1050  
  2.1051 -	menu->insertSeparator();
  2.1052 -
  2.1053 -    a = new QAction( tr( "Edit Map Info" ), QPixmap(), tr( "Edit Map Info" ), 0, this, "editMapInfo" );
  2.1054 -    connect( a, SIGNAL( activated() ), this, SLOT( editMapInfo() ) );
  2.1055 -    a->addTo( menu );
  2.1056 +    a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
  2.1057 +	a->setStatusTip ( tr( "Hide object in exports" ) );
  2.1058 +	a->setShortcut (Qt::Key_H );
  2.1059 +	a->setToggleAction(true);
  2.1060 +    tb->addAction (a);
  2.1061 +	a->setEnabled (false);
  2.1062 +    connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
  2.1063 +	actionEditToggleHideExport=a;
  2.1064 +
  2.1065 +    a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
  2.1066 +	a->setStatusTip ( tr( "Edit Map Info" ));
  2.1067  	a->setEnabled (true);
  2.1068 +    connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
  2.1069  	actionEditMapInfo=a;
  2.1070  
  2.1071 -	menu->insertSeparator();
  2.1072 -
  2.1073 -    // Shortcuts to modify heading:
  2.1074 -    a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Enter, this, "editHeading" );
  2.1075 -    connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
  2.1076 +	// Import at selection (adding to selection)
  2.1077 +    a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
  2.1078 +	a->setStatusTip (tr( "Add map at selection" ));
  2.1079 +    connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
  2.1080  	a->setEnabled (false);
  2.1081 -    a->addTo ( menu );
  2.1082 -	actionEditHeading=a;
  2.1083 -    a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Return, this, "editHeading" );
  2.1084 -    connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
  2.1085 -    //a->addTo ( menu );
  2.1086 -    
  2.1087 -    // Shortcut to delete selection
  2.1088 -    a = new QAction( tr( "Delete Selection" ),tr( "Delete Selection" ), Key_Delete, this, "deleteBranch" );
  2.1089 -    connect( a, SIGNAL( activated() ), this, SLOT( editDeleteSelection() ) );
  2.1090 +	actionListBranches.append(a);
  2.1091 +	actionEditImportAdd=a;
  2.1092 +
  2.1093 +	// Import at selection (replacing selection)
  2.1094 +    a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
  2.1095 +	a->setStatusTip (tr( "Replace selection with map" ));
  2.1096 +    connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
  2.1097  	a->setEnabled (false);
  2.1098 -    a->addTo ( menu );
  2.1099 -	actionEditDelete=a;
  2.1100 -    
  2.1101 -    // Shortcut to add branch
  2.1102 -	#if defined (Q_OS_MACX)
  2.1103 -		a = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), CTRL + Key_I, this, "newBranch" );
  2.1104 -	#else
  2.1105 -		a = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), Key_Insert, this, "newBranch" );
  2.1106 -	#endif
  2.1107 -    connect( a, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
  2.1108 +	actionListBranches.append(a);
  2.1109 +	actionEditImportReplace=a;
  2.1110 +
  2.1111 +	// Save selection 
  2.1112 +    a = new QAction( tr( "Save selection","Edit menu" ), this);
  2.1113 +	a->setStatusTip (tr( "Save selection" ));
  2.1114 +    connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
  2.1115  	a->setEnabled (false);
  2.1116 -    a->addTo ( menu );
  2.1117 -	actionEditAddBranch=a;
  2.1118 -
  2.1119 -	// Add branch above
  2.1120 -    a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_Insert, this, "newBranch" );
  2.1121 -    connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
  2.1122 +	actionListBranches.append(a);
  2.1123 +	actionEditSaveBranch=a;
  2.1124 +
  2.1125 +	// Only remove branch, not its childs
  2.1126 +    a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
  2.1127 +	a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
  2.1128 +	a->setShortcut (Qt::ALT + Qt::Key_Delete );
  2.1129 +    connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChilds() ) );
  2.1130  	a->setEnabled (false);
  2.1131 -    a->addTo ( menu );
  2.1132 -	actionEditAddBranchAbove=a;
  2.1133 -
  2.1134 -	// Add branch below 
  2.1135 -    a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_Insert, this, "newBranch" );
  2.1136 -    connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
  2.1137 +	addAction (a);
  2.1138 +	actionListBranches.append(a);
  2.1139 +	actionEditDeleteKeepChilds=a;
  2.1140 +
  2.1141 +	// Only remove childs of a branch
  2.1142 +    a = new QAction( tr( "Remove childs","Edit menu" ), this);
  2.1143 +	a->setStatusTip (tr( "Remove childs of branch" ));
  2.1144 +	a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
  2.1145 +    connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChilds() ) );
  2.1146  	a->setEnabled (false);
  2.1147 -    a->addTo ( menu );
  2.1148 -	actionEditAddBranchBelow=a;
  2.1149 -
  2.1150 -	// Import at selection (adding to selection)
  2.1151 -    a = new QAction( tr( "Add map at selection" ),tr( "Import (add)" ), 0, this, "importAdd" );
  2.1152 -    connect( a, SIGNAL( activated() ), this, SLOT( editImportAdd() ) );
  2.1153 +	actionListBranches.append(a);
  2.1154 +	actionEditDeleteChilds=a;
  2.1155 +
  2.1156 +    // Shortcuts for navigating with cursor:
  2.1157 +    a = new QAction(tr( "Select upper branch","Edit menu" ), this);
  2.1158 +	a->setStatusTip ( tr( "Select upper branch" ));
  2.1159 +	a->setShortcut (Qt::Key_Up );
  2.1160 +	a->setShortcutContext (Qt::WindowShortcut);
  2.1161 +	addAction (a);
  2.1162 +    connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
  2.1163 +    a = new QAction( tr( "Select lower branch","Edit menu" ),this);
  2.1164 +	a->setStatusTip (tr( "Select lower branch" ));
  2.1165 +	a->setShortcut ( Qt::Key_Down );
  2.1166 +	a->setShortcutContext (Qt::WindowShortcut);
  2.1167 +	addAction (a);
  2.1168 +    connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
  2.1169 +    a = new QAction(tr( "Select left branch","Edit menu" ), this);
  2.1170 +	a->setStatusTip ( tr( "Select left branch" ));
  2.1171 +	a->setShortcut (Qt::Key_Left );
  2.1172 +	a->setShortcutContext (Qt::WindowShortcut);
  2.1173 +	addAction (a);
  2.1174 +    connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
  2.1175 +    a = new QAction( tr( "Select child branch","Edit menu" ), this);
  2.1176 +	a->setStatusTip (tr( "Select right branch" ));
  2.1177 +	a->setShortcut (Qt::Key_Right);
  2.1178 +	a->setShortcutContext (Qt::WindowShortcut);
  2.1179 +	addAction (a);
  2.1180 +    connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
  2.1181 +    a = new QAction( tr( "Select first branch","Edit menu" ), this);
  2.1182 +	a->setStatusTip (tr( "Select first branch" ));
  2.1183 +	a->setShortcut (Qt::Key_Home );
  2.1184 +	a->setShortcutContext (Qt::WindowShortcut);
  2.1185 +	addAction (a);
  2.1186  	a->setEnabled (false);
  2.1187 -    a->addTo ( menu );
  2.1188 -	actionEditImportAdd=a;
  2.1189 -
  2.1190 -	// Import at selection (replacing selection)
  2.1191 -    a = new QAction( tr( "Replace selection with map" ),tr( "Import (replace)" ), 0, this, "importReplace" );
  2.1192 -    connect( a, SIGNAL( activated() ), this, SLOT( editImportReplace() ) );
  2.1193 +	editMenu->addAction (a);
  2.1194 +	actionListBranches.append(a);
  2.1195 +	actionEditSelectFirst=a;
  2.1196 +    connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
  2.1197 +    a = new QAction( tr( "Select last branch","Edit menu" ),this);
  2.1198 +	a->setStatusTip (tr( "Select last branch" ));
  2.1199 +	a->setShortcut ( Qt::Key_End );
  2.1200 +	a->setShortcutContext (Qt::WindowShortcut);
  2.1201 +	addAction (a);
  2.1202 +    connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
  2.1203  	a->setEnabled (false);
  2.1204 -    a->addTo ( menu );
  2.1205 -	actionEditImportReplace=a;
  2.1206 -
  2.1207 -	// Save selection 
  2.1208 -    a = new QAction( tr( "Save selction" ),tr( "Save selection" ), 0, this, "saveSelection" );
  2.1209 -    connect( a, SIGNAL( activated() ), this, SLOT( editSaveBranch() ) );
  2.1210 -	a->setEnabled (false);
  2.1211 -    a->addTo ( menu );
  2.1212 -	actionEditSaveBranch=a;
  2.1213 -
  2.1214 -    // Shortcuts for navigating with cursor:
  2.1215 -    a = new QAction( tr( "Select upper branch" ),tr( "Select upper branch" ), Key_Up, this, "upperBranch" );
  2.1216 -    connect( a, SIGNAL( activated() ), this, SLOT( editUpperBranch() ) );
  2.1217 -    a = new QAction( tr( "Select lower branch" ),tr( "Select lower branch" ), Key_Down, this, "lowerBranch" );
  2.1218 -    connect( a, SIGNAL( activated() ), this, SLOT( editLowerBranch() ) );
  2.1219 -    a = new QAction( tr( "Select left branch" ),tr( "Select left branch" ), Key_Left, this, "upperBranch" );
  2.1220 -    connect( a, SIGNAL( activated() ), this, SLOT( editLeftBranch() ) );
  2.1221 -    a = new QAction( tr( "Select right branch" ),tr( "Select child branch" ), Key_Right, this, "rightBranch" );
  2.1222 -    connect( a, SIGNAL( activated() ), this, SLOT( editRightBranch() ) );
  2.1223 -    a = new QAction( tr( "Select first branch" ),tr( "Select first branch" ), Key_Home, this, "firstBranch" );
  2.1224 -	a->setEnabled (false);
  2.1225 -    a->addTo ( menu );
  2.1226 -	actionEditSelectFirst=a;
  2.1227 -    connect( a, SIGNAL( activated() ), this, SLOT( editFirstBranch() ) );
  2.1228 -    a = new QAction( tr( "Select last branch" ),tr( "Select last branch" ), Key_End, this, "lastBranch" );
  2.1229 -    connect( a, SIGNAL( activated() ), this, SLOT( editLastBranch() ) );
  2.1230 -	a->setEnabled (false);
  2.1231 -    a->addTo ( menu );
  2.1232 +	editMenu->addAction (a);
  2.1233 +	actionListBranches.append(a);
  2.1234  	actionEditSelectLast=a;
  2.1235  
  2.1236 -    a = new QAction( tr( "Add Image" ),tr( "Add Image" ), 0, this, "loadImage" );
  2.1237 -    connect( a, SIGNAL( activated() ), this, SLOT( editLoadImage() ) );
  2.1238 +    a = new QAction( tr( "Add Image...","Edit menu" ), this);
  2.1239 +	a->setStatusTip (tr( "Add Image" ));
  2.1240 +    connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
  2.1241  	actionEditLoadImage=a;
  2.1242 +
  2.1243 +    a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
  2.1244 +	a->setStatusTip (tr( "Set properties for selection" ));
  2.1245 +	a->setShortcut ( Qt::CTRL + Qt::Key_I );		//Property window
  2.1246 +	a->setShortcutContext (Qt::WindowShortcut);
  2.1247 +	a->setToggleAction (true);
  2.1248 +	addAction (a);
  2.1249 +    connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
  2.1250 +	actionViewTogglePropertyWindow=a;
  2.1251  }
  2.1252  
  2.1253  // Format Actions
  2.1254  void Main::setupFormatActions()
  2.1255  {
  2.1256 -    QPopupMenu *menu = new QPopupMenu( this );
  2.1257 -    menuBar()->insertItem( tr( "&Format" ), menu );
  2.1258 -
  2.1259 -    QToolBar *tb = new QToolBar( this );
  2.1260 +    QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
  2.1261 +
  2.1262 +    QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
  2.1263 +	tb->setObjectName ("formatTB");
  2.1264      QAction *a;
  2.1265      QPixmap pix( 16,16);
  2.1266 -    pix.fill (black);
  2.1267 -    actionFormatColor= new QAction( tr( "Set Color" ), pix, tr( "Set &Color" ), 0, this, "formatColor" );
  2.1268 -    connect( actionFormatColor, SIGNAL( activated() ), this, SLOT( formatSelectColor() ) );
  2.1269 -    actionFormatColor->addTo( tb );
  2.1270 -    actionFormatColor->addTo( menu );
  2.1271 -    a= new QAction( tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ), QPixmap(formatcolorpicker_xpm), tr( "Pic&k color" ), CTRL + Key_K, this, "pickColor" );
  2.1272 -    connect( a, SIGNAL( activated() ), this, SLOT( formatPickColor() ) );
  2.1273 +    pix.fill (Qt::black);
  2.1274 +    a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
  2.1275 +	a->setStatusTip ( tr( "Set Color" ));
  2.1276 +    connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
  2.1277 +    a->addTo( tb );
  2.1278 +	formatMenu->addAction (a);
  2.1279 +	actionFormatColor=a;
  2.1280 +    a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
  2.1281 +	a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
  2.1282 +	a->setShortcut (Qt::CTRL + Qt::Key_K );
  2.1283 +    connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
  2.1284  	a->setEnabled (false);
  2.1285      a->addTo( tb );
  2.1286 -    a->addTo( menu );
  2.1287 +	formatMenu->addAction (a);
  2.1288 +	actionListBranches.append(a);
  2.1289  	actionFormatPickColor=a;
  2.1290 -    a= new QAction( tr( "Color branch" ), QPixmap(formatcoloritem_xpm), tr( "Color &branch" ), CTRL + Key_I, this, "colorItem" );
  2.1291 -    connect( a, SIGNAL( activated() ), this, SLOT( formatColorItem() ) );
  2.1292 +
  2.1293 +    a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
  2.1294 +	a->setStatusTip ( tr( "Color branch" ) );
  2.1295 +	a->setShortcut (Qt::CTRL + Qt::Key_B);
  2.1296 +    connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
  2.1297  	a->setEnabled (false);
  2.1298      a->addTo( tb );
  2.1299 -    a->addTo( menu );
  2.1300 -	actionFormatColorBranch=a;
  2.1301 -    a= new QAction( tr( "Color Subtree" ), QPixmap(formatcolorbranch_xpm), tr( "Color sub&tree" ), CTRL + Key_T, this, "colorBranch" );
  2.1302 -    connect( a, SIGNAL( activated() ), this, SLOT( formatColorBranch() ) );
  2.1303 +	formatMenu->addAction (a);
  2.1304 +	actionListBranches.append(a);
  2.1305 +	actionFormatColorSubtree=a;
  2.1306 +
  2.1307 +    a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
  2.1308 +	a->setStatusTip ( tr( "Color Subtree" ));
  2.1309 +	a->setShortcut (Qt::CTRL + Qt::Key_T);
  2.1310 +    connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
  2.1311  	a->setEnabled (false);
  2.1312 -    a->addTo( menu );
  2.1313 +	formatMenu->addAction (a);
  2.1314      a->addTo( tb );
  2.1315 +	actionListBranches.append(a);
  2.1316  	actionFormatColorSubtree=a;
  2.1317  
  2.1318 -    menu->insertSeparator();
  2.1319 -	actionGroupFormatLinkStyles=new QActionGroup ( this, "formatLinkStyles");
  2.1320 +	formatMenu->addSeparator();
  2.1321 +	actionGroupFormatLinkStyles=new QActionGroup ( this);
  2.1322  	actionGroupFormatLinkStyles->setExclusive (true);
  2.1323 -    a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
  2.1324 +    a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
  2.1325 +	a->setStatusTip (tr( "Line" ));
  2.1326  	a->setToggleAction(true);
  2.1327 -    connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleLine() ) );
  2.1328 +    connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
  2.1329 +	formatMenu->addAction (a);
  2.1330  	actionFormatLinkStyleLine=a;
  2.1331 -    a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
  2.1332 +    a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
  2.1333 +	a->setStatusTip (tr( "Line" ));
  2.1334  	a->setToggleAction(true);
  2.1335 -    connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleParabel() ) );
  2.1336 +    connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
  2.1337 +	formatMenu->addAction (a);
  2.1338  	actionFormatLinkStyleParabel=a;
  2.1339 -    a= new QAction( tr( "PolyLine" ), QPixmap(), tr( "Linkstyle Thick Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
  2.1340 +    a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
  2.1341 +	a->setStatusTip (tr( "PolyLine" ));
  2.1342  	a->setToggleAction(true);
  2.1343 -    connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyLine() ) );
  2.1344 +    connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
  2.1345 +	formatMenu->addAction (a);
  2.1346  	actionFormatLinkStylePolyLine=a;
  2.1347 -    a= new QAction( tr( "PolyParabel" ), QPixmap(), tr( "Linkstyle Thick Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStylePolyParabel" );
  2.1348 +    a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
  2.1349 +	a->setStatusTip (tr( "PolyParabel" ) );
  2.1350  	a->setToggleAction(true);
  2.1351 -    connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyParabel() ) );
  2.1352 +	a->setChecked (true);
  2.1353 +    connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
  2.1354 +	formatMenu->addAction (a);
  2.1355  	actionFormatLinkStylePolyParabel=a;
  2.1356 -	actionGroupFormatLinkStyles->addTo (menu);
  2.1357  	
  2.1358 -	actionGroupFormatFrameTypes=new QActionGroup ( this, "formatFrameTypes");
  2.1359 -	actionGroupFormatFrameTypes->setExclusive (true);
  2.1360 -    a = new QAction( tr( "No Frame" ),tr( "No Frame" ), 0, actionGroupFormatFrameTypes, "frameNone" );
  2.1361 +    a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
  2.1362 +	a->setStatusTip (tr( "Hide link" ));
  2.1363  	a->setToggleAction(true);
  2.1364 -    connect( a, SIGNAL( activated() ), this, SLOT( formatFrameNone() ) );
  2.1365 -	actionFormatFrameNone=a;
  2.1366 -    a = new QAction( tr( "Rectangle" ),tr( "Rectangle" ), 0, actionGroupFormatFrameTypes, "frameRectangle" );
  2.1367 +    connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
  2.1368 +	actionFormatHideLinkUnselected=a;
  2.1369 +
  2.1370 +	formatMenu->addSeparator();
  2.1371 +    a= new QAction( tr( "&Use color of heading for link","Branch attribute" ),  this);
  2.1372 +	a->setStatusTip (tr( "Use same color for links and headings" ));
  2.1373  	a->setToggleAction(true);
  2.1374 -    connect( a, SIGNAL( activated() ), this, SLOT( formatFrameRectangle() ) );
  2.1375 -	actionFormatFrameRectangle=a;
  2.1376 -
  2.1377 -    menu->insertSeparator();
  2.1378 -    a= new QAction( tr( "Use same color for links and headings" ), QPixmap(), tr( "&Use color of heading for link" ), 0, this, "formatLinkColorHint" );
  2.1379 -	a->setToggleAction(true);
  2.1380 -    connect( a, SIGNAL( activated() ), this, SLOT( formatToggleLinkColorHint() ) );
  2.1381 -	a->addTo( menu );
  2.1382 +    connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
  2.1383 +	formatMenu->addAction (a);
  2.1384  	actionFormatLinkColorHint=a;
  2.1385 -    pix.fill (white);
  2.1386 -    actionFormatLinkColor= new QAction( tr( "Set Link Color" ), pix, tr( "Set &Link Color" ), 0, this, "formatLinkColor" );
  2.1387 -    connect( actionFormatLinkColor, SIGNAL( activated() ), this, SLOT( formatSelectLinkColor() ) );
  2.1388 -    actionFormatLinkColor->addTo( menu );
  2.1389 -    actionFormatBackColor= new QAction( tr( "Set Background Color" ), pix, tr( "Set &Background Color" ), 0, this, "formatBackColor" );
  2.1390 -    connect( actionFormatBackColor, SIGNAL( activated() ), this, SLOT( formatSelectBackColor() ) );
  2.1391 -    actionFormatBackColor->addTo( menu );
  2.1392 +
  2.1393 +    pix.fill (Qt::white);
  2.1394 +    a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this  );
  2.1395 +	a->setStatusTip (tr( "Set Link Color" ));
  2.1396 +	formatMenu->addAction (a);
  2.1397 +    connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
  2.1398 +    actionFormatLinkColor=a;
  2.1399 +
  2.1400 +    a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this  );
  2.1401 +	a->setStatusTip (tr( "Set Selection Color" ));
  2.1402 +	formatMenu->addAction (a);
  2.1403 +    connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
  2.1404 +    actionFormatSelectionColor=a;
  2.1405 +
  2.1406 +    a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
  2.1407 +	a->setStatusTip (tr( "Set Background Color" ));
  2.1408 +	formatMenu->addAction (a);
  2.1409 +    connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
  2.1410 +    actionFormatBackColor=a;
  2.1411 +
  2.1412 +    a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
  2.1413 +	a->setStatusTip (tr( "Set Background image" ));
  2.1414 +	formatMenu->addAction (a);
  2.1415 +    connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
  2.1416 +    actionFormatBackImage=a;
  2.1417  }
  2.1418  
  2.1419  // View Actions
  2.1420  void Main::setupViewActions()
  2.1421  {
  2.1422 -    QToolBar *tb = new QToolBar( this );
  2.1423 +    QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
  2.1424      tb->setLabel( "View Actions" );
  2.1425 -    QPopupMenu *menu = new QPopupMenu( this );
  2.1426 -    menuBar()->insertItem( tr( "&View" ), menu );
  2.1427 +	tb->setObjectName ("viewTB");
  2.1428 +    QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
  2.1429  
  2.1430      QAction *a;
  2.1431 -    a = new QAction( tr( "Zoom reset" ), QPixmap(viewzoomreset_xpm), tr( "reset Zoom" ), 0, this, "zoomReset" );
  2.1432 -    connect( a, SIGNAL( activated() ), this, SLOT(viewZoomReset() ) );
  2.1433 +    a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
  2.1434 +	a->setStatusTip ( tr( "Zoom reset" ) );
  2.1435 +	a->setShortcut (Qt::CTRL + Qt::Key_0 );
  2.1436      a->addTo( tb );
  2.1437 -    a->addTo( menu );
  2.1438 -    a = new QAction( tr( "Zoom in" ), QPixmap(viewzoomin_xpm), tr( "Zoom in" ), CTRL + Key_Plus, this, "zoomIn" );
  2.1439 -    connect( a, SIGNAL( activated() ), this, SLOT(viewZoomIn() ) );
  2.1440 +	viewMenu->addAction (a);
  2.1441 +    connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
  2.1442 +	
  2.1443 +    a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
  2.1444 +	a->setStatusTip (tr( "Zoom in" ));
  2.1445 +	a->setShortcut (Qt::CTRL + Qt::Key_Plus);
  2.1446      a->addTo( tb );
  2.1447 -    a->addTo( menu );
  2.1448 -    a = new QAction( tr( "Zoom out" ), QPixmap(viewzoomout_xpm), tr( "Zoom out" ), CTRL + Key_Minus, this, "zoomOut" );
  2.1449 -    connect( a, SIGNAL( activated() ), this, SLOT( viewZoomOut() ) );
  2.1450 +	viewMenu->addAction (a);
  2.1451 +    connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
  2.1452 +	
  2.1453 +    a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
  2.1454 +	a->setStatusTip (tr( "Zoom out" ));
  2.1455 +	a->setShortcut (Qt::CTRL + Qt::Key_Minus );
  2.1456      a->addTo( tb );
  2.1457 -    a->addTo( menu );
  2.1458 -    a = new QAction( tr( "Toggle Note Editor" ), QPixmap(flag_note_xpm), tr( "Toggle Note Editor" ), CTRL + Key_E , this, "noteEditor" );
  2.1459 -    connect( a, SIGNAL( activated() ), this, SLOT(windowToggleNoteEditor() ) );
  2.1460 +	viewMenu->addAction (a);
  2.1461 +    connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
  2.1462 +
  2.1463 +    a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
  2.1464 +	a->setStatusTip (tr( "Show selection" ));
  2.1465 +	a->setShortcut (Qt::Key_Period);
  2.1466 +    a->addTo( tb );
  2.1467 +	viewMenu->addAction (a);
  2.1468 +    connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
  2.1469 +
  2.1470 +	viewMenu->addSeparator();	
  2.1471 +
  2.1472 +    a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
  2.1473 +	a->setStatusTip ( tr( "Show Note Editor" ));
  2.1474 +	a->setShortcut ( Qt::CTRL + Qt::Key_E );
  2.1475  	a->setToggleAction(true);
  2.1476 -	if (textEditor->showWithMain())
  2.1477 -		a->setOn(true);
  2.1478 -	else	
  2.1479 -		a->setOn(false);
  2.1480      a->addTo( tb );
  2.1481 -    a->addTo( menu );
  2.1482 +	viewMenu->addAction (a);
  2.1483 +    connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
  2.1484  	actionViewToggleNoteEditor=a;
  2.1485 -    a = new QAction( tr( "&Next Window" ), QPixmap(), tr( "Next Window" ), ALT + Key_N , this, "nextWindow" );
  2.1486 -    connect( a, SIGNAL( activated() ), this, SLOT(windowNextEditor() ) );
  2.1487 -    a->addTo( menu );
  2.1488 -    a = new QAction( tr( "&Previous Window" ), QPixmap(), tr( "Previous Window" ), ALT + Key_P , this, "previousWindow" );
  2.1489 -    connect( a, SIGNAL( activated() ), this, SLOT(windowPreviousEditor() ) );
  2.1490 -    a->addTo( menu );
  2.1491 +
  2.1492 +    a = new QAction(QPixmap(iconPath+"history.png"),  tr( "History Window","View action" ),this );
  2.1493 +	a->setStatusTip ( tr( "Show History Window" ));
  2.1494 +	a->setShortcut ( Qt::CTRL + Qt::Key_H  );
  2.1495 +	a->setToggleAction(true);
  2.1496 +    a->addTo( tb );
  2.1497 +	viewMenu->addAction (a);
  2.1498 +    connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
  2.1499 +	actionViewToggleHistoryWindow=a;
  2.1500 +
  2.1501 +	viewMenu->addAction (actionViewTogglePropertyWindow);
  2.1502 +
  2.1503 +	viewMenu->addSeparator();	
  2.1504 +
  2.1505 +    a = new QAction(tr( "Antialiasing","View action" ),this );
  2.1506 +	a->setStatusTip ( tr( "Antialiasing" ));
  2.1507 +	a->setToggleAction(true);
  2.1508 +	a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
  2.1509 +	viewMenu->addAction (a);
  2.1510 +    connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
  2.1511 +	actionViewToggleAntiAlias=a;
  2.1512 +
  2.1513 +    a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
  2.1514 +	a->setStatusTip (a->text());
  2.1515 +	a->setToggleAction(true);
  2.1516 +	a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
  2.1517 +	viewMenu->addAction (a);
  2.1518 +    connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
  2.1519 +	actionViewToggleSmoothPixmapTransform=a;
  2.1520 +
  2.1521 +    a = new QAction(tr( "Next Map","View action" ), this);
  2.1522 +	a->setStatusTip (a->text());
  2.1523 +	a->setShortcut (Qt::ALT + Qt::Key_N );
  2.1524 +	viewMenu->addAction (a);
  2.1525 +    connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
  2.1526 +
  2.1527 +    a = new QAction (tr( "Previous Map","View action" ), this );
  2.1528 +	a->setStatusTip (a->text());
  2.1529 +	a->setShortcut (Qt::ALT + Qt::Key_P );
  2.1530 +	viewMenu->addAction (a);
  2.1531 +    connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
  2.1532 +}
  2.1533 +
  2.1534 +// Mode Actions
  2.1535 +void Main::setupModeActions()
  2.1536 +{
  2.1537 +    //QPopupMenu *menu = new QPopupMenu( this );
  2.1538 +    //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
  2.1539 +
  2.1540 +    QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
  2.1541 +	tb->setObjectName ("modesTB");
  2.1542 +    QAction *a;
  2.1543 +	actionGroupModModes=new QActionGroup ( this);
  2.1544 +	actionGroupModModes->setExclusive (true);
  2.1545 +    a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
  2.1546 +	a->setShortcut (Qt::Key_J);
  2.1547 +    a->setStatusTip ( tr( "Use modifier to color branches" ));
  2.1548 +	a->setToggleAction(true);
  2.1549 +	a->addTo (tb);
  2.1550 +	a->setOn(true);
  2.1551 +	actionModModeColor=a;
  2.1552 +	
  2.1553 +    a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
  2.1554 +	a->setShortcut( Qt::Key_K); 
  2.1555 +    a->setStatusTip( tr( "Use modifier to copy" ));
  2.1556 +	a->setToggleAction(true);
  2.1557 +	a->addTo (tb);
  2.1558 +	actionModModeCopy=a;
  2.1559 +
  2.1560 +    a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
  2.1561 +	a->setShortcut (Qt::Key_L);
  2.1562 +    a->setStatusTip( tr( "Use modifier to draw xLinks" ));
  2.1563 +	a->setToggleAction(true);
  2.1564 +	a->addTo (tb);
  2.1565 +	actionModModeXLink=a;
  2.1566  }
  2.1567  
  2.1568  // Flag Actions
  2.1569  void Main::setupFlagActions()
  2.1570  {
  2.1571 -	standardFlagsDefault->makeToolbar(this, "Standard Flags");
  2.1572 +	// Create System Flags
  2.1573 +	QToolBar *tb=NULL;
  2.1574 +	bool avis=true;
  2.1575 +
  2.1576 +	systemFlagsDefault = new FlagRowObj ();
  2.1577 +	systemFlagsDefault->setVisibility (false);
  2.1578 +	systemFlagsDefault->setName ("systemFlagsDef");
  2.1579 +
  2.1580 +	FlagObj *fo = new FlagObj ();
  2.1581 +	fo->load(QPixmap(flagsPath+"flag-note.png"));
  2.1582 +	setupFlag (fo,tb,avis,"note",tr("Note","SystemFlag"));
  2.1583 +
  2.1584 +	fo->load(QPixmap(flagsPath+"flag-url.png"));
  2.1585 +	setupFlag (fo,tb,avis,"url",tr("URL to Document ","SystemFlag"));
  2.1586 +	
  2.1587 +	fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
  2.1588 +	setupFlag (fo,tb,avis,"vymLink",tr("Link to another vym map","SystemFlag"));
  2.1589 +
  2.1590 +	fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
  2.1591 +	setupFlag (fo,tb,avis,"scrolledright",tr("subtree is scrolled","SystemFlag"));
  2.1592 +	
  2.1593 +	fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
  2.1594 +	setupFlag (fo,tb,avis,"tmpUnscrolledright",tr("subtree is temporary scrolled","SystemFlag"));
  2.1595 +
  2.1596 +	fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
  2.1597 +	setupFlag (fo,tb,avis,"hideInExport",tr("Hide object in exported maps","SystemFlag"));
  2.1598 +
  2.1599 +	// Create Standard Flags
  2.1600 +	tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
  2.1601 +	tb->setObjectName ("standardFlagTB");
  2.1602 +
  2.1603 +	standardFlagsDefault = new FlagRowObj ();
  2.1604 +	standardFlagsDefault->setVisibility (false);
  2.1605 +	standardFlagsDefault->setName ("standardFlagsDef");
  2.1606 +	standardFlagsDefault->setToolBar (tb);
  2.1607 +
  2.1608 +	fo->load(flagsPath+"flag-exclamationmark.png");
  2.1609 +	fo->setGroup("standard-mark");
  2.1610 +	setupFlag (fo,tb,avis,"exclamationmark",tr("Take care!","Standardflag"));
  2.1611 +	
  2.1612 +	fo->load(flagsPath+"flag-questionmark.png");
  2.1613 +	fo->setGroup("standard-mark");
  2.1614 +	setupFlag (fo,tb,avis,"questionmark",tr("Really?","Standardflag"));
  2.1615 +
  2.1616 +	fo->load(flagsPath+"flag-hook-green.png");
  2.1617 +	fo->setGroup("standard-hook");
  2.1618 +	setupFlag (fo,tb,avis,"hook-green",tr("ok!","Standardflag"));
  2.1619 +
  2.1620 +	fo->load(flagsPath+"flag-cross-red.png");
  2.1621 +	fo->setGroup("standard-hook");
  2.1622 +	setupFlag (fo,tb,avis,"cross-red",tr("Not ok!","Standardflag"));
  2.1623 +	fo->unsetGroup();
  2.1624 +
  2.1625 +	fo->load(flagsPath+"flag-stopsign.png");
  2.1626 +	setupFlag (fo,tb,avis,"stopsign",tr("This won't work!","Standardflag"));
  2.1627 +
  2.1628 +	fo->load(flagsPath+"flag-smiley-good.png");
  2.1629 +	fo->setGroup("standard-smiley");
  2.1630 +	setupFlag (fo,tb,avis,"smiley-good",tr("Good","Standardflag"));
  2.1631 +
  2.1632 +	fo->load(flagsPath+"flag-smiley-sad.png");
  2.1633 +	fo->setGroup("standard-smiley");
  2.1634 +	setupFlag (fo,tb,avis,"smiley-sad",tr("Bad","Standardflag"));
  2.1635 +
  2.1636 +	fo->load(flagsPath+"flag-smiley-omg.png");
  2.1637 +	fo->setGroup("standard-smiley");
  2.1638 +	setupFlag (fo,tb,avis,"smiley-omb",tr("Oh no!","Standardflag"));
  2.1639 +	// Original omg.png (in KDE emoticons)
  2.1640 +	fo->unsetGroup();
  2.1641 +
  2.1642 +	fo->load(flagsPath+"flag-kalarm.png");
  2.1643 +	setupFlag (fo,tb,avis,"clock",tr("Time critical","Standardflag"));
  2.1644 +
  2.1645 +	fo->load(flagsPath+"flag-phone.png");
  2.1646 +	setupFlag (fo,tb,avis,"phone",tr("Call...","Standardflag"));
  2.1647 +
  2.1648 +	fo->load(flagsPath+"flag-lamp.png");
  2.1649 +	setupFlag (fo,tb,avis,"lamp",tr("Idea!","Standardflag"));
  2.1650 +
  2.1651 +	fo->load(flagsPath+"flag-arrow-up.png");
  2.1652 +	fo->setGroup("standard-arrow");
  2.1653 +	setupFlag (fo,tb,avis,"arrow-up",tr("Important","Standardflag"));
  2.1654 +
  2.1655 +	fo->load(flagsPath+"flag-arrow-down.png");
  2.1656 +	fo->setGroup("standard-arrow");
  2.1657 +	setupFlag (fo,tb,avis,"arrow-down",tr("Unimportant","Standardflag"));
  2.1658 +
  2.1659 +	fo->load(flagsPath+"flag-arrow-2up.png");
  2.1660 +	fo->setGroup("standard-arrow");
  2.1661 +	setupFlag (fo,tb,avis,"2arrow-up",tr("Very important!","Standardflag"));
  2.1662 +
  2.1663 +	fo->load(flagsPath+"flag-arrow-2down.png");
  2.1664 +	fo->setGroup("standard-arrow");
  2.1665 +	setupFlag (fo,tb,avis,"2arrow-down",tr("Very unimportant!","Standardflag"));
  2.1666 +	fo->unsetGroup();
  2.1667 +
  2.1668 +	fo->load(flagsPath+"flag-thumb-up.png");
  2.1669 +	fo->setGroup("standard-thumb");
  2.1670 +	setupFlag (fo,tb,avis,"thumb-up",tr("I like this","Standardflag"));
  2.1671 +
  2.1672 +	fo->load(flagsPath+"flag-thumb-down.png");
  2.1673 +	fo->setGroup("standard-thumb");
  2.1674 +	setupFlag (fo,tb,avis,"thumb-down",tr("I do not like this","Standardflag"));
  2.1675 +	fo->unsetGroup();
  2.1676 +	
  2.1677 +	fo->load(flagsPath+"flag-rose.png");
  2.1678 +	setupFlag (fo,tb,avis,"rose",tr("Rose","Standardflag"));
  2.1679 +
  2.1680 +	fo->load(flagsPath+"flag-heart.png");
  2.1681 +	setupFlag (fo,tb,avis,"heart",tr("I just love...","Standardflag"));
  2.1682 +
  2.1683 +	fo->load(flagsPath+"flag-present.png");
  2.1684 +	setupFlag (fo,tb,avis,"present",tr("Surprise!","Standardflag"));
  2.1685 +
  2.1686 +	fo->load(flagsPath+"flag-flash.png");
  2.1687 +	setupFlag (fo,tb,avis,"flash",tr("Dangerous","Standardflag"));
  2.1688 +	
  2.1689 +	// Original: xsldbg_output.png
  2.1690 +	fo->load(flagsPath+"flag-info.png");
  2.1691 +	setupFlag (fo,tb,avis,"info",tr("Info","Standardflag"));
  2.1692 +
  2.1693 +	// Original khelpcenter.png
  2.1694 +	fo->load(flagsPath+"flag-lifebelt.png");
  2.1695 +	setupFlag (fo,tb,avis,"lifebelt",tr("This will help","Standardflag"));
  2.1696 +
  2.1697 +	// Freemind flags
  2.1698 +
  2.1699 +	avis=false;
  2.1700 +
  2.1701 +	fo->load(flagsPath+"freemind/warning.png");
  2.1702 +	setupFlag (fo,tb, avis, "freemind-warning",tr("Important","Freemind-Flag"));
  2.1703 +
  2.1704 +	for (int i=1; i<8; i++)
  2.1705 +	{
  2.1706 +		fo->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
  2.1707 +		setupFlag (fo,tb, avis,QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
  2.1708 +	}
  2.1709 +
  2.1710 +	fo->load(flagsPath+"freemind/back.png");
  2.1711 +	setupFlag (fo,tb,avis,"freemind-back",tr("Back","Freemind-Flag"));
  2.1712 +
  2.1713 +	fo->load(flagsPath+"freemind/forward.png");
  2.1714 +	setupFlag (fo,tb,avis,"freemind-forward",tr("Forward","Freemind-Flag"));
  2.1715 +
  2.1716 +	fo->load(flagsPath+"freemind/attach.png");
  2.1717 +	setupFlag (fo,tb,avis,"freemind-attach",tr("Look here","Freemind-Flag"));
  2.1718 +
  2.1719 +	fo->load(flagsPath+"freemind/clanbomber.png");
  2.1720 +	setupFlag (fo,tb,avis,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
  2.1721 +
  2.1722 +	fo->load(flagsPath+"freemind/desktopnew.png");
  2.1723 +	setupFlag (fo,tb,avis,"freemind-desktopnew",tr("Don't forget","Freemind-Flag"));
  2.1724 +
  2.1725 +	fo->load(flagsPath+"freemind/flag.png");
  2.1726 +	setupFlag (fo,tb,avis,"freemind-flag",tr("Flag","Freemind-Flag"));
  2.1727 +
  2.1728 +
  2.1729 +	fo->load(flagsPath+"freemind/gohome.png");
  2.1730 +	setupFlag (fo,tb,avis,"freemind-gohome",tr("Home","Freemind-Flag"));
  2.1731 +
  2.1732 +
  2.1733 +	fo->load(flagsPath+"freemind/kaddressbook.png");
  2.1734 +	setupFlag (fo,tb,avis,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
  2.1735 +
  2.1736 +	fo->load(flagsPath+"freemind/knotify.png");
  2.1737 +	setupFlag (fo,tb,avis,"freemind-knotify",tr("Music","Freemind-Flag"));
  2.1738 +
  2.1739 +	fo->load(flagsPath+"freemind/korn.png");
  2.1740 +	setupFlag (fo,tb,avis,"freemind-korn",tr("Mailbox","Freemind-Flag"));
  2.1741 +
  2.1742 +	fo->load(flagsPath+"freemind/mail.png");
  2.1743 +	setupFlag (fo,tb,avis,"freemind-mail",tr("Maix","Freemind-Flag"));
  2.1744 +
  2.1745 +	fo->load(flagsPath+"freemind/password.png");
  2.1746 +	setupFlag (fo,tb,avis,"freemind-password",tr("Password","Freemind-Flag"));
  2.1747 +
  2.1748 +	fo->load(flagsPath+"freemind/pencil.png");
  2.1749 +	setupFlag (fo,tb,avis,"freemind-pencil",tr("To be improved","Freemind-Flag"));
  2.1750 +
  2.1751 +	fo->load(flagsPath+"freemind/stop.png");
  2.1752 +	setupFlag (fo,tb,avis,"freemind-stop",tr("Stop","Freemind-Flag"));
  2.1753 +
  2.1754 +	fo->load(flagsPath+"freemind/wizard.png");
  2.1755 +	setupFlag (fo,tb,avis,"freemind-wizard",tr("Magic","Freemind-Flag"));
  2.1756 +
  2.1757 +	fo->load(flagsPath+"freemind/xmag.png");
  2.1758 +	setupFlag (fo,tb,avis,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
  2.1759 +
  2.1760 +	fo->load(flagsPath+"freemind/bell.png");
  2.1761 +	setupFlag (fo,tb,avis,"freemind-bell",tr("Reminder","Freemind-Flag"));
  2.1762 +
  2.1763 +	fo->load(flagsPath+"freemind/bookmark.png");
  2.1764 +	setupFlag (fo,tb,avis,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
  2.1765 +
  2.1766 +	fo->load(flagsPath+"freemind/penguin.png");
  2.1767 +	setupFlag (fo,tb,avis,"freemind-penguin",tr("Linux","Freemind-Flag"));
  2.1768 +
  2.1769 +	fo->load(flagsPath+"freemind/licq.png");
  2.1770 +	setupFlag (fo,tb,avis,"freemind-licq",tr("Sweet","Freemind-Flag"));
  2.1771 +
  2.1772 +	delete (fo);
  2.1773  }
  2.1774  
  2.1775 +void Main::setupFlag (FlagObj *fo, QToolBar *tb, bool aw, const QString &name, const QString &tooltip)
  2.1776 +{
  2.1777 +	fo->setName(name);
  2.1778 +	fo->setToolTip (tooltip);
  2.1779 +	QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
  2.1780 +	if (tb)
  2.1781 +	{
  2.1782 +		// StandardFlag
  2.1783 +		tb->addAction (a);
  2.1784 +		fo->setAction (a);
  2.1785 +		fo->setAlwaysVisible(aw);
  2.1786 +		a->setCheckable(true);
  2.1787 +		a->setObjectName(fo->getName());
  2.1788 +		a->setToolTip(tooltip);
  2.1789 +		connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
  2.1790 +		standardFlagsDefault->addFlag (fo);	
  2.1791 +	} else
  2.1792 +	{
  2.1793 +		// SystemFlag
  2.1794 +		systemFlagsDefault->addFlag (fo);	
  2.1795 +	}
  2.1796 +}
  2.1797 +// Network Actions
  2.1798 +void Main::setupNetworkActions()
  2.1799 +{
  2.1800 +	if (!settings.value( "/mainwindow/showTestMenu",false).toBool() ) 
  2.1801 +		return;
  2.1802 +    QMenu *netMenu = menuBar()->addMenu(  "Network" );
  2.1803 +
  2.1804 +	QAction *a;
  2.1805 +
  2.1806 +    a = new QAction(  "Start TCPserver for MapEditor",this);
  2.1807 +    //a->setStatusTip ( "Set application to open pdf files"));
  2.1808 +	a->setShortcut ( Qt::Key_T );		//New TCP server
  2.1809 +    connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
  2.1810 +	netMenu->addAction (a);
  2.1811 +
  2.1812 +    a = new QAction(  "Connect MapEditor to server",this);
  2.1813 +    //a->setStatusTip ( "Set application to open pdf files"));
  2.1814 +	a->setShortcut ( Qt::Key_C );		// Connect to server
  2.1815 +    connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
  2.1816 +	netMenu->addAction (a);
  2.1817 +}
  2.1818 +	
  2.1819  // Settings Actions
  2.1820  void Main::setupSettingsActions()
  2.1821  {
  2.1822 -    QPopupMenu *menu = new QPopupMenu( this );
  2.1823 -    menuBar()->insertItem( tr( "&Settings" ), menu );
  2.1824 +    QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
  2.1825  
  2.1826  	QAction *a;
  2.1827  
  2.1828 -
  2.1829 -    a = new QAction( tr( "Set application to open pdf files" ), QPixmap(), tr( "Set application to open pdf files" ), 0, this, "setPDF" );
  2.1830 -    connect( a, SIGNAL( activated() ), this, SLOT( settingsPDF() ) );
  2.1831 -    a->addTo( menu );
  2.1832 -
  2.1833 -    a = new QAction( tr( "Set application to open an URL" ), QPixmap(), tr( "Set application to open an URL" ), 0, this, "setURL" );
  2.1834 -    connect( a, SIGNAL( activated() ), this, SLOT( settingsURL() ) );
  2.1835 -    a->addTo( menu );
  2.1836 -
  2.1837 -    menu->insertSeparator();
  2.1838 -    a = new QAction( tr( "Edit branch after adding it" ), QPixmap(), tr( "Edit branch after adding it" ), 0, this, "autoedit" );
  2.1839 +    a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
  2.1840 +    a->setStatusTip ( tr( "Set application to open pdf files"));
  2.1841 +    connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
  2.1842 +	settingsMenu->addAction (a);
  2.1843 +
  2.1844 +    a = new QAction( tr( "Set application to open external links","Settings action"), this);
  2.1845 +    a->setStatusTip( tr( "Set application to open external links"));
  2.1846 +    connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
  2.1847 +	settingsMenu->addAction (a);
  2.1848 +
  2.1849 +    a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
  2.1850 +    a->setStatusTip( tr( "Set path for macros"));
  2.1851 +    connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
  2.1852 +	settingsMenu->addAction (a);
  2.1853 +
  2.1854 +    a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
  2.1855 +    a->setStatusTip( tr( "Set number of undo levels"));
  2.1856 +    connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
  2.1857 +	settingsMenu->addAction (a);
  2.1858 +
  2.1859 +	settingsMenu->addSeparator();
  2.1860 +
  2.1861 +    a = new QAction( tr( "Autosave","Settings action"), this);
  2.1862 +    a->setStatusTip( tr( "Autosave"));
  2.1863  	a->setToggleAction(true);
  2.1864 -	a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoedit",true) );
  2.1865 -    a->addTo( menu );
  2.1866 -	actionSettingsAutoedit=a;
  2.1867 -
  2.1868 -    a= new QAction( tr( "Select branch after adding it" ), QPixmap(), tr( "Select branch after adding it" ), 0, this, "autoselectheading" );
  2.1869 +	a->setOn ( settings.value ("/mainwindow/autosave/use",false).toBool());
  2.1870 +    connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
  2.1871 +	settingsMenu->addAction (a);
  2.1872 +	actionSettingsAutosaveToggle=a;
  2.1873 +
  2.1874 +    a = new QAction( tr( "Autosave time","Settings action")+"...", this);
  2.1875 +    a->setStatusTip( tr( "Autosave time"));
  2.1876 +    connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
  2.1877 +	settingsMenu->addAction (a);
  2.1878 +	actionSettingsAutosaveTime=a;
  2.1879 +
  2.1880 +    a = new QAction( tr( "Write backup file on save","Settings action"), this);
  2.1881 +    a->setStatusTip( tr( "Write backup file on save"));
  2.1882  	a->setToggleAction(true);
  2.1883 -	a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselect",false) );
  2.1884 -    a->addTo( menu );
  2.1885 -	actionSettingsAutoselectHeading=a;
  2.1886 +	a->setOn ( settings.value ("/mainwindow/writeBackupFile",false).toBool());
  2.1887 +    connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) );
  2.1888 +	settingsMenu->addAction (a);
  2.1889 +	actionSettingsWriteBackupFile=a;
  2.1890 +
  2.1891 +	settingsMenu->addSeparator();
  2.1892 +
  2.1893 +    a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
  2.1894 +    a->setStatusTip( tr( "Edit branch after adding it" ));
  2.1895 +	a->setToggleAction(true);
  2.1896 +	a->setOn ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
  2.1897 +	settingsMenu->addAction (a);
  2.1898 +	actionSettingsAutoEditNewBranch=a;
  2.1899 +
  2.1900 +    a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
  2.1901 +    a->setStatusTip( tr( "Select branch after adding it" ));
  2.1902 +	a->setToggleAction(true);
  2.1903 +	a->setOn ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
  2.1904 +	settingsMenu->addAction (a);
  2.1905 +	actionSettingsAutoSelectNewBranch=a;
  2.1906  	
  2.1907 -    a= new QAction( tr( "Select heading before editing" ), QPixmap(), tr( "Select existing heading" ), 0, this, "autoselectexistingtext" );
  2.1908 +    a= new QAction(tr( "Select existing heading","Settings action" ), this);
  2.1909 +    a->setStatusTip( tr( "Select heading before editing" ));
  2.1910  	a->setToggleAction(true);
  2.1911 -	a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselectexistingtext",true) );
  2.1912 -    a->addTo( menu );
  2.1913 -	actionSettingsAutoselectText=a;
  2.1914 +	a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
  2.1915 +	settingsMenu->addAction (a);
  2.1916 +	actionSettingsAutoSelectText=a;
  2.1917  	
  2.1918 -    a= new QAction( tr( "Enable pasting into new branch" ), QPixmap(), tr( "Enable pasting into new branch" ), 0, this, "pastenewheading" );
  2.1919 +    a= new QAction( tr( "Delete key","Settings action" ), this);
  2.1920 +    a->setStatusTip( tr( "Delete key for deleting branches" ));
  2.1921  	a->setToggleAction(true);
  2.1922 -	a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/newheadingisempty",true) );
  2.1923 -    a->addTo( menu );
  2.1924 -	actionSettingsPasteNewHeading=a;
  2.1925 +	a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
  2.1926 +	settingsMenu->addAction (a);
  2.1927 +    connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
  2.1928 +	actionSettingsUseDelKey=a;
  2.1929 +
  2.1930 +    a= new QAction( tr( "Exclusive flags","Settings action" ), this);
  2.1931 +    a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
  2.1932 +	a->setToggleAction(true);
  2.1933 +	a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
  2.1934 +	settingsMenu->addAction (a);
  2.1935 +	actionSettingsUseFlagGroups=a;
  2.1936  	
  2.1937 -    a= new QAction( tr( "Enable Delete key for deleting branches" ), QPixmap(), tr( "Enable Delete key" ), 0, this, "delkey" );
  2.1938 +    a= new QAction( tr( "Use hide flags","Settings action" ), this);
  2.1939 +    a->setStatusTip( tr( "Use hide flag during exports " ));
  2.1940  	a->setToggleAction(true);
  2.1941 -	a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useDelKey",false) );
  2.1942 -    a->addTo( menu );
  2.1943 -	actionSettingsUseDelKey=a;
  2.1944 +	a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
  2.1945 +	settingsMenu->addAction (a);
  2.1946 +	actionSettingsUseHideExport=a;
  2.1947 +
  2.1948 +    a = new QAction( tr( "Animation","Settings action"), this);
  2.1949 +    a->setStatusTip( tr( "Animation"));
  2.1950 +	a->setToggleAction(true);
  2.1951 +	a->setOn (settings.value("/animation/use",false).toBool() );
  2.1952 +    connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) );
  2.1953 +	if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
  2.1954 +	{
  2.1955 +		settingsMenu->addAction (a);
  2.1956 +	}	
  2.1957 +	actionSettingsUseAnimation=a;
  2.1958  }
  2.1959  
  2.1960  // Test Actions
  2.1961  void Main::setupTestActions()
  2.1962  {
  2.1963 -    QPopupMenu *menu = new QPopupMenu( this );
  2.1964 -    menuBar()->insertItem( tr( "&Test" ), menu );
  2.1965 +    QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
  2.1966  
  2.1967      QAction *a;
  2.1968 -    a = new QAction( tr( "Test Flag" ), QPixmap(), tr( "test flag" ), 0, this, "flag" );
  2.1969 -    connect( a, SIGNAL( activated() ), this, SLOT( testFunction() ) );
  2.1970 -    a->addTo( menu );
  2.1971 -
  2.1972 -	a = new QAction( tr( "Show Clipboard" ), QPixmap(), tr( "Show clipboard" ), 0, this, "clipboard" );
  2.1973 -    connect( a, SIGNAL( activated() ), this, SLOT( testShowClipboard() ) );
  2.1974 -    a->addTo( menu );
  2.1975 +    a = new QAction( "Test function 1" , this);
  2.1976 +    a->setStatusTip( "Call test function 1" );
  2.1977 +	testMenu->addAction (a);
  2.1978 +    connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
  2.1979 +
  2.1980 +    a = new QAction( "Test function 2" , this);
  2.1981 +    a->setStatusTip( "Call test function 2" );
  2.1982 +	testMenu->addAction (a);
  2.1983 +    connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
  2.1984 +
  2.1985 +    a = new QAction( "Command" , this);
  2.1986 +    a->setStatusTip( "Enter command to call in editor" );
  2.1987 +    connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
  2.1988 +	testMenu->addAction (a);
  2.1989  }
  2.1990  
  2.1991  // Help Actions
  2.1992  void Main::setupHelpActions()
  2.1993  {
  2.1994 -    QPopupMenu *menu = new QPopupMenu( this );
  2.1995 -    menuBar()->insertItem( tr( "&Help" ), menu );
  2.1996 +    QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
  2.1997  
  2.1998      QAction *a;
  2.1999 -    a = new QAction( tr( "Open VYM Documentation (pdf)" ), QPixmap(), tr( "Open VYM Documentation (pdf) " ), 0, this, "about" );
  2.2000 -    connect( a, SIGNAL( activated() ), this, SLOT( helpDoc() ) );
  2.2001 -    a->addTo( menu );
  2.2002 -
  2.2003 -    a = new QAction( tr( "Information about VYM" ), QPixmap(), tr( "About VYM" ), 0, this, "about" );
  2.2004 -    connect( a, SIGNAL( activated() ), this, SLOT( helpAbout() ) );
  2.2005 -    a->addTo( menu );
  2.2006 -
  2.2007 -    a = new QAction( tr( "Information about QT toolkit" ), QPixmap(), tr( "About QT" ), 0, this, "about" );
  2.2008 -    connect( a, SIGNAL( activated() ), this, SLOT( helpAboutQT() ) );
  2.2009 -    a->addTo( menu );
  2.2010 +    a = new QAction(  tr( "Open VYM Documentation (pdf) ","Help action" ), this );
  2.2011 +    a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
  2.2012 +    connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
  2.2013 +	helpMenu->addAction (a);
  2.2014 +
  2.2015 +    a = new QAction(  tr( "Open VYM example maps ","Help action" ), this );
  2.2016 +    a->setStatusTip( tr( "Open VYM example maps " ));
  2.2017 +    connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
  2.2018 +	helpMenu->addAction (a);
  2.2019 +
  2.2020 +    a = new QAction( tr( "About VYM","Help action" ), this);
  2.2021 +    a->setStatusTip( tr( "About VYM")+vymName);
  2.2022 +    connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
  2.2023 +	helpMenu->addAction (a);
  2.2024 +
  2.2025 +    a = new QAction( tr( "About QT","Help action" ), this);
  2.2026 +    a->setStatusTip( tr( "Information about QT toolkit" ));
  2.2027 +    connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
  2.2028 +	helpMenu->addAction (a);
  2.2029  }
  2.2030  
  2.2031  // Context Menus
  2.2032 @@ -772,135 +1536,146 @@
  2.2033  	QAction*a;
  2.2034  
  2.2035  	// Context Menu for branch or mapcenter
  2.2036 -	branchContextMenu =new QPopupMenu (this);
  2.2037 -	actionEditAddBranch->addTo ( branchContextMenu );
  2.2038 -	actionEditAddBranchAbove->addTo ( branchContextMenu );
  2.2039 -	actionEditAddBranchBelow->addTo ( branchContextMenu );
  2.2040 +	branchContextMenu =new QMenu (this);
  2.2041 +	branchContextMenu->addAction (actionViewTogglePropertyWindow);
  2.2042 +	branchContextMenu->addSeparator();	
  2.2043 +
  2.2044 +		// Submenu "Add"
  2.2045 +		branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
  2.2046 +		branchAddContextMenu->addAction (actionEditPaste );
  2.2047 +		branchAddContextMenu->addAction ( actionEditAddBranch );
  2.2048 +		branchAddContextMenu->addAction ( actionEditAddBranchBefore );
  2.2049 +		branchAddContextMenu->addAction ( actionEditAddBranchAbove);
  2.2050 +		branchAddContextMenu->addAction ( actionEditAddBranchBelow );
  2.2051 +		branchAddContextMenu->addSeparator();	
  2.2052 +		branchAddContextMenu->addAction ( actionEditImportAdd );
  2.2053 +		branchAddContextMenu->addAction ( actionEditImportReplace );
  2.2054 +
  2.2055 +		// Submenu "Remove"
  2.2056 +		branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
  2.2057 +		branchRemoveContextMenu->addAction (actionEditCut);
  2.2058 +		branchRemoveContextMenu->addAction ( actionEditDelete );
  2.2059 +		branchRemoveContextMenu->addAction ( actionEditDeleteKeepChilds );
  2.2060 +		branchRemoveContextMenu->addAction ( actionEditDeleteChilds );
  2.2061 +		
  2.2062 +
  2.2063  	actionEditSaveBranch->addTo( branchContextMenu );
  2.2064 -	branchContextMenu->insertSeparator();	
  2.2065 -	actionEditImportAdd->addTo ( branchContextMenu );
  2.2066 -	actionEditImportReplace->addTo ( branchContextMenu );
  2.2067 -	branchContextMenu->insertSeparator();	
  2.2068 -	actionEditOpenURL->addTo ( branchContextMenu );
  2.2069 -	actionEditURL->addTo ( branchContextMenu );
  2.2070 -	actionEditHeading2URL->addTo ( branchContextMenu );
  2.2071 -    if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) 
  2.2072 -		actionEditBugzilla2URL->addTo( branchContextMenu );
  2.2073 -	branchContextMenu->insertSeparator();	
  2.2074 -	actionEditOpenVymLink->addTo ( branchContextMenu );
  2.2075 -	actionEditVymLink->addTo ( branchContextMenu );
  2.2076 -	actionEditDeleteVymLink->addTo ( branchContextMenu );
  2.2077 -	branchContextMenu->insertSeparator();	
  2.2078 -	actionEditLoadImage->addTo( branchContextMenu );
  2.2079 -	branchContextMenu->insertSeparator();	
  2.2080 -	actionEditCopy->addTo( branchContextMenu );
  2.2081 -	actionEditCut->addTo( branchContextMenu );
  2.2082 -	actionEditPaste->addTo( branchContextMenu );
  2.2083 -	branchContextMenu->insertSeparator();	
  2.2084 -	actionGroupFormatFrameTypes->addTo( branchContextMenu );
  2.2085 -
  2.2086 +	actionFileNewCopy->addTo (branchContextMenu );
  2.2087 +
  2.2088 +	branchContextMenu->addSeparator();	
  2.2089 +	branchContextMenu->addAction ( actionEditLoadImage);
  2.2090 +
  2.2091 +	// Submenu for Links (URLs, vymLinks)
  2.2092 +	branchLinksContextMenu =new QMenu (this);
  2.2093 +
  2.2094 +		branchContextMenu->addSeparator();	
  2.2095 +		branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));	
  2.2096 +		branchLinksContextMenu->addAction ( actionEditOpenURL );
  2.2097 +		branchLinksContextMenu->addAction ( actionEditOpenURLTab );
  2.2098 +		branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
  2.2099 +		branchLinksContextMenu->addAction ( actionEditURL );
  2.2100 +		branchLinksContextMenu->addAction ( actionEditLocalURL );
  2.2101 +		branchLinksContextMenu->addAction ( actionEditHeading2URL );
  2.2102 +		branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
  2.2103 +		if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
  2.2104 +		{
  2.2105 +			branchLinksContextMenu->addAction ( actionEditFATE2URL );
  2.2106 +		}	
  2.2107 +		branchLinksContextMenu->addSeparator();	
  2.2108 +		branchLinksContextMenu->addAction ( actionEditOpenVymLink );
  2.2109 +		branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
  2.2110 +		branchLinksContextMenu->addAction ( actionEditVymLink );
  2.2111 +		branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
  2.2112 +		
  2.2113 +
  2.2114 +	// Context Menu for XLinks in a branch menu
  2.2115 +	// This will be populated "on demand" in MapEditor::updateActions
  2.2116 +	branchContextMenu->addSeparator();	
  2.2117 +	branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
  2.2118 +	branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
  2.2119 +	connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
  2.2120 +	connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
  2.2121 + 	
  2.2122 +	
  2.2123  	// Context menu for floatimage
  2.2124 -	floatimageContextMenu =new QPopupMenu (this);
  2.2125 -	saveImageFormatMenu=new QPopupMenu (this);
  2.2126 -	exportImageFormatMenu=new QPopupMenu (this);
  2.2127 -
  2.2128 -	QStrList fmt = QImage::outputFormats();
  2.2129 -	for (const char* f = fmt.first(); f; f = fmt.next()) 
  2.2130 -	{
  2.2131 -		saveImageFormatMenu->insertItem( f );
  2.2132 -		exportImageFormatMenu->insertItem( f );
  2.2133 -	}	
  2.2134 -	connect( saveImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( editSaveImage(int ) ) );
  2.2135 -	connect( exportImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( fileExportImage(int ) ) );
  2.2136 -	floatimageContextMenu->insertItem( tr("Save image"),saveImageFormatMenu );
  2.2137 -	
  2.2138 -	floatimageContextMenu->insertSeparator();	
  2.2139 +	floatimageContextMenu =new QMenu (this);
  2.2140 +	a= new QAction (tr ("Save image","Context action"),this);
  2.2141 +	connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
  2.2142 +	floatimageContextMenu->addAction (a);
  2.2143 +
  2.2144 +	floatimageContextMenu->addSeparator();	
  2.2145  	actionEditCopy->addTo( floatimageContextMenu );
  2.2146  	actionEditCut->addTo( floatimageContextMenu );
  2.2147  
  2.2148 -	floatimageContextMenu->insertSeparator();	
  2.2149 -    a = new QAction( tr( "Use for Export" ), QPixmap(), tr( "Use for Export"), 0, this, "useForExport" );
  2.2150 -	a->setToggleAction(true);
  2.2151 -    connect( a, SIGNAL( activated() ), this, SLOT( editToggleFloatExport() ) );
  2.2152 -    a->addTo( floatimageContextMenu);
  2.2153 -	actionEditToggleFloatExport=a;
  2.2154 -
  2.2155 -
  2.2156 -
  2.2157 -	// Context menu for exports
  2.2158 -	exportMenu->insertItem ( tr("Export map as image"),exportImageFormatMenu);
  2.2159 -
  2.2160 -    a = new QAction( tr( "Export as ASCII (still experimental)" ), QPixmap(), tr( "Export (ASCII)" ), 0, this, "exportASCII" );
  2.2161 -    connect( a, SIGNAL( activated() ), this, SLOT( fileExportASCII() ) );
  2.2162 -    a->addTo( exportMenu );
  2.2163 -
  2.2164 -	a = new QAction( tr( "Export XML" ), QPixmap(), tr( "Export XML" ),  0, this, "exportXML" );
  2.2165 -    connect( a, SIGNAL( activated() ), this, SLOT( fileExportXML() ) );
  2.2166 -    a->addTo( exportMenu );
  2.2167 -	
  2.2168 -    if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) 
  2.2169 -	{
  2.2170 -		a = new QAction( tr( "Export HTML" ), QPixmap(), tr( "Export HTML" ), 0, this, "exportHTML" );
  2.2171 -		connect( a, SIGNAL( activated() ), this, SLOT( fileExportHTML() ) );
  2.2172 -		a->addTo( exportMenu );
  2.2173 -	}
  2.2174 -
  2.2175 -	a = new QAction( tr( "Export XHTML" ), QPixmap(), tr( "Export XHTML" ), ALT + Key_X, this, "exportXHTML" );
  2.2176 -    connect( a, SIGNAL( activated() ), this, SLOT( fileExportXHTML() ) );
  2.2177 -    a->addTo( exportMenu );
  2.2178 +	floatimageContextMenu->addSeparator();	
  2.2179 +	floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
  2.2180  
  2.2181  	
  2.2182  	// Context menu for canvas
  2.2183 -	canvasContextMenu =new QPopupMenu (this);
  2.2184 +	canvasContextMenu =new QMenu (this);
  2.2185  	actionEditMapInfo->addTo( canvasContextMenu );
  2.2186 +	if (settings.value( "/mainwindow/showTestMenu",false).toBool() ) 
  2.2187 +		actionEditAddMapCenter->addTo( canvasContextMenu );
  2.2188  	canvasContextMenu->insertSeparator();	
  2.2189  	actionGroupFormatLinkStyles->addTo( canvasContextMenu );
  2.2190  	canvasContextMenu->insertSeparator();	
  2.2191  	actionFormatLinkColorHint->addTo( canvasContextMenu );
  2.2192  	actionFormatLinkColor->addTo( canvasContextMenu );
  2.2193 +	actionFormatSelectionColor->addTo( canvasContextMenu );
  2.2194  	actionFormatBackColor->addTo( canvasContextMenu );
  2.2195 +	// actionFormatBackImage->addTo( canvasContextMenu );  //FIXME makes vym too slow: postponed for later version 
  2.2196  
  2.2197  	// Menu for last opened files
  2.2198 -	// Read settings initially
  2.2199 -	QString s;
  2.2200 -	int j=settings.readNumEntry( "/vym/lastMaps/number",0);
  2.2201 -	for (int i=1;i<=j;i++)
  2.2202 +	// Create actions
  2.2203 +	for (int i = 0; i < MaxRecentFiles; ++i) 
  2.2204  	{
  2.2205 -		s=settings.readEntry(QString("/vym/lastMaps/map-%1").arg(i),"");
  2.2206 -		if (!s.isEmpty() && j<=maxLastMaps) 
  2.2207 -			lastMaps.append(s);
  2.2208 -	}
  2.2209 -	setupLastMapsMenu();
  2.2210 -	connect( lastMapsMenu, SIGNAL( activated(int) ), this, SLOT( fileLoadLast(int ) ) );
  2.2211 +        recentFileActions[i] = new QAction(this);
  2.2212 +        recentFileActions[i]->setVisible(false);
  2.2213 +        fileLastMapsMenu->addAction(recentFileActions[i]);
  2.2214 +        connect(recentFileActions[i], SIGNAL(triggered()),
  2.2215 +                this, SLOT(fileLoadRecent()));
  2.2216 +    }
  2.2217 +	setupRecentMapsMenu();
  2.2218  }
  2.2219  
  2.2220 -void Main::setupLastMapsMenu()
  2.2221 +void Main::setupRecentMapsMenu()
  2.2222  {
  2.2223 -	// Remove double entries
  2.2224 -	QStringList::Iterator it=lastMaps.begin();
  2.2225 -	QStringList::Iterator jt;
  2.2226 -	while (it!=lastMaps.end() )
  2.2227 +    QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
  2.2228 +
  2.2229 +    int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
  2.2230 +
  2.2231 +    for (int i = 0; i < numRecentFiles; ++i) {
  2.2232 +        QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
  2.2233 +        recentFileActions[i]->setText(text);
  2.2234 +        recentFileActions[i]->setData(files[i]);
  2.2235 +        recentFileActions[i]->setVisible(true);
  2.2236 +    }
  2.2237 +    for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
  2.2238 +        recentFileActions[j]->setVisible(false);
  2.2239 +}
  2.2240 +
  2.2241 +void Main::setupMacros()
  2.2242 +{
  2.2243 +    for (int i = 0; i <= 11; i++) 
  2.2244  	{
  2.2245 -		jt=it;
  2.2246 -		++jt;
  2.2247 -		while (jt!=lastMaps.end() )
  2.2248 -		{
  2.2249 -			if (*it == *jt)		
  2.2250 -				jt=lastMaps.remove(jt);
  2.2251 -			else	
  2.2252 -				jt++;
  2.2253 -		}
  2.2254 -		it++;
  2.2255 -	}	
  2.2256 -
  2.2257 -	// Limit length of list to maxLastMaps
  2.2258 -	while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
  2.2259 -	
  2.2260 -	// build Menu from lastMaps string list
  2.2261 -	lastMapsMenu->clear();
  2.2262 -	for (it = lastMaps.begin(); it != lastMaps.end(); ++it ) 
  2.2263 -		lastMapsMenu->insertItem (*it );
  2.2264 -		
  2.2265 +        macroActions[i] = new QAction(this);
  2.2266 +        macroActions[i]->setData(i);
  2.2267 +        addAction (macroActions[i]);
  2.2268 +        connect(macroActions[i], SIGNAL(triggered()),
  2.2269 +                this, SLOT(callMacro()));
  2.2270 +	}			
  2.2271 +	macroActions[0]->setShortcut ( Qt::Key_F1 );
  2.2272 +	macroActions[1]->setShortcut ( Qt::Key_F2 );
  2.2273 +	macroActions[2]->setShortcut ( Qt::Key_F3 );
  2.2274 +	macroActions[3]->setShortcut ( Qt::Key_F4 );
  2.2275 +	macroActions[4]->setShortcut ( Qt::Key_F5 );
  2.2276 +	macroActions[5]->setShortcut ( Qt::Key_F6 );
  2.2277 +	macroActions[6]->setShortcut ( Qt::Key_F7 );
  2.2278 +	macroActions[7]->setShortcut ( Qt::Key_F8 );
  2.2279 +	macroActions[8]->setShortcut ( Qt::Key_F9 );
  2.2280 +	macroActions[9]->setShortcut ( Qt::Key_F10 );
  2.2281 +	macroActions[10]->setShortcut ( Qt::Key_F11 );
  2.2282 +	macroActions[11]->setShortcut ( Qt::Key_F12 );
  2.2283  }
  2.2284  
  2.2285  void Main::hideEvent (QHideEvent * )
  2.2286 @@ -910,51 +1685,9 @@
  2.2287  
  2.2288  void Main::showEvent (QShowEvent * )
  2.2289  {
  2.2290 -	if (textEditor->showWithMain()) textEditor->show();
  2.2291 +	if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
  2.2292  }
  2.2293  
  2.2294 -bool Main::reallyWriteDirectory(const QString &dir)
  2.2295 -{
  2.2296 -	QStringList eList = QDir(dir).entryList();
  2.2297 -	if (eList.first() ==".")  eList.pop_front();	// remove "."
  2.2298 -	if (eList.first() =="..") eList.pop_front();	// remove "."
  2.2299 -	if (!eList.isEmpty())
  2.2300 -	{
  2.2301 -		QMessageBox mb( "VYM",
  2.2302 -			tr("The directory ") + dir + 
  2.2303 -			tr(" is not empty. Do you risk to overwrite its contents?"),
  2.2304 -		QMessageBox::Warning,
  2.2305 -		QMessageBox::Yes ,
  2.2306 -		QMessageBox::Cancel | QMessageBox::Default,
  2.2307 -		QMessageBox::QMessageBox::NoButton );
  2.2308 -
  2.2309 -		mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
  2.2310 -		mb.setButtonText( QMessageBox::No, tr("Cancel"));
  2.2311 -		switch( mb.exec() ) 
  2.2312 -		{
  2.2313 -			case QMessageBox::Yes:
  2.2314 -				// save 
  2.2315 -				return true;
  2.2316 -			case QMessageBox::Cancel:
  2.2317 -				// do nothing
  2.2318 -				return false;
  2.2319 -		}
  2.2320 -	}
  2.2321 -	return true;
  2.2322 -}
  2.2323 -
  2.2324 -QString Main::browseDirectory (const QString &caption)
  2.2325 -{
  2.2326 -	QFileDialog fd(this,caption);
  2.2327 -	fd.setMode (QFileDialog::DirectoryOnly);
  2.2328 -	fd.setCaption("VYM - "+caption);
  2.2329 -	fd.show();
  2.2330 -	
  2.2331 -	if ( fd.exec() == QDialog::Accepted )
  2.2332 -		return fd.selectedFile();
  2.2333 -	else
  2.2334 -		return "";
  2.2335 -}
  2.2336  
  2.2337  MapEditor* Main::currentMapEditor() const
  2.2338  {
  2.2339 @@ -964,49 +1697,64 @@
  2.2340      return NULL;	
  2.2341  }
  2.2342  
  2.2343 -//TODO not used now, maybe use this for overview window later
  2.2344 -void Main::newView() 
  2.2345 -{
  2.2346 -    // Open a new view... have it delete when closed.
  2.2347 -    Main *m = new Main(0, 0, WDestructiveClose);
  2.2348 -    qApp->setMainWidget(m);
  2.2349 -    m->show();
  2.2350 -    qApp->setMainWidget(0);
  2.2351 -}
  2.2352  
  2.2353  void Main::editorChanged(QWidget *)
  2.2354  {
  2.2355  	// Unselect all possibly selected objects
  2.2356  	// (Important to update note editor)
  2.2357 -	int i;
  2.2358  	MapEditor *me;
  2.2359 -	for (i=0;i<=tabWidget->count() -1;i++)
  2.2360 +	for (int i=0;i<=tabWidget->count() -1;i++)
  2.2361  	{
  2.2362 -		
  2.2363  		me=(MapEditor*)tabWidget->page(i);
  2.2364  		me->unselect();
  2.2365  	}	
  2.2366 -	currentMapEditor()->reselect();
  2.2367 +	me=currentMapEditor();
  2.2368 +	if (me) me->reselect();
  2.2369  
  2.2370  	// Update actions to in menus and toolbars according to editor
  2.2371 -	currentMapEditor()->updateActions();
  2.2372 +	updateActions();
  2.2373  }
  2.2374  
  2.2375  void Main::fileNew()
  2.2376  {
  2.2377  	QString fn="unnamed";
  2.2378 -	MapEditor* medit = new MapEditor (tabWidget, true);
  2.2379 -	tabWidget->addTab (medit,fn);
  2.2380 -	tabWidget->showPage(medit);
  2.2381 -	medit->viewport()->setFocus();
  2.2382 -	medit->select("mc:");
  2.2383 +	MapEditor* me = new MapEditor ( NULL);
  2.2384 +	tabWidget->addTab (me,fn);
  2.2385 +	tabWidget->showPage(me);
  2.2386 +	me->viewport()->setFocus();
  2.2387 +	me->setAntiAlias (actionViewToggleAntiAlias->isOn());
  2.2388 +	me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
  2.2389 +	
  2.2390 +	// For the very first map we do not have flagrows yet...
  2.2391 +	me->select("mc:");
  2.2392  }
  2.2393  
  2.2394 -void Main::fileLoad(QString fn, const LoadMode &lmode)
  2.2395 +void Main::fileNewCopy()
  2.2396  {
  2.2397 -	// Error codes
  2.2398 -	enum errorCode {success,aborted};
  2.2399 -	errorCode err=success;
  2.2400 +	QString fn="unnamed";
  2.2401 +	MapEditor* oldME =currentMapEditor();
  2.2402 +	if (oldME)
  2.2403 +	{
  2.2404 +		oldME->copy();
  2.2405 +		MapEditor* newME = new MapEditor ( NULL);
  2.2406 +		if (newME)
  2.2407 +		{
  2.2408 +			tabWidget->addTab (newME,fn);
  2.2409 +			tabWidget->showPage(newME);
  2.2410 +			newME->viewport()->setFocus();
  2.2411 +			newME->setAntiAlias (actionViewToggleAntiAlias->isOn());
  2.2412 +			newME->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
  2.2413 +			// For the very first map we do not have flagrows yet...
  2.2414 +			newME->select("mc:");
  2.2415 +			newME->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
  2.2416 +		}
  2.2417 +
  2.2418 +	}
  2.2419 +}
  2.2420 +
  2.2421 +ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
  2.2422 +{
  2.2423 +	ErrorCode err=success;
  2.2424  	
  2.2425  	// fn is usually the archive, mapfile the file after uncompressing
  2.2426  	QString mapfile;
  2.2427 @@ -1026,15 +1774,15 @@
  2.2428  			if (me->getFilePath() == fn)
  2.2429  			{
  2.2430  				// Already there, ask for confirmation
  2.2431 -				QMessageBox mb( "VYM",
  2.2432 -					tr("The map ") + fn + tr ("\n is already opened."
  2.2433 +				QMessageBox mb( vymName,
  2.2434 +					tr("The map %1\nis already opened."
  2.2435  					"Opening the same map in multiple editors may lead \n"
  2.2436  					"to confusion when finishing working with vym."
  2.2437 -					"Do you want to"),
  2.2438 +					"Do you want to").arg(fn),
  2.2439  					QMessageBox::Warning,
  2.2440  					QMessageBox::Yes | QMessageBox::Default,
  2.2441  					QMessageBox::Cancel | QMessageBox::Escape,
  2.2442 -					QMessageBox::QMessageBox::NoButton);
  2.2443 +					QMessageBox::NoButton);
  2.2444  				mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
  2.2445  				mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
  2.2446  				switch( mb.exec() ) 
  2.2447 @@ -1045,7 +1793,7 @@
  2.2448  						break;
  2.2449  					case QMessageBox::Cancel:
  2.2450  						// do nothing
  2.2451 -						return;
  2.2452 +						return aborted;
  2.2453  						break;
  2.2454  				}
  2.2455  			}
  2.2456 @@ -1064,23 +1812,26 @@
  2.2457  		// create a new mapeditor in a new tab
  2.2458  		if ( lmode==NewMap && (!me || !me->isDefault() ) )
  2.2459  		{
  2.2460 -			me = new MapEditor (tabWidget,true);
  2.2461 +			me= new MapEditor ( NULL);
  2.2462  			tabWidget->addTab (me,fn);
  2.2463  			tabIndex=tabWidget->indexOf (me);
  2.2464  			tabWidget->setCurrentPage (tabIndex);
  2.2465 +			me->setAntiAlias (actionViewToggleAntiAlias->isOn());
  2.2466 +			me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
  2.2467  		}
  2.2468  		
  2.2469  		// Check, if file exists (important for creating new files
  2.2470  		// from command line
  2.2471 +		/*
  2.2472 +		*/
  2.2473  		if (!QFile(fn).exists() )
  2.2474  		{
  2.2475 -			QMessageBox mb( "VYM",
  2.2476 -				tr("The map") + fn + 
  2.2477 -				tr(" does not exist.\n Do you want to create a new one?"),
  2.2478 +			QMessageBox mb( vymName,
  2.2479 +				tr("This map does not exist:\n  %1\nDo you want to create a new one?").arg(fn),
  2.2480  				QMessageBox::Question,
  2.2481  				QMessageBox::Yes ,
  2.2482  				QMessageBox::Cancel | QMessageBox::Default,
  2.2483 -				QMessageBox::QMessageBox::NoButton );
  2.2484 +				QMessageBox::NoButton );
  2.2485  
  2.2486  			mb.setButtonText( QMessageBox::Yes, tr("Create"));
  2.2487  			mb.setButtonText( QMessageBox::No, tr("Cancel"));
  2.2488 @@ -1092,162 +1843,78 @@
  2.2489  					tabWidget->setTabLabel (currentMapEditor(),
  2.2490  						currentMapEditor()->getFileName() );
  2.2491  					statusBar()->message( "Created " + fn , statusbarTime );
  2.2492 -					return;
  2.2493 +					return success;
  2.2494  						
  2.2495  				case QMessageBox::Cancel:
  2.2496  					// don't create new map
  2.2497  					statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
  2.2498  					fileCloseMap();
  2.2499 -					return;
  2.2500 +					return aborted;
  2.2501  			}
  2.2502  		}	
  2.2503  
  2.2504 -
  2.2505  		//tabWidget->currentPage() won't be NULL here, because of above...
  2.2506  		tabWidget->showPage(me);
  2.2507  		me->viewport()->setFocus();
  2.2508  
  2.2509 -		// Create temporary directory for packing
  2.2510 -		char tmpdir1[]="/tmp/vym-XXXXXX";	
  2.2511 -		QString tmpMapDir=mkdtemp(tmpdir1);
  2.2512 -
  2.2513 -		// Try to unzip file
  2.2514 -		Process *zipProc=new Process ();
  2.2515 -		zipProc->clearArguments();
  2.2516 -		zipProc->setWorkingDirectory (QDir(tmpMapDir));
  2.2517 -		zipProc->addArgument ("unzip");
  2.2518 -		zipProc->addArgument (fn );
  2.2519 -		zipProc->addArgument ("-d");
  2.2520 -		zipProc->addArgument (tmpMapDir);
  2.2521 -
  2.2522 -		if (!zipProc->start() )
  2.2523 +		if (err!=aborted)
  2.2524  		{
  2.2525 -			QMessageBox::critical( 0, tr( "Critical Load Error" ),
  2.2526 -						   tr("Couldn't start unzip to decompress data."));
  2.2527 -			err=aborted;
  2.2528 -			
  2.2529 -		} else
  2.2530 +			// Save existing filename in case  we import
  2.2531 +			QString fn_org=me->getFilePath();
  2.2532 +
  2.2533 +			// Finally load map into mapEditor
  2.2534 +			me->setFilePath (fn);
  2.2535 +			err=me->load(fn,lmode,ftype);
  2.2536 +
  2.2537 +			// Restore old (maybe empty) filepath, if this is an import
  2.2538 +			if (lmode!=NewMap)
  2.2539 +				me->setFilePath (fn_org);
  2.2540 +		}	
  2.2541 +
  2.2542 +		// Finally check for errors and go home
  2.2543 +		if (err==aborted) 
  2.2544  		{
  2.2545 -			zipProc->waitFinished();
  2.2546 -			if (!zipProc->normalExit() )
  2.2547 -			{
  2.2548 -				QMessageBox::critical( 0, tr( "Critical Load Error" ),
  2.2549 -							   tr("unzip didn't exit normally") +
  2.2550 -							   zipProc->getErrout() );
  2.2551 -				err=aborted;
  2.2552 -			} else
  2.2553 -			{
  2.2554 -				if (zipProc->exitStatus()>0)
  2.2555 -				{
  2.2556 -					if (zipProc->exitStatus()==9)
  2.2557 -					{
  2.2558 -						// no zipped file, but maybe .xml or old version? Try again.
  2.2559 -						mapfile=fn;
  2.2560 -						me->setZipped(false);
  2.2561 -					}	
  2.2562 -					else	
  2.2563 -					{
  2.2564 -						QMessageBox::critical( 0, tr( "Critical Load Error" ),
  2.2565 -									   QString("unzip exit code:  %1").arg(zipProc->exitStatus() ) +
  2.2566 -									   zipProc->getErrout() );
  2.2567 -						err=aborted;
  2.2568 -					}
  2.2569 -				} else
  2.2570 -				{	// Uncompressing was successfull,
  2.2571 -					// load from uncompressed temporary directory
  2.2572 -
  2.2573 -					me->setZipped(true);
  2.2574 -
  2.2575 -					
  2.2576 -					// Look for mapname.xml
  2.2577 -					mapfile= fn.left(fn.findRev(".",-1,true));
  2.2578 -					mapfile=mapfile.section( '/', -1 );
  2.2579 -					QFile file( tmpMapDir + "/" + mapfile + ".xml");
  2.2580 -					if (!file.exists() )
  2.2581 -					{
  2.2582 -						// mapname.xml does not exist, well, 
  2.2583 -						// maybe some renamed the mapname.vym file...
  2.2584 -						// Try to find any .xml in the toplevel 
  2.2585 -						// directory of the .vym file
  2.2586 -						QStringList flist=QDir (tmpMapDir).entryList("*.xml");
  2.2587 -						if (flist.count()==1) 
  2.2588 -						{
  2.2589 -							// Only one entry, take this one
  2.2590 -							mapfile=tmpMapDir + "/"+flist.first();
  2.2591 -						} else
  2.2592 -						{
  2.2593 -							for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it ) 
  2.2594 -								*it=tmpMapDir + "/" + *it;
  2.2595 -							// FIXME	
  2.2596 -							// Multiple entries, load all (but only the first one into this ME)
  2.2597 -							//mainWindow->fileLoadFromTmp (flist);
  2.2598 -							//returnCode=1;	// Silently forget this attempt to load
  2.2599 -							qWarning ("MainWindow::load (fn)  multimap found...");
  2.2600 -						}	
  2.2601 -							
  2.2602 -						if (flist.isEmpty() )
  2.2603 -						{
  2.2604 -							QMessageBox::critical( 0, tr( "Critical Load Error" ),
  2.2605 -									   tr("Couldn't find a map (*.xml) in .vym archive.\n"));
  2.2606 -							err=aborted;				   
  2.2607 -						}	
  2.2608 -					} //file doesn't exist	
  2.2609 -					else
  2.2610 -						mapfile=file.name();
  2.2611 -				} // Uncompressing successfull
  2.2612 -			}
  2.2613 -		}
  2.2614 -
  2.2615 -		// Finally load map into mapEditor
  2.2616 -		me->setFilePath (mapfile,fn);
  2.2617 -		if (me->load(mapfile,lmode))
  2.2618 -			err=aborted;
  2.2619 -
  2.2620 -		// Delete tmpDir
  2.2621 -		system ( "rm -rf "+tmpMapDir);
  2.2622 -
  2.2623 -		// Check for errors
  2.2624 -		if (err==success) 
  2.2625 +			if (lmode==NewMap) fileCloseMap();
  2.2626 +			statusBar()->message( "Could not load " + fn, statusbarTime );
  2.2627 +		} else 
  2.2628  		{
  2.2629  			if (lmode==NewMap)
  2.2630  			{
  2.2631  				me->setFilePath (fn);
  2.2632  				tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
  2.2633 -				lastMaps.prepend(me->getFilePath() );
  2.2634 -				setupLastMapsMenu();
  2.2635 +				if (!isInTmpDir (fn))
  2.2636 +				{
  2.2637 +					// Only append to lastMaps if not loaded from a tmpDir
  2.2638 +					// e.g. imported bookmarks are in a tmpDir
  2.2639 +					addRecentMap(me->getFilePath() );
  2.2640 +				}
  2.2641  				actionFilePrint->setEnabled (true);
  2.2642  			}	
  2.2643  			statusBar()->message( "Loaded " + fn, statusbarTime );
  2.2644 -			return;
  2.2645 -		} else 
  2.2646 -		{
  2.2647 -			if (lmode==NewMap)
  2.2648 -				fileCloseMap();
  2.2649  		}	
  2.2650 -
  2.2651 -
  2.2652  	}
  2.2653 -	statusBar()->message( "Could not load " + fn, statusbarTime );
  2.2654 +	return err;
  2.2655  }
  2.2656  
  2.2657  
  2.2658  void Main::fileLoad(const LoadMode &lmode)
  2.2659  {
  2.2660 +	QStringList filters;
  2.2661 +	filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
  2.2662  	QFileDialog *fd=new QFileDialog( this);
  2.2663 -	if (!lastFileDir.isEmpty()) 
  2.2664 -		fd->setDir (lastFileDir);
  2.2665 -	fd->addFilter ("XML (*.xml)");
  2.2666 -	fd->addFilter ("VYM map (*.vym *.vyp)");
  2.2667 +	fd->setDir (lastFileDir);
  2.2668 +	fd->setFileMode (QFileDialog::ExistingFiles);
  2.2669 +	fd->setFilters (filters);
  2.2670  	switch (lmode)
  2.2671  	{
  2.2672  		case NewMap:
  2.2673 -			fd->setCaption(tr("Load vym map"));
  2.2674 +			fd->setCaption(vymName+ " - " +tr("Load vym map"));
  2.2675  			break;
  2.2676  		case ImportAdd:
  2.2677 -			fd->setCaption(tr("Import: Add vym map to selection"));
  2.2678 +			fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
  2.2679  			break;
  2.2680  		case ImportReplace:
  2.2681 -			fd->setCaption(tr("Import: Replace selection with vym map"));
  2.2682 +			fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
  2.2683  			break;
  2.2684  	}
  2.2685  	fd->show();
  2.2686 @@ -1255,10 +1922,17 @@
  2.2687  	QString fn;
  2.2688  	if ( fd->exec() == QDialog::Accepted )
  2.2689  	{
  2.2690 -		lastFileDir=fd->dirPath();
  2.2691 -        fn = fd->selectedFile();
  2.2692 -		fileLoad(fn, lmode);				   
  2.2693 +		lastFileDir=fd->directory().path();
  2.2694 +	    QStringList flist = fd->selectedFiles();
  2.2695 +		QStringList::Iterator it = flist.begin();
  2.2696 +		while( it != flist.end() ) 
  2.2697 +		{
  2.2698 +			fn = *it;
  2.2699 +			fileLoad(*it, lmode);				   
  2.2700 +			++it;
  2.2701 +		}
  2.2702  	}
  2.2703 +	delete (fd);
  2.2704  }
  2.2705  
  2.2706  void Main::fileLoad()
  2.2707 @@ -1266,182 +1940,84 @@
  2.2708  	fileLoad (NewMap);
  2.2709  }
  2.2710  
  2.2711 -void Main::fileLoadLast(int i)
  2.2712 +void Main::fileLoadRecent()
  2.2713  {
  2.2714 -	fileLoad(*lastMaps.at(lastMapsMenu->indexOf (i) ),NewMap);			   
  2.2715 +    QAction *action = qobject_cast<QAction *>(sender());
  2.2716 +    if (action)
  2.2717 +        fileLoad (action->data().toString(), NewMap);
  2.2718  }
  2.2719  
  2.2720 -void Main::fileSave(const SaveMode &savemode)
  2.2721 +void Main::addRecentMap (const QString &fileName)
  2.2722  {
  2.2723 -	// tmp dir for zipping 
  2.2724 -	QString tmpMapDir;
  2.2725 -	
  2.2726 -	// Error codes
  2.2727 -	enum errorCode {success,aborted};
  2.2728 -	errorCode err=success;
  2.2729 -	
  2.2730 -	QString safeFilePath;
  2.2731 -
  2.2732 -	bool saveZipped=currentMapEditor()->saveZipped();
  2.2733 -
  2.2734 -	if (currentMapEditor())
  2.2735 +
  2.2736 +    QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
  2.2737 +    files.removeAll(fileName);
  2.2738 +    files.prepend(fileName);
  2.2739 +    while (files.size() > MaxRecentFiles)
  2.2740 +        files.removeLast();
  2.2741 +
  2.2742 +    settings.setValue("/mainwindow/recentFileList", files);
  2.2743 +
  2.2744 +	setupRecentMapsMenu();
  2.2745 +}
  2.2746 +
  2.2747 +void Main::fileSave(MapEditor *me, const SaveMode &savemode)
  2.2748 +{
  2.2749 +	if (!me) return;
  2.2750 +
  2.2751 +	if ( me->getFilePath().isEmpty() ) 
  2.2752  	{
  2.2753 -		QString fn=currentMapEditor()->getFilePath();
  2.2754 -		// filename=unnamed, filepath="" in constructor...
  2.2755 -		if ( !fn.isEmpty() ) 
  2.2756 -		{	
  2.2757 -			// We have a filepath, go on saving			
  2.2758 -			// First remove existing file, we 
  2.2759 -			// don't want to add to old zip archives
  2.2760 -			QFile f(fn);
  2.2761 -			if (f.exists() ) 
  2.2762 -				if (!f.remove())
  2.2763 -					QMessageBox::warning( 0, tr( "Save Error" ),
  2.2764 -						fn+   tr("\ncould not be removed before saving"));
  2.2765 -
  2.2766 -			// Look, if we should zip the data:
  2.2767 -			if (!saveZipped)
  2.2768 -			{
  2.2769 -				QMessageBox mb( "VYM",
  2.2770 -					tr("The map ") + fn + 
  2.2771 -					tr ("\ndid not use the compressed "
  2.2772 -					"vym file format.\nWriting it uncompressed will also write images \n"
  2.2773 -					"and flags and thus may overwrite files in the "
  2.2774 -					"given directory\n\nDo you want to write the map"),
  2.2775 -					QMessageBox::Warning,
  2.2776 -					QMessageBox::Yes | QMessageBox::Default,
  2.2777 -					QMessageBox::No ,
  2.2778 -					QMessageBox::Cancel | QMessageBox::Escape);
  2.2779 -				mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
  2.2780 -				mb.setButtonText( QMessageBox::No, tr("uncompressed") );
  2.2781 -				mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
  2.2782 -				switch( mb.exec() ) 
  2.2783 -				{
  2.2784 -					case QMessageBox::Yes:
  2.2785 -						// save compressed (default file format)
  2.2786 -						saveZipped=true;
  2.2787 -						break;
  2.2788 -					case QMessageBox::No:
  2.2789 -						// save uncompressed
  2.2790 -						saveZipped=false;
  2.2791 -						break;
  2.2792 -					case QMessageBox::Cancel:
  2.2793 -						// do nothing
  2.2794 -						return;
  2.2795 -						break;
  2.2796 -				}
  2.2797 -			}
  2.2798 -
  2.2799 -			if (saveZipped)
  2.2800 -			{
  2.2801 -				char tmpdir1[]="/tmp/vym-XXXXXX";	
  2.2802 -				tmpMapDir=mkdtemp(tmpdir1);
  2.2803 -			
  2.2804 -				safeFilePath=currentMapEditor()->getFilePath();
  2.2805 -				currentMapEditor()->setFilePath (tmpMapDir+"/"+
  2.2806 -					currentMapEditor()->getMapName()+ ".xml",
  2.2807 -					safeFilePath);
  2.2808 -				currentMapEditor()->save (savemode);
  2.2809 -				currentMapEditor()->setFilePath (safeFilePath);
  2.2810 -				
  2.2811 -				// zip the temporary directory
  2.2812 -				Process *zipProc=new Process ();
  2.2813 -				zipProc->clearArguments();
  2.2814 -				zipProc->setWorkingDirectory (QDir(tmpMapDir));
  2.2815 -				zipProc->addArgument ("zip");
  2.2816 -				zipProc->addArgument ("-r");
  2.2817 -				zipProc->addArgument (fn);
  2.2818 -				zipProc->addArgument (".");
  2.2819 -
  2.2820 -				if (!zipProc->start() )
  2.2821 -				{	
  2.2822 -					// zip could not be started
  2.2823 -					QMessageBox::critical( 0, tr( "Critical Save Error" ),
  2.2824 -								   tr("Couldn't start zip to compress data."));
  2.2825 -					err=aborted;
  2.2826 -				} else
  2.2827 -				{
  2.2828 -					// zip could be started
  2.2829 -					zipProc->waitFinished();
  2.2830 -					if (!zipProc->normalExit() )
  2.2831 -					{
  2.2832 -						QMessageBox::critical( 0, tr( "Critical Save Error" ),
  2.2833 -									   tr("zip didn't exit normally")+
  2.2834 -									   "\n" + zipProc->getErrout());
  2.2835 -						err=aborted;
  2.2836 -					} else
  2.2837 -					{
  2.2838 -						if (zipProc->exitStatus()>0)
  2.2839 -						{
  2.2840 -							QMessageBox::critical( 0, tr( "Critical Save Error" ),
  2.2841 -									   QString("zip exit code:  %1").arg(zipProc->exitStatus() )+
  2.2842 -									   "\n" + zipProc->getErrout() );
  2.2843 -							err=aborted;
  2.2844 -						}
  2.2845 -					}
  2.2846 -				}	// zip could be started
  2.2847 -			} // save zipped
  2.2848 -			else
  2.2849 -			{
  2.2850 -				// Save unzipped. 
  2.2851 -				safeFilePath=currentMapEditor()->getFilePath();
  2.2852 -				currentMapEditor()->setFilePath (fn, safeFilePath);
  2.2853 -				currentMapEditor()->save (savemode);
  2.2854 -				currentMapEditor()->setFilePath (safeFilePath);
  2.2855 -			} // save zipped 	
  2.2856 -		} // filepath available
  2.2857 -		else
  2.2858 -		{
  2.2859 -			// We have  no filepath yet,
  2.2860 -			// call fileSaveAs() now, this will call fileSave() 
  2.2861 -			// again.
  2.2862 -			fileSaveAs(savemode);
  2.2863 -		}
  2.2864 -    }
  2.2865 -
  2.2866 -	if (currentMapEditor()->saveZipped())
  2.2867 +		// We have  no filepath yet,
  2.2868 +		// call fileSaveAs() now, this will call fileSave() 
  2.2869 +		// again.
  2.2870 +		// First switch to editor
  2.2871 +		tabWidget->setCurrentWidget (me);
  2.2872 +		fileSaveAs(savemode);
  2.2873 +	}
  2.2874 +
  2.2875 +	if (me->save (savemode)==success)
  2.2876  	{
  2.2877 -		// Delete tmpDir
  2.2878 -		system ( "rm -rf "+ tmpMapDir );
  2.2879 -	} 
  2.2880 -
  2.2881 -	if (err==success)
  2.2882  		statusBar()->message( 
  2.2883 -			tr("Saved")+" " + currentMapEditor()->getFilePath(), 
  2.2884 +			tr("Saved  %1").arg(me->getFilePath()), 
  2.2885  			statusbarTime );
  2.2886 -	else		
  2.2887 +		addRecentMap (me->getFilePath() );
  2.2888 +	} else		
  2.2889  		statusBar()->message( 
  2.2890 -			tr("Couldn't save")+" " + currentMapEditor()->getFilePath(), 
  2.2891 +			tr("Couldn't save ").arg(me->getFilePath()), 
  2.2892  			statusbarTime );
  2.2893  }
  2.2894  
  2.2895  void Main::fileSave()
  2.2896  {
  2.2897 -	fileSave (CompleteMap);
  2.2898 +	fileSave (currentMapEditor(), CompleteMap);
  2.2899 +}
  2.2900 +
  2.2901 +void Main::fileSave(MapEditor *me)
  2.2902 +{
  2.2903 +	fileSave (me,CompleteMap);
  2.2904  }
  2.2905  
  2.2906  void Main::fileSaveAs(const SaveMode& savemode)
  2.2907  {
  2.2908 -	QString tmpMapDir;
  2.2909  	QString fn;
  2.2910  
  2.2911  	if (currentMapEditor())
  2.2912  	{
  2.2913  		if (savemode==CompleteMap)
  2.2914 -			fn = QFileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
  2.2915 +			fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
  2.2916  		else		
  2.2917 -			fn = QFileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
  2.2918 +			fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
  2.2919  		if ( !fn.isEmpty() ) 
  2.2920  		{
  2.2921  			// Check for existing file
  2.2922  			if (QFile (fn).exists())
  2.2923  			{
  2.2924 -				QMessageBox mb( "VYM",
  2.2925 -					tr("The file ") + fn + tr ("\nexists already. Do you want to"),
  2.2926 +				QMessageBox mb( vymName,
  2.2927 +					tr("The file %1\nexists already. Do you want to").arg(fn),
  2.2928  					QMessageBox::Warning,
  2.2929  					QMessageBox::Yes | QMessageBox::Default,
  2.2930  					QMessageBox::Cancel | QMessageBox::Escape,
  2.2931 -					QMessageBox::QMessageBox::NoButton);
  2.2932 +					QMessageBox::NoButton);
  2.2933  				mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
  2.2934  				mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
  2.2935  				switch( mb.exec() ) 
  2.2936 @@ -1474,11 +2050,12 @@
  2.2937  
  2.2938  			// Save now
  2.2939  			currentMapEditor()->setFilePath(fn);
  2.2940 -			fileSave(savemode);
  2.2941 +			fileSave(currentMapEditor(), savemode);
  2.2942  
  2.2943  			// Set name of tab
  2.2944 -			tabWidget->setTabLabel (currentMapEditor(),
  2.2945 -				currentMapEditor()->getFileName() );
  2.2946 +			if (savemode==CompleteMap)
  2.2947 +				tabWidget->setTabLabel (currentMapEditor(),
  2.2948 +					currentMapEditor()->getFileName() );
  2.2949  			return;
  2.2950  		} 
  2.2951  	}
  2.2952 @@ -1489,102 +2066,243 @@
  2.2953  	fileSaveAs (CompleteMap);
  2.2954  }
  2.2955  
  2.2956 +void Main::fileImportKDEBookmarks()
  2.2957 +{
  2.2958 +	ImportKDEBookmarks im;
  2.2959 +	im.transform();
  2.2960 +	if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
  2.2961 +		currentMapEditor()->setFilePath ("");
  2.2962 +}
  2.2963 +
  2.2964 +void Main::fileImportFirefoxBookmarks()
  2.2965 +{
  2.2966 +	Q3FileDialog *fd=new Q3FileDialog( this);
  2.2967 +	fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
  2.2968 +	fd->setMode (Q3FileDialog::ExistingFiles);
  2.2969 +	fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
  2.2970 +	fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
  2.2971 +	fd->show();
  2.2972 +
  2.2973 +	if ( fd->exec() == QDialog::Accepted )
  2.2974 +	{
  2.2975 +		ImportFirefoxBookmarks im;
  2.2976 +	    QStringList flist = fd->selectedFiles();
  2.2977 +		QStringList::Iterator it = flist.begin();
  2.2978 +		while( it != flist.end() ) 
  2.2979 +		{
  2.2980 +			im.setFile (*it);
  2.2981 +			if (im.transform() && 
  2.2982 +				success==fileLoad (im.getTransformedFile(),NewMap,FreemindMap) && 
  2.2983 +				currentMapEditor() )
  2.2984 +				currentMapEditor()->setFilePath ("");
  2.2985 +			++it;
  2.2986 +		}
  2.2987 +	}
  2.2988 +	delete (fd);
  2.2989 +}
  2.2990 +
  2.2991 +void Main::fileImportFreemind()
  2.2992 +{
  2.2993 +	QStringList filters;
  2.2994 +	filters <<"Freemind map (*.mm)"<<"All files (*)";
  2.2995 +	QFileDialog *fd=new QFileDialog( this);
  2.2996 +	fd->setDir (lastFileDir);
  2.2997 +	fd->setFileMode (QFileDialog::ExistingFiles);
  2.2998 +	fd->setFilters (filters);
  2.2999 +	fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
  2.3000 +	fd->show();
  2.3001 +
  2.3002 +	QString fn;
  2.3003 +	if ( fd->exec() == QDialog::Accepted )
  2.3004 +	{
  2.3005 +		lastFileDir=fd->directory().path();
  2.3006 +	    QStringList flist = fd->selectedFiles();
  2.3007 +		QStringList::Iterator it = flist.begin();
  2.3008 +		while( it != flist.end() ) 
  2.3009 +		{
  2.3010 +			fn = *it;
  2.3011 +			if ( fileLoad (fn,NewMap, FreemindMap)  )
  2.3012 +			{	
  2.3013 +				currentMapEditor()->setFilePath ("");
  2.3014 +			}	
  2.3015 +			++it;
  2.3016 +		}
  2.3017 +	}
  2.3018 +	delete (fd);
  2.3019 +}
  2.3020 +
  2.3021 +
  2.3022 +void Main::fileImportMM()
  2.3023 +{
  2.3024 +	ImportMM im;
  2.3025 +
  2.3026 +	Q3FileDialog *fd=new Q3FileDialog( this);
  2.3027 +	fd->setDir (lastFileDir);
  2.3028 +	fd->setMode (Q3FileDialog::ExistingFiles);
  2.3029 +	fd->addFilter ("Mind Manager (*.mmap)");
  2.3030 +	fd->setCaption(tr("Import")+" "+"Mind Manager");
  2.3031 +	fd->show();
  2.3032 +
  2.3033 +	if ( fd->exec() == QDialog::Accepted )
  2.3034 +	{
  2.3035 +		lastFileDir=fd->dirPath();
  2.3036 +	    QStringList flist = fd->selectedFiles();
  2.3037 +		QStringList::Iterator it = flist.begin();
  2.3038 +		while( it != flist.end() ) 
  2.3039 +		{
  2.3040 +			im.setFile (*it);
  2.3041 +			if (im.transform() && 
  2.3042 +				success==fileLoad (im.getTransformedFile(),NewMap) && 
  2.3043 +				currentMapEditor() )
  2.3044 +				currentMapEditor()->setFilePath ("");
  2.3045 +
  2.3046 +			++it;
  2.3047 +		}
  2.3048 +	}
  2.3049 +	delete (fd);
  2.3050 +
  2.3051 +}
  2.3052 +
  2.3053  void Main::fileImportDir()
  2.3054  {
  2.3055  	if (currentMapEditor())
  2.3056  		currentMapEditor()->importDir();	
  2.3057  }
  2.3058  
  2.3059 -void Main::fileExportXML()
  2.3060 +void Main::fileExportXML()	
  2.3061  {
  2.3062 -	if (currentMapEditor())
  2.3063 +	MapEditor *me=currentMapEditor();
  2.3064 +	if (me) me->exportXML();
  2.3065 +}
  2.3066 +
  2.3067 +
  2.3068 +void Main::fileExportXHTML()	
  2.3069 +{
  2.3070 +	MapEditor *me=currentMapEditor();
  2.3071 +	if (me) me->exportXHTML();
  2.3072 +}
  2.3073 +
  2.3074 +void Main::fileExportImage()	
  2.3075 +{
  2.3076 +	MapEditor *me=currentMapEditor();
  2.3077 +	if (me) me->exportImage();
  2.3078 +}
  2.3079 +
  2.3080 +void Main::fileExportASCII()
  2.3081 +{
  2.3082 +	MapEditor *me=currentMapEditor();
  2.3083 +	if (me) me->exportASCII();
  2.3084 +}
  2.3085 +
  2.3086 +void Main::fileExportCSV()	//FIXME not scriptable yet
  2.3087 +{
  2.3088 +	MapEditor *me=currentMapEditor();
  2.3089 +	if (me)
  2.3090  	{
  2.3091 -		QString dir=browseDirectory(tr("Export XML to directory"));
  2.3092 -		if (dir !="" && reallyWriteDirectory(dir) )
  2.3093 -			currentMapEditor()->exportXML(dir);
  2.3094 +		ExportCSV ex;
  2.3095 +		ex.setModel (me->getModel());
  2.3096 +		ex.addFilter ("CSV (*.csv)");
  2.3097 +		ex.setDir(lastImageDir);
  2.3098 +		ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
  2.3099 +		if (ex.execDialog() ) 
  2.3100 +		{
  2.3101 +			me->setExportMode(true);
  2.3102 +			ex.doExport();
  2.3103 +			me->setExportMode(false);
  2.3104 +		}
  2.3105 +	}
  2.3106 +}
  2.3107 +
  2.3108 +void Main::fileExportLaTeX()	//FIXME not scriptable yet
  2.3109 +{
  2.3110 +	MapEditor *me=currentMapEditor();
  2.3111 +	if (me)
  2.3112 +	{
  2.3113 +		ExportLaTeX ex;
  2.3114 +		ex.setModel (me->getModel());
  2.3115 +		ex.addFilter ("Tex (*.tex)");
  2.3116 +		ex.setDir(lastImageDir);
  2.3117 +		ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
  2.3118 +		if (ex.execDialog() ) 
  2.3119 +		{
  2.3120 +			me->setExportMode(true);
  2.3121 +			ex.doExport();
  2.3122 +			me->setExportMode(false);
  2.3123 +		}
  2.3124 +	}
  2.3125 +}
  2.3126 +
  2.3127 +void Main::fileExportKDEBookmarks()	//FIXME not scriptable yet
  2.3128 +{
  2.3129 +	ExportKDEBookmarks ex;
  2.3130 +	MapEditor *me=currentMapEditor();
  2.3131 +	if (me)
  2.3132 +	{
  2.3133 +		ex.setModel (me->getModel());
  2.3134 +		ex.doExport();
  2.3135  	}	
  2.3136  }
  2.3137  
  2.3138 -void Main::fileExportHTML()
  2.3139 +void Main::fileExportTaskjuggler()	//FIXME not scriptable yet
  2.3140  {
  2.3141 -	if (currentMapEditor())
  2.3142 +	ExportTaskjuggler ex;
  2.3143 +	MapEditor *me=currentMapEditor();
  2.3144 +	if (me)
  2.3145  	{
  2.3146 -		ExportHTMLDialog dia(this);
  2.3147 -		
  2.3148 -		if (dia.exec()==QDialog::Accepted)
  2.3149 +		ex.setModel (me->getModel());
  2.3150 +		ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
  2.3151 +		ex.setDir(lastImageDir);
  2.3152 +		ex.addFilter ("Taskjuggler (*.tjp)");
  2.3153 +		if (ex.execDialog() ) 
  2.3154  		{
  2.3155 -			QString dir=dia.getDir();
  2.3156 -			if (reallyWriteDirectory(dir) )
  2.3157 -			{
  2.3158 -				currentMapEditor()->exportXML (dia.getDir() );
  2.3159 -				dia.doExport(currentMapEditor()->getMapName() );
  2.3160 -			}	
  2.3161 +			me->setExportMode(true);
  2.3162 +			ex.doExport();
  2.3163 +			me->setExportMode(false);
  2.3164  		}
  2.3165  	}	
  2.3166  }
  2.3167  
  2.3168 -void Main::fileExportXHTML()
  2.3169 +void Main::fileExportOOPresentation()	//FIXME not scriptable yet
  2.3170  {
  2.3171 -	QString dir;
  2.3172 -	if (currentMapEditor())
  2.3173 +	ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
  2.3174 +	// TODO add preview in dialog
  2.3175 +	//ImagePreview *p =new ImagePreview (fd);
  2.3176 +	//fd->setContentsPreviewEnabled( TRUE );
  2.3177 +	//fd->setContentsPreview( p, p );
  2.3178 +	//fd->setPreviewMode( QFileDialog::Contents );
  2.3179 +	fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
  2.3180 +	fd->setDir (QDir().current());
  2.3181 +	if (fd->foundConfig())
  2.3182  	{
  2.3183 -		ExportXHTMLDialog dia(this);
  2.3184 -		dia.setFilePath (currentMapEditor()->getFilePath() );
  2.3185 -		dia.setMapName (currentMapEditor()->getMapName() );
  2.3186 -		dia.readSettings();
  2.3187 -		
  2.3188 -		if (dia.exec()==QDialog::Accepted)
  2.3189 +		fd->show();
  2.3190 +
  2.3191 +		if ( fd->exec() == QDialog::Accepted )
  2.3192  		{
  2.3193 -			QString dir=dia.getDir();
  2.3194 -			// Check, if warnings should be used before overwriting
  2.3195 -			// the output directory
  2.3196 -			bool ok;
  2.3197 -			if (dia.warnings()) 
  2.3198 -				ok=reallyWriteDirectory(dir);
  2.3199 -			else
  2.3200 -				ok=true;
  2.3201 -
  2.3202 -			if (ok)
  2.3203 -			{
  2.3204 -				currentMapEditor()->exportXML (dia.getDir() );
  2.3205 -				dia.doExport(currentMapEditor()->getMapName() );
  2.3206 -				if (dia.hasChanged())
  2.3207 -					currentMapEditor()->setChanged();
  2.3208 -			}	
  2.3209 +			QString fn=fd->selectedFile();
  2.3210 +			if (!fn.contains (".odp"))
  2.3211 +				fn +=".odp";
  2.3212 +
  2.3213 +			//lastImageDir=fn.left(fn.findRev ("/"));
  2.3214 +			if (currentMapEditor())
  2.3215 +				currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());	
  2.3216  		}
  2.3217 -	}	
  2.3218 -}
  2.3219 -
  2.3220 -void Main::fileExportImage(int item)
  2.3221 -{
  2.3222 -	if (currentMapEditor())
  2.3223 +	} else
  2.3224  	{
  2.3225 -		QString fn = QFileDialog::getSaveFileName( QString::null, "Image  (*.bmp *.jpg *.pbm *.pgm *.png *.ppm *xbm *.xpm)",
  2.3226 -							   this );
  2.3227 -		if ( !fn.isEmpty() ) 
  2.3228 -		{
  2.3229 -			currentMapEditor()->exportImage(fn,item);
  2.3230 -		} else {
  2.3231 -			statusBar()->message( tr("Couldn't save") + fn, statusbarTime );
  2.3232 -		}
  2.3233 +		QMessageBox::warning(0, 
  2.3234 +		tr("Warning"),
  2.3235 +		tr("Couldn't find configuration for export to Open Office\n"));
  2.3236  	}
  2.3237  }
  2.3238  
  2.3239 -void Main::fileExportASCII()
  2.3240 -{
  2.3241 -	if (currentMapEditor())
  2.3242 -		currentMapEditor()->exportASCII();	
  2.3243 -}
  2.3244 -
  2.3245  void Main::fileCloseMap()
  2.3246  {
  2.3247 -	if (currentMapEditor())
  2.3248 +	MapEditor *me = currentMapEditor();
  2.3249 +	if (me)
  2.3250  	{
  2.3251 -		if (currentMapEditor()->hasChanged())
  2.3252 +		if (me->hasChanged())
  2.3253  		{
  2.3254 -			QMessageBox mb( "VYM",
  2.3255 -				tr("The map ") + currentMapEditor()->getFileName() +
  2.3256 -				tr(" has been modified but not saved yet. Do you want to"),
  2.3257 +			QMessageBox mb( vymName,
  2.3258 +				tr("The map %1 has been modified but not saved yet. Do you want to").arg(me->getFileName()),
  2.3259  				QMessageBox::Warning,
  2.3260  				QMessageBox::Yes | QMessageBox::Default,
  2.3261  				QMessageBox::No,
  2.3262 @@ -1595,7 +2313,7 @@
  2.3263  			{
  2.3264  				case QMessageBox::Yes:
  2.3265  					// save and close
  2.3266 -					fileSave(CompleteMap);
  2.3267 +					fileSave(me, CompleteMap);
  2.3268  					break;
  2.3269  				case QMessageBox::No:
  2.3270  				// close  without saving
  2.3271 @@ -1605,11 +2323,17 @@
  2.3272  				return;
  2.3273  			}
  2.3274  		} 
  2.3275 -		currentMapEditor()->closeMap();
  2.3276 -		tabWidget->removePage(currentMapEditor());
  2.3277 +		//me->closeMap(); 
  2.3278 +		tabWidget->removePage(me);
  2.3279  		if (tabWidget->count()==0)
  2.3280  			actionFilePrint->setEnabled (false);
  2.3281 -	}	
  2.3282 +
  2.3283 +        //Remove mapEditor;
  2.3284 +		// Better would be delete (me), but then we have a Qt error:
  2.3285 +		// "QObject: Do not delete object, 'MapEditor', during its event handler!"
  2.3286 +		// So we only remove data now and call deconstructor when vym closes later
  2.3287 +		me->clear();
  2.3288 +	}
  2.3289  }
  2.3290  
  2.3291  void Main::filePrint()
  2.3292 @@ -1629,10 +2353,10 @@
  2.3293  		me=(MapEditor*)tabWidget->page(i);
  2.3294  
  2.3295  		// If something changed, ask what to do
  2.3296 -		if (me->isUnsaved())
  2.3297 +		if (me->hasChanged())
  2.3298  		{
  2.3299  			tabWidget->setCurrentPage(i);
  2.3300 -			QMessageBox mb( "VYM",
  2.3301 +			QMessageBox mb( vymName,
  2.3302  				tr("This map is not saved yet. Do you want to"),
  2.3303  				QMessageBox::Warning,
  2.3304  				QMessageBox::Yes | QMessageBox::Default,
  2.3305 @@ -1640,18 +2364,13 @@
  2.3306  				QMessageBox::Cancel | QMessageBox::Escape );
  2.3307  			mb.setButtonText( QMessageBox::Yes, tr("Save map") );
  2.3308  			mb.setButtonText( QMessageBox::No, tr("Discard changes") );
  2.3309 +			mb.setModal (true);
  2.3310  			mb.show();
  2.3311 -			// Call undocumented function: setActiveWindow is only
  2.3312 -			// possible, if widget is visible. This depends on
  2.3313 -			// windowmanager...
  2.3314 -#if defined(Q_OS_LINUX)
  2.3315 -			qt_wait_for_window_manager( this);
  2.3316 -#endif			
  2.3317  			mb.setActiveWindow();
  2.3318  			switch( mb.exec() ) {
  2.3319  				case QMessageBox::Yes:
  2.3320  					// save (the changed editors) and exit
  2.3321 -					fileSave(CompleteMap);
  2.3322 +					fileSave(currentMapEditor(), CompleteMap);
  2.3323  					break;
  2.3324  				case QMessageBox::No:
  2.3325  					// exit without saving
  2.3326 @@ -1661,6 +2380,7 @@
  2.3327  				return;
  2.3328  			}
  2.3329  		}
  2.3330 +		me->clear();	// remove and unselect now, before mainWindow has gone...
  2.3331  	} // loop over all MEs	
  2.3332      qApp->quit();
  2.3333  }
  2.3334 @@ -1671,8 +2391,16 @@
  2.3335  		currentMapEditor()->undo();
  2.3336  }
  2.3337  
  2.3338 -void Main::editRedo()	    // TODO
  2.3339 +void Main::editRedo()	   
  2.3340  {
  2.3341 +	if (currentMapEditor())
  2.3342 +		currentMapEditor()->redo();
  2.3343 +}
  2.3344 +
  2.3345 +void Main::gotoHistoryStep (int i)	   
  2.3346 +{
  2.3347 +	if (currentMapEditor())
  2.3348 +		currentMapEditor()->gotoHistoryStep (i);
  2.3349  }
  2.3350  
  2.3351  void Main::editCopy()
  2.3352 @@ -1697,13 +2425,6 @@
  2.3353  {
  2.3354  	findWindow->popup();
  2.3355  	findWindow->raise();
  2.3356 -
  2.3357 -	// Call undocumented function: setActiveWindow is only
  2.3358 -	// possible, if widget is visible. This depends on
  2.3359 -	// windowmanager...
  2.3360 -#if defined(Q_OS_LINUX)
  2.3361 -	qt_wait_for_window_manager( this);
  2.3362 -#endif	
  2.3363  	findWindow->setActiveWindow();
  2.3364  }
  2.3365  
  2.3366 @@ -1717,8 +2438,7 @@
  2.3367  	} else
  2.3368  	{
  2.3369  		QMessageBox::information( findWindow, tr( "VYM -Information:" ),
  2.3370 -							   tr("No matches found for ")+
  2.3371 -							   "'<b>"+s+"</b>'");
  2.3372 +							   tr("No matches found for \"%1\"").arg(s));
  2.3373  	}	
  2.3374  }
  2.3375  
  2.3376 @@ -1727,11 +2447,130 @@
  2.3377  	currentMapEditor()->findReset();
  2.3378  }
  2.3379  
  2.3380 +void Main::openTabs(QStringList urls)
  2.3381 +{
  2.3382 +	if (!urls.isEmpty())
  2.3383 +	{	
  2.3384 +		bool success=true;
  2.3385 +		QStringList args;
  2.3386 +		QString browser=settings.value("/mainwindow/readerURL" ).toString();
  2.3387 +		QProcess *p;
  2.3388 +		if (!procBrowser ||  procBrowser->state()!=QProcess::Running)
  2.3389 +		{
  2.3390 +			QString u=urls.takeFirst();
  2.3391 +			procBrowser = new QProcess( this );
  2.3392 +			args<<u;
  2.3393 +			procBrowser->start(browser,args);
  2.3394 +			if ( !procBrowser->waitForStarted())
  2.3395 +			{
  2.3396 +				// try to set path to browser
  2.3397 +				QMessageBox::warning(0, 
  2.3398 +					tr("Warning"),
  2.3399 +					tr("Couldn't find a viewer to open %1.\n").arg(u)+
  2.3400 +					tr("Please use Settings->")+tr("Set application to open an URL"));
  2.3401 +				return;
  2.3402 +			}
  2.3403 +#if defined(Q_OS_WIN32)
  2.3404 +            // There's no sleep in VCEE, replace it with Qt's QThread::wait().
  2.3405 +            this->thread()->wait(3000);
  2.3406 +#else
  2.3407 +			sleep (3);
  2.3408 +#endif
  2.3409 +		}
  2.3410 +		if (browser.contains("konqueror"))
  2.3411 +		{
  2.3412 +			for (int i=0; i<urls.size(); i++)
  2.3413 +			{
  2.3414 +				// Open new browser
  2.3415 +				// Try to open new tab in existing konqueror started previously by vym
  2.3416 +				p=new QProcess (this);
  2.3417 +				args.clear();
  2.3418 +#if defined(Q_OS_WIN32)
  2.3419 +                // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
  2.3420 +                // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
  2.3421 +				args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
  2.3422 +					"konqueror-mainwindow#1"<<
  2.3423 +					"newTab" <<
  2.3424 +					urls.at(i);
  2.3425 +#else
  2.3426 +				args<< QString("konqueror-%1").arg(procBrowser->pid())<<
  2.3427 +					"konqueror-mainwindow#1"<<
  2.3428 +					"newTab" <<
  2.3429 +					urls.at(i);
  2.3430 +#endif
  2.3431 +				p->start ("dcop",args);
  2.3432 +				//cout << qPrintable (args.join(" "))<<endl;
  2.3433 +				if ( !p->waitForStarted() ) success=false;
  2.3434 +			}
  2.3435 +			if (!success)
  2.3436 +				QMessageBox::warning(0, 
  2.3437 +					tr("Warning"),
  2.3438 +					tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
  2.3439 +			return;		
  2.3440 +		} else if (browser.contains ("firefox") || browser.contains ("mozilla") )
  2.3441 +		{
  2.3442 +			for (int i=0; i<urls.size(); i++)
  2.3443 +			{
  2.3444 +				// Try to open new tab in firefox
  2.3445 +				p=new QProcess (this);
  2.3446 +				args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
  2.3447 +				p->start (browser,args);
  2.3448 +				if ( !p->waitForStarted() ) success=false;
  2.3449 +			}			
  2.3450 +			if (!success)
  2.3451 +				QMessageBox::warning(0, 
  2.3452 +					tr("Warning"),
  2.3453 +					tr("Couldn't start %1 to open a new tab").arg(browser));
  2.3454 +			return;		
  2.3455 +		}			
  2.3456 +		QMessageBox::warning(0, 
  2.3457 +			tr("Warning"),
  2.3458 +			tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
  2.3459 +	}	
  2.3460 +}
  2.3461 +
  2.3462  void Main::editOpenURL()
  2.3463  {
  2.3464 +	// Open new browser
  2.3465  	if (currentMapEditor())
  2.3466 -	    currentMapEditor()->openURL();
  2.3467 +	{	
  2.3468 +	    QString url=currentMapEditor()->getURL();
  2.3469 +		QStringList args;
  2.3470 +		if (url=="") return;
  2.3471 +		QString browser=settings.value("/mainwindow/readerURL" ).toString();
  2.3472 +		procBrowser = new QProcess( this );
  2.3473 +		args<<url;
  2.3474 +		procBrowser->start(browser,args);
  2.3475 +		if ( !procBrowser->waitForStarted())
  2.3476 +		{
  2.3477 +			// try to set path to browser
  2.3478 +			QMessageBox::warning(0, 
  2.3479 +				tr("Warning"),
  2.3480 +				tr("Couldn't find a viewer to open %1.\n").arg(url)+
  2.3481 +				tr("Please use Settings->")+tr("Set application to open an URL"));
  2.3482 +			settingsURL() ; 
  2.3483 +		}	
  2.3484 +	}	
  2.3485  }
  2.3486 +void Main::editOpenURLTab()
  2.3487 +{
  2.3488 +	if (currentMapEditor())
  2.3489 +	{	
  2.3490 +	    QStringList urls;
  2.3491 +		urls.append(currentMapEditor()->getURL());
  2.3492 +		openTabs (urls);
  2.3493 +	}	
  2.3494 +}
  2.3495 +void Main::editOpenMultipleURLTabs()
  2.3496 +{
  2.3497 +	if (currentMapEditor())
  2.3498 +	{	
  2.3499 +	    QStringList urls;
  2.3500 +		urls=currentMapEditor()->getURLs();
  2.3501 +		openTabs (urls);
  2.3502 +	}	
  2.3503 +}
  2.3504 +
  2.3505  
  2.3506  void Main::editURL()
  2.3507  {
  2.3508 @@ -1739,6 +2578,12 @@
  2.3509  	    currentMapEditor()->editURL();
  2.3510  }
  2.3511  
  2.3512 +void Main::editLocalURL()
  2.3513 +{
  2.3514 +	if (currentMapEditor())
  2.3515 +	    currentMapEditor()->editLocalURL();
  2.3516 +}
  2.3517 +
  2.3518  void Main::editHeading2URL()
  2.3519  {
  2.3520  	if (currentMapEditor())
  2.3521 @@ -1751,13 +2596,190 @@
  2.3522  	    currentMapEditor()->editBugzilla2URL();
  2.3523  }
  2.3524  
  2.3525 -void Main::editOpenVymLink()
  2.3526 +void Main::editFATE2URL()
  2.3527  {
  2.3528 -	// Get current path to map
  2.3529 -	QString currentVymLink;
  2.3530 +	if (currentMapEditor())
  2.3531 +	    currentMapEditor()->editFATE2URL();
  2.3532 +}
  2.3533 +
  2.3534 +void Main::editHeadingFinished()
  2.3535 +{
  2.3536 +	// only called from editHeading(), so there is a currentME
  2.3537 +	MapEditor *me=currentMapEditor();
  2.3538 +	if (me)
  2.3539 +	{
  2.3540 +		me->setStateEditHeading (false);
  2.3541 +		QPoint p;	//Not used here, only to find out pos of branch
  2.3542 +		bool ok;
  2.3543 +		QString s=me->getHeading(ok,p);
  2.3544 +
  2.3545 +#if defined(Q_OS_MACX) || defined(Q_OS_WIN32)
  2.3546 +#else
  2.3547 +		if (ok && s!=lineedit->text())
  2.3548 +			me->setHeading(lineedit->text());
  2.3549 +			
  2.3550 +		lineedit->releaseKeyboard();
  2.3551 +		lineedit->hide();
  2.3552 +		setFocus();
  2.3553 +#endif	
  2.3554 +		if (!actionSettingsAutoSelectNewBranch->isOn() && 
  2.3555 +			!prevSelection.isEmpty()) 
  2.3556 +			me->select(prevSelection);
  2.3557 +		prevSelection="";
  2.3558 +	}
  2.3559 +}
  2.3560 +
  2.3561 +void Main::editHeading()
  2.3562 +{
  2.3563  	if (currentMapEditor())
  2.3564  	{
  2.3565 -		currentVymLink=currentMapEditor()->getVymLink();	
  2.3566 +		MapEditor *me=currentMapEditor();
  2.3567 +		QString oldSel=me->getSelectString();
  2.3568 +
  2.3569 +		if (lineedit->isVisible())
  2.3570 +			editHeadingFinished();
  2.3571 +		else
  2.3572 +		{
  2.3573 +			bool ok;
  2.3574 +			QPoint p;
  2.3575 +			QString s=me->getHeading(ok,p);
  2.3576 +
  2.3577 +			if (ok)
  2.3578 +			{
  2.3579 +				me->setStateEditHeading (true);
  2.3580 +#if defined(Q_OS_MACX) || defined(Q_OS_WIN32)
  2.3581 +				p=me->mapToGlobal (p);
  2.3582 +				QDialog *d =new QDialog(NULL);
  2.3583 +				QLineEdit *le=new QLineEdit (d);
  2.3584 +				d->setWindowFlags (Qt::FramelessWindowHint);
  2.3585 +				d->setGeometry(p.x(),p.y(),230,25);
  2.3586 +				le->resize (d->width()-10,d->height());
  2.3587 +				le->setText (s);
  2.3588 +				le->selectAll();
  2.3589 +				connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
  2.3590 +				d->activateWindow();
  2.3591 +				d->exec();
  2.3592 +				me->setHeading (le->text());
  2.3593 +				delete (le);
  2.3594 +				delete (d);
  2.3595 +				editHeadingFinished();
  2.3596 +#else
  2.3597 +				p=me->mapTo (this,p);
  2.3598 +				lineedit->setGeometry(p.x(),p.y(),230,25);
  2.3599 +				lineedit->setText(s);
  2.3600 +				lineedit->setCursorPosition(1);
  2.3601 +				lineedit->selectAll();
  2.3602 +				lineedit->show();
  2.3603 +				lineedit->grabKeyboard();
  2.3604 +				lineedit->setFocus();
  2.3605 +#endif
  2.3606 +			}
  2.3607 +		}
  2.3608 +	} // currentMapEditor()	
  2.3609 +}
  2.3610 +
  2.3611 +void Main::editAttributeFinished()
  2.3612 +{
  2.3613 +	// only called from editHeading(), so there is a currentME
  2.3614 +
  2.3615 +	/*
  2.3616 +	MapEditor *me=currentMapEditor();
  2.3617 +	if (me)
  2.3618 +	{
  2.3619 +		me->setStateEditHeading (false);
  2.3620 +		QPoint p;	//Not used here, only to find out pos of branch
  2.3621 +		bool ok;
  2.3622 +		QString s=me->getHeading(ok,p);
  2.3623 +
  2.3624 +#if defined(Q_OS_MACX)
  2.3625 +#else
  2.3626 +		if (ok && s!=lineedit->text())
  2.3627 +			me->setHeading(lineedit->text());
  2.3628 +			
  2.3629 +		lineedit->releaseKeyboard();
  2.3630 +		lineedit->hide();
  2.3631 +		setFocus();
  2.3632 +#endif	
  2.3633 +		if (!actionSettingsAutoSelectNewBranch->isOn() && 
  2.3634 +			!prevSelection.isEmpty()) 
  2.3635 +			me->select(prevSelection);
  2.3636 +		prevSelection="";
  2.3637 +	}
  2.3638 +	*/
  2.3639 +}
  2.3640 +
  2.3641 +#include "attribute.h"
  2.3642 +#include "attributedialog.h"
  2.3643 +void Main::editAttribute()
  2.3644 +{
  2.3645 +	MapEditor *me=currentMapEditor();
  2.3646 +	if (me)
  2.3647 +	{
  2.3648 +		BranchObj *bo=me->getSelectedBranch();
  2.3649 +		if (bo)
  2.3650 +		{
  2.3651 +			AttributeDialog dia(this);
  2.3652 +			dia.setTable (me->attributeTable() );
  2.3653 +			dia.setBranch (bo);
  2.3654 +			dia.setMode (Definition);
  2.3655 +			dia.updateTable();
  2.3656 +			dia.exec();
  2.3657 +		}
  2.3658 +	}	
  2.3659 +	/*
  2.3660 +	if (currentMapEditor())
  2.3661 +	{
  2.3662 +		MapEditor *me=currentMapEditor();
  2.3663 +		QString oldSel=me->getSelectString();
  2.3664 +
  2.3665 +		if (lineedit->isVisible())
  2.3666 +			editAttributeFinished();
  2.3667 +		else
  2.3668 +		{
  2.3669 +			bool ok;
  2.3670 +			QPoint p;
  2.3671 +			QString s=me->getHeading(ok,p);
  2.3672 +
  2.3673 +			if (ok)
  2.3674 +			{
  2.3675 +				me->setStateEditHeading (true);
  2.3676 +#if defined(Q_OS_MACX)
  2.3677 +				p=me->mapToGlobal (p);
  2.3678 +				QDialog *d =new QDialog(NULL);
  2.3679 +				QLineEdit *le=new QLineEdit (d);
  2.3680 +				d->setWindowFlags (Qt::FramelessWindowHint);
  2.3681 +				d->setGeometry(p.x(),p.y(),230,25);
  2.3682 +				le->resize (d->width()-10,d->height());
  2.3683 +				le->setText (s);
  2.3684 +				le->selectAll();
  2.3685 +				connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
  2.3686 +				d->activateWindow();
  2.3687 +				d->exec();
  2.3688 +				me->setHeading (le->text());
  2.3689 +				delete (le);
  2.3690 +				delete (d);
  2.3691 +				editHeadingFinished();
  2.3692 +#else
  2.3693 +				p=me->mapTo (this,p);
  2.3694 +				lineedit->setGeometry(p.x(),p.y(),230,25);
  2.3695 +				lineedit->setText(s);
  2.3696 +				lineedit->setCursorPosition(1);
  2.3697 +				lineedit->selectAll();
  2.3698 +				lineedit->show();
  2.3699 +				lineedit->grabKeyboard();
  2.3700 +				lineedit->setFocus();
  2.3701 +#endif
  2.3702 +			}
  2.3703 +		} 
  2.3704 +	} // currentMapEditor()	
  2.3705 +
  2.3706 +	*/
  2.3707 +}
  2.3708 +
  2.3709 +void Main::openVymLinks(const QStringList &vl)
  2.3710 +{
  2.3711 +	for (int j=0; j<vl.size(); j++)
  2.3712 +	{
  2.3713  		// compare path with already loaded maps
  2.3714  		int index=-1;
  2.3715  		int i;
  2.3716 @@ -1765,7 +2787,7 @@
  2.3717  		for (i=0;i<=tabWidget->count() -1;i++)
  2.3718  		{
  2.3719  			me=(MapEditor*)tabWidget->page(i);
  2.3720 -			if (currentVymLink==me->getFilePath() )
  2.3721 +			if (vl.at(j)==me->getFilePath() )
  2.3722  			{
  2.3723  				index=i;
  2.3724  				break;
  2.3725 @@ -1774,12 +2796,12 @@
  2.3726  		if (index<0)
  2.3727  		// Load map
  2.3728  		{
  2.3729 -			if (!QFile(currentVymLink).exists() )
  2.3730 +			if (!QFile(vl.at(j)).exists() )
  2.3731  				QMessageBox::critical( 0, tr( "Critical Error" ),
  2.3732 -				   tr("Couldn't open map " +currentVymLink)+".");
  2.3733 +				   tr("Couldn't open map %1").arg(vl.at(j)));
  2.3734  			else
  2.3735  			{
  2.3736 -				fileLoad (currentVymLink, NewMap);
  2.3737 +				fileLoad (vl.at(j), NewMap);
  2.3738  				tabWidget->setCurrentPage (tabWidget->count()-1);	
  2.3739  			}
  2.3740  		} else
  2.3741 @@ -1788,6 +2810,26 @@
  2.3742  	}
  2.3743  }
  2.3744  
  2.3745 +void Main::editOpenVymLink()
  2.3746 +{
  2.3747 +	if (currentMapEditor())
  2.3748 +	{
  2.3749 +		QStringList vl;
  2.3750 +		vl.append(currentMapEditor()->getVymLink());	
  2.3751 +		openVymLinks (vl);
  2.3752 +	}
  2.3753 +}
  2.3754 +
  2.3755 +void Main::editOpenMultipleVymLinks()
  2.3756 +{
  2.3757 +	QString currentVymLink;
  2.3758 +	if (currentMapEditor())
  2.3759 +	{
  2.3760 +		QStringList vl=currentMapEditor()->getVymLinks();
  2.3761 +		openVymLinks (vl);
  2.3762 +	}
  2.3763 +}
  2.3764 +
  2.3765  void Main::editVymLink()
  2.3766  {
  2.3767  	if (currentMapEditor())
  2.3768 @@ -1800,6 +2842,12 @@
  2.3769  		currentMapEditor()->deleteVymLink();	
  2.3770  }
  2.3771  
  2.3772 +void Main::editToggleHideExport()
  2.3773 +{
  2.3774 +	if (currentMapEditor())
  2.3775 +		currentMapEditor()->toggleHideExport();	
  2.3776 +}
  2.3777 +
  2.3778  void Main::editMapInfo()
  2.3779  {
  2.3780  	if (currentMapEditor())
  2.3781 @@ -1818,6 +2866,12 @@
  2.3782  		currentMapEditor()->moveBranchDown();
  2.3783  }
  2.3784  
  2.3785 +void Main::editSortChildren()
  2.3786 +{
  2.3787 +	if (currentMapEditor())
  2.3788 +		currentMapEditor()->sortChildren();
  2.3789 +}
  2.3790 +
  2.3791  void Main::editToggleScroll()
  2.3792  {
  2.3793  	if (currentMapEditor())
  2.3794 @@ -1826,36 +2880,113 @@
  2.3795  	}	
  2.3796  }
  2.3797  
  2.3798 -void Main::editUnScrollAll()
  2.3799 +void Main::editUnscrollChilds()
  2.3800  {
  2.3801  	if (currentMapEditor())
  2.3802 +		currentMapEditor()->unscrollChilds();	
  2.3803 +}
  2.3804 +
  2.3805 +void Main::editAddMapCenter()
  2.3806 +{
  2.3807 +	MapEditor *me=currentMapEditor();
  2.3808 +	if (!lineedit->isVisible() && me)
  2.3809  	{
  2.3810 -		currentMapEditor()->unScrollAll();	
  2.3811 +		me->addMapCenter ();
  2.3812  	}	
  2.3813  }
  2.3814  
  2.3815 -void Main::editHeading()
  2.3816 -{
  2.3817 -	if (currentMapEditor())
  2.3818 -		currentMapEditor()->editHeading();
  2.3819 -}
  2.3820 -
  2.3821  void Main::editNewBranch()
  2.3822  {
  2.3823 -	if (currentMapEditor())
  2.3824 -		currentMapEditor()->addNewBranch(0);
  2.3825 +	MapEditor *me=currentMapEditor();
  2.3826 +	if (!lineedit->isVisible() && me)
  2.3827 +	{
  2.3828 +		BranchObj *bo=(BranchObj*)me->getSelection();
  2.3829 +		BranchObj *newbo=me->addNewBranch(0);
  2.3830 +
  2.3831 +		prevSelection=me->getModel()->getSelectString(bo);
  2.3832 +		if (newbo) 
  2.3833 +			me->select (newbo);
  2.3834 +		else
  2.3835 +			return;
  2.3836 +
  2.3837 +		if (actionSettingsAutoEditNewBranch->isOn())
  2.3838 +		{
  2.3839 +			editHeading();
  2.3840 +			return;
  2.3841 +		}	
  2.3842 +		if (!prevSelection.isEmpty()) 
  2.3843 +		{
  2.3844 +			me->select(prevSelection);
  2.3845 +			prevSelection="";
  2.3846 +		}
  2.3847 +
  2.3848 +	}	
  2.3849 +}
  2.3850 +
  2.3851 +void Main::editNewBranchBefore()
  2.3852 +{
  2.3853 +	MapEditor *me=currentMapEditor();
  2.3854 +	if (!lineedit->isVisible() && me)
  2.3855 +	{
  2.3856 +		BranchObj *bo=(BranchObj*)me->getSelection();
  2.3857 +		BranchObj *newbo=me->addNewBranchBefore();
  2.3858 +
  2.3859 +		if (newbo) 
  2.3860 +			me->select (newbo);
  2.3861 +		else
  2.3862 +			return;
  2.3863 +
  2.3864 +		if (actionSettingsAutoEditNewBranch->isOn())
  2.3865 +		{
  2.3866 +			if (!actionSettingsAutoSelectNewBranch->isOn())
  2.3867 +				prevSelection=me->getModel()->getSelectString(bo); //TODO access directly
  2.3868 +			editHeading();
  2.3869 +		}
  2.3870 +	}	
  2.3871  }
  2.3872  
  2.3873  void Main::editNewBranchAbove()
  2.3874  {
  2.3875 -	if (currentMapEditor())
  2.3876 -		currentMapEditor()->addNewBranch(-1);
  2.3877 +	MapEditor *me=currentMapEditor();
  2.3878 +	if (!lineedit->isVisible() && me)
  2.3879 +	{
  2.3880 +		BranchObj *bo=(BranchObj*)me->getSelection();
  2.3881 +		BranchObj *newbo=me->addNewBranch (-1);
  2.3882 +
  2.3883 +		if (newbo) 
  2.3884 +			me->select (newbo);
  2.3885 +		else
  2.3886 +			return;
  2.3887 +
  2.3888 +		if (actionSettingsAutoEditNewBranch->isOn())
  2.3889 +		{
  2.3890 +			if (!actionSettingsAutoSelectNewBranch->isOn())
  2.3891 +				prevSelection=me->getModel()->getSelectString (bo);	// TODO access directly
  2.3892 +			editHeading();
  2.3893 +		}
  2.3894 +	}	
  2.3895  }
  2.3896  
  2.3897  void Main::editNewBranchBelow()
  2.3898  {
  2.3899 -	if (currentMapEditor())
  2.3900 -		currentMapEditor()->addNewBranch(1);
  2.3901 +	MapEditor *me=currentMapEditor();
  2.3902 +	if (!lineedit->isVisible() && me)
  2.3903 +	{
  2.3904 +		BranchObj *bo=(BranchObj*)me->getSelection();
  2.3905 +		BranchObj *newbo=me->addNewBranch (1);
  2.3906 +
  2.3907 +		if (newbo) 
  2.3908 +			me->select (newbo);
  2.3909 +		else
  2.3910 +			return;
  2.3911 +
  2.3912 +		if (actionSettingsAutoEditNewBranch->isOn())
  2.3913 +		{
  2.3914 +			if (!actionSettingsAutoSelectNewBranch->isOn())
  2.3915 +				prevSelection=me->getModel()->getSelectString(bo);	//TODO access directly
  2.3916 +			editHeading();
  2.3917 +		}
  2.3918 +	}	
  2.3919  }
  2.3920  
  2.3921  void Main::editImportAdd()
  2.3922 @@ -1873,9 +3004,21 @@
  2.3923  	fileSaveAs (PartOfMap);
  2.3924  }
  2.3925  
  2.3926 +void Main::editDeleteKeepChilds()
  2.3927 +{
  2.3928 +	if (currentMapEditor())
  2.3929 +		currentMapEditor()->deleteKeepChilds();
  2.3930 +}
  2.3931 +
  2.3932 +void Main::editDeleteChilds()
  2.3933 +{
  2.3934 +	if (currentMapEditor())
  2.3935 +		currentMapEditor()->deleteChilds();
  2.3936 +}
  2.3937 +
  2.3938  void Main::editDeleteSelection()
  2.3939  {
  2.3940 -	if (currentMapEditor())
  2.3941 +	if (currentMapEditor() && actionSettingsUseDelKey->isOn())
  2.3942  		currentMapEditor()->deleteSelection();
  2.3943  }
  2.3944  
  2.3945 @@ -1921,25 +3064,31 @@
  2.3946  		currentMapEditor()->loadFloatImage();
  2.3947  }
  2.3948  
  2.3949 -void Main::editSaveImage(int item)
  2.3950 +void Main::editSaveImage()
  2.3951  {
  2.3952  	if (currentMapEditor())
  2.3953 -		currentMapEditor()->saveFloatImage(item);
  2.3954 +		currentMapEditor()->saveFloatImage();
  2.3955  }
  2.3956  
  2.3957 -void Main::editToggleFloatExport()
  2.3958 +void Main::editFollowXLink(QAction *a)
  2.3959 +{
  2.3960 +
  2.3961 +	if (currentMapEditor())
  2.3962 +		currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
  2.3963 +}
  2.3964 +
  2.3965 +void Main::editEditXLink(QAction *a)
  2.3966  {
  2.3967  	if (currentMapEditor())
  2.3968 -		currentMapEditor()->toggleFloatExport();
  2.3969 +		currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
  2.3970  }
  2.3971  
  2.3972  void Main::formatSelectColor()
  2.3973  {
  2.3974  	if (currentMapEditor())
  2.3975  	{
  2.3976 -		QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
  2.3977 +		QColor col = QColorDialog::getColor((currentColor ), this );
  2.3978  		if ( !col.isValid() ) return;
  2.3979 -		currentMapEditor()->setColor( col );
  2.3980  		colorChanged( col );
  2.3981  	}	
  2.3982  }
  2.3983 @@ -1947,7 +3096,7 @@
  2.3984  void Main::formatPickColor()
  2.3985  {
  2.3986  	if (currentMapEditor())
  2.3987 -		colorChanged( currentMapEditor()->pickColor() );
  2.3988 +		colorChanged( currentMapEditor()->getCurrentHeadingColor() );
  2.3989  }
  2.3990  
  2.3991  void Main::colorChanged(QColor c)
  2.3992 @@ -1955,82 +3104,100 @@
  2.3993      QPixmap pix( 16, 16 );
  2.3994      pix.fill( c );
  2.3995      actionFormatColor->setIconSet( pix );
  2.3996 -}
  2.3997 -
  2.3998 -void Main::formatColorItem()
  2.3999 -{
  2.4000 -	if (currentMapEditor())
  2.4001 -		currentMapEditor()->colorItem();
  2.4002 +	currentColor=c;
  2.4003  }
  2.4004  
  2.4005  void Main::formatColorBranch()
  2.4006  {
  2.4007  	if (currentMapEditor())
  2.4008 -		currentMapEditor()->colorBranch();
  2.4009 +		currentMapEditor()->colorBranch(currentColor);
  2.4010 +}
  2.4011 +
  2.4012 +void Main::formatColorSubtree()
  2.4013 +{
  2.4014 +	if (currentMapEditor())
  2.4015 +		currentMapEditor()->colorSubtree (currentColor);
  2.4016  }
  2.4017  
  2.4018  void Main::formatLinkStyleLine()
  2.4019  {
  2.4020  	if (currentMapEditor())
  2.4021 -		currentMapEditor()->setLinkStyle(StyleLine);
  2.4022 +    {
  2.4023 +		currentMapEditor()->setMapLinkStyle("StyleLine");
  2.4024 +        actionFormatLinkStyleLine->setOn(true);
  2.4025 +    }
  2.4026  }
  2.4027  
  2.4028  void Main::formatLinkStyleParabel()
  2.4029  {
  2.4030  	if (currentMapEditor())
  2.4031 -		currentMapEditor()->setLinkStyle(StyleParabel);
  2.4032 +    {
  2.4033 +		currentMapEditor()->setMapLinkStyle("StyleParabel");
  2.4034 +        actionFormatLinkStyleParabel->setOn(true);
  2.4035 +    }
  2.4036  }
  2.4037  
  2.4038  void Main::formatLinkStylePolyLine()
  2.4039  {
  2.4040  	if (currentMapEditor())
  2.4041 -		currentMapEditor()->setLinkStyle(StylePolyLine);
  2.4042 +    {
  2.4043 +		currentMapEditor()->setMapLinkStyle("StylePolyLine");
  2.4044 +        actionFormatLinkStylePolyLine->setOn(true);
  2.4045 +    }
  2.4046  }
  2.4047  
  2.4048  void Main::formatLinkStylePolyParabel()
  2.4049  {
  2.4050  	if (currentMapEditor())
  2.4051 -		currentMapEditor()->setLinkStyle(StylePolyParabel);
  2.4052 +    {
  2.4053 +		currentMapEditor()->setMapLinkStyle("StylePolyParabel");
  2.4054 +        actionFormatLinkStylePolyParabel->setOn(true);
  2.4055 +    }
  2.4056  }
  2.4057  
  2.4058  void Main::formatSelectBackColor()
  2.4059  {
  2.4060  	if (currentMapEditor())
  2.4061 -		currentMapEditor()->selectBackgroundColor();
  2.4062 +		currentMapEditor()->selectMapBackgroundColor();
  2.4063 +}
  2.4064 +
  2.4065 +void Main::formatSelectBackImage()
  2.4066 +{
  2.4067 +	if (currentMapEditor())
  2.4068 +		currentMapEditor()->selectMapBackgroundImage();
  2.4069  }
  2.4070  
  2.4071  void Main::formatSelectLinkColor()
  2.4072  {
  2.4073  	if (currentMapEditor())
  2.4074 -		currentMapEditor()->selectLinkColor();
  2.4075 +		currentMapEditor()->selectMapLinkColor();
  2.4076 +}
  2.4077 +
  2.4078 +void Main::formatSelectSelectionColor()
  2.4079 +{
  2.4080 +	if (currentMapEditor())
  2.4081 +		currentMapEditor()->selectMapSelectionColor();
  2.4082  }
  2.4083  
  2.4084  void Main::formatToggleLinkColorHint()
  2.4085  {
  2.4086 -	currentMapEditor()->toggleLinkColorHint();
  2.4087 +	currentMapEditor()->toggleMapLinkColorHint();
  2.4088  }
  2.4089  
  2.4090 -void Main::formatFrameNone()
  2.4091 +
  2.4092 +void Main::formatHideLinkUnselected()	//FIXME get rid of this with imagepropertydialog
  2.4093  {
  2.4094  	if (currentMapEditor())
  2.4095 -		currentMapEditor()->setFrame(NoFrame);
  2.4096 -}
  2.4097 -
  2.4098 -void Main::formatFrameRectangle()
  2.4099 -{
  2.4100 -	if (currentMapEditor())
  2.4101 -		currentMapEditor()->setFrame(Rectangle);
  2.4102 +		currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
  2.4103  }
  2.4104  
  2.4105  void Main::viewZoomReset()
  2.4106  {
  2.4107  	if (currentMapEditor())
  2.4108  	{
  2.4109 -		QWMatrix m;
  2.4110 +		QMatrix m;
  2.4111  		m.reset();
  2.4112 -		currentMapEditor()->setWorldMatrix( m );
  2.4113 -		currentMapEditor()->setViewCenter();
  2.4114 -		currentMapEditor()->adjustCanvasSize();
  2.4115 +		currentMapEditor()->setMatrix( m );
  2.4116  	}	
  2.4117  }
  2.4118  
  2.4119 @@ -2038,11 +3205,9 @@
  2.4120  {
  2.4121  	if (currentMapEditor())
  2.4122  	{
  2.4123 -		QWMatrix m = currentMapEditor()->worldMatrix();
  2.4124 +		QMatrix m = currentMapEditor()->matrix();
  2.4125  		m.scale( 1.25, 1.25 );
  2.4126 -		currentMapEditor()->setWorldMatrix( m );
  2.4127 -		currentMapEditor()->setViewCenter();
  2.4128 -		currentMapEditor()->adjustCanvasSize();
  2.4129 +		currentMapEditor()->setMatrix( m );
  2.4130  	}	
  2.4131  }
  2.4132  
  2.4133 @@ -2050,22 +3215,42 @@
  2.4134  {
  2.4135  	if (currentMapEditor())
  2.4136  	{
  2.4137 -		QWMatrix m = currentMapEditor()->worldMatrix();
  2.4138 +		QMatrix m = currentMapEditor()->matrix();
  2.4139  		m.scale( 0.8, 0.8 );
  2.4140 -		currentMapEditor()->setWorldMatrix( m );
  2.4141 -		currentMapEditor()->setViewCenter();
  2.4142 -		currentMapEditor()->adjustCanvasSize();
  2.4143 +		currentMapEditor()->setMatrix( m );
  2.4144  	}	
  2.4145  }
  2.4146 +
  2.4147 +void Main::viewCenter()
  2.4148 +{
  2.4149 +	MapEditor *me=currentMapEditor();
  2.4150 +	if (me)
  2.4151 +	{
  2.4152 +		me->ensureSelectionVisible();
  2.4153 +	}	
  2.4154 +}
  2.4155 +
  2.4156 +void Main::networkStartServer()
  2.4157 +{
  2.4158 +	MapEditor *me=currentMapEditor();
  2.4159 +	if (me) me->newServer();
  2.4160 +}
  2.4161 +
  2.4162 +void Main::networkConnect()
  2.4163 +{
  2.4164 +	MapEditor *me=currentMapEditor();
  2.4165 +	if (me) me->connectToServer();
  2.4166 +}
  2.4167 +
  2.4168  bool Main::settingsPDF()
  2.4169  {
  2.4170  	// Default browser is set in constructor
  2.4171  	bool ok;
  2.4172  	QString text = QInputDialog::getText(
  2.4173 -		"VYM", tr("Enter path for pdf reader:"), QLineEdit::Normal,
  2.4174 -		settings.readEntry("/vym/mainwindow/readerPDF"), &ok, this );
  2.4175 +		"VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
  2.4176 +		settings.value("/mainwindow/readerPDF").toString(), &ok, this );
  2.4177  	if (ok)
  2.4178 -		settings.writeEntry ("/vym/mainwindow/readerPDF",text);
  2.4179 +		settings.setValue ("/mainwindow/readerPDF",text);
  2.4180  	return ok;
  2.4181  }
  2.4182  
  2.4183 @@ -2075,20 +3260,364 @@
  2.4184  	// Default browser is set in constructor
  2.4185  	bool ok;
  2.4186  	QString text = QInputDialog::getText(
  2.4187 -		"VYM", tr("Enter path for application to open an URL:"), QLineEdit::Normal,
  2.4188 -		settings.readEntry("/vym/mainwindow/readerURL")
  2.4189 +		"VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
  2.4190 +		settings.value("/mainwindow/readerURL").toString()
  2.4191  		, &ok, this );
  2.4192  	if (ok)
  2.4193 -		settings.writeEntry ("/vym/mainwindow/readerURL",text);
  2.4194 +		settings.setValue ("/mainwindow/readerURL",text);
  2.4195  	return ok;
  2.4196  }
  2.4197  
  2.4198 +void Main::settingsMacroDir()
  2.4199 +{
  2.4200 +	QDir defdir(vymBaseDir.path() + "/macros");
  2.4201 +	if (!defdir.exists())
  2.4202 +		defdir=vymBaseDir;
  2.4203 +	QDir dir=QFileDialog::getExistingDirectory (
  2.4204 +		this,
  2.4205 +		tr ("Directory with vym macros:"), 
  2.4206 +		settings.value ("/macros/macroDir",defdir.path()).toString()
  2.4207 +	);
  2.4208 +	if (dir.exists())
  2.4209 +		settings.setValue ("/macros/macroDir",dir.absolutePath());
  2.4210 +}
  2.4211 +
  2.4212 +void Main::settingsUndoLevels()
  2.4213 +{
  2.4214 +	bool ok;
  2.4215 +	int i = QInputDialog::getInteger(
  2.4216 +		this, 
  2.4217 +		tr("QInputDialog::getInteger()"),
  2.4218 +	    tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
  2.4219 +	if (ok)
  2.4220 +	{
  2.4221 +		settings.setValue ("/mapeditor/stepsTotal",i);
  2.4222 +		QMessageBox::information( this, tr( "VYM -Information:" ),
  2.4223 +		   tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i)); 
  2.4224 +   }	
  2.4225 +}
  2.4226 +
  2.4227 +void Main::settingsAutosaveToggle()
  2.4228 +{
  2.4229 +	settings.setValue ("/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
  2.4230 +}
  2.4231 +
  2.4232 +void Main::settingsAutosaveTime()
  2.4233 +{
  2.4234 +	bool ok;
  2.4235 +	int i = QInputDialog::getInteger(
  2.4236 +		this, 
  2.4237 +		tr("QInputDialog::getInteger()"),
  2.4238 +	    tr("Number of seconds before autosave:"), settings.value("/mainwindow/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
  2.4239 +	if (ok)
  2.4240 +		settings.setValue ("/mainwindow/autosave/ms",i * 1000);
  2.4241 +}
  2.4242 +
  2.4243 +void Main::settingsWriteBackupFileToggle()
  2.4244 +{
  2.4245 +	settings.setValue ("/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
  2.4246 +}
  2.4247 +
  2.4248 +void Main::settingsToggleAnimation()
  2.4249 +{
  2.4250 +	settings.setValue ("/animation/use",actionSettingsUseAnimation->isOn() );
  2.4251 +}
  2.4252 +
  2.4253 +void Main::settingsToggleDelKey()
  2.4254 +{
  2.4255 +	if (actionSettingsUseDelKey->isOn())
  2.4256 +	{
  2.4257 +		actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
  2.4258 +	} else
  2.4259 +	{
  2.4260 +		actionEditDelete->setAccel (QKeySequence (""));
  2.4261 +	}
  2.4262 +}
  2.4263 +
  2.4264  void Main::windowToggleNoteEditor()
  2.4265  {
  2.4266 -	if (textEditor->showWithMain() )
  2.4267 +	if (textEditor->isVisible() )
  2.4268  		windowHideNoteEditor();
  2.4269 +	else
  2.4270 +		windowShowNoteEditor();
  2.4271 +}
  2.4272 +
  2.4273 +void Main::windowToggleHistory()
  2.4274 +{
  2.4275 +	if (historyWindow->isVisible())
  2.4276 +		historyWindow->hide();
  2.4277  	else	
  2.4278 -		windowShowNoteEditor();
  2.4279 +		historyWindow->show();
  2.4280 +
  2.4281 +}
  2.4282 +
  2.4283 +void Main::windowToggleProperty()
  2.4284 +{
  2.4285 +	if (branchPropertyWindow->isVisible())
  2.4286 +		branchPropertyWindow->hide();
  2.4287 +	else	
  2.4288 +		branchPropertyWindow->show();
  2.4289 +
  2.4290 +	if(currentMapEditor())
  2.4291 +	{
  2.4292 +		BranchObj *bo=currentMapEditor()->getSelectedBranch();
  2.4293 +		if (bo) 
  2.4294 +		{
  2.4295 +			branchPropertyWindow->setMapEditor(currentMapEditor());
  2.4296 +			branchPropertyWindow->setBranch(bo);
  2.4297 +			return;
  2.4298 +		}
  2.4299 +		
  2.4300 +	}	
  2.4301 +	branchPropertyWindow->setBranch(NULL);
  2.4302 +}
  2.4303 +
  2.4304 +void Main::windowToggleAntiAlias()
  2.4305 +{
  2.4306 +	bool b=actionViewToggleAntiAlias->isOn();
  2.4307 +	MapEditor *me;
  2.4308 +	for (int i=0;i<tabWidget->count();i++)
  2.4309 +	{
  2.4310 +		
  2.4311 +		me=(MapEditor*)tabWidget->page(i);
  2.4312 +		me->setAntiAlias(b);
  2.4313 +	}	
  2.4314 +
  2.4315 +}
  2.4316 +
  2.4317 +void Main::windowToggleSmoothPixmap()
  2.4318 +{
  2.4319 +	bool b=actionViewToggleSmoothPixmapTransform->isOn();
  2.4320 +	MapEditor *me;
  2.4321 +	for (int i=0;i<tabWidget->count();i++)
  2.4322 +	{
  2.4323 +		
  2.4324 +		me=(MapEditor*)tabWidget->page(i);
  2.4325 +		me->setSmoothPixmap(b);
  2.4326 +	}	
  2.4327 +}
  2.4328 +
  2.4329 +void Main::updateHistory(SimpleSettings &undoSet)
  2.4330 +{
  2.4331 +	historyWindow->update (undoSet);
  2.4332 +}
  2.4333 +
  2.4334 +void Main::updateNoteFlag()
  2.4335 +{
  2.4336 +	if (currentMapEditor())
  2.4337 +		currentMapEditor()->updateNoteFlag();
  2.4338 +}
  2.4339 +
  2.4340 +void Main::updateSatellites(MapEditor *me)
  2.4341 +{
  2.4342 +	branchPropertyWindow->setMapEditor (me);
  2.4343 +}
  2.4344 +
  2.4345 +void Main::updateActions()
  2.4346 +{
  2.4347 +	MapEditor *me=currentMapEditor();
  2.4348 +	if (!me) return;
  2.4349 +
  2.4350 +	historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(currentMapEditor()->getFileName()));
  2.4351 +
  2.4352 +	// updateActions is also called when NoteEditor is closed
  2.4353 +	actionViewToggleNoteEditor->setOn (textEditor->isVisible());
  2.4354 +	actionViewToggleHistoryWindow->setOn (historyWindow->isVisible());
  2.4355 +	actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible());
  2.4356 +
  2.4357 +	if (me->getMapLinkColorHint()==LinkableMapObj::HeadingColor) 
  2.4358 +		actionFormatLinkColorHint->setOn(true);
  2.4359 +	else	
  2.4360 +		actionFormatLinkColorHint->setOn(false);
  2.4361 +
  2.4362 +	switch (me->getMapLinkStyle())
  2.4363 +	{
  2.4364 +		case LinkableMapObj::Line: 
  2.4365 +			actionFormatLinkStyleLine->setOn(true);
  2.4366 +			break;
  2.4367 +		case LinkableMapObj::Parabel:
  2.4368 +			actionFormatLinkStyleParabel->setOn(true);
  2.4369 +			break;
  2.4370 +		case LinkableMapObj::PolyLine:	
  2.4371 +			actionFormatLinkStylePolyLine->setOn(true);
  2.4372 +			break;
  2.4373 +		case LinkableMapObj::PolyParabel:	
  2.4374 +			actionFormatLinkStylePolyParabel->setOn(true);
  2.4375 +			break;
  2.4376 +		default:
  2.4377 +			break;
  2.4378 +	}	
  2.4379 +
  2.4380 +	// Update colors
  2.4381 +	QPixmap pix( 16, 16 );
  2.4382 +    pix.fill( me->getMapBackgroundColor() );
  2.4383 +    actionFormatBackColor->setIconSet( pix );
  2.4384 +    pix.fill( me->getSelectionColor() );
  2.4385 +    actionFormatSelectionColor->setIconSet( pix );
  2.4386 +    pix.fill( me->getMapDefLinkColor() );
  2.4387 +    actionFormatLinkColor->setIconSet( pix );
  2.4388 +
  2.4389 +
  2.4390 +	actionFileSave->setEnabled( me->hasChanged() );
  2.4391 +	if (me->isUndoAvailable())
  2.4392 +		actionEditUndo->setEnabled( true);
  2.4393 +	else	
  2.4394 +		actionEditUndo->setEnabled( false);
  2.4395 +
  2.4396 +	if (me->isRedoAvailable())
  2.4397 +		actionEditRedo->setEnabled( true);
  2.4398 +	else	
  2.4399 +		actionEditRedo->setEnabled( false);
  2.4400 +
  2.4401 +	LinkableMapObj *selection=me->getSelection();
  2.4402 +	if (selection)
  2.4403 +	{
  2.4404 +		if ( (typeid(*selection) == typeid(BranchObj)) || 
  2.4405 +			(typeid(*selection) == typeid(MapCenterObj))  )
  2.4406 +		{
  2.4407 +			BranchObj *bo=(BranchObj*)selection;
  2.4408 +			// Take care of links
  2.4409 +			if (bo->countXLinks()==0)
  2.4410 +			{
  2.4411 +				branchXLinksContextMenuEdit->clear();
  2.4412 +				branchXLinksContextMenuFollow->clear();
  2.4413 +			} else
  2.4414 +			{
  2.4415 +				BranchObj *bot;
  2.4416 +				QString s;
  2.4417 +				branchXLinksContextMenuEdit->clear();
  2.4418 +				branchXLinksContextMenuFollow->clear();
  2.4419 +				for (int i=0; i<=bo->countXLinks();i++)
  2.4420 +				{
  2.4421 +					bot=bo->XLinkTargetAt(i);
  2.4422 +					if (bot)
  2.4423 +					{
  2.4424 +						s=bot->getHeading();
  2.4425 +						if (s.length()>xLinkMenuWidth)
  2.4426 +							s=s.left(xLinkMenuWidth)+"...";
  2.4427 +						branchXLinksContextMenuFollow->addAction (s);
  2.4428 +						branchXLinksContextMenuEdit->addAction (s);
  2.4429 +					}	
  2.4430 +				}
  2.4431 +			}
  2.4432 +
  2.4433 +			standardFlagsDefault->setEnabled (true);
  2.4434 +
  2.4435 +			actionEditToggleScroll->setEnabled (true);
  2.4436 +			if ( bo->isScrolled() )
  2.4437 +				actionEditToggleScroll->setOn(true);
  2.4438 +			else	
  2.4439 +				actionEditToggleScroll->setOn(false);
  2.4440 +
  2.4441 +			if ( bo->getURL().isEmpty() )
  2.4442 +			{
  2.4443 +				actionEditOpenURL->setEnabled (false);
  2.4444 +				actionEditOpenURLTab->setEnabled (false);
  2.4445 +			}	
  2.4446 +			else	
  2.4447 +			{
  2.4448 +				actionEditOpenURL->setEnabled (true);
  2.4449 +				actionEditOpenURLTab->setEnabled (true);
  2.4450 +			}
  2.4451 +			if ( bo->getVymLink().isEmpty() )
  2.4452 +			{
  2.4453 +				actionEditOpenVymLink->setEnabled (false);
  2.4454 +				actionEditDeleteVymLink->setEnabled (false);
  2.4455 +			} else	
  2.4456 +			{
  2.4457 +				actionEditOpenVymLink->setEnabled (true);
  2.4458 +				actionEditDeleteVymLink->setEnabled (true);
  2.4459 +			}	
  2.4460 +
  2.4461 +			if (bo->canMoveBranchUp()) 
  2.4462 +				actionEditMoveUp->setEnabled (true);
  2.4463 +			else	
  2.4464 +				actionEditMoveUp->setEnabled (false);
  2.4465 +			if (bo->canMoveBranchDown()) 
  2.4466 +				actionEditMoveDown->setEnabled (true);
  2.4467 +			else	
  2.4468 +				actionEditMoveDown->setEnabled (false);
  2.4469 +
  2.4470 +
  2.4471 +			actionEditToggleHideExport->setEnabled (true);	
  2.4472 +			actionEditToggleHideExport->setOn (bo->hideInExport() );	
  2.4473 +
  2.4474 +			actionEditCopy->setEnabled (true);	
  2.4475 +			actionEditCut->setEnabled (true);	
  2.4476 +			if (!clipboardEmpty)
  2.4477 +				actionEditPaste->setEnabled (true);	
  2.4478 +			else	
  2.4479 +				actionEditPaste->setEnabled (false);	
  2.4480 +			for (int i=0; i<actionListBranches.size(); ++i)	
  2.4481 +				actionListBranches.at(i)->setEnabled(true);
  2.4482 +			actionEditDelete->setEnabled (true);
  2.4483 +			actionFormatHideLinkUnselected->setOn
  2.4484 +				(selection->getHideLinkUnselected());
  2.4485 +		}
  2.4486 +		if ( (typeid(*selection) == typeid(FloatImageObj)) )
  2.4487 +		{
  2.4488 +			FloatObj *fo=(FloatImageObj*)selection;
  2.4489 +
  2.4490 +			actionEditOpenURL->setEnabled (false);
  2.4491 +			actionEditOpenVymLink->setEnabled (false);
  2.4492 +			actionEditDeleteVymLink->setEnabled (false);	
  2.4493 +			actionEditToggleHideExport->setEnabled (true);	
  2.4494 +			actionEditToggleHideExport->setOn (fo->hideInExport() );	
  2.4495 +
  2.4496 +
  2.4497 +			actionEditCopy->setEnabled (true);
  2.4498 +			actionEditCut->setEnabled (true);	
  2.4499 +			actionEditPaste->setEnabled (false);
  2.4500 +			for (int i=0; i<actionListBranches.size(); ++i)	
  2.4501 +				actionListBranches.at(i)->setEnabled(false);
  2.4502 +			actionEditDelete->setEnabled (true);
  2.4503 +			actionFormatHideLinkUnselected->setOn
  2.4504 +				( selection->getHideLinkUnselected());
  2.4505 +			actionEditMoveUp->setEnabled (false);
  2.4506 +			actionEditMoveDown->setEnabled (false);
  2.4507 +		}
  2.4508 +
  2.4509 +	} else
  2.4510 +	{
  2.4511 +		actionEditCopy->setEnabled (false);	
  2.4512 +		actionEditCut->setEnabled (false);	
  2.4513 +		actionEditPaste->setEnabled (false);	
  2.4514 +		for (int i=0; i<actionListBranches.size(); ++i)	
  2.4515 +			actionListBranches.at(i)->setEnabled(false);
  2.4516 +
  2.4517 +		actionEditToggleScroll->setEnabled (false);
  2.4518 +		actionEditOpenURL->setEnabled (false);
  2.4519 +		actionEditOpenVymLink->setEnabled (false);
  2.4520 +		actionEditDeleteVymLink->setEnabled (false);	
  2.4521 +		actionEditHeading2URL->setEnabled (false);	
  2.4522 +		actionEditDelete->setEnabled (false);
  2.4523 +		actionEditMoveUp->setEnabled (false);
  2.4524 +		actionEditMoveDown->setEnabled (false);
  2.4525 +		actionEditToggleHideExport->setEnabled (false);	
  2.4526 +	}	
  2.4527 +}
  2.4528 +
  2.4529 +Main::ModMode Main::getModMode()
  2.4530 +{
  2.4531 +	if (actionModModeColor->isOn()) return ModModeColor;
  2.4532 +	if (actionModModeCopy->isOn()) return ModModeCopy;
  2.4533 +	if (actionModModeXLink->isOn()) return ModModeXLink;
  2.4534 +	return ModModeNone;
  2.4535 +}
  2.4536 +
  2.4537 +bool Main::autoEditNewBranch()
  2.4538 +{
  2.4539 +	return actionSettingsAutoEditNewBranch->isOn();
  2.4540 +}
  2.4541 +
  2.4542 +bool Main::autoSelectNewBranch()
  2.4543 +{
  2.4544 +	return actionSettingsAutoSelectNewBranch->isOn();
  2.4545 +}
  2.4546 +
  2.4547 +bool Main::useFlagGroups()
  2.4548 +{
  2.4549 +	return actionSettingsUseFlagGroups->isOn();
  2.4550  }
  2.4551  
  2.4552  void Main::windowShowNoteEditor()
  2.4553 @@ -2105,6 +3634,27 @@
  2.4554  	actionViewToggleNoteEditor->setOn (false);
  2.4555  }
  2.4556  
  2.4557 +void Main::setScript (const QString &script)
  2.4558 +{
  2.4559 +	scriptEditor->setScript (script);
  2.4560 +}
  2.4561 +
  2.4562 +void Main::runScript (const QString &script)
  2.4563 +{
  2.4564 +	if (currentMapEditor())
  2.4565 +		currentMapEditor()->runScript (script);
  2.4566 +}
  2.4567 +
  2.4568 +void Main::runScriptEverywhere (const QString &script)
  2.4569 +{
  2.4570 +	MapEditor *me;
  2.4571 +	for (int i=0;i<=tabWidget->count() -1;i++)
  2.4572 +	{
  2.4573 +		me=(MapEditor*)tabWidget->page(i);
  2.4574 +		if (me) me->runScript (script);
  2.4575 +	}	
  2.4576 +}
  2.4577 +
  2.4578  void Main::windowNextEditor()
  2.4579  {
  2.4580  	if (tabWidget->currentPageIndex() < tabWidget->count())
  2.4581 @@ -2119,91 +3669,142 @@
  2.4582  
  2.4583  void Main::standardFlagChanged()
  2.4584  {
  2.4585 -	currentMapEditor()->toggleStandardFlag(sender()->name());
  2.4586 +	if (currentMapEditor())
  2.4587 +		currentMapEditor()->toggleStandardFlag(sender()->name());
  2.4588  }
  2.4589  
  2.4590 -void Main::testFunction()
  2.4591 +void Main::testFunction1()
  2.4592  {
  2.4593 -	//textEditor->stackUnder(this);
  2.4594 -	currentMapEditor()->testFunction();
  2.4595 +	if (!currentMapEditor()) return;
  2.4596 +	currentMapEditor()->testFunction1();
  2.4597 +	//editAttribute();
  2.4598  }
  2.4599  
  2.4600 -void Main::testShowClipboard()
  2.4601 +void Main::testFunction2()
  2.4602  {
  2.4603 -	clipboardME->show();
  2.4604 +	if (!currentMapEditor()) return;
  2.4605 +	currentMapEditor()->testFunction2();
  2.4606 +}
  2.4607 +
  2.4608 +void Main::testCommand()
  2.4609 +{
  2.4610 +	if (!currentMapEditor()) return;
  2.4611 +	scriptEditor->show();
  2.4612 +	/*
  2.4613 +	bool ok;
  2.4614 +	QString com = QInputDialog::getText(
  2.4615 +			vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
  2.4616 +	if (ok) currentMapEditor()->parseAtom(com);
  2.4617 +	*/
  2.4618  }
  2.4619  
  2.4620  void Main::helpDoc()
  2.4621  {
  2.4622 -	QString docpath;
  2.4623 -	// default path in SUSE LINUX
  2.4624 -	docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
  2.4625 -
  2.4626 -	if (!QFile (docpath).exists() )
  2.4627 +	QString locale = QLocale::system().name();
  2.4628 +	QString docname;
  2.4629 +	if (locale.left(2)=="es")
  2.4630 +		docname="vym_es.pdf";
  2.4631 +	else	
  2.4632 +		docname="vym.pdf";
  2.4633 +
  2.4634 +	QStringList searchList;
  2.4635 +	QDir docdir;
  2.4636 +	#if defined(Q_OS_MACX)
  2.4637 +		searchList << "./vym.app/Contents/Resources/doc";
  2.4638 +    #elif defined(Q_OS_WIN32)
  2.4639 +        searchList << vymInstallDir.path() + "/share/doc/packages/vym";
  2.4640 +	#else
  2.4641 +		#if defined(VYM_DOCDIR)
  2.4642 +			searchList << VYM_DOCDIR;
  2.4643 +		#endif
  2.4644 +		// default path in SUSE LINUX
  2.4645 +		searchList << "/usr/share/doc/packages/vym";
  2.4646 +	#endif
  2.4647 +
  2.4648 +	searchList << "doc";	// relative path for easy testing in tarball
  2.4649 +	searchList << "doc/tex";	// Easy testing working on vym.tex
  2.4650 +	searchList << "/usr/share/doc/vym";	// Debian
  2.4651 +	searchList << "/usr/share/doc/packages";// Knoppix
  2.4652 +
  2.4653 +	bool found=false;
  2.4654 +	QFile docfile;
  2.4655 +	for (int i=0; i<searchList.count(); ++i)
  2.4656  	{
  2.4657 -		// relative path for easy testing in tarball
  2.4658 -		docpath="doc/vym.pdf";
  2.4659 -		if (!QFile (docpath).exists() )
  2.4660 +		docfile.setFileName(searchList.at(i)+"/"+docname);
  2.4661 +		if (docfile.exists())
  2.4662  		{
  2.4663 -			// relative path for testing while still writing vym.tex
  2.4664 -			docpath="doc/tex/vym.pdf";
  2.4665 -			if (!QFile (docpath).exists() )
  2.4666 -			{
  2.4667 -				QMessageBox::critical(0, 
  2.4668 -				tr("Critcal error"),
  2.4669 -				tr("Couldn't find the documentation\n"
  2.4670 -				"vym.pdf in various places."));
  2.4671 -				return;
  2.4672 -			}	
  2.4673 -		}
  2.4674 +			found=true;
  2.4675 +			break;
  2.4676 +		}	
  2.4677  	}
  2.4678 -	
  2.4679 +
  2.4680 +	if (!found)
  2.4681 +	{
  2.4682 +		QMessageBox::critical(0, 
  2.4683 +			tr("Critcal error"),
  2.4684 +			tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
  2.4685 +		return;
  2.4686 +	}	
  2.4687 +
  2.4688 +	QStringList args;
  2.4689  	Process *pdfProc = new Process();
  2.4690 -	pdfProc->clearArguments();
  2.4691 -	pdfProc->addArgument( settings.readEntry("/vym/mainwindow/readerPDF"));
  2.4692 -	pdfProc->addArgument( docpath);
  2.4693 -
  2.4694 -	if ( !pdfProc->start() ) 
  2.4695 +    args << QDir::toNativeSeparators(docfile.fileName());
  2.4696 +
  2.4697 +	pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
  2.4698 +	if ( !pdfProc->waitForStarted() ) 
  2.4699  	{
  2.4700  		// error handling
  2.4701 -		QMessageBox::critical(0, 
  2.4702 -		tr("Critcal error"),
  2.4703 -		tr("Couldn't find a viewer to read vym.pdf.\n"
  2.4704 -		"Please use Settings->")+tr("Set application to open pdf files"));
  2.4705 +		QMessageBox::warning(0, 
  2.4706 +			tr("Warning"),
  2.4707 +			tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
  2.4708 +			tr("Please use Settings->")+tr("Set application to open PDF files"));
  2.4709 +		settingsPDF();	
  2.4710  		return;
  2.4711  	}
  2.4712  }
  2.4713  
  2.4714  
  2.4715 +void Main::helpDemo()
  2.4716 +{
  2.4717 +	QStringList filters;
  2.4718 +	filters <<"VYM example map (*.vym)";
  2.4719 +	QFileDialog *fd=new QFileDialog( this);
  2.4720 +	#if defined(Q_OS_MACX)
  2.4721 +		fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
  2.4722 +	#else
  2.4723 +		// default path in SUSE LINUX
  2.4724 +		fd->setDir (QDir(vymBaseDir.path()+"/demos"));
  2.4725 +	#endif
  2.4726 +
  2.4727 +	fd->setFileMode (QFileDialog::ExistingFiles);
  2.4728 +	fd->setFilters (filters);
  2.4729 +	fd->setCaption(vymName+ " - " +tr("Load vym example map"));
  2.4730 +	fd->show();
  2.4731 +
  2.4732 +	QString fn;
  2.4733 +	if ( fd->exec() == QDialog::Accepted )
  2.4734 +	{
  2.4735 +		lastFileDir=fd->directory().path();
  2.4736 +	    QStringList flist = fd->selectedFiles();
  2.4737 +		QStringList::Iterator it = flist.begin();
  2.4738 +		while( it != flist.end() ) 
  2.4739 +		{
  2.4740 +			fn = *it;
  2.4741 +			fileLoad(*it, NewMap);				   
  2.4742 +			++it;
  2.4743 +		}
  2.4744 +	}
  2.4745 +	delete (fd);
  2.4746 +}
  2.4747 +
  2.4748 +
  2.4749  void Main::helpAbout()
  2.4750  {
  2.4751 -    static QMessageBox* about = new QMessageBox( "VYM",
  2.4752 -			"<h3>VYM - View Your Mind </h3>"
  2.4753 -			"<p> A tool to put the things you have got in your mind into a map.</p>"
  2.4754 -			"<ul>"
  2.4755 -				"<li> (c) by Uwe Drechsel (vym@InSilmaril.de)</li>"
  2.4756 -				"<li> vym is released under the GPL (Gnu General Public License)"
  2.4757 -				", with one exception (see the file \"LICENSE\"which "
  2.4758 -				"comes with vym). This exception is needed to build vym with QT libraries for proprietary operating systems.</li>"
  2.4759 -				"<li> Project homepage <a href=\"http:/www.InSilmaril.de/vym\">"
  2.4760 -    					"http:/www.InSilmaril.de/vym</a></li>"
  2.4761 -			"<li> Credits " 
  2.4762 -				"<ul>"
  2.4763 -					"<li>Thomas Schraitle for the stylesheet  used for XHTML-export </li>"
  2.4764 -					"<li>Clemens Kraus for stylesheets and script used for HTML-export "
  2.4765 -					"<a href=\"http://www.clemens-kraus.de\">(www.clemens-kraus.de)</a></li>"
  2.4766 -					"<li>Alexander Johannesen for providing stylesheets from his xsiteable project " 
  2.4767 -					"<a href=\"http://www.shelter.nu/xsiteable/xsiteable.html\">(www.shelter.nu/xsiteable/xsiteable.html)</a>. </li>"
  2.4768 -					"<li>Ken Wimer and Olaf Hering for Mac support</li>"
  2.4769 -				"</ul>"
  2.4770 -			"</li>"
  2.4771 -			"<li> Version "  __VYM_VERSION__  "</li>"
  2.4772 -				"<li> Build date "  __BUILD_DATE__"</li>"
  2.4773 -			"</ul>", QMessageBox::Information, 1, 0, 0, this, 0, FALSE );
  2.4774 -    about->setButtonText( 1, "Dismiss" );
  2.4775 -    about->setMinimumSize(QSize(300,300));
  2.4776 -	about->setIconPixmap (QPixmap(vym_logo_xpm));
  2.4777 -    about->show();
  2.4778 +	AboutDialog ad;
  2.4779 +	ad.setName ("aboutwindow");
  2.4780 +	ad.setMinimumSize(500,500);
  2.4781 +	ad.resize (QSize (500,500));
  2.4782 +	ad.exec();
  2.4783  }
  2.4784  
  2.4785  void Main::helpAboutQT()
  2.4786 @@ -2211,3 +3812,62 @@
  2.4787  	QMessageBox::aboutQt( this, "Qt Application Example" );
  2.4788  }
  2.4789  
  2.4790 +void Main::callMacro ()
  2.4791 +{
  2.4792 +    QAction *action = qobject_cast<QAction *>(sender());
  2.4793 +	int i=-1;
  2.4794 +    if (action)
  2.4795 +	{
  2.4796 +        i=action->data().toInt();
  2.4797 +		QString mDir (settings.value ("macros/macroDir").toString() );
  2.4798 +
  2.4799 +		QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
  2.4800 +		QFile f (fn);
  2.4801 +		if ( !f.open( QIODevice::ReadOnly ) )
  2.4802 +		{
  2.4803 +			QMessageBox::warning(0, 
  2.4804 +				tr("Warning"),
  2.4805 +				tr("Couldn't find a macro at  %1.\n").arg(fn)+
  2.4806 +				tr("Please use Settings->")+tr("Set directory for vym macros"));
  2.4807 +			return;
  2.4808 +		}	
  2.4809 +
  2.4810 +		QTextStream ts( &f );
  2.4811 +		QString m= ts.read();
  2.4812 +
  2.4813 +		if (! m.isEmpty())
  2.4814 +		{
  2.4815 +			//cout <<"Main::callMacro  m="<<qPrintable (m)<<endl;
  2.4816 +			currentMapEditor()->runScript (m);
  2.4817 +		}	
  2.4818 +	}	
  2.4819 +}
  2.4820 +
  2.4821 +
  2.4822 +
  2.4823 +//////////////////////////////////
  2.4824 +/*
  2.4825 +@@ -2544,18 +2576,27 @@
  2.4826 + 				// Try to open new tab in existing konqueror started previously by vym
  2.4827 + 				p=new QProcess (this);
  2.4828 + 				args.clear();
  2.4829 +-				args<< QString("konqueror-%1").arg(procBrowser->pid())<< 
  2.4830 +-					"konqueror-mainwindow#1"<< 
  2.4831 +-					"newTab" << 
  2.4832 ++#if defined(Q_OS_WIN32)
  2.4833 ++                // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
  2.4834 ++                // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
  2.4835 ++				args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
  2.4836 ++					"konqueror-mainwindow#1"<<
  2.4837 ++					"newTab" <<
  2.4838 + 					urls.at(i);
  2.4839 ++#else
  2.4840 ++				args<< QString("konqueror-%1").arg(procBrowser->pid())<<
  2.4841 ++					"konqueror-mainwindow#1"<<
  2.4842 ++					"newTab" <<
  2.4843 ++					urls.at(i);
  2.4844 ++#endif
  2.4845 + 				p->start ("dcop",args);
  2.4846 + 				if ( !p->waitForStarted() ) success=false;
  2.4847 + 			}
  2.4848 +*/			
     3.1 --- a/mapeditor.cpp	Thu Mar 05 09:33:30 2009 +0000
     3.2 +++ b/mapeditor.cpp	Tue Mar 10 11:27:17 2009 +0000
     3.3 @@ -185,9 +185,9 @@
     3.4  
     3.5  MapEditor::~MapEditor()
     3.6  {
     3.7 -	//cout <<"Destructor MapEditor\n";
     3.8 -	autosaveTimer->stop();
     3.9 +	//cout <<"Destructor MapEditor "<<mapName.toStdString()<<endl;
    3.10  	fileChangedTimer->stop();
    3.11 +	clear();
    3.12  
    3.13  	// tmpMapDir is in tmpVymDir, so it gets removed automagically when vym closes
    3.14  	
    3.15 @@ -1847,7 +1847,7 @@
    3.16  
    3.17  	// FIXME trying to debug save problem
    3.18  	if (saveFile.length()<1000)
    3.19 -		QMessageBox::critical (0,"Critical error in MapEditor::save",QString("saveFile is too small:\n%1").arg(saveFile));
    3.20 +		QMessageBox::critical (0,"Critical error in MapEditor::save",QString("saveFile is too small, try make a backup NOW\nof your original file\nbefore vym writes to\"%1\":\n%2").arg(mapName).arg(saveFile));
    3.21  	if (!saveStringToDisk(fileDir+mapFileName,saveFile))
    3.22  	{
    3.23  		err=aborted;
    3.24 @@ -2169,7 +2169,9 @@
    3.25  
    3.26  void MapEditor::clear()
    3.27  {
    3.28 -	xelection.unselect();
    3.29 +	//cout << "ME::clear() "<<mapName.toStdString()<<endl;
    3.30 +	xelection.clear();
    3.31 +	autosaveTimer->stop();
    3.32  	model->clear();
    3.33  }
    3.34  
     4.1 --- a/tex/vym.changelog	Thu Mar 05 09:33:30 2009 +0000
     4.2 +++ b/tex/vym.changelog	Tue Mar 10 11:27:17 2009 +0000
     4.3 @@ -1,3 +1,10 @@
     4.4 +-------------------------------------------------------------------
     4.5 +Tue Mar 10 12:23:21 CET 2009 - uwedr@suse.de
     4.6 +
     4.7 +- Bugfix: Closing a modified map without saving and with autosave
     4.8 +		   enabled made autosave writing an empty map and thus
     4.9 +		   destroying the original file 
    4.10 +
    4.11  -------------------------------------------------------------------
    4.12  Wed Feb 25 13:43:28 CET 2009 - uwedr@suse.de
    4.13  
     5.1 --- a/version.h	Thu Mar 05 09:33:30 2009 +0000
     5.2 +++ b/version.h	Tue Mar 10 11:27:17 2009 +0000
     5.3 @@ -4,10 +4,10 @@
     5.4  #include <QString>
     5.5  
     5.6  #define __VYM_NAME "VYM"
     5.7 -#define __VYM_VERSION "1.12.2d"
     5.8 -//#define __VYM_CODENAME "Maintenance Update "
     5.9 -#define __VYM_CODENAME "Codename: development version"
    5.10 -#define __VYM_BUILD_DATE "2009-03-04"
    5.11 +#define __VYM_VERSION "1.12.2e"
    5.12 +#define __VYM_CODENAME "Maintenance Update "
    5.13 +//#define __VYM_CODENAME "Codename: development version"
    5.14 +#define __VYM_BUILD_DATE "2009-03-10"
    5.15  
    5.16  
    5.17  bool checkVersion(const QString &);
     6.1 --- a/vymmodel.cpp	Thu Mar 05 09:33:30 2009 +0000
     6.2 +++ b/vymmodel.cpp	Tue Mar 10 11:27:17 2009 +0000
     6.3 @@ -15,7 +15,8 @@
     6.4  
     6.5  VymModel::~VymModel() 
     6.6  {
     6.7 -//    cout << "Destr VymModel\n";
     6.8 +    //cout << "Destr VymModel\n";
     6.9 +	clear();
    6.10  }	
    6.11  
    6.12  void VymModel::clear()