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