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