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