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