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