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