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