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