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