mainwindow.cpp
author insilmaril
Fri, 09 Apr 2010 14:16:02 +0000
changeset 845 b98c1793bb8b
parent 844 c48bb42fb977
child 847 43268373032d
permissions -rw-r--r--
XHTML export obsoleted by HTML export
insilmaril@0
     1
#include "mainwindow.h"
insilmaril@0
     2
insilmaril@366
     3
#include <QtGui>
insilmaril@390
     4
insilmaril@0
     5
#include <iostream>
insilmaril@611
     6
#include <typeinfo>
insilmaril@0
     7
insilmaril@205
     8
#include "aboutdialog.h"
insilmaril@421
     9
#include "branchpropwindow.h"
insilmaril@749
    10
#include "branchitem.h"
insilmaril@205
    11
#include "exportoofiledialog.h"
insilmaril@228
    12
#include "exports.h"
insilmaril@205
    13
#include "file.h"
insilmaril@825
    14
#include "findresultwidget.h"
insilmaril@829
    15
#include "findwidget.h"
insilmaril@767
    16
#include "flagrow.h"
insilmaril@377
    17
#include "historywindow.h"
insilmaril@205
    18
#include "imports.h"
insilmaril@0
    19
#include "mapeditor.h"
insilmaril@205
    20
#include "misc.h"
insilmaril@205
    21
#include "options.h"
insilmaril@0
    22
#include "process.h"
insilmaril@0
    23
#include "settings.h"
insilmaril@804
    24
#include "shortcuts.h"
insilmaril@205
    25
#include "texteditor.h"
insilmaril@842
    26
#include "treeeditor.h"
insilmaril@442
    27
#include "warningdialog.h"
insilmaril@790
    28
#include "xlinkitem.h"
insilmaril@0
    29
insilmaril@816
    30
//#include <modeltest.h>	// FIXME-3
insilmaril@791
    31
insilmaril@608
    32
#if defined(Q_OS_WIN32)
insilmaril@608
    33
// Define only this structure as opposed to
insilmaril@608
    34
// including full 'windows.h'. FindWindow
insilmaril@608
    35
// clashes with the one in Win32 API.
insilmaril@608
    36
typedef struct _PROCESS_INFORMATION
insilmaril@608
    37
{
insilmaril@808
    38
	long hProcess;
insilmaril@808
    39
	long hThread;
insilmaril@808
    40
	long dwProcessId;
insilmaril@808
    41
	long dwThreadId;
insilmaril@608
    42
} PROCESS_INFORMATION, *LPPROCESS_INFORMATION;
insilmaril@608
    43
#endif
insilmaril@608
    44
insilmaril@0
    45
extern TextEditor *textEditor;
insilmaril@0
    46
extern Main *mainWindow;
insilmaril@829
    47
extern FindWidget *findWidget;
insilmaril@829
    48
extern FindResultWidget *findResultWidget;
insilmaril@164
    49
extern QString tmpVymDir;
insilmaril@166
    50
extern QString clipboardDir;
insilmaril@491
    51
extern QString clipboardFile;
insilmaril@166
    52
extern bool clipboardEmpty;
insilmaril@0
    53
extern int statusbarTime;
insilmaril@767
    54
extern FlagRow *standardFlagsMaster;	
insilmaril@767
    55
extern FlagRow *systemFlagsMaster;
insilmaril@404
    56
extern QString vymName;
insilmaril@404
    57
extern QString vymVersion;
insilmaril@404
    58
extern QString vymBuildDate;
insilmaril@502
    59
extern bool debug;
insilmaril@0
    60
insilmaril@390
    61
QMenu* branchContextMenu;
insilmaril@390
    62
QMenu* branchAddContextMenu;
insilmaril@390
    63
QMenu* branchRemoveContextMenu;
insilmaril@390
    64
QMenu* branchLinksContextMenu;
insilmaril@390
    65
QMenu* branchXLinksContextMenuEdit;
insilmaril@390
    66
QMenu* floatimageContextMenu;
insilmaril@390
    67
QMenu* canvasContextMenu;
insilmaril@390
    68
QMenu* fileLastMapsMenu;
insilmaril@390
    69
QMenu* fileImportMenu;
insilmaril@390
    70
QMenu* fileExportMenu;
insilmaril@0
    71
insilmaril@0
    72
insilmaril@0
    73
extern Settings settings;
insilmaril@0
    74
extern Options options;
insilmaril@366
    75
extern ImageIO imageIO;
insilmaril@366
    76
insilmaril@269
    77
extern QDir vymBaseDir;
insilmaril@366
    78
extern QDir lastImageDir;
insilmaril@366
    79
extern QDir lastFileDir;
insilmaril@625
    80
#if defined(Q_OS_WIN32)
insilmaril@625
    81
extern QDir vymInstallDir;
insilmaril@625
    82
#endif
insilmaril@269
    83
extern QString iconPath;
insilmaril@269
    84
extern QString flagsPath;
insilmaril@0
    85
insilmaril@725
    86
insilmaril@366
    87
Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
insilmaril@807
    88
QMainWindow(parent,name,f)
insilmaril@0
    89
{
insilmaril@808
    90
	mainWindow=this;
insilmaril@808
    91
insilmaril@808
    92
	setCaption ("VYM - View Your Mind");
insilmaril@808
    93
insilmaril@808
    94
	// Load window settings
insilmaril@808
    95
	#if defined(Q_OS_WIN32)
insilmaril@808
    96
	if (settings.value("/mainwindow/geometry/maximized", false).toBool())
insilmaril@808
    97
	{
insilmaril@808
    98
		setWindowState(Qt::WindowMaximized);
insilmaril@808
    99
	}
insilmaril@808
   100
	else
insilmaril@808
   101
	#endif
insilmaril@808
   102
	{
insilmaril@808
   103
		resize (settings.value("/mainwindow/geometry/size", QSize (800,600)).toSize());
insilmaril@808
   104
		move   (settings.value("/mainwindow/geometry/pos",  QPoint(300,100)).toPoint());
insilmaril@808
   105
	}
insilmaril@808
   106
insilmaril@808
   107
	// Sometimes we may need to remember old selections
insilmaril@808
   108
	prevSelection="";
insilmaril@808
   109
insilmaril@808
   110
	// Default color
insilmaril@808
   111
	currentColor=Qt::black;
insilmaril@808
   112
insilmaril@808
   113
	// Create unique temporary directory
insilmaril@808
   114
	bool ok;
insilmaril@808
   115
	tmpVymDir=makeTmpDir (ok,"vym");
insilmaril@808
   116
	if (!ok)
insilmaril@808
   117
	{
insilmaril@808
   118
		qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
insilmaril@808
   119
		exit (1);
insilmaril@808
   120
	}
insilmaril@808
   121
	if (debug) qDebug (QString("vym tmpDir=%1").arg(tmpVymDir) );
insilmaril@808
   122
insilmaril@808
   123
	// Create direcctory for clipboard
insilmaril@808
   124
	clipboardDir=tmpVymDir+"/clipboard";
insilmaril@808
   125
	clipboardFile="map.xml";
insilmaril@808
   126
	QDir d(clipboardDir);
insilmaril@808
   127
	d.mkdir (clipboardDir,true);
insilmaril@808
   128
	makeSubDirs (clipboardDir);
insilmaril@808
   129
	clipboardEmpty=true;
insilmaril@808
   130
insilmaril@829
   131
	// Remember PID of our friendly webbrowser
insilmaril@808
   132
	browserPID=new qint64;
insilmaril@808
   133
	*browserPID=0;
insilmaril@808
   134
insilmaril@829
   135
	// Dock widgets 
insilmaril@829
   136
	findResultWidget=new FindResultWidget ();
insilmaril@829
   137
	QDockWidget *dw= new QDockWidget (tr ("Search results","FindResultWidget"),this);
insilmaril@825
   138
	dw->setWidget (findResultWidget);
insilmaril@829
   139
	dw->setObjectName ("FindResultWidget");
insilmaril@829
   140
	dw->hide();	
insilmaril@825
   141
	addDockWidget (Qt::RightDockWidgetArea,dw);
insilmaril@842
   142
	connect (findResultWidget, SIGNAL (noteSelected (QString, int)),this, SLOT (selectInNoteEditor (QString, int)));
insilmaril@842
   143
insilmaril@825
   144
insilmaril@808
   145
	// Satellite windows //////////////////////////////////////////
insilmaril@808
   146
	// history window
insilmaril@808
   147
	historyWindow=new HistoryWindow();
insilmaril@808
   148
	connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
insilmaril@808
   149
insilmaril@808
   150
	// properties window
insilmaril@808
   151
	branchPropertyWindow = new BranchPropertyWindow();
insilmaril@808
   152
	connect (branchPropertyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
insilmaril@808
   153
insilmaril@808
   154
	// Connect TextEditor, so that we can update flags if text changes
insilmaril@808
   155
	connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
insilmaril@808
   156
	connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
insilmaril@808
   157
insilmaril@808
   158
	// Initialize script editor
insilmaril@808
   159
	scriptEditor = new SimpleScriptEditor();
insilmaril@808
   160
	scriptEditor->move (50,50);
insilmaril@808
   161
insilmaril@808
   162
	connect( scriptEditor, SIGNAL( runScript ( QString ) ), 
insilmaril@808
   163
		this, SLOT( runScript( QString ) ) );
insilmaril@808
   164
insilmaril@808
   165
	// Initialize some settings, which are platform dependant
insilmaril@808
   166
	QString p,s;
insilmaril@808
   167
insilmaril@808
   168
		// application to open URLs
insilmaril@808
   169
		p="/mainwindow/readerURL";
insilmaril@808
   170
		#if defined(Q_OS_LINUX)
insilmaril@808
   171
			s=settings.value (p,"xdg-open").toString();
insilmaril@0
   172
		#else
insilmaril@808
   173
			#if defined(Q_OS_MACX)
insilmaril@808
   174
				s=settings.value (p,"/usr/bin/open").toString();
insilmaril@808
   175
insilmaril@807
   176
			#else
insilmaril@808
   177
				#if defined(Q_OS_WIN32)
insilmaril@808
   178
					// Assume that system has been set up so that
insilmaril@808
   179
					// Explorer automagically opens up the URL
insilmaril@808
   180
					// in the user's preferred browser.
insilmaril@808
   181
					s=settings.value (p,"explorer").toString();
insilmaril@808
   182
				#else
insilmaril@808
   183
					s=settings.value (p,"mozilla").toString();
insilmaril@808
   184
				#endif
insilmaril@0
   185
			#endif
insilmaril@0
   186
		#endif
insilmaril@808
   187
		settings.setValue( p,s);
insilmaril@808
   188
insilmaril@808
   189
		// application to open PDFs
insilmaril@808
   190
		p="/mainwindow/readerPDF";
insilmaril@808
   191
		#if defined(Q_OS_LINUX)
insilmaril@808
   192
			s=settings.value (p,"xdg-open").toString();
insilmaril@0
   193
		#else
insilmaril@808
   194
			#if defined(Q_OS_MACX)
insilmaril@808
   195
				s=settings.value (p,"/usr/bin/open").toString();
insilmaril@808
   196
			#elif defined(Q_OS_WIN32)
insilmaril@808
   197
				s=settings.value (p,"acrord32").toString();
insilmaril@808
   198
			#else
insilmaril@808
   199
				s=settings.value (p,"acroread").toString();
insilmaril@808
   200
			#endif
insilmaril@0
   201
		#endif
insilmaril@808
   202
		settings.setValue( p,s);
insilmaril@808
   203
insilmaril@808
   204
	// width of xLinksMenu
insilmaril@808
   205
	xLinkMenuWidth=60;
insilmaril@808
   206
insilmaril@829
   207
	// Create Layout
insilmaril@829
   208
	QWidget* centralWidget = new QWidget (this);
insilmaril@829
   209
	QVBoxLayout *layout=new QVBoxLayout (centralWidget);
insilmaril@829
   210
	setCentralWidget(centralWidget);	
insilmaril@829
   211
insilmaril@808
   212
	// Create tab widget which holds the maps
insilmaril@829
   213
	tabWidget= new QTabWidget (centralWidget);
insilmaril@808
   214
	connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ), 
insilmaril@808
   215
		this, SLOT( editorChanged( QWidget * ) ) );
insilmaril@808
   216
insilmaril@829
   217
	// Create findWidget
insilmaril@829
   218
	findWidget = new FindWidget (centralWidget);
insilmaril@829
   219
	findWidget->hide();
insilmaril@829
   220
	layout->addWidget (tabWidget);
insilmaril@829
   221
	layout->addWidget (findWidget);
insilmaril@829
   222
insilmaril@829
   223
	connect (
insilmaril@829
   224
		findWidget, SIGNAL (nextButton (QString) ), 
insilmaril@829
   225
		this, SLOT (editFindNext(QString) ) );
insilmaril@829
   226
    connect (
insilmaril@829
   227
        findWidget , SIGNAL (hideFindWidget() ),
insilmaril@829
   228
        this, SLOT (editHideFindWidget() ) );
insilmaril@808
   229
insilmaril@808
   230
	setupFileActions();
insilmaril@808
   231
	setupEditActions();
insilmaril@808
   232
	setupFormatActions();
insilmaril@808
   233
	setupViewActions();
insilmaril@808
   234
	setupModeActions();
insilmaril@808
   235
	setupFlagActions();
insilmaril@808
   236
	setupNetworkActions();
insilmaril@808
   237
	setupSettingsActions();
insilmaril@808
   238
	setupContextMenus();
insilmaril@808
   239
	setupMacros();
insilmaril@842
   240
	if (options.isOn("shortcuts")) switchboard.print();
insilmaril@842
   241
	if (options.isOn("shortcutsLaTeX")) switchboard.printLaTeX();
insilmaril@824
   242
insilmaril@808
   243
	if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
insilmaril@808
   244
	setupHelpActions();
insilmaril@808
   245
insilmaril@808
   246
	// Status bar and progress bar there
insilmaril@808
   247
	statusBar();
insilmaril@808
   248
	progressMax=0;
insilmaril@821
   249
	progressCounter=0;
insilmaril@821
   250
	progressCounterTotal=0;
insilmaril@821
   251
insilmaril@821
   252
	progressDialog.setLabelText (tr("Loading maps","Mainwindow"));
insilmaril@821
   253
	progressDialog.setAutoReset(false);
insilmaril@821
   254
	progressDialog.setAutoClose(false);
insilmaril@821
   255
	//progressDialog.setWindowModality (Qt::WindowModal);	// That forces mainwindo to update and slows down
insilmaril@821
   256
	//progressDialog.setCancelButton (NULL);
insilmaril@808
   257
insilmaril@808
   258
	restoreState (settings.value("/mainwindow/state",0).toByteArray());
insilmaril@808
   259
insilmaril@808
   260
	updateGeometry();
insilmaril@0
   261
}
insilmaril@0
   262
insilmaril@0
   263
Main::~Main()
insilmaril@0
   264
{
insilmaril@808
   265
	// Save Settings
insilmaril@808
   266
	#if defined(Q_OS_WIN32)
insilmaril@808
   267
	settings.setValue ("/mainwindow/geometry/maximized", isMaximized());
insilmaril@808
   268
	#endif
insilmaril@808
   269
	settings.setValue ("/mainwindow/geometry/size", size());
insilmaril@808
   270
	settings.setValue ("/mainwindow/geometry/pos", pos());
insilmaril@808
   271
	settings.setValue ("/mainwindow/state",saveState(0));
insilmaril@808
   272
insilmaril@808
   273
	settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
insilmaril@808
   274
	settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
insilmaril@808
   275
	settings.setValue( "/version/version", vymVersion );
insilmaril@808
   276
	settings.setValue( "/version/builddate", vymBuildDate );
insilmaril@808
   277
insilmaril@808
   278
	settings.setValue( "/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
insilmaril@837
   279
	settings.setValue ("/mainwindow/autoLayout/use",actionSettingsAutoLayoutToggle->isOn() );
insilmaril@808
   280
	settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isOn() );
insilmaril@808
   281
	settings.setValue( "/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
insilmaril@808
   282
	settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
insilmaril@808
   283
	settings.setValue( "/mapeditor/editmode/autoEditNewBranch",actionSettingsAutoEditNewBranch->isOn() );
insilmaril@808
   284
	settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
insilmaril@808
   285
	settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
insilmaril@808
   286
	settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
insilmaril@808
   287
insilmaril@808
   288
	//TODO save scriptEditor settings
insilmaril@808
   289
insilmaril@808
   290
	// call the destructors
insilmaril@808
   291
	delete textEditor;
insilmaril@808
   292
	delete historyWindow;
insilmaril@808
   293
	delete branchPropertyWindow;
insilmaril@808
   294
insilmaril@808
   295
	// Remove temporary directory
insilmaril@808
   296
	removeDir (QDir(tmpVymDir));
insilmaril@0
   297
}
insilmaril@0
   298
insilmaril@0
   299
void Main::loadCmdLine()
insilmaril@0
   300
{
insilmaril@808
   301
	/* TODO draw some kind of splashscreen while loading...
insilmaril@808
   302
	if (qApp->argc()>1)
insilmaril@808
   303
	{
insilmaril@808
   304
	}
insilmaril@808
   305
	*/
insilmaril@808
   306
insilmaril@808
   307
	QStringList flist=options.getFileList();
insilmaril@808
   308
	QStringList::Iterator it=flist.begin();
insilmaril@808
   309
insilmaril@821
   310
	progressCounter=flist.count();
insilmaril@821
   311
	progressCounterTotal=flist.count();
insilmaril@808
   312
	while (it !=flist.end() )
insilmaril@808
   313
	{
insilmaril@808
   314
		fileLoad (*it, NewMap);
insilmaril@808
   315
		*it++;
insilmaril@808
   316
	}	
insilmaril@0
   317
}
insilmaril@0
   318
insilmaril@0
   319
insilmaril@0
   320
void Main::statusMessage(const QString &s)
insilmaril@0
   321
{
insilmaril@821
   322
	// Surpress messages while progressdialog during 
insilmaril@808
   323
	// load is active
insilmaril@821
   324
	if (progressMax==0)
insilmaril@808
   325
		statusBar()->message( s);
insilmaril@742
   326
}
insilmaril@742
   327
insilmaril@821
   328
void Main::setProgressMaximum (int max)	
insilmaril@742
   329
{
insilmaril@821
   330
	if (progressCounterTotal!=0)
insilmaril@821
   331
	
insilmaril@821
   332
		progressDialog.setRange (0,progressCounterTotal*1000);
insilmaril@821
   333
	else
insilmaril@821
   334
		progressDialog.setRange (0,max+10);
insilmaril@821
   335
insilmaril@821
   336
	progressDialog.setValue (0);
insilmaril@821
   337
	progressMax=max*1000;
insilmaril@821
   338
	//cout << "Main  max="<<max<<"  v="<<progressDialog.value()<<endl;
insilmaril@821
   339
	progressDialog.show();
insilmaril@742
   340
}
insilmaril@742
   341
insilmaril@821
   342
void Main::addProgressValue (float v)
insilmaril@742
   343
{
insilmaril@821
   344
	//cout << "addVal v="<<v*1000<<"/"<<progressMax<<"  cur="<<progressDialog.value()<<"  counter="<<v+progressCounter<<"/"<<progressCounterTotal<<endl;
insilmaril@821
   345
	if (progressCounterTotal!=0)
insilmaril@821
   346
		progressDialog.setValue ( (v+progressCounterTotal-progressCounter)*1000 );
insilmaril@821
   347
	else	
insilmaril@821
   348
		progressDialog.setValue (v+progressDialog.value());
insilmaril@742
   349
}
insilmaril@742
   350
insilmaril@822
   351
void Main::removeProgressCounter()
insilmaril@742
   352
{
insilmaril@821
   353
	progressMax=0;
insilmaril@821
   354
	progressCounter--;
insilmaril@821
   355
	if (progressCounter<=0)
insilmaril@821
   356
	{ 
insilmaril@821
   357
		// Hide dialog again
insilmaril@821
   358
		progressCounterTotal=0;
insilmaril@821
   359
		progressDialog.reset();
insilmaril@821
   360
		progressDialog.hide();
insilmaril@821
   361
	}	
insilmaril@0
   362
}
insilmaril@0
   363
insilmaril@0
   364
void Main::closeEvent (QCloseEvent* )
insilmaril@0
   365
{
insilmaril@808
   366
	fileExitVYM();
insilmaril@0
   367
}
insilmaril@0
   368
insilmaril@0
   369
// File Actions
insilmaril@0
   370
void Main::setupFileActions()
insilmaril@0
   371
{
insilmaril@808
   372
	QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
insilmaril@808
   373
	QToolBar *tb = addToolBar( tr ("&Map") );
insilmaril@808
   374
	tb->setObjectName ("mapTB");
insilmaril@808
   375
insilmaril@808
   376
	QAction *a;
insilmaril@808
   377
	a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this);
insilmaril@808
   378
	a->setStatusTip ( tr( "New map","Status tip File menu" ) );
insilmaril@808
   379
	a->setShortcut ( Qt::CTRL + Qt::Key_N );		//New map
insilmaril@824
   380
	switchboard.addConnection(a,tr("File","Shortcut group"));
insilmaril@808
   381
	a->addTo( tb );
insilmaril@808
   382
	fileMenu->addAction (a);
insilmaril@808
   383
	connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
insilmaril@808
   384
insilmaril@808
   385
	a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this);
insilmaril@808
   386
	a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) );
insilmaril@808
   387
	a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N );		//New map
insilmaril@824
   388
	switchboard.addConnection(a,tr("File","Shortcut group"));
insilmaril@808
   389
	fileMenu->addAction (a);
insilmaril@808
   390
	connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) );
insilmaril@808
   391
	actionFileNewCopy=a;
insilmaril@808
   392
insilmaril@808
   393
	a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
insilmaril@808
   394
	a->setStatusTip (tr( "Open","Status tip File menu" ) );
insilmaril@808
   395
	a->setShortcut ( Qt::CTRL + Qt::Key_O );		//Open map
insilmaril@824
   396
	switchboard.addConnection(a,tr("File","Shortcut group"));
insilmaril@808
   397
	a->addTo( tb );
insilmaril@808
   398
	fileMenu->addAction (a);
insilmaril@808
   399
	connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
insilmaril@808
   400
insilmaril@808
   401
	fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
insilmaril@808
   402
	fileMenu->addSeparator();
insilmaril@808
   403
insilmaril@808
   404
	a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
insilmaril@808
   405
	a->setStatusTip ( tr( "Save","Status tip file menu" ));
insilmaril@808
   406
	a->setShortcut (Qt::CTRL + Qt::Key_S );			//Save map
insilmaril@824
   407
	switchboard.addConnection(a,tr("File","Shortcut group"));
insilmaril@808
   408
	a->addTo( tb );
insilmaril@808
   409
	fileMenu->addAction (a);
insilmaril@808
   410
	connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
insilmaril@808
   411
	actionFileSave=a;
insilmaril@808
   412
insilmaril@808
   413
	a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
insilmaril@808
   414
	a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
insilmaril@824
   415
	switchboard.addConnection(a,tr("File","Shortcut group"));
insilmaril@808
   416
	fileMenu->addAction (a);
insilmaril@808
   417
	connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
insilmaril@808
   418
insilmaril@808
   419
	fileMenu->addSeparator();
insilmaril@808
   420
insilmaril@808
   421
	fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
insilmaril@808
   422
insilmaril@808
   423
	a = new QAction(tr("KDE 3 Bookmarks"), this);
insilmaril@808
   424
	a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 3 bookmarks")));
insilmaril@824
   425
	switchboard.addConnection(a,tr("File","Shortcut group"));
insilmaril@366
   426
	a->addTo (fileImportMenu);
insilmaril@808
   427
	connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE3Bookmarks() ) );
insilmaril@808
   428
insilmaril@808
   429
	a = new QAction(tr("KDE 4 Bookmarks"), this);
insilmaril@808
   430
	a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 4 bookmarks")));
insilmaril@808
   431
	a->addTo (fileImportMenu);
insilmaril@824
   432
	switchboard.addConnection(a,tr("File","Shortcut group"));
insilmaril@808
   433
	connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE4Bookmarks() ) );
insilmaril@808
   434
insilmaril@808
   435
	if (settings.value( "/mainwindow/showTestMenu",false).toBool()) 
insilmaril@808
   436
	{
insilmaril@808
   437
		a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
insilmaril@808
   438
		a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
insilmaril@808
   439
		a->addTo (fileImportMenu);
insilmaril@824
   440
		switchboard.addConnection(a,tr("File","Shortcut group"));
insilmaril@808
   441
		connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
insilmaril@808
   442
	}	
insilmaril@808
   443
insilmaril@808
   444
	a = new QAction("Freemind...",this);
insilmaril@808
   445
	a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Freemind")  );
insilmaril@824
   446
	switchboard.addConnection(a,tr("File","Shortcut group"));
insilmaril@808
   447
	fileImportMenu->addAction (a);
insilmaril@808
   448
	connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFreemind() ) );
insilmaril@808
   449
insilmaril@808
   450
	a = new QAction("Mind Manager...",this);
insilmaril@808
   451
	a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager")  );
insilmaril@824
   452
	switchboard.addConnection(a,tr("File","Shortcut group"));
insilmaril@808
   453
	fileImportMenu->addAction (a);
insilmaril@808
   454
	connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
insilmaril@808
   455
insilmaril@808
   456
	a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
insilmaril@808
   457
	a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
insilmaril@824
   458
	switchboard.addConnection(a,tr("File","Shortcut group"));
insilmaril@808
   459
	fileImportMenu->addAction (a);
insilmaril@808
   460
	connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
insilmaril@808
   461
insilmaril@808
   462
	fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
insilmaril@808
   463
insilmaril@808
   464
	a = new QAction( tr("Image%1","File export menu").arg("..."), this);
insilmaril@808
   465
	a->setStatusTip( tr( "Export map as image","status tip file menu" ));
insilmaril@824
   466
	switchboard.addConnection(a,tr("File","Shortcut group"));
insilmaril@808
   467
	connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
insilmaril@808
   468
	fileExportMenu->addAction (a);
insilmaril@808
   469
insilmaril@808
   470
	a = new QAction( "Open Office...", this);
insilmaril@808
   471
	a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
insilmaril@824
   472
	switchboard.addConnection(a,tr("File","Shortcut group"));
insilmaril@808
   473
	connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
insilmaril@808
   474
	fileExportMenu->addAction (a);
insilmaril@808
   475
insilmaril@819
   476
	a = new QAction(  "Webpage (HTML)...",this );
insilmaril@819
   477
	a->setShortcut (Qt::ALT + Qt::Key_X);			//Export HTML
insilmaril@845
   478
	a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (HTML)","status tip file menu")));
insilmaril@824
   479
	switchboard.addConnection(a,tr("File","Shortcut group"));
insilmaril@819
   480
	connect( a, SIGNAL( triggered() ), this, SLOT( fileExportHTML() ) );
insilmaril@819
   481
	fileExportMenu->addAction (a);
insilmaril@819
   482
insilmaril@808
   483
	a = new QAction( "Text (A&O report)...", this);
insilmaril@808
   484
	a->setStatusTip ( tr( "Export as %1").arg("A&O report "+tr("(still experimental)" )));
insilmaril@824
   485
	switchboard.addConnection(a,tr("File","Shortcut group"));
insilmaril@808
   486
	connect( a, SIGNAL( triggered() ), this, SLOT( fileExportAO() ) );
insilmaril@808
   487
	fileExportMenu->addAction (a);
insilmaril@808
   488
insilmaril@808
   489
	a = new QAction( "Text (ASCII)...", this);
insilmaril@808
   490
	a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
insilmaril@824
   491
	switchboard.addConnection(a,tr("File","Shortcut group"));
insilmaril@808
   492
	connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
insilmaril@808
   493
	fileExportMenu->addAction (a);
insilmaril@808
   494
insilmaril@808
   495
	a = new QAction( "Spreadsheet (CSV)...", this);
insilmaril@808
   496
	a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
insilmaril@824
   497
	switchboard.addConnection(a,tr("File","Shortcut group"));
insilmaril@808
   498
	connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
insilmaril@808
   499
	fileExportMenu->addAction (a);
insilmaril@808
   500
insilmaril@808
   501
	a = new QAction( tr("KDE 3 Bookmarks","File menu"), this);
insilmaril@808
   502
	a->setStatusTip( tr( "Export as %1").arg(tr("KDE 3 Bookmarks" )));
insilmaril@824
   503
	switchboard.addConnection(a,tr("File","Shortcut group"));
insilmaril@808
   504
	connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE3Bookmarks() ) );
insilmaril@808
   505
	fileExportMenu->addAction (a);
insilmaril@808
   506
insilmaril@808
   507
	a = new QAction( tr("KDE 4 Bookmarks","File menu"), this);
insilmaril@808
   508
	a->setStatusTip( tr( "Export as %1").arg(tr("KDE 4 Bookmarks" )));
insilmaril@824
   509
	switchboard.addConnection(a,tr("File","Shortcut group"));
insilmaril@808
   510
	connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE4Bookmarks() ) );
insilmaril@808
   511
	fileExportMenu->addAction (a);
insilmaril@808
   512
insilmaril@808
   513
	a = new QAction( "Taskjuggler...", this );
insilmaril@808
   514
	a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
insilmaril@824
   515
	switchboard.addConnection(a,tr("File","Shortcut group"));
insilmaril@808
   516
	connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
insilmaril@808
   517
	fileExportMenu->addAction (a);
insilmaril@808
   518
insilmaril@808
   519
	a = new QAction( "LaTeX...", this);
insilmaril@808
   520
	a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
