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