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