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