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