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