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