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