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