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