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