mainwindow.cpp
author insilmaril
Mon, 23 Jul 2007 12:42:02 +0000
changeset 566 ebebedffba50
parent 564 b8f0eefe4351
child 571 bc9083a4a7fb
permissions -rw-r--r--
Added import filter for Freemind
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@564
  1335
insilmaril@408
  1336
	fo->load(flagsPath+"flag-present.png");
insilmaril@564
  1337
	setupFlag (fo,tb,"present",tr("Surprise!","Standardflag"));
insilmaril@564
  1338
insilmaril@564
  1339
	fo->load(flagsPath+"flag-flash.png");
insilmaril@564
  1340
	setupFlag (fo,tb,"flash",tr("Dangerous","Standardflag"));
insilmaril@564
  1341
	
insilmaril@564
  1342
	// Original: xsldbg_output.png
insilmaril@564
  1343
	fo->load(flagsPath+"flag-info.png");
insilmaril@564
  1344
	setupFlag (fo,tb,"info",tr("Info","Standardflag"));
insilmaril@564
  1345
insilmaril@564
  1346
	// Original khelpcenter.png
insilmaril@564
  1347
	fo->load(flagsPath+"flag-lifebelt.png");
insilmaril@564
  1348
	setupFlag (fo,tb,"lifebelt",tr("This will help","Standardflag"));
insilmaril@564
  1349
insilmaril@564
  1350
	// Freemind flags
insilmaril@564
  1351
insilmaril@564
  1352
	fo->load(flagsPath+"freemind/warning.png");
insilmaril@564
  1353
	setupFlag (fo,tb,"freemind-warning",tr("Important","Freemind-Flag"));
insilmaril@564
  1354
insilmaril@564
  1355
	for (int i=1; i<8; i++)
