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