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