insilmaril@564
  1356
	{
insilmaril@564
  1357
		fo->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
insilmaril@564
  1358
		setupFlag (fo,tb,QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
insilmaril@564
  1359
	}
insilmaril@564
  1360
insilmaril@564
  1361
	fo->load(flagsPath+"freemind/back.png");
insilmaril@564
  1362
	setupFlag (fo,tb,"freemind-back",tr("Back","Freemind-Flag"));
insilmaril@564
  1363
insilmaril@564
  1364
	fo->load(flagsPath+"freemind/forward.png");
insilmaril@564
  1365
	setupFlag (fo,tb,"freemind-forward",tr("Forward","Freemind-Flag"));
insilmaril@564
  1366
insilmaril@564
  1367
insilmaril@564
  1368
	fo->load(flagsPath+"freemind/attach.png");
insilmaril@564
  1369
	setupFlag (fo,tb,"freemind-attach",tr("Look here","Freemind-Flag"));
insilmaril@564
  1370
insilmaril@564
  1371
insilmaril@564
  1372
	fo->load(flagsPath+"freemind/clanbomber.png");
insilmaril@564
  1373
	setupFlag (fo,tb,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
insilmaril@564
  1374
insilmaril@564
  1375
insilmaril@564
  1376
	fo->load(flagsPath+"freemind/desktopnew.png");
insilmaril@564
  1377
	setupFlag (fo,tb,"freemind-desktopnew",tr("Don't forget","Freemind-Flag"));
insilmaril@564
  1378
insilmaril@564
  1379
insilmaril@564
  1380
	fo->load(flagsPath+"freemind/flag.png");
insilmaril@564
  1381
	setupFlag (fo,tb,"freemind-flag",tr("Flag","Freemind-Flag"));
insilmaril@564
  1382
insilmaril@564
  1383
insilmaril@564
  1384
	fo->load(flagsPath+"freemind/gohome.png");
insilmaril@564
  1385
	setupFlag (fo,tb,"freemind-gohome",tr("Home","Freemind-Flag"));
insilmaril@564
  1386
insilmaril@564
  1387
insilmaril@564
  1388
	fo->load(flagsPath+"freemind/kaddressbook.png");
insilmaril@564
  1389
	setupFlag (fo,tb,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
insilmaril@564
  1390
insilmaril@564
  1391
insilmaril@564
  1392
	fo->load(flagsPath+"freemind/knotify.png");
insilmaril@564
  1393
	setupFlag (fo,tb,"freemind-knotify",tr("Music","Freemind-Flag"));
insilmaril@564
  1394
insilmaril@564
  1395
insilmaril@564
  1396
	fo->load(flagsPath+"freemind/korn.png");
insilmaril@564
  1397
	setupFlag (fo,tb,"freemind-korn",tr("Mailbox","Freemind-Flag"));
insilmaril@564
  1398
insilmaril@564
  1399
insilmaril@564
  1400
	fo->load(flagsPath+"freemind/mail.png");
insilmaril@564
  1401
	setupFlag (fo,tb,"freemind-mail",tr("Maix","Freemind-Flag"));
insilmaril@564
  1402
insilmaril@564
  1403
	fo->load(flagsPath+"freemind/password.png");
insilmaril@564
  1404
	setupFlag (fo,tb,"freemind-password",tr("Password","Freemind-Flag"));
insilmaril@564
  1405
insilmaril@564
  1406
	fo->load(flagsPath+"freemind/pencil.png");
insilmaril@564
  1407
	setupFlag (fo,tb,"freemind-pencil",tr("To be improved","Freemind-Flag"));
insilmaril@564
  1408
insilmaril@564
  1409
	fo->load(flagsPath+"freemind/stop.png");
insilmaril@564
  1410
	setupFlag (fo,tb,"freemind-stop",tr("Stop","Freemind-Flag"));
insilmaril@564
  1411
insilmaril@564
  1412
	fo->load(flagsPath+"freemind/wizard.png");
insilmaril@564
  1413
	setupFlag (fo,tb,"freemind-wizard",tr("Magic","Freemind-Flag"));
insilmaril@564
  1414
insilmaril@564
  1415
	fo->load(flagsPath+"freemind/xmag.png");
insilmaril@564
  1416
	setupFlag (fo,tb,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
insilmaril@564
  1417
insilmaril@564
  1418
	fo->load(flagsPath+"freemind/bell.png");
insilmaril@564
  1419
	setupFlag (fo,tb,"freemind-bell",tr("Reminder","Freemind-Flag"));
insilmaril@564
  1420
insilmaril@564
  1421
	fo->load(flagsPath+"freemind/bookmark.png");
insilmaril@564
  1422
	setupFlag (fo,tb,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
insilmaril@564
  1423
insilmaril@564
  1424
	fo->load(flagsPath+"freemind/penguin.png");
insilmaril@564
  1425
	setupFlag (fo,tb,"freemind-penguin",tr("Linux","Freemind-Flag"));
insilmaril@564
  1426
insilmaril@564
  1427
	fo->load(flagsPath+"freemind/licq.png");
insilmaril@564
  1428
	setupFlag (fo,tb,"freemind-licq",tr("Sweet","Freemind-Flag"));
insilmaril@564
  1429
insilmaril@564
  1430
	delete (fo);
insilmaril@564
  1431
}
insilmaril@564
  1432
insilmaril@564
  1433
void Main::setupFlag (FlagObj *fo, QToolBar *tb, const QString &name, const QString &tooltip)
insilmaril@564
  1434
{
insilmaril@564
  1435
	fo->setName(name);
insilmaril@564
  1436
	QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
insilmaril@366
  1437
	tb->addAction (a);
insilmaril@366
  1438
	fo->setAction (a);
insilmaril@366
  1439
	a->setCheckable(true);
insilmaril@366
  1440
	a->setObjectName(fo->getName());
insilmaril@564
  1441
	a->setToolTip(tooltip);
insilmaril@366
  1442
	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
insilmaril@269
  1443
	standardFlagsDefault->addFlag (fo);	
insilmaril@0
  1444
}
insilmaril@528
  1445
// Network Actions
insilmaril@528
  1446
void Main::setupNetworkActions()
insilmaril@528
  1447
{
insilmaril@528
  1448
	if (!settings.value( "/mainwindow/showTestMenu",false).toBool() ) 
insilmaril@528
  1449
		return;
insilmaril@528
  1450
    QMenu *netMenu = menuBar()->addMenu(  "&Network" );
insilmaril@528
  1451
insilmaril@528
  1452
	QAction *a;
insilmaril@528
  1453
insilmaril@528
  1454
    a = new QAction(  "Start TCPserver for MapEditor",this);
insilmaril@528
  1455
    //a->setStatusTip ( "Set application to open pdf files"));
insilmaril@528
  1456
	a->setShortcut ( Qt::Key_T );		//New TCP server
insilmaril@528
  1457
    connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
insilmaril@528
  1458
	netMenu->addAction (a);
insilmaril@528
  1459
insilmaril@528
  1460
    a = new QAction(  "Connect MapEditor to server",this);
insilmaril@528
  1461
    //a->setStatusTip ( "Set application to open pdf files"));
insilmaril@528
  1462
	a->setShortcut ( Qt::Key_C );		// Connect to server
insilmaril@528
  1463
    connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
insilmaril@528
  1464
	netMenu->addAction (a);
insilmaril@528
  1465
}
insilmaril@528
  1466
	
insilmaril@0
  1467
// Settings Actions
insilmaril@0
  1468
void Main::setupSettingsActions()
insilmaril@0
  1469
{
insilmaril@366
  1470
    QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
insilmaril@0
  1471
insilmaril@0
  1472
	QAction *a;
insilmaril@0
  1473
insilmaril@395
  1474
    a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
insilmaril@366
  1475
    a->setStatusTip ( tr( "Set application to open pdf files"));
insilmaril@366
  1476
    connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
insilmaril@366
  1477
	settingsMenu->addAction (a);
insilmaril@366
  1478
insilmaril@395
  1479
    a = new QAction( tr( "Set application to open external links","Settings action"), this);
insilmaril@366
  1480
    a->setStatusTip( tr( "Set application to open external links"));
insilmaril@366
  1481
    connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
insilmaril@366
  1482
	settingsMenu->addAction (a);
insilmaril@366
  1483
insilmaril@473
  1484
    a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
insilmaril@450
  1485
    a->setStatusTip( tr( "Set path for macros"));
insilmaril@450
  1486
    connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
insilmaril@450
  1487
	settingsMenu->addAction (a);
insilmaril@450
  1488
insilmaril@473
  1489
    a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
insilmaril@473
  1490
    a->setStatusTip( tr( "Set number of undo levels"));
insilmaril@473
  1491
    connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
insilmaril@473
  1492
	settingsMenu->addAction (a);
insilmaril@473
  1493
insilmaril@366
  1494
	settingsMenu->addSeparator();
insilmaril@473
  1495
insilmaril@473
  1496
    a = new QAction( tr( "Autosave","Settings action"), this);
insilmaril@473
  1497
    a->setStatusTip( tr( "Autosave"));
insilmaril@473
  1498
	a->setToggleAction(true);
insilmaril@473
  1499
	a->setOn ( settings.value ("/mapeditor/autosave/use",true).toBool());
insilmaril@473
  1500
    connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
insilmaril@473
  1501
	settingsMenu->addAction (a);
insilmaril@473
  1502
	actionSettingsAutosaveToggle=a;
insilmaril@473
  1503
insilmaril@473
  1504
    a = new QAction( tr( "Autosave time","Settings action")+"...", this);
insilmaril@473
  1505
    a->setStatusTip( tr( "Autosave time"));
insilmaril@473
  1506
    connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
insilmaril@473
  1507
	settingsMenu->addAction (a);
insilmaril@473
  1508
	actionSettingsAutosaveTime=a;
insilmaril@473
  1509
insilmaril@473
  1510
	settingsMenu->addSeparator();
insilmaril@473
  1511
insilmaril@395
  1512
    a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
insilmaril@366
  1513
    a->setStatusTip( tr( "Edit branch after adding it" ));
insilmaril@0
  1514
	a->setToggleAction(true);
insilmaril@537
  1515
	a->setOn ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
insilmaril@366
  1516
	settingsMenu->addAction (a);
insilmaril@537
  1517
	actionSettingsAutoEditNewBranch=a;
insilmaril@0
  1518
insilmaril@395
  1519
    a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
insilmaril@366
  1520
    a->setStatusTip( tr( "Select branch after adding it" ));
insilmaril@0
  1521
	a->setToggleAction(true);
insilmaril@537
  1522
	a->setOn ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
insilmaril@366
  1523
	settingsMenu->addAction (a);
insilmaril@537
  1524
	actionSettingsAutoSelectNewBranch=a;
insilmaril@0
  1525
	
insilmaril@395
  1526
    a= new QAction(tr( "Select existing heading","Settings action" ), this);
insilmaril@366
  1527
    a->setStatusTip( tr( "Select heading before editing" ));
insilmaril@0
  1528
	a->setToggleAction(true);
insilmaril@366
  1529
	a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
insilmaril@366
  1530
	settingsMenu->addAction (a);
insilmaril@390
  1531
	actionSettingsAutoSelectText=a;
insilmaril@0
  1532
	
insilmaril@395
  1533
    a= new QAction( tr( "Delete key","Settings action" ), this);
insilmaril@366
  1534
    a->setStatusTip( tr( "Delete key for deleting branches" ));
insilmaril@0
  1535
	a->setToggleAction(true);
insilmaril@505
  1536
	a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
insilmaril@366
  1537
	settingsMenu->addAction (a);
insilmaril@366
  1538
    connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
insilmaril@366
  1539
	actionSettingsUseDelKey=a;
insilmaril@366
  1540
insilmaril@395
  1541
    a= new QAction( tr( "Exclusive flags","Settings action" ), this);
insilmaril@366
  1542
    a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
insilmaril@0
  1543
	a->setToggleAction(true);
insilmaril@366
  1544
	a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
insilmaril@366
  1545
	settingsMenu->addAction (a);
insilmaril@103
  1546
	actionSettingsUseFlagGroups=a;
insilmaril@260
  1547
	
insilmaril@395
  1548
    a= new QAction( tr( "Use hide flags","Settings action" ), this);
insilmaril@366
  1549
    a->setStatusTip( tr( "Use hide flag during exports " ));
insilmaril@260
  1550
	a->setToggleAction(true);
insilmaril@366
  1551
	a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
insilmaril@366
  1552
	settingsMenu->addAction (a);
insilmaril@260
  1553
	actionSettingsUseHideExport=a;
insilmaril@0
  1554
}
insilmaril@0
  1555
insilmaril@0
  1556
// Test Actions
insilmaril@0
  1557
void Main::setupTestActions()
insilmaril@0
  1558
{
insilmaril@366
  1559
    QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
insilmaril@0
  1560
insilmaril@0
  1561
    QAction *a;
insilmaril@527
  1562
    a = new QAction( "Test function 1" , this);
insilmaril@527
  1563
    a->setStatusTip( "Call test function 1" );
insilmaril@527
  1564
	testMenu->addAction (a);
insilmaril@445
  1565
	//a->setShortcut (Qt::Key_F4 );
insilmaril@527
  1566
    connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
insilmaril@527
  1567
insilmaril@527
  1568
    a = new QAction( "Test function 2" , this);
insilmaril@527
  1569
    a->setStatusTip( "Call test function 2" );
insilmaril@527
  1570
	//a->setShortcut (Qt::Key_F4 );
insilmaril@366
  1571
	testMenu->addAction (a);
insilmaril@527
  1572
    connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
insilmaril@527
  1573
insilmaril@395
  1574
    a = new QAction( "Command" , this);
insilmaril@395
  1575
    a->setStatusTip( "Enter command to call in editor" );
insilmaril@445
  1576
	//a->setShortcut (Qt::Key_F5 );
insilmaril@393
  1577
    connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
insilmaril@393
  1578
	testMenu->addAction (a);
insilmaril@0
  1579
}
insilmaril@0
  1580
insilmaril@0
  1581
// Help Actions
insilmaril@0
  1582
void Main::setupHelpActions()
insilmaril@0
  1583
{
insilmaril@395
  1584
    QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
insilmaril@0
  1585
insilmaril@0
  1586
    QAction *a;
insilmaril@395
  1587
    a = new QAction(  tr( "Open VYM Documentation (pdf) ","Help action" ), this );
insilmaril@366
  1588
    a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
insilmaril@366
  1589
    connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
insilmaril@366
  1590
	helpMenu->addAction (a);
insilmaril@366
  1591
insilmaril@505
  1592
    a = new QAction(  tr( "Open VYM example maps ","Help action" ), this );
insilmaril@505
  1593
    a->setStatusTip( tr( "Open VYM example maps " ));
insilmaril@505
  1594
    connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
insilmaril@505
  1595
	helpMenu->addAction (a);
insilmaril@505
  1596
insilmaril@395
  1597
    a = new QAction( tr( "About VYM","Help action" ), this);
insilmaril@404
  1598
    a->setStatusTip( tr( "About VYM")+vymName);
insilmaril@366
  1599
    connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
insilmaril@366
  1600
	helpMenu->addAction (a);
insilmaril@366
  1601
insilmaril@395
  1602
    a = new QAction( tr( "About QT","Help action" ), this);
insilmaril@366
  1603
    a->setStatusTip( tr( "Information about QT toolkit" ));
insilmaril@366
  1604
    connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
insilmaril@366
  1605
	helpMenu->addAction (a);
insilmaril@0
  1606
}
insilmaril@0
  1607
insilmaril@0
  1608
// Context Menus
insilmaril@0
  1609
void Main::setupContextMenus()
insilmaril@0
  1610
{
insilmaril@0
  1611
	QAction*a;
insilmaril@0
  1612
insilmaril@0
  1613
	// Context Menu for branch or mapcenter
insilmaril@366
  1614
	branchContextMenu =new QMenu (this);
insilmaril@486
  1615
	branchContextMenu->addAction (actionViewTogglePropertyWindow);
insilmaril@421
  1616
	branchContextMenu->addSeparator();	
insilmaril@421
  1617
insilmaril@98
  1618
		// Submenu "Add"
insilmaril@366
  1619
		branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
insilmaril@366
  1620
		branchAddContextMenu->addAction (actionEditPaste );
insilmaril@366
  1621
		branchAddContextMenu->addAction ( actionEditAddBranch );
insilmaril@394
  1622
		branchAddContextMenu->addAction ( actionEditAddBranchBefore );
insilmaril@366
  1623
		branchAddContextMenu->addAction ( actionEditAddBranchAbove);
insilmaril@366
  1624
		branchAddContextMenu->addAction ( actionEditAddBranchBelow );
insilmaril@366
  1625
		branchAddContextMenu->addSeparator();	
insilmaril@366
  1626
		branchAddContextMenu->addAction ( actionEditImportAdd );
insilmaril@366
  1627
		branchAddContextMenu->addAction ( actionEditImportReplace );
insilmaril@98
  1628
insilmaril@98
  1629
		// Submenu "Remove"
insilmaril@395
  1630
		branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
insilmaril@366
  1631
		branchRemoveContextMenu->addAction (actionEditCut);
insilmaril@366
  1632
		branchRemoveContextMenu->addAction ( actionEditDelete );
insilmaril@395
  1633
		branchRemoveContextMenu->addAction ( actionEditDeleteKeepChilds );
insilmaril@395
  1634
		branchRemoveContextMenu->addAction ( actionEditDeleteChilds );
insilmaril@98
  1635
		
insilmaril@98
  1636
insilmaril@0
  1637
	actionEditSaveBranch->addTo( branchContextMenu );
insilmaril@98
  1638
insilmaril@366
  1639
	branchContextMenu->addSeparator();	
insilmaril@398
  1640
	branchContextMenu->addAction ( actionEditLoadImage);
insilmaril@366
  1641
insilmaril@366
  1642
	// Submenu for Links (URLs, vymLinks)
insilmaril@366
  1643
	branchLinksContextMenu =new QMenu (this);
insilmaril@366
  1644
insilmaril@366
  1645
		branchContextMenu->addSeparator();	
insilmaril@473
  1646
		branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));	
insilmaril@366
  1647
		branchLinksContextMenu->addAction ( actionEditOpenURL );
insilmaril@366
  1648
		branchLinksContextMenu->addAction ( actionEditOpenURLTab );
insilmaril@366
  1649
		branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
insilmaril@366
  1650
		branchLinksContextMenu->addAction ( actionEditURL );
insilmaril@366
  1651
		branchLinksContextMenu->addAction ( actionEditHeading2URL );
insilmaril@366
  1652
		branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
insilmaril@528
  1653
		if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
insilmaril@366
  1654
		{
insilmaril@366
  1655
			branchLinksContextMenu->addAction ( actionEditFATE2URL );
insilmaril@366
  1656
		}	
insilmaril@366
  1657
		branchLinksContextMenu->addSeparator();	
insilmaril@366
  1658
		branchLinksContextMenu->addAction ( actionEditOpenVymLink );
insilmaril@366
  1659
		branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
insilmaril@366
  1660
		branchLinksContextMenu->addAction ( actionEditVymLink );
insilmaril@366
  1661
		branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
insilmaril@366
  1662
		
insilmaril@366
  1663
insilmaril@366
  1664
	// Context Menu for XLinks in a branch menu
insilmaril@89
  1665
	// This will be populated "on demand" in MapEditor::updateActions
insilmaril@366
  1666
	branchContextMenu->addSeparator();	
insilmaril@395
  1667
	branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
insilmaril@395
  1668
	branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
insilmaril@366
  1669
	connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
insilmaril@366
  1670
	connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
insilmaril@366
  1671
 	
insilmaril@105
  1672
	
insilmaril@0
  1673
	// Context menu for floatimage
insilmaril@366
  1674
	floatimageContextMenu =new QMenu (this);
insilmaril@395
  1675
	a= new QAction (tr ("Save image","Context action"),this);
insilmaril@366
  1676
	connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
insilmaril@366
  1677
	floatimageContextMenu->addAction (a);
insilmaril@366
  1678
insilmaril@366
  1679
	floatimageContextMenu->addSeparator();	
insilmaril@0
  1680
	actionEditCopy->addTo( floatimageContextMenu );
insilmaril@0
  1681
	actionEditCut->addTo( floatimageContextMenu );
insilmaril@0
  1682
insilmaril@366
  1683
	floatimageContextMenu->addSeparator();	
insilmaril@366
  1684
	floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
insilmaril@366
  1685
insilmaril@0
  1686
	
insilmaril@0
  1687
	// Context menu for canvas
insilmaril@366
  1688
	canvasContextMenu =new QMenu (this);
insilmaril@0
  1689
	actionEditMapInfo->addTo( canvasContextMenu );
insilmaril@0
  1690
	canvasContextMenu->insertSeparator();	
insilmaril@0
  1691
	actionGroupFormatLinkStyles->addTo( canvasContextMenu );
insilmaril@0
  1692
	canvasContextMenu->insertSeparator();	
insilmaril@0
  1693
	actionFormatLinkColorHint->addTo( canvasContextMenu );
insilmaril@0
  1694
	actionFormatLinkColor->addTo( canvasContextMenu );
insilmaril@442
  1695
	actionFormatSelectionColor->addTo( canvasContextMenu );
insilmaril@0
  1696
	actionFormatBackColor->addTo( canvasContextMenu );
insilmaril@505
  1697
	// actionFormatBackImage->addTo( canvasContextMenu );  //FIXME makes vym too slow: postponed for later version 
insilmaril@0
  1698
insilmaril@0
  1699
	// Menu for last opened files
insilmaril@401
  1700
	// Create actions
insilmaril@401
  1701
	for (int i = 0; i < MaxRecentFiles; ++i) 
insilmaril@0
  1702
	{
insilmaril@445
  1703
        recentFileActions[i] = new QAction(this);
insilmaril@445
  1704
        recentFileActions[i]->setVisible(false);
insilmaril@445
  1705
        fileLastMapsMenu->addAction(recentFileActions[i]);
insilmaril@445
  1706
        connect(recentFileActions[i], SIGNAL(triggered()),
insilmaril@401
  1707
                this, SLOT(fileLoadRecent()));
insilmaril@401
  1708
    }
insilmaril@401
  1709
	setupRecentMapsMenu();
insilmaril@0
  1710
}
insilmaril@0
  1711
insilmaril@401
  1712
void Main::setupRecentMapsMenu()
insilmaril@0
  1713
{
insilmaril@401
  1714
    QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
insilmaril@401
  1715
insilmaril@401
  1716
    int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
insilmaril@401
  1717
insilmaril@401
  1718
    for (int i = 0; i < numRecentFiles; ++i) {
insilmaril@401
  1719
        QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
insilmaril@445
  1720
        recentFileActions[i]->setText(text);
insilmaril@445
  1721
        recentFileActions[i]->setData(files[i]);
insilmaril@445
  1722
        recentFileActions[i]->setVisible(true);
insilmaril@401
  1723
    }
insilmaril@401
  1724
    for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
insilmaril@445
  1725
        recentFileActions[j]->setVisible(false);
insilmaril@445
  1726
}
insilmaril@445
  1727
insilmaril@445
  1728
void Main::setupMacros()
insilmaril@445
  1729
{
insilmaril@445
  1730
    for (int i = 0; i <= 11; i++) 
insilmaril@445
  1731
	{
insilmaril@445
  1732
        macroActions[i] = new QAction(this);
insilmaril@445
  1733
        macroActions[i]->setData(i);
insilmaril@445
  1734
        addAction (macroActions[i]);
insilmaril@445
  1735
        connect(macroActions[i], SIGNAL(triggered()),
insilmaril@445
  1736
                this, SLOT(callMacro()));
insilmaril@445
  1737
	}			
insilmaril@445
  1738
	macroActions[0]->setShortcut ( Qt::Key_F1 );
insilmaril@445
  1739
	macroActions[1]->setShortcut ( Qt::Key_F2 );
insilmaril@445
  1740
	macroActions[2]->setShortcut ( Qt::Key_F3 );
insilmaril@445
  1741
	macroActions[3]->setShortcut ( Qt::Key_F4 );
insilmaril@445
  1742
	macroActions[4]->setShortcut ( Qt::Key_F5 );
insilmaril@445
  1743
	macroActions[5]->setShortcut ( Qt::Key_F6 );
insilmaril@445
  1744
	macroActions[6]->setShortcut ( Qt::Key_F7 );
insilmaril@445
  1745
	macroActions[7]->setShortcut ( Qt::Key_F8 );
insilmaril@445
  1746
	macroActions[8]->setShortcut ( Qt::Key_F9 );
insilmaril@445
  1747
	macroActions[9]->setShortcut ( Qt::Key_F10 );
insilmaril@445
  1748
	macroActions[10]->setShortcut ( Qt::Key_F11 );
insilmaril@445
  1749
	macroActions[11]->setShortcut ( Qt::Key_F12 );
insilmaril@0
  1750
}
insilmaril@0
  1751
insilmaril@0
  1752
void Main::hideEvent (QHideEvent * )
insilmaril@0
  1753
{
insilmaril@0
  1754
	if (!textEditor->isMinimized() ) textEditor->hide();
insilmaril@0
  1755
}
insilmaril@0
  1756
insilmaril@0
  1757
void Main::showEvent (QShowEvent * )
insilmaril@0
  1758
{
insilmaril@491
  1759
	if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
insilmaril@0
  1760
}
insilmaril@0
  1761
insilmaril@0
  1762
insilmaril@0
  1763
MapEditor* Main::currentMapEditor() const
insilmaril@0
  1764
{
insilmaril@0
  1765
    if ( tabWidget->currentPage() &&
insilmaril@0
  1766
	 tabWidget->currentPage()->inherits( "MapEditor" ) )
insilmaril@0
  1767
		return (MapEditor*)tabWidget->currentPage();
insilmaril@0
  1768
    return NULL;	
insilmaril@0
  1769
}
insilmaril@0
  1770
insilmaril@0
  1771
insilmaril@0
  1772
void Main::editorChanged(QWidget *)
insilmaril@0
  1773
{
insilmaril@0
  1774
	// Unselect all possibly selected objects
insilmaril@0
  1775
	// (Important to update note editor)
insilmaril@0
  1776
	MapEditor *me;
insilmaril@473
  1777
	for (int i=0;i<=tabWidget->count() -1;i++)
insilmaril@0
  1778
	{
insilmaril@0
  1779
		
insilmaril@0
  1780
		me=(MapEditor*)tabWidget->page(i);
insilmaril@0
  1781
		me->unselect();
insilmaril@0
  1782
	}	
insilmaril@0
  1783
	currentMapEditor()->reselect();
insilmaril@0
  1784
insilmaril@0
  1785
	// Update actions to in menus and toolbars according to editor
insilmaril@407
  1786
	updateActions();
insilmaril@0
  1787
}
insilmaril@0
  1788
insilmaril@0
  1789
void Main::fileNew()
insilmaril@0
  1790
{
insilmaril@0
  1791
	QString fn="unnamed";
insilmaril@408
  1792
	MapEditor* me = new MapEditor ( NULL);
insilmaril@408
  1793
	tabWidget->addTab (me,fn);
insilmaril@408
  1794
	tabWidget->showPage(me);
insilmaril@408
  1795
	me->viewport()->setFocus();
insilmaril@408
  1796
	me->setAntiAlias (actionViewToggleAntiAlias->isOn());
insilmaril@408
  1797
	me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
insilmaril@408
  1798
	
insilmaril@366
  1799
	// For the very first map we do not have flagrows yet...
insilmaril@408
  1800
	me->select("mc:");
insilmaril@0
  1801
}
insilmaril@0
  1802
insilmaril@491
  1803
void Main::fileNewCopy()
insilmaril@491
  1804
{
insilmaril@491
  1805
	QString fn="unnamed";
insilmaril@491
  1806
	MapEditor* oldME =currentMapEditor();
insilmaril@491
  1807
	if (oldME)
insilmaril@491
  1808
	{
insilmaril@491
  1809
		oldME->copy();
insilmaril@491
  1810
		MapEditor* newME = new MapEditor ( NULL);
insilmaril@491
  1811
		if (newME)
insilmaril@491
  1812
		{
insilmaril@491
  1813
			tabWidget->addTab (newME,fn);
insilmaril@491
  1814
			tabWidget->showPage(newME);
insilmaril@491
  1815
			newME->viewport()->setFocus();
insilmaril@491
  1816
			newME->setAntiAlias (actionViewToggleAntiAlias->isOn());
insilmaril@491
  1817
			newME->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
insilmaril@491
  1818
			// For the very first map we do not have flagrows yet...
insilmaril@491
  1819
			newME->select("mc:");
insilmaril@491
  1820
			newME->load (clipboardDir+"/"+clipboardFile,ImportReplace);
insilmaril@491
  1821
		}
insilmaril@491
  1822
insilmaril@491
  1823
	}
insilmaril@491
  1824
}
insilmaril@491
  1825
insilmaril@205
  1826
ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
insilmaril@0
  1827
{
insilmaril@205
  1828
	ErrorCode err=success;
insilmaril@0
  1829
	
insilmaril@0
  1830
	// fn is usually the archive, mapfile the file after uncompressing
insilmaril@0
  1831
	QString mapfile;
insilmaril@0
  1832
insilmaril@0
  1833
	// Make fn absolute (needed for unzip)
insilmaril@0
  1834
	fn=QDir (fn).absPath();
insilmaril@0
  1835
insilmaril@0
  1836
	MapEditor *me;
insilmaril@0
  1837
insilmaril@0
  1838
	if (lmode==NewMap)
insilmaril@0
  1839
	{
insilmaril@0
  1840
		// Check, if map is already loaded
insilmaril@0
  1841
		int i=0;
insilmaril@0
  1842
		while (i<=tabWidget->count() -1)
insilmaril@0
  1843
		{
insilmaril@0
  1844
			me=(MapEditor*)tabWidget->page(i);
insilmaril@0
  1845
			if (me->getFilePath() == fn)
insilmaril@0
  1846
			{
insilmaril@0
  1847
				// Already there, ask for confirmation
insilmaril@404
  1848
				QMessageBox mb( vymName,
insilmaril@159
  1849
					tr("The map %1\nis already opened."
insilmaril@0
  1850
					"Opening the same map in multiple editors may lead \n"
insilmaril@0
  1851
					"to confusion when finishing working with vym."
insilmaril@159
  1852
					"Do you want to").arg(fn),
insilmaril@0
  1853
					QMessageBox::Warning,
insilmaril@0
  1854
					QMessageBox::Yes | QMessageBox::Default,
insilmaril@0
  1855
					QMessageBox::Cancel | QMessageBox::Escape,
insilmaril@366
  1856
					QMessageBox::NoButton);
insilmaril@0
  1857
				mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
insilmaril@0
  1858
				mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
insilmaril@0
  1859
				switch( mb.exec() ) 
insilmaril@0
  1860
				{
insilmaril@0
  1861
					case QMessageBox::Yes:
insilmaril@0
  1862
						// load anyway
insilmaril@0
  1863
						i=tabWidget->count();
insilmaril@0
  1864
						break;
insilmaril@0
  1865
					case QMessageBox::Cancel:
insilmaril@0
  1866
						// do nothing
insilmaril@205
  1867
						return aborted;
insilmaril@0
  1868
						break;
insilmaril@0
  1869
				}
insilmaril@0
  1870
			}
insilmaril@0
  1871
			i++;
insilmaril@0
  1872
		}
insilmaril@0
  1873
	}
insilmaril@0
  1874
insilmaril@0
  1875
insilmaril@0
  1876
	// Try to load map
insilmaril@0
  1877
    if ( !fn.isEmpty() )
insilmaril@0
  1878
	{
insilmaril@0
  1879
		me = currentMapEditor();
insilmaril@0
  1880
		int tabIndex=tabWidget->currentPageIndex();
insilmaril@0
  1881
		// Check first, if mapeditor exists
insilmaril@0
  1882
		// If it is not default AND we want a new map, 
insilmaril@0
  1883
		// create a new mapeditor in a new tab
insilmaril@0
  1884
		if ( lmode==NewMap && (!me || !me->isDefault() ) )
insilmaril@0
  1885
		{
insilmaril@390
  1886
			me= new MapEditor ( NULL);
insilmaril@0
  1887
			tabWidget->addTab (me,fn);
insilmaril@0
  1888
			tabIndex=tabWidget->indexOf (me);
insilmaril@0
  1889
			tabWidget->setCurrentPage (tabIndex);
insilmaril@408
  1890
			me->setAntiAlias (actionViewToggleAntiAlias->isOn());
insilmaril@408
  1891
			me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
insilmaril@0
  1892
		}
insilmaril@0
  1893
		
insilmaril@0
  1894
		// Check, if file exists (important for creating new files
insilmaril@0
  1895
		// from command line
insilmaril@0
  1896
		if (!QFile(fn).exists() )
insilmaril@0
  1897
		{
insilmaril@404
  1898
			QMessageBox mb( vymName,
insilmaril@159
  1899
				tr("This map does not exist:\n  %1\nDo you want to create a new one?").arg(fn),
insilmaril@0
  1900
				QMessageBox::Question,
insilmaril@0
  1901
				QMessageBox::Yes ,
insilmaril@0
  1902
				QMessageBox::Cancel | QMessageBox::Default,
insilmaril@366
  1903
				QMessageBox::NoButton );
insilmaril@0
  1904
insilmaril@0
  1905
			mb.setButtonText( QMessageBox::Yes, tr("Create"));
insilmaril@0
  1906
			mb.setButtonText( QMessageBox::No, tr("Cancel"));
insilmaril@0
  1907
			switch( mb.exec() ) 
insilmaril@0
  1908
			{
insilmaril@0
  1909
				case QMessageBox::Yes:
insilmaril@0
  1910
					// Create new map
insilmaril@0
  1911
					currentMapEditor()->setFilePath(fn);
insilmaril@0
  1912
					tabWidget->setTabLabel (currentMapEditor(),
insilmaril@0
  1913
						currentMapEditor()->getFileName() );
insilmaril@0
  1914
					statusBar()->message( "Created " + fn , statusbarTime );
insilmaril@205
  1915
					return success;
insilmaril@0
  1916
						
insilmaril@0
  1917
				case QMessageBox::Cancel:
insilmaril@0
  1918
					// don't create new map
insilmaril@0
  1919
					statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
insilmaril@0
  1920
					fileCloseMap();
insilmaril@205
  1921
					return aborted;
insilmaril@0
  1922
			}
insilmaril@0
  1923
		}	
insilmaril@0
  1924
insilmaril@0
  1925
insilmaril@0
  1926
		//tabWidget->currentPage() won't be NULL here, because of above...
insilmaril@0
  1927
		tabWidget->showPage(me);
insilmaril@0
  1928
		me->viewport()->setFocus();
insilmaril@0
  1929
insilmaril@0
  1930
		// Create temporary directory for packing
insilmaril@377
  1931
		bool ok;
insilmaril@377
  1932
		QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
insilmaril@377
  1933
		if (!ok)
insilmaril@377
  1934
		{
insilmaril@377
  1935
			QMessageBox::critical( 0, tr( "Critical Load Error" ),
insilmaril@377
  1936
			   tr("Couldn't create temporary directory before load\n"));
insilmaril@377
  1937
			return aborted; 
insilmaril@377
  1938
		}
insilmaril@0
  1939
insilmaril@0
  1940
		// Try to unzip file
insilmaril@185
  1941
		err=unzipDir (tmpMapDir,fn);
insilmaril@185
  1942
		if (err==nozip)
insilmaril@0
  1943
		{
insilmaril@185
  1944
			mapfile=fn;
insilmaril@185
  1945
			me->setZipped(false);
insilmaril@0
  1946
		} else
insilmaril@0
  1947
		{
insilmaril@185
  1948
			me->setZipped(true);
insilmaril@185
  1949
			
insilmaril@185
  1950
			// Look for mapname.xml
insilmaril@185
  1951
			mapfile= fn.left(fn.findRev(".",-1,true));
insilmaril@185
  1952
			mapfile=mapfile.section( '/', -1 );
insilmaril@185
  1953
			QFile file( tmpMapDir + "/" + mapfile + ".xml");
insilmaril@185
  1954
			if (!file.exists() )
insilmaril@0
  1955
			{
insilmaril@185
  1956
				// mapname.xml does not exist, well, 
insilmaril@428
  1957
				// maybe someone renamed the mapname.vym file...
insilmaril@185
  1958
				// Try to find any .xml in the toplevel 
insilmaril@185
  1959
				// directory of the .vym file
insilmaril@185
  1960
				QStringList flist=QDir (tmpMapDir).entryList("*.xml");
insilmaril@185
  1961
				if (flist.count()==1) 
insilmaril@0
  1962
				{
insilmaril@185
  1963
					// Only one entry, take this one
insilmaril@185
  1964
					mapfile=tmpMapDir + "/"+flist.first();
insilmaril@0
  1965
				} else
insilmaril@185
  1966
				{
insilmaril@185
  1967
					for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it ) 
insilmaril@185
  1968
						*it=tmpMapDir + "/" + *it;
insilmaril@185
  1969
					// TODO Multiple entries, load all (but only the first one into this ME)
insilmaril@185
  1970
					//mainWindow->fileLoadFromTmp (flist);
insilmaril@185
  1971
					//returnCode=1;	// Silently forget this attempt to load
insilmaril@185
  1972
					qWarning ("MainWindow::load (fn)  multimap found...");
insilmaril@185
  1973
				}	
insilmaril@0
  1974
					
insilmaril@185
  1975
				if (flist.isEmpty() )
insilmaril@185
  1976
				{
insilmaril@185
  1977
					QMessageBox::critical( 0, tr( "Critical Load Error" ),
insilmaril@185
  1978
							   tr("Couldn't find a map (*.xml) in .vym archive.\n"));
insilmaril@185
  1979
					err=aborted;				   
insilmaril@185
  1980
				}	
insilmaril@185
  1981
			} //file doesn't exist	
insilmaril@185
  1982
			else
insilmaril@185
  1983
				mapfile=file.name();
insilmaril@0
  1984
		}
insilmaril@0
  1985
insilmaril@185
  1986
		if (err!=aborted)
insilmaril@185
  1987
		{
insilmaril@185
  1988
			// Save existing filename in case  we import
insilmaril@185
  1989
			QString fn_org=me->getFilePath();
insilmaril@106
  1990
insilmaril@185
  1991
			// Finally load map into mapEditor
insilmaril@185
  1992
			me->setFilePath (mapfile,fn);
insilmaril@205
  1993
			err=me->load(mapfile,lmode);
insilmaril@106
  1994
insilmaril@185
  1995
			// Restore old (maybe empty) filepath, if this is an import
insilmaril@185
  1996
			if (lmode!=NewMap)
insilmaril@185
  1997
				me->setFilePath (fn_org);
insilmaril@185
  1998
		}	
insilmaril@0
  1999
insilmaril@185
  2000
		// Finally check for errors and go home
insilmaril@185
  2001
		if (err==aborted) 
insilmaril@185
  2002
		{
insilmaril@185
  2003
			if (lmode==NewMap) fileCloseMap();
insilmaril@185
  2004
			statusBar()->message( "Could not load " + fn, statusbarTime );
insilmaril@185
  2005
		} else 
insilmaril@0
  2006
		{
insilmaril@0
  2007
			if (lmode==NewMap)
insilmaril@0
  2008
			{
insilmaril@0
  2009
				me->setFilePath (fn);
insilmaril@0
  2010
				tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
insilmaril@205
  2011
				if (fn.left(9)!="/tmp/vym-")
insilmaril@205
  2012
				{
insilmaril@205
  2013
					// Only append to lastMaps if not loaded from a tmpDir
insilmaril@205
  2014
					// e.g. imported bookmarks are in a tmpDir
insilmaril@401
  2015
					addRecentMap(me->getFilePath() );
insilmaril@205
  2016
				}
insilmaril@0
  2017
				actionFilePrint->setEnabled (true);
insilmaril@0
  2018
			}	
insilmaril@0
  2019
			statusBar()->message( "Loaded " + fn, statusbarTime );
insilmaril@0
  2020
		}	
insilmaril@0
  2021
insilmaril@185
  2022
		// Delete tmpDir
insilmaril@185
  2023
		removeDir (QDir(tmpMapDir));
insilmaril@0
  2024
	}
insilmaril@205
  2025
	return err;
insilmaril@0
  2026
}
insilmaril@0
  2027
insilmaril@0
  2028
insilmaril@0
  2029
void Main::fileLoad(const LoadMode &lmode)
insilmaril@0
  2030
{
insilmaril@377
  2031
	QStringList filters;
insilmaril@389
  2032
	filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
insilmaril@377
  2033
	QFileDialog *fd=new QFileDialog( this);
insilmaril@366
  2034
	fd->setDir (lastFileDir);
insilmaril@377
  2035
	fd->setFileMode (QFileDialog::ExistingFiles);
insilmaril@377
  2036
	fd->setFilters (filters);
insilmaril@0
  2037
	switch (lmode)
insilmaril@0
  2038
	{
insilmaril@0
  2039
		case NewMap:
insilmaril@404
  2040
			fd->setCaption(vymName+ " - " +tr("Load vym map"));
insilmaril@0
  2041
			break;
insilmaril@0
  2042
		case ImportAdd:
insilmaril@404
  2043
			fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
insilmaril@0
  2044
			break;
insilmaril@0
  2045
		case ImportReplace:
insilmaril@404
  2046
			fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
insilmaril@0
  2047
			break;
insilmaril@0
  2048
	}
insilmaril@0
  2049
	fd->show();
insilmaril@0
  2050
insilmaril@0
  2051
	QString fn;
insilmaril@0
  2052
	if ( fd->exec() == QDialog::Accepted )
insilmaril@0
  2053
	{
insilmaril@377
  2054
		lastFileDir=fd->directory().path();
insilmaril@185
  2055
	    QStringList flist = fd->selectedFiles();
insilmaril@185
  2056
		QStringList::Iterator it = flist.begin();
insilmaril@185
  2057
		while( it != flist.end() ) 
insilmaril@185
  2058
		{
insilmaril@185
  2059
			fn = *it;
insilmaril@185
  2060
			fileLoad(*it, lmode);				   
insilmaril@185
  2061
			++it;
insilmaril@185
  2062
		}
insilmaril@0
  2063
	}
insilmaril@185
  2064
	delete (fd);
insilmaril@0
  2065
}
insilmaril@0
  2066
insilmaril@0
  2067
void Main::fileLoad()
insilmaril@0
  2068
{
insilmaril@0
  2069
	fileLoad (NewMap);
insilmaril@0
  2070
}
insilmaril@0
  2071
insilmaril@401
  2072
void Main::fileLoadRecent()
insilmaril@0
  2073
{
insilmaril@401
  2074
    QAction *action = qobject_cast<QAction *>(sender());
insilmaril@401
  2075
    if (action)
insilmaril@401
  2076
        fileLoad (action->data().toString(), NewMap);
insilmaril@401
  2077
}
insilmaril@401
  2078
insilmaril@401
  2079
void Main::addRecentMap (const QString &fileName)
insilmaril@401
  2080
{
insilmaril@401
  2081
insilmaril@401
  2082
    QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
insilmaril@401
  2083
    files.removeAll(fileName);
insilmaril@401
  2084
    files.prepend(fileName);
insilmaril@401
  2085
    while (files.size() > MaxRecentFiles)
insilmaril@401
  2086
        files.removeLast();
insilmaril@401
  2087
insilmaril@401
  2088
    settings.setValue("/mainwindow/recentFileList", files);
insilmaril@401
  2089
insilmaril@401
  2090
	setupRecentMapsMenu();
insilmaril@0
  2091
}
insilmaril@0
  2092
insilmaril@473
  2093
void Main::fileSave(MapEditor *me, const SaveMode &savemode)
insilmaril@0
  2094
{
insilmaril@0
  2095
	// tmp dir for zipping 
insilmaril@0
  2096
	QString tmpMapDir;
insilmaril@0
  2097
	
insilmaril@0
  2098
	// Error codes
insilmaril@205
  2099
	ErrorCode err=success;
insilmaril@0
  2100
	
insilmaril@0
  2101
	QString safeFilePath;
insilmaril@0
  2102
insilmaril@473
  2103
	bool saveZipped=me->saveZipped();
insilmaril@473
  2104
insilmaril@151
  2105
	if (me)
insilmaril@0
  2106
	{
insilmaril@151
  2107
		QString fn=me->getFilePath();
insilmaril@473
  2108
		// filename=unnamed, filepath="" in constructor of mapEditor
insilmaril@0
  2109
		if ( !fn.isEmpty() ) 
insilmaril@0
  2110
		{	
insilmaril@0
  2111
			// We have a filepath, go on saving			
insilmaril@0
  2112
			// First remove existing file, we 
insilmaril@0
  2113
			// don't want to add to old zip archives
insilmaril@0
  2114
			QFile f(fn);
insilmaril@0
  2115
			if (f.exists() ) 
insilmaril@0
  2116
				if (!f.remove())
insilmaril@0
  2117
					QMessageBox::warning( 0, tr( "Save Error" ),
insilmaril@0
  2118
						fn+   tr("\ncould not be removed before saving"));
insilmaril@0
  2119
insilmaril@0
  2120
			// Look, if we should zip the data:
insilmaril@0
  2121
			if (!saveZipped)
insilmaril@0
  2122
			{
insilmaril@404
  2123
				QMessageBox mb( vymName,
insilmaril@159
  2124
					tr("The map %1\ndid not use the compressed "
insilmaril@0
  2125
					"vym file format.\nWriting it uncompressed will also write images \n"
insilmaril@0
  2126
					"and flags and thus may overwrite files in the "
insilmaril@159
  2127
					"given directory\n\nDo you want to write the map").arg(fn),
insilmaril@0
  2128
					QMessageBox::Warning,
insilmaril@0
  2129
					QMessageBox::Yes | QMessageBox::Default,
insilmaril@0
  2130
					QMessageBox::No ,
insilmaril@0
  2131
					QMessageBox::Cancel | QMessageBox::Escape);
insilmaril@0
  2132
				mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
insilmaril@0
  2133
				mb.setButtonText( QMessageBox::No, tr("uncompressed") );
insilmaril@0
  2134
				mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
insilmaril@0
  2135
				switch( mb.exec() ) 
insilmaril@0
  2136
				{
insilmaril@0
  2137
					case QMessageBox::Yes:
insilmaril@0
  2138
						// save compressed (default file format)
insilmaril@0
  2139
						saveZipped=true;
insilmaril@0
  2140
						break;
insilmaril@0
  2141
					case QMessageBox::No:
insilmaril@0
  2142
						// save uncompressed
insilmaril@0
  2143
						saveZipped=false;
insilmaril@0
  2144
						break;
insilmaril@0
  2145
					case QMessageBox::Cancel:
insilmaril@0
  2146
						// do nothing
insilmaril@0
  2147
						return;
insilmaril@0
  2148
						break;
insilmaril@0
  2149
				}
insilmaril@0
  2150
			}
insilmaril@0
  2151
insilmaril@0
  2152
			if (saveZipped)
insilmaril@0
  2153
			{
insilmaril@377
  2154
				// Create temporary directory for packing
insilmaril@377
  2155
				bool ok;
insilmaril@377
  2156
				QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
insilmaril@377
  2157
				if (!ok)
insilmaril@377
  2158
				{
insilmaril@377
  2159
					QMessageBox::critical( 0, tr( "Critical Load Error" ),
insilmaril@377
  2160
					   tr("Couldn't create temporary directory before save\n"));
insilmaril@377
  2161
					return; 
insilmaril@377
  2162
				}
insilmaril@377
  2163
insilmaril@151
  2164
				safeFilePath=me->getFilePath();
insilmaril@151
  2165
				me->setFilePath (tmpMapDir+"/"+
insilmaril@151
  2166
					me->getMapName()+ ".xml",
insilmaril@0
  2167
					safeFilePath);
insilmaril@151
  2168
				me->save (savemode);
insilmaril@151
  2169
				me->setFilePath (safeFilePath);
insilmaril@0
  2170
				
insilmaril@175
  2171
				zipDir (tmpMapDir,fn);
insilmaril@0
  2172
			} // save zipped
insilmaril@0
  2173
			else
insilmaril@0
  2174
			{
insilmaril@0
  2175
				// Save unzipped. 
insilmaril@151
  2176
				safeFilePath=me->getFilePath();
insilmaril@151
  2177
				me->setFilePath (fn, safeFilePath);
insilmaril@151
  2178
				me->save (savemode);
insilmaril@151
  2179
				me->setFilePath (safeFilePath);
insilmaril@0
  2180
			} // save zipped 	
insilmaril@0
  2181
		} // filepath available
insilmaril@0
  2182
		else
insilmaril@0
  2183
		{
insilmaril@0
  2184
			// We have  no filepath yet,
insilmaril@0
  2185
			// call fileSaveAs() now, this will call fileSave() 
insilmaril@0
  2186
			// again.
insilmaril@473
  2187
			// First switch to editor
insilmaril@473
  2188
			tabWidget->setCurrentWidget (me);
insilmaril@0
  2189
			fileSaveAs(savemode);
insilmaril@0
  2190
		}
insilmaril@0
  2191
    }
insilmaril@0
  2192
insilmaril@250
  2193
	if (saveZipped && !tmpMapDir.isEmpty())
insilmaril@0
  2194
		// Delete tmpDir
insilmaril@175
  2195
		removeDir (QDir(tmpMapDir));
insilmaril@0
  2196
insilmaril@0
  2197
	if (err==success)
insilmaril@151
  2198
	{
insilmaril@0
  2199
		statusBar()->message( 
insilmaril@159
  2200
			tr("Saved  %1").arg(me->getFilePath()), 
insilmaril@0
  2201
			statusbarTime );
insilmaril@401
  2202
		addRecentMap (me->getFilePath() );
insilmaril@151
  2203
	} else		
insilmaril@0
  2204
		statusBar()->message( 
insilmaril@159
  2205
			tr("Couldn't save ").arg(me->getFilePath()), 
insilmaril@0
  2206
			statusbarTime );
insilmaril@0
  2207
}
insilmaril@0
  2208
insilmaril@0
  2209
void Main::fileSave()
insilmaril@0
  2210
{
insilmaril@473
  2211
	fileSave (currentMapEditor(), CompleteMap);
insilmaril@473
  2212
}
insilmaril@473
  2213
insilmaril@473
  2214
void Main::fileSave(MapEditor *me)
insilmaril@473
  2215
{
insilmaril@473
  2216
	fileSave (me,CompleteMap);
insilmaril@0
  2217
}
insilmaril@0
  2218
insilmaril@0
  2219
void Main::fileSaveAs(const SaveMode& savemode)
insilmaril@0
  2220
{
insilmaril@0
  2221
	QString fn;
insilmaril@0
  2222
insilmaril@0
  2223
	if (currentMapEditor())
insilmaril@0
  2224
	{
insilmaril@0
  2225
		if (savemode==CompleteMap)
insilmaril@366
  2226
			fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
insilmaril@0
  2227
		else		
insilmaril@366
  2228
			fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
insilmaril@0
  2229
		if ( !fn.isEmpty() ) 
insilmaril@0
  2230
		{
insilmaril@0
  2231
			// Check for existing file
insilmaril@0
  2232
			if (QFile (fn).exists())
insilmaril@0
  2233
			{
insilmaril@404
  2234
				QMessageBox mb( vymName,
insilmaril@159
  2235
					tr("The file %1\nexists already. Do you want to").arg(fn),
insilmaril@0
  2236
					QMessageBox::Warning,
insilmaril@0
  2237
					QMessageBox::Yes | QMessageBox::Default,
insilmaril@0
  2238
					QMessageBox::Cancel | QMessageBox::Escape,
insilmaril@366
  2239
					QMessageBox::NoButton);
insilmaril@0
  2240
				mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
insilmaril@0
  2241
				mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
insilmaril@0
  2242
				switch( mb.exec() ) 
insilmaril@0
  2243
				{
insilmaril@0
  2244
					case QMessageBox::Yes:
insilmaril@0
  2245
						// save 
insilmaril@0
  2246
						break;
insilmaril@0
  2247
					case QMessageBox::Cancel:
insilmaril@0
  2248
						// do nothing
insilmaril@0
  2249
						return;
insilmaril@0
  2250
						break;
insilmaril@0
  2251
				}
insilmaril@0
  2252
			} else
insilmaril@0
  2253
			{
insilmaril@0
  2254
				// New file, add extension to filename, if missing
insilmaril@0
  2255
				// This is always .vym or .vyp, depending on savemode
insilmaril@0
  2256
				if (savemode==CompleteMap)
insilmaril@0
  2257
				{
insilmaril@0
  2258
					if (!fn.contains (".vym") && !fn.contains (".xml"))
insilmaril@0
  2259
						fn +=".vym";
insilmaril@0
  2260
				} else		
insilmaril@0
  2261
				{
insilmaril@0
  2262
					if (!fn.contains (".vyp") && !fn.contains (".xml"))
insilmaril@0
  2263
						fn +=".vyp";
insilmaril@0
  2264
				}
insilmaril@0
  2265
			}
insilmaril@0
  2266
	
insilmaril@0
  2267
insilmaril@0
  2268
insilmaril@0
  2269
insilmaril@0
  2270
			// Save now
insilmaril@0
  2271
			currentMapEditor()->setFilePath(fn);
insilmaril@473
  2272
			fileSave(currentMapEditor(), savemode);
insilmaril@0
  2273
insilmaril@0
  2274
			// Set name of tab
insilmaril@94
  2275
			if (savemode==CompleteMap)
insilmaril@94
  2276
				tabWidget->setTabLabel (currentMapEditor(),
insilmaril@94
  2277
					currentMapEditor()->getFileName() );
insilmaril@0
  2278
			return;
insilmaril@0
  2279
		} 
insilmaril@0
  2280
	}
insilmaril@0
  2281
}
insilmaril@0
  2282
insilmaril@0
  2283
void Main::fileSaveAs()
insilmaril@0
  2284
{
insilmaril@0
  2285
	fileSaveAs (CompleteMap);
insilmaril@0
  2286
}
insilmaril@0
  2287
insilmaril@205
  2288
void Main::fileImportKDEBookmarks()
insilmaril@205
  2289
{
insilmaril@205
  2290
	ImportKDEBookmarks im;
insilmaril@205
  2291
	im.transform();
insilmaril@205
  2292
	if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
insilmaril@205
  2293
		currentMapEditor()->setFilePath ("");
insilmaril@205
  2294
}
insilmaril@205
  2295
insilmaril@314
  2296
void Main::fileImportFirefoxBookmarks()
insilmaril@314
  2297
{
insilmaril@366
  2298
	Q3FileDialog *fd=new Q3FileDialog( this);
insilmaril@327
  2299
	fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
insilmaril@366
  2300
	fd->setMode (Q3FileDialog::ExistingFiles);
insilmaril@327
  2301
	fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
insilmaril@327
  2302
	fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
insilmaril@327
  2303
	fd->show();
insilmaril@327
  2304
insilmaril@327
  2305
	if ( fd->exec() == QDialog::Accepted )
insilmaril@327
  2306
	{
insilmaril@327
  2307
		ImportFirefoxBookmarks im;
insilmaril@327
  2308
	    QStringList flist = fd->selectedFiles();
insilmaril@327
  2309
		QStringList::Iterator it = flist.begin();
insilmaril@327
  2310
		while( it != flist.end() ) 
insilmaril@327
  2311
		{
insilmaril@327
  2312
			im.setFile (*it);
insilmaril@327
  2313
			if (im.transform() && 
insilmaril@327
  2314
				success==fileLoad (im.getTransformedFile(),NewMap) && 
insilmaril@327
  2315
				currentMapEditor() )
insilmaril@327
  2316
				currentMapEditor()->setFilePath ("");
insilmaril@327
  2317
			++it;
insilmaril@327
  2318
		}
insilmaril@327
  2319
	}
insilmaril@327
  2320
	delete (fd);
insilmaril@314
  2321
}
insilmaril@314
  2322
insilmaril@215
  2323
void Main::fileImportMM()
insilmaril@215
  2324
{
insilmaril@215
  2325
	ImportMM im;
insilmaril@215
  2326
insilmaril@366
  2327
	Q3FileDialog *fd=new Q3FileDialog( this);
insilmaril@366
  2328
	fd->setDir (lastFileDir);
insilmaril@366
  2329
	fd->setMode (Q3FileDialog::ExistingFiles);
insilmaril@215
  2330
	fd->addFilter ("Mind Manager (*.mmap)");
insilmaril@215
  2331
	fd->setCaption(tr("Import")+" "+"Mind Manager");
insilmaril@215
  2332
	fd->show();
insilmaril@215
  2333
insilmaril@215
  2334
	if ( fd->exec() == QDialog::Accepted )
insilmaril@215
  2335
	{
insilmaril@215
  2336
		lastFileDir=fd->dirPath();
insilmaril@215
  2337
	    QStringList flist = fd->selectedFiles();
insilmaril@215
  2338
		QStringList::Iterator it = flist.begin();
insilmaril@215
  2339
		while( it != flist.end() ) 
insilmaril@215
  2340
		{
insilmaril@215
  2341
			im.setFile (*it);
insilmaril@215
  2342
			if (im.transform() && 
insilmaril@215
  2343
				success==fileLoad (im.getTransformedFile(),NewMap) && 
insilmaril@215
  2344
				currentMapEditor() )
insilmaril@215
  2345
				currentMapEditor()->setFilePath ("");
insilmaril@215
  2346
insilmaril@215
  2347
			++it;
insilmaril@215
  2348
		}
insilmaril@215
  2349
	}
insilmaril@215
  2350
	delete (fd);
insilmaril@215
  2351
insilmaril@215
  2352
}
insilmaril@215
  2353
insilmaril@215
  2354
void Main::fileImportDir()
insilmaril@215
  2355
{
insilmaril@215
  2356
	if (currentMapEditor())
insilmaril@215
  2357
		currentMapEditor()->importDir();	
insilmaril@215
  2358
}
insilmaril@215
  2359
insilmaril@526
  2360
void Main::fileExportXML()	
insilmaril@0
  2361
{
insilmaril@526
  2362
	MapEditor *me=currentMapEditor();
insilmaril@526
  2363
	if (me) me->exportXML();
insilmaril@0
  2364
}
insilmaril@0
  2365
insilmaril@0
  2366
insilmaril@517
  2367
void Main::fileExportXHTML()	
insilmaril@0
  2368
{
insilmaril@260
  2369
	MapEditor *me=currentMapEditor();
insilmaril@517
  2370
	if (me) me->exportXHTML();
insilmaril@0
  2371
}
insilmaril@0
  2372
insilmaril@517
  2373
void Main::fileExportImage()	
insilmaril@0
  2374
{
insilmaril@260
  2375
	MapEditor *me=currentMapEditor();
insilmaril@514
  2376
	if (me) me->exportImage();
insilmaril@0
  2377
}
insilmaril@0
  2378
insilmaril@0
  2379
void Main::fileExportASCII()
insilmaril@0
  2380
{
insilmaril@260
  2381
	MapEditor *me=currentMapEditor();
insilmaril@514
  2382
	if (me) me->exportASCII();
insilmaril@0
  2383
}
insilmaril@0
  2384
insilmaril@517
  2385
void Main::fileExportCSV()	//FIXME not scriptable yet
insilmaril@497
  2386
{
insilmaril@497
  2387
	MapEditor *me=currentMapEditor();
insilmaril@497
  2388
	if (me)
insilmaril@497
  2389
	{
insilmaril@497
  2390
		ExportCSV ex;
insilmaril@497
  2391
		ex.setMapCenter(me->getMapCenter());
insilmaril@497
  2392
		ex.addFilter ("CSV (*.csv)");
insilmaril@497
  2393
		ex.setDir(lastImageDir);
insilmaril@497
  2394
		ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
insilmaril@497
  2395
		if (ex.execDialog() ) 
insilmaril@497
  2396
		{
insilmaril@497
  2397
			me->setExportMode(true);
insilmaril@497
  2398
			ex.doExport();
insilmaril@497
  2399
			me->setExportMode(false);
insilmaril@497
  2400
		}
insilmaril@497
  2401
	}
insilmaril@497
  2402
}
insilmaril@497
  2403
insilmaril@517
  2404
void Main::fileExportLaTeX()	//FIXME not scriptable yet
insilmaril@163
  2405
{
insilmaril@260
  2406
	MapEditor *me=currentMapEditor();
insilmaril@260
  2407
	if (me)
insilmaril@228
  2408
	{
insilmaril@228
  2409
		ExportLaTeX ex;
insilmaril@260
  2410
		ex.setMapCenter(me->getMapCenter());
insilmaril@228
  2411
		ex.addFilter ("Tex (*.tex)");
insilmaril@424
  2412
		ex.setDir(lastImageDir);
insilmaril@404
  2413
		ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
insilmaril@260
  2414
		if (ex.execDialog() ) 
insilmaril@260
  2415
		{
insilmaril@260
  2416
			me->setExportMode(true);
insilmaril@260
  2417
			ex.doExport();
insilmaril@260
  2418
			me->setExportMode(false);
insilmaril@260
  2419
		}
insilmaril@228
  2420
	}
insilmaril@228
  2421
}
insilmaril@228
  2422
insilmaril@517
  2423
void Main::fileExportKDEBookmarks()	//FIXME not scriptable yet
insilmaril@243
  2424
{
insilmaril@243
  2425
	ExportKDEBookmarks ex;
insilmaril@260
  2426
	MapEditor *me=currentMapEditor();
insilmaril@260
  2427
	if (me)
insilmaril@243
  2428
	{
insilmaril@260
  2429
		ex.setMapCenter (me->getMapCenter() );
insilmaril@243
  2430
		ex.doExport();
insilmaril@243
  2431
	}	
insilmaril@243
  2432
}
insilmaril@243
  2433
insilmaril@517
  2434
void Main::fileExportTaskjuggler()	//FIXME not scriptable yet
insilmaril@228
  2435
{
insilmaril@228
  2436
	ExportTaskjuggler ex;
insilmaril@260
  2437
	MapEditor *me=currentMapEditor();
insilmaril@260
  2438
	if (me)
insilmaril@228
  2439
	{
insilmaril@260
  2440
		ex.setMapCenter (me->getMapCenter() );
insilmaril@404
  2441
		ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
insilmaril@424
  2442
		ex.setDir(lastImageDir);
insilmaril@243
  2443
		ex.addFilter ("Taskjuggler (*.tjp)");
insilmaril@260
  2444
		if (ex.execDialog() ) 
insilmaril@260
  2445
		{
insilmaril@260
  2446
			me->setExportMode(true);
insilmaril@260
  2447
			ex.doExport();
insilmaril@260
  2448
			me->setExportMode(false);
insilmaril@260
  2449
		}
insilmaril@228
  2450
	}	
insilmaril@163
  2451
}
insilmaril@163
  2452
insilmaril@517
  2453
void Main::fileExportOOPresentation()	//FIXME not scriptable yet
insilmaril@163
  2454
{
insilmaril@404
  2455
	ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
insilmaril@366
  2456
	// TODO add preview in dialog
insilmaril@185
  2457
	//ImagePreview *p =new ImagePreview (fd);
insilmaril@185
  2458
	//fd->setContentsPreviewEnabled( TRUE );
insilmaril@185
  2459
	//fd->setContentsPreview( p, p );
insilmaril@185
  2460
	//fd->setPreviewMode( QFileDialog::Contents );
insilmaril@404
  2461
	fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
insilmaril@366
  2462
	fd->setDir (QDir().current());
insilmaril@357
  2463
	if (fd->foundConfig())
insilmaril@357
  2464
	{
insilmaril@357
  2465
		fd->show();
insilmaril@185
  2466
insilmaril@357
  2467
		if ( fd->exec() == QDialog::Accepted )
insilmaril@357
  2468
		{
insilmaril@357
  2469
			QString fn=fd->selectedFile();
insilmaril@366
  2470
			if (!fn.contains (".odp"))
insilmaril@366
  2471
				fn +=".odp";
insilmaril@366
  2472
insilmaril@357
  2473
			//lastImageDir=fn.left(fn.findRev ("/"));
insilmaril@357
  2474
			if (currentMapEditor())
insilmaril@357
  2475
				currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());	
insilmaril@357
  2476
		}
insilmaril@357
  2477
	} else
insilmaril@185
  2478
	{
insilmaril@357
  2479
		QMessageBox::warning(0, 
insilmaril@366
  2480
		tr("Warning"),
insilmaril@366
  2481
		tr("Couldn't find configuration for export to Open Office\n"));
insilmaril@185
  2482
	}
insilmaril@163
  2483
}
insilmaril@163
  2484
