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