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