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