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