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