insilmaril@824
   521
	switchboard.addConnection(a,tr("File","Shortcut group"));
insilmaril@808
   522
	connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
insilmaril@808
   523
	fileExportMenu->addAction (a);
insilmaril@808
   524
insilmaril@808
   525
	a = new QAction( "XML..." , this );
insilmaril@808
   526
	a->setStatusTip (tr( "Export as %1").arg("XML"));
insilmaril@824
   527
	switchboard.addConnection(a,tr("File","Shortcut group"));
insilmaril@808
   528
	connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
insilmaril@808
   529
	fileExportMenu->addAction (a);
insilmaril@808
   530
insilmaril@808
   531
	fileMenu->addSeparator();
insilmaril@808
   532
insilmaril@808
   533
	a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
insilmaril@808
   534
	a->setStatusTip ( tr( "Print" ,"File menu") );
insilmaril@808
   535
	a->setShortcut (Qt::CTRL + Qt::Key_P );			//Print map
insilmaril@808
   536
	a->addTo( tb );
insilmaril@824
   537
	switchboard.addConnection(a,tr("File","Shortcut group"));
insilmaril@808
   538
	fileMenu->addAction (a);
insilmaril@808
   539
	connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
insilmaril@808
   540
	actionFilePrint=a;
insilmaril@808
   541
insilmaril@808
   542
	a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
insilmaril@808
   543
	a->setStatusTip (tr( "Close Map" ) );
insilmaril@808
   544
	a->setShortcut (Qt::CTRL + Qt::Key_W );			//Close map
insilmaril@824
   545
	switchboard.addConnection(a,tr("File","Shortcut group"));
insilmaril@808
   546
	fileMenu->addAction (a);
insilmaril@808
   547
	connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
insilmaril@808
   548
insilmaril@808
   549
	a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
insilmaril@808
   550
	a->setStatusTip ( tr( "Exit")+" "+vymName );
insilmaril@808
   551
	a->setShortcut (Qt::CTRL + Qt::Key_Q );			//Quit vym
insilmaril@824
   552
	switchboard.addConnection(a,tr("File","Shortcut group"));
insilmaril@808
   553
	fileMenu->addAction (a);
insilmaril@808
   554
	connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
insilmaril@0
   555
}
insilmaril@0
   556
insilmaril@0
   557
insilmaril@0
   558
//Edit Actions
insilmaril@0
   559
void Main::setupEditActions()
insilmaril@0
   560
{
insilmaril@808
   561
	QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
insilmaril@808
   562
	tb->setLabel( "Edit Actions" );
insilmaril@808
   563
	tb->setObjectName ("actionsTB");
insilmaril@808
   564
	QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
insilmaril@808
   565
insilmaril@808
   566
	QAction *a;
insilmaril@808
   567
	a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
insilmaril@808
   568
	connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
insilmaril@808
   569
	a->setStatusTip (tr( "Undo" ) );
insilmaril@808
   570
	a->setShortcut ( Qt::CTRL + Qt::Key_Z );		//Undo last action
insilmaril@808
   571
	a->setEnabled (false);
insilmaril@824
   572
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@808
   573
	tb->addAction (a);
insilmaril@808
   574
	editMenu->addAction (a);
insilmaril@808
   575
	actionUndo=a;
insilmaril@808
   576
insilmaril@808
   577
	a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this); 
insilmaril@808
   578
	a->setStatusTip (tr( "Redo" ));
insilmaril@808
   579
	a->setShortcut (Qt::CTRL + Qt::Key_Y );			//Redo last action
insilmaril@824
   580
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@808
   581
	tb->addAction (a);
insilmaril@808
   582
	editMenu->addAction (a);
insilmaril@808
   583
	connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
insilmaril@808
   584
	actionRedo=a;
insilmaril@808
   585
insilmaril@808
   586
	editMenu->addSeparator();
insilmaril@808
   587
	a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
insilmaril@808
   588
	a->setStatusTip ( tr( "Copy" ) );
insilmaril@808
   589
	a->setShortcut (Qt::CTRL + Qt::Key_C );			//Copy
insilmaril@808
   590
	a->setEnabled (false);
insilmaril@824
   591
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@808
   592
	tb->addAction (a);
insilmaril@808
   593
	editMenu->addAction (a);
insilmaril@808
   594
	connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
insilmaril@808
   595
	actionCopy=a;
insilmaril@808
   596
insilmaril@808
   597
	a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
insilmaril@808
   598
	a->setStatusTip ( tr( "Cut" ) );
insilmaril@808
   599
	a->setShortcut (Qt::CTRL + Qt::Key_X );			//Cut
insilmaril@808
   600
	a->setEnabled (false);
insilmaril@808
   601
	tb->addAction (a);
insilmaril@824
   602
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@808
   603
	editMenu->addAction (a);
insilmaril@808
   604
	actionCut=a;
insilmaril@808
   605
	connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
insilmaril@808
   606
insilmaril@808
   607
	a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
insilmaril@808
   608
	connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
insilmaril@808
   609
	a->setStatusTip ( tr( "Paste" ) );
insilmaril@808
   610
	a->setShortcut ( Qt::CTRL + Qt::Key_V );		//Paste
insilmaril@808
   611
	a->setEnabled (false);
insilmaril@808
   612
	tb->addAction (a);
insilmaril@824
   613
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@808
   614
	editMenu->addAction (a);
insilmaril@808
   615
	actionPaste=a;
insilmaril@808
   616
insilmaril@808
   617
	// Shortcut to delete selection
insilmaril@808
   618
	a = new QAction( tr( "Delete Selection","Edit menu" ),this);
insilmaril@808
   619
	a->setStatusTip (tr( "Delete Selection" ));
insilmaril@808
   620
	a->setShortcut ( Qt::Key_Delete);				//Delete selection
insilmaril@808
   621
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@824
   622
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@808
   623
	addAction (a);
insilmaril@808
   624
	connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
insilmaril@808
   625
	actionDelete=a;
insilmaril@808
   626
insilmaril@808
   627
	// Shortcut to add attribute
insilmaril@808
   628
	a= new QAction(tr( "Add attribute" ), this);
insilmaril@842
   629
	if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
insilmaril@842
   630
	{
insilmaril@842
   631
		a->setShortcut ( Qt::Key_Q);	
insilmaril@842
   632
		a->setShortcutContext (Qt::WindowShortcut);
insilmaril@842
   633
		switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@842
   634
	}
insilmaril@808
   635
	addAction (a);
insilmaril@808
   636
	connect( a, SIGNAL( triggered() ), this, SLOT( editAddAttribute() ) );
insilmaril@808
   637
	actionAddAttribute= a;
insilmaril@808
   638
insilmaril@808
   639
insilmaril@808
   640
	// Shortcut to add mapcenter
insilmaril@808
   641
	a= new QAction(QPixmap(iconPath+"newmapcenter.png"),tr( "Add mapcenter","Canvas context menu" ), this);
insilmaril@808
   642
	a->setShortcut ( Qt::Key_M);	
insilmaril@808
   643
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@824
   644
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@808
   645
	connect( a, SIGNAL( triggered() ), this, SLOT( editAddMapCenter() ) );
insilmaril@808
   646
	//actionListBranches.append(a);
insilmaril@808
   647
	tb->addAction (a);
insilmaril@808
   648
	actionAddMapCenter = a;
insilmaril@808
   649
insilmaril@808
   650
insilmaril@808
   651
	// Shortcut to add branch
insilmaril@833
   652
	a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
insilmaril@833
   653
	a->setStatusTip ( tr( "Add a branch as child of selection" ));
insilmaril@833
   654
	a->setShortcut (Qt::Key_A);					//Add branch
insilmaril@833
   655
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@833
   656
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@833
   657
	addAction (a);
insilmaril@833
   658
	connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
insilmaril@808
   659
	a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
insilmaril@808
   660
	a->setStatusTip ( tr( "Add a branch as child of selection" ));
insilmaril@808
   661
	a->setShortcut (Qt::Key_Insert);				//Add branch
insilmaril@824
   662
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@808
   663
	connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
insilmaril@808
   664
	actionListBranches.append(a);
insilmaril@833
   665
	actionAddBranch=a;
insilmaril@808
   666
	editMenu->addAction (actionAddBranch);
insilmaril@808
   667
	tb->addAction (actionAddBranch);
insilmaril@808
   668
insilmaril@808
   669
insilmaril@808
   670
	// Add branch by inserting it at selection
insilmaril@808
   671
	a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
insilmaril@808
   672
	a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
insilmaril@808
   673
	a->setShortcut ( Qt::ALT + Qt::Key_A );			//Insert branch
insilmaril@808
   674
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@824
   675
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@808
   676
	addAction (a);
insilmaril@808
   677
	connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
insilmaril@808
   678
	actionListBranches.append(a);
insilmaril@837
   679
	actionAddBranchBefore=a;
insilmaril@808
   680
insilmaril@808
   681
	// Add branch above
insilmaril@808
   682
	a = new QAction(tr( "Add branch above","Edit menu" ), this);
insilmaril@808
   683
	a->setStatusTip ( tr( "Add a branch above selection" ));
insilmaril@808
   684
	a->setShortcut (Qt::SHIFT+Qt::Key_Insert );		//Add branch above
insilmaril@808
   685
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@824
   686
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@808
   687
	addAction (a);
insilmaril@808
   688
	connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
insilmaril@808
   689
	a->setEnabled (false);
insilmaril@808
   690
	actionListBranches.append(a);
insilmaril@808
   691
	actionAddBranchAbove=a;
insilmaril@808
   692
	a = new QAction(tr( "Add branch above","Edit menu" ), this);
insilmaril@808
   693
	a->setStatusTip ( tr( "Add a branch above selection" ));
insilmaril@808
   694
	a->setShortcut (Qt::SHIFT+Qt::Key_A );			//Add branch above
insilmaril@808
   695
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@824
   696
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@808
   697
	addAction (a);
insilmaril@808
   698
	connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
insilmaril@808
   699
	actionListBranches.append(a);
insilmaril@808
   700
insilmaril@808
   701
	// Add branch below 
insilmaril@808
   702
	a = new QAction(tr( "Add branch below","Edit menu" ), this);
insilmaril@808
   703
	a->setStatusTip ( tr( "Add a branch below selection" ));
insilmaril@808
   704
	a->setShortcut (Qt::CTRL +Qt::Key_Insert );		//Add branch below
insilmaril@808
   705
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@824
   706
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@808
   707
	addAction (a);
insilmaril@808
   708
	connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
insilmaril@808
   709
	a->setEnabled (false);
insilmaril@808
   710
	actionListBranches.append(a);
insilmaril@808
   711
	actionAddBranchBelow=a;
insilmaril@808
   712
	a = new QAction(tr( "Add branch below","Edit menu" ), this);
insilmaril@808
   713
	a->setStatusTip ( tr( "Add a branch below selection" ));
insilmaril@808
   714
	a->setShortcut (Qt::CTRL +Qt::Key_A );			// Add branch below
insilmaril@808
   715
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@824
   716
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@808
   717
	addAction (a);
insilmaril@808
   718
	connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
insilmaril@808
   719
	actionListBranches.append(a);
insilmaril@808
   720
insilmaril@808
   721
	a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
insilmaril@808
   722
	a->setStatusTip ( tr( "Move branch up" ) );
insilmaril@842
   723
	a->setShortcut (Qt::Key_PageUp );				// Move branch up	//FIXME-2 If already on top, GraphicsView scrolls up, probably because this action is disabled?!
insilmaril@808
   724
	a->setEnabled (false);
insilmaril@824
   725
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@808
   726
	tb->addAction (a);
insilmaril@808
   727
	editMenu->addAction (a);
insilmaril@808
   728
	connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
insilmaril@808
   729
	actionMoveUp=a;
insilmaril@808
   730
insilmaril@808
   731
	a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
insilmaril@808
   732
	connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
insilmaril@808
   733
	a->setStatusTip (tr( "Move branch down" ) );
insilmaril@808
   734
	a->setShortcut ( Qt::Key_PageDown );			// Move branch down
insilmaril@808
   735
	a->setEnabled (false);
insilmaril@824
   736
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@808
   737
	tb->addAction (a);
insilmaril@808
   738
	editMenu->addAction (a);
insilmaril@808
   739
	actionMoveDown=a;
insilmaril@808
   740
insilmaril@808
   741
	a = new QAction(QPixmap(), tr( "&Detach","Context menu" ),this);
insilmaril@808
   742
	a->setStatusTip ( tr( "Detach branch and use as mapcenter","Context menu" ) );
insilmaril@808
   743
	a->setShortcut ( Qt::Key_D );					// Detach branch
insilmaril@824
   744
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@808
   745
	editMenu->addAction (a);
insilmaril@808
   746
	connect( a, SIGNAL( triggered() ), this, SLOT( editDetach() ) );
insilmaril@808
   747
	actionDetach=a;
insilmaril@808
   748
insilmaril@808
   749
	a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this );
insilmaril@808
   750
	connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) );
insilmaril@808
   751
	a->setEnabled (true);
insilmaril@808
   752
	a->addTo( tb );
insilmaril@824
   753
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@808
   754
	editMenu->addAction (a);
insilmaril@808
   755
	actionSortChildren=a;
insilmaril@808
   756
insilmaril@822
   757
	a = new QAction( QPixmap(iconPath+"editsortback.png" ), tr( "Sort children backwards","Edit menu" ), this );
insilmaril@822
   758
	connect( a, SIGNAL( activated() ), this, SLOT( editSortBackChildren() ) );
insilmaril@822
   759
	a->setEnabled (true);
insilmaril@822
   760
	a->addTo( tb );
insilmaril@824
   761
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@822
   762
	editMenu->addAction (a);
insilmaril@830
   763
	actionSortBackChildren=a;	
insilmaril@830
   764
insilmaril@830
   765
	a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
insilmaril@830
   766
	a->setShortcut ( Qt::Key_S );					// Scroll branch
insilmaril@830
   767
	a->setStatusTip (tr( "Scroll branch" )); 
insilmaril@833
   768
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@833
   769
	connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
insilmaril@830
   770
	a->setEnabled (false);
insilmaril@830
   771
	a->setToggleAction(true);
insilmaril@830
   772
	actionToggleScroll=a;
insilmaril@808
   773
	tb->addAction (actionToggleScroll);
insilmaril@808
   774
	editMenu->addAction ( actionToggleScroll);
insilmaril@808
   775
	editMenu->addAction (actionToggleScroll);
insilmaril@808
   776
	addAction (a);
insilmaril@808
   777
	actionListBranches.append(actionToggleScroll);
insilmaril@808
   778
insilmaril@808
   779
	a = new QAction( QPixmap(), tr( "Expand all branches","Edit menu" ), this);
insilmaril@808
   780
	a->setShortcut ( Qt::SHIFT + Qt::Key_X );		// Expand all branches 
insilmaril@808
   781
	a->setStatusTip (tr( "Expand all branches" )); 
insilmaril@824
   782
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@808
   783
	connect( a, SIGNAL( triggered() ), this, SLOT( editExpandAll() ) );
insilmaril@808
   784
	actionExpandAll=a;
insilmaril@808
   785
	actionExpandAll->setEnabled (false);
insilmaril@808
   786
	actionExpandAll->setToggleAction(false);
insilmaril@808
   787
	//tb->addAction (actionExpandAll);
insilmaril@808
   788
	editMenu->addAction ( actionExpandAll);
insilmaril@808
   789
	addAction (a);
insilmaril@808
   790
	actionListBranches.append(actionExpandAll);
insilmaril@808
   791
insilmaril@808
   792
	a = new QAction( QPixmap(), tr( "Expand one level","Edit menu" ), this);
insilmaril@808
   793
	a->setShortcut ( Qt::Key_Greater );		// Expand one level in tree editor
insilmaril@824
   794
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@808
   795
	a->setStatusTip (tr( "Expand one level in tree editor" )); 
insilmaril@808
   796
	connect( a, SIGNAL( triggered() ), this, SLOT( editExpandOneLevel() ) );
insilmaril@808
   797
	a->setEnabled (false);
insilmaril@808
   798
	a->setToggleAction(false);
insilmaril@808
   799
	actionExpandOneLevel=a;
insilmaril@808
   800
	//tb->addAction (a);
insilmaril@808
   801
	editMenu->addAction ( a);
insilmaril@808
   802
	addAction (a);
insilmaril@808
   803
	actionListBranches.append(a);
insilmaril@808
   804
insilmaril@808
   805
	a = new QAction( QPixmap(), tr( "Collapse one level","Edit menu" ), this);
insilmaril@808
   806
	a->setShortcut ( Qt::Key_Less);			// Collapse one level in tree editor
insilmaril@824
   807
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@808
   808
	a->setStatusTip (tr( "Collapse one level in tree editor" )); 
insilmaril@808
   809
	connect( a, SIGNAL( triggered() ), this, SLOT( editCollapseOneLevel() ) );
insilmaril@808
   810
	a->setEnabled (false);
insilmaril@808
   811
	a->setToggleAction(false);
insilmaril@808
   812
	actionCollapseOneLevel=a;
insilmaril@808
   813
	//tb->addAction (a);
insilmaril@808
   814
	editMenu->addAction ( a);
insilmaril@808
   815
	addAction (a);
insilmaril@808
   816
	actionListBranches.append(a);
insilmaril@808
   817
insilmaril@808
   818
	a = new QAction( tr( "Unscroll children","Edit menu" ), this);
insilmaril@808
   819
	a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
insilmaril@824
   820
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@808
   821
	editMenu->addAction (a);
insilmaril@808
   822
	connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChildren() ) );
insilmaril@808
   823
insilmaril@808
   824
	editMenu->addSeparator();
insilmaril@808
   825
insilmaril@808
   826
	a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
insilmaril@808
   827
	a->setStatusTip (tr( "Find" ) );
insilmaril@808
   828
	a->setShortcut (Qt::CTRL + Qt::Key_F );				//Find
insilmaril@824
   829
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@808
   830
	editMenu->addAction (a);
insilmaril@808
   831
	connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWidget() ) );
insilmaril@808
   832
insilmaril@821
   833
	a = new QAction( tr( "Find duplicate URLs","Edit menu"), this);
insilmaril@821
   834
	//a->setStatusTip (tr( "Find" ) );
insilmaril@821
   835
	a->setShortcut (Qt::SHIFT + Qt::Key_F);				//Find duplicate URLs
insilmaril@824
   836
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@821
   837
	if (settings.value( "/mainwindow/showTestMenu",false).toBool() ) 
insilmaril@821
   838
		editMenu->addAction (a);
insilmaril@821
   839
	connect( a, SIGNAL( triggered() ), this, SLOT( editFindDuplicateURLs() ) );
insilmaril@821
   840
insilmaril@808
   841
	editMenu->addSeparator();
insilmaril@808
   842
insilmaril@808
   843
	a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
insilmaril@808
   844
	a->setShortcut (Qt::SHIFT + Qt::Key_U );
insilmaril@824
   845
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@808
   846
	tb->addAction (a);
insilmaril@808
   847
	addAction(a);
insilmaril@808
   848
	connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
insilmaril@808
   849
	actionOpenURL=a;
insilmaril@808
   850
insilmaril@808
   851
	a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
insilmaril@808
   852
	a->setStatusTip (tr( "Open URL in new tab" ));
insilmaril@808
   853
	//a->setShortcut (Qt::CTRL+Qt::Key_U );
insilmaril@824
   854
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@808
   855
	addAction(a);
insilmaril@808
   856
	connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
insilmaril@808
   857
	actionOpenURLTab=a;
insilmaril@808
   858
insilmaril@821
   859
	a = new QAction( tr( "Open all URLs in subtree (including scrolled branches)","Edit menu" ), this);
insilmaril@821
   860
	a->setStatusTip (tr( "Open all URLs in subtree (including scrolled branches)" ));
insilmaril@821
   861
	a->setShortcut ( Qt::CTRL + Qt::Key_U );
insilmaril@824
   862
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@821
   863
	addAction(a);
insilmaril@821
   864
	actionListBranches.append(a);
insilmaril@821
   865
	connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVisURLTabs() ) );
insilmaril@821
   866
	actionOpenMultipleVisURLTabs=a;
insilmaril@821
   867
insilmaril@808
   868
	a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
insilmaril@808
   869
	a->setStatusTip (tr( "Open all URLs in subtree" ));
insilmaril@824
   870
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@808
   871
	addAction(a);
insilmaril@808
   872
	actionListBranches.append(a);
insilmaril@808
   873
	connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
insilmaril@808
   874
	actionOpenMultipleURLTabs=a;
insilmaril@808
   875
insilmaril@808
   876
	a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
insilmaril@808
   877
	a->setStatusTip ( tr( "Edit URL" ) );
insilmaril@808
   878
	a->setShortcut ( Qt::Key_U );
insilmaril@808
   879
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@824
   880
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@808
   881
	actionListBranches.append(a);
insilmaril@808
   882
	addAction(a);
insilmaril@808
   883
	connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
insilmaril@808
   884
	actionURL=a;
insilmaril@808
   885
insilmaril@808
   886
	a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
insilmaril@808
   887
	a->setStatusTip ( tr( "Edit local URL" ) );
insilmaril@808
   888
	//a->setShortcut (Qt::SHIFT +  Qt::Key_U );
insilmaril@808
   889
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@824
   890
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@808
   891
	actionListBranches.append(a);
insilmaril@808
   892
	addAction(a);
insilmaril@808
   893
	connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
insilmaril@808
   894
	actionLocalURL=a;
insilmaril@808
   895
insilmaril@808
   896
	a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
insilmaril@808
   897
	a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
insilmaril@808
   898
	a->setEnabled (false);
insilmaril@824
   899
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@808
   900
	actionListBranches.append(a);
insilmaril@808
   901
	connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
insilmaril@808
   902
	actionHeading2URL=a;
insilmaril@808
   903
insilmaril@808
   904
	a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
insilmaril@808
   905
	a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
insilmaril@808
   906
	a->setEnabled (false);
insilmaril@808
   907
	actionListBranches.append(a);
insilmaril@808
   908
	a->setShortcut ( Qt::Key_B );
insilmaril@808
   909
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@824
   910
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@808
   911
	addAction(a);
insilmaril@808
   912
	connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
insilmaril@808
   913
	actionBugzilla2URL=a;
insilmaril@808
   914
insilmaril@821
   915
	a = new QAction(tr( "Get data from Novell Bugzilla","Edit menu" ), this);
insilmaril@820
   916
	a->setStatusTip ( tr( "Get data from Novell Bugzilla" ));
insilmaril@820
   917
	a->setEnabled (false);
insilmaril@820
   918
	actionListBranches.append(a);
insilmaril@820
   919
	a->setShortcut ( Qt::Key_B + Qt::SHIFT);
insilmaril@820
   920
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@824
   921
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@820
   922
	addAction(a);
insilmaril@820
   923
	connect( a, SIGNAL( triggered() ), this, SLOT( getBugzillaData() ) );
insilmaril@820
   924
	actionGetBugzillaData=a;
insilmaril@820
   925
insilmaril@808
   926
	a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
insilmaril@808
   927
	a->setStatusTip ( tr( "Create URL to Novell FATE" ));
insilmaril@808
   928
	a->setEnabled (false);
insilmaril@824
   929
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@808
   930
	actionListBranches.append(a);
insilmaril@808
   931
	connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
insilmaril@808
   932
	actionFATE2URL=a;
insilmaril@808
   933
insilmaril@808
   934
	a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
insilmaril@808
   935
	a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
insilmaril@808
   936
	tb->addAction (a);
insilmaril@808
   937
	a->setEnabled (false);
insilmaril@824
   938
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@808
   939
	connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
insilmaril@808
   940
	actionOpenVymLink=a;
insilmaril@808
   941
insilmaril@808
   942
	a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
insilmaril@808
   943
	a->setStatusTip ( tr( "Open all vym links in subtree" ));
insilmaril@808
   944
	a->setEnabled (false);
insilmaril@824
   945
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@808
   946
	actionListBranches.append(a);
insilmaril@808
   947
	connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
insilmaril@808
   948
	actionOpenMultipleVymLinks=a;
insilmaril@808
   949
insilmaril@808
   950
insilmaril@808
   951
	a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
insilmaril@808
   952
	a->setEnabled (false);
insilmaril@808
   953
	a->setStatusTip ( tr( "Edit link to another vym map" ));
insilmaril@824
   954
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@808
   955
	connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
insilmaril@808
   956
	actionListBranches.append(a);
insilmaril@808
   957
	actionVymLink=a;
insilmaril@808
   958
insilmaril@808
   959
	a = new QAction(tr( "Delete vym link","Edit menu" ),this);
insilmaril@808
   960
	a->setStatusTip ( tr( "Delete link to another vym map" ));
insilmaril@808
   961
	a->setEnabled (false);
insilmaril@824
   962
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@808
   963
	connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
insilmaril@808
   964
	actionDeleteVymLink=a;
insilmaril@808
   965
insilmaril@808
   966
	a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
insilmaril@808
   967
	a->setStatusTip ( tr( "Hide object in exports" ) );
insilmaril@808
   968
	a->setShortcut (Qt::Key_H );
insilmaril@808
   969
	a->setToggleAction(true);
insilmaril@808
   970
	tb->addAction (a);
insilmaril@808
   971
	a->setEnabled (false);
insilmaril@824
   972
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@808
   973
	connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
insilmaril@808
   974
	actionToggleHideExport=a;
insilmaril@808
   975
insilmaril@808
   976
	a = new QAction(tr( "Add timestamp","Edit menu" ), this);
insilmaril@808
   977
	a->setStatusTip ( tr( "Add timestamp" ));
insilmaril@808
   978
	a->setEnabled (false);
insilmaril@808
   979
	actionListBranches.append(a);
insilmaril@808
   980
	a->setShortcut ( Qt::Key_T );	// Add timestamp
insilmaril@808
   981
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@824
   982
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@808
   983
	addAction(a);
insilmaril@808
   984
	connect( a, SIGNAL( triggered() ), this, SLOT( editAddTimestamp() ) );
insilmaril@808
   985
	actionAddTimestamp=a;
insilmaril@808
   986
insilmaril@808
   987
	a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
insilmaril@808
   988
	a->setStatusTip ( tr( "Edit Map Info" ));
insilmaril@808
   989
	a->setEnabled (true);
insilmaril@824
   990
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@808
   991
	connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
insilmaril@808
   992
	actionMapInfo=a;
insilmaril@808
   993
insilmaril@808
   994
	// Import at selection (adding to selection)
insilmaril@808
   995
	a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
insilmaril@808
   996
	a->setStatusTip (tr( "Add map at selection" ));
insilmaril@808
   997
	connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
insilmaril@808
   998
	a->setEnabled (false);
insilmaril@824
   999
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@808
  1000
	actionListBranches.append(a);
insilmaril@808
  1001
	actionImportAdd=a;
insilmaril@808
  1002
insilmaril@808
  1003
	// Import at selection (replacing selection)
insilmaril@808
  1004
	a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
insilmaril@808
  1005
	a->setStatusTip (tr( "Replace selection with map" ));
insilmaril@824
  1006
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@808
  1007
	connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
insilmaril@808
  1008
	a->setEnabled (false);
insilmaril@808
  1009
	actionListBranches.append(a);
insilmaril@808
  1010
	actionImportReplace=a;
insilmaril@808
  1011
insilmaril@808
  1012
	// Save selection 
insilmaril@808
  1013
	a = new QAction( tr( "Save selection","Edit menu" ), this);
insilmaril@808
  1014
	a->setStatusTip (tr( "Save selection" ));
insilmaril@808
  1015
	connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
insilmaril@808
  1016
	a->setEnabled (false);
insilmaril@824
  1017
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@808
  1018
	actionListBranches.append(a);
insilmaril@808
  1019
	actionSaveBranch=a;
insilmaril@808
  1020
insilmaril@808
  1021
	// Only remove branch, not its children
insilmaril@808
  1022
	a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
insilmaril@808
  1023
	a->setStatusTip ( tr( "Remove only branch and keep its children" ));
insilmaril@808
  1024
	a->setShortcut (Qt::ALT + Qt::Key_Delete );
insilmaril@808
  1025
	connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChildren() ) );
insilmaril@808
  1026
	a->setEnabled (false);
insilmaril@824
  1027
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@808
  1028
	addAction (a);
insilmaril@808
  1029
	actionListBranches.append(a);
insilmaril@808
  1030
	actionDeleteKeepChildren=a;
insilmaril@808
  1031
insilmaril@808
  1032
	// Only remove children of a branch
insilmaril@808
  1033
	a = new QAction( tr( "Remove children","Edit menu" ), this);
insilmaril@808
  1034
	a->setStatusTip (tr( "Remove children of branch" ));
insilmaril@808
  1035
	a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
insilmaril@824
  1036
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@808
  1037
	connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChildren() ) );
insilmaril@808
  1038
	a->setEnabled (false);
insilmaril@808
  1039
	actionListBranches.append(a);
insilmaril@808
  1040
	actionDeleteChildren=a;
insilmaril@808
  1041
insilmaril@808
  1042
	a = new QAction( tr( "Add Image...","Edit menu" ), this);
insilmaril@808
  1043
	a->setStatusTip (tr( "Add Image" ));
insilmaril@824
  1044
	switchboard.addConnection(a,tr("Edit","Shortcut group"));
insilmaril@808
  1045
	connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
insilmaril@808
  1046
	actionLoadImage=a;
insilmaril@808
  1047
insilmaril@808
  1048
	a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
insilmaril@808
  1049
	a->setStatusTip (tr( "Set properties for selection" ));
insilmaril@808
  1050
	a->setShortcut ( Qt::CTRL + Qt::Key_I );		//Property window