insilmaril@0
  2485
void Main::fileCloseMap()
insilmaril@0
  2486
{
insilmaril@0
  2487
	if (currentMapEditor())
insilmaril@0
  2488
	{
insilmaril@0
  2489
		if (currentMapEditor()->hasChanged())
insilmaril@0
  2490
		{
insilmaril@404
  2491
			QMessageBox mb( vymName,
insilmaril@159
  2492
				tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
insilmaril@0
  2493
				QMessageBox::Warning,
insilmaril@0
  2494
				QMessageBox::Yes | QMessageBox::Default,
insilmaril@0
  2495
				QMessageBox::No,
insilmaril@0
  2496
				QMessageBox::Cancel | QMessageBox::Escape );
insilmaril@0
  2497
			mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
insilmaril@0
  2498
			mb.setButtonText( QMessageBox::No, tr("Discard changes"));
insilmaril@0
  2499
			switch( mb.exec() ) 
insilmaril@0
  2500
			{
insilmaril@0
  2501
				case QMessageBox::Yes:
insilmaril@0
  2502
					// save and close
insilmaril@473
  2503
					fileSave(currentMapEditor(), CompleteMap);
insilmaril@0
  2504
					break;
insilmaril@0
  2505
				case QMessageBox::No:
insilmaril@0
  2506
				// close  without saving
insilmaril@0
  2507
					break;
insilmaril@0
  2508
				case QMessageBox::Cancel:
insilmaril@0
  2509
					// do nothing
insilmaril@0
  2510
				return;
insilmaril@0
  2511
			}
insilmaril@0
  2512
		} 
insilmaril@0
  2513
		currentMapEditor()->closeMap();
insilmaril@0
  2514
		tabWidget->removePage(currentMapEditor());
insilmaril@0
  2515
		if (tabWidget->count()==0)
insilmaril@0
  2516
			actionFilePrint->setEnabled (false);
insilmaril@0
  2517
	}	
insilmaril@0
  2518
}
insilmaril@0
  2519
