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