insilmaril@808
  1051
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@808
  1052
	a->setToggleAction (true);
insilmaril@824
  1053
	switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
insilmaril@808
  1054
	addAction (a);
insilmaril@808
  1055
	connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
insilmaril@808
  1056
	actionViewTogglePropertyWindow=a;
insilmaril@0
  1057
}
insilmaril@0
  1058
insilmaril@0
  1059
// Format Actions
insilmaril@0
  1060
void Main::setupFormatActions()
insilmaril@0
  1061
{
insilmaril@808
  1062
	QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
insilmaril@808
  1063
insilmaril@808
  1064
	QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
insilmaril@808
  1065
	tb->setObjectName ("formatTB");
insilmaril@808
  1066
	QAction *a;
insilmaril@808
  1067
	QPixmap pix( 16,16);
insilmaril@808
  1068
	pix.fill (Qt::black);
insilmaril@808
  1069
	a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
insilmaril@808
  1070
	a->setStatusTip ( tr( "Set Color" ));
insilmaril@808
  1071
	connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
insilmaril@808
  1072
	a->addTo( tb );
insilmaril@808
  1073
	formatMenu->addAction (a);
insilmaril@808
  1074
	actionFormatColor=a;
insilmaril@808
  1075
	a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
insilmaril@808
  1076
	a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
insilmaril@808
  1077
	a->setShortcut (Qt::CTRL + Qt::Key_K );
insilmaril@808
  1078
	connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
insilmaril@808
  1079
	a->setEnabled (false);
insilmaril@808
  1080
	a->addTo( tb );
insilmaril@808
  1081
	formatMenu->addAction (a);
insilmaril@808
  1082
	actionListBranches.append(a);
insilmaril@808
  1083
	actionFormatPickColor=a;
insilmaril@808
  1084
insilmaril@808
  1085
	a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
insilmaril@808
  1086
	a->setStatusTip ( tr( "Color branch" ) );
insilmaril@825
  1087
	a->setShortcut (Qt::CTRL + Qt::Key_B + Qt::SHIFT);
insilmaril@808
  1088
	connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
insilmaril@808
  1089
	a->setEnabled (false);
insilmaril@808
  1090
	a->addTo( tb );
insilmaril@808
  1091
	formatMenu->addAction (a);
insilmaril@808
  1092
	actionListBranches.append(a);
insilmaril@808
  1093
	actionFormatColorSubtree=a;
insilmaril@808
  1094
insilmaril@808
  1095
	a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
insilmaril@808
  1096
	a->setStatusTip ( tr( "Color Subtree" ));
insilmaril@825
  1097
	a->setShortcut (Qt::CTRL + Qt::Key_B);	// Color subtree
insilmaril@808
  1098
	connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
insilmaril@808
  1099
	a->setEnabled (false);
insilmaril@808
  1100
	formatMenu->addAction (a);
insilmaril@808
  1101
	a->addTo( tb );
insilmaril@808
  1102
	actionListBranches.append(a);
insilmaril@808
  1103
	actionFormatColorSubtree=a;
insilmaril@808
  1104
insilmaril@808
  1105
	formatMenu->addSeparator();
insilmaril@808
  1106
	actionGroupFormatLinkStyles=new QActionGroup ( this);
insilmaril@808
  1107
	actionGroupFormatLinkStyles->setExclusive (true);
insilmaril@808
  1108
	a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
insilmaril@808
  1109
	a->setStatusTip (tr( "Line" ));
insilmaril@808
  1110
	a->setToggleAction(true);
insilmaril@808
  1111
	connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
insilmaril@808
  1112
	formatMenu->addAction (a);
insilmaril@808
  1113
	actionFormatLinkStyleLine=a;
insilmaril@808
  1114
	a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
insilmaril@808
  1115
	a->setStatusTip (tr( "Line" ));
insilmaril@808
  1116
	a->setToggleAction(true);
insilmaril@808
  1117
	connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
insilmaril@808
  1118
	formatMenu->addAction (a);
insilmaril@808
  1119
	actionFormatLinkStyleParabel=a;
insilmaril@808
  1120
	a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
insilmaril@808
  1121
	a->setStatusTip (tr( "PolyLine" ));
insilmaril@808
  1122
	a->setToggleAction(true);
insilmaril@808
  1123
	connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
insilmaril@808
  1124
	formatMenu->addAction (a);
insilmaril@808
  1125
	actionFormatLinkStylePolyLine=a;
insilmaril@808
  1126
	a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
insilmaril@808
  1127
	a->setStatusTip (tr( "PolyParabel" ) );
insilmaril@808
  1128
	a->setToggleAction(true);
insilmaril@808
  1129
	a->setChecked (true);
insilmaril@808
  1130
	connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
insilmaril@808
  1131
	formatMenu->addAction (a);
insilmaril@808
  1132
	actionFormatLinkStylePolyParabel=a;
insilmaril@808
  1133
insilmaril@808
  1134
	a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
insilmaril@808
  1135
	a->setStatusTip (tr( "Hide link" ));
insilmaril@808
  1136
	a->setToggleAction(true);
insilmaril@808
  1137
	connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
insilmaril@808
  1138
	actionFormatHideLinkUnselected=a;
insilmaril@808
  1139
insilmaril@808
  1140
	formatMenu->addSeparator();
insilmaril@808
  1141
	a= new QAction( tr( "&Use color of heading for link","Branch attribute" ),  this);
insilmaril@808
  1142
	a->setStatusTip (tr( "Use same color for links and headings" ));
insilmaril@808
  1143
	a->setToggleAction(true);
insilmaril@808
  1144
	connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
insilmaril@808
  1145
	formatMenu->addAction (a);
insilmaril@808
  1146
	actionFormatLinkColorHint=a;
insilmaril@808
  1147
insilmaril@808
  1148
	pix.fill (Qt::white);
insilmaril@808
  1149
	a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this  );
insilmaril@808
  1150
	a->setStatusTip (tr( "Set Link Color" ));
insilmaril@808
  1151
	formatMenu->addAction (a);
insilmaril@808
  1152
	connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
insilmaril@808
  1153
	actionFormatLinkColor=a;
insilmaril@808
  1154
insilmaril@808
  1155
	a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this  );
insilmaril@808
  1156
	a->setStatusTip (tr( "Set Selection Color" ));
insilmaril@808
  1157
	formatMenu->addAction (a);
insilmaril@808
  1158
	connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
insilmaril@808
  1159
	actionFormatSelectionColor=a;
insilmaril@808
  1160
insilmaril@808
  1161
	a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
insilmaril@808
  1162
	a->setStatusTip (tr( "Set Background Color" ));
insilmaril@808
  1163
	formatMenu->addAction (a);
insilmaril@808
  1164
	connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
insilmaril@808
  1165
	actionFormatBackColor=a;
insilmaril@808
  1166
insilmaril@808
  1167
	a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
insilmaril@808
  1168
	a->setStatusTip (tr( "Set Background image" ));
insilmaril@808
  1169
	formatMenu->addAction (a);
insilmaril@808
  1170
	connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
insilmaril@808
  1171
	actionFormatBackImage=a;
insilmaril@0
  1172
}
insilmaril@0
  1173
insilmaril@0
  1174
// View Actions
insilmaril@0
  1175
void Main::setupViewActions()
insilmaril@0
  1176
{
insilmaril@808
  1177
	QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
insilmaril@808
  1178
	tb->setLabel( "View Actions" );
insilmaril@808
  1179
	tb->setObjectName ("viewTB");
insilmaril@808
  1180
	QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
insilmaril@808
  1181
insilmaril@808
  1182
insilmaril@808
  1183
	QAction *a;
insilmaril@808
  1184
	a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
insilmaril@808
  1185
	a->setStatusTip ( tr( "Zoom reset" ) );
insilmaril@841
  1186
	a->setShortcut (Qt::Key_Comma);	// Reset zoom
insilmaril@824
  1187
	switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
insilmaril@808
  1188
	a->addTo( tb );
insilmaril@808
  1189
	viewMenu->addAction (a);
insilmaril@808
  1190
	connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
insilmaril@808
  1191
insilmaril@808
  1192
	a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
insilmaril@808
  1193
	a->setStatusTip (tr( "Zoom in" ));
insilmaril@841
  1194
	a->setShortcut(Qt::Key_Plus);
insilmaril@824
  1195
	switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
insilmaril@808
  1196
	a->addTo( tb );
insilmaril@808
  1197
	viewMenu->addAction (a);
insilmaril@808
  1198
	connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
insilmaril@808
  1199
insilmaril@808
  1200
	a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
insilmaril@808
  1201
	a->setStatusTip (tr( "Zoom out" ));
insilmaril@841
  1202
	a->setShortcut(Qt::Key_Minus);
insilmaril@824
  1203
	switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
insilmaril@808
  1204
	a->addTo( tb );
insilmaril@808
  1205
	viewMenu->addAction (a);
insilmaril@808
  1206
	connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
insilmaril@808
  1207
insilmaril@808
  1208
	a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
insilmaril@808
  1209
	a->setStatusTip (tr( "Show selection" ));
insilmaril@837
  1210
	a->setShortcut(Qt::Key_Period);
insilmaril@824
  1211
	switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
insilmaril@808
  1212
	a->addTo( tb );
insilmaril@808
  1213
	viewMenu->addAction (a);
insilmaril@808
  1214
	connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
insilmaril@808
  1215
insilmaril@808
  1216
	viewMenu->addSeparator();	
insilmaril@808
  1217
insilmaril@808
  1218
	a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
insilmaril@808
  1219
	a->setStatusTip ( tr( "Show Note Editor" ));
insilmaril@808
  1220
	a->setShortcut ( Qt::CTRL + Qt::Key_E );	// Toggle Note Editor
insilmaril@824
  1221
	switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
insilmaril@808
  1222
	a->setToggleAction(true);
insilmaril@808
  1223
	a->addTo( tb );
insilmaril@808
  1224
	viewMenu->addAction (a);
insilmaril@808
  1225
	connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
insilmaril@808
  1226
	actionViewToggleNoteEditor=a;
insilmaril@808
  1227
insilmaril@842
  1228
	// Original icon is "category" from KDE
insilmaril@842
  1229
	a = new QAction(QPixmap(iconPath+"treeeditor.png"), tr( "Show tree editor","View action" ),this);
insilmaril@823
  1230
	a->setStatusTip ( tr( "Show tree editor" ));
insilmaril@824
  1231
	a->setShortcut ( Qt::CTRL + Qt::Key_T );	// Toggle Tree Editor // FIXME-3 originally: color subtree
insilmaril@824
  1232
	switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
insilmaril@823
  1233
	a->setToggleAction(true);
insilmaril@823
  1234
	a->addTo( tb );
insilmaril@823
  1235
	viewMenu->addAction (a);
insilmaril@823
  1236
	connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleTreeEditor() ) );
insilmaril@823
  1237
	actionViewToggleTreeEditor=a;
insilmaril@823
  1238
insilmaril@808
  1239
	a = new QAction(QPixmap(iconPath+"history.png"),  tr( "History Window","View action" ),this );
insilmaril@808
  1240
	a->setStatusTip ( tr( "Show History Window" ));
insilmaril@808
  1241
	a->setShortcut ( Qt::CTRL + Qt::Key_H  );	// Toggle history window
insilmaril@824
  1242
	switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
insilmaril@808
  1243
	a->setToggleAction(true);
insilmaril@808
  1244
	a->addTo( tb );
insilmaril@808
  1245
	viewMenu->addAction (a);
insilmaril@808
  1246
	connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
insilmaril@808
  1247
	actionViewToggleHistoryWindow=a;
insilmaril@808
  1248
insilmaril@808
  1249
	viewMenu->addAction (actionViewTogglePropertyWindow);
insilmaril@808
  1250
insilmaril@808
  1251
	viewMenu->addSeparator();	
insilmaril@808
  1252
insilmaril@808
  1253
	a = new QAction(tr( "Antialiasing","View action" ),this );
insilmaril@808
  1254
	a->setStatusTip ( tr( "Antialiasing" ));
insilmaril@808
  1255
	a->setToggleAction(true);
insilmaril@808
  1256
	a->setChecked (settings.value("/mainwindow/view/AntiAlias",true).toBool());
insilmaril@824
  1257
	switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
insilmaril@808
  1258
	viewMenu->addAction (a);
insilmaril@808
  1259
	connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
insilmaril@808
  1260
	actionViewToggleAntiAlias=a;
insilmaril@808
  1261
insilmaril@808
  1262
	a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
insilmaril@808
  1263
	a->setStatusTip (a->text());
insilmaril@808
  1264
	a->setToggleAction(true);
insilmaril@808
  1265
	a->setChecked (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
insilmaril@824
  1266
	switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
insilmaril@808
  1267
	viewMenu->addAction (a);
insilmaril@808
  1268
	connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
insilmaril@808
  1269
	actionViewToggleSmoothPixmapTransform=a;
insilmaril@808
  1270
insilmaril@808
  1271
	a = new QAction(tr( "Next Map","View action" ), this);
insilmaril@808
  1272
	a->setStatusTip (a->text());
insilmaril@808
  1273
	a->setShortcut (Qt::ALT + Qt::Key_N );
insilmaril@824
  1274
	switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
insilmaril@808
  1275
	viewMenu->addAction (a);
insilmaril@808
  1276
	connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
insilmaril@808
  1277
insilmaril@808
  1278
	a = new QAction (tr( "Previous Map","View action" ), this );
insilmaril@808
  1279
	a->setStatusTip (a->text());
insilmaril@808
  1280
	a->setShortcut (Qt::ALT + Qt::Key_P );
insilmaril@824
  1281
	switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
insilmaril@808
  1282
	viewMenu->addAction (a);
insilmaril@808
  1283
	connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
insilmaril@0
  1284
}
insilmaril@0
  1285
insilmaril@89
  1286
// Mode Actions
insilmaril@89
  1287
void Main::setupModeActions()
insilmaril@89
  1288
{
insilmaril@808
  1289
	//QPopupMenu *menu = new QPopupMenu( this );
insilmaril@808
  1290
	//menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
insilmaril@808
  1291
insilmaril@808
  1292
	QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
insilmaril@808
  1293
	tb->setObjectName ("modesTB");
insilmaril@808
  1294
	QAction *a;
insilmaril@808
  1295
	actionGroupModModes=new QActionGroup ( this);
insilmaril@808
  1296
	actionGroupModModes->setExclusive (true);
insilmaril@808
  1297
	a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
insilmaril@808
  1298
	a->setShortcut (Qt::Key_J);
insilmaril@824
  1299
	switchboard.addConnection(a,tr("Modes","Shortcut group"));
insilmaril@808
  1300
	a->setStatusTip ( tr( "Use modifier to color branches" ));
insilmaril@808
  1301
	a->setToggleAction(true);
insilmaril@808
  1302
	a->addTo (tb);
insilmaril@808
  1303
	a->setChecked(true);
insilmaril@808
  1304
	actionModModeColor=a;
insilmaril@808
  1305
insilmaril@808
  1306
	a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
insilmaril@808
  1307
	a->setShortcut( Qt::Key_K); 
insilmaril@824
  1308
	switchboard.addConnection(a,tr("Modes","Shortcut group"));
insilmaril@808
  1309
	a->setStatusTip( tr( "Use modifier to copy" ));
insilmaril@808
  1310
	a->setToggleAction(true);
insilmaril@808
  1311
	a->addTo (tb);
insilmaril@808
  1312
	actionModModeCopy=a;
insilmaril@808
  1313
insilmaril@808
  1314
	a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
insilmaril@808
  1315
	a->setShortcut (Qt::Key_L);
insilmaril@824
  1316
	switchboard.addConnection(a,tr("Modes","Shortcut group"));
insilmaril@808
  1317
	a->setStatusTip( tr( "Use modifier to draw xLinks" ));
insilmaril@808
  1318
	a->setToggleAction(true);
insilmaril@808
  1319
	a->addTo (tb);
insilmaril@808
  1320
	actionModModeXLink=a;
insilmaril@89
  1321
}
insilmaril@89
  1322
insilmaril@0
  1323
// Flag Actions
insilmaril@0
  1324
void Main::setupFlagActions()
insilmaril@0
  1325
{
insilmaril@808
  1326
	// Create System Flags
insilmaril@808
  1327
	QToolBar *tb=NULL;
insilmaril@808
  1328
insilmaril@837
  1329
	Flag *flag=new Flag(flagsPath+"flag-note.png");
insilmaril@808
  1330
	setupFlag (flag,tb,"system-note",tr("Note","SystemFlag"));
insilmaril@808
  1331
insilmaril@837
  1332
	flag=new Flag(flagsPath+"flag-url.png");
insilmaril@808
  1333
	setupFlag (flag,tb,"system-url",tr("URL to Document ","SystemFlag"));
insilmaril@808
  1334
insilmaril@837
  1335
	flag=new Flag(flagsPath+"flag-url-bugzilla-novell.png");
insilmaril@823
  1336
	setupFlag (flag,tb,"system-url-bugzilla-novell",tr("URL to Bugzilla ","SystemFlag"));
insilmaril@823
  1337
insilmaril@837
  1338
	flag=new Flag(flagsPath+"flag-vymlink.png");
insilmaril@808
  1339
	setupFlag (flag,tb,"system-vymLink",tr("Link to another vym map","SystemFlag"));
insilmaril@808
  1340
insilmaril@837
  1341
	flag=new Flag(flagsPath+"flag-scrolled-right.png");
insilmaril@808
  1342
	setupFlag (flag,tb,"system-scrolledright",tr("subtree is scrolled","SystemFlag"));
insilmaril@808
  1343
insilmaril@837
  1344
	flag=new Flag(flagsPath+"flag-tmpUnscrolled-right.png");
insilmaril@808
  1345
	setupFlag (flag,tb,"system-tmpUnscrolledRight",tr("subtree is temporary scrolled","SystemFlag"));
insilmaril@808
  1346
insilmaril@837
  1347
	flag=new Flag(flagsPath+"flag-hideexport.png");
insilmaril@808
  1348
	setupFlag (flag,tb,"system-hideInExport",tr("Hide object in exported maps","SystemFlag"));
insilmaril@808
  1349
insilmaril@808
  1350
	// Create Standard Flags
insilmaril@808
  1351
	tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
insilmaril@808
  1352
	tb->setObjectName ("standardFlagTB");
insilmaril@808
  1353
	standardFlagsMaster->setToolBar (tb);
insilmaril@808
  1354
insilmaril@837
  1355
	flag=new Flag(flagsPath+"flag-exclamationmark.png");
insilmaril@808
  1356
	flag->setGroup("standard-mark");
insilmaril@808
  1357
	setupFlag (flag,tb,"exclamationmark",tr("Take care!","Standardflag"));
insilmaril@808
  1358
insilmaril@837
  1359
	flag=new Flag(flagsPath+"flag-questionmark.png");
insilmaril@808
  1360
	flag->setGroup("standard-mark");
insilmaril@808
  1361
	setupFlag (flag,tb,"questionmark",tr("Really?","Standardflag"));
insilmaril@808
  1362
insilmaril@837
  1363
	flag=new Flag(flagsPath+"flag-hook-green.png");
insilmaril@815
  1364
	flag->setGroup("standard-status");
insilmaril@815
  1365
	setupFlag (flag,tb,"hook-green",tr("Status - ok,done","Standardflag"));
insilmaril@815
  1366
insilmaril@837
  1367
	flag=new Flag(flagsPath+"flag-wip.png");
insilmaril@815
  1368
	flag->setGroup("standard-status");
insilmaril@815
  1369
	setupFlag (flag,tb,"wip",tr("Status - work in progress","Standardflag"));
insilmaril@808
  1370
insilmaril@837
  1371
	flag=new Flag(flagsPath+"flag-cross-red.png");
insilmaril@815
  1372
	flag->setGroup("standard-status");
insilmaril@815
  1373
	setupFlag (flag,tb,"cross-red",tr("Status - missing, not started","Standardflag"));
insilmaril@808
  1374
	flag->unsetGroup();
insilmaril@808
  1375
insilmaril@837
  1376
	flag=new Flag(flagsPath+"flag-stopsign.png");
insilmaril@808
  1377
	setupFlag (flag,tb,"stopsign",tr("This won't work!","Standardflag"));
insilmaril@808
  1378
insilmaril@837
  1379
	flag=new Flag(flagsPath+"flag-smiley-good.png");
insilmaril@808
  1380
	flag->setGroup("standard-smiley");
insilmaril@808
  1381
	setupFlag (flag,tb,"smiley-good",tr("Good","Standardflag"));
insilmaril@808
  1382
insilmaril@837
  1383
	flag=new Flag(flagsPath+"flag-smiley-sad.png");
insilmaril@808
  1384
	flag->setGroup("standard-smiley");
insilmaril@808
  1385
	setupFlag (flag,tb,"smiley-sad",tr("Bad","Standardflag"));
insilmaril@808
  1386
insilmaril@837
  1387
	flag=new Flag(flagsPath+"flag-smiley-omg.png");
insilmaril@808
  1388
	flag->setGroup("standard-smiley");
insilmaril@808
  1389
	setupFlag (flag,tb,"smiley-omb",tr("Oh no!","Standardflag"));
insilmaril@808
  1390
	// Original omg.png (in KDE emoticons)
insilmaril@808
  1391
	flag->unsetGroup();
insilmaril@808
  1392
insilmaril@837
  1393
	flag=new Flag(flagsPath+"flag-kalarm.png");
insilmaril@808
  1394
	setupFlag (flag,tb,"clock",tr("Time critical","Standardflag"));
insilmaril@808
  1395
insilmaril@837
  1396
	flag=new Flag(flagsPath+"flag-phone.png");
insilmaril@808
  1397
	setupFlag (flag,tb,"phone",tr("Call...","Standardflag"));
insilmaril@808
  1398
insilmaril@837
  1399
	flag=new Flag(flagsPath+"flag-lamp.png");
insilmaril@808
  1400
	setupFlag (flag,tb,"lamp",tr("Idea!","Standardflag"));
insilmaril@808
  1401
insilmaril@837
  1402
	flag=new Flag(flagsPath+"flag-arrow-up.png");
insilmaril@808
  1403
	flag->setGroup("standard-arrow");
insilmaril@808
  1404
	setupFlag (flag,tb,"arrow-up",tr("Important","Standardflag"));
insilmaril@808
  1405
insilmaril@837
  1406
	flag=new Flag(flagsPath+"flag-arrow-down.png");
insilmaril@808
  1407
	flag->setGroup("standard-arrow");
insilmaril@808
  1408
	setupFlag (flag,tb,"arrow-down",tr("Unimportant","Standardflag"));
insilmaril@808
  1409
insilmaril@837
  1410
	flag=new Flag(flagsPath+"flag-arrow-2up.png");
insilmaril@808
  1411
	flag->setGroup("standard-arrow");
insilmaril@808
  1412
	setupFlag (flag,tb,"2arrow-up",tr("Very important!","Standardflag"));
insilmaril@808
  1413
insilmaril@837
  1414
	flag=new Flag(flagsPath+"flag-arrow-2down.png");
insilmaril@808
  1415
	flag->setGroup("standard-arrow");
insilmaril@808
  1416
	setupFlag (flag,tb,"2arrow-down",tr("Very unimportant!","Standardflag"));
insilmaril@808
  1417
	flag->unsetGroup();
insilmaril@808
  1418
insilmaril@837
  1419
	flag=new Flag(flagsPath+"flag-thumb-up.png");
insilmaril@808
  1420
	flag->setGroup("standard-thumb");
insilmaril@808
  1421
	setupFlag (flag,tb,"thumb-up",tr("I like this","Standardflag"));
insilmaril@808
  1422
insilmaril@837
  1423
	flag=new Flag(flagsPath+"flag-thumb-down.png");
insilmaril@808
  1424
	flag->setGroup("standard-thumb");
insilmaril@808
  1425
	setupFlag (flag,tb,"thumb-down",tr("I do not like this","Standardflag"));
insilmaril@808
  1426
	flag->unsetGroup();
insilmaril@808
  1427
insilmaril@837
  1428
	flag=new Flag(flagsPath+"flag-rose.png");
insilmaril@808
  1429
	setupFlag (flag,tb,"rose",tr("Rose","Standardflag"));
insilmaril@808
  1430
insilmaril@837
  1431
	flag=new Flag(flagsPath+"flag-heart.png");
insilmaril@808
  1432
	setupFlag (flag,tb,"heart",tr("I just love...","Standardflag"));
insilmaril@808
  1433
insilmaril@837
  1434
	flag=new Flag(flagsPath+"flag-present.png");
insilmaril@808
  1435
	setupFlag (flag,tb,"present",tr("Surprise!","Standardflag"));
insilmaril@808
  1436
insilmaril@837
  1437
	flag=new Flag(flagsPath+"flag-flash.png");
insilmaril@808
  1438
	setupFlag (flag,tb,"flash",tr("Dangerous","Standardflag"));
insilmaril@808
  1439
insilmaril@808
  1440
	// Original: xsldbg_output.png
insilmaril@837
  1441
	flag=new Flag(flagsPath+"flag-info.png");
insilmaril@808
  1442
	setupFlag (flag,tb,"info",tr("Info","Standardflag"));
insilmaril@808
  1443
insilmaril@808
  1444
	// Original khelpcenter.png
insilmaril@837
  1445
	flag=new Flag(flagsPath+"flag-lifebelt.png");
insilmaril@808
  1446
	setupFlag (flag,tb,"lifebelt",tr("This will help","Standardflag"));
insilmaril@808
  1447
insilmaril@808
  1448
	// Freemind flags
insilmaril@837
  1449
	flag=new Flag(flagsPath+"freemind/warning.png");
insilmaril@808
  1450
	flag->setVisible(false);
insilmaril@808
  1451
	setupFlag (flag,tb,  "freemind-warning",tr("Important","Freemind-Flag"));
insilmaril@808
  1452
insilmaril@808
  1453
	for (int i=1; i<8; i++)
insilmaril@808
  1454
	{
insilmaril@837
  1455
		flag=new Flag(flagsPath+QString("freemind/priority-%1.png").arg(i));
insilmaril@838
  1456
		flag->setVisible(false);
insilmaril@838
  1457
		flag->setGroup ("Freemind-priority");
insilmaril@808
  1458
		setupFlag (flag,tb, QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
insilmaril@808
  1459
	}
insilmaril@808
  1460
insilmaril@837
  1461
	flag=new Flag(flagsPath+"freemind/back.png");
insilmaril@837
  1462
	flag->setVisible(false);
insilmaril@808
  1463
	setupFlag (flag,tb,"freemind-back",tr("Back","Freemind-Flag"));
insilmaril@808
  1464
insilmaril@837
  1465
	flag=new Flag(flagsPath+"freemind/forward.png");
insilmaril@837
  1466
	flag->setVisible(false);
insilmaril@808
  1467
	setupFlag (flag,tb,"freemind-forward",tr("forward","Freemind-Flag"));
insilmaril@808
  1468
insilmaril@837
  1469
	flag=new Flag(flagsPath+"freemind/attach.png");
insilmaril@837
  1470
	flag->setVisible(false);
insilmaril@808
  1471
	setupFlag (flag,tb,"freemind-attach",tr("Look here","Freemind-Flag"));
insilmaril@808
  1472
insilmaril@837
  1473
	flag=new Flag(flagsPath+"freemind/clanbomber.png");
insilmaril@837
  1474
	flag->setVisible(false);
insilmaril@808
  1475
	setupFlag (flag,tb,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
insilmaril@808
  1476
insilmaril@837
  1477
	flag=new Flag(flagsPath+"freemind/desktopnew.png");
insilmaril@837
  1478
	flag->setVisible(false);
insilmaril@808
  1479
	setupFlag (flag,tb,"freemind-desktopnew",tr("Don't flagrget","Freemind-Flag"));
insilmaril@808
  1480
insilmaril@837
  1481
	flag=new Flag(flagsPath+"freemind/flag.png");
insilmaril@837
  1482
	flag->setVisible(false);
insilmaril@808
  1483
	setupFlag (flag,tb,"freemind-flag",tr("Flag","Freemind-Flag"));
insilmaril@808
  1484
insilmaril@808
  1485
insilmaril@837
  1486
	flag=new Flag(flagsPath+"freemind/gohome.png");
insilmaril@837
  1487
	flag->setVisible(false);
insilmaril@808
  1488
	setupFlag (flag,tb,"freemind-gohome",tr("Home","Freemind-Flag"));
insilmaril@808
  1489
insilmaril@837
  1490
	flag=new Flag(flagsPath+"freemind/kaddressbook.png");
insilmaril@837
  1491
	flag->setVisible(false);
insilmaril@808
  1492
	setupFlag (flag,tb,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
insilmaril@808
  1493
insilmaril@837
  1494
	flag=new Flag(flagsPath+"freemind/knotify.png");
insilmaril@837
  1495
	flag->setVisible(false);
insilmaril@808
  1496
	setupFlag (flag,tb,"freemind-knotify",tr("Music","Freemind-Flag"));
insilmaril@808
  1497
insilmaril@837
  1498
	flag=new Flag(flagsPath+"freemind/korn.png");
insilmaril@837
  1499
	flag->setVisible(false);
insilmaril@808
  1500
	setupFlag (flag,tb,"freemind-korn",tr("Mailbox","Freemind-Flag"));
insilmaril@808
  1501
insilmaril@837
  1502
	flag=new Flag(flagsPath+"freemind/mail.png");
insilmaril@837
  1503
	flag->setVisible(false);
insilmaril@808
  1504
	setupFlag (flag,tb,"freemind-mail",tr("Maix","Freemind-Flag"));
insilmaril@808
  1505
insilmaril@837
  1506
	flag=new Flag(flagsPath+"freemind/password.png");
insilmaril@837
  1507
	flag->setVisible(false);
insilmaril@808
  1508
	setupFlag (flag,tb,"freemind-password",tr("Password","Freemind-Flag"));
insilmaril@808
  1509
insilmaril@837
  1510
	flag=new Flag(flagsPath+"freemind/pencil.png");
insilmaril@837
  1511
	flag->setVisible(false);
insilmaril@808
  1512
	setupFlag (flag,tb,"freemind-pencil",tr("To be improved","Freemind-Flag"));
insilmaril@808
  1513
insilmaril@837
  1514
	flag=new Flag(flagsPath+"freemind/stop.png");
insilmaril@837
  1515
	flag->setVisible(false);
insilmaril@808
  1516
	setupFlag (flag,tb,"freemind-stop",tr("Stop","Freemind-Flag"));
insilmaril@808
  1517
insilmaril@837
  1518
	flag=new Flag(flagsPath+"freemind/wizard.png");
insilmaril@837
  1519
	flag->setVisible(false);
insilmaril@808
  1520
	setupFlag (flag,tb,"freemind-wizard",tr("Magic","Freemind-Flag"));
insilmaril@808
  1521
insilmaril@837
  1522
	flag=new Flag(flagsPath+"freemind/xmag.png");
insilmaril@837
  1523
	flag->setVisible(false);
insilmaril@808
  1524
	setupFlag (flag,tb,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
insilmaril@808
  1525
insilmaril@837
  1526
	flag=new Flag(flagsPath+"freemind/bell.png");
insilmaril@837
  1527
	flag->setVisible(false);
insilmaril@808
  1528
	setupFlag (flag,tb,"freemind-bell",tr("Reminder","Freemind-Flag"));
insilmaril@808
  1529
insilmaril@837
  1530
	flag=new Flag(flagsPath+"freemind/bookmark.png");
insilmaril@837
  1531
	flag->setVisible(false);
insilmaril@808
  1532
	setupFlag (flag,tb,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
insilmaril@808
  1533
insilmaril@837
  1534
	flag= new Flag(flagsPath+"freemind/penguin.png");
insilmaril@837
  1535
	flag->setVisible(false);
insilmaril@808
  1536
	setupFlag (flag,tb,"freemind-penguin",tr("Linux","Freemind-Flag"));
insilmaril@808
  1537
insilmaril@837
  1538
	flag=new Flag (flagsPath+"freemind/licq.png");
insilmaril@837
  1539
	flag->setVisible(false);
insilmaril@808
  1540
	setupFlag (flag,tb,"freemind-licq",tr("Sweet","Freemind-Flag"));
insilmaril@564
  1541
}
insilmaril@564
  1542
insilmaril@767
  1543
void Main::setupFlag (Flag *flag, QToolBar *tb, const QString &name, const QString &tooltip)
insilmaril@564
  1544
{
insilmaril@808
  1545
	flag->setName(name);
insilmaril@808
  1546
	flag->setToolTip (tooltip);
insilmaril@808
  1547
	QAction *a;
insilmaril@808
  1548
	if (tb)
insilmaril@808
  1549
	{
insilmaril@808
  1550
		a=new QAction (flag->getPixmap(),name,this);
insilmaril@808
  1551
		// StandardFlag
insilmaril@808
  1552
		tb->addAction (a);
insilmaril@808
  1553
		flag->setAction (a);
insilmaril@808
  1554
		a->setVisible (flag->isVisible());
insilmaril@808
  1555
		a->setCheckable(true);
insilmaril@808
  1556
		a->setObjectName(name);
insilmaril@808
  1557
		a->setToolTip(tooltip);
insilmaril@808
  1558
		connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
insilmaril@808
  1559
		standardFlagsMaster->addFlag (flag);	
insilmaril@808
  1560
	} else
insilmaril@808
  1561
	{
insilmaril@808
  1562
		// SystemFlag
insilmaril@808
  1563
		systemFlagsMaster->addFlag (flag);	
insilmaril@808
  1564
	}
insilmaril@0
  1565
}
insilmaril@767
  1566
insilmaril@528
  1567
// Network Actions
insilmaril@528
  1568
void Main::setupNetworkActions()
insilmaril@528
  1569
{
insilmaril@808
  1570
	if (!settings.value( "/mainwindow/showTestMenu",false).toBool() ) 
insilmaril@808
  1571
		return;
insilmaril@808
  1572
	QMenu *netMenu = menuBar()->addMenu(  "Network" );
insilmaril@808
  1573
insilmaril@808
  1574
	QAction *a;
insilmaril@808
  1575
insilmaril@808
  1576
	a = new QAction(  "Start TCPserver for MapEditor",this);
insilmaril@808
  1577
	//a->setStatusTip ( "Set application to open pdf files"));
insilmaril@808
  1578
	//a->setShortcut ( Qt::ALT + Qt::Key_T );		//New TCP server
insilmaril@824
  1579
	switchboard.addConnection(a,tr("Network shortcuts","Shortcut group"));
insilmaril@808
  1580
	connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
insilmaril@808
  1581
	netMenu->addAction (a);
insilmaril@808
  1582
insilmaril@808
  1583
	a = new QAction(  "Connect MapEditor to server",this);
insilmaril@808
  1584
	//a->setStatusTip ( "Set application to open pdf files"));
insilmaril@808
  1585
	a->setShortcut ( Qt::ALT + Qt::Key_C );		// Connect to server
insilmaril@824
  1586
	switchboard.addConnection(a,tr("Network shortcuts","Shortcut group"));
insilmaril@808
  1587
	connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
insilmaril@808
  1588
	netMenu->addAction (a);
insilmaril@528
  1589
}
insilmaril@807
  1590
insilmaril@0
  1591
// Settings Actions
insilmaril@0
  1592
void Main::setupSettingsActions()
insilmaril@0
  1593
{
insilmaril@808
  1594
	QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
insilmaril@808
  1595
insilmaril@808
  1596
	QAction *a;
insilmaril@808
  1597
insilmaril@808
  1598
	a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
insilmaril@808
  1599
	a->setStatusTip ( tr( "Set application to open pdf files"));
insilmaril@808
  1600
	connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
insilmaril@808
  1601
	settingsMenu->addAction (a);
insilmaril@808
  1602
insilmaril@808
  1603
	a = new QAction( tr( "Set application to open external links","Settings action"), this);
insilmaril@808
  1604
	a->setStatusTip( tr( "Set application to open external links"));
insilmaril@808
  1605
	connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
insilmaril@808
  1606
	settingsMenu->addAction (a);
insilmaril@808
  1607
insilmaril@808
  1608
	a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
insilmaril@808
  1609
	a->setStatusTip( tr( "Set path for macros"));
insilmaril@808
  1610
	connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
insilmaril@808
  1611
	settingsMenu->addAction (a);
insilmaril@808
  1612
insilmaril@808
  1613
	a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
insilmaril@808
  1614
	a->setStatusTip( tr( "Set number of undo levels"));
insilmaril@808
  1615
	connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
insilmaril@808
  1616
	settingsMenu->addAction (a);
insilmaril@808
  1617
insilmaril@808
  1618
	settingsMenu->addSeparator();
insilmaril@808
  1619
insilmaril@808
  1620
	a = new QAction( tr( "Autosave","Settings action"), this);
insilmaril@808
  1621
	a->setStatusTip( tr( "Autosave"));
insilmaril@808
  1622
	a->setToggleAction(true);
insilmaril@808
  1623
	a->setChecked ( settings.value ("/mainwindow/autosave/use",false).toBool());
insilmaril@808
  1624
	connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
insilmaril@808
  1625
	settingsMenu->addAction (a);
insilmaril@808
  1626
	actionSettingsAutosaveToggle=a;
insilmaril@808
  1627
insilmaril@808
  1628
	a = new QAction( tr( "Autosave time","Settings action")+"...", this);
insilmaril@808
  1629
	a->setStatusTip( tr( "Autosave time"));
insilmaril@808
  1630
	connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
insilmaril@808
  1631
	settingsMenu->addAction (a);
insilmaril@808
  1632
	actionSettingsAutosaveTime=a;
insilmaril@808
  1633
insilmaril@808
  1634
	a = new QAction( tr( "Write backup file on save","Settings action"), this);
insilmaril@808
  1635
	a->setStatusTip( tr( "Write backup file on save"));
insilmaril@808
  1636
	a->setToggleAction(true);
insilmaril@808
  1637
	a->setChecked ( settings.value ("/mainwindow/writeBackupFile",false).toBool());
insilmaril@808
  1638
	connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) );
insilmaril@808
  1639
	settingsMenu->addAction (a);
insilmaril@808
  1640
	actionSettingsWriteBackupFile=a;
insilmaril@808
  1641
insilmaril@808
  1642
	settingsMenu->addSeparator();
insilmaril@808
  1643
insilmaril@808
  1644
	a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
insilmaril@808
  1645
	a->setStatusTip( tr( "Edit branch after adding it" ));
insilmaril@808
  1646
	a->setToggleAction(true);
insilmaril@808
  1647
	a->setChecked ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
insilmaril@808
  1648
	settingsMenu->addAction (a);
insilmaril@808
  1649
	actionSettingsAutoEditNewBranch=a;
insilmaril@808
  1650
insilmaril@808
  1651
	a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
insilmaril@808
  1652
	a->setStatusTip( tr( "Select branch after adding it" ));
insilmaril@808
  1653
	a->setToggleAction(true);
insilmaril@808
  1654
	a->setChecked ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
insilmaril@808
  1655
	settingsMenu->addAction (a);
insilmaril@808
  1656
	actionSettingsAutoSelectNewBranch=a;
insilmaril@808
  1657
insilmaril@808
  1658
	a= new QAction(tr( "Select existing heading","Settings action" ), this);
insilmaril@808
  1659
	a->setStatusTip( tr( "Select heading before editing" ));
insilmaril@808
  1660
	a->setToggleAction(true);
insilmaril@808
  1661
	a->setChecked ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
insilmaril@808
  1662
	settingsMenu->addAction (a);
insilmaril@808
  1663
	actionSettingsAutoSelectText=a;
insilmaril@808
  1664
insilmaril@808
  1665
	a= new QAction( tr( "Delete key","Settings action" ), this);
insilmaril@808
  1666
	a->setStatusTip( tr( "Delete key for deleting branches" ));
insilmaril@808
  1667
	a->setToggleAction(true);
insilmaril@808
  1668
	a->setChecked ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
insilmaril@808
  1669
	settingsMenu->addAction (a);
insilmaril@808
  1670
	connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
insilmaril@808
  1671
	actionSettingsUseDelKey=a;
insilmaril@808
  1672
insilmaril@808
  1673
	a= new QAction( tr( "Exclusive flags","Settings action" ), this);
insilmaril@808
  1674
	a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
insilmaril@808
  1675
	a->setToggleAction(true);
insilmaril@808
  1676
	a->setChecked ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
insilmaril@808
  1677
	settingsMenu->addAction (a);
insilmaril@808
  1678
	actionSettingsUseFlagGroups=a;
insilmaril@808
  1679
insilmaril@808
  1680
	a= new QAction( tr( "Use hide flags","Settings action" ), this);
insilmaril@808
  1681
	a->setStatusTip( tr( "Use hide flag during exports " ));
insilmaril@808
  1682
	a->setToggleAction(true);
insilmaril@808
  1683
	a->setChecked ( settings.value ("/export/useHideExport",true).toBool() );
insilmaril@808
  1684
	settingsMenu->addAction (a);
insilmaril@808
  1685
	actionSettingsUseHideExport=a;
insilmaril@808
  1686
insilmaril@837
  1687
	settingsMenu->addSeparator();
insilmaril@837
  1688
insilmaril@808
  1689
	a = new QAction( tr( "Animation","Settings action"), this);
insilmaril@808
  1690
	a->setStatusTip( tr( "Animation"));
insilmaril@808
  1691
	a->setToggleAction(true);
insilmaril@808
  1692
	a->setChecked (settings.value("/animation/use",true).toBool() );
insilmaril@808
  1693
	connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) );
insilmaril@808
  1694
	settingsMenu->addAction (a);
insilmaril@808
  1695
	actionSettingsUseAnimation=a;
insilmaril@837
  1696
insilmaril@837
  1697
	a = new QAction( tr( "Automatic layout","Settings action"), this);
insilmaril@837
  1698
	a->setStatusTip( tr( "Automatic layout"));
insilmaril@837
  1699
	a->setToggleAction(true);
insilmaril@837
  1700
	a->setChecked ( settings.value ("/mainwindow/autoLayout/use",true).toBool());
insilmaril@837
  1701
	connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutoLayoutToggle() ) );