insilmaril@0
  2520
void Main::filePrint()
insilmaril@0
  2521
{
insilmaril@0
  2522
	if (currentMapEditor())
insilmaril@0
  2523
		currentMapEditor()->print();
insilmaril@0
  2524
}
insilmaril@0
  2525
insilmaril@0
  2526
void Main::fileExitVYM()
insilmaril@0
  2527
{
insilmaril@0
  2528
	// Check if one or more editors have changed
insilmaril@0
  2529
	MapEditor *me;
insilmaril@0
  2530
	int i;
insilmaril@0
  2531
	for (i=0;i<=tabWidget->count() -1;i++)
insilmaril@0
  2532
	{
insilmaril@0
  2533
		
insilmaril@0
  2534
		me=(MapEditor*)tabWidget->page(i);
insilmaril@0
  2535
insilmaril@0
  2536
		// If something changed, ask what to do
insilmaril@486
  2537
		if (me->hasChanged())
insilmaril@0
  2538
		{
insilmaril@0
  2539
			tabWidget->setCurrentPage(i);
insilmaril@404
  2540
			QMessageBox mb( vymName,
insilmaril@0
  2541
				tr("This map is not saved yet. Do you want to"),
insilmaril@0
  2542
				QMessageBox::Warning,
insilmaril@0
  2543
				QMessageBox::Yes | QMessageBox::Default,
insilmaril@0
  2544
				QMessageBox::No,
insilmaril@0
  2545
				QMessageBox::Cancel | QMessageBox::Escape );
insilmaril@0
  2546
			mb.setButtonText( QMessageBox::Yes, tr("Save map") );
insilmaril@0
  2547
			mb.setButtonText( QMessageBox::No, tr("Discard changes") );
insilmaril@366
  2548
			mb.setModal (true);
insilmaril@0
  2549
			mb.show();
insilmaril@0
  2550
			mb.setActiveWindow();
insilmaril@0
  2551
			switch( mb.exec() ) {
insilmaril@0
  2552
				case QMessageBox::Yes:
insilmaril@0
  2553
					// save (the changed editors) and exit
insilmaril@473
  2554
					fileSave(currentMapEditor(), CompleteMap);
insilmaril@0
  2555
					break;
insilmaril@0
  2556
				case QMessageBox::No:
insilmaril@0
  2557
					// exit without saving
insilmaril@0
  2558
					break;
insilmaril@0
  2559
				case QMessageBox::Cancel:
insilmaril@0
  2560
					// don't save and don't exit
insilmaril@0
  2561
				return;
insilmaril@0
  2562
			}
insilmaril@0
  2563
		}
insilmaril@0
  2564
	} // loop over all MEs	
insilmaril@0
  2565
    qApp->quit();
insilmaril@0
  2566
}
insilmaril@0
  2567
insilmaril@0
  2568
void Main::editUndo()
insilmaril@0
  2569
{
insilmaril@0
  2570
	if (currentMapEditor())
insilmaril@0
  2571
		currentMapEditor()->undo();
insilmaril@0
  2572
}
insilmaril@0
  2573
insilmaril@163
  2574
void Main::editRedo()	   
insilmaril@0
  2575
{
insilmaril@163
  2576
	if (currentMapEditor())
insilmaril@163
  2577
		currentMapEditor()->redo();
insilmaril@0
  2578
}
insilmaril@0
  2579
insilmaril@404
  2580
void Main::gotoHistoryStep (int i)	   
insilmaril@404
  2581
{
insilmaril@404
  2582
	if (currentMapEditor())
insilmaril@404
  2583
		currentMapEditor()->gotoHistoryStep (i);
insilmaril@404
  2584
}
insilmaril@404
  2585
insilmaril@0
  2586
void Main::editCopy()
insilmaril@0
  2587
{
insilmaril@0
  2588
	if (currentMapEditor())
insilmaril@0
  2589
		currentMapEditor()->copy();
insilmaril@0
  2590
}
insilmaril@0
  2591
insilmaril@0
  2592
void Main::editPaste()
insilmaril@0
  2593
{
insilmaril@0
  2594
	if (currentMapEditor())
insilmaril@0
  2595
		currentMapEditor()->paste();
insilmaril@0
  2596
}
insilmaril@0
  2597
insilmaril@0
  2598
void Main::editCut()
insilmaril@0
  2599
{
insilmaril@0
  2600
	if (currentMapEditor())
insilmaril@0
  2601
		currentMapEditor()->cut();
insilmaril@0
  2602
}
insilmaril@0
  2603
insilmaril@0
  2604
void Main::editOpenFindWindow()
insilmaril@0
  2605
{
insilmaril@0
  2606
	findWindow->popup();
insilmaril@0
  2607
	findWindow->raise();
insilmaril@0
  2608
	findWindow->setActiveWindow();
insilmaril@0
  2609
}
insilmaril@0
  2610
insilmaril@0
  2611
void Main::editFind(QString s)
insilmaril@0
  2612
{
insilmaril@0
  2613
	bool cs=false;
insilmaril@0
  2614
	BranchObj *bo=currentMapEditor()->findText(s, cs);
insilmaril@0
  2615
	if (bo)
insilmaril@0
  2616
	{	
insilmaril@0
  2617
		statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
insilmaril@0
  2618
	} else
insilmaril@0
  2619
	{
insilmaril@0
  2620
		QMessageBox::information( findWindow, tr( "VYM -Information:" ),
insilmaril@349
  2621
							   tr("No matches found for \"%1\"").arg(s));
insilmaril@0
  2622
	}	
insilmaril@0
  2623
}
insilmaril@0
  2624
insilmaril@0
  2625
void Main::editFindChanged()
insilmaril@0
  2626
{	// Notify editor, to abort the current find process
insilmaril@0
  2627
	currentMapEditor()->findReset();
insilmaril@0
  2628
}
insilmaril@0
  2629
insilmaril@366
  2630
void Main::openTabs(QStringList urls)
insilmaril@366
  2631
{
insilmaril@366
  2632
	if (!urls.isEmpty())
insilmaril@366
  2633
	{	
insilmaril@366
  2634
		bool success=true;
insilmaril@366
  2635
		QStringList args;
insilmaril@366
  2636
		QString browser=settings.value("/mainwindow/readerURL" ).toString();
insilmaril@366
  2637
		QProcess *p;
insilmaril@366
  2638
		if (!procBrowser ||  procBrowser->state()!=QProcess::Running)
insilmaril@366
  2639
		{
insilmaril@366
  2640
			QString u=urls.takeFirst();
insilmaril@366
  2641
			procBrowser = new QProcess( this );
insilmaril@366
  2642
			args<<u;
insilmaril@366
  2643
			procBrowser->start(browser,args);
insilmaril@366
  2644
			if ( !procBrowser->waitForStarted())
insilmaril@366
  2645
			{
insilmaril@366
  2646
				// try to set path to browser
insilmaril@366
  2647
				QMessageBox::warning(0, 
insilmaril@366
  2648
					tr("Warning"),
insilmaril@366
  2649
					tr("Couldn't find a viewer to open %1.\n").arg(u)+
insilmaril@366
  2650
					tr("Please use Settings->")+tr("Set application to open an URL"));
insilmaril@366
  2651
				return;
insilmaril@366
  2652
			}
insilmaril@366
  2653
			sleep (3);
insilmaril@366
  2654
		}
insilmaril@366
  2655
		if (browser.contains("konqueror"))
insilmaril@366
  2656
		{
insilmaril@366
  2657
			for (int i=0; i<urls.size(); i++)
insilmaril@366
  2658
			{
insilmaril@366
  2659
				// Open new browser
insilmaril@366
  2660
				// Try to open new tab in existing konqueror started previously by vym
insilmaril@366
  2661
				p=new QProcess (this);
insilmaril@366
  2662
				args.clear();
insilmaril@366
  2663
				args<< QString("konqueror-%1").arg(procBrowser->pid())<< 
insilmaril@366
  2664
					"konqueror-mainwindow#1"<< 
insilmaril@366
  2665
					"newTab" << 
insilmaril@366
  2666
					urls.at(i);
insilmaril@366
  2667
				p->start ("dcop",args);
insilmaril@366
  2668
				if ( !p->waitForStarted() ) success=false;
insilmaril@366
  2669
			}
insilmaril@366
  2670
			if (!success)
insilmaril@366
  2671
				QMessageBox::warning(0, 
insilmaril@366
  2672
					tr("Warning"),
insilmaril@366
  2673
					tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
insilmaril@366
  2674
			return;		
insilmaril@366
  2675
		} else if (browser.contains ("firefox") || browser.contains ("mozilla") )
insilmaril@366
  2676
		{
insilmaril@366
  2677
			for (int i=0; i<urls.size(); i++)
insilmaril@366
  2678
			{
insilmaril@366
  2679
				// Try to open new tab in firefox
insilmaril@366
  2680
				p=new QProcess (this);
insilmaril@366
  2681
				args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
insilmaril@366
  2682
				p->start (browser,args);
insilmaril@366
  2683
				if ( !p->waitForStarted() ) success=false;
insilmaril@366
  2684
			}			
insilmaril@366
  2685
			if (!success)
insilmaril@366
  2686
				QMessageBox::warning(0, 
insilmaril@366
  2687
					tr("Warning"),
insilmaril@366
  2688
					tr("Couldn't start %1 to open a new tab").arg(browser));
insilmaril@366
  2689
			return;		
insilmaril@366
  2690
		}			
insilmaril@366
  2691
		QMessageBox::warning(0, 
insilmaril@366
  2692
			tr("Warning"),
insilmaril@366
  2693
			tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
insilmaril@366
  2694
	}	
insilmaril@366
  2695
}
insilmaril@366
  2696
insilmaril@0
  2697
void Main::editOpenURL()
insilmaril@0
  2698
{
insilmaril@266
  2699
	// Open new browser
insilmaril@0
  2700
	if (currentMapEditor())
insilmaril@266
  2701
	{	
insilmaril@266
  2702
	    QString url=currentMapEditor()->getURL();
insilmaril@366
  2703
		QStringList args;
insilmaril@266
  2704
		if (url=="") return;
insilmaril@366
  2705
		QString browser=settings.value("/mainwindow/readerURL" ).toString();
insilmaril@266
  2706
		procBrowser = new QProcess( this );
insilmaril@366
  2707
		args<<url;
insilmaril@366
  2708
		procBrowser->start(browser,args);
insilmaril@366
  2709
		if ( !procBrowser->waitForStarted())
insilmaril@266
  2710
		{
insilmaril@266
  2711
			// try to set path to browser
insilmaril@266
  2712
			QMessageBox::warning(0, 
insilmaril@266
  2713
				tr("Warning"),
insilmaril@266
  2714
				tr("Couldn't find a viewer to open %1.\n").arg(url)+
insilmaril@266
  2715
				tr("Please use Settings->")+tr("Set application to open an URL"));
insilmaril@266
  2716
			settingsURL() ; 
insilmaril@266
  2717
		}	
insilmaril@266
  2718
	}	
insilmaril@266
  2719
}
insilmaril@266
  2720
void Main::editOpenURLTab()
insilmaril@266
  2721
{
insilmaril@266
  2722
	if (currentMapEditor())
insilmaril@266
  2723
	{	
insilmaril@366
  2724
	    QStringList urls;
insilmaril@366
  2725
		urls.append(currentMapEditor()->getURL());
insilmaril@366
  2726
		openTabs (urls);
insilmaril@266
  2727
	}	
insilmaril@0
  2728
}
insilmaril@366
  2729
void Main::editOpenMultipleURLTabs()
insilmaril@366
  2730
{
insilmaril@366
  2731
	if (currentMapEditor())
insilmaril@366
  2732
	{	
insilmaril@366
  2733
	    QStringList urls;
insilmaril@366
  2734
		urls=currentMapEditor()->getURLs();
insilmaril@366
  2735
		openTabs (urls);
insilmaril@366
  2736
	}	
insilmaril@366
  2737
}
insilmaril@366
  2738
insilmaril@0
  2739
insilmaril@0
  2740
void Main::editURL()
insilmaril@0
  2741
{
insilmaril@0
  2742
	if (currentMapEditor())
insilmaril@0
  2743
	    currentMapEditor()->editURL();
insilmaril@0
  2744
}
insilmaril@0
  2745
insilmaril@528
  2746
void Main::editLocalURL()
insilmaril@528
  2747
{
insilmaril@528
  2748
	if (currentMapEditor())
insilmaril@528
  2749
	    currentMapEditor()->editLocalURL();
insilmaril@528
  2750
}
insilmaril@528
  2751
insilmaril@0
  2752
void Main::editHeading2URL()
insilmaril@0
  2753
{
insilmaril@0
  2754
	if (currentMapEditor())
insilmaril@0
  2755
	    currentMapEditor()->editHeading2URL();
insilmaril@0
  2756
}
insilmaril@0
  2757
insilmaril@0
  2758
void Main::editBugzilla2URL()
insilmaril@0
  2759
{
insilmaril@0
  2760
	if (currentMapEditor())
insilmaril@0
  2761
	    currentMapEditor()->editBugzilla2URL();
insilmaril@0
  2762
}
insilmaril@0
  2763
insilmaril@175
  2764
void Main::editFATE2URL()
insilmaril@175
  2765
{
insilmaril@175
  2766
	if (currentMapEditor())
insilmaril@175
  2767
	    currentMapEditor()->editFATE2URL();
insilmaril@175
  2768
}
insilmaril@175
  2769
insilmaril@394
  2770
void Main::editHeadingFinished()
insilmaril@394
  2771
{
insilmaril@394
  2772
	// only called from editHeading(), so there is a currentME
insilmaril@394
  2773
	MapEditor *me=currentMapEditor();
insilmaril@421
  2774
	if (me)
insilmaril@421
  2775
	{
insilmaril@491
  2776
		me->setStateEditHeading (false);
insilmaril@421
  2777
		QPoint p;	//Not used here, only to find out pos of branch
insilmaril@421
  2778
		bool ok;
insilmaril@421
  2779
		QString s=me->getHeading(ok,p);
insilmaril@394
  2780
insilmaril@394
  2781
#if defined(Q_OS_MACX)
insilmaril@394
  2782
#else
insilmaril@421
  2783
		if (ok && s!=lineedit->text())
insilmaril@421
  2784
			me->setHeading(lineedit->text());
insilmaril@421
  2785
			
insilmaril@421
  2786
		lineedit->releaseKeyboard();
insilmaril@421
  2787
		lineedit->hide();
insilmaril@421
  2788
		setFocus();
insilmaril@394
  2789
#endif	
insilmaril@537
  2790
		if (!actionSettingsAutoSelectNewBranch->isOn() && 
insilmaril@537
  2791
			!prevSelection.isEmpty()) 
insilmaril@537
  2792
			me->select(prevSelection);
insilmaril@421
  2793
		prevSelection="";
insilmaril@421
  2794
	}
insilmaril@394
  2795
}
insilmaril@394
  2796
insilmaril@366
  2797
void Main::editHeading()
insilmaril@0
  2798
{
insilmaril@394
  2799
	if (currentMapEditor())
insilmaril@0
  2800
	{
insilmaril@394
  2801
		MapEditor *me=currentMapEditor();
insilmaril@394
  2802
		QString oldSel=me->getSelectString();
insilmaril@394
  2803
insilmaril@394
  2804
		if (lineedit->isVisible())
insilmaril@394
  2805
			editHeadingFinished();
insilmaril@394
  2806
		else
insilmaril@366
  2807
		{
insilmaril@366
  2808
			bool ok;
insilmaril@366
  2809
			QPoint p;
insilmaril@531
  2810
			QString s=me->getHeading(ok,p);
insilmaril@366
  2811
insilmaril@366
  2812
			if (ok)
insilmaril@366
  2813
			{
insilmaril@491
  2814
				me->setStateEditHeading (true);
insilmaril@366
  2815
#if defined(Q_OS_MACX)
insilmaril@531
  2816
				p=me->mapToGlobal (p);
insilmaril@366
  2817
				QDialog *d =new QDialog(NULL);
insilmaril@366
  2818
				QLineEdit *le=new QLineEdit (d);
insilmaril@366
  2819
				d->setWindowFlags (Qt::FramelessWindowHint);
insilmaril@394
  2820
				d->setGeometry(p.x(),p.y(),230,25);
insilmaril@394
  2821
				le->resize (d->width()-10,d->height());
insilmaril@366
  2822
				le->setText (s);
insilmaril@366
  2823
				le->selectAll();
insilmaril@366
  2824
				connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
insilmaril@366
  2825
				d->activateWindow();
insilmaril@366
  2826
				d->exec();
insilmaril@531
  2827
				me->setHeading (le->text());
insilmaril@394
  2828
				delete (le);
insilmaril@394
  2829
				delete (d);
insilmaril@394
  2830
				editHeadingFinished();
insilmaril@366
  2831
#else
insilmaril@531
  2832
				p=me->mapTo (this,p);
insilmaril@394
  2833
				lineedit->setGeometry(p.x(),p.y(),230,25);
insilmaril@366
  2834
				lineedit->setText(s);
insilmaril@366
  2835
				lineedit->setCursorPosition(1);
insilmaril@366
  2836
				lineedit->selectAll();
insilmaril@366
  2837
				lineedit->show();
insilmaril@366
  2838
				lineedit->grabKeyboard();
insilmaril@366
  2839
				lineedit->setFocus();
insilmaril@366
  2840
#endif
insilmaril@366
  2841
			}
insilmaril@366
  2842
		}
insilmaril@394
  2843
	} // currentMapEditor()	
insilmaril@366
  2844
}
insilmaril@366
  2845
insilmaril@366
  2846
void Main::openVymLinks(const QStringList &vl)
insilmaril@366
  2847
{
insilmaril@366
  2848
	for (int j=0; j<vl.size(); j++)
insilmaril@366
  2849
	{
insilmaril@0
  2850
		// compare path with already loaded maps
insilmaril@0
  2851
		int index=-1;
insilmaril@0
  2852
		int i;
insilmaril@0
  2853
		MapEditor *me;
insilmaril@0
  2854
		for (i=0;i<=tabWidget->count() -1;i++)
insilmaril@0
  2855
		{
insilmaril@0
  2856
			me=(MapEditor*)tabWidget->page(i);
insilmaril@366
  2857
			if (vl.at(j)==me->getFilePath() )
insilmaril@0
  2858
			{
insilmaril@0
  2859
				index=i;
insilmaril@0
  2860
				break;
insilmaril@0
  2861
			}
insilmaril@0
  2862
		}	
insilmaril@0
  2863
		if (index<0)
insilmaril@0
  2864
		// Load map
insilmaril@0
  2865
		{
insilmaril@366
  2866
			if (!QFile(vl.at(j)).exists() )
insilmaril@0
  2867
				QMessageBox::critical( 0, tr( "Critical Error" ),
insilmaril@366
  2868
				   tr("Couldn't open map %1").arg(vl.at(j)));
insilmaril@0
  2869
			else
insilmaril@0
  2870
			{
insilmaril@366
  2871
				fileLoad (vl.at(j), NewMap);
insilmaril@0
  2872
				tabWidget->setCurrentPage (tabWidget->count()-1);	
insilmaril@0
  2873
			}
insilmaril@0
  2874
		} else
insilmaril@0
  2875
			// Go to tab containing the map
insilmaril@0
  2876
			tabWidget->setCurrentPage (index);	
insilmaril@0
  2877
	}
insilmaril@0
  2878
}
insilmaril@0
  2879
insilmaril@366
  2880
void Main::editOpenVymLink()
insilmaril@366
  2881
{
insilmaril@366
  2882
	if (currentMapEditor())
insilmaril@366
  2883
	{
insilmaril@366
  2884
		QStringList vl;
insilmaril@366
  2885
		vl.append(currentMapEditor()->getVymLink());	
insilmaril@366
  2886
		openVymLinks (vl);
insilmaril@366
  2887
	}
insilmaril@366
  2888
}
insilmaril@366
  2889
insilmaril@366
  2890
void Main::editOpenMultipleVymLinks()
insilmaril@366
  2891
{
insilmaril@366
  2892
	QString currentVymLink;
insilmaril@366
  2893
	if (currentMapEditor())
insilmaril@366
  2894
	{
insilmaril@366
  2895
		QStringList vl=currentMapEditor()->getVymLinks();
insilmaril@366
  2896
		openVymLinks (vl);
insilmaril@366
  2897
	}
insilmaril@366
  2898
}
insilmaril@366
  2899
insilmaril@0
  2900
void Main::editVymLink()
insilmaril@0
  2901
{
insilmaril@0
  2902
	if (currentMapEditor())
insilmaril@0
  2903
		currentMapEditor()->editVymLink();	
insilmaril@0
  2904
}
insilmaril@0
  2905
insilmaril@0
  2906
void Main::editDeleteVymLink()
insilmaril@0
  2907
{
insilmaril@0
  2908
	if (currentMapEditor())
insilmaril@0
  2909
		currentMapEditor()->deleteVymLink();	
insilmaril@0
  2910
}
insilmaril@0
  2911
insilmaril@243
  2912
void Main::editToggleHideExport()
insilmaril@243
  2913
{
insilmaril@243
  2914
	if (currentMapEditor())
insilmaril@294
  2915
		currentMapEditor()->toggleHideExport();	
insilmaril@243
  2916
}
insilmaril@243
  2917
insilmaril@0
  2918
void Main::editMapInfo()
insilmaril@0
  2919
{
insilmaril@0
  2920
	if (currentMapEditor())
insilmaril@0
  2921
		currentMapEditor()->editMapInfo();	
insilmaril@0
  2922
}
insilmaril@0
  2923
insilmaril@0
  2924
void Main::editMoveUp()
insilmaril@0
  2925
{
insilmaril@0
  2926
	if (currentMapEditor())
insilmaril@0
  2927
	    currentMapEditor()->moveBranchUp();
insilmaril@0
  2928
}
insilmaril@0
  2929
insilmaril@0
  2930
void Main::editMoveDown()
insilmaril@0
  2931
{
insilmaril@0
  2932
	if (currentMapEditor())
insilmaril@0
  2933
		currentMapEditor()->moveBranchDown();
insilmaril@0
  2934
}
insilmaril@0
  2935
insilmaril@0
  2936
void Main::editToggleScroll()
insilmaril@0
  2937
{
insilmaril@0
  2938
	if (currentMapEditor())
insilmaril@0
  2939
	{
insilmaril@0
  2940
		currentMapEditor()->toggleScroll();	
insilmaril@0
  2941
	}	
insilmaril@0
  2942
}
insilmaril@0
  2943
insilmaril@473
  2944
void Main::editUnscrollChilds()
insilmaril@0
  2945
{
insilmaril@0
  2946
	if (currentMapEditor())
insilmaril@428
  2947
		currentMapEditor()->unscrollChilds();	
insilmaril@394
  2948
}
insilmaril@394
  2949
insilmaril@394
  2950
void Main::editNewBranch()
insilmaril@394
  2951
{
insilmaril@394
  2952
	MapEditor *me=currentMapEditor();
insilmaril@394
  2953
	if (!lineedit->isVisible() && me)
insilmaril@0
  2954
	{
insilmaril@394
  2955
		BranchObj *bo=(BranchObj*)me->getSelection();
insilmaril@394
  2956
		BranchObj *newbo=me->addNewBranch(0);
insilmaril@394
  2957
insilmaril@534
  2958
		prevSelection=bo->getSelectString();
insilmaril@394
  2959
		if (newbo) 
insilmaril@394
  2960
			me->select (newbo->getSelectString());
insilmaril@394
  2961
		else
insilmaril@394
  2962
			return;
insilmaril@394
  2963
insilmaril@537
  2964
		if (actionSettingsAutoEditNewBranch->isOn())
insilmaril@394
  2965
		{
insilmaril@394
  2966
			editHeading();
insilmaril@534
  2967
			return;
insilmaril@534
  2968
		}	
insilmaril@534
  2969
		if (!prevSelection.isEmpty()) 
insilmaril@534
  2970
		{
insilmaril@534
  2971
			me->select(prevSelection);
insilmaril@534
  2972
			prevSelection="";
insilmaril@394
  2973
		}
insilmaril@534
  2974
insilmaril@0
  2975
	}	
insilmaril@0
  2976
}
insilmaril@0
  2977
insilmaril@394
  2978
void Main::editNewBranchBefore()
insilmaril@0
  2979
{
insilmaril@394
  2980
	MapEditor *me=currentMapEditor();
insilmaril@394
  2981
	if (!lineedit->isVisible() && me)
insilmaril@394
  2982
	{
insilmaril@394
  2983
		BranchObj *bo=(BranchObj*)me->getSelection();
insilmaril@394
  2984
		BranchObj *newbo=me->addNewBranchBefore();
insilmaril@394
  2985
insilmaril@394
  2986
		if (newbo) 
insilmaril@394
  2987
			me->select (newbo->getSelectString());
insilmaril@394
  2988
		else
insilmaril@394
  2989
			return;
insilmaril@394
  2990
insilmaril@537
  2991
		if (actionSettingsAutoEditNewBranch->isOn())
insilmaril@394
  2992
		{
insilmaril@537
  2993
			if (!actionSettingsAutoSelectNewBranch->isOn())
insilmaril@394
  2994
				prevSelection=bo->getSelectString();
insilmaril@394
  2995
			editHeading();
insilmaril@394
  2996
		}
insilmaril@394
  2997
	}	
insilmaril@98
  2998
}
insilmaril@98
  2999
insilmaril@0
  3000
void Main::editNewBranchAbove()
insilmaril@0
  3001
{
insilmaril@394
  3002
	MapEditor *me=currentMapEditor();
insilmaril@394
  3003
	if (!lineedit->isVisible() && me)
insilmaril@394
  3004
	{
insilmaril@394
  3005
		BranchObj *bo=(BranchObj*)me->getSelection();
insilmaril@394
  3006
		BranchObj *newbo=me->addNewBranch (-1);
insilmaril@394
  3007
insilmaril@394
  3008
		if (newbo) 
insilmaril@394
  3009
			me->select (newbo->getSelectString());
insilmaril@394
  3010
		else
insilmaril@394
  3011
			return;
insilmaril@394
  3012
insilmaril@537
  3013
		if (actionSettingsAutoEditNewBranch->isOn())
insilmaril@394
  3014
		{
insilmaril@537
  3015
			if (!actionSettingsAutoSelectNewBranch->isOn())
insilmaril@394
  3016
				prevSelection=bo->getSelectString();
insilmaril@394
  3017
			editHeading();
insilmaril@394
  3018
		}
insilmaril@394
  3019
	}	
insilmaril@0
  3020
}
insilmaril@0
  3021
insilmaril@0
  3022
void Main::editNewBranchBelow()
insilmaril@0
  3023
{
insilmaril@394
  3024
	MapEditor *me=currentMapEditor();
insilmaril@394
  3025
	if (!lineedit->isVisible() && me)
insilmaril@394
  3026
	{
insilmaril@394
  3027
		BranchObj *bo=(BranchObj*)me->getSelection();
insilmaril@394
  3028
		BranchObj *newbo=me->addNewBranch (1);
insilmaril@394
  3029
insilmaril@394
  3030
		if (newbo) 
insilmaril@394
  3031
			me->select (newbo->getSelectString());
insilmaril@394
  3032
		else
insilmaril@394
  3033
			return;
insilmaril@394
  3034
insilmaril@537
  3035
		if (actionSettingsAutoEditNewBranch->isOn())
insilmaril@394
  3036
		{
insilmaril@537
  3037
			if (!actionSettingsAutoSelectNewBranch->isOn())
insilmaril@394
  3038
				prevSelection=bo->getSelectString();
insilmaril@394
  3039
			editHeading();
insilmaril@394
  3040
		}
insilmaril@394
  3041
	}	
insilmaril@0
  3042
}
insilmaril@0
  3043
insilmaril@0
  3044
void Main::editImportAdd()
insilmaril@0
  3045
{
insilmaril@0
  3046
	fileLoad (ImportAdd);
insilmaril@0
  3047
}
insilmaril@0
  3048
insilmaril@0
  3049
void Main::editImportReplace()
insilmaril@0
  3050
{
insilmaril@0
  3051
	fileLoad (ImportReplace);
insilmaril@0
  3052
}
insilmaril@0
  3053
insilmaril@0
  3054
void Main::editSaveBranch()
insilmaril@0
  3055
{
insilmaril@0
  3056
	fileSaveAs (PartOfMap);
insilmaril@0
  3057
}
insilmaril@0
  3058
insilmaril@395
  3059
void Main::editDeleteKeepChilds()
insilmaril@98
  3060
{
insilmaril@98
  3061
	if (currentMapEditor())
insilmaril@395
  3062
		currentMapEditor()->deleteKeepChilds();
insilmaril@98
  3063
}
insilmaril@98
  3064
insilmaril@395
  3065
void Main::editDeleteChilds()
insilmaril@98
  3066
{
insilmaril@98
  3067
	if (currentMapEditor())
insilmaril@395
  3068
		currentMapEditor()->deleteChilds();
insilmaril@98
  3069
}
insilmaril@98
  3070
insilmaril@0
  3071
void Main::editDeleteSelection()
insilmaril@0
  3072
{
insilmaril@151
  3073
	if (currentMapEditor() && actionSettingsUseDelKey->isOn())
insilmaril@0
  3074
		currentMapEditor()->deleteSelection();
insilmaril@0
  3075
}
insilmaril@0
  3076
insilmaril@0
  3077
void Main::editUpperBranch()
insilmaril@0
  3078
{
insilmaril@0
  3079
	if (currentMapEditor())
insilmaril@0
  3080
		currentMapEditor()->selectUpperBranch();
insilmaril@0
  3081
}
insilmaril@0
  3082
insilmaril@0
  3083
void Main::editLowerBranch()
insilmaril@0
  3084
{
insilmaril@0
  3085
	if (currentMapEditor())
insilmaril@0
  3086
		currentMapEditor()->selectLowerBranch();
insilmaril@0
  3087
}
insilmaril@0
  3088
insilmaril@0
  3089
void Main::editLeftBranch()
insilmaril@0
  3090
{
insilmaril@0
  3091
	if (currentMapEditor())
insilmaril@0
  3092
		currentMapEditor()->selectLeftBranch();
insilmaril@0
  3093
}
insilmaril@0
  3094
insilmaril@0
  3095
void Main::editRightBranch()
insilmaril@0
  3096
{
insilmaril@0
  3097
	if (currentMapEditor())
insilmaril@0
  3098
		currentMapEditor()->selectRightBranch();
insilmaril@0
  3099
}
insilmaril@0
  3100
insilmaril@0
  3101
void Main::editFirstBranch()
insilmaril@0
  3102
{
insilmaril@0
  3103
	if (currentMapEditor())
insilmaril@0
  3104
		currentMapEditor()->selectFirstBranch();
insilmaril@0
  3105
}
insilmaril@0
  3106
insilmaril@0
  3107
void Main::editLastBranch()
insilmaril@0
  3108
{
insilmaril@0
  3109
	if (currentMapEditor())
insilmaril@0
  3110
		currentMapEditor()->selectLastBranch();
insilmaril@0
  3111
}
insilmaril@0
  3112
insilmaril@0
  3113
void Main::editLoadImage()
insilmaril@0
  3114
{
insilmaril@0
  3115
	if (currentMapEditor())
insilmaril@0
  3116
		currentMapEditor()->loadFloatImage();
insilmaril@0
  3117
}
insilmaril@0
  3118
insilmaril@366
  3119
void Main::editSaveImage()
insilmaril@0
  3120
{
insilmaril@0
  3121
	if (currentMapEditor())
insilmaril@366
  3122
		currentMapEditor()->saveFloatImage();
insilmaril@0
  3123
}
insilmaril@0
  3124
insilmaril@366
  3125
void Main::editFollowXLink(QAction *a)
insilmaril@366
  3126
{
insilmaril@366
  3127
insilmaril@366
  3128
	if (currentMapEditor())
insilmaril@366
  3129
		currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
insilmaril@366
  3130
}
insilmaril@366
  3131
insilmaril@366
  3132
void Main::editEditXLink(QAction *a)
insilmaril@89
  3133
{
insilmaril@89
  3134
	if (currentMapEditor())
insilmaril@366
  3135
		currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
insilmaril@94
  3136
}
insilmaril@94
  3137
insilmaril@0
  3138
void Main::formatSelectColor()
insilmaril@0
  3139
{
insilmaril@0
  3140
	if (currentMapEditor())
insilmaril@0
  3141
	{
insilmaril@395
  3142
		QColor col = QColorDialog::getColor((currentColor ), this );
insilmaril@0
  3143
		if ( !col.isValid() ) return;
insilmaril@0
  3144
		colorChanged( col );
insilmaril@0
  3145
	}	
insilmaril@0
  3146
}
insilmaril@0
  3147
insilmaril@0
  3148
void Main::formatPickColor()
insilmaril@0
  3149
{
insilmaril@0
  3150
	if (currentMapEditor())
insilmaril@395
  3151
		colorChanged( currentMapEditor()->getCurrentHeadingColor() );
insilmaril@0
  3152
}
insilmaril@0
  3153
insilmaril@0
  3154
void Main::colorChanged(QColor c)
insilmaril@0
  3155
{
insilmaril@0
  3156
    QPixmap pix( 16, 16 );
insilmaril@0
  3157
    pix.fill( c );
insilmaril@0
  3158
    actionFormatColor->setIconSet( pix );
insilmaril@395
  3159
	currentColor=c;
insilmaril@0
  3160
}
insilmaril@0
  3161
insilmaril@0
  3162
void Main::formatColorBranch()
insilmaril@0
  3163
{
insilmaril@0
  3164
	if (currentMapEditor())
insilmaril@395
  3165
		currentMapEditor()->colorBranch(currentColor);
insilmaril@0
  3166
}
insilmaril@0
  3167
insilmaril@417
  3168
void Main::formatColorSubtree()
insilmaril@417
  3169
{
insilmaril@417
  3170
	if (currentMapEditor())
insilmaril@417
  3171
		currentMapEditor()->colorSubtree (currentColor);
insilmaril@417
  3172
}
insilmaril@417
  3173
insilmaril@0
  3174
void Main::formatLinkStyleLine()
insilmaril@0
  3175
{
insilmaril@0
  3176
	if (currentMapEditor())
insilmaril@398
  3177
		currentMapEditor()->setMapLinkStyle("StyleLine");
insilmaril@0
  3178
}
insilmaril@0
  3179
insilmaril@0
  3180
void Main::formatLinkStyleParabel()
insilmaril@0
  3181
{
insilmaril@0
  3182
	if (currentMapEditor())
insilmaril@398
  3183
		currentMapEditor()->setMapLinkStyle("StyleParabel");
insilmaril@0
  3184
}
insilmaril@0
  3185
insilmaril@0
  3186
void Main::formatLinkStylePolyLine()
insilmaril@0
  3187
{
insilmaril@0
  3188
	if (currentMapEditor())
insilmaril@398
  3189
		currentMapEditor()->setMapLinkStyle("StylePolyLine");
insilmaril@0
  3190
}
insilmaril@0
  3191
insilmaril@0
  3192
void Main::formatLinkStylePolyParabel()
insilmaril@0
  3193
{
insilmaril@0
  3194
	if (currentMapEditor())
insilmaril@398
  3195
		currentMapEditor()->setMapLinkStyle("StylePolyParabel");
insilmaril@0
  3196
}
insilmaril@0
  3197
insilmaril@0
  3198
void Main::formatSelectBackColor()
insilmaril@0
  3199
{
insilmaril@0
  3200
	if (currentMapEditor())
insilmaril@398
  3201
		currentMapEditor()->selectMapBackgroundColor();
insilmaril@0
  3202
}
insilmaril@0
  3203
insilmaril@408
  3204
void Main::formatSelectBackImage()
insilmaril@408
  3205
{
insilmaril@408
  3206
	if (currentMapEditor())
insilmaril@408
  3207
		currentMapEditor()->selectMapBackgroundImage();
insilmaril@408
  3208
}
insilmaril@408
  3209
insilmaril@0
  3210
void Main::formatSelectLinkColor()
insilmaril@0
  3211
{
insilmaril@0
  3212
	if (currentMapEditor())
insilmaril@398
  3213
		currentMapEditor()->selectMapLinkColor();
insilmaril@0
  3214
}
insilmaril@0
  3215
insilmaril@442
  3216
void Main::formatSelectSelectionColor()
insilmaril@442
  3217
{
insilmaril@442
  3218
	if (currentMapEditor())
insilmaril@442
  3219
		currentMapEditor()->selectMapSelectionColor();
insilmaril@442
  3220
}
insilmaril@442
  3221
insilmaril@0
  3222
void Main::formatToggleLinkColorHint()
insilmaril@0
  3223
{
insilmaril@398
  3224
	currentMapEditor()->toggleMapLinkColorHint();
insilmaril@0
  3225
}
insilmaril@0
  3226
insilmaril@0
  3227
insilmaril@421
  3228
void Main::formatHideLinkUnselected()	//FIXME get rid of this with imagepropertydialog
insilmaril@160
  3229
{
insilmaril@160
  3230
	if (currentMapEditor())
insilmaril@160
  3231
		currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
insilmaril@160
  3232
}
insilmaril@160
  3233
insilmaril@0
  3234
void Main::viewZoomReset()
insilmaril@0
  3235
{
insilmaril@0
  3236
	if (currentMapEditor())
insilmaril@0
  3237
	{
insilmaril@366
  3238
		QMatrix m;
insilmaril@0
  3239
		m.reset();
insilmaril@408
  3240
		currentMapEditor()->setMatrix( m );
insilmaril@0
  3241
	}	
insilmaril@0
  3242
}
insilmaril@0
  3243
insilmaril@0
  3244
void Main::viewZoomIn()
insilmaril@0
  3245
{
insilmaril@0
  3246
	if (currentMapEditor())
insilmaril@0
  3247
	{
insilmaril@408
  3248
		QMatrix m = currentMapEditor()->matrix();
insilmaril@0
  3249
		m.scale( 1.25, 1.25 );
insilmaril@408
  3250
		currentMapEditor()->setMatrix( m );
insilmaril@0
  3251
	}	
insilmaril@0
  3252
}
insilmaril@0
  3253
insilmaril@0
  3254
void Main::viewZoomOut()
insilmaril@0
  3255
{
insilmaril@0
  3256
	if (currentMapEditor())
insilmaril@0
  3257
	{
insilmaril@408
  3258
		QMatrix m = currentMapEditor()->matrix();
insilmaril@0
  3259
		m.scale( 0.8, 0.8 );
insilmaril@408
  3260
		currentMapEditor()->setMatrix( m );
insilmaril@0
  3261
	}	
insilmaril@0
  3262
}
insilmaril@89
  3263
insilmaril@526
  3264
void Main::viewCenter()
insilmaril@526
  3265
{
insilmaril@526
  3266
	MapEditor *me=currentMapEditor();
insilmaril@526
  3267
	if (me)
insilmaril@526
  3268
	{
insilmaril@526
  3269
		me->ensureSelectionVisible();
insilmaril@526
  3270
	}	
insilmaril@526
  3271
}
insilmaril@526
  3272
insilmaril@528
  3273
void Main::networkStartServer()
insilmaril@528
  3274
{
insilmaril@528
  3275
	MapEditor *me=currentMapEditor();
insilmaril@528
  3276
	if (me) me->newServer();
insilmaril@528
  3277
}
insilmaril@528
  3278
insilmaril@528
  3279
void Main::networkConnect()
insilmaril@528
  3280
{
insilmaril@528
  3281
	MapEditor *me=currentMapEditor();
insilmaril@531
  3282
	if (me) me->connectToServer();
insilmaril@528
  3283
}
insilmaril@528
  3284
insilmaril@0
  3285
bool Main::settingsPDF()
insilmaril@0
  3286
{
insilmaril@0
  3287
	// Default browser is set in constructor
insilmaril@0
  3288
	bool ok;
insilmaril@0
  3289
	QString text = QInputDialog::getText(
insilmaril@266
  3290
		"VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
insilmaril@366
  3291
		settings.value("/mainwindow/readerPDF").toString(), &ok, this );
insilmaril@0
  3292
	if (ok)
insilmaril@366
  3293
		settings.setValue ("/mainwindow/readerPDF",text);
insilmaril@0
  3294
	return ok;
insilmaril@0
  3295
}
insilmaril@0
  3296
insilmaril@0
  3297
insilmaril@0
  3298
bool Main::settingsURL()
insilmaril@0
  3299
{
insilmaril@0
  3300
	// Default browser is set in constructor
insilmaril@0
  3301
	bool ok;
insilmaril@0
  3302
	QString text = QInputDialog::getText(
insilmaril@266
  3303
		"VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
insilmaril@366
  3304
		settings.value("/mainwindow/readerURL").toString()
insilmaril@0
  3305
		, &ok, this );
insilmaril@0
  3306
	if (ok)
insilmaril@366
  3307
		settings.setValue ("/mainwindow/readerURL",text);
insilmaril@0
  3308
	return ok;
insilmaril@0
  3309
}
insilmaril@0
  3310
insilmaril@450
  3311
void Main::settingsMacroDir()
insilmaril@450
  3312
{
insilmaril@450
  3313
	QDir defdir=vymBaseDir;
insilmaril@450
  3314
	defdir.cd("macros");
insilmaril@450
  3315
	if (!defdir.exists())
insilmaril@450
  3316
		defdir=vymBaseDir;
insilmaril@450
  3317
	QDir dir=QFileDialog::getExistingDirectory (
insilmaril@450
  3318
		this,
insilmaril@450
  3319
		tr ("Directory with vym macros:"), 
insilmaril@450
  3320
		settings.value ("/macros/macroDir",defdir.path()).toString()
insilmaril@450
  3321
	);
insilmaril@450
  3322
	if (dir.exists())
insilmaril@450
  3323
		settings.setValue ("/macros/macroDir",dir.path());
insilmaril@450
  3324
}
insilmaril@450
  3325
insilmaril@473
  3326
void Main::settingsUndoLevels()
insilmaril@473
  3327
{
insilmaril@473
  3328
	bool ok;
insilmaril@473
  3329
	int i = QInputDialog::getInteger(
insilmaril@473
  3330
		this, 
insilmaril@473
  3331
		tr("QInputDialog::getInteger()"),
insilmaril@473
  3332
	    tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
insilmaril@473
  3333
	if (ok)
insilmaril@473
  3334
	{
insilmaril@473
  3335
		settings.setValue ("/mapeditor/stepsTotal",i);
insilmaril@473
  3336
		QMessageBox::information( this, tr( "VYM -Information:" ),
insilmaril@473
  3337
		   tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i)); 
insilmaril@473
  3338
   }	
insilmaril@473
  3339
}
insilmaril@473
  3340
insilmaril@473
  3341
void Main::settingsAutosaveToggle()
insilmaril@473
  3342
{
insilmaril@531
  3343
	settings.setValue ("/mapeditor/autosave/use",actionSettingsAutosaveToggle->isOn() );
insilmaril@473
  3344
}
insilmaril@473
  3345
insilmaril@473
  3346
void Main::settingsAutosaveTime()
insilmaril@473
  3347
{
insilmaril@473
  3348
	bool ok;
insilmaril@473
  3349
	int i = QInputDialog::getInteger(
insilmaril@473
  3350
		this, 
insilmaril@473
  3351
		tr("QInputDialog::getInteger()"),
insilmaril@473
  3352
	    tr("Number of seconds before autosave:"), settings.value("/mapeditor/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
insilmaril@473
  3353
	if (ok)
insilmaril@473
  3354
	{
insilmaril@473
  3355
		settings.setValue ("/mapeditor/autosave/ms",i * 1000);
insilmaril@473
  3356
    }	
insilmaril@473
  3357
}
insilmaril@473
  3358
insilmaril@327
  3359
void Main::settingsToggleDelKey()
insilmaril@327
  3360
{
insilmaril@327
  3361
	if (actionSettingsUseDelKey->isOn())
insilmaril@327
  3362
	{
insilmaril@366
  3363
		actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
insilmaril@327
  3364
	} else
insilmaril@327
  3365
	{
insilmaril@327
  3366
		actionEditDelete->setAccel (QKeySequence (""));
insilmaril@327
  3367
	}
insilmaril@327
  3368
}
insilmaril@327
  3369
insilmaril@0
  3370
void Main::windowToggleNoteEditor()
insilmaril@0
  3371
{
insilmaril@502
  3372
	if (textEditor->isVisible() )
insilmaril@497
  3373
		windowHideNoteEditor();
insilmaril@497
  3374
	else
insilmaril@497
  3375
		windowShowNoteEditor();
insilmaril@0
  3376
}
insilmaril@0
  3377
insilmaril@294
  3378
void Main::windowToggleHistory()
insilmaril@294
  3379
{
insilmaril@404
  3380
	if (historyWindow->isVisible())
insilmaril@404
  3381
		historyWindow->hide();
insilmaril@404
  3382
	else	
insilmaril@404
  3383
		historyWindow->show();
insilmaril@404
  3384
insilmaril@404
  3385
}
insilmaril@404
  3386
insilmaril@473
  3387
void Main::windowToggleProperty()
insilmaril@473
  3388
{
insilmaril@473
  3389
	if (branchPropertyWindow->isVisible())
insilmaril@473
  3390
		branchPropertyWindow->hide();
insilmaril@473
  3391
	else	
insilmaril@473
  3392
		branchPropertyWindow->show();
insilmaril@486
  3393
insilmaril@473
  3394
	if(currentMapEditor())
insilmaril@473
  3395
	{
insilmaril@473
  3396
		LinkableMapObj *sel=currentMapEditor()->getSelection();
insilmaril@473
  3397
		if (sel && (typeid(*sel) == typeid(BranchObj) ||
insilmaril@473
  3398
		           typeid(*sel) == typeid(MapCenterObj)))
insilmaril@473
  3399
		{
insilmaril@473
  3400
			branchPropertyWindow->setMapEditor(currentMapEditor());
insilmaril@473
  3401
			branchPropertyWindow->setBranch((BranchObj*)sel);
insilmaril@473
  3402
			return;
insilmaril@473
  3403
		}
insilmaril@473
  3404
		
insilmaril@473
  3405
	}	
insilmaril@473
  3406
	branchPropertyWindow->setBranch(NULL);
insilmaril@473
  3407
}
insilmaril@473
  3408
insilmaril@408
  3409
void Main::windowToggleAntiAlias()
insilmaril@408
  3410
{
insilmaril@408
  3411
	bool b=actionViewToggleAntiAlias->isOn();
insilmaril@408
  3412
	MapEditor *me;
insilmaril@408
  3413
	for (int i=0;i<tabWidget->count();i++)
insilmaril@408
  3414
	{
insilmaril@408
  3415
		
insilmaril@408
  3416
		me=(MapEditor*)tabWidget->page(i);
insilmaril@408
  3417
		me->setAntiAlias(b);
insilmaril@408
  3418
	}	
insilmaril@408
  3419
insilmaril@408
  3420
}
insilmaril@408
  3421
insilmaril@408
  3422
void Main::windowToggleSmoothPixmap()
insilmaril@408
  3423
{
insilmaril@408
  3424
	bool b=actionViewToggleSmoothPixmapTransform->isOn();
insilmaril@408
  3425
	MapEditor *me;
insilmaril@408
  3426
	for (int i=0;i<tabWidget->count();i++)
insilmaril@408
  3427
	{
insilmaril@408
  3428
		
insilmaril@408
  3429
		me=(MapEditor*)tabWidget->page(i);
insilmaril@408
  3430
		me->setSmoothPixmap(b);
insilmaril@408
  3431
	}	
insilmaril@408
  3432
}
insilmaril@408
  3433
insilmaril@404
  3434
void Main::updateHistory(SimpleSettings &undoSet)
insilmaril@404
  3435
{
insilmaril@404
  3436
	historyWindow->update (undoSet);
insilmaril@294
  3437
}
insilmaril@294
  3438
insilmaril@160
  3439
void Main::updateNoteFlag()
insilmaril@160
  3440
{
insilmaril@160
  3441
	if (currentMapEditor())
insilmaril@160
  3442
		currentMapEditor()->updateNoteFlag();
insilmaril@160
  3443
}
insilmaril@160
  3444
insilmaril@442
  3445
void Main::updateSatellites(MapEditor *me)
insilmaril@442
  3446
{
insilmaril@442
  3447
	branchPropertyWindow->setMapEditor (me);
insilmaril@442
  3448
}
insilmaril@442
  3449
insilmaril@390
  3450
void Main::updateActions()
insilmaril@390
  3451
{
insilmaril@390
  3452
	MapEditor *me=currentMapEditor();
insilmaril@390
  3453
	if (!me) return;
insilmaril@390
  3454
insilmaril@491
  3455
	historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(currentMapEditor()->getFileName()));
insilmaril@407
  3456
insilmaril@390
  3457
	// updateActions is also called when NoteEditor is closed
insilmaril@486
  3458
	actionViewToggleNoteEditor->setOn (textEditor->isVisible());
insilmaril@486
  3459
	actionViewToggleHistoryWindow->setOn (historyWindow->isVisible());
insilmaril@486
  3460
	actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible());
insilmaril@390
  3461
insilmaril@473
  3462
	if (me->getMapLinkColorHint()==LinkableMapObj::HeadingColor) 
insilmaril@390
  3463
		actionFormatLinkColorHint->setOn(true);
insilmaril@390
  3464
	else	
insilmaril@390
  3465
		actionFormatLinkColorHint->setOn(false);
insilmaril@390
  3466
insilmaril@398
  3467
	switch (me->getMapLinkStyle())
insilmaril@390
  3468
	{
insilmaril@473
  3469
		case LinkableMapObj::Line: 
insilmaril@390
  3470
			actionFormatLinkStyleLine->setOn(true);
insilmaril@390
  3471
			break;
insilmaril@473
  3472
		case LinkableMapObj::Parabel:
insilmaril@390
  3473
			actionFormatLinkStyleParabel->setOn(true);
insilmaril@390
  3474
			break;
insilmaril@473
  3475
		case LinkableMapObj::PolyLine:	
insilmaril@390
  3476
			actionFormatLinkStylePolyLine->setOn(true);
insilmaril@390
  3477
			break;
insilmaril@473
  3478
		case LinkableMapObj::PolyParabel:	
insilmaril@390
  3479
			actionFormatLinkStylePolyParabel->setOn(true);
insilmaril@390
  3480
			break;
insilmaril@390
  3481
		default:
insilmaril@390
  3482
			break;
insilmaril@390
  3483
	}	
insilmaril@390
  3484
insilmaril@442
  3485
	// Update colors
insilmaril@390
  3486
	QPixmap pix( 16, 16 );
insilmaril@398
  3487
    pix.fill( me->getMapBackgroundColor() );
insilmaril@390
  3488
    actionFormatBackColor->setIconSet( pix );
insilmaril@442
  3489
    pix.fill( me->getSelectionColor() );
insilmaril@442
  3490
    actionFormatSelectionColor->setIconSet( pix );
insilmaril@398
  3491
    pix.fill( me->getMapDefLinkColor() );
insilmaril@390
  3492
    actionFormatLinkColor->setIconSet( pix );
insilmaril@390
  3493
insilmaril@442
  3494
insilmaril@486
  3495
	actionFileSave->setEnabled( me->hasChanged() );
insilmaril@390
  3496
	if (me->isUndoAvailable())
insilmaril@390
  3497
		actionEditUndo->setEnabled( true);
insilmaril@390
  3498
	else	
insilmaril@390
  3499
		actionEditUndo->setEnabled( false);
insilmaril@390
  3500
insilmaril@390
  3501
	if (me->isRedoAvailable())
insilmaril@390
  3502
		actionEditRedo->setEnabled( true);
insilmaril@390
  3503
	else	
insilmaril@390
  3504
		actionEditRedo->setEnabled( false);
insilmaril@390
  3505
insilmaril@390
  3506
	LinkableMapObj *selection=me->getSelection();
insilmaril@390
  3507
	if (selection)
insilmaril@390
  3508
	{
insilmaril@390
  3509
		if ( (typeid(*selection) == typeid(BranchObj)) || 
insilmaril@390
  3510
			(typeid(*selection) == typeid(MapCenterObj))  )
insilmaril@390
  3511
		{
insilmaril@390
  3512
			BranchObj *bo=(BranchObj*)selection;
insilmaril@390
  3513
			// Take care of links
insilmaril@390
  3514
			if (bo->countXLinks()==0)
insilmaril@390
  3515
			{
insilmaril@390
  3516
				branchXLinksContextMenuEdit->clear();
insilmaril@390
  3517
				branchXLinksContextMenuFollow->clear();
insilmaril@390
  3518
			} else
insilmaril@390
  3519
			{
insilmaril@390
  3520
				BranchObj *bot;
insilmaril@390
  3521
				QString s;
insilmaril@390
  3522
				branchXLinksContextMenuEdit->clear();
insilmaril@390
  3523
				branchXLinksContextMenuFollow->clear();
insilmaril@390
  3524
				for (int i=0; i<=bo->countXLinks();i++)
insilmaril@390
  3525
				{
insilmaril@390
  3526
					bot=bo->XLinkTargetAt(i);
insilmaril@390
  3527
					if (bot)
insilmaril@390
  3528
					{
insilmaril@390
  3529
						s=bot->getHeading();
insilmaril@390
  3530
						if (s.length()>25)
insilmaril@390
  3531
							s=s.left(25)+"...";
insilmaril@390
  3532
						branchXLinksContextMenuFollow->addAction (s);
insilmaril@390
  3533
						branchXLinksContextMenuEdit->addAction (s);
insilmaril@390
  3534
					}	
insilmaril@390
  3535
				}
insilmaril@390
  3536
			}
insilmaril@390
  3537
insilmaril@390
  3538
			standardFlagsDefault->setEnabled (true);
insilmaril@390
  3539
insilmaril@390
  3540
			actionEditToggleScroll->setEnabled (true);
insilmaril@390
  3541
			if ( bo->isScrolled() )
insilmaril@390
  3542
				actionEditToggleScroll->setOn(true);
insilmaril@390
  3543
			else	
insilmaril@390
  3544
				actionEditToggleScroll->setOn(false);
insilmaril@390
  3545
insilmaril@390
  3546
			if ( bo->getURL().isEmpty() )
insilmaril@390
  3547
			{
insilmaril@390
  3548
				actionEditOpenURL->setEnabled (false);
insilmaril@390
  3549
				actionEditOpenURLTab->setEnabled (false);
insilmaril@390
  3550
			}	
insilmaril@390
  3551
			else	
insilmaril@390
  3552
			{
insilmaril@390
  3553
				actionEditOpenURL->setEnabled (true);
insilmaril@390
  3554
				actionEditOpenURLTab->setEnabled (true);
insilmaril@390
  3555
			}
insilmaril@390
  3556
			if ( bo->getVymLink().isEmpty() )
insilmaril@390
  3557
			{
insilmaril@390
  3558
				actionEditOpenVymLink->setEnabled (false);
insilmaril@390
  3559
				actionEditDeleteVymLink->setEnabled (false);
insilmaril@390
  3560
			} else	
insilmaril@390
  3561
			{
insilmaril@390
  3562
				actionEditOpenVymLink->setEnabled (true);
insilmaril@390
  3563
				actionEditDeleteVymLink->setEnabled (true);
insilmaril@390
  3564
			}	
insilmaril@390
  3565
insilmaril@390
  3566
			if (bo->canMoveBranchUp()) 
insilmaril@390
  3567
				actionEditMoveUp->setEnabled (true);
insilmaril@390
  3568
			else	
insilmaril@390
  3569
				actionEditMoveUp->setEnabled (false);
insilmaril@390
  3570
			if (bo->canMoveBranchDown()) 
insilmaril@390
  3571
				actionEditMoveDown->setEnabled (true);
insilmaril@390
  3572
			else	
insilmaril@390
  3573
				actionEditMoveDown->setEnabled (false);
insilmaril@390
  3574
insilmaril@390
  3575
insilmaril@390
  3576
			actionEditToggleHideExport->setEnabled (true);	
insilmaril@390
  3577
			actionEditToggleHideExport->setOn (bo->hideInExport() );	
insilmaril@390
  3578
insilmaril@390
  3579
			actionEditCopy->setEnabled (true);	
insilmaril@390
  3580
			actionEditCut->setEnabled (true);	
insilmaril@390
  3581
			if (!clipboardEmpty)
insilmaril@390
  3582
				actionEditPaste->setEnabled (true);	
insilmaril@390
  3583
			else	
insilmaril@390
  3584
				actionEditPaste->setEnabled (false);	
insilmaril@406
  3585
			for (int i=0; i<actionListBranches.size(); ++i)	
insilmaril@406
  3586
				actionListBranches.at(i)->setEnabled(true);
insilmaril@390
  3587
			actionEditDelete->setEnabled (true);
insilmaril@390
  3588
			actionFormatHideLinkUnselected->setOn
insilmaril@390
  3589
				(selection->getHideLinkUnselected());
insilmaril@390
  3590
		}
insilmaril@390
  3591
		if ( (typeid(*selection) == typeid(FloatImageObj)) )
insilmaril@390
  3592
		{
insilmaril@390
  3593
			FloatObj *fo=(FloatImageObj*)selection;
insilmaril@390
  3594
insilmaril@390
  3595
			actionEditOpenURL->setEnabled (false);
insilmaril@390
  3596
			actionEditOpenVymLink->setEnabled (false);
insilmaril@390
  3597
			actionEditDeleteVymLink->setEnabled (false);	
insilmaril@390
  3598
			actionEditToggleHideExport->setEnabled (true);	
insilmaril@390
  3599
			actionEditToggleHideExport->setOn (fo->hideInExport() );	
insilmaril@390
  3600
insilmaril@390
  3601
insilmaril@390
  3602
			actionEditCopy->setEnabled (true);
insilmaril@390
  3603
			actionEditCut->setEnabled (true);	
insilmaril@390
  3604
			actionEditPaste->setEnabled (false);
insilmaril@406
  3605
			for (int i=0; i<actionListBranches.size(); ++i)	
insilmaril@406
  3606
				actionListBranches.at(i)->setEnabled(false);
insilmaril@390
  3607
			actionEditDelete->setEnabled (true);
insilmaril@390
  3608
			actionFormatHideLinkUnselected->setOn
insilmaril@390
  3609
				( selection->getHideLinkUnselected());
insilmaril@390
  3610
			actionEditMoveUp->setEnabled (false);
insilmaril@390
  3611
			actionEditMoveDown->setEnabled (false);
insilmaril@390
  3612
		}
insilmaril@390
  3613
insilmaril@390
  3614
	} else
insilmaril@390
  3615
	{
insilmaril@390
  3616
		actionEditCopy->setEnabled (false);	
insilmaril@390
  3617
		actionEditCut->setEnabled (false);	
insilmaril@390
  3618
		actionEditPaste->setEnabled (false);	
insilmaril@406
  3619
		for (int i=0; i<actionListBranches.size(); ++i)	
insilmaril@406
  3620
			actionListBranches.at(i)->setEnabled(false);
insilmaril@390
  3621
insilmaril@390
  3622
		actionEditToggleScroll->setEnabled (false);
insilmaril@390
  3623
		actionEditOpenURL->setEnabled (false);
insilmaril@390
  3624
		actionEditOpenVymLink->setEnabled (false);
insilmaril@390
  3625
		actionEditDeleteVymLink->setEnabled (false);	
insilmaril@390
  3626
		actionEditHeading2URL->setEnabled (false);	
insilmaril@390
  3627
		actionEditDelete->setEnabled (false);
insilmaril@390
  3628
		actionEditMoveUp->setEnabled (false);
insilmaril@390
  3629
		actionEditMoveDown->setEnabled (false);
insilmaril@390
  3630
		actionEditToggleHideExport->setEnabled (false);	
insilmaril@390
  3631
	}	
insilmaril@390
  3632
}
insilmaril@390
  3633
insilmaril@473
  3634
Main::ModMode Main::getModMode()
insilmaril@390
  3635
{
insilmaril@390
  3636
	if (actionModModeColor->isOn()) return ModModeColor;
insilmaril@390
  3637
	if (actionModModeCopy->isOn()) return ModModeCopy;
insilmaril@390
  3638
	if (actionModModeXLink->isOn()) return ModModeXLink;
insilmaril@390
  3639
	return ModModeNone;
insilmaril@390
  3640
}
insilmaril@390
  3641
insilmaril@537
  3642
bool Main::autoEditNewBranch()
insilmaril@390
  3643
{
insilmaril@537
  3644
	return actionSettingsAutoEditNewBranch->isOn();
insilmaril@390
  3645
}
insilmaril@390
  3646
insilmaril@537
  3647
bool Main::autoSelectNewBranch()
insilmaril@390
  3648
{
insilmaril@537
  3649
	return actionSettingsAutoSelectNewBranch->isOn();
insilmaril@390
  3650
}
insilmaril@390
  3651
insilmaril@390
  3652
bool Main::useFlagGroups()
insilmaril@390
  3653
{
insilmaril@390
  3654
	return actionSettingsUseFlagGroups->isOn();
insilmaril@390
  3655
}
insilmaril@390
  3656
insilmaril@0
  3657
void Main::windowShowNoteEditor()
insilmaril@0
  3658
{
insilmaril@497
  3659
	textEditor->setShowWithMain(true);
insilmaril@0
  3660
	textEditor->show();
insilmaril@0
  3661
	actionViewToggleNoteEditor->setOn (true);
insilmaril@0
  3662
}
insilmaril@0
  3663
insilmaril@0
  3664
void Main::windowHideNoteEditor()
insilmaril@0
  3665
{
insilmaril@497
  3666
	textEditor->setShowWithMain(false);
insilmaril@0
  3667
	textEditor->hide();
insilmaril@0
  3668
	actionViewToggleNoteEditor->setOn (false);
insilmaril@0
  3669
}
insilmaril@0
  3670
insilmaril@434
  3671
void Main::setScript (const QString &script)
insilmaril@434
  3672
{
insilmaril@434
  3673
	scriptEditor->setScript (script);
insilmaril@434
  3674
}
insilmaril@434
  3675
insilmaril@434
  3676
void Main::runScript (const QString &script)
insilmaril@432
  3677
{
insilmaril@432
  3678
	if (currentMapEditor())
insilmaril@432
  3679
		currentMapEditor()->runScript (script);
insilmaril@432
  3680
}
insilmaril@432
  3681
insilmaril@514
  3682
void Main::runScriptEverywhere (const QString &script)
insilmaril@514
  3683
{
insilmaril@514
  3684
	MapEditor *me;
insilmaril@514
  3685
	for (int i=0;i<=tabWidget->count() -1;i++)
insilmaril@514
  3686
	{
insilmaril@514
  3687
		me=(MapEditor*)tabWidget->page(i);
insilmaril@514
  3688
		if (me) me->runScript (script);
insilmaril@514
  3689
	}	
insilmaril@514
  3690
}
insilmaril@514
  3691
insilmaril@0
  3692
void Main::windowNextEditor()
insilmaril@0
  3693
{
insilmaril@0
  3694
	if (tabWidget->currentPageIndex() < tabWidget->count())
insilmaril@0
  3695
		tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
insilmaril@0
  3696
}
insilmaril@0
  3697
insilmaril@0
  3698
void Main::windowPreviousEditor()
insilmaril@0
  3699
{
insilmaril@0
  3700
	if (tabWidget->currentPageIndex() >0)
insilmaril@0
  3701
		tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
insilmaril@0
  3702
}
insilmaril@0
  3703
insilmaril@0
  3704
void Main::standardFlagChanged()
insilmaril@0
  3705
{
insilmaril@421
  3706
	if (currentMapEditor())
insilmaril@421
  3707
		currentMapEditor()->toggleStandardFlag(sender()->name());
insilmaril@0
  3708
}
insilmaril@0
  3709
insilmaril@527
  3710
void Main::testFunction1()
insilmaril@0
  3711
{
insilmaril@393
  3712
	if (!currentMapEditor()) return;
insilmaril@564
  3713
	currentMapEditor()->testFunction1();
insilmaril@527
  3714
}
insilmaril@527
  3715
insilmaril@527
  3716
void Main::testFunction2()
insilmaril@527
  3717
{
insilmaril@527
  3718
	if (!currentMapEditor()) return;
insilmaril@564
  3719
	currentMapEditor()->testFunction2();
insilmaril@0
  3720
}
insilmaril@0
  3721
insilmaril@393
  3722
void Main::testCommand()
insilmaril@393
  3723
{
insilmaril@393
  3724
	if (!currentMapEditor()) return;
insilmaril@432
  3725
	scriptEditor->show();
insilmaril@432
  3726
	/*
insilmaril@393
  3727
	bool ok;
insilmaril@393
  3728
	QString com = QInputDialog::getText(
insilmaril@404
  3729
			vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
insilmaril@393
  3730
	if (ok) currentMapEditor()->parseAtom(com);
insilmaril@432
  3731
	*/
insilmaril@393
  3732
}
insilmaril@393
  3733
insilmaril@0
  3734
void Main::helpDoc()
insilmaril@0
  3735
{
insilmaril@395
  3736
	QString locale = QLocale::system().name();
insilmaril@395
  3737
	QString docname;
insilmaril@395
  3738
	if (locale.left(2)=="es")
insilmaril@395
  3739
		docname="vym_es.pdf";
insilmaril@395
  3740
	else	
insilmaril@395
  3741
		docname="vym.pdf";
insilmaril@420
  3742
insilmaril@420
  3743
	QStringList searchList;
insilmaril@395
  3744
	QDir docdir;
insilmaril@103
  3745
	#if defined(Q_OS_MACX)
insilmaril@537
  3746
		searchList << "./vym.app/Contents/Resources/doc";
insilmaril@103
  3747
	#else
insilmaril@103
  3748
		// default path in SUSE LINUX
insilmaril@420
  3749
		searchList <<"/usr/share/doc/packages/vym/doc";
insilmaril@103
  3750
	#endif
insilmaril@0
  3751
insilmaril@420
  3752
	searchList << "doc";	// relative path for easy testing in tarball
insilmaril@420
  3753
	searchList << "doc/tex";	// Easy testing working on vym.tex
insilmaril@420
  3754
	searchList << "/usr/share/doc/vym";	// Debian
insilmaril@420
  3755
	searchList << "/usr/share/doc/packages";// Knoppix
insilmaril@420
  3756
insilmaril@420
  3757
	bool found=false;
insilmaril@420
  3758
	QFile docfile;
insilmaril@420
  3759
	for (int i=0; i<searchList.count(); ++i)
insilmaril@0
  3760
	{
insilmaril@420
  3761
		docfile.setFileName(QDir::convertSeparators(searchList.at(i)+"/"+docname));
insilmaril@420
  3762
		if (docfile.exists() )
insilmaril@0
  3763
		{
insilmaril@420
  3764
			found=true;
insilmaril@420
  3765
			break;
insilmaril@420
  3766
		}	
insilmaril@420
  3767
insilmaril@0
  3768
	}
insilmaril@420
  3769
	if (!found)
insilmaril@420
  3770
	{
insilmaril@420
  3771
		QMessageBox::critical(0, 
insilmaril@420
  3772
			tr("Critcal error"),
insilmaril@420
  3773
			tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
insilmaril@420
  3774
		return;
insilmaril@420
  3775
	}	
insilmaril@420
  3776
insilmaril@408
  3777
	QStringList args;
insilmaril@0
  3778
	Process *pdfProc = new Process();
insilmaril@420
  3779
	args <<docfile.fileName();
insilmaril@420
  3780
insilmaril@420
  3781
	pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
insilmaril@408
  3782
	if ( !pdfProc->waitForStarted() ) 
insilmaril@0
  3783
	{
insilmaril@0
  3784
		// error handling
insilmaril@266
  3785
		QMessageBox::warning(0, 
insilmaril@266
  3786
			tr("Warning"),
insilmaril@420
  3787
			tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
insilmaril@266
  3788
			tr("Please use Settings->")+tr("Set application to open PDF files"));
insilmaril@266
  3789
		settingsPDF();	
insilmaril@0
  3790
		return;
insilmaril@0
  3791
	}
insilmaril@0
  3792
}
insilmaril@0
  3793
insilmaril@0
  3794
insilmaril@505
  3795
void Main::helpDemo()
insilmaril@505
  3796
{
insilmaril@505
  3797
	QStringList filters;
insilmaril@505
  3798
	filters <<"VYM example map (*.vym)";
insilmaril@505
  3799
	QFileDialog *fd=new QFileDialog( this);
insilmaril@505
  3800
	fd->setDir (QDir(vymBaseDir.path()+"/demos"));
insilmaril@505
  3801
	fd->setFileMode (QFileDialog::ExistingFiles);
insilmaril@505
  3802
	fd->setFilters (filters);
insilmaril@505
  3803
	fd->setCaption(vymName+ " - " +tr("Load vym example map"));
insilmaril@505
  3804
	fd->show();
insilmaril@505
  3805
insilmaril@505
  3806
	QString fn;
insilmaril@505
  3807
	if ( fd->exec() == QDialog::Accepted )
insilmaril@505
  3808
	{
insilmaril@505
  3809
		lastFileDir=fd->directory().path();
insilmaril@505
  3810
	    QStringList flist = fd->selectedFiles();
insilmaril@505
  3811
		QStringList::Iterator it = flist.begin();
insilmaril@505
  3812
		while( it != flist.end() ) 
insilmaril@505
  3813
		{
insilmaril@505
  3814
			fn = *it;
insilmaril@505
  3815
			fileLoad(*it, NewMap);				   
insilmaril@505
  3816
			++it;
insilmaril@505
  3817
		}
insilmaril@505
  3818
	}
insilmaril@505
  3819
	delete (fd);
insilmaril@505
  3820
}
insilmaril@505
  3821
insilmaril@505
  3822
insilmaril@0
  3823
void Main::helpAbout()
insilmaril@0
  3824
{
insilmaril@148
  3825
	AboutDialog ad;
insilmaril@150
  3826
	ad.setName ("aboutwindow");
insilmaril@148
  3827
	ad.setMinimumSize(500,500);
insilmaril@148
  3828
	ad.resize (QSize (500,500));
insilmaril@148
  3829
	ad.exec();
insilmaril@0
  3830
}
insilmaril@0
  3831
insilmaril@0
  3832
void Main::helpAboutQT()
insilmaril@0
  3833
{
insilmaril@0
  3834
	QMessageBox::aboutQt( this, "Qt Application Example" );
insilmaril@0
  3835
}
insilmaril@0
  3836
insilmaril@445
  3837
void Main::callMacro ()
insilmaril@445
  3838
{
insilmaril@445
  3839
    QAction *action = qobject_cast<QAction *>(sender());
insilmaril@445
  3840
	int i=-1;
insilmaril@445
  3841
    if (action)
insilmaril@445
  3842
	{
insilmaril@445
  3843
        i=action->data().toInt();
insilmaril@447
  3844
		QString mDir (settings.value ("macros/macroDir").toString() );
insilmaril@447
  3845
insilmaril@447
  3846
		QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
insilmaril@447
  3847
		QFile f (fn);
insilmaril@447
  3848
		if ( !f.open( QIODevice::ReadOnly ) )
insilmaril@447
  3849
		{
insilmaril@447
  3850
			QMessageBox::warning(0, 
insilmaril@447
  3851
				tr("Warning"),
insilmaril@447
  3852
				tr("Couldn't find a macro at  %1.\n").arg(fn)+
insilmaril@447
  3853
				tr("Please use Settings->")+tr("Set directory for vym macros"));
insilmaril@447
  3854
			return;
insilmaril@447
  3855
		}	
insilmaril@447
  3856
insilmaril@447
  3857
		QTextStream ts( &f );
insilmaril@447
  3858
		QString m= ts.read();
insilmaril@447
  3859
insilmaril@445
  3860
		if (! m.isEmpty())
insilmaril@445
  3861
		{
insilmaril@447
  3862
			//cout <<"Main::callMacro  m="<<m.ascii()<<endl;
insilmaril@445
  3863
			currentMapEditor()->runScript (m);
insilmaril@445
  3864
		}	
insilmaril@445
  3865
	}	
insilmaril@445
  3866
}
insilmaril@445
  3867