insilmaril@837
  1702
	settingsMenu->addAction (a);
insilmaril@837
  1703
	actionSettingsAutoLayoutToggle=a;
insilmaril@837
  1704
insilmaril@0
  1705
}
insilmaril@0
  1706
insilmaril@0
  1707
// Test Actions
insilmaril@0
  1708
void Main::setupTestActions()
insilmaril@0
  1709
{
insilmaril@829
  1710
	QMenu *testMenu = menuBar()->addMenu( tr( "Test" ));
insilmaril@808
  1711
insilmaril@808
  1712
	QAction *a;
insilmaril@808
  1713
	a = new QAction( "Test function 1" , this);
insilmaril@808
  1714
	a->setStatusTip( "Call test function 1" );
insilmaril@823
  1715
	a->setShortcut (Qt::SHIFT + Qt::Key_T);	// Test function 1  
insilmaril@824
  1716
	switchboard.addConnection(a,tr("Test shortcuts","Shortcut group"));
insilmaril@808
  1717
	testMenu->addAction (a);
insilmaril@808
  1718
	connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
insilmaril@808
  1719
insilmaril@808
  1720
	a = new QAction( "Test function 2" , this);
insilmaril@808
  1721
	a->setStatusTip( "Call test function 2" );
insilmaril@823
  1722
	a->setShortcut (Qt::ALT + Qt::Key_T);	// Test function 2
insilmaril@824
  1723
	switchboard.addConnection(a,tr("Test shortcuts","Shortcut group"));
insilmaril@808
  1724
	testMenu->addAction (a);
insilmaril@808
  1725
	connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
insilmaril@808
  1726
insilmaril@808
  1727
	a = new QAction( "Command" , this);
insilmaril@808
  1728
	a->setStatusTip( "Enter command to call in editor" );
insilmaril@824
  1729
	switchboard.addConnection(a,tr("Test shortcuts","Shortcut group"));
insilmaril@808
  1730
	connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
insilmaril@808
  1731
	testMenu->addAction (a);
insilmaril@0
  1732
}
insilmaril@0
  1733
insilmaril@0
  1734
// Help Actions
insilmaril@0
  1735
void Main::setupHelpActions()
insilmaril@0
  1736
{
insilmaril@808
  1737
	QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
insilmaril@808
  1738
insilmaril@808
  1739
	QAction *a;
insilmaril@808
  1740
	a = new QAction(  tr( "Open VYM Documentation (pdf) ","Help action" ), this );
insilmaril@808
  1741
	a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
insilmaril@824
  1742
	switchboard.addConnection(a,tr("Help shortcuts","Shortcut group"));
insilmaril@808
  1743
	connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
insilmaril@808
  1744
	helpMenu->addAction (a);
insilmaril@808
  1745
insilmaril@808
  1746
	a = new QAction(  tr( "Open VYM example maps ","Help action" ), this );
insilmaril@808
  1747
	a->setStatusTip( tr( "Open VYM example maps " ));
insilmaril@824
  1748
	switchboard.addConnection(a,tr("Help shortcuts","Shortcut group"));
insilmaril@808
  1749
	connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
insilmaril@808
  1750
	helpMenu->addAction (a);
insilmaril@808
  1751
insilmaril@808
  1752
	a = new QAction( tr( "About VYM","Help action" ), this);
insilmaril@808
  1753
	a->setStatusTip( tr( "About VYM")+vymName);
insilmaril@808
  1754
	connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
insilmaril@808
  1755
	helpMenu->addAction (a);
insilmaril@808
  1756
insilmaril@808
  1757
	a = new QAction( tr( "About QT","Help action" ), this);
insilmaril@808
  1758
	a->setStatusTip( tr( "Information about QT toolkit" ));
insilmaril@808
  1759
	connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
insilmaril@808
  1760
	helpMenu->addAction (a);
insilmaril@0
  1761
}
insilmaril@0
  1762
insilmaril@0
  1763
// Context Menus
insilmaril@0
  1764
void Main::setupContextMenus()
insilmaril@0
  1765
{
insilmaril@808
  1766
	// Context Menu for branch or mapcenter
insilmaril@808
  1767
	branchContextMenu =new QMenu (this);
insilmaril@808
  1768
	branchContextMenu->addAction (actionViewTogglePropertyWindow);
insilmaril@421
  1769
	branchContextMenu->addSeparator();	
insilmaril@808
  1770
insilmaril@808
  1771
		// Submenu "Add"
insilmaril@808
  1772
		branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
insilmaril@808
  1773
		branchAddContextMenu->addAction (actionPaste );
insilmaril@808
  1774
		branchAddContextMenu->addAction ( actionAddMapCenter );
insilmaril@808
  1775
		branchAddContextMenu->addAction ( actionAddBranch );
insilmaril@808
  1776
		branchAddContextMenu->addAction ( actionAddBranchBefore );
insilmaril@808
  1777
		branchAddContextMenu->addAction ( actionAddBranchAbove);
insilmaril@808
  1778
		branchAddContextMenu->addAction ( actionAddBranchBelow );
insilmaril@808
  1779
		branchAddContextMenu->addSeparator();	
insilmaril@808
  1780
		branchAddContextMenu->addAction ( actionImportAdd );
insilmaril@808
  1781
		branchAddContextMenu->addAction ( actionImportReplace );
insilmaril@808
  1782
insilmaril@808
  1783
		// Submenu "Remove"
insilmaril@808
  1784
		branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
insilmaril@808
  1785
		branchRemoveContextMenu->addAction (actionCut);
insilmaril@808
  1786
		branchRemoveContextMenu->addAction ( actionDelete );
insilmaril@808
  1787
		branchRemoveContextMenu->addAction ( actionDeleteKeepChildren );
insilmaril@808
  1788
		branchRemoveContextMenu->addAction ( actionDeleteChildren );
insilmaril@808
  1789
		
insilmaril@808
  1790
insilmaril@808
  1791
	actionSaveBranch->addTo( branchContextMenu );
insilmaril@808
  1792
	actionFileNewCopy->addTo (branchContextMenu );
insilmaril@808
  1793
	actionDetach->addTo (branchContextMenu );
insilmaril@808
  1794
insilmaril@808
  1795
	branchContextMenu->addSeparator();	
insilmaril@808
  1796
	branchContextMenu->addAction ( actionLoadImage);
insilmaril@818
  1797
	if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
insilmaril@818
  1798
		branchContextMenu->addAction ( actionAddAttribute);
insilmaril@808
  1799
insilmaril@808
  1800
	// Submenu for Links (URLs, vymLinks)
insilmaril@808
  1801
	branchLinksContextMenu =new QMenu (this);
insilmaril@808
  1802
insilmaril@808
  1803
		branchContextMenu->addSeparator();	
insilmaril@808
  1804
		branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));	
insilmaril@808
  1805
		branchLinksContextMenu->addAction ( actionOpenURL );
insilmaril@808
  1806
		branchLinksContextMenu->addAction ( actionOpenURLTab );
insilmaril@821
  1807
		branchLinksContextMenu->addAction ( actionOpenMultipleVisURLTabs );
insilmaril@808
  1808
		branchLinksContextMenu->addAction ( actionOpenMultipleURLTabs );
insilmaril@808
  1809
		branchLinksContextMenu->addAction ( actionURL );
insilmaril@808
  1810
		branchLinksContextMenu->addAction ( actionLocalURL );
insilmaril@808
  1811
		branchLinksContextMenu->addAction ( actionHeading2URL );
insilmaril@808
  1812
		branchLinksContextMenu->addAction ( actionBugzilla2URL );
insilmaril@808
  1813
		if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
insilmaril@808
  1814
		{
insilmaril@820
  1815
			branchLinksContextMenu->addAction ( actionGetBugzillaData );
insilmaril@808
  1816
			branchLinksContextMenu->addAction ( actionFATE2URL );
insilmaril@808
  1817
		}	
insilmaril@808
  1818
		branchLinksContextMenu->addSeparator();	
insilmaril@808
  1819
		branchLinksContextMenu->addAction ( actionOpenVymLink );
insilmaril@808
  1820
		branchLinksContextMenu->addAction ( actionOpenMultipleVymLinks );
insilmaril@808
  1821
		branchLinksContextMenu->addAction ( actionVymLink );
insilmaril@808
  1822
		branchLinksContextMenu->addAction ( actionDeleteVymLink );
insilmaril@808
  1823
		
insilmaril@808
  1824
insilmaril@808
  1825
	// Context Menu for XLinks in a branch menu
insilmaril@808
  1826
	// This will be populated "on demand" in MapEditor::updateActions
insilmaril@808
  1827
	branchContextMenu->addSeparator();	
insilmaril@808
  1828
	branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
insilmaril@808
  1829
	connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
insilmaril@808
  1830
insilmaril@808
  1831
insilmaril@808
  1832
	// Context menu for floatimage
insilmaril@808
  1833
	floatimageContextMenu =new QMenu (this);
insilmaril@837
  1834
	QAction *a= new QAction (tr ("Save image","Context action"),this);
insilmaril@808
  1835
	connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
insilmaril@808
  1836
	floatimageContextMenu->addAction (a);
insilmaril@808
  1837
insilmaril@808
  1838
	floatimageContextMenu->addSeparator();	
insilmaril@808
  1839
	actionCopy->addTo( floatimageContextMenu );
insilmaril@808
  1840
	actionCut->addTo( floatimageContextMenu );
insilmaril@808
  1841
insilmaril@808
  1842
	floatimageContextMenu->addSeparator();	
insilmaril@808
  1843
	floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
insilmaril@808
  1844
insilmaril@808
  1845
insilmaril@808
  1846
	// Context menu for canvas
insilmaril@808
  1847
	canvasContextMenu =new QMenu (this);
insilmaril@808
  1848
	actionAddMapCenter->addTo( canvasContextMenu );
insilmaril@808
  1849
	actionMapInfo->addTo( canvasContextMenu );
insilmaril@808
  1850
	canvasContextMenu->insertSeparator();	
insilmaril@808
  1851
	actionGroupFormatLinkStyles->addTo( canvasContextMenu );
insilmaril@808
  1852
	canvasContextMenu->insertSeparator();	
insilmaril@808
  1853
	actionFormatLinkColorHint->addTo( canvasContextMenu );
insilmaril@808
  1854
	actionFormatLinkColor->addTo( canvasContextMenu );
insilmaril@808
  1855
	actionFormatSelectionColor->addTo( canvasContextMenu );
insilmaril@808
  1856
	actionFormatBackColor->addTo( canvasContextMenu );
insilmaril@808
  1857
	// actionFormatBackImage->addTo( canvasContextMenu );  //FIXME-4 makes vym too slow: postponed for later version 
insilmaril@808
  1858
insilmaril@808
  1859
	// Menu for last opened files
insilmaril@808
  1860
	// Create actions
insilmaril@808
  1861
	for (int i = 0; i < MaxRecentFiles; ++i) 
insilmaril@807
  1862
	{
insilmaril@808
  1863
		recentFileActions[i] = new QAction(this);
insilmaril@808
  1864
		recentFileActions[i]->setVisible(false);
insilmaril@808
  1865
		fileLastMapsMenu->addAction(recentFileActions[i]);
insilmaril@808
  1866
		connect(recentFileActions[i], SIGNAL(triggered()),
insilmaril@808
  1867
				this, SLOT(fileLoadRecent()));
insilmaril@808
  1868
	}
insilmaril@808
  1869
	setupRecentMapsMenu();
insilmaril@0
  1870
}
insilmaril@0
  1871
insilmaril@401
  1872
void Main::setupRecentMapsMenu()
insilmaril@0
  1873
{
insilmaril@808
  1874
	QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
insilmaril@808
  1875
insilmaril@808
  1876
	int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
insilmaril@808
  1877
insilmaril@808
  1878
	for (int i = 0; i < numRecentFiles; ++i) {
insilmaril@808
  1879
		QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
insilmaril@808
  1880
		recentFileActions[i]->setText(text);
insilmaril@808
  1881
		recentFileActions[i]->setData(files[i]);
insilmaril@808
  1882
		recentFileActions[i]->setVisible(true);
insilmaril@808
  1883
	}
insilmaril@808
  1884
	for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
insilmaril@808
  1885
		recentFileActions[j]->setVisible(false);
insilmaril@445
  1886
}
insilmaril@445
  1887
insilmaril@445
  1888
void Main::setupMacros()
insilmaril@445
  1889
{
insilmaril@808
  1890
	for (int i = 0; i <= 11; i++) 
insilmaril@808
  1891
	{
insilmaril@808
  1892
		macroActions[i] = new QAction(this);
insilmaril@808
  1893
		macroActions[i]->setData(i);
insilmaril@808
  1894
		addAction (macroActions[i]);
insilmaril@824
  1895
		//switchboard.addConnection(macroActions[i],tr("Macro shortcuts","Shortcut group"));
insilmaril@808
  1896
		connect(macroActions[i], SIGNAL(triggered()),
insilmaril@808
  1897
				this, SLOT(callMacro()));
insilmaril@808
  1898
	}			
insilmaril@808
  1899
	macroActions[0]->setShortcut ( Qt::Key_F1 );
insilmaril@808
  1900
	macroActions[1]->setShortcut ( Qt::Key_F2 );
insilmaril@808
  1901
	macroActions[2]->setShortcut ( Qt::Key_F3 );
insilmaril@808
  1902
	macroActions[3]->setShortcut ( Qt::Key_F4 );
insilmaril@808
  1903
	macroActions[4]->setShortcut ( Qt::Key_F5 );
insilmaril@808
  1904
	macroActions[5]->setShortcut ( Qt::Key_F6 );
insilmaril@808
  1905
	macroActions[6]->setShortcut ( Qt::Key_F7 );
insilmaril@808
  1906
	macroActions[7]->setShortcut ( Qt::Key_F8 );
insilmaril@808
  1907
	macroActions[8]->setShortcut ( Qt::Key_F9 );
insilmaril@808
  1908
	macroActions[9]->setShortcut ( Qt::Key_F10 );
insilmaril@808
  1909
	macroActions[10]->setShortcut ( Qt::Key_F11 );
insilmaril@808
  1910
	macroActions[11]->setShortcut ( Qt::Key_F12 );
insilmaril@0
  1911
}
insilmaril@0
  1912
insilmaril@0
  1913
void Main::hideEvent (QHideEvent * )
insilmaril@0
  1914
{
insilmaril@808
  1915
	if (!textEditor->isMinimized() ) textEditor->hide();
insilmaril@0
  1916
}
insilmaril@0
  1917
insilmaril@0
  1918
void Main::showEvent (QShowEvent * )
insilmaril@0
  1919
{
insilmaril@808
  1920
	if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
insilmaril@0
  1921
}
insilmaril@0
  1922
insilmaril@0
  1923
insilmaril@0
  1924
MapEditor* Main::currentMapEditor() const
insilmaril@0
  1925
{
insilmaril@808
  1926
	if ( tabWidget->currentPage())
insilmaril@808
  1927
		return vymViews.at(tabWidget->currentIndex())->getMapEditor();
insilmaril@808
  1928
	return NULL;	
insilmaril@0
  1929
}
insilmaril@0
  1930
insilmaril@832
  1931
uint  Main::currentModelID() const
insilmaril@832
  1932
{
insilmaril@832
  1933
	if (currentModel())
insilmaril@832
  1934
		return currentModel()->getID();
insilmaril@832
  1935
	return 0;	
insilmaril@832
  1936
}
insilmaril@832
  1937
insilmaril@721
  1938
VymModel* Main::currentModel() const
insilmaril@721
  1939
{
insilmaril@808
  1940
	if ( tabWidget->currentPage())
insilmaril@808
  1941
		return vymViews.at(tabWidget->currentIndex())->getModel();
insilmaril@808
  1942
	return NULL;	
insilmaril@721
  1943
}
insilmaril@721
  1944
insilmaril@834
  1945
VymModel* Main::getModel(uint id) const	
insilmaril@823
  1946
{
insilmaril@829
  1947
	// Used in BugAgent
insilmaril@834
  1948
	for (int i=0; i<vymViews.count();i++)
insilmaril@834
  1949
		if (vymViews.at(i)->getModel()->getID()==id)
insilmaril@834
  1950
			return vymViews.at(i)->getModel();
insilmaril@823
  1951
	return NULL;	
insilmaril@823
  1952
}
insilmaril@823
  1953
insilmaril@0
  1954
insilmaril@0
  1955
void Main::editorChanged(QWidget *)
insilmaril@0
  1956
{
insilmaril@808
  1957
	// Unselect all possibly selected objects
insilmaril@808
  1958
	// (Important to update note editor)
insilmaril@808
  1959
	VymModel *m;
insilmaril@808
  1960
	for (int i=0;i<=tabWidget->count() -1;i++)
insilmaril@808
  1961
	{
insilmaril@808
  1962
		m= vymViews.at(i)->getModel();
insilmaril@808
  1963
		if (m) m->unselect();
insilmaril@808
  1964
	}
insilmaril@808
  1965
	m=currentModel();
insilmaril@808
  1966
	if (m) m->reselect();
insilmaril@808
  1967
insilmaril@808
  1968
	// Update actions to in menus and toolbars according to editor
insilmaril@808
  1969
	updateActions();
insilmaril@0
  1970
}
insilmaril@0
  1971
insilmaril@0
  1972
void Main::fileNew()
insilmaril@0
  1973
{
insilmaril@808
  1974
	VymModel *vm=new VymModel;
insilmaril@808
  1975
insilmaril@808
  1976
	/////////////////////////////////////
insilmaril@816
  1977
//	new ModelTest(vm, this);	//FIXME-3
insilmaril@808
  1978
	/////////////////////////////////////
insilmaril@808
  1979
insilmaril@808
  1980
	VymView *vv=new VymView (vm);
insilmaril@808
  1981
	vymViews.append (vv);
insilmaril@808
  1982
	tabWidget->addTab (vv,tr("unnamed","MainWindow: name for new and empty file"));
insilmaril@808
  1983
	tabWidget->setCurrentIndex (vymViews.count() );
insilmaril@808
  1984
	vv->initFocus();
insilmaril@808
  1985
insilmaril@808
  1986
	// Create MapCenter for empty map
insilmaril@808
  1987
	vm->addMapCenter();
insilmaril@808
  1988
	vm->makeDefault();
insilmaril@808
  1989
insilmaril@808
  1990
	// For the very first map we do not have flagrows yet...
insilmaril@808
  1991
	vm->select("mc:");
insilmaril@0
  1992
}
insilmaril@0
  1993
insilmaril@491
  1994
void Main::fileNewCopy()
insilmaril@491
  1995
{
insilmaril@808
  1996
	QString fn="unnamed";
insilmaril@808
  1997
	VymModel *srcModel=currentModel();
insilmaril@808
  1998
	if (srcModel)
insilmaril@808
  1999
	{
insilmaril@808
  2000
		srcModel->copy();
insilmaril@808
  2001
		fileNew();
insilmaril@808
  2002
		VymModel *dstModel=vymViews.last()->getModel();
insilmaril@808
  2003
		dstModel->select("mc:");
insilmaril@808
  2004
		dstModel->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
insilmaril@808
  2005
	}
insilmaril@807
  2006
}
insilmaril@807
  2007
insilmaril@807
  2008
ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
insilmaril@807
  2009
{
insilmaril@808
  2010
	ErrorCode err=success;
insilmaril@808
  2011
insilmaril@808
  2012
	// fn is usually the archive, mapfile the file after uncompressing
insilmaril@808
  2013
	QString mapfile;
insilmaril@808
  2014
insilmaril@808
  2015
	// Make fn absolute (needed for unzip)
insilmaril@808
  2016
	fn=QDir (fn).absPath();
insilmaril@808
  2017
insilmaril@808
  2018
	VymModel *vm;
insilmaril@808
  2019
insilmaril@808
  2020
	if (lmode==NewMap)
insilmaril@491
  2021
	{
insilmaril@808
  2022
		// Check, if map is already loaded
insilmaril@808
  2023
		int i=0;
insilmaril@808
  2024
		while (i<=tabWidget->count() -1)
insilmaril@807
  2025
		{
insilmaril@808
  2026
			if (vymViews.at(i)->getModel()->getFilePath() == fn)
insilmaril@807
  2027
			{
insilmaril@808
  2028
				// Already there, ask for confirmation
insilmaril@808
  2029
				QMessageBox mb( vymName,
insilmaril@808
  2030
					tr("The map %1\nis already opened."
insilmaril@808
  2031
					"Opening the same map in multiple editors may lead \n"
insilmaril@808
  2032
					"to confusion when finishing working with vym."
insilmaril@808
  2033
					"Do you want to").arg(fn),
insilmaril@808
  2034
					QMessageBox::Warning,
insilmaril@808
  2035
					QMessageBox::Yes | QMessageBox::Default,
insilmaril@808
  2036
					QMessageBox::Cancel | QMessageBox::Escape,
insilmaril@808
  2037
					QMessageBox::NoButton);
insilmaril@808
  2038
				mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
insilmaril@808
  2039
				mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
insilmaril@808
  2040
				switch( mb.exec() ) 
insilmaril@808
  2041
				{
insilmaril@808
  2042
					case QMessageBox::Yes:
insilmaril@808
  2043
						// end loop and load anyway
insilmaril@808
  2044
						i=tabWidget->count();
insilmaril@808
  2045
						break;
insilmaril@808
  2046
					case QMessageBox::Cancel:
insilmaril@808
  2047
						// do nothing
insilmaril@808
  2048
						return aborted;
insilmaril@808
  2049
						break;
insilmaril@808
  2050
				}
insilmaril@807
  2051
			}
insilmaril@808
  2052
			i++;
insilmaril@807
  2053
		}
insilmaril@491
  2054
	}
insilmaril@808
  2055
insilmaril@808
  2056
	int tabIndex=tabWidget->currentPageIndex();
insilmaril@0
  2057
insilmaril@0
  2058
	// Try to load map
insilmaril@0
  2059
    if ( !fn.isEmpty() )
insilmaril@0
  2060
	{
insilmaril@727
  2061
		vm = currentModel();
insilmaril@0
  2062
		// Check first, if mapeditor exists
insilmaril@0
  2063
		// If it is not default AND we want a new map, 
insilmaril@0
  2064
		// create a new mapeditor in a new tab
insilmaril@727
  2065
		if ( lmode==NewMap && (!vm || !vm->isDefault() )  )
insilmaril@0
  2066
		{
insilmaril@727
  2067
			vm=new VymModel;
insilmaril@769
  2068
			VymView *vv=new VymView (vm);
insilmaril@772
  2069
			vymViews.append (vv);
insilmaril@769
  2070
			tabWidget->addTab (vv,fn);
insilmaril@725
  2071
			tabIndex=tabWidget->count()-1;
insilmaril@0
  2072
			tabWidget->setCurrentPage (tabIndex);
insilmaril@769
  2073
			vv->initFocus();
insilmaril@0
  2074
		}
insilmaril@0
  2075
		
insilmaril@0
  2076
		// Check, if file exists (important for creating new files
insilmaril@0
  2077
		// from command line
insilmaril@0
  2078
		if (!QFile(fn).exists() )
insilmaril@0
  2079
		{
insilmaril@404
  2080
			QMessageBox mb( vymName,
insilmaril@159
  2081
				tr("This map does not exist:\n  %1\nDo you want to create a new one?").arg(fn),
insilmaril@0
  2082
				QMessageBox::Question,
insilmaril@0
  2083
				QMessageBox::Yes ,
insilmaril@0
  2084
				QMessageBox::Cancel | QMessageBox::Default,
insilmaril@366
  2085
				QMessageBox::NoButton );
insilmaril@0
  2086
insilmaril@0
  2087
			mb.setButtonText( QMessageBox::Yes, tr("Create"));
insilmaril@0
  2088
			mb.setButtonText( QMessageBox::No, tr("Cancel"));
insilmaril@0
  2089
			switch( mb.exec() ) 
insilmaril@0
  2090
			{
insilmaril@0
  2091
				case QMessageBox::Yes:
insilmaril@0
  2092
					// Create new map
insilmaril@721
  2093
					currentMapEditor()->getModel()->setFilePath(fn);
insilmaril@725
  2094
					tabWidget->setTabText (tabIndex,
insilmaril@721
  2095
						currentMapEditor()->getModel()->getFileName() );
insilmaril@0
  2096
					statusBar()->message( "Created " + fn , statusbarTime );
insilmaril@205
  2097
					return success;
insilmaril@0
  2098
						
insilmaril@0
  2099
				case QMessageBox::Cancel:
insilmaril@0
  2100
					// don't create new map
insilmaril@0
  2101
					statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
insilmaril@0
  2102
					fileCloseMap();
insilmaril@205
  2103
					return aborted;
insilmaril@0
  2104
			}
insilmaril@0
  2105
		}	
insilmaril@0
  2106
insilmaril@721
  2107
insilmaril@0
  2108
		//tabWidget->currentPage() won't be NULL here, because of above...
insilmaril@725
  2109
		tabWidget->setCurrentIndex (tabIndex);
insilmaril@746
  2110
		//FIXME-3 no me anymore... me->viewport()->setFocus();
insilmaril@0
  2111
insilmaril@185
  2112
		if (err!=aborted)
insilmaril@185
  2113
		{
insilmaril@185
  2114
			// Save existing filename in case  we import
insilmaril@727
  2115
			QString fn_org=vm->getFilePath();
insilmaril@106
  2116
insilmaril@185
  2117
			// Finally load map into mapEditor
insilmaril@727
  2118
			vm->setFilePath (fn);
insilmaril@727
  2119
			err=vm->load(fn,lmode,ftype);
insilmaril@106
  2120
insilmaril@185
  2121
			// Restore old (maybe empty) filepath, if this is an import
insilmaril@185
  2122
			if (lmode!=NewMap)
insilmaril@727
  2123
				vm->setFilePath (fn_org);
insilmaril@185
  2124
		}	
insilmaril@0
  2125
insilmaril@185
  2126
		// Finally check for errors and go home
insilmaril@185
  2127
		if (err==aborted) 
insilmaril@185
  2128
		{
insilmaril@185
  2129
			if (lmode==NewMap) fileCloseMap();
insilmaril@185
  2130
			statusBar()->message( "Could not load " + fn, statusbarTime );
insilmaril@185
  2131
		} else 
insilmaril@0
  2132
		{
insilmaril@0
  2133
			if (lmode==NewMap)
insilmaril@0
  2134
			{
insilmaril@727
  2135
				vm->setFilePath (fn);
insilmaril@727
  2136
				tabWidget->setTabText (tabIndex, vm->getFileName());
insilmaril@608
  2137
				if (!isInTmpDir (fn))
insilmaril@205
  2138
				{
insilmaril@205
  2139
					// Only append to lastMaps if not loaded from a tmpDir
insilmaril@205
  2140
					// e.g. imported bookmarks are in a tmpDir
insilmaril@727
  2141
					addRecentMap(vm->getFilePath() );
insilmaril@205
  2142
				}
insilmaril@0
  2143
				actionFilePrint->setEnabled (true);
insilmaril@0
  2144
			}	
insilmaril@0
  2145
			statusBar()->message( "Loaded " + fn, statusbarTime );
insilmaril@0
  2146
		}	
insilmaril@0
  2147
	}
insilmaril@205
  2148
	return err;
insilmaril@0
  2149
}
insilmaril@0
  2150
insilmaril@0
  2151
insilmaril@0
  2152
void Main::fileLoad(const LoadMode &lmode)
insilmaril@0
  2153
{
insilmaril@377
  2154
	QStringList filters;
insilmaril@389
  2155
	filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
insilmaril@377
  2156
	QFileDialog *fd=new QFileDialog( this);
insilmaril@366
  2157
	fd->setDir (lastFileDir);
insilmaril@377
  2158
	fd->setFileMode (QFileDialog::ExistingFiles);
insilmaril@377
  2159
	fd->setFilters (filters);
insilmaril@0
  2160
	switch (lmode)
insilmaril@0
  2161
	{
insilmaril@0
  2162
		case NewMap:
insilmaril@404
  2163
			fd->setCaption(vymName+ " - " +tr("Load vym map"));
insilmaril@0
  2164
			break;
insilmaril@0
  2165
		case ImportAdd:
insilmaril@404
  2166
			fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
insilmaril@0
  2167
			break;
insilmaril@0
  2168
		case ImportReplace:
insilmaril@404
  2169
			fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
insilmaril@0
  2170
			break;
insilmaril@0
  2171
	}
insilmaril@0
  2172
	fd->show();
insilmaril@0
  2173
insilmaril@0
  2174
	QString fn;
insilmaril@0
  2175
	if ( fd->exec() == QDialog::Accepted )
insilmaril@0
  2176
	{
insilmaril@377
  2177
		lastFileDir=fd->directory().path();
insilmaril@185
  2178
	    QStringList flist = fd->selectedFiles();
insilmaril@185
  2179
		QStringList::Iterator it = flist.begin();
insilmaril@821
  2180
		
insilmaril@821
  2181
		progressCounter=flist.count();
insilmaril@821
  2182
		progressCounterTotal=flist.count();
insilmaril@185
  2183
		while( it != flist.end() ) 
insilmaril@185
  2184
		{
insilmaril@185
  2185
			fn = *it;
insilmaril@185
  2186
			fileLoad(*it, lmode);				   
insilmaril@185
  2187
			++it;
insilmaril@185
  2188
		}
insilmaril@0
  2189
	}
insilmaril@185
  2190
	delete (fd);
insilmaril@0
  2191
}
insilmaril@0
  2192
insilmaril@0
  2193
void Main::fileLoad()
insilmaril@0
  2194
{
insilmaril@0
  2195
	fileLoad (NewMap);
insilmaril@0
  2196
}
insilmaril@0
  2197
insilmaril@401
  2198
void Main::fileLoadRecent()
insilmaril@0
  2199
{
insilmaril@401
  2200
    QAction *action = qobject_cast<QAction *>(sender());
insilmaril@401
  2201
    if (action)
insilmaril@401
  2202
        fileLoad (action->data().toString(), NewMap);
insilmaril@401
  2203
}
insilmaril@401
  2204
insilmaril@401
  2205
void Main::addRecentMap (const QString &fileName)
insilmaril@401
  2206
{
insilmaril@401
  2207
insilmaril@401
  2208
    QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
insilmaril@401
  2209
    files.removeAll(fileName);
insilmaril@401
  2210
    files.prepend(fileName);
insilmaril@401
  2211
    while (files.size() > MaxRecentFiles)
insilmaril@401
  2212
        files.removeLast();
insilmaril@401
  2213
insilmaril@401
  2214
    settings.setValue("/mainwindow/recentFileList", files);
insilmaril@401
  2215
insilmaril@401
  2216
	setupRecentMapsMenu();
insilmaril@0
  2217
}
insilmaril@0
  2218
insilmaril@721
  2219
void Main::fileSave(VymModel *m, const SaveMode &savemode)
insilmaril@0
  2220
{
insilmaril@721
  2221
	if (!m) return;
insilmaril@721
  2222
insilmaril@721
  2223
	if ( m->getFilePath().isEmpty() ) 
insilmaril@676
  2224
	{
insilmaril@676
  2225
		// We have  no filepath yet,
insilmaril@676
  2226
		// call fileSaveAs() now, this will call fileSave() 
insilmaril@676
  2227
		// again.
insilmaril@676
  2228
		// First switch to editor
insilmaril@746
  2229
		//FIXME-3 needed???  tabWidget->setCurrentWidget (m->getMapEditor());
insilmaril@676
  2230
		fileSaveAs(savemode);
insilmaril@676
  2231
	}
insilmaril@676
  2232
insilmaril@721
  2233
	if (m->save (savemode)==success)
insilmaril@151
  2234
	{
insilmaril@0
  2235
		statusBar()->message( 
insilmaril@721
  2236
			tr("Saved  %1").arg(m->getFilePath()), 
insilmaril@0
  2237
			statusbarTime );
insilmaril@721
  2238
		addRecentMap (m->getFilePath() );
insilmaril@151
  2239
	} else		
insilmaril@0
  2240
		statusBar()->message( 
insilmaril@721
  2241
			tr("Couldn't save ").arg(m->getFilePath()), 
insilmaril@0
  2242
			statusbarTime );
insilmaril@0
  2243
}
insilmaril@0
  2244
insilmaril@0
  2245
void Main::fileSave()
insilmaril@0
  2246
{
insilmaril@721
  2247
	fileSave (currentModel(), CompleteMap);
insilmaril@473
  2248
}
insilmaril@473
  2249
insilmaril@721
  2250
void Main::fileSave(VymModel *m)
insilmaril@473
  2251
{
insilmaril@721
  2252
	fileSave (m,CompleteMap);
insilmaril@0
  2253
}
insilmaril@0
  2254
insilmaril@0
  2255
void Main::fileSaveAs(const SaveMode& savemode)
insilmaril@0
  2256
{
insilmaril@0
  2257
	QString fn;
insilmaril@0
  2258
insilmaril@0
  2259
	if (currentMapEditor())
insilmaril@0
  2260
	{
insilmaril@0
  2261
		if (savemode==CompleteMap)
insilmaril@366
  2262
			fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
insilmaril@0
  2263
		else		
insilmaril@366
  2264
			fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
insilmaril@0
  2265
		if ( !fn.isEmpty() ) 
insilmaril@0
  2266
		{
insilmaril@0
  2267
			// Check for existing file
insilmaril@0
  2268
			if (QFile (fn).exists())
insilmaril@0
  2269
			{
insilmaril@404
  2270
				QMessageBox mb( vymName,
insilmaril@159
  2271
					tr("The file %1\nexists already. Do you want to").arg(fn),
insilmaril@0
  2272
					QMessageBox::Warning,
insilmaril@0
  2273
					QMessageBox::Yes | QMessageBox::Default,
insilmaril@0
  2274
					QMessageBox::Cancel | QMessageBox::Escape,
insilmaril@366
  2275
					QMessageBox::NoButton);
insilmaril@0
  2276
				mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
insilmaril@0
  2277
				mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
insilmaril@0
  2278
				switch( mb.exec() ) 
insilmaril@0
  2279
				{
insilmaril@0
  2280
					case QMessageBox::Yes:
insilmaril@0
  2281
						// save 
insilmaril@0
  2282
						break;
insilmaril@0
  2283
					case QMessageBox::Cancel:
insilmaril@0
  2284
						// do nothing
insilmaril@0
  2285
						return;
insilmaril@0
  2286
						break;
insilmaril@0
  2287
				}
insilmaril@0
  2288
			} else
insilmaril@0
  2289
			{
insilmaril@0
  2290
				// New file, add extension to filename, if missing
insilmaril@0
  2291
				// This is always .vym or .vyp, depending on savemode
insilmaril@0
  2292
				if (savemode==CompleteMap)
insilmaril@0
  2293
				{
insilmaril@0
  2294
					if (!fn.contains (".vym") && !fn.contains (".xml"))
insilmaril@0
  2295
						fn +=".vym";
insilmaril@0
  2296
				} else		
insilmaril@0
  2297
				{
insilmaril@0
  2298
					if (!fn.contains (".vyp") && !fn.contains (".xml"))
insilmaril@0
  2299
						fn +=".vyp";
insilmaril@0
  2300
				}
insilmaril@0
  2301
			}
insilmaril@0
  2302
	
insilmaril@0
  2303
insilmaril@0
  2304
insilmaril@0
  2305
insilmaril@0
  2306
			// Save now
insilmaril@725
  2307
			VymModel *m=currentModel();
insilmaril@725
  2308
			m->setFilePath(fn);
insilmaril@725
  2309
			fileSave(m, savemode);
insilmaril@725
  2310
insilmaril@725
  2311
			// Set name of tab, assuming current tab is the one we just saved
insilmaril@94
  2312
			if (savemode==CompleteMap)
insilmaril@725
  2313
				tabWidget->setTabText (tabWidget->currentIndex(), m->getFileName() );
insilmaril@0
  2314
			return;
insilmaril@0
  2315
		} 
insilmaril@0
  2316
	}
insilmaril@0
  2317
}
insilmaril@0
  2318
insilmaril@0
  2319
void Main::fileSaveAs()
insilmaril@0
  2320
{
insilmaril@0
  2321
	fileSaveAs (CompleteMap);
insilmaril@0
  2322
}
insilmaril@0
  2323
insilmaril@742
  2324
void Main::fileImportKDE3Bookmarks()
insilmaril@205
  2325
{
insilmaril@742
  2326
	ImportKDE3Bookmarks im;
insilmaril@205
  2327
	im.transform();
insilmaril@742
  2328
	if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
insilmaril@742
  2329
		currentMapEditor()->getModel()->setFilePath ("");
insilmaril@742
  2330
}
insilmaril@742
  2331
insilmaril@742
  2332
void Main::fileImportKDE4Bookmarks()
insilmaril@742
  2333
{
insilmaril@742
  2334
	ImportKDE4Bookmarks im;
insilmaril@742
  2335
	im.transform();
insilmaril@742
  2336
	if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
insilmaril@721
  2337
		currentMapEditor()->getModel()->setFilePath ("");
insilmaril@205
  2338
}
insilmaril@205
  2339
insilmaril@314
  2340
void Main::fileImportFirefoxBookmarks()
insilmaril@314
  2341
{
insilmaril@366
  2342
	Q3FileDialog *fd=new Q3FileDialog( this);
insilmaril@327
  2343
	fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
insilmaril@366
  2344
	fd->setMode (Q3FileDialog::ExistingFiles);
insilmaril@327
  2345
	fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
insilmaril@327
  2346
	fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
insilmaril@327
  2347
	fd->show();
insilmaril@327
  2348
insilmaril@327
  2349
	if ( fd->exec() == QDialog::Accepted )
insilmaril@327
  2350
	{
insilmaril@327
  2351
		ImportFirefoxBookmarks im;
insilmaril@327
  2352
	    QStringList flist = fd->selectedFiles();
insilmaril@327
  2353
		QStringList::Iterator it = flist.begin();
insilmaril@327
  2354
		while( it != flist.end() ) 
insilmaril@327
  2355
		{
insilmaril@327
  2356
			im.setFile (*it);
insilmaril@327
  2357
			if (im.transform() && 
insilmaril@742
  2358
				aborted!=fileLoad (im.getTransformedFile(),NewMap,FreemindMap) && 
insilmaril@327
  2359
				currentMapEditor() )
insilmaril@721
  2360
				currentMapEditor()->getModel()->setFilePath ("");
insilmaril@327
  2361
			++it;
insilmaril@327
  2362
		}
insilmaril@327
  2363
	}
insilmaril@327
  2364
	delete (fd);
insilmaril@314
  2365
}
insilmaril@314
  2366
insilmaril@571
  2367
void Main::fileImportFreemind()
insilmaril@571
  2368
{
insilmaril@571
  2369
	QStringList filters;
insilmaril@571
  2370
	filters <<"Freemind map (*.mm)"<<"All files (*)";
insilmaril@571
  2371
	QFileDialog *fd=new QFileDialog( this);
insilmaril@571
  2372
	fd->setDir (lastFileDir);
insilmaril@571
  2373
	fd->setFileMode (QFileDialog::ExistingFiles);
insilmaril@571
  2374
	fd->setFilters (filters);
insilmaril@571
  2375
	fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
insilmaril@571
  2376
	fd->show();
insilmaril@571
  2377
insilmaril@571
  2378
	QString fn;
insilmaril@571
  2379
	if ( fd->exec() == QDialog::Accepted )
insilmaril@571
  2380
	{
insilmaril@571
  2381
		lastFileDir=fd->directory().path();
insilmaril@571
  2382
	    QStringList flist = fd->selectedFiles();
insilmaril@571
  2383
		QStringList::Iterator it = flist.begin();
insilmaril@571
  2384
		while( it != flist.end() ) 
insilmaril@571
  2385
		{
insilmaril@571
  2386
			fn = *it;
insilmaril@571
  2387
			if ( fileLoad (fn,NewMap, FreemindMap)  )
insilmaril@571
  2388
			{	
insilmaril@721
  2389
				currentMapEditor()->getModel()->setFilePath ("");
insilmaril@571
  2390
			}	
insilmaril@571
  2391
			++it;
insilmaril@571
  2392
		}
insilmaril@571
  2393
	}
insilmaril@571
  2394
	delete (fd);
insilmaril@571
  2395
}
insilmaril@571
  2396
insilmaril@571
  2397
insilmaril@215
  2398
void Main::fileImportMM()
insilmaril@215
  2399
{
insilmaril@215
  2400
	ImportMM im;
insilmaril@215
  2401
insilmaril@366
  2402
	Q3FileDialog *fd=new Q3FileDialog( this);
insilmaril@366
  2403
	fd->setDir (lastFileDir);
insilmaril@366
  2404
	fd->setMode (Q3FileDialog::ExistingFiles);
insilmaril@215
  2405
	fd->addFilter ("Mind Manager (*.mmap)");
insilmaril@215
  2406
	fd->setCaption(tr("Import")+" "+"Mind Manager");
insilmaril@215
  2407
	fd->show();
insilmaril@215
  2408
insilmaril@215
  2409
	if ( fd->exec() == QDialog::Accepted )
insilmaril@215
  2410
	{
insilmaril@215
  2411
		lastFileDir=fd->dirPath();
insilmaril@215
  2412
	    QStringList flist = fd->selectedFiles();
insilmaril@215
  2413
		QStringList::Iterator it = flist.begin();
insilmaril@215
  2414
		while( it != flist.end() ) 
insilmaril@215
  2415
		{
insilmaril@215
  2416
			im.setFile (*it);
insilmaril@215
  2417
			if (im.transform() && 
insilmaril@215
  2418
				success==fileLoad (im.getTransformedFile(),NewMap) && 
insilmaril@215
  2419
				currentMapEditor() )
insilmaril@721
  2420
				currentMapEditor()->getModel()->setFilePath ("");
insilmaril@215
  2421
			++it;
insilmaril@215
  2422
		}
insilmaril@215
  2423
	}
insilmaril@215
  2424
	delete (fd);
insilmaril@215
  2425
}
insilmaril@215
  2426
insilmaril@215
  2427
void Main::fileImportDir()
insilmaril@215
  2428
{
insilmaril@721
  2429
	VymModel *m=currentModel();
insilmaril@721
  2430
	if (m) m->importDir();
insilmaril@215
  2431
}
insilmaril@215
  2432
insilmaril@526
  2433
void Main::fileExportXML()	
insilmaril@0
  2434
{
insilmaril@721
  2435
	VymModel *m=currentModel();
insilmaril@721
  2436
	if (m) m->exportXML();
insilmaril@0
  2437
}
insilmaril@0
  2438
insilmaril@819
  2439
void Main::fileExportHTML()	
insilmaril@819
  2440
{
insilmaril@819
  2441
	VymModel *m=currentModel();
insilmaril@819
  2442
	if (m) m->exportHTML();
insilmaril@819
  2443
}
insilmaril@819
  2444
insilmaril@517
  2445
void Main::fileExportImage()	
insilmaril@0
  2446
{
insilmaril@721
  2447
	VymModel *m=currentModel();
insilmaril@721
  2448
	if (m) m->exportImage();
insilmaril@0
  2449
}
insilmaril@0
  2450
insilmaril@807
  2451
void Main::fileExportAO()
insilmaril@807
  2452
{
insilmaril@807
  2453
	VymModel *m=currentModel();
insilmaril@807
  2454
	if (m) m->exportAO();
insilmaril@807
  2455
}
insilmaril@807
  2456
insilmaril@0
  2457
void Main::fileExportASCII()
insilmaril@0
  2458
{
insilmaril@721
  2459
	VymModel *m=currentModel();
insilmaril@721
  2460
	if (m) m->exportASCII();
insilmaril@0
  2461
}
insilmaril@0
  2462
insilmaril@756
  2463
void Main::fileExportCSV()	//FIXME-3 not scriptable yet
insilmaril@497
  2464
{
insilmaril@721
  2465
	VymModel *m=currentModel();
insilmaril@721
  2466
	if (m)
insilmaril@497
  2467
	{
insilmaril@497
  2468
		ExportCSV ex;
insilmaril@721
  2469
		ex.setModel (m);
insilmaril@497
  2470
		ex.addFilter ("CSV (*.csv)");
insilmaril@497
  2471
		ex.setDir(lastImageDir);
insilmaril@497
  2472
		ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
insilmaril@497
  2473
		if (ex.execDialog() ) 
insilmaril@497
  2474
		{
insilmaril@721
  2475
			m->setExportMode(true);
insilmaril@497
  2476
			ex.doExport();
insilmaril@721
  2477
			m->setExportMode(false);
insilmaril@497
  2478
		}
insilmaril@497
  2479
	}
insilmaril@497
  2480
}
insilmaril@497
  2481
insilmaril@756
  2482
void Main::fileExportLaTeX()	//FIXME-3 not scriptable yet
insilmaril@163
  2483
{
insilmaril@721
  2484
	VymModel *m=currentModel();
insilmaril@721
  2485
	if (m)
insilmaril@228
  2486
	{
insilmaril@228
  2487
		ExportLaTeX ex;
insilmaril@721
  2488
		ex.setModel (m);
insilmaril@228
  2489
		ex.addFilter ("Tex (*.tex)");
insilmaril@424
  2490
		ex.setDir(lastImageDir);
insilmaril@404
  2491
		ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
insilmaril@260
  2492
		if (ex.execDialog() ) 
insilmaril@260
  2493
		{
insilmaril@721
  2494
			m->setExportMode(true);
insilmaril@260
  2495
			ex.doExport();
insilmaril@721
  2496
			m->setExportMode(false);
insilmaril@260
  2497
		}
insilmaril@228
  2498
	}
insilmaril@228
  2499
}
insilmaril@228
  2500
insilmaril@756
  2501
void Main::fileExportKDE3Bookmarks()	//FIXME-3 not scriptable yet
insilmaril@243
  2502
{
insilmaril@742
  2503
	ExportKDE3Bookmarks ex;
insilmaril@742
  2504
	VymModel *m=currentModel();
insilmaril@742
  2505
	if (m)
insilmaril@742
  2506
	{
insilmaril@742
  2507
		ex.setModel (m);
insilmaril@742
  2508
		ex.doExport();
insilmaril@742
  2509
	}	
insilmaril@742
  2510
}
insilmaril@742
  2511
insilmaril@756
  2512
void Main::fileExportKDE4Bookmarks()	//FIXME-3 not scriptable yet
insilmaril@742
  2513
{
insilmaril@742
  2514
	ExportKDE4Bookmarks ex;
insilmaril@721
  2515
	VymModel *m=currentModel();
insilmaril@721
  2516
	if (m)
insilmaril@243
  2517
	{
insilmaril@721
  2518
		ex.setModel (m);
insilmaril@243
  2519
		ex.doExport();
insilmaril@243
  2520
	}	
insilmaril@243
  2521
}
insilmaril@243
  2522
insilmaril@756
  2523
void Main::fileExportTaskjuggler()	//FIXME-3 not scriptable yet
insilmaril@228
  2524
{
insilmaril@228
  2525
	ExportTaskjuggler ex;
insilmaril@721
  2526
	VymModel *m=currentModel();
insilmaril@721
  2527
	if (m)
insilmaril@228
  2528
	{
insilmaril@721
  2529
		ex.setModel (m);
insilmaril@404
  2530
		ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
insilmaril@424
  2531
		ex.setDir(lastImageDir);
insilmaril@243
  2532
		ex.addFilter ("Taskjuggler (*.tjp)");
insilmaril@260
  2533
		if (ex.execDialog() ) 
insilmaril@260
  2534
		{
insilmaril@721
  2535
			m->setExportMode(true);
insilmaril@260
  2536
			ex.doExport();
insilmaril@721
  2537
			m->setExportMode(false);
insilmaril@260
  2538
		}
insilmaril@228
  2539
	}	
insilmaril@163
  2540
}
insilmaril@163
  2541
insilmaril@756
  2542
void Main::fileExportOOPresentation()	//FIXME-3 not scriptable yet
insilmaril@163
  2543
{
insilmaril@404
  2544
	ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
insilmaril@366
  2545
	// TODO add preview in dialog
insilmaril@185
  2546
	//ImagePreview *p =new ImagePreview (fd);
insilmaril@185
  2547
	//fd->setContentsPreviewEnabled( TRUE );
insilmaril@185
  2548
	//fd->setContentsPreview( p, p );
insilmaril@185
  2549
	//fd->setPreviewMode( QFileDialog::Contents );
insilmaril@404
  2550
	fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
insilmaril@366
  2551
	fd->setDir (QDir().current());
insilmaril@357
  2552
	if (fd->foundConfig())
insilmaril@357
  2553
	{
insilmaril@357
  2554
		fd->show();
insilmaril@185
  2555
insilmaril@357
  2556
		if ( fd->exec() == QDialog::Accepted )
insilmaril@357
  2557
		{
insilmaril@357
  2558
			QString fn=fd->selectedFile();
insilmaril@366
  2559
			if (!fn.contains (".odp"))
insilmaril@366
  2560
				fn +=".odp";
insilmaril@366
  2561
insilmaril@357
  2562
			//lastImageDir=fn.left(fn.findRev ("/"));
insilmaril@721
  2563
			VymModel *m=currentModel();
insilmaril@721
  2564
			if (m) m->exportOOPresentation(fn,fd->selectedConfig());	
insilmaril@357
  2565
		}
insilmaril@357
  2566
	} else
insilmaril@185
  2567
	{
insilmaril@357
  2568
		QMessageBox::warning(0, 
insilmaril@366
  2569
		tr("Warning"),
insilmaril@366
  2570
		tr("Couldn't find configuration for export to Open Office\n"));
insilmaril@185
  2571
	}
insilmaril@163
  2572
}
insilmaril@163
  2573
insilmaril@772
  2574
void Main::fileCloseMap()	
insilmaril@0
  2575
{
insilmaril@721
  2576
	VymModel *m=currentModel();
insilmaril@721
  2577
	if (m)
insilmaril@0
  2578
	{
insilmaril@721
  2579
		if (m->hasChanged())
insilmaril@0
  2580
		{
insilmaril@404
  2581
			QMessageBox mb( vymName,
insilmaril@772
  2582
				tr("The map %1 has been modified but not saved yet. Do you want to").arg(m->getFileName()),
insilmaril@0
  2583
				QMessageBox::Warning,
insilmaril@0
  2584
				QMessageBox::Yes | QMessageBox::Default,
insilmaril@0
  2585
				QMessageBox::No,
insilmaril@0
  2586
				QMessageBox::Cancel | QMessageBox::Escape );
insilmaril@0
  2587
			mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
insilmaril@0
  2588
			mb.setButtonText( QMessageBox::No, tr("Discard changes"));
insilmaril@0
  2589
			switch( mb.exec() ) 
insilmaril@0
  2590
			{
insilmaril@0
  2591
				case QMessageBox::Yes:
insilmaril@0
  2592
					// save and close
insilmaril@721
  2593
					fileSave(m, CompleteMap);
insilmaril@0
  2594
					break;
insilmaril@0
  2595
				case QMessageBox::No:
insilmaril@0
  2596
				// close  without saving
insilmaril@0
  2597
					break;
insilmaril@0
  2598
				case QMessageBox::Cancel:
insilmaril@0
  2599
					// do nothing
insilmaril@0
  2600
				return;
insilmaril@0
  2601
			}
insilmaril@0
  2602
		} 
insilmaril@772
  2603
		// And here comes the segfault, because removeTab triggers 
insilmaril@804
  2604
		// FIXME-3 currentChanged->Main::editorChanged -> updateActions and VM is not NULL yet...
insilmaril@772
  2605
		vymViews.removeAt (tabWidget->currentIndex() );
insilmaril@725
  2606
		tabWidget->removeTab (tabWidget->currentIndex() );
insilmaril@742
  2607
insilmaril@844
  2608
		delete (m); // changing model still will try to update selection in editors, remove model first
insilmaril@844
  2609
		//delete (m->getMapEditor());
insilmaril@807
  2610
insilmaril@724
  2611
		updateActions();
insilmaril@625
  2612
	}
insilmaril@0
  2613
}
insilmaril@0
  2614
insilmaril@0
  2615
void Main::filePrint()
insilmaril@0
  2616
{
insilmaril@0
  2617
	if (currentMapEditor())
insilmaril@0
  2618
		currentMapEditor()->print();
insilmaril@0
  2619
}
insilmaril@0
  2620
insilmaril@0
  2621
void Main::fileExitVYM()
insilmaril@0
  2622
{
insilmaril@0
  2623
	// Check if one or more editors have changed
insilmaril@0
  2624
	int i;
insilmaril@772
  2625
	for (i=0;i<=vymViews.count() -1;i++)
insilmaril@0
  2626
	{
insilmaril@0
  2627
		// If something changed, ask what to do
insilmaril@772
  2628
		if (vymViews.at(i)->getModel()->hasChanged())
insilmaril@0
  2629
		{
insilmaril@0
  2630
			tabWidget->setCurrentPage(i);
insilmaril@404
  2631
			QMessageBox mb( vymName,
insilmaril@0
  2632
				tr("This map is not saved yet. Do you want to"),
insilmaril@0
  2633
				QMessageBox::Warning,
insilmaril@0
  2634
				QMessageBox::Yes | QMessageBox::Default,
insilmaril@0
  2635
				QMessageBox::No,
insilmaril@0
  2636
				QMessageBox::Cancel | QMessageBox::Escape );
insilmaril@0
  2637
			mb.setButtonText( QMessageBox::Yes, tr("Save map") );
insilmaril@0
  2638
			mb.setButtonText( QMessageBox::No, tr("Discard changes") );
insilmaril@366
  2639
			mb.setModal (true);
insilmaril@0
  2640
			mb.show();
insilmaril@0
  2641
			mb.setActiveWindow();
insilmaril@0
  2642
			switch( mb.exec() ) {
insilmaril@0
  2643
				case QMessageBox::Yes:
insilmaril@0
  2644
					// save (the changed editors) and exit
insilmaril@721
  2645
					fileSave(currentModel(), CompleteMap);
insilmaril@0
  2646
					break;
insilmaril@0
  2647
				case QMessageBox::No:
insilmaril@0
  2648
					// exit without saving
insilmaril@0
  2649
					break;
insilmaril@0
  2650
				case QMessageBox::Cancel:
insilmaril@0
  2651
					// don't save and don't exit
insilmaril@0
  2652
				return;
insilmaril@0
  2653
			}
insilmaril@0
  2654
		}
insilmaril@0
  2655
	} // loop over all MEs	
insilmaril@0
  2656
    qApp->quit();
insilmaril@0
  2657
}
insilmaril@0
  2658
insilmaril@0
  2659
void Main::editUndo()
insilmaril@0
  2660
{
insilmaril@721
  2661
	VymModel *m=currentModel();
insilmaril@721
  2662
	if (m) m->undo();
insilmaril@0
  2663
}
insilmaril@0
  2664
insilmaril@163
  2665
void Main::editRedo()	   
insilmaril@0
  2666
{
insilmaril@721
  2667
	VymModel *m=currentModel();
insilmaril@721
  2668
	if (m) m->redo();
insilmaril@0
  2669
}
insilmaril@0
  2670
insilmaril@404
  2671
void Main::gotoHistoryStep (int i)	   
insilmaril@404
  2672
{
insilmaril@721
  2673
	VymModel *m=currentModel();
insilmaril@721
  2674
	if (m) m->gotoHistoryStep(i);
insilmaril@404
  2675
}
insilmaril@404
  2676
insilmaril@0
  2677
void Main::editCopy()
insilmaril@0
  2678
{
insilmaril@721
  2679
	VymModel *m=currentModel();
insilmaril@721
  2680
	if (m) m->copy();
insilmaril@0
  2681
}
insilmaril@0
  2682
insilmaril@0
  2683
void Main::editPaste()
insilmaril@0
  2684
{
insilmaril@721
  2685
	VymModel *m=currentModel();
insilmaril@721
  2686
	if (m) m->paste();
insilmaril@0
  2687
}
insilmaril@0
  2688
insilmaril@0
  2689
void Main::editCut()
insilmaril@0
  2690
{
insilmaril@721
  2691
	VymModel *m=currentModel();
insilmaril@721
  2692
	if (m) m->cut();
insilmaril@0
  2693
}
insilmaril@0
  2694
insilmaril@829
  2695
void Main::editOpenFindWidget()  
insilmaril@0
  2696
{
insilmaril@829
  2697
	if (!findWidget->isVisible())
insilmaril@829
  2698
	{
insilmaril@829
  2699
		findWidget->show();
insilmaril@829
  2700
		findWidget->setFocus();
insilmaril@829
  2701
	} else if (!findResultWidget->parentWidget()->isVisible())
insilmaril@829
  2702
		findResultWidget->parentWidget()->show();
insilmaril@829
  2703
	else 
insilmaril@829
  2704
	{
insilmaril@829
  2705
		findWidget->hide();
insilmaril@829
  2706
		findResultWidget->parentWidget()->hide();
insilmaril@829
  2707
	}
insilmaril@829
  2708
}
insilmaril@829
  2709
insilmaril@829
  2710
void Main::editHideFindWidget()
insilmaril@829
  2711
{
insilmaril@829
  2712
    // findWidget hides itself, but we want
insilmaril@829
  2713
    // to have focus back at mapEditor usually
insilmaril@829
  2714
	MapEditor *me=currentMapEditor();
insilmaril@829
  2715
    if (me) me->setFocus();
insilmaril@829
  2716
}
insilmaril@829
  2717
insilmaril@829
  2718
void Main::editFindNext(QString s)  
insilmaril@829
  2719
{
insilmaril@829
  2720
	Qt::CaseSensitivity cs=Qt::CaseInsensitive;
insilmaril@721
  2721
	VymModel *m=currentModel();
insilmaril@829
  2722
	if (m) 
insilmaril@829
  2723
	{
insilmaril@829
  2724
		m->findAll (findResultWidget->getResultModel(),s,cs);
insilmaril@829
  2725
insilmaril@842
  2726
		BranchItem *bi=m->findText(s, cs);
insilmaril@829
  2727
		if (bi)
insilmaril@829
  2728
		{
insilmaril@829
  2729
			findWidget->setStatus (FindWidget::Success);
insilmaril@829
  2730
		}	
insilmaril@829
  2731
		else
insilmaril@829
  2732
			findWidget->setStatus (FindWidget::Failed);
insilmaril@829
  2733
	}
insilmaril@0
  2734
}
insilmaril@0
  2735
insilmaril@829
  2736
void Main::editFindDuplicateURLs() //FIXME-4 feature: use FindResultWidget for display
insilmaril@821
  2737
{
insilmaril@821
  2738
	VymModel *m=currentModel();
insilmaril@821
  2739
	if (m) m->findDuplicateURLs();
insilmaril@821
  2740
}
insilmaril@821
  2741
insilmaril@366
  2742
void Main::openTabs(QStringList urls)
insilmaril@366
  2743
{
insilmaril@366
  2744
	if (!urls.isEmpty())
insilmaril@366
  2745
	{	
insilmaril@366
  2746
		bool success=true;
insilmaril@366
  2747
		QStringList args;
insilmaril@366
  2748
		QString browser=settings.value("/mainwindow/readerURL" ).toString();
insilmaril@821
  2749
		//qDebug ()<<"Services: "<<QDBusConnection::sessionBus().interface()->registeredServiceNames().value();
insilmaril@821
  2750
		if (*browserPID==0 ||
insilmaril@821
  2751
			(browser.contains("konqueror") &&
insilmaril@821
  2752
			 !QDBusConnection::sessionBus().interface()->registeredServiceNames().value().contains (QString("org.kde.konqueror-%1").arg(*browserPID)))
insilmaril@821
  2753
		   )	 
insilmaril@366
  2754
		{
insilmaril@821
  2755
			// Start a new browser, if there is not one running already or
insilmaril@821
  2756
			// if a previously started konqueror is gone.
insilmaril@821
  2757
			if (debug) cout <<"Main::openTabs no konqueror-"<<*browserPID<<" found\n";
insilmaril@366
  2758
			QString u=urls.takeFirst();
insilmaril@366
  2759
			args<<u;
insilmaril@804
  2760
			QString workDir=QDir::currentDirPath();
insilmaril@804
  2761
			if (!QProcess::startDetached(browser,args,workDir,browserPID))
insilmaril@366
  2762
			{
insilmaril@366
  2763
				// try to set path to browser
insilmaril@366
  2764
				QMessageBox::warning(0, 
insilmaril@366
  2765
					tr("Warning"),
insilmaril@366
  2766
					tr("Couldn't find a viewer to open %1.\n").arg(u)+
insilmaril@366
  2767
					tr("Please use Settings->")+tr("Set application to open an URL"));
insilmaril@366
  2768
				return;
insilmaril@366
  2769
			}
insilmaril@804
  2770
			if (debug) cout << "Main::openTabs  Started konqueror-"<<*browserPID<<endl;
insilmaril@608
  2771
#if defined(Q_OS_WIN32)
insilmaril@608
  2772
            // There's no sleep in VCEE, replace it with Qt's QThread::wait().
insilmaril@608
  2773
            this->thread()->wait(3000);
insilmaril@608
  2774
#else
insilmaril@804
  2775
			sleep (3);	//FIXME-3 needed?
insilmaril@608
  2776
#endif
insilmaril@366
  2777
		}
insilmaril@804
  2778
insilmaril@366
  2779
		if (browser.contains("konqueror"))
insilmaril@366
  2780
		{
insilmaril@366
  2781
			for (int i=0; i<urls.size(); i++)
insilmaril@366
  2782
			{
insilmaril@366
  2783
				// Open new browser
insilmaril@366
  2784
				// Try to open new tab in existing konqueror started previously by vym
insilmaril@366
  2785
				args.clear();
insilmaril@804
  2786
insilmaril@804
  2787
/*	On KDE3 use DCOP
insilmaril@608
  2788
				args<< QString("konqueror-%1").arg(procBrowser->pid())<<
insilmaril@608
  2789
					"konqueror-mainwindow#1"<<
insilmaril@608
  2790
					"newTab" <<
insilmaril@608
  2791
					urls.at(i);
insilmaril@804
  2792
*/					
insilmaril@804
  2793
				args<< QString("org.kde.konqueror-%1").arg(*browserPID)<<
insilmaril@804
  2794
					"/konqueror/MainWindow_1"<<
insilmaril@804
  2795
					"newTab" <<
insilmaril@804
  2796
					urls.at(i)<<
insilmaril@804
  2797
					"false";
insilmaril@804
  2798
				if (debug) cout << "MainWindow::openURLs  args="<<args.join(" ").toStdString()<<endl;
insilmaril@804
  2799
				if (!QProcess::startDetached ("qdbus",args))
insilmaril@804
  2800
					success=false;
insilmaril@366
  2801
			}
insilmaril@366
  2802
			if (!success)
insilmaril@366
  2803
				QMessageBox::warning(0, 
insilmaril@366
  2804
					tr("Warning"),
insilmaril@366
  2805
					tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
insilmaril@366
  2806
			return;		
insilmaril@366
  2807
		} else if (browser.contains ("firefox") || browser.contains ("mozilla") )
insilmaril@366
  2808
		{
insilmaril@366
  2809
			for (int i=0; i<urls.size(); i++)
insilmaril@366
  2810
			{
insilmaril@366
  2811
				// Try to open new tab in firefox
insilmaril@366
  2812
				args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
insilmaril@804
  2813
				if (!QProcess::startDetached (browser,args))
insilmaril@804
  2814
					success=false;
insilmaril@366
  2815
			}			
insilmaril@366
  2816
			if (!success)
insilmaril@366
  2817
				QMessageBox::warning(0, 
insilmaril@366
  2818
					tr("Warning"),
insilmaril@366
  2819
					tr("Couldn't start %1 to open a new tab").arg(browser));
insilmaril@366
  2820
			return;		
insilmaril@366
  2821
		}			
insilmaril@366
  2822
		QMessageBox::warning(0, 
insilmaril@366
  2823
			tr("Warning"),
insilmaril@366
  2824
			tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
insilmaril@366
  2825
	}	
insilmaril@366
  2826
}
insilmaril@366
  2827
insilmaril@0
  2828
void Main::editOpenURL()
insilmaril@0
  2829
{
insilmaril@266
  2830
	// Open new browser
insilmaril@721
  2831
	VymModel *m=currentModel();
insilmaril@721
  2832
	if (m)
insilmaril@266
  2833
	{	
insilmaril@721
  2834
	    QString url=m->getURL();
insilmaril@366
  2835
		QStringList args;
insilmaril@266
  2836
		if (url=="") return;
insilmaril@366
  2837
		QString browser=settings.value("/mainwindow/readerURL" ).toString();
insilmaril@366
  2838
		args<<url;
insilmaril@804
  2839
		QString workDir=QDir::currentDirPath();
insilmaril@804
  2840
		if (!procBrowser->startDetached(browser,args))
insilmaril@266
  2841
		{
insilmaril@266
  2842
			// try to set path to browser
insilmaril@266
  2843
			QMessageBox::warning(0, 
insilmaril@266
  2844
				tr("Warning"),
insilmaril@266
  2845
				tr("Couldn't find a viewer to open %1.\n").arg(url)+
insilmaril@266
  2846
				tr("Please use Settings->")+tr("Set application to open an URL"));
insilmaril@266
  2847
			settingsURL() ; 
insilmaril@266
  2848
		}	
insilmaril@266
  2849
	}	
insilmaril@266
  2850
}
insilmaril@266
  2851
void Main::editOpenURLTab()
insilmaril@266
  2852
{
insilmaril@721
  2853
	VymModel *m=currentModel();
insilmaril@721
  2854
	if (m)
insilmaril@266
  2855
	{	
insilmaril@366
  2856
	    QStringList urls;
insilmaril@721
  2857
		urls.append(m->getURL());
insilmaril@366
  2858
		openTabs (urls);
insilmaril@266
  2859
	}	
insilmaril@0
  2860
}
insilmaril@821
  2861
insilmaril@821
  2862
void Main::editOpenMultipleVisURLTabs(bool ignoreScrolled)
insilmaril@366
  2863
{
insilmaril@721
  2864
	VymModel *m=currentModel();
insilmaril@721
  2865
	if (m)
insilmaril@366
  2866
	{	
insilmaril@366
  2867
	    QStringList urls;
insilmaril@821
  2868
		urls=m->getURLs(ignoreScrolled);
insilmaril@366
  2869
		openTabs (urls);
insilmaril@366
  2870
	}	
insilmaril@366
  2871
}
insilmaril@366
  2872
insilmaril@821
  2873
void Main::editOpenMultipleURLTabs()
insilmaril@821
  2874
{
insilmaril@821
  2875
	editOpenMultipleVisURLTabs (false);
insilmaril@821
  2876
}
insilmaril@821
  2877
insilmaril@0
  2878
insilmaril@0
  2879
void Main::editURL()
insilmaril@0
  2880
{
insilmaril@721
  2881
	VymModel *m=currentModel();
insilmaril@721
  2882
	if (m) m->editURL();
insilmaril@0
  2883
}
insilmaril@0
  2884
insilmaril@528
  2885
void Main::editLocalURL()
insilmaril@528
  2886
{
insilmaril@721
  2887
	VymModel *m=currentModel();
insilmaril@721
  2888
	if (m) m->editLocalURL();
insilmaril@528
  2889
}
insilmaril@528
  2890
insilmaril@0
  2891
void Main::editHeading2URL()
insilmaril@0
  2892
{
insilmaril@721
  2893
	VymModel *m=currentModel();
insilmaril@721
  2894
	if (m) m->editHeading2URL();
insilmaril@0
  2895
}
insilmaril@0
  2896
insilmaril@0
  2897
void Main::editBugzilla2URL()
insilmaril@0
  2898
{
insilmaril@721
  2899
	VymModel *m=currentModel();
insilmaril@721
  2900
	if (m) m->editBugzilla2URL();
insilmaril@0
  2901
}
insilmaril@0
  2902
insilmaril@820
  2903
void Main::getBugzillaData()
insilmaril@820
  2904
{
insilmaril@820
  2905
	VymModel *m=currentModel();
insilmaril@821
  2906
	/*
insilmaril@821
  2907
	QProgressDialog progress ("Doing stuff","cancl",0,10,this);
insilmaril@821
  2908
	progress.setWindowModality(Qt::WindowModal);
insilmaril@821
  2909
	//progress.setCancelButton (NULL);
insilmaril@821
  2910
	progress.show();
insilmaril@821
  2911
	progress.setMinimumDuration (0);
insilmaril@821
  2912
	progress.setValue (1);
insilmaril@821
  2913
	progress.setValue (5);
insilmaril@821
  2914
	progress.update();
insilmaril@821
  2915
	*/
insilmaril@821
  2916
	/*
insilmaril@821
  2917
	QProgressBar *pb=new QProgressBar;
insilmaril@821
  2918
	pb->setMinimum (0);
insilmaril@821
  2919
	pb->setMaximum (0);
insilmaril@821
  2920
	pb->show();
insilmaril@821
  2921
	pb->repaint();
insilmaril@821
  2922
	*/
insilmaril@820
  2923
	if (m) m->getBugzillaData();
insilmaril@820
  2924
}
insilmaril@820
  2925
insilmaril@175
  2926
void Main::editFATE2URL()
insilmaril@175
  2927
{
insilmaril@721
  2928
	VymModel *m=currentModel();
insilmaril@721
  2929
	if (m) m->editFATE2URL();
insilmaril@175
  2930
}
insilmaril@175
  2931
insilmaril@721
  2932
void Main::editHeadingFinished(VymModel *m)
insilmaril@394
  2933
{
insilmaril@721
  2934
	if (m)
insilmaril@721
  2935
	{
insilmaril@721
  2936
		if (!actionSettingsAutoSelectNewBranch->isOn() && 
insilmaril@721
  2937
			!prevSelection.isEmpty()) 
insilmaril@721
  2938
			m->select(prevSelection);
insilmaril@721
  2939
		prevSelection="";
insilmaril@721
  2940
	}
insilmaril@394
  2941
}
insilmaril@394
  2942
insilmaril@366
  2943
void Main::openVymLinks(const QStringList &vl)
insilmaril@366
  2944
{
insilmaril@366
  2945
	for (int j=0; j<vl.size(); j++)
insilmaril@366
  2946
	{
insilmaril@0
  2947
		// compare path with already loaded maps
insilmaril@0
  2948
		int index=-1;
insilmaril@0
  2949
		int i;
insilmaril@772
  2950
		for (i=0;i<=vymViews.count() -1;i++)
insilmaril@0
  2951
		{
insilmaril@772
  2952
			if (vl.at(j)==vymViews.at(i)->getModel()->getFilePath() )
insilmaril@0
  2953
			{
insilmaril@0
  2954
				index=i;
insilmaril@0
  2955
				break;
insilmaril@0
  2956
			}
insilmaril@0
  2957
		}	
insilmaril@0
  2958
		if (index<0)
insilmaril@0
  2959
		// Load map
insilmaril@0
  2960
		{
insilmaril@366
  2961
			if (!QFile(vl.at(j)).exists() )
insilmaril@0
  2962
				QMessageBox::critical( 0, tr( "Critical Error" ),
insilmaril@366
  2963
				   tr("Couldn't open map %1").arg(vl.at(j)));
insilmaril@0
  2964
			else
insilmaril@0
  2965
			{
insilmaril@366
  2966
				fileLoad (vl.at(j), NewMap);
insilmaril@725
  2967
				tabWidget->setCurrentIndex (tabWidget->count()-1);	
insilmaril@0
  2968
			}
insilmaril@0
  2969
		} else
insilmaril@0
  2970
			// Go to tab containing the map
insilmaril@725
  2971
			tabWidget->setCurrentIndex (index);	
insilmaril@0
  2972
	}
insilmaril@0
  2973
}
insilmaril@0
  2974
insilmaril@366
  2975
void Main::editOpenVymLink()
insilmaril@366
  2976
{
insilmaril@721
  2977
	VymModel *m=currentModel();
insilmaril@721
  2978
	if (m)
insilmaril@366
  2979
	{
insilmaril@366
  2980
		QStringList vl;
insilmaril@721
  2981
		vl.append(m->getVymLink());	
insilmaril@366
  2982
		openVymLinks (vl);
insilmaril@366
  2983
	}
insilmaril@366
  2984
}
insilmaril@366
  2985
insilmaril@366
  2986
void Main::editOpenMultipleVymLinks()
insilmaril@366
  2987
{
insilmaril@366
  2988
	QString currentVymLink;
insilmaril@721
  2989
	VymModel *m=currentModel();
insilmaril@721
  2990
	if (m)
insilmaril@366
  2991
	{
insilmaril@721
  2992
		QStringList vl=m->getVymLinks();
insilmaril@366
  2993
		openVymLinks (vl);
insilmaril@366
  2994
	}
insilmaril@366
  2995
}
insilmaril@366
  2996
insilmaril@0
  2997
void Main::editVymLink()
insilmaril@0
  2998
{
insilmaril@721
  2999
	VymModel *m=currentModel();
insilmaril@721
  3000
	if (m)
insilmaril@721
  3001
		m->editVymLink();	
insilmaril@0
  3002
}
insilmaril@0
  3003
insilmaril@0
  3004
void Main::editDeleteVymLink()
insilmaril@0
  3005
{
insilmaril@721
  3006
	VymModel *m=currentModel();
insilmaril@721
  3007
	if (m) m->deleteVymLink();	
insilmaril@0
  3008
}
insilmaril@0
  3009
insilmaril@243
  3010
void Main::editToggleHideExport()
insilmaril@243
  3011
{
insilmaril@721
  3012
	VymModel *m=currentModel();
insilmaril@721
  3013
	if (m) m->toggleHideExport();	
insilmaril@243
  3014
}
insilmaril@243
  3015
insilmaril@804
  3016
void Main::editAddTimestamp()
insilmaril@804
  3017
{
insilmaril@804
  3018
	VymModel *m=currentModel();
insilmaril@804
  3019
	if (m) m->addTimestamp();	
insilmaril@804
  3020
}
insilmaril@804
  3021
insilmaril@0
  3022
void Main::editMapInfo()
insilmaril@0
  3023
{
insilmaril@721
  3024
	VymModel *m=currentModel();
insilmaril@795
  3025
	if (!m) return;
insilmaril@721
  3026
insilmaril@721
  3027
	ExtraInfoDialog dia;
insilmaril@721
  3028
	dia.setMapName (m->getFileName() );
insilmaril@721
  3029
	dia.setAuthor (m->getAuthor() );
insilmaril@721
  3030
	dia.setComment(m->getComment() );
insilmaril@721
  3031
insilmaril@721
  3032
	// Calc some stats
insilmaril@721
  3033
	QString stats;
insilmaril@795
  3034
    stats+=tr("%1 items on map\n","Info about map").arg (m->getScene()->items().size(),6);
insilmaril@721
  3035
insilmaril@721
  3036
	uint b=0;
insilmaril@721
  3037
	uint f=0;
insilmaril@721
  3038
	uint n=0;
insilmaril@721
  3039
	uint xl=0;
insilmaril@795
  3040
	BranchItem *cur=NULL;
insilmaril@795
  3041
	BranchItem *prev=NULL;
insilmaril@804
  3042
	m->nextBranch(cur,prev);
insilmaril@795
  3043
	while (cur) 
insilmaril@721
  3044
	{
insilmaril@795
  3045
		if (!cur->getNote().isEmpty() ) n++;
insilmaril@795
  3046
		f+= cur->imageCount();
insilmaril@721
  3047
		b++;
insilmaril@795
  3048
		xl+=cur->xlinkCount();
insilmaril@804
  3049
		m->nextBranch(cur,prev);
insilmaril@721
  3050
	}
insilmaril@795
  3051
insilmaril@721
  3052
    stats+=QString ("%1 xLinks \n").arg (xl,6);
insilmaril@721
  3053
    stats+=QString ("%1 notes\n").arg (n,6);
insilmaril@721
  3054
    stats+=QString ("%1 images\n").arg (f,6);
insilmaril@749
  3055
    stats+=QString ("%1 branches\n").arg (m->branchCount(),6);
insilmaril@721
  3056
	dia.setStats (stats);
insilmaril@721
  3057
insilmaril@721
  3058
	// Finally show dialog
insilmaril@721
  3059
	if (dia.exec() == QDialog::Accepted)
insilmaril@721
  3060
	{
insilmaril@721
  3061
		m->setAuthor (dia.getAuthor() );
insilmaril@721
  3062
		m->setComment (dia.getComment() );
insilmaril@721
  3063
	}
insilmaril@0
  3064
}
insilmaril@0
  3065
insilmaril@0
  3066
void Main::editMoveUp()
insilmaril@0
  3067
{
insilmaril@721
  3068
	VymModel *m=currentModel();
insilmaril@767
  3069
	if (m) m->moveUp();
insilmaril@0
  3070
}
insilmaril@0
  3071
insilmaril@0
  3072
void Main::editMoveDown()
insilmaril@0
  3073
{
insilmaril@721
  3074
	VymModel *m=currentModel();
insilmaril@767
  3075
	if (m) m->moveDown();
insilmaril@0
  3076
}
insilmaril@0
  3077
insilmaril@795
  3078
void Main::editDetach()
insilmaril@795
  3079
{
insilmaril@795
  3080
	VymModel *m=currentModel();
insilmaril@795
  3081
	if (m) m->detach();
insilmaril@795
  3082
}
insilmaril@795
  3083
insilmaril@608
  3084
void Main::editSortChildren()
insilmaril@608
  3085
{
insilmaril@721
  3086
	VymModel *m=currentModel();
insilmaril@822
  3087
	if (m) m->sortChildren(false);
insilmaril@822
  3088
}
insilmaril@822
  3089
insilmaril@822
  3090
void Main::editSortBackChildren()
insilmaril@822
  3091
{
insilmaril@822
  3092
	VymModel *m=currentModel();
insilmaril@822
  3093
	if (m) m->sortChildren(true);
insilmaril@608
  3094
}
insilmaril@608
  3095
insilmaril@0
  3096
void Main::editToggleScroll()
insilmaril@0
  3097
{
insilmaril@721
  3098
	VymModel *m=currentModel();
insilmaril@721
  3099
	if (m) m->toggleScroll();
insilmaril@721
  3100
}
insilmaril@721
  3101
insilmaril@763
  3102
void Main::editExpandAll()
insilmaril@763
  3103
{
insilmaril@763
  3104
	VymModel *m=currentModel();
insilmaril@763
  3105
	if (m) m->emitExpandAll();
insilmaril@763
  3106
}
insilmaril@763
  3107
insilmaril@804
  3108
void Main::editExpandOneLevel()
insilmaril@804
  3109
{
insilmaril@804
  3110
	VymModel *m=currentModel();
insilmaril@804
  3111
	if (m) m->emitExpandOneLevel();
insilmaril@804
  3112
}
insilmaril@804
  3113
insilmaril@804
  3114
void Main::editCollapseOneLevel()
insilmaril@804
  3115
{
insilmaril@804
  3116
	VymModel *m=currentModel();
insilmaril@804
  3117
	if (m) m->emitCollapseOneLevel();
insilmaril@804
  3118
}
insilmaril@804
  3119
insilmaril@721
  3120
void Main::editUnscrollChildren()
insilmaril@721
  3121
{
insilmaril@721
  3122
	VymModel *m=currentModel();
insilmaril@721
  3123
	if (m) m->unscrollChildren();
insilmaril@721
  3124
}
insilmaril@721
  3125
insilmaril@786
  3126
void Main::editAddAttribute()
insilmaril@786
  3127
{
insilmaril@786
  3128
	VymModel *m=currentModel();
insilmaril@819
  3129
	if (m) 
insilmaril@819
  3130
	{
insilmaril@819
  3131
insilmaril@819
  3132
		m->addAttribute();
insilmaril@819
  3133
	}
insilmaril@786
  3134
}
insilmaril@786
  3135
insilmaril@721
  3136
void Main::editAddMapCenter()
insilmaril@721
  3137
{
insilmaril@721
  3138
	VymModel *m=currentModel();
insilmaril@835
  3139
	if (m) m->select (m->addMapCenter ());
insilmaril@0
  3140
}
insilmaril@0
  3141
insilmaril@394
  3142
void Main::editNewBranch()
insilmaril@394
  3143
{
insilmaril@721
  3144
	VymModel *m=currentModel();
insilmaril@725
  3145
	if (m)
insilmaril@0
  3146
	{
insilmaril@775
  3147
		BranchItem *bi=m->addNewBranch();
insilmaril@775
  3148
		if (!bi) return;
insilmaril@775
  3149
insilmaril@775
  3150
		if (actionSettingsAutoEditNewBranch->isOn() 
insilmaril@775
  3151
		     && !actionSettingsAutoSelectNewBranch->isOn() )
insilmaril@775
  3152
			prevSelection=m->getSelectString();
insilmaril@775
  3153
		else	
insilmaril@775
  3154
			prevSelection=QString();
insilmaril@775
  3155
insilmaril@775
  3156
		if (actionSettingsAutoSelectNewBranch->isOn()  
insilmaril@775
  3157
			|| actionSettingsAutoEditNewBranch->isOn()) 
insilmaril@775
  3158
		{
insilmaril@753
  3159
			m->select (bi);
insilmaril@775
  3160
			if (actionSettingsAutoEditNewBranch->isOn())
insilmaril@775
  3161
				currentMapEditor()->editHeading();
insilmaril@394
  3162
		}
insilmaril@0
  3163
	}	
insilmaril@0
  3164
}
insilmaril@0
  3165
insilmaril@394
  3166
void Main::editNewBranchBefore()
insilmaril@0
  3167
{
insilmaril@721
  3168
	VymModel *m=currentModel();
insilmaril@725
  3169
	if (m)
insilmaril@394
  3170
	{
insilmaril@771
  3171
		BranchItem *bi=m->addNewBranchBefore();
insilmaril@753
  3172
insilmaril@753
  3173
		if (bi) 
insilmaril@753
  3174
			m->select (bi);
insilmaril@394
  3175
		else
insilmaril@394
  3176
			return;
insilmaril@394
  3177
insilmaril@537
  3178
		if (actionSettingsAutoEditNewBranch->isOn())
insilmaril@394
  3179
		{
insilmaril@537
  3180
			if (!actionSettingsAutoSelectNewBranch->isOn())
insilmaril@753
  3181
				prevSelection=m->getSelectString(bi); 
insilmaril@721
  3182
			currentMapEditor()->editHeading();
insilmaril@394
  3183
		}
insilmaril@394
  3184
	}	
insilmaril@98
  3185
}
insilmaril@98
  3186
insilmaril@813
  3187
void Main::editNewBranchAbove()	
insilmaril@0
  3188
{
insilmaril@721
  3189
	VymModel *m=currentModel();
insilmaril@725
  3190
	if ( m)
insilmaril@394
  3191
	{
insilmaril@763
  3192
		BranchItem *bi=m->addNewBranch (-1);
insilmaril@753
  3193
insilmaril@753
  3194
insilmaril@753
  3195
		if (bi) 
insilmaril@753
  3196
			m->select (bi);
insilmaril@394
  3197
		else
insilmaril@394
  3198
			return;
insilmaril@394
  3199
insilmaril@537
  3200
		if (actionSettingsAutoEditNewBranch->isOn())
insilmaril@394
  3201
		{
insilmaril@537
  3202
			if (!actionSettingsAutoSelectNewBranch->isOn())
insilmaril@753
  3203
				prevSelection=m->getSelectString (bi);	
insilmaril@721
  3204
			currentMapEditor()->editHeading();
insilmaril@394
  3205
		}
insilmaril@394
  3206
	}	
insilmaril@0
  3207
}
insilmaril@0
  3208
insilmaril@0
  3209
void Main::editNewBranchBelow()
insilmaril@0
  3210
{
insilmaril@721
  3211
	VymModel *m=currentModel();
insilmaril@725
  3212
	if (m)
insilmaril@394
  3213
	{
insilmaril@763
  3214
		BranchItem *bi=m->addNewBranch (1);
insilmaril@753
  3215
insilmaril@753
  3216
		if (bi) 
insilmaril@753
  3217
			m->select (bi);
insilmaril@394
  3218
		else
insilmaril@394
  3219
			return;
insilmaril@394
  3220
insilmaril@537
  3221
		if (actionSettingsAutoEditNewBranch->isOn())
insilmaril@394
  3222
		{
insilmaril@537
  3223
			if (!actionSettingsAutoSelectNewBranch->isOn())
insilmaril@753
  3224
				prevSelection=m->getSelectString(bi);
insilmaril@721
  3225
			currentMapEditor()->editHeading();
insilmaril@394
  3226
		}
insilmaril@394
  3227
	}	
insilmaril@0
  3228
}
insilmaril@0
  3229
insilmaril@0
  3230
void Main::editImportAdd()
insilmaril@0
  3231
{
insilmaril@0
  3232
	fileLoad (ImportAdd);
insilmaril@0
  3233
}
insilmaril@0
  3234
insilmaril@0
  3235
void Main::editImportReplace()
insilmaril@0
  3236
{
insilmaril@0
  3237
	fileLoad (ImportReplace);
insilmaril@0
  3238
}
insilmaril@0
  3239
insilmaril@0
  3240
void Main::editSaveBranch()
insilmaril@0
  3241
{
insilmaril@0
  3242
	fileSaveAs (PartOfMap);
insilmaril@0
  3243
}
insilmaril@0
  3244
insilmaril@721
  3245
void Main::editDeleteKeepChildren()
insilmaril@98
  3246
{
insilmaril@721
  3247
	VymModel *m=currentModel();
insilmaril@721
  3248
	 if (m) m->deleteKeepChildren();
insilmaril@98
  3249
}
insilmaril@98
  3250
insilmaril@721
  3251
void Main::editDeleteChildren()
insilmaril@98
  3252
{
insilmaril@721
  3253
	VymModel *m=currentModel();
insilmaril@721
  3254
	if (m) m->deleteChildren();
insilmaril@98
  3255
}
insilmaril@98
  3256
insilmaril@0
  3257
void Main::editDeleteSelection()
insilmaril@0
  3258
{
insilmaril@721
  3259
	VymModel *m=currentModel();
insilmaril@721
  3260
	if (m && actionSettingsUseDelKey->isOn())
insilmaril@721
  3261
		m->deleteSelection();
insilmaril@0
  3262
}
insilmaril@0
  3263
insilmaril@0
  3264
void Main::editLoadImage()
insilmaril@0
  3265
{
insilmaril@721
  3266
	VymModel *m=currentModel();
insilmaril@721
  3267
	if (m) m->loadFloatImage();
insilmaril@0
  3268
}
insilmaril@0
  3269
insilmaril@366
  3270
void Main::editSaveImage()
insilmaril@0
  3271
{
insilmaril@721
  3272
	VymModel *m=currentModel();
insilmaril@721
  3273
	if (m) m->saveFloatImage();
insilmaril@0
  3274
}
insilmaril@0
  3275
insilmaril@366
  3276
void Main::editEditXLink(QAction *a)
insilmaril@89
  3277
{
insilmaril@721
  3278
	VymModel *m=currentModel();
insilmaril@721
  3279
	if (m)
insilmaril@721
  3280
		m->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
insilmaril@94
  3281
}
insilmaril@94
  3282
insilmaril@0
  3283
void Main::formatSelectColor()
insilmaril@0
  3284
{
insilmaril@721
  3285
	QColor col = QColorDialog::getColor((currentColor ), this );
insilmaril@721
  3286
	if ( !col.isValid() ) return;
insilmaril@721
  3287
	colorChanged( col );
insilmaril@0
  3288
}
insilmaril@0
  3289
insilmaril@0
  3290
void Main::formatPickColor()
insilmaril@0
  3291
{
insilmaril@721
  3292
	VymModel *m=currentModel();
insilmaril@721
  3293
	if (m)
insilmaril@721
  3294
		colorChanged( m->getCurrentHeadingColor() );
insilmaril@0
  3295
}
insilmaril@0
  3296
insilmaril@0
  3297
void Main::colorChanged(QColor c)
insilmaril@0
  3298
{
insilmaril@0
  3299
    QPixmap pix( 16, 16 );
insilmaril@0
  3300
    pix.fill( c );
insilmaril@0
  3301
    actionFormatColor->setIconSet( pix );
insilmaril@395
  3302
	currentColor=c;
insilmaril@0
  3303
}
insilmaril@0
  3304
insilmaril@0
  3305
void Main::formatColorBranch()
insilmaril@0
  3306
{
insilmaril@721
  3307
	VymModel *m=currentModel();
insilmaril@721
  3308
	if (m) m->colorBranch(currentColor);
insilmaril@0
  3309
}
insilmaril@0
  3310
insilmaril@417
  3311
void Main::formatColorSubtree()
insilmaril@417
  3312
{
insilmaril@721
  3313
	VymModel *m=currentModel();
insilmaril@721
  3314
	if (m) m->colorSubtree (currentColor);
insilmaril@417
  3315
}
insilmaril@417
  3316
insilmaril@0
  3317
void Main::formatLinkStyleLine()
insilmaril@0
  3318
{
insilmaril@721
  3319
	VymModel *m=currentModel();
insilmaril@721
  3320
	if (m)
insilmaril@625
  3321
    {
insilmaril@721
  3322
		m->setMapLinkStyle("StyleLine");
insilmaril@802
  3323
        actionFormatLinkStyleLine->setChecked(true);
insilmaril@625
  3324
    }
insilmaril@0
  3325
}
insilmaril@0
  3326
insilmaril@0
  3327
void Main::formatLinkStyleParabel()
insilmaril@0
  3328
{
insilmaril@721
  3329
	VymModel *m=currentModel();
insilmaril@721
  3330
	if (m)
insilmaril@625
  3331
    {
insilmaril@721
  3332
		m->setMapLinkStyle("StyleParabel");
insilmaril@802
  3333
        actionFormatLinkStyleParabel->setChecked(true);
insilmaril@625
  3334
    }
insilmaril@0
  3335
}
insilmaril@0
  3336
insilmaril@0
  3337
void Main::formatLinkStylePolyLine()
insilmaril@0
  3338
{
insilmaril@721
  3339
	VymModel *m=currentModel();
insilmaril@721
  3340
	if (m)
insilmaril@625
  3341
    {
insilmaril@721
  3342
		m->setMapLinkStyle("StylePolyLine");
insilmaril@802
  3343
        actionFormatLinkStylePolyLine->setChecked(true);
insilmaril@625
  3344
    }
insilmaril@0
  3345
}
insilmaril@0
  3346
insilmaril@0
  3347
void Main::formatLinkStylePolyParabel()
insilmaril@0
  3348
{
insilmaril@721
  3349
	VymModel *m=currentModel();
insilmaril@721
  3350
	if (m)
insilmaril@625
  3351
    {
insilmaril@721
  3352
		m->setMapLinkStyle("StylePolyParabel");
insilmaril@802
  3353
        actionFormatLinkStylePolyParabel->setChecked(true);
insilmaril@625
  3354
    }
insilmaril@0
  3355
}
insilmaril@0
  3356
insilmaril@0
  3357
void Main::formatSelectBackColor()
insilmaril@0
  3358
{
insilmaril@721
  3359
	VymModel *m=currentModel();
insilmaril@721
  3360
	if (m) m->selectMapBackgroundColor();
insilmaril@0
  3361
}
insilmaril@0
  3362
insilmaril@408
  3363
void Main::formatSelectBackImage()
insilmaril@408
  3364
{
insilmaril@721
  3365
	VymModel *m=currentModel();
insilmaril@721
  3366
	if (m)
insilmaril@721
  3367
		m->selectMapBackgroundImage();
insilmaril@408
  3368
}
insilmaril@408
  3369
insilmaril@0
  3370
void Main::formatSelectLinkColor()
insilmaril@0
  3371
{
insilmaril@721
  3372
	VymModel *m=currentModel();
insilmaril@721
  3373
	if (m)
insilmaril@721
  3374
	{
insilmaril@721
  3375
		QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
insilmaril@721
  3376
		m->setMapDefLinkColor( col );
insilmaril@721
  3377
	}
insilmaril@0
  3378
}
insilmaril@0
  3379
insilmaril@442
  3380
void Main::formatSelectSelectionColor()
insilmaril@442
  3381
{
insilmaril@721
  3382
	VymModel *m=currentModel();
insilmaril@721
  3383
	if (m)
insilmaril@721
  3384
	{
insilmaril@721
  3385
		QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
insilmaril@721
  3386
		m->setSelectionColor (col);
insilmaril@721
  3387
	}
insilmaril@721
  3388
insilmaril@442
  3389
}
insilmaril@442
  3390
insilmaril@0
  3391
void Main::formatToggleLinkColorHint()
insilmaril@0
  3392
{
insilmaril@721
  3393
	VymModel *m=currentModel();
insilmaril@721
  3394
	if (m) m->toggleMapLinkColorHint();
insilmaril@0
  3395
}
insilmaril@0
  3396
insilmaril@0
  3397
insilmaril@746
  3398
void Main::formatHideLinkUnselected()	//FIXME-3 get rid of this with imagepropertydialog
insilmaril@160
  3399
{
insilmaril@721
  3400
	VymModel *m=currentModel();
insilmaril@721
  3401
	if (m)
insilmaril@721
  3402
		m->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
insilmaril@160
  3403
}
insilmaril@160
  3404
insilmaril@0
  3405
void Main::viewZoomReset()
insilmaril@0
  3406
{
insilmaril@767
  3407
	MapEditor *me=currentMapEditor();
insilmaril@767
  3408
	if (me) me->setZoomFactorTarget (1);
insilmaril@0
  3409
}
insilmaril@0
  3410
insilmaril@0
  3411
void Main::viewZoomIn()
insilmaril@0
  3412
{
insilmaril@767
  3413
	MapEditor *me=currentMapEditor();
insilmaril@837
  3414
	if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*1.15);
insilmaril@0
  3415
}
insilmaril@0
  3416
insilmaril@0
  3417
void Main::viewZoomOut()
insilmaril@0
  3418
{
insilmaril@767
  3419
	MapEditor *me=currentMapEditor();
insilmaril@837
  3420
	if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*0.85);
insilmaril@0
  3421
}
insilmaril@89
  3422
insilmaril@526
  3423
void Main::viewCenter()
insilmaril@526
  3424
{
insilmaril@721
  3425
	VymModel *m=currentModel();
insilmaril@763
  3426
	if (m) m->emitShowSelection();
insilmaril@526
  3427
}
insilmaril@526
  3428
insilmaril@528
  3429
void Main::networkStartServer()
insilmaril@528
  3430
{
insilmaril@721
  3431
	VymModel *m=currentModel();
insilmaril@721
  3432
	if (m) m->newServer();
insilmaril@528
  3433
}
insilmaril@528
  3434
insilmaril@528
  3435
void Main::networkConnect()
insilmaril@528
  3436
{
insilmaril@721
  3437
	VymModel *m=currentModel();
insilmaril@721
  3438
	if (m) m->connectToServer();
insilmaril@528
  3439
}
insilmaril@528
  3440
insilmaril@0
  3441
bool Main::settingsPDF()
insilmaril@0
  3442
{
insilmaril@0
  3443
	// Default browser is set in constructor
insilmaril@0
  3444
	bool ok;
insilmaril@0
  3445
	QString text = QInputDialog::getText(
insilmaril@266
  3446
		"VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
insilmaril@366
  3447
		settings.value("/mainwindow/readerPDF").toString(), &ok, this );
insilmaril@0
  3448
	if (ok)
insilmaril@366
  3449
		settings.setValue ("/mainwindow/readerPDF",text);
insilmaril@0
  3450
	return ok;
insilmaril@0
  3451
}
insilmaril@0
  3452
insilmaril@0
  3453
insilmaril@0
  3454
bool Main::settingsURL()
insilmaril@0
  3455
{
insilmaril@0
  3456
	// Default browser is set in constructor
insilmaril@0
  3457
	bool ok;
insilmaril@0
  3458
	QString text = QInputDialog::getText(
insilmaril@266
  3459
		"VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
insilmaril@366
  3460
		settings.value("/mainwindow/readerURL").toString()
insilmaril@0
  3461
		, &ok, this );
insilmaril@0
  3462
	if (ok)
insilmaril@366
  3463
		settings.setValue ("/mainwindow/readerURL",text);
insilmaril@0
  3464
	return ok;
insilmaril@0
  3465
}
insilmaril@0
  3466
insilmaril@450
  3467
void Main::settingsMacroDir()
insilmaril@450
  3468
{
insilmaril@625
  3469
	QDir defdir(vymBaseDir.path() + "/macros");
insilmaril@450
  3470
	if (!defdir.exists())
insilmaril@450
  3471
		defdir=vymBaseDir;
insilmaril@450
  3472
	QDir dir=QFileDialog::getExistingDirectory (
insilmaril@450
  3473
		this,
insilmaril@450
  3474
		tr ("Directory with vym macros:"), 
insilmaril@450
  3475
		settings.value ("/macros/macroDir",defdir.path()).toString()
insilmaril@450
  3476
	);
insilmaril@450
  3477
	if (dir.exists())
insilmaril@625
  3478
		settings.setValue ("/macros/macroDir",dir.absolutePath());
insilmaril@450
  3479
}
insilmaril@450
  3480
insilmaril@473
  3481
void Main::settingsUndoLevels()
insilmaril@473
  3482
{
insilmaril@473
  3483
	bool ok;
insilmaril@473
  3484
	int i = QInputDialog::getInteger(
insilmaril@473
  3485
		this, 
insilmaril@473
  3486
		tr("QInputDialog::getInteger()"),
insilmaril@473
  3487
	    tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
insilmaril@473
  3488
	if (ok)
insilmaril@473
  3489
	{
insilmaril@473
  3490
		settings.setValue ("/mapeditor/stepsTotal",i);
insilmaril@473
  3491
		QMessageBox::information( this, tr( "VYM -Information:" ),
insilmaril@473
  3492
		   tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i)); 
insilmaril@473
  3493
   }	
insilmaril@473
  3494
}
insilmaril@473
  3495
insilmaril@473
  3496
void Main::settingsAutosaveToggle()
insilmaril@473
  3497
{
insilmaril@742
  3498
	settings.setValue ("/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
insilmaril@473
  3499
}
insilmaril@473
  3500
insilmaril@473
  3501
void Main::settingsAutosaveTime()
insilmaril@473
  3502
{
insilmaril@473
  3503
	bool ok;
insilmaril@473
  3504
	int i = QInputDialog::getInteger(
insilmaril@473
  3505
		this, 
insilmaril@473
  3506
		tr("QInputDialog::getInteger()"),
insilmaril@742
  3507
	    tr("Number of seconds before autosave:"), settings.value("/mainwindow/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
insilmaril@473
  3508
	if (ok)
insilmaril@742
  3509
		settings.setValue ("/mainwindow/autosave/ms",i * 1000);
insilmaril@473
  3510
}
insilmaril@473
  3511
insilmaril@837
  3512
void Main::settingsAutoLayoutToggle()
insilmaril@837
  3513
{
insilmaril@837
  3514
	settings.setValue ("/mainwindow/autoLayout/use",actionSettingsAutosaveToggle->isOn() );
insilmaril@837
  3515
}
insilmaril@837
  3516
insilmaril@625
  3517
void Main::settingsWriteBackupFileToggle()
insilmaril@625
  3518
{
insilmaril@742
  3519
	settings.setValue ("/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
insilmaril@625
  3520
}
insilmaril@625
  3521
insilmaril@689
  3522
void Main::settingsToggleAnimation()
insilmaril@689
  3523
{
insilmaril@689
  3524
	settings.setValue ("/animation/use",actionSettingsUseAnimation->isOn() );
insilmaril@689
  3525
}
insilmaril@689
  3526
insilmaril@327
  3527
void Main::settingsToggleDelKey()
insilmaril@327
  3528
{
insilmaril@327
  3529
	if (actionSettingsUseDelKey->isOn())
insilmaril@327
  3530
	{
insilmaril@723
  3531
		actionDelete->setAccel (QKeySequence (Qt::Key_Delete));
insilmaril@327
  3532
	} else
insilmaril@327
  3533
	{
insilmaril@723
  3534
		actionDelete->setAccel (QKeySequence (""));
insilmaril@327
  3535
	}
insilmaril@327
  3536
}
insilmaril@327
  3537
insilmaril@0
  3538
void Main::windowToggleNoteEditor()
insilmaril@0
  3539
{
insilmaril@502
  3540
	if (textEditor->isVisible() )
insilmaril@497
  3541
		windowHideNoteEditor();
insilmaril@497
  3542
	else
insilmaril@497
  3543
		windowShowNoteEditor();
insilmaril@0
  3544
}
insilmaril@0
  3545
insilmaril@823
  3546
void Main::windowToggleTreeEditor()
insilmaril@823
  3547
{
insilmaril@823
  3548
	if ( tabWidget->currentPage())
insilmaril@823
  3549
		vymViews.at(tabWidget->currentIndex())->toggleTreeEditor();
insilmaril@823
  3550
}
insilmaril@823
  3551
insilmaril@294
  3552
void Main::windowToggleHistory()
insilmaril@294
  3553
{
insilmaril@404
  3554
	if (historyWindow->isVisible())
insilmaril@404
  3555
		historyWindow->hide();
insilmaril@404
  3556
	else	
insilmaril@404
  3557
		historyWindow->show();
insilmaril@404
  3558
insilmaril@404
  3559
}
insilmaril@404
  3560
insilmaril@473
  3561
void Main::windowToggleProperty()
insilmaril@473
  3562
{
insilmaril@473
  3563
	if (branchPropertyWindow->isVisible())
insilmaril@473
  3564
		branchPropertyWindow->hide();
insilmaril@473
  3565
	else	
insilmaril@473
  3566
		branchPropertyWindow->show();
insilmaril@721
  3567
	branchPropertyWindow->setModel (currentModel() );
insilmaril@473
  3568
}
insilmaril@473
  3569
insilmaril@408
  3570
void Main::windowToggleAntiAlias()
insilmaril@408
  3571
{
insilmaril@408
  3572
	bool b=actionViewToggleAntiAlias->isOn();
insilmaril@408
  3573
	MapEditor *me;
insilmaril@772
  3574
	for (int i=0;i<vymViews.count();i++)
insilmaril@408
  3575
	{
insilmaril@772
  3576
		me=vymViews.at(i)->getMapEditor();
insilmaril@725
  3577
		if (me) me->setAntiAlias(b);
insilmaril@408
  3578
	}	
insilmaril@408
  3579
insilmaril@408
  3580
}
insilmaril@408
  3581
insilmaril@732
  3582
bool Main::isAliased()
insilmaril@732
  3583
{
insilmaril@732
  3584
	return actionViewToggleAntiAlias->isOn();
insilmaril@732
  3585
}
insilmaril@732
  3586
insilmaril@732
  3587
bool Main::hasSmoothPixmapTransform()
insilmaril@732
  3588
{
insilmaril@732
  3589
	return actionViewToggleSmoothPixmapTransform->isOn();
insilmaril@732
  3590
}
insilmaril@732
  3591
insilmaril@408
  3592
void Main::windowToggleSmoothPixmap()
insilmaril@408
  3593
{
insilmaril@408
  3594
	bool b=actionViewToggleSmoothPixmapTransform->isOn();
insilmaril@408
  3595
	MapEditor *me;
insilmaril@772
  3596
	for (int i=0;i<vymViews.count();i++)
insilmaril@408
  3597
	{
insilmaril@408
  3598
		
insilmaril@772
  3599
		me=vymViews.at(i)->getMapEditor();
insilmaril@725
  3600
		if (me) me->setSmoothPixmap(b);
insilmaril@408
  3601
	}	
insilmaril@408
  3602
}
insilmaril@408
  3603
insilmaril@404
  3604
void Main::updateHistory(SimpleSettings &undoSet)
insilmaril@404
  3605
{
insilmaril@404
  3606
	historyWindow->update (undoSet);
insilmaril@294
  3607
}
insilmaril@294
  3608
insilmaril@746
  3609
void Main::updateNoteFlag()	
insilmaril@160
  3610
{
insilmaril@721
  3611
	// this slot is connected to TextEditor::textHasChanged()
insilmaril@721
  3612
	VymModel *m=currentModel();
insilmaril@721
  3613
	if (m) m->updateNoteFlag();
insilmaril@160
  3614
}
insilmaril@160
  3615
insilmaril@753
  3616
void Main::updateNoteEditor(QModelIndex index )
insilmaril@746
  3617
{
insilmaril@821
  3618
	TreeItem *ti=((VymModel*) QObject::sender())->getItem(index);
insilmaril@821
  3619
	/*
insilmaril@821
  3620
	cout << "Main::updateNoteEditor model="<<sender();
insilmaril@821
  3621
	cout << "  item="<<ti->getHeadingStd()<<" ("<<ti<<")"<<endl;
insilmaril@821
  3622
	*/
insilmaril@746
  3623
	textEditor->setNote (ti->getNoteObj() );
insilmaril@746
  3624
}
insilmaril@746
  3625
insilmaril@842
  3626
void Main::selectInNoteEditor(QString s,int i)
insilmaril@842
  3627
{
insilmaril@842
  3628
	// TreeItem is already selected at this time, therefor
insilmaril@842
  3629
	// the note is already in the editor
insilmaril@842
  3630
	textEditor->findText (s,0,i);
insilmaril@842
  3631
}
insilmaril@842
  3632
insilmaril@746
  3633
void Main::changeSelection (VymModel *model, const QItemSelection &newsel, const QItemSelection &oldsel)
insilmaril@746
  3634
{
insilmaril@785
  3635
	branchPropertyWindow->setModel (model ); //FIXME-3 this used to be called from BranchObj::select(). Maybe use signal now...
insilmaril@748
  3636
insilmaril@746
  3637
	if (model && model==currentModel() )
insilmaril@746
  3638
	{
insilmaril@746
  3639
		// NoteEditor
insilmaril@746
  3640
		TreeItem *ti;
insilmaril@746
  3641
		if (!oldsel.indexes().isEmpty() )
insilmaril@746
  3642
		{
insilmaril@746
  3643
			ti=model->getItem(oldsel.indexes().first());
insilmaril@768
  3644
insilmaril@768
  3645
			// Don't update note if both treeItem and textEditor are empty
insilmaril@768
  3646
			//if (! (ti->hasEmptyNote() && textEditor->isEmpty() ))
insilmaril@768
  3647
			//	ti->setNoteObj (textEditor->getNoteObj(),false );
insilmaril@746
  3648
		} 
insilmaril@746
  3649
		if (!newsel.indexes().isEmpty() )
insilmaril@746
  3650
		{
insilmaril@746
  3651
			ti=model->getItem(newsel.indexes().first());
insilmaril@768
  3652
			if (!ti->hasEmptyNote() )
insilmaril@746
  3653
				textEditor->setNote(ti->getNoteObj() );
insilmaril@768
  3654
			else
insilmaril@768
  3655
				textEditor->setNote(NoteObj() );	//FIXME-4 maybe add a clear() to TE
insilmaril@770
  3656
			
insilmaril@770
  3657
			// Show URL and link in statusbar	
insilmaril@770
  3658
			QString status;
insilmaril@770
  3659
			QString s=ti->getURL();
insilmaril@770
  3660
			if (!s.isEmpty() ) status+="URL: "+s+"  ";
insilmaril@770
  3661
			s=ti->getVymLink();
insilmaril@770
  3662
			if (!s.isEmpty() ) status+="Link: "+s;
insilmaril@770
  3663
			if (!status.isEmpty() ) statusMessage (status);
insilmaril@770
  3664
insilmaril@746
  3665
		} else
insilmaril@746
  3666
			textEditor->setInactive();
insilmaril@746
  3667
insilmaril@746
  3668
		updateActions();
insilmaril@746
  3669
	}
insilmaril@442
  3670
}
insilmaril@442
  3671
insilmaril@390
  3672
void Main::updateActions()
insilmaril@390
  3673
{
insilmaril@802
  3674
	// updateActions is also called when satellites are closed	//FIXME-2 doesn't update immediatly, e.g. historyWindow is still visible, when "close" is pressed
insilmaril@802
  3675
	actionViewToggleNoteEditor->setChecked (textEditor->isVisible());
insilmaril@802
  3676
	actionViewToggleHistoryWindow->setChecked (historyWindow->isVisible());
insilmaril@802
  3677
	actionViewTogglePropertyWindow->setChecked (branchPropertyWindow->isVisible());
insilmaril@842
  3678
	if ( tabWidget->currentPage())
insilmaril@842
  3679
		actionViewToggleTreeEditor->setChecked (
insilmaril@842
  3680
			vymViews.at(tabWidget->currentIndex())->getTreeEditor()->isVisible()
insilmaril@842
  3681
		);
insilmaril@802
  3682
insilmaril@721
  3683
	VymModel  *m =currentModel();
insilmaril@724
  3684
	if (m) 
insilmaril@724
  3685
	{
insilmaril@724
  3686
		// Printing
insilmaril@724
  3687
		actionFilePrint->setEnabled (true);
insilmaril@724
  3688
insilmaril@724
  3689
		// Link style in context menu
insilmaril@724
  3690
		switch (m->getMapLinkStyle())
insilmaril@724
  3691
		{
insilmaril@724
  3692
			case LinkableMapObj::Line: 
insilmaril@802
  3693
				actionFormatLinkStyleLine->setChecked(true);
insilmaril@724
  3694
				break;
insilmaril@724
  3695
			case LinkableMapObj::Parabel:
insilmaril@802
  3696
				actionFormatLinkStyleParabel->setChecked(true);
insilmaril@724
  3697
				break;
insilmaril@724
  3698
			case LinkableMapObj::PolyLine:	
insilmaril@802
  3699
				actionFormatLinkStylePolyLine->setChecked(true);
insilmaril@724
  3700
				break;
insilmaril@724
  3701
			case LinkableMapObj::PolyParabel:	
insilmaril@802
  3702
				actionFormatLinkStylePolyParabel->setChecked(true);
insilmaril@724
  3703
				break;
insilmaril@724
  3704
			default:
insilmaril@724
  3705
				break;
insilmaril@724
  3706
		}		
insilmaril@724
  3707
insilmaril@724
  3708
		// Update colors
insilmaril@724
  3709
		QPixmap pix( 16, 16 );
insilmaril@724
  3710
		pix.fill( m->getMapBackgroundColor() );
insilmaril@724
  3711
		actionFormatBackColor->setIconSet( pix );
insilmaril@724
  3712
		pix.fill( m->getSelectionColor() );
insilmaril@724
  3713
		actionFormatSelectionColor->setIconSet( pix );
insilmaril@724
  3714
		pix.fill( m->getMapDefLinkColor() );
insilmaril@724
  3715
		actionFormatLinkColor->setIconSet( pix );
insilmaril@724
  3716
insilmaril@724
  3717
		// History window
insilmaril@724
  3718
		historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName()));
insilmaril@724
  3719
insilmaril@804
  3720
insilmaril@804
  3721
		// Expanding/collapsing
insilmaril@804
  3722
		actionExpandAll->setEnabled (true);
insilmaril@804
  3723
		actionExpandOneLevel->setEnabled (true);
insilmaril@804
  3724
		actionCollapseOneLevel->setEnabled (true);
insilmaril@724
  3725
	} else
insilmaril@724
  3726
	{
insilmaril@724
  3727
		// Printing
insilmaril@724
  3728
		actionFilePrint->setEnabled (false);
insilmaril@804
  3729
insilmaril@804
  3730
		// Expanding/collapsing
insilmaril@804
  3731
		actionExpandAll->setEnabled (false);
insilmaril@804
  3732
		actionExpandOneLevel->setEnabled (false);
insilmaril@804
  3733
		actionCollapseOneLevel->setEnabled (false);
insilmaril@724
  3734
	}
insilmaril@407
  3735
insilmaril@724
  3736
	if (m && m->getMapLinkColorHint()==LinkableMapObj::HeadingColor) 
insilmaril@802
  3737
		actionFormatLinkColorHint->setChecked(true);
insilmaril@390
  3738
	else	
insilmaril@802
  3739
		actionFormatLinkColorHint->setChecked(false);
insilmaril@390
  3740
insilmaril@724
  3741
insilmaril@724
  3742
	if (m && m->hasChanged() )
insilmaril@724
  3743
		actionFileSave->setEnabled( true);
insilmaril@724
  3744
	else	
insilmaril@788
  3745
		actionFileSave->setEnabled( false);
insilmaril@724
  3746
	if (m && m->isUndoAvailable())
insilmaril@723
  3747
		actionUndo->setEnabled( true);
insilmaril@390
  3748
	else	
insilmaril@723
  3749
		actionUndo->setEnabled( false);
insilmaril@390
  3750
insilmaril@724
  3751
	if (m && m->isRedoAvailable())
insilmaril@723
  3752
		actionRedo->setEnabled( true);
insilmaril@390
  3753
	else	
insilmaril@723
  3754
		actionRedo->setEnabled( false);
insilmaril@390
  3755
insilmaril@772
  3756
	if (m)
insilmaril@390
  3757
	{
insilmaril@772
  3758
		TreeItem *selti=m->getSelectedItem();
insilmaril@787
  3759
		BranchItem *selbi=m->getSelectedBranch();
insilmaril@772
  3760
		if (selti)
insilmaril@390
  3761
		{
insilmaril@788
  3762
			if (selbi || selti->getType()==TreeItem::Image)
insilmaril@788
  3763
			{
insilmaril@802
  3764
				actionFormatHideLinkUnselected->setChecked (((MapItem*)selti)->getHideLinkUnselected());
insilmaril@788
  3765
				actionFormatHideLinkUnselected->setEnabled (true);
insilmaril@788
  3766
			}
insilmaril@788
  3767
insilmaril@790
  3768
			if (selbi)	
insilmaril@390
  3769
			{
insilmaril@790
  3770
				// Take care of xlinks  
insilmaril@790
  3771
				branchXLinksContextMenuEdit->clear();
insilmaril@790
  3772
				if (selbi->xlinkCount()>0)
insilmaril@772
  3773
				{
insilmaril@790
  3774
					BranchItem *bi;
insilmaril@772
  3775
					QString s;
insilmaril@790
  3776
					for (int i=0; i<selbi->xlinkCount();++i)
insilmaril@772
  3777
					{
insilmaril@790
  3778
						bi=selbi->getXLinkNum(i)->getPartnerBranch();
insilmaril@790
  3779
						if (bi)
insilmaril@772
  3780
						{
insilmaril@790
  3781
							s=bi->getHeading();
insilmaril@772
  3782
							if (s.length()>xLinkMenuWidth)
insilmaril@772
  3783
								s=s.left(xLinkMenuWidth)+"...";
insilmaril@772
  3784
							branchXLinksContextMenuEdit->addAction (s);
insilmaril@772
  3785
						}	
insilmaril@772
  3786
					}
insilmaril@772
  3787
				}
insilmaril@772
  3788
				//Standard Flags
insilmaril@772
  3789
				standardFlagsMaster->updateToolBar (selbi->activeStandardFlagNames() );
insilmaril@772
  3790
insilmaril@772
  3791
				// System Flags
insilmaril@772
  3792
				actionToggleScroll->setEnabled (true);
insilmaril@772
  3793
				if ( selbi->isScrolled() )
insilmaril@802
  3794
					actionToggleScroll->setChecked(true);
insilmaril@772
  3795
				else	
insilmaril@802
  3796
					actionToggleScroll->setChecked(false);
insilmaril@772
  3797
insilmaril@772
  3798
				if ( selti->getURL().isEmpty() )
insilmaril@772
  3799
				{
insilmaril@772
  3800
					actionOpenURL->setEnabled (false);
insilmaril@772
  3801
					actionOpenURLTab->setEnabled (false);
insilmaril@772
  3802
				}	
insilmaril@772
  3803
				else	
insilmaril@772
  3804
				{
insilmaril@772
  3805
					actionOpenURL->setEnabled (true);
insilmaril@772
  3806
					actionOpenURLTab->setEnabled (true);
insilmaril@772
  3807
				}
insilmaril@772
  3808
				if ( selti->getVymLink().isEmpty() )
insilmaril@772
  3809
				{
insilmaril@772
  3810
					actionOpenVymLink->setEnabled (false);
insilmaril@772
  3811
					actionDeleteVymLink->setEnabled (false);
insilmaril@772
  3812
				} else	
insilmaril@772
  3813
				{
insilmaril@772
  3814
					actionOpenVymLink->setEnabled (true);
insilmaril@772
  3815
					actionDeleteVymLink->setEnabled (true);
insilmaril@772
  3816
				}	
insilmaril@772
  3817
insilmaril@772
  3818
				if (selbi->canMoveUp()) 
insilmaril@772
  3819
					actionMoveUp->setEnabled (true);
insilmaril@772
  3820
				else	
insilmaril@772
  3821
					actionMoveUp->setEnabled (false);
insilmaril@772
  3822
				if (selbi->canMoveDown()) 
insilmaril@772
  3823
					actionMoveDown->setEnabled (true);
insilmaril@772
  3824
				else	
insilmaril@772
  3825
					actionMoveDown->setEnabled (false);
insilmaril@772
  3826
insilmaril@772
  3827
				actionSortChildren->setEnabled (true);
insilmaril@822
  3828
				actionSortBackChildren->setEnabled (true);
insilmaril@772
  3829
insilmaril@772
  3830
				actionToggleHideExport->setEnabled (true);	
insilmaril@802
  3831
				actionToggleHideExport->setChecked (selbi->hideInExport() );	
insilmaril@772
  3832
insilmaril@772
  3833
				actionCopy->setEnabled (true);	
insilmaril@772
  3834
				actionCut->setEnabled (true);	
insilmaril@772
  3835
				if (!clipboardEmpty)
insilmaril@772
  3836
					actionPaste->setEnabled (true);	
insilmaril@772
  3837
				else	
insilmaril@772
  3838
					actionPaste->setEnabled (false);	
insilmaril@772
  3839
				for (int i=0; i<actionListBranches.size(); ++i)	
insilmaril@772
  3840
					actionListBranches.at(i)->setEnabled(true);
insilmaril@772
  3841
				actionDelete->setEnabled (true);
insilmaril@788
  3842
			}	// Branch
insilmaril@772
  3843
			if ( selti->getType()==TreeItem::Image)
insilmaril@390
  3844
			{
insilmaril@723
  3845
				actionOpenURL->setEnabled (false);
insilmaril@723
  3846
				actionOpenVymLink->setEnabled (false);
insilmaril@772
  3847
				actionDeleteVymLink->setEnabled (false);	
insilmaril@772
  3848
				actionToggleHideExport->setEnabled (true);	
insilmaril@802
  3849
				actionToggleHideExport->setChecked (selti->hideInExport() );	
insilmaril@772
  3850
insilmaril@772
  3851
insilmaril@772
  3852
				actionCopy->setEnabled (true);
insilmaril@772
  3853
				actionCut->setEnabled (true);	
insilmaril@772
  3854
				actionPaste->setEnabled (false);	//FIXME-4 why not allowing copy of images?
insilmaril@772
  3855
				for (int i=0; i<actionListBranches.size(); ++i)	
insilmaril@772
  3856
					actionListBranches.at(i)->setEnabled(false);
insilmaril@772
  3857
				actionDelete->setEnabled (true);
insilmaril@723
  3858
				actionMoveUp->setEnabled (false);
insilmaril@723
  3859
				actionMoveDown->setEnabled (false);
insilmaril@788
  3860
			}	// Image
insilmaril@772
  3861
insilmaril@772
  3862
		} else
insilmaril@772
  3863
		{	// !selti
insilmaril@772
  3864
			actionCopy->setEnabled (false);	
insilmaril@772
  3865
			actionCut->setEnabled (false);	
insilmaril@772
  3866
			actionPaste->setEnabled (false);	
insilmaril@406
  3867
			for (int i=0; i<actionListBranches.size(); ++i)	
insilmaril@772
  3868
				actionListBranches.at(i)->setEnabled(false);
insilmaril@772
  3869
insilmaril@772
  3870
			actionToggleScroll->setEnabled (false);
insilmaril@723
  3871
			actionOpenURL->setEnabled (false);
insilmaril@723
  3872
			actionOpenVymLink->setEnabled (false);
insilmaril@723
  3873
			actionDeleteVymLink->setEnabled (false);	
insilmaril@772
  3874
			actionHeading2URL->setEnabled (false);	
insilmaril@772
  3875
			actionDelete->setEnabled (false);
insilmaril@723
  3876
			actionMoveUp->setEnabled (false);
insilmaril@723
  3877
			actionMoveDown->setEnabled (false);
insilmaril@788
  3878
			actionFormatHideLinkUnselected->setEnabled (false);
insilmaril@772
  3879
			actionSortChildren->setEnabled (false);
insilmaril@822
  3880
			actionSortBackChildren->setEnabled (false);
insilmaril@772
  3881
			actionToggleHideExport->setEnabled (false);	
insilmaril@772
  3882
		}	
insilmaril@772
  3883
	} // m
insilmaril@390
  3884
}
insilmaril@390
  3885
insilmaril@473
  3886
Main::ModMode Main::getModMode()
insilmaril@390
  3887
{
insilmaril@390
  3888
	if (actionModModeColor->isOn()) return ModModeColor;
insilmaril@390
  3889
	if (actionModModeCopy->isOn()) return ModModeCopy;
insilmaril@390
  3890
	if (actionModModeXLink->isOn()) return ModModeXLink;
insilmaril@390
  3891
	return ModModeNone;
insilmaril@390
  3892
}
insilmaril@390
  3893
insilmaril@537
  3894
bool Main::autoEditNewBranch()
insilmaril@390
  3895
{
insilmaril@537
  3896
	return actionSettingsAutoEditNewBranch->isOn();
insilmaril@390
  3897
}
insilmaril@390
  3898
insilmaril@537
  3899
bool Main::autoSelectNewBranch()
insilmaril@390
  3900
{
insilmaril@537
  3901
	return actionSettingsAutoSelectNewBranch->isOn();
insilmaril@390
  3902
}
insilmaril@390
  3903
insilmaril@0
  3904
void Main::windowShowNoteEditor()
insilmaril@0
  3905
{
insilmaril@497
  3906
	textEditor->setShowWithMain(true);
insilmaril@0
  3907
	textEditor->show();
insilmaril@802
  3908
	actionViewToggleNoteEditor->setChecked (true);
insilmaril@0
  3909
}
insilmaril@0
  3910
insilmaril@0
  3911
void Main::windowHideNoteEditor()
insilmaril@0
  3912
{
insilmaril@497
  3913
	textEditor->setShowWithMain(false);
insilmaril@0
  3914
	textEditor->hide();
insilmaril@802
  3915
	actionViewToggleNoteEditor->setChecked (false);
insilmaril@0
  3916
}
insilmaril@0
  3917
insilmaril@434
  3918
void Main::setScript (const QString &script)
insilmaril@434
  3919
{
insilmaril@434
  3920
	scriptEditor->setScript (script);
insilmaril@434
  3921
}
insilmaril@434
  3922
insilmaril@434
  3923
void Main::runScript (const QString &script)
insilmaril@432
  3924
{
insilmaril@721
  3925
	VymModel *m=currentModel();
insilmaril@721
  3926
	if (m) m->runScript (script);
insilmaril@432
  3927
}
insilmaril@432
  3928
insilmaril@514
  3929
void Main::runScriptEverywhere (const QString &script)
insilmaril@514
  3930
{
insilmaril@514
  3931
	MapEditor *me;
insilmaril@514
  3932
	for (int i=0;i<=tabWidget->count() -1;i++)
insilmaril@514
  3933
	{
insilmaril@514
  3934
		me=(MapEditor*)tabWidget->page(i);
insilmaril@721
  3935
		if (me) me->getModel()->runScript (script);
insilmaril@514
  3936
	}	
insilmaril@514
  3937
}
insilmaril@514
  3938
insilmaril@0
  3939
void Main::windowNextEditor()
insilmaril@0
  3940
{
insilmaril@725
  3941
	if (tabWidget->currentIndex() < tabWidget->count())
insilmaril@725
  3942
		tabWidget->setCurrentIndex (tabWidget->currentIndex() +1);
insilmaril@0
  3943
}
insilmaril@0
  3944
insilmaril@0
  3945
void Main::windowPreviousEditor()
insilmaril@0
  3946
{
insilmaril@725
  3947
	if (tabWidget->currentIndex() >0)
insilmaril@725
  3948
		tabWidget->setCurrentIndex (tabWidget->currentIndex() -1);
insilmaril@0
  3949
}
insilmaril@0
  3950
insilmaril@0
  3951
void Main::standardFlagChanged()
insilmaril@0
  3952
{
insilmaril@766
  3953
	if (currentModel())
insilmaril@767
  3954
	{
insilmaril@767
  3955
		if ( actionSettingsUseFlagGroups->isOn() )
insilmaril@767
  3956
			currentModel()->toggleStandardFlag(sender()->name(),standardFlagsMaster);
insilmaril@767
  3957
		else	
insilmaril@767
  3958
			currentModel()->toggleStandardFlag(sender()->name());
insilmaril@770
  3959
		updateActions();	
insilmaril@767
  3960
	}
insilmaril@0
  3961
}
insilmaril@0
  3962
insilmaril@823
  3963
insilmaril@527
  3964
void Main::testFunction1()
insilmaril@0
  3965
{
insilmaril@841
  3966
/*
insilmaril@841
  3967
#include "attributeitem.h"
insilmaril@823
  3968
	VymModel *m=currentModel();
insilmaril@823
  3969
	if (!m) return;
insilmaril@823
  3970
insilmaril@823
  3971
	BranchItem *selbi=m->getSelectedBranch();
insilmaril@823
  3972
	if (selbi)
insilmaril@822
  3973
	{
insilmaril@823
  3974
		QList<QVariant> cData;
insilmaril@823
  3975
		cData << "new ai" << "undef";
insilmaril@823
  3976
insilmaril@823
  3977
		AttributeItem *ai=new AttributeItem (cData,selbi);
insilmaril@823
  3978
		ai->set ("Key 1","Val a",AttributeItem::FreeString);
insilmaril@823
  3979
insilmaril@823
  3980
		m->addAttribute (ai);
insilmaril@822
  3981
	}
insilmaril@821
  3982
	return;
insilmaril@841
  3983
*/
insilmaril@805
  3984
	if (!currentMapEditor()) return;
insilmaril@805
  3985
	currentMapEditor()->testFunction1();
insilmaril@527
  3986
}
insilmaril@527
  3987
insilmaril@527
  3988
void Main::testFunction2()
insilmaril@527
  3989
{
insilmaril@527
  3990
	if (!currentMapEditor()) return;
insilmaril@792
  3991
	currentMapEditor()->testFunction2();
insilmaril@0
  3992
}
insilmaril@0
  3993
insilmaril@393
  3994
void Main::testCommand()
insilmaril@393
  3995
{
insilmaril@393
  3996
	if (!currentMapEditor()) return;
insilmaril@432
  3997
	scriptEditor->show();
insilmaril@432
  3998
	/*
insilmaril@393
  3999
	bool ok;
insilmaril@393
  4000
	QString com = QInputDialog::getText(
insilmaril@404
  4001
			vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
insilmaril@393
  4002
	if (ok) currentMapEditor()->parseAtom(com);
insilmaril@432
  4003
	*/
insilmaril@393
  4004
}
insilmaril@393
  4005
insilmaril@0
  4006
void Main::helpDoc()
insilmaril@0
  4007
{
insilmaril@395
  4008
	QString locale = QLocale::system().name();
insilmaril@395
  4009
	QString docname;
insilmaril@395
  4010
	if (locale.left(2)=="es")
insilmaril@395
  4011
		docname="vym_es.pdf";
insilmaril@395
  4012
	else	
insilmaril@395
  4013
		docname="vym.pdf";
insilmaril@420
  4014
insilmaril@420
  4015
	QStringList searchList;
insilmaril@395
  4016
	QDir docdir;
insilmaril@103
  4017
	#if defined(Q_OS_MACX)
insilmaril@537
  4018
		searchList << "./vym.app/Contents/Resources/doc";
insilmaril@625
  4019
    #elif defined(Q_OS_WIN32)
insilmaril@625
  4020
        searchList << vymInstallDir.path() + "/share/doc/packages/vym";
insilmaril@103
  4021
	#else
insilmaril@608
  4022
		#if defined(VYM_DOCDIR)
insilmaril@608
  4023
			searchList << VYM_DOCDIR;
insilmaril@608
  4024
		#endif
insilmaril@103
  4025
		// default path in SUSE LINUX
insilmaril@625
  4026
		searchList << "/usr/share/doc/packages/vym";
insilmaril@103
  4027
	#endif
insilmaril@0
  4028
insilmaril@420
  4029
	searchList << "doc";	// relative path for easy testing in tarball
insilmaril@420
  4030
	searchList << "doc/tex";	// Easy testing working on vym.tex
insilmaril@420
  4031
	searchList << "/usr/share/doc/vym";	// Debian
insilmaril@420
  4032
	searchList << "/usr/share/doc/packages";// Knoppix
insilmaril@420
  4033
insilmaril@420
  4034
	bool found=false;
insilmaril@420
  4035
	QFile docfile;
insilmaril@420
  4036
	for (int i=0; i<searchList.count(); ++i)
insilmaril@0
  4037
	{
insilmaril@625
  4038
		docfile.setFileName(searchList.at(i)+"/"+docname);
insilmaril@625
  4039
		if (docfile.exists())
insilmaril@0
  4040
		{
insilmaril@420
  4041
			found=true;
insilmaril@420
  4042
			break;
insilmaril@420
  4043
		}	
insilmaril@0
  4044
	}
insilmaril@625
  4045
insilmaril@420
  4046
	if (!found)
insilmaril@420
  4047
	{
insilmaril@420
  4048
		QMessageBox::critical(0, 
insilmaril@420
  4049
			tr("Critcal error"),
insilmaril@420
  4050
			tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
insilmaril@420
  4051
		return;
insilmaril@420
  4052
	}	
insilmaril@420
  4053
insilmaril@408
  4054
	QStringList args;
insilmaril@0
  4055
	Process *pdfProc = new Process();
insilmaril@625
  4056
    args << QDir::toNativeSeparators(docfile.fileName());
insilmaril@420
  4057
insilmaril@804
  4058
	if (!pdfProc->startDetached( settings.value("/mainwindow/readerPDF").toString(),args) )
insilmaril@0
  4059
	{
insilmaril@0
  4060
		// error handling
insilmaril@266
  4061
		QMessageBox::warning(0, 
insilmaril@266
  4062
			tr("Warning"),
insilmaril@420
  4063
			tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
insilmaril@266
  4064
			tr("Please use Settings->")+tr("Set application to open PDF files"));
insilmaril@266
  4065
		settingsPDF();	
insilmaril@0
  4066
		return;
insilmaril@0
  4067
	}
insilmaril@0
  4068
}
insilmaril@0
  4069
insilmaril@0
  4070
insilmaril@505
  4071
void Main::helpDemo()
insilmaril@505
  4072
{
insilmaril@505
  4073
	QStringList filters;
insilmaril@505
  4074
	filters <<"VYM example map (*.vym)";
insilmaril@505
  4075
	QFileDialog *fd=new QFileDialog( this);
insilmaril@595
  4076
	#if defined(Q_OS_MACX)
insilmaril@595
  4077
		fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
insilmaril@595
  4078
	#else
insilmaril@595
  4079
		// default path in SUSE LINUX
insilmaril@595
  4080
		fd->setDir (QDir(vymBaseDir.path()+"/demos"));
insilmaril@595
  4081
	#endif
insilmaril@595
  4082
insilmaril@505
  4083
	fd->setFileMode (QFileDialog::ExistingFiles);
insilmaril@505
  4084
	fd->setFilters (filters);
insilmaril@505
  4085
	fd->setCaption(vymName+ " - " +tr("Load vym example map"));
insilmaril@505
  4086
	fd->show();
insilmaril@505
  4087
insilmaril@505
  4088
	QString fn;
insilmaril@505
  4089
	if ( fd->exec() == QDialog::Accepted )
insilmaril@505
  4090
	{
insilmaril@505
  4091
		lastFileDir=fd->directory().path();
insilmaril@505
  4092
	    QStringList flist = fd->selectedFiles();
insilmaril@505
  4093
		QStringList::Iterator it = flist.begin();
insilmaril@505
  4094
		while( it != flist.end() ) 
insilmaril@505
  4095
		{
insilmaril@505
  4096
			fn = *it;
insilmaril@505
  4097
			fileLoad(*it, NewMap);				   
insilmaril@505
  4098
			++it;
insilmaril@505
  4099
		}
insilmaril@505
  4100
	}
insilmaril@505
  4101
	delete (fd);
insilmaril@505
  4102
}
insilmaril@505
  4103
insilmaril@505
  4104
insilmaril@0
  4105
void Main::helpAbout()
insilmaril@0
  4106
{
insilmaril@148
  4107
	AboutDialog ad;
insilmaril@150
  4108
	ad.setName ("aboutwindow");
insilmaril@148
  4109
	ad.setMinimumSize(500,500);
insilmaril@148
  4110
	ad.resize (QSize (500,500));
insilmaril@148
  4111
	ad.exec();
insilmaril@0
  4112
}
insilmaril@0
  4113
insilmaril@0
  4114
void Main::helpAboutQT()
insilmaril@0
  4115
{
insilmaril@0
  4116
	QMessageBox::aboutQt( this, "Qt Application Example" );
insilmaril@0
  4117
}
insilmaril@0
  4118
insilmaril@445
  4119
void Main::callMacro ()
insilmaril@445
  4120
{
insilmaril@445
  4121
    QAction *action = qobject_cast<QAction *>(sender());
insilmaril@445
  4122
	int i=-1;
insilmaril@445
  4123
    if (action)
insilmaril@445
  4124
	{
insilmaril@445
  4125
        i=action->data().toInt();
insilmaril@447
  4126
		QString mDir (settings.value ("macros/macroDir").toString() );
insilmaril@447
  4127
insilmaril@447
  4128
		QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
insilmaril@447
  4129
		QFile f (fn);
insilmaril@447
  4130
		if ( !f.open( QIODevice::ReadOnly ) )
insilmaril@447
  4131
		{
insilmaril@447
  4132
			QMessageBox::warning(0, 
insilmaril@447
  4133
				tr("Warning"),
insilmaril@447
  4134
				tr("Couldn't find a macro at  %1.\n").arg(fn)+
insilmaril@447
  4135
				tr("Please use Settings->")+tr("Set directory for vym macros"));
insilmaril@447
  4136
			return;
insilmaril@447
  4137
		}	
insilmaril@447
  4138
insilmaril@447
  4139
		QTextStream ts( &f );
insilmaril@721
  4140
		QString macro= ts.read();
insilmaril@721
  4141
insilmaril@721
  4142
		if (! macro.isEmpty())
insilmaril@445
  4143
		{
insilmaril@721
  4144
			VymModel *m=currentModel();
insilmaril@721
  4145
			if (m) m->runScript(macro);
insilmaril@445
  4146
		}	
insilmaril@445
  4147
	}	
insilmaril@445
  4148
}
insilmaril@445
  4149