mainwindow.cpp
author insilmaril
Wed, 10 Jan 2007 13:26:12 +0000
changeset 420 b7447adddc9a
parent 417 1cc7bbf75f0b
child 421 5522d1da7e37
permissions -rw-r--r--
Fixed relinking of floats undo/redo
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@205
     8
#include "exportoofiledialog.h"
insilmaril@228
     9
#include "exports.h"
insilmaril@205
    10
#include "exportxhtmldialog.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@0
    21
insilmaril@0
    22
extern TextEditor *textEditor;
insilmaril@0
    23
extern Main *mainWindow;
insilmaril@164
    24
extern QString tmpVymDir;
insilmaril@166
    25
extern QString clipboardDir;
insilmaril@166
    26
extern bool clipboardEmpty;
insilmaril@0
    27
extern int statusbarTime;
insilmaril@0
    28
extern FlagRowObj* standardFlagsDefault;
insilmaril@166
    29
extern FlagRowObj* systemFlagsDefault;
insilmaril@404
    30
extern QString vymName;
insilmaril@404
    31
extern QString vymVersion;
insilmaril@404
    32
extern QString vymBuildDate;
insilmaril@0
    33
insilmaril@390
    34
QMenu* branchContextMenu;
insilmaril@390
    35
QMenu* branchAddContextMenu;
insilmaril@390
    36
QMenu* branchRemoveContextMenu;
insilmaril@390
    37
QMenu* branchLinksContextMenu;
insilmaril@390
    38
QMenu* branchXLinksContextMenuEdit;
insilmaril@390
    39
QMenu* branchXLinksContextMenuFollow;
insilmaril@390
    40
QMenu* floatimageContextMenu;
insilmaril@390
    41
QMenu* canvasContextMenu;
insilmaril@390
    42
QMenu* fileLastMapsMenu;
insilmaril@390
    43
QMenu* fileImportMenu;
insilmaril@390
    44
QMenu* fileExportMenu;
insilmaril@0
    45
insilmaril@0
    46
insilmaril@0
    47
extern Settings settings;
insilmaril@0
    48
extern Options options;
insilmaril@366
    49
extern ImageIO imageIO;
insilmaril@366
    50
insilmaril@269
    51
extern QDir vymBaseDir;
insilmaril@366
    52
extern QDir lastImageDir;
insilmaril@366
    53
extern QDir lastFileDir;
insilmaril@269
    54
extern QString iconPath;
insilmaril@269
    55
extern QString flagsPath;
insilmaril@0
    56
insilmaril@366
    57
Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
insilmaril@0
    58
    QMainWindow(parent,name,f)
insilmaril@0
    59
{
insilmaril@0
    60
	mainWindow=this;
insilmaril@0
    61
insilmaril@0
    62
	setCaption ("VYM - View Your Mind");
insilmaril@0
    63
insilmaril@0
    64
	// Load window settings
insilmaril@366
    65
	resize (settings.value( "/mainwindow/geometry/size",QSize (800,600)).toSize());
insilmaril@366
    66
	move   (settings.value( "/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
insilmaril@0
    67
insilmaril@0
    68
insilmaril@394
    69
	// Sometimes we may need to remember old selections
insilmaril@394
    70
	prevSelection="";
insilmaril@394
    71
insilmaril@395
    72
	// Default color
insilmaril@395
    73
	currentColor=Qt::black;
insilmaril@395
    74
insilmaril@164
    75
	// Create unique temporary directory
insilmaril@366
    76
	bool ok;
insilmaril@366
    77
	tmpVymDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
insilmaril@366
    78
	if (!ok)
insilmaril@366
    79
	{
insilmaril@366
    80
		qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
insilmaril@366
    81
		exit (1);
insilmaril@366
    82
	}
insilmaril@164
    83
insilmaril@166
    84
	// Create direcctory for clipboard
insilmaril@166
    85
	clipboardDir=tmpVymDir+"/clipboard";
insilmaril@166
    86
	QDir d(clipboardDir);
insilmaril@166
    87
	d.mkdir (clipboardDir,true);
insilmaril@166
    88
	makeSubDirs (clipboardDir);
insilmaril@166
    89
	clipboardEmpty=true;
insilmaril@164
    90
insilmaril@266
    91
	procBrowser=NULL;
insilmaril@266
    92
insilmaril@404
    93
	// Initialize history window;
insilmaril@404
    94
	historyWindow=new HistoryWindow();
insilmaril@93
    95
insilmaril@0
    96
	// Initialize some settings, which are platform dependant
insilmaril@0
    97
	QString p,s;
insilmaril@0
    98
insilmaril@0
    99
		// application to open URLs
insilmaril@366
   100
		p="/mainwindow/readerURL";
insilmaril@0
   101
		#if defined(Q_OS_LINUX)
insilmaril@366
   102
			s=settings.value (p,"konqueror").toString();
insilmaril@0
   103
		#else
insilmaril@0
   104
			#if defined(Q_OS_MACX)
insilmaril@366
   105
				s=settings.value (p,"/usr/bin/open").toString();
insilmaril@0
   106
			#else
insilmaril@366
   107
				s=settings.value (p,"mozilla");
insilmaril@0
   108
			#endif
insilmaril@0
   109
		#endif
insilmaril@366
   110
		settings.setValue( p,s);
insilmaril@0
   111
insilmaril@0
   112
		// application to open PDFs
insilmaril@366
   113
		p="/mainwindow/readerPDF";
insilmaril@0
   114
		#if defined(Q_OS_LINUX)
insilmaril@366
   115
			s=settings.value (p,"acroread").toString();
insilmaril@0
   116
		#else
insilmaril@0
   117
			#if defined(Q_OS_MACX)
insilmaril@366
   118
				s=settings.value (p,"/usr/bin/open").toString();
insilmaril@0
   119
			#else
insilmaril@366
   120
				s=settings.value (p,"acroread").toString();
insilmaril@0
   121
			#endif
insilmaril@0
   122
		#endif
insilmaril@366
   123
		settings.setValue( p,s);
insilmaril@0
   124
insilmaril@0
   125
	
insilmaril@0
   126
	// Create tab widget which holds the maps
insilmaril@0
   127
	tabWidget= new QTabWidget (this);
insilmaril@0
   128
	connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ), 
insilmaril@0
   129
		this, SLOT( editorChanged( QWidget * ) ) );
insilmaril@0
   130
insilmaril@366
   131
	lineedit=new QLineEdit (this);
insilmaril@366
   132
	lineedit->hide();
insilmaril@366
   133
insilmaril@0
   134
	setCentralWidget(tabWidget);	
insilmaril@0
   135
insilmaril@0
   136
    setupFileActions();
insilmaril@0
   137
    setupEditActions();
insilmaril@0
   138
    setupFormatActions();
insilmaril@0
   139
    setupViewActions();
insilmaril@89
   140
    setupModeActions();
insilmaril@0
   141
	setupFlagActions();
insilmaril@0
   142
    setupSettingsActions();
insilmaril@0
   143
	setupContextMenus();
insilmaril@366
   144
    if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
insilmaril@0
   145
    setupHelpActions();
insilmaril@0
   146
    
insilmaril@0
   147
    statusBar();
insilmaril@0
   148
insilmaril@366
   149
	restoreState (settings.value("/mainwindow/state",0).toByteArray());
insilmaril@0
   150
insilmaril@0
   151
	// Initialize Find window
insilmaril@374
   152
	findWindow=new FindWindow(NULL);
insilmaril@374
   153
	findWindow->move (x(),y()+70);
insilmaril@0
   154
	connect (findWindow, SIGNAL( findButton(QString) ), 
insilmaril@0
   155
		this, SLOT(editFind(QString) ) );	
insilmaril@0
   156
	connect (findWindow, SIGNAL( somethingChanged() ), 
insilmaril@0
   157
		this, SLOT(editFindChanged() ) );	
insilmaril@0
   158
insilmaril@160
   159
	// Connect TextEditor, so that we can update flags if text changes
insilmaril@160
   160
	connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
insilmaril@393
   161
	connect (textEditor, SIGNAL (textEditorClosed() ), this, SLOT (updateActions()));
insilmaril@160
   162
insilmaril@0
   163
	updateGeometry();
insilmaril@0
   164
}
insilmaril@0
   165
insilmaril@0
   166
Main::~Main()
insilmaril@0
   167
{
insilmaril@0
   168
	// Save Settings
insilmaril@366
   169
	settings.setValue ( "/mainwindow/geometry/size", size() );
insilmaril@366
   170
	settings.setValue ( "/mainwindow/geometry/pos", pos() );
insilmaril@366
   171
	settings.setValue ("/mainwindow/state",saveState(0));
insilmaril@366
   172
insilmaril@408
   173
	settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
insilmaril@408
   174
	settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
insilmaril@404
   175
	settings.setValue( "/version/version", vymVersion );
insilmaril@404
   176
	settings.setValue( "/version/builddate", vymBuildDate );
insilmaril@366
   177
insilmaril@390
   178
	settings.setValue( "/mapeditor/editmode/autoSelectHeading",actionSettingsAutoSelectHeading->isOn() );
insilmaril@390
   179
	settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
insilmaril@390
   180
	settings.setValue( "/mapeditor/editmode/autoEdit",actionSettingsAutoEdit->isOn() );
insilmaril@366
   181
	settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
insilmaril@366
   182
	settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
insilmaril@366
   183
	settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
insilmaril@0
   184
insilmaril@404
   185
	// call the destructors
insilmaril@0
   186
	delete (textEditor);
insilmaril@404
   187
	delete historyWindow;
insilmaril@164
   188
insilmaril@164
   189
	// Remove temporary directory
insilmaril@164
   190
	removeDir (QDir(tmpVymDir));
insilmaril@0
   191
}
insilmaril@0
   192
insilmaril@0
   193
void Main::loadCmdLine()
insilmaril@0
   194
{
insilmaril@0
   195
	/* TODO draw some kind of splashscreen while loading...
insilmaril@0
   196
	if (qApp->argc()>1)
insilmaril@0
   197
	{
insilmaril@0
   198
	}
insilmaril@0
   199
	*/
insilmaril@0
   200
	
insilmaril@0
   201
	QStringList flist=options.getFileList();
insilmaril@0
   202
	QStringList::Iterator it=flist.begin();
insilmaril@0
   203
insilmaril@0
   204
	while (it !=flist.end() )
insilmaril@0
   205
	{
insilmaril@0
   206
		fileLoad (*it, NewMap);
insilmaril@0
   207
		*it++;
insilmaril@0
   208
	}	
insilmaril@0
   209
}
insilmaril@0
   210
insilmaril@0
   211
insilmaril@0
   212
void Main::statusMessage(const QString &s)
insilmaril@0
   213
{
insilmaril@0
   214
	statusBar()->message (s);
insilmaril@0
   215
}
insilmaril@0
   216
insilmaril@0
   217
void Main::closeEvent (QCloseEvent* )
insilmaril@0
   218
{
insilmaril@0
   219
	fileExitVYM();
insilmaril@0
   220
}
insilmaril@0
   221
insilmaril@0
   222
// File Actions
insilmaril@0
   223
void Main::setupFileActions()
insilmaril@0
   224
{
insilmaril@366
   225
	QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
insilmaril@366
   226
    QToolBar *tb = addToolBar( tr ("&Map") );
insilmaril@366
   227
	tb->setObjectName ("mapTB");
insilmaril@0
   228
insilmaril@0
   229
    QAction *a;
insilmaril@395
   230
    a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New...","File menu" ),this);
insilmaril@395
   231
	a->setStatusTip ( tr( "New map","Status tip File menu" ) );
insilmaril@366
   232
	a->setShortcut ( Qt::CTRL + Qt::Key_N );
insilmaril@0
   233
    a->addTo( tb );
insilmaril@366
   234
	fileMenu->addAction (a);
insilmaril@366
   235
    connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
insilmaril@0
   236
	
insilmaril@395
   237
    a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
insilmaril@395
   238
	a->setStatusTip (tr( "Open","Status tip File menu" ) );
insilmaril@366
   239
	a->setShortcut ( Qt::CTRL + Qt::Key_O );
insilmaril@0
   240
    a->addTo( tb );
insilmaril@366
   241
	fileMenu->addAction (a);
insilmaril@366
   242
    connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
insilmaril@0
   243
	
insilmaril@395
   244
	fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
insilmaril@366
   245
	fileMenu->addSeparator();
insilmaril@0
   246
	
insilmaril@395
   247
    a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
insilmaril@395
   248
	a->setStatusTip ( tr( "Save","Status tip file menu" ));
insilmaril@366
   249
	a->setShortcut (Qt::CTRL + Qt::Key_S );
insilmaril@0
   250
    a->addTo( tb );
insilmaril@366
   251
	fileMenu->addAction (a);
insilmaril@366
   252
    connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
insilmaril@0
   253
	actionFileSave=a;
insilmaril@0
   254
	
insilmaril@395
   255
    a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
insilmaril@395
   256
	a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
insilmaril@366
   257
	fileMenu->addAction (a);
insilmaril@366
   258
    connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
insilmaril@366
   259
insilmaril@366
   260
	fileMenu->addSeparator();
insilmaril@366
   261
insilmaril@395
   262
	fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
insilmaril@366
   263
insilmaril@366
   264
	a = new QAction(tr("KDE Bookmarks"), this);
insilmaril@395
   265
	a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE bookmarks")));
insilmaril@366
   266
	a->addTo (fileImportMenu);
insilmaril@366
   267
	connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) );
insilmaril@366
   268
insilmaril@366
   269
    if (settings.value( "/mainwindow/showTestMenu",false).toBool()) 
insilmaril@331
   270
	{
insilmaril@395
   271
		a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
insilmaril@395
   272
		a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
insilmaril@366
   273
		a->addTo (fileImportMenu);
insilmaril@366
   274
		connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
insilmaril@331
   275
	}	
insilmaril@314
   276
insilmaril@366
   277
	a = new QAction("Mind Manager...",this);
insilmaril@395
   278
	a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager")  );
insilmaril@366
   279
	fileImportMenu->addAction (a);
insilmaril@366
   280
	connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
insilmaril@366
   281
insilmaril@395
   282
    a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
insilmaril@395
   283
	a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
insilmaril@366
   284
	fileImportMenu->addAction (a);
insilmaril@366
   285
    connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
insilmaril@366
   286
insilmaril@395
   287
	fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
insilmaril@395
   288
insilmaril@395
   289
	a = new QAction( tr("Image%1","File export menu").arg("..."), this);
insilmaril@395
   290
	a->setStatusTip( tr( "Export map as image","status tip file menu" ));
insilmaril@366
   291
	connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
insilmaril@366
   292
	fileExportMenu->addAction (a);
insilmaril@366
   293
insilmaril@395
   294
	a = new QAction( "Open Office...", this);
insilmaril@395
   295
	a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
insilmaril@366
   296
	connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
insilmaril@366
   297
	fileExportMenu->addAction (a);
insilmaril@366
   298
insilmaril@366
   299
	a = new QAction(  "Webpage (XHTML)...",this );
insilmaril@366
   300
	a->setShortcut (Qt::ALT + Qt::Key_X);
insilmaril@395
   301
	a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
insilmaril@366
   302
    connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
insilmaril@366
   303
	fileExportMenu->addAction (a);
insilmaril@366
   304
insilmaril@366
   305
    a = new QAction( "Text (ASCII)...", this);
insilmaril@395
   306
	a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
insilmaril@366
   307
    connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
insilmaril@366
   308
	fileExportMenu->addAction (a);
insilmaril@366
   309
insilmaril@395
   310
	a = new QAction( tr("KDE Bookmarks","File menu"), this);
insilmaril@395
   311
	a->setStatusTip( tr( "Export as %1").arg(tr("KDE Bookmarks" )));
insilmaril@366
   312
	connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
insilmaril@366
   313
	fileExportMenu->addAction (a);
insilmaril@366
   314
insilmaril@366
   315
    a = new QAction( "Taskjuggler...", this );
insilmaril@395
   316
    a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
insilmaril@366
   317
    connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
insilmaril@366
   318
	fileExportMenu->addAction (a);
insilmaril@366
   319
insilmaril@366
   320
    a = new QAction( "LaTeX...", this);
insilmaril@395
   321
    a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
insilmaril@366
   322
    connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
insilmaril@366
   323
	fileExportMenu->addAction (a);
insilmaril@366
   324
insilmaril@366
   325
	a = new QAction( "XML..." , this );
insilmaril@395
   326
	a->setStatusTip (tr( "Export as %1").arg("XML"));
insilmaril@366
   327
    connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
insilmaril@366
   328
	fileExportMenu->addAction (a);
insilmaril@366
   329
insilmaril@366
   330
	fileMenu->addSeparator();
insilmaril@366
   331
insilmaril@366
   332
    a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
insilmaril@395
   333
	a->setStatusTip ( tr( "Print" ,"File menu") );
insilmaril@366
   334
	a->setShortcut (Qt::CTRL + Qt::Key_P );
insilmaril@0
   335
    a->addTo( tb );
insilmaril@366
   336
	fileMenu->addAction (a);
insilmaril@366
   337
    connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
insilmaril@0
   338
	actionFilePrint=a;
insilmaril@0
   339
insilmaril@395
   340
    a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
insilmaril@366
   341
	a->setStatusTip (tr( "Close Map" ) );
insilmaril@366
   342
	a->setShortcut (Qt::ALT + Qt::Key_C );
insilmaril@366
   343
	fileMenu->addAction (a);
insilmaril@366
   344
    connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
insilmaril@366
   345
insilmaril@404
   346
    a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
insilmaril@404
   347
	a->setStatusTip ( tr( "Exit")+" "+vymName );
insilmaril@366
   348
	a->setShortcut (Qt::CTRL + Qt::Key_Q );
insilmaril@366
   349
	fileMenu->addAction (a);
insilmaril@366
   350
    connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
insilmaril@0
   351
}
insilmaril@0
   352
insilmaril@0
   353
insilmaril@0
   354
//Edit Actions
insilmaril@0
   355
void Main::setupEditActions()
insilmaril@0
   356
{
insilmaril@395
   357
    QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
insilmaril@0
   358
    tb->setLabel( "Edit Actions" );
insilmaril@366
   359
	tb->setObjectName ("actionsTB");
insilmaril@395
   360
    QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
insilmaril@0
   361
insilmaril@0
   362
    QAction *a;
insilmaril@102
   363
	QAction *alt;
insilmaril@395
   364
    a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
insilmaril@366
   365
    connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
insilmaril@366
   366
	a->setStatusTip (tr( "Undo" ) );
insilmaril@366
   367
	a->setShortcut ( Qt::CTRL + Qt::Key_Z );
insilmaril@0
   368
	a->setEnabled (false);
insilmaril@366
   369
    tb->addAction (a);
insilmaril@366
   370
	editMenu->addAction (a);
insilmaril@0
   371
	actionEditUndo=a;
insilmaril@163
   372
    
insilmaril@395
   373
	a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this); 
insilmaril@366
   374
	a->setStatusTip (tr( "Redo" ));
insilmaril@366
   375
	a->setShortcut (Qt::CTRL + Qt::Key_Y );
insilmaril@366
   376
    tb->addAction (a);
insilmaril@366
   377
	editMenu->addAction (a);
insilmaril@366
   378
	connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
insilmaril@366
   379
	actionEditRedo=a;
insilmaril@163
   380
   
insilmaril@366
   381
	editMenu->addSeparator();
insilmaril@395
   382
    a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
insilmaril@366
   383
	a->setStatusTip ( tr( "Copy" ) );
insilmaril@366
   384
	a->setShortcut (Qt::CTRL + Qt::Key_C );
insilmaril@0
   385
	a->setEnabled (false);
insilmaril@366
   386
    tb->addAction (a);
insilmaril@366
   387
	editMenu->addAction (a);
insilmaril@366
   388
    connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
insilmaril@0
   389
	actionEditCopy=a;
insilmaril@366
   390
	
insilmaril@395
   391
    a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
insilmaril@366
   392
	a->setStatusTip ( tr( "Cut" ) );
insilmaril@366
   393
	a->setShortcut (Qt::CTRL + Qt::Key_X );
insilmaril@0
   394
	a->setEnabled (false);
insilmaril@366
   395
    tb->addAction (a);
insilmaril@366
   396
	editMenu->addAction (a);
insilmaril@0
   397
	actionEditCut=a;
insilmaril@366
   398
    connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
insilmaril@366
   399
	
insilmaril@395
   400
    a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
insilmaril@366
   401
    connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
insilmaril@366
   402
	a->setStatusTip ( tr( "Paste" ) );
insilmaril@366
   403
	a->setShortcut ( Qt::CTRL + Qt::Key_V );
insilmaril@0
   404
	a->setEnabled (false);
insilmaril@366
   405
    tb->addAction (a);
insilmaril@366
   406
	editMenu->addAction (a);
insilmaril@0
   407
	actionEditPaste=a;
insilmaril@98
   408
insilmaril@351
   409
    // Shortcuts to modify heading:
insilmaril@395
   410
    a = new QAction(tr( "Edit heading","Edit menu" ),this);
insilmaril@366
   411
	a->setStatusTip ( tr( "edit Heading" ));
insilmaril@366
   412
	a->setShortcut ( Qt::Key_Enter);
insilmaril@366
   413
//	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   414
	addAction (a);
insilmaril@366
   415
    connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
insilmaril@351
   416
	actionListBranches.append(a);
insilmaril@395
   417
    a = new QAction( tr( "Edit heading","Edit menu" ), this);
insilmaril@366
   418
	a->setStatusTip (tr( "edit Heading" ));
insilmaril@366
   419
	a->setShortcut (Qt::Key_Return );
insilmaril@366
   420
	//a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   421
	addAction (a);
insilmaril@366
   422
    connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
insilmaril@351
   423
	actionListBranches.append(a);
insilmaril@366
   424
	editMenu->addAction (a);
insilmaril@351
   425
	actionEditHeading=a;
insilmaril@395
   426
    a = new QAction( tr( "Edit heading","Edit menu" ), this);
insilmaril@366
   427
	a->setStatusTip (tr( "edit Heading" ));
insilmaril@366
   428
	a->setShortcut ( Qt::Key_F2 );
insilmaril@366
   429
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   430
	addAction (a);
insilmaril@366
   431
    connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
insilmaril@351
   432
	actionListBranches.append(a);
insilmaril@351
   433
    
insilmaril@351
   434
    // Shortcut to delete selection
insilmaril@395
   435
    a = new QAction( tr( "Delete Selection","Edit menu" ),this);
insilmaril@366
   436
	a->setStatusTip (tr( "Delete Selection" ));
insilmaril@366
   437
	a->setShortcut ( Qt::Key_Delete);
insilmaril@366
   438
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   439
	addAction (a);
insilmaril@366
   440
    connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
insilmaril@351
   441
	actionEditDelete=a;
insilmaril@351
   442
    
insilmaril@351
   443
    // Shortcut to add branch
insilmaril@395
   444
	alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
insilmaril@366
   445
	alt->setStatusTip ( tr( "Add a branch as child of selection" ));
insilmaril@366
   446
	alt->setShortcut (Qt::Key_A);
insilmaril@366
   447
	alt->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   448
	addAction (alt);
insilmaril@366
   449
	connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
insilmaril@395
   450
	a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
insilmaril@366
   451
	a->setStatusTip ( tr( "Add a branch as child of selection" ));
insilmaril@366
   452
	a->setShortcut (Qt::Key_Insert);	
insilmaril@366
   453
	connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
insilmaril@351
   454
	actionListBranches.append(a);
insilmaril@351
   455
	#if defined (Q_OS_MACX)
insilmaril@366
   456
		// In OSX show different shortcut in menues, the keys work indepently always			
insilmaril@351
   457
		actionEditAddBranch=alt;
insilmaril@351
   458
	#else	
insilmaril@351
   459
		actionEditAddBranch=a;
insilmaril@351
   460
	#endif	
insilmaril@366
   461
	editMenu->addAction (actionEditAddBranch);
insilmaril@366
   462
	tb->addAction (actionEditAddBranch);
insilmaril@366
   463
insilmaril@351
   464
insilmaril@351
   465
    // Add branch by inserting it at selection
insilmaril@395
   466
	a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
insilmaril@366
   467
	a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
insilmaril@366
   468
	a->setShortcut (Qt::ALT + Qt::Key_Insert );
insilmaril@366
   469
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   470
	addAction (a);
insilmaril@394
   471
    connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
insilmaril@351
   472
	a->setEnabled (false);
insilmaril@351
   473
	actionListBranches.append(a);
insilmaril@394
   474
	actionEditAddBranchBefore=a;
insilmaril@395
   475
	a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
insilmaril@366
   476
	a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
insilmaril@366
   477
	a->setShortcut ( Qt::ALT + Qt::Key_A );
insilmaril@366
   478
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   479
	addAction (a);
insilmaril@394
   480
    connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
insilmaril@351
   481
	actionListBranches.append(a);
insilmaril@351
   482
insilmaril@351
   483
	// Add branch above
insilmaril@395
   484
    a = new QAction(tr( "Add branch above","Edit menu" ), this);
insilmaril@366
   485
	a->setStatusTip ( tr( "Add a branch above selection" ));
insilmaril@366
   486
	a->setShortcut (Qt::SHIFT+Qt::Key_Insert );
insilmaril@366
   487
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   488
	addAction (a);
insilmaril@366
   489
    connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
insilmaril@351
   490
	a->setEnabled (false);
insilmaril@351
   491
	actionListBranches.append(a);
insilmaril@351
   492
	actionEditAddBranchAbove=a;
insilmaril@395
   493
    a = new QAction(tr( "Add branch above","Edit menu" ), this);
insilmaril@366
   494
	a->setStatusTip ( tr( "Add a branch above selection" ));
insilmaril@366
   495
	a->setShortcut (Qt::SHIFT+Qt::Key_A );
insilmaril@366
   496
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   497
	addAction (a);
insilmaril@366
   498
    connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
insilmaril@351
   499
	actionListBranches.append(a);
insilmaril@351
   500
insilmaril@351
   501
	// Add branch below 
insilmaril@395
   502
    a = new QAction(tr( "Add branch below","Edit menu" ), this);
insilmaril@366
   503
	a->setStatusTip ( tr( "Add a branch below selection" ));
insilmaril@366
   504
	a->setShortcut (Qt::CTRL +Qt::Key_Insert );
insilmaril@366
   505
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   506
	addAction (a);
insilmaril@366
   507
    connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
insilmaril@351
   508
	a->setEnabled (false);
insilmaril@351
   509
	actionListBranches.append(a);
insilmaril@351
   510
	actionEditAddBranchBelow=a;
insilmaril@395
   511
    a = new QAction(tr( "Add branch below","Edit menu" ), this);
insilmaril@366
   512
	a->setStatusTip ( tr( "Add a branch below selection" ));
insilmaril@366
   513
	a->setShortcut (Qt::CTRL +Qt::Key_A );
insilmaril@366
   514
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   515
	addAction (a);
insilmaril@366
   516
    connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
insilmaril@351
   517
	actionListBranches.append(a);
insilmaril@351
   518
insilmaril@395
   519
    a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
insilmaril@366
   520
	a->setStatusTip ( tr( "Move branch up" ) );
insilmaril@366
   521
	a->setShortcut (Qt::Key_PageUp );
insilmaril@0
   522
	a->setEnabled (false);
insilmaril@366
   523
    tb->addAction (a);
insilmaril@366
   524
	editMenu->addAction (a);
insilmaril@366
   525
    connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
insilmaril@0
   526
	actionEditMoveUp=a;
insilmaril@98
   527
insilmaril@395
   528
    a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
insilmaril@366
   529
    connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
insilmaril@366
   530
	a->setStatusTip (tr( "Move branch down" ) );
insilmaril@366
   531
	a->setShortcut ( Qt::Key_PageDown );
insilmaril@0
   532
	a->setEnabled (false);
insilmaril@366
   533
    tb->addAction (a);
insilmaril@366
   534
	editMenu->addAction (a);
insilmaril@0
   535
	actionEditMoveDown=a;
insilmaril@98
   536
	
insilmaril@0
   537
insilmaril@395
   538
	a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this);
insilmaril@366
   539
	a->setShortcut ( Qt::Key_ScrollLock );
insilmaril@366
   540
	a->setStatusTip (tr( "Scroll branch" ) );
insilmaril@366
   541
    connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
insilmaril@375
   542
insilmaril@395
   543
	alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
insilmaril@366
   544
	alt->setShortcut ( Qt::Key_S );
insilmaril@366
   545
	alt->setStatusTip (tr( "Scroll branch" )); 
insilmaril@366
   546
    connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
insilmaril@102
   547
	#if defined(Q_OS_MACX)
insilmaril@102
   548
		actionEditToggleScroll=alt;
insilmaril@102
   549
	#else	
insilmaril@102
   550
		actionEditToggleScroll=a;
insilmaril@102
   551
	#endif	
insilmaril@102
   552
	actionEditToggleScroll->setEnabled (false);
insilmaril@250
   553
	actionEditToggleScroll->setToggleAction(true);
insilmaril@366
   554
    tb->addAction (actionEditToggleScroll);
insilmaril@366
   555
    editMenu->addAction ( actionEditToggleScroll);
insilmaril@366
   556
	editMenu->addAction (actionEditToggleScroll);
insilmaril@375
   557
	addAction (a);
insilmaril@375
   558
	addAction (alt);
insilmaril@102
   559
	actionListBranches.append(actionEditToggleScroll);
insilmaril@0
   560
	
insilmaril@395
   561
    a = new QAction( tr( "Unscroll all scrolled branches","Edit menu" ), this);
insilmaril@366
   562
	a->setStatusTip (tr( "Unscroll all" ));
insilmaril@366
   563
	editMenu->addAction (a);
insilmaril@366
   564
    connect( a, SIGNAL( triggered() ), this, SLOT( editUnScrollAll() ) );
insilmaril@0
   565
	
insilmaril@366
   566
	editMenu->addSeparator();
insilmaril@366
   567
insilmaril@395
   568
	a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
insilmaril@366
   569
	a->setStatusTip (tr( "Find" ) );
insilmaril@366
   570
	a->setShortcut (Qt::CTRL + Qt::Key_F );
insilmaril@366
   571
	editMenu->addAction (a);
insilmaril@366
   572
    connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
insilmaril@0
   573
    
insilmaril@366
   574
	editMenu->addSeparator();
insilmaril@366
   575
insilmaril@395
   576
	a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
insilmaril@366
   577
	a->setShortcut (Qt::CTRL + Qt::Key_U );
insilmaril@366
   578
	a->setShortcut (tr( "Open URL" ));
insilmaril@366
   579
    tb->addAction (a);
insilmaril@366
   580
	addAction(a);
insilmaril@366
   581
    connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
insilmaril@0
   582
	actionEditOpenURL=a;
insilmaril@0
   583
insilmaril@395
   584
	a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
insilmaril@366
   585
	a->setStatusTip (tr( "Open URL in new tab" ));
insilmaril@366
   586
	a->setShortcut (Qt::CTRL+Qt::Key_U );
insilmaril@366
   587
	addAction(a);
insilmaril@366
   588
    connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
insilmaril@266
   589
	actionEditOpenURLTab=a;
insilmaril@266
   590
insilmaril@395
   591
	a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
insilmaril@366
   592
	a->setStatusTip (tr( "Open all URLs in subtree" ));
insilmaril@366
   593
	addAction(a);
insilmaril@366
   594
	actionListBranches.append(a);
insilmaril@366
   595
    connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
insilmaril@366
   596
	actionEditOpenMultipleURLTabs=a;
insilmaril@366
   597
insilmaril@395
   598
	a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
insilmaril@366
   599
	a->setStatusTip ( tr( "Edit URL" ) );
insilmaril@366
   600
	a->setShortcut (Qt::SHIFT + Qt::CTRL + Qt::Key_U );
insilmaril@366
   601
	//a->setShortcut ( Qt::Key_U );
insilmaril@366
   602
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   603
	actionListBranches.append(a);
insilmaril@366
   604
	addAction(a);
insilmaril@366
   605
    connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
insilmaril@366
   606
	actionEditURL=a;
insilmaril@366
   607
	
insilmaril@395
   608
	a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
insilmaril@366
   609
	a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
insilmaril@0
   610
	a->setEnabled (false);
insilmaril@98
   611
	actionListBranches.append(a);
insilmaril@366
   612
    connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
insilmaril@366
   613
	actionEditHeading2URL=a;
insilmaril@366
   614
    
insilmaril@395
   615
	a = new QAction(tr( "Create URL to Bugzilla","Edit menu" ), this);
insilmaril@366
   616
	a->setStatusTip ( tr( "Create URL to Bugzilla" ));
insilmaril@0
   617
	a->setEnabled (false);
insilmaril@98
   618
	actionListBranches.append(a);
insilmaril@366
   619
    connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
insilmaril@366
   620
	actionEditBugzilla2URL=a;
insilmaril@0
   621
    
insilmaril@395
   622
	a = new QAction(tr( "Create URL to FATE","Edit menu" ), this);
insilmaril@366
   623
	a->setStatusTip ( tr( "Create URL to FATE" ));
insilmaril@0
   624
	a->setEnabled (false);
insilmaril@98
   625
	actionListBranches.append(a);
insilmaril@366
   626
    connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
insilmaril@366
   627
	actionEditFATE2URL=a;
insilmaril@366
   628
	
insilmaril@395
   629
    a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
insilmaril@366
   630
	a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
insilmaril@366
   631
    tb->addAction (a);
insilmaril@366
   632
	a->setEnabled (false);
insilmaril@366
   633
    connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
insilmaril@366
   634
	actionEditOpenVymLink=a;
insilmaril@366
   635
	
insilmaril@395
   636
    a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
insilmaril@366
   637
	a->setStatusTip ( tr( "Open all vym links in subtree" ));
insilmaril@175
   638
	a->setEnabled (false);
insilmaril@175
   639
	actionListBranches.append(a);
insilmaril@366
   640
    connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
insilmaril@366
   641
	actionEditOpenMultipleVymLinks=a;
insilmaril@0
   642
	
insilmaril@366
   643
insilmaril@395
   644
    a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
insilmaril@0
   645
	a->setEnabled (false);
insilmaril@366
   646
	a->setStatusTip ( tr( "Edit link to another vym map" ));
insilmaril@366
   647
    connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
insilmaril@98
   648
	actionListBranches.append(a);
insilmaril@0
   649
	actionEditVymLink=a;
insilmaril@0
   650
insilmaril@395
   651
    a = new QAction(tr( "Delete vym link","Edit menu" ),this);
insilmaril@366
   652
	a->setStatusTip ( tr( "Delete link to another vym map" ));
insilmaril@0
   653
	a->setEnabled (false);
insilmaril@366
   654
    connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
insilmaril@0
   655
	actionEditDeleteVymLink=a;
insilmaril@0
   656
insilmaril@395
   657
    a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
insilmaril@366
   658
	a->setStatusTip ( tr( "Hide object in exports" ) );
insilmaril@366
   659
	a->setShortcut (Qt::Key_H );
insilmaril@243
   660
	a->setToggleAction(true);
insilmaril@366
   661
    tb->addAction (a);
insilmaril@243
   662
	a->setEnabled (false);
insilmaril@366
   663
    connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
insilmaril@243
   664
	actionEditToggleHideExport=a;
insilmaril@243
   665
insilmaril@395
   666
    a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
insilmaril@366
   667
	a->setStatusTip ( tr( "Edit Map Info" ));
insilmaril@0
   668
	a->setEnabled (true);
insilmaril@366
   669
    connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
insilmaril@0
   670
	actionEditMapInfo=a;
insilmaril@0
   671
insilmaril@0
   672
	// Import at selection (adding to selection)
insilmaril@395
   673
    a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
insilmaril@366
   674
	a->setStatusTip (tr( "Add map at selection" ));
insilmaril@366
   675
    connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
insilmaril@0
   676
	a->setEnabled (false);
insilmaril@98
   677
	actionListBranches.append(a);
insilmaril@0
   678
	actionEditImportAdd=a;
insilmaril@0
   679
insilmaril@0
   680
	// Import at selection (replacing selection)
insilmaril@395
   681
    a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
insilmaril@366
   682
	a->setStatusTip (tr( "Replace selection with map" ));
insilmaril@366
   683
    connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
insilmaril@0
   684
	a->setEnabled (false);
insilmaril@98
   685
	actionListBranches.append(a);
insilmaril@0
   686
	actionEditImportReplace=a;
insilmaril@0
   687
insilmaril@0
   688
	// Save selection 
insilmaril@395
   689
    a = new QAction( tr( "Save selection","Edit menu" ), this);
insilmaril@366
   690
	a->setStatusTip (tr( "Save selection" ));
insilmaril@366
   691
    connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
insilmaril@0
   692
	a->setEnabled (false);
insilmaril@98
   693
	actionListBranches.append(a);
insilmaril@0
   694
	actionEditSaveBranch=a;
insilmaril@0
   695
insilmaril@98
   696
	// Only remove branch, not its childs
insilmaril@395
   697
    a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
insilmaril@366
   698
	a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
insilmaril@366
   699
	a->setShortcut (Qt::ALT + Qt::Key_Delete );
insilmaril@395
   700
    connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChilds() ) );
insilmaril@98
   701
	a->setEnabled (false);
insilmaril@375
   702
	addAction (a);
insilmaril@98
   703
	actionListBranches.append(a);
insilmaril@395
   704
	actionEditDeleteKeepChilds=a;
insilmaril@98
   705
insilmaril@98
   706
	// Only remove childs of a branch
insilmaril@395
   707
    a = new QAction( tr( "Remove childs","Edit menu" ), this);
insilmaril@366
   708
	a->setStatusTip (tr( "Remove childs of branch" ));
insilmaril@366
   709
	a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
insilmaril@395
   710
    connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChilds() ) );
insilmaril@98
   711
	a->setEnabled (false);
insilmaril@98
   712
	actionListBranches.append(a);
insilmaril@395
   713
	actionEditDeleteChilds=a;
insilmaril@98
   714
insilmaril@0
   715
    // Shortcuts for navigating with cursor:
insilmaril@395
   716
    a = new QAction(tr( "Select upper branch","Edit menu" ), this);
insilmaril@366
   717
	a->setStatusTip ( tr( "Select upper branch" ));
insilmaril@366
   718
	a->setShortcut (Qt::Key_Up );
insilmaril@366
   719
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   720
	addAction (a);
insilmaril@366
   721
    connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
insilmaril@395
   722
    a = new QAction( tr( "Select lower branch","Edit menu" ),this);
insilmaril@366
   723
	a->setStatusTip (tr( "Select lower branch" ));
insilmaril@366
   724
	a->setShortcut ( Qt::Key_Down );
insilmaril@366
   725
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   726
	addAction (a);
insilmaril@366
   727
    connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
insilmaril@395
   728
    a = new QAction(tr( "Select left branch","Edit menu" ), this);
insilmaril@366
   729
	a->setStatusTip ( tr( "Select left branch" ));
insilmaril@366
   730
	a->setShortcut (Qt::Key_Left );
insilmaril@366
   731
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   732
	addAction (a);
insilmaril@366
   733
    connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
insilmaril@395
   734
    a = new QAction( tr( "Select child branch","Edit menu" ), this);
insilmaril@366
   735
	a->setStatusTip (tr( "Select right branch" ));
insilmaril@366
   736
	a->setShortcut (Qt::Key_Right);
insilmaril@366
   737
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   738
	addAction (a);
insilmaril@366
   739
    connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
insilmaril@395
   740
    a = new QAction( tr( "Select first branch","Edit menu" ), this);
insilmaril@366
   741
	a->setStatusTip (tr( "Select first branch" ));
insilmaril@366
   742
	a->setShortcut (Qt::Key_Home );
insilmaril@366
   743
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   744
	addAction (a);
insilmaril@0
   745
	a->setEnabled (false);
insilmaril@366
   746
	editMenu->addAction (a);
insilmaril@98
   747
	actionListBranches.append(a);
insilmaril@0
   748
	actionEditSelectFirst=a;
insilmaril@366
   749
    connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
insilmaril@395
   750
    a = new QAction( tr( "Select last branch","Edit menu" ),this);
insilmaril@366
   751
	a->setStatusTip (tr( "Select last branch" ));
insilmaril@366
   752
	a->setShortcut ( Qt::Key_End );
insilmaril@366
   753
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   754
	addAction (a);
insilmaril@366
   755
    connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
insilmaril@0
   756
	a->setEnabled (false);
insilmaril@366
   757
	editMenu->addAction (a);
insilmaril@98
   758
	actionListBranches.append(a);
insilmaril@0
   759
	actionEditSelectLast=a;
insilmaril@0
   760
insilmaril@395
   761
    a = new QAction( tr( "Add Image...","Edit menu" ), this);
insilmaril@366
   762
	a->setStatusTip (tr( "Add Image" ));
insilmaril@366
   763
    connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
insilmaril@0
   764
	actionEditLoadImage=a;
insilmaril@89
   765
insilmaril@0
   766
}
insilmaril@0
   767
insilmaril@0
   768
// Format Actions
insilmaril@0
   769
void Main::setupFormatActions()
insilmaril@0
   770
{
insilmaril@395
   771
    QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
insilmaril@395
   772
insilmaril@395
   773
    QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
insilmaril@366
   774
	tb->setObjectName ("formatTB");
insilmaril@0
   775
    QAction *a;
insilmaril@0
   776
    QPixmap pix( 16,16);
insilmaril@366
   777
    pix.fill (Qt::black);
insilmaril@366
   778
    a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
insilmaril@366
   779
	a->setStatusTip ( tr( "Set Color" ));
insilmaril@366
   780
    connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
insilmaril@366
   781
    a->addTo( tb );
insilmaril@366
   782
	formatMenu->addAction (a);
insilmaril@366
   783
	actionFormatColor=a;
insilmaril@395
   784
    a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
insilmaril@366
   785
	a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
insilmaril@366
   786
	a->setShortcut (Qt::CTRL + Qt::Key_K );
insilmaril@366
   787
    connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
insilmaril@0
   788
	a->setEnabled (false);
insilmaril@0
   789
    a->addTo( tb );
insilmaril@366
   790
	formatMenu->addAction (a);
insilmaril@98
   791
	actionListBranches.append(a);
insilmaril@0
   792
	actionFormatPickColor=a;
insilmaril@366
   793
insilmaril@417
   794
    a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
insilmaril@366
   795
	a->setStatusTip ( tr( "Color branch" ) );
insilmaril@366
   796
	a->setShortcut (Qt::CTRL + Qt::Key_I);
insilmaril@417
   797
    connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
insilmaril@0
   798
	a->setEnabled (false);
insilmaril@0
   799
    a->addTo( tb );
insilmaril@366
   800
	formatMenu->addAction (a);
insilmaril@98
   801
	actionListBranches.append(a);
insilmaril@417
   802
	actionFormatColorSubtree=a;
insilmaril@417
   803
insilmaril@417
   804
    a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
insilmaril@366
   805
	a->setStatusTip ( tr( "Color Subtree" ));
insilmaril@366
   806
	a->setShortcut (Qt::CTRL + Qt::Key_T);
insilmaril@417
   807
    connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
insilmaril@0
   808
	a->setEnabled (false);
insilmaril@366
   809
	formatMenu->addAction (a);
insilmaril@0
   810
    a->addTo( tb );
insilmaril@98
   811
	actionListBranches.append(a);
insilmaril@0
   812
	actionFormatColorSubtree=a;
insilmaril@0
   813
insilmaril@366
   814
	formatMenu->addSeparator();
insilmaril@366
   815
	actionGroupFormatLinkStyles=new QActionGroup ( this);
insilmaril@0
   816
	actionGroupFormatLinkStyles->setExclusive (true);
insilmaril@366
   817
    a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
insilmaril@366
   818
	a->setStatusTip (tr( "Line" ));
insilmaril@0
   819
	a->setToggleAction(true);
insilmaril@366
   820
    connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
insilmaril@366
   821
	formatMenu->addAction (a);
insilmaril@0
   822
	actionFormatLinkStyleLine=a;
insilmaril@366
   823
    a= new QAction( tr( "Linkstyle Parabel" ), actionGroupFormatLinkStyles);
insilmaril@366
   824
	a->setStatusTip (tr( "Line" ));
insilmaril@0
   825
	a->setToggleAction(true);
insilmaril@366
   826
    connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
insilmaril@366
   827
	formatMenu->addAction (a);
insilmaril@0
   828
	actionFormatLinkStyleParabel=a;
insilmaril@366
   829
    a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
insilmaril@366
   830
	a->setStatusTip (tr( "PolyLine" ));
insilmaril@0
   831
	a->setToggleAction(true);
insilmaril@366
   832
    connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
insilmaril@366
   833
	formatMenu->addAction (a);
insilmaril@0
   834
	actionFormatLinkStylePolyLine=a;
insilmaril@366
   835
    a= new QAction( tr( "Linkstyle Thick Parabel" ), actionGroupFormatLinkStyles);
insilmaril@366
   836
	a->setStatusTip (tr( "PolyParabel" ) );
insilmaril@0
   837
	a->setToggleAction(true);
insilmaril@366
   838
	a->setChecked (true);
insilmaril@366
   839
    connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
insilmaril@366
   840
	formatMenu->addAction (a);
insilmaril@0
   841
	actionFormatLinkStylePolyParabel=a;
insilmaril@0
   842
	
insilmaril@366
   843
	actionGroupFormatFrameTypes=new QActionGroup ( this);
insilmaril@0
   844
	actionGroupFormatFrameTypes->setExclusive (true);
insilmaril@395
   845
    a = new QAction( tr( "No Frame","Branch attribute" ), actionGroupFormatFrameTypes );
insilmaril@366
   846
	a->setStatusTip (tr("No Frame"));
insilmaril@0
   847
	a->setToggleAction(true);
insilmaril@366
   848
    connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameNone() ) );
insilmaril@0
   849
	actionFormatFrameNone=a;
insilmaril@395
   850
    a = new QAction( tr( "Rectangle""Branch attribute" ), actionGroupFormatFrameTypes);
insilmaril@366
   851
	a->setStatusTip (tr( "Rectangle" ));
insilmaril@0
   852
	a->setToggleAction(true);
insilmaril@366
   853
    connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameRectangle() ) );
insilmaril@0
   854
	actionFormatFrameRectangle=a;
insilmaril@0
   855
insilmaril@395
   856
    a = new QAction( tr( "Include images vertically","Branch attribute" ),  this);
insilmaril@366
   857
	a->setStatusTip ( tr ("Include top and bottom position of images into branch"));
insilmaril@175
   858
	a->setToggleAction(true);
insilmaril@366
   859
    connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesVer() ) );
insilmaril@175
   860
	actionFormatIncludeImagesVer=a;
insilmaril@175
   861
insilmaril@395
   862
    a = new QAction( tr( "Include images horizontally","Branch attribute" ),  this);
insilmaril@366
   863
	a->setStatusTip ( tr ("Include left and right position of images into branch"));
insilmaril@175
   864
	a->setToggleAction(true);
insilmaril@366
   865
    connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesHor() ) );
insilmaril@175
   866
	actionFormatIncludeImagesHor=a;
insilmaril@175
   867
insilmaril@395
   868
    a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
insilmaril@366
   869
	a->setStatusTip (tr( "Hide link" ));
insilmaril@160
   870
	a->setToggleAction(true);
insilmaril@366
   871
    connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
insilmaril@160
   872
	actionFormatHideLinkUnselected=a;
insilmaril@160
   873
insilmaril@366
   874
	formatMenu->addSeparator();
insilmaril@395
   875
    a= new QAction( tr( "&Use color of heading for link","Branch attribute" ),  this);
insilmaril@366
   876
	a->setStatusTip (tr( "Use same color for links and headings" ));
insilmaril@0
   877
	a->setToggleAction(true);
insilmaril@366
   878
    connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
insilmaril@366
   879
	formatMenu->addAction (a);
insilmaril@0
   880
	actionFormatLinkColorHint=a;
insilmaril@366
   881
insilmaril@366
   882
    pix.fill (Qt::white);
insilmaril@366
   883
    a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this  );
insilmaril@366
   884
	a->setStatusTip (tr( "Set Link Color" ));
insilmaril@366
   885
	formatMenu->addAction (a);
insilmaril@366
   886
    connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
insilmaril@366
   887
    actionFormatLinkColor=a;
insilmaril@366
   888
insilmaril@366
   889
    a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
insilmaril@366
   890
	a->setStatusTip (tr( "Set Background Color" ));
insilmaril@366
   891
	formatMenu->addAction (a);
insilmaril@366
   892
    connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
insilmaril@366
   893
    actionFormatBackColor=a;
insilmaril@408
   894
insilmaril@408
   895
    a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
insilmaril@408
   896
	a->setStatusTip (tr( "Set Background image" ));
insilmaril@408
   897
	formatMenu->addAction (a);
insilmaril@408
   898
    connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
insilmaril@408
   899
    actionFormatBackImage=a;
insilmaril@0
   900
}
insilmaril@0
   901
insilmaril@0
   902
// View Actions
insilmaril@0
   903
void Main::setupViewActions()
insilmaril@0
   904
{
insilmaril@395
   905
    QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
insilmaril@0
   906
    tb->setLabel( "View Actions" );
insilmaril@366
   907
	tb->setObjectName ("viewTB");
insilmaril@366
   908
    QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
insilmaril@0
   909
insilmaril@0
   910
    QAction *a;
insilmaril@395
   911
    a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
insilmaril@366
   912
	a->setStatusTip ( tr( "Zoom reset" ) );
insilmaril@366
   913
	a->setShortcut (Qt::CTRL + Qt::Key_0 );
insilmaril@0
   914
    a->addTo( tb );
insilmaril@366
   915
	viewMenu->addAction (a);
insilmaril@366
   916
    connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
insilmaril@366
   917
	
insilmaril@395
   918
    a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
insilmaril@366
   919
	a->setStatusTip (tr( "Zoom in" ));
insilmaril@366
   920
	a->setShortcut (Qt::CTRL + Qt::Key_Plus);
insilmaril@0
   921
    a->addTo( tb );
insilmaril@366
   922
	viewMenu->addAction (a);
insilmaril@366
   923
    connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
insilmaril@366
   924
	
insilmaril@395
   925
    a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
insilmaril@366
   926
	a->setStatusTip (tr( "Zoom out" ));
insilmaril@366
   927
	a->setShortcut (Qt::CTRL + Qt::Key_Minus );
insilmaril@0
   928
    a->addTo( tb );
insilmaril@366
   929
	viewMenu->addAction (a);
insilmaril@366
   930
    connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
insilmaril@366
   931
insilmaril@366
   932
insilmaril@395
   933
    a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
insilmaril@366
   934
	a->setStatusTip ( tr( "Show Note Editor" ));
insilmaril@366
   935
	a->setShortcut ( Qt::CTRL + Qt::Key_E );
insilmaril@0
   936
	a->setToggleAction(true);
insilmaril@0
   937
	if (textEditor->showWithMain())
insilmaril@0
   938
		a->setOn(true);
insilmaril@0
   939
	else	
insilmaril@0
   940
		a->setOn(false);
insilmaril@0
   941
    a->addTo( tb );
insilmaril@366
   942
	viewMenu->addAction (a);
insilmaril@366
   943
    connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
insilmaril@0
   944
	actionViewToggleNoteEditor=a;
insilmaril@294
   945
insilmaril@404
   946
    a = new QAction(QPixmap(iconPath+"history.png"),  tr( "Show history window","View action" ),this );
insilmaril@366
   947
	a->setStatusTip ( tr( "Show history window" ));
insilmaril@366
   948
	a->setShortcut ( Qt::CTRL + Qt::Key_H  );
insilmaril@407
   949
	a->setToggleAction(true);
insilmaril@404
   950
    a->addTo( tb );
insilmaril@366
   951
	viewMenu->addAction (a);
insilmaril@366
   952
    connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
insilmaril@294
   953
	actionViewToggleHistoryWindow=a;
insilmaril@294
   954
insilmaril@408
   955
    a = new QAction(tr( "Antialiasing","View action" ),this );
insilmaril@408
   956
	a->setStatusTip ( tr( "Antialiasing" ));
insilmaril@408
   957
	a->setToggleAction(true);
insilmaril@408
   958
	a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
insilmaril@408
   959
	viewMenu->addAction (a);
insilmaril@408
   960
    connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
insilmaril@408
   961
	actionViewToggleAntiAlias=a;
insilmaril@408
   962
insilmaril@408
   963
    a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
insilmaril@408
   964
	a->setStatusTip (a->text());
insilmaril@408
   965
	a->setToggleAction(true);
insilmaril@408
   966
	a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
insilmaril@408
   967
	viewMenu->addAction (a);
insilmaril@408
   968
    connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
insilmaril@408
   969
	actionViewToggleSmoothPixmapTransform=a;
insilmaril@408
   970
insilmaril@395
   971
    a = new QAction(tr( "Next Window","View action" ), this);
insilmaril@408
   972
	a->setStatusTip (a->text());
insilmaril@366
   973
	a->setShortcut (Qt::ALT + Qt::Key_N );
insilmaril@366
   974
	viewMenu->addAction (a);
insilmaril@366
   975
    connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
insilmaril@366
   976
insilmaril@395
   977
    a = new QAction (tr( "Previous Window","View action" ), this );
insilmaril@408
   978
	a->setStatusTip (a->text());
insilmaril@366
   979
	a->setShortcut (Qt::ALT + Qt::Key_P );
insilmaril@366
   980
	viewMenu->addAction (a);
insilmaril@366
   981
    connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
insilmaril@0
   982
}
insilmaril@0
   983
insilmaril@89
   984
// Mode Actions
insilmaril@89
   985
void Main::setupModeActions()
insilmaril@89
   986
{
insilmaril@89
   987
    //QPopupMenu *menu = new QPopupMenu( this );
insilmaril@89
   988
    //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
insilmaril@89
   989
insilmaril@395
   990
    QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
insilmaril@366
   991
	tb->setObjectName ("modesTB");
insilmaril@89
   992
    QAction *a;
insilmaril@366
   993
	actionGroupModModes=new QActionGroup ( this);
insilmaril@89
   994
	actionGroupModModes->setExclusive (true);
insilmaril@395
   995
    a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
insilmaril@366
   996
	a->setShortcut (Qt::Key_J);
insilmaril@366
   997
    a->setStatusTip ( tr( "Use modifier to color branches" ));
insilmaril@89
   998
	a->setToggleAction(true);
insilmaril@89
   999
	a->addTo (tb);
insilmaril@89
  1000
	a->setOn(true);
insilmaril@89
  1001
	actionModModeColor=a;
insilmaril@104
  1002
	
insilmaril@395
  1003
    a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
insilmaril@366
  1004
	a->setShortcut( Qt::Key_K); 
insilmaril@366
  1005
    a->setStatusTip( tr( "Use modifier to copy" ));
insilmaril@104
  1006
	a->setToggleAction(true);
insilmaril@104
  1007
	a->addTo (tb);
insilmaril@104
  1008
	actionModModeCopy=a;
insilmaril@104
  1009
insilmaril@395
  1010
    a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
insilmaril@366
  1011
	a->setShortcut (Qt::Key_L);
insilmaril@366
  1012
    a->setStatusTip( tr( "Use modifier to draw xLinks" ));
insilmaril@89
  1013
	a->setToggleAction(true);
insilmaril@89
  1014
	a->addTo (tb);
insilmaril@390
  1015
	actionModModeXLink=a;
insilmaril@89
  1016
}
insilmaril@89
  1017
insilmaril@0
  1018
// Flag Actions
insilmaril@0
  1019
void Main::setupFlagActions()
insilmaril@0
  1020
{
insilmaril@166
  1021
	// Create System Flags
insilmaril@166
  1022
	systemFlagsDefault = new FlagRowObj ();
insilmaril@166
  1023
	systemFlagsDefault->setVisibility (false);
insilmaril@166
  1024
	systemFlagsDefault->setName ("systemFlagsDef");
insilmaril@166
  1025
insilmaril@166
  1026
	FlagObj *fo = new FlagObj ();
insilmaril@269
  1027
	fo->load(QPixmap(flagsPath+"flag-note.png"));
insilmaril@166
  1028
	fo->setName("note");
insilmaril@166
  1029
	fo->setToolTip(tr("Note","Systemflag"));
insilmaril@166
  1030
	systemFlagsDefault->addFlag (fo);	// makes deep copy
insilmaril@166
  1031
insilmaril@269
  1032
	fo->load(QPixmap(flagsPath+"flag-url.png"));
insilmaril@166
  1033
	fo->setName("url");
insilmaril@166
  1034
	fo->setToolTip(tr("WWW Document (external)","Systemflag"));
insilmaril@166
  1035
	systemFlagsDefault->addFlag (fo);
insilmaril@166
  1036
	
insilmaril@269
  1037
	fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
insilmaril@166
  1038
	fo->setName("vymLink");
insilmaril@166
  1039
	fo->setToolTip(tr("Link to another vym map","Systemflag"));
insilmaril@166
  1040
	systemFlagsDefault->addFlag (fo);	
insilmaril@166
  1041
insilmaril@269
  1042
	fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
insilmaril@166
  1043
	fo->setName("scrolledright");
insilmaril@166
  1044
	fo->setToolTip(tr("subtree is scrolled","Systemflag"));
insilmaril@166
  1045
	systemFlagsDefault->addFlag (fo);
insilmaril@166
  1046
	
insilmaril@269
  1047
	fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
insilmaril@166
  1048
	fo->setName("tmpUnscrolledright");
insilmaril@166
  1049
	fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
insilmaril@166
  1050
	systemFlagsDefault->addFlag (fo);
insilmaril@166
  1051
insilmaril@269
  1052
	fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
insilmaril@243
  1053
	fo->setName("hideInExport");
insilmaril@243
  1054
	fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
insilmaril@243
  1055
	systemFlagsDefault->addFlag (fo);
insilmaril@243
  1056
insilmaril@166
  1057
	// Create Standard Flags
insilmaril@366
  1058
	QToolBar *tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
insilmaril@366
  1059
	tb->setObjectName ("standardFlagTB");
insilmaril@366
  1060
insilmaril@166
  1061
	standardFlagsDefault = new FlagRowObj ();
insilmaril@166
  1062
	standardFlagsDefault->setVisibility (false);
insilmaril@166
  1063
	standardFlagsDefault->setName ("standardFlagsDef");
insilmaril@366
  1064
	standardFlagsDefault->setToolBar (tb);
insilmaril@166
  1065
insilmaril@408
  1066
	fo->load(flagsPath+"flag-exclamationmark.png");
insilmaril@166
  1067
	fo->setName ("exclamationmark");
insilmaril@166
  1068
	fo->setGroup("standard-mark");
insilmaril@366
  1069
	QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
insilmaril@366
  1070
	tb->addAction (a);
insilmaril@366
  1071
	fo->setAction (a);
insilmaril@366
  1072
	a->setCheckable(true);
insilmaril@366
  1073
	a->setObjectName(fo->getName());
insilmaril@366
  1074
	a->setToolTip(tr("Take care!","Standardflag"));
insilmaril@366
  1075
	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
insilmaril@166
  1076
	standardFlagsDefault->addFlag (fo);	// makes deep copy
insilmaril@166
  1077
	
insilmaril@408
  1078
	fo->load(flagsPath+"flag-questionmark.png");
insilmaril@166
  1079
	fo->setName("questionmark");
insilmaril@166
  1080
	fo->setGroup("standard-mark");
insilmaril@366
  1081
	a=new QAction (fo->getPixmap(),fo->getName(),this);
insilmaril@366
  1082
	tb->addAction (a);
insilmaril@366
  1083
	fo->setAction (a);
insilmaril@366
  1084
	a->setCheckable(true);
insilmaril@366
  1085
	a->setObjectName(fo->getName());
insilmaril@366
  1086
	a->setToolTip(tr("Really?","Standardflag"));
insilmaril@366
  1087
	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
insilmaril@166
  1088
	standardFlagsDefault->addFlag (fo);	
insilmaril@166
  1089
insilmaril@408
  1090
	fo->load(flagsPath+"flag-hook-green.png");
insilmaril@166
  1091
	fo->setName("hook-green");
insilmaril@166
  1092
	fo->setGroup("standard-hook");
insilmaril@366
  1093
	a=new QAction (fo->getPixmap(),fo->getName(),this);
insilmaril@366
  1094
	tb->addAction (a);
insilmaril@366
  1095
	fo->setAction (a);
insilmaril@366
  1096
	a->setCheckable(true);
insilmaril@366
  1097
	a->setObjectName(fo->getName());
insilmaril@366
  1098
	a->setToolTip(tr("ok!","Standardflag"));
insilmaril@366
  1099
	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
insilmaril@166
  1100
	standardFlagsDefault->addFlag (fo);	
insilmaril@166
  1101
insilmaril@408
  1102
	fo->load(flagsPath+"flag-cross-red.png");
insilmaril@166
  1103
	fo->setName("cross-red");
insilmaril@166
  1104
	fo->setGroup("standard-hook");
insilmaril@366
  1105
	a=new QAction (fo->getPixmap(),fo->getName(),this);
insilmaril@366
  1106
	tb->addAction (a);
insilmaril@366
  1107
	fo->setAction (a);
insilmaril@366
  1108
	a->setCheckable(true);
insilmaril@366
  1109
	a->setObjectName(fo->getName());
insilmaril@366
  1110
	a->setToolTip(tr("Not ok!","Standardflag"));
insilmaril@366
  1111
	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
insilmaril@166
  1112
	standardFlagsDefault->addFlag (fo);	
insilmaril@166
  1113
insilmaril@408
  1114
	fo->load(flagsPath+"flag-stopsign.png");
insilmaril@166
  1115
	fo->setName("stopsign");
insilmaril@366
  1116
	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("This won't work!","Standardflag"));
insilmaril@366
  1122
	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
insilmaril@166
  1123
	standardFlagsDefault->addFlag (fo);	
insilmaril@166
  1124
insilmaril@408
  1125
	fo->load(flagsPath+"flag-smiley-good.png");
insilmaril@166
  1126
	fo->setName("smiley-good");
insilmaril@166
  1127
	fo->setGroup("standard-smiley");
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("Good","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-smiley-sad.png");
insilmaril@166
  1138
	fo->setName("smiley-sad");
insilmaril@166
  1139
	fo->setGroup("standard-smiley");
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("Bad","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-smiley-omg.png");
insilmaril@269
  1150
	// Original omg.png (in KDE emoticons)
insilmaril@269
  1151
	fo->setName("smiley-omg");
insilmaril@269
  1152
	fo->setGroup("standard-smiley");
insilmaril@366
  1153
	a=new QAction (fo->getPixmap(),fo->getName(),this);
insilmaril@366
  1154
	tb->addAction (a);
insilmaril@366
  1155
	fo->setAction (a);
insilmaril@366
  1156
	a->setCheckable(true);
insilmaril@366
  1157
	a->setObjectName(fo->getName());
insilmaril@366
  1158
	a->setToolTip(tr("Oh no!","Standardflag"));
insilmaril@366
  1159
	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
insilmaril@269
  1160
	standardFlagsDefault->addFlag (fo);	
insilmaril@269
  1161
insilmaril@408
  1162
	fo->load(flagsPath+"flag-kalarm.png");
insilmaril@166
  1163
	fo->setName("clock");
insilmaril@366
  1164
	a=new QAction (fo->getPixmap(),fo->getName(),this);
insilmaril@366
  1165
	tb->addAction (a);
insilmaril@366
  1166
	fo->setAction (a);
insilmaril@366
  1167
	a->setCheckable(true);
insilmaril@366
  1168
	a->setObjectName(fo->getName());
insilmaril@366
  1169
	a->setToolTip(tr("Time critical","Standardflag"));
insilmaril@366
  1170
	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
insilmaril@166
  1171
	standardFlagsDefault->addFlag (fo);	
insilmaril@166
  1172
insilmaril@408
  1173
	fo->load(flagsPath+"flag-phone.png");
insilmaril@269
  1174
	fo->setName("phone");
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("Call...","Standardflag"));
insilmaril@366
  1181
	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
insilmaril@269
  1182
	standardFlagsDefault->addFlag (fo);	
insilmaril@269
  1183
insilmaril@408
  1184
	fo->load(flagsPath+"flag-lamp.png");
insilmaril@166
  1185
	fo->setName("lamp");
insilmaril@366
  1186
	a=new QAction (fo->getPixmap(),fo->getName(),this);
insilmaril@366
  1187
	tb->addAction (a);
insilmaril@366
  1188
	fo->setAction (a);
insilmaril@366
  1189
	a->setCheckable(true);
insilmaril@366
  1190
	a->setObjectName(fo->getName());
insilmaril@366
  1191
	a->setToolTip(tr("Idea!","Standardflag"));
insilmaril@366
  1192
	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
insilmaril@166
  1193
	standardFlagsDefault->addFlag (fo);	
insilmaril@166
  1194
insilmaril@408
  1195
	fo->load(flagsPath+"flag-arrow-up.png");
insilmaril@166
  1196
	fo->setName("arrow-up");
insilmaril@166
  1197
	fo->setGroup("standard-arrow");
insilmaril@366
  1198
	a=new QAction (fo->getPixmap(),fo->getName(),this);
insilmaril@366
  1199
	tb->addAction (a);
insilmaril@366
  1200
	fo->setAction (a);
insilmaril@366
  1201
	a->setCheckable(true);
insilmaril@366
  1202
	a->setObjectName(fo->getName());
insilmaril@366
  1203
	a->setToolTip(tr("Important","Standardflag"));
insilmaril@366
  1204
	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
insilmaril@166
  1205
	standardFlagsDefault->addFlag (fo);	
insilmaril@166
  1206
insilmaril@408
  1207
	fo->load(flagsPath+"flag-arrow-down.png");
insilmaril@166
  1208
	fo->setName("arrow-down");
insilmaril@166
  1209
	fo->setGroup("standard-arrow");
insilmaril@366
  1210
	a=new QAction (fo->getPixmap(),fo->getName(),this);
insilmaril@366
  1211
	tb->addAction (a);
insilmaril@366
  1212
	fo->setAction (a);
insilmaril@366
  1213
	a->setCheckable(true);
insilmaril@366
  1214
	a->setObjectName(fo->getName());
insilmaril@366
  1215
	a->setToolTip(tr("Unimportant","Standardflag"));
insilmaril@366
  1216
	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
insilmaril@166
  1217
	standardFlagsDefault->addFlag (fo);	
insilmaril@166
  1218
insilmaril@408
  1219
	fo->load(flagsPath+"flag-arrow-2up.png");
insilmaril@269
  1220
	fo->setName("2arrow-up");
insilmaril@269
  1221
	fo->setGroup("standard-arrow");
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("Very important!","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-arrow-2down.png");
insilmaril@269
  1232
	fo->setName("2arrow-down");
insilmaril@269
  1233
	fo->setGroup("standard-arrow");
insilmaril@366
  1234
	a=new QAction (fo->getPixmap(),fo->getName(),this);
insilmaril@366
  1235
	tb->addAction (a);
insilmaril@366
  1236
	fo->setAction (a);
insilmaril@366
  1237
	a->setCheckable(true);
insilmaril@366
  1238
	a->setObjectName(fo->getName());
insilmaril@366
  1239
	a->setToolTip(tr("Very unimportant!","Standardflag"));
insilmaril@366
  1240
	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
insilmaril@269
  1241
	standardFlagsDefault->addFlag (fo);	
insilmaril@269
  1242
insilmaril@408
  1243
	fo->load(flagsPath+"flag-thumb-up.png");
insilmaril@166
  1244
	fo->setName("thumb-up");
insilmaril@166
  1245
	fo->setGroup("standard-thumb");
insilmaril@366
  1246
	a=new QAction (fo->getPixmap(),fo->getName(),this);
insilmaril@366
  1247
	tb->addAction (a);
insilmaril@366
  1248
	fo->setAction (a);
insilmaril@366
  1249
	a->setCheckable(true);
insilmaril@366
  1250
	a->setObjectName(fo->getName());
insilmaril@366
  1251
	a->setToolTip(tr("I like this","Standardflag"));
insilmaril@366
  1252
	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
insilmaril@166
  1253
	standardFlagsDefault->addFlag (fo);	
insilmaril@166
  1254
insilmaril@408
  1255
	fo->load(flagsPath+"flag-thumb-down.png");
insilmaril@166
  1256
	fo->setName("thumb-down");
insilmaril@166
  1257
	fo->setGroup("standard-thumb");
insilmaril@366
  1258
	a=new QAction (fo->getPixmap(),fo->getName(),this);
insilmaril@366
  1259
	tb->addAction (a);
insilmaril@366
  1260
	fo->setAction (a);
insilmaril@366
  1261
	a->setCheckable(true);
insilmaril@366
  1262
	a->setObjectName(fo->getName());
insilmaril@366
  1263
	a->setToolTip(tr("I do not like this","Standardflag"));
insilmaril@366
  1264
	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
insilmaril@166
  1265
	standardFlagsDefault->addFlag (fo);	
insilmaril@166
  1266
	
insilmaril@408
  1267
	fo->load(flagsPath+"flag-rose.png");
insilmaril@269
  1268
	fo->setName("rose");
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("Rose","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-heart.png");
insilmaril@166
  1279
	fo->setName("heart");
insilmaril@366
  1280
	a=new QAction (fo->getPixmap(),fo->getName(),this);
insilmaril@366
  1281
	tb->addAction (a);
insilmaril@366
  1282
	a->setCheckable(true);
insilmaril@366
  1283
	a->setObjectName(fo->getName());
insilmaril@366
  1284
	a->setToolTip(tr("I just love... ","Standardflag"));
insilmaril@366
  1285
	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
insilmaril@166
  1286
	standardFlagsDefault->addFlag (fo);	
insilmaril@166
  1287
insilmaril@408
  1288
	fo->load(flagsPath+"flag-present.png");
insilmaril@269
  1289
	fo->setName("present");
insilmaril@366
  1290
	a=new QAction (fo->getPixmap(),fo->getName(),this);
insilmaril@366
  1291
	tb->addAction (a);
insilmaril@366
  1292
	fo->setAction (a);
insilmaril@366
  1293
	a->setCheckable(true);
insilmaril@366
  1294
	a->setObjectName(fo->getName());
insilmaril@366
  1295
	a->setToolTip(tr("Surprise!","Standardflag"));
insilmaril@366
  1296
	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
insilmaril@269
  1297
	standardFlagsDefault->addFlag (fo);	
insilmaril@269
  1298
insilmaril@408
  1299
	fo->load(flagsPath+"flag-flash.png");
insilmaril@166
  1300
	fo->setName("flash");
insilmaril@366
  1301
	a=new QAction (fo->getPixmap(),fo->getName(),this);
insilmaril@366
  1302
	tb->addAction (a);
insilmaril@366
  1303
	fo->setAction (a);
insilmaril@366
  1304
	a->setCheckable(true);
insilmaril@366
  1305
	a->setObjectName(fo->getName());
insilmaril@366
  1306
	a->setToolTip(tr("Dangerous","Standardflag"));
insilmaril@366
  1307
	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
insilmaril@166
  1308
	standardFlagsDefault->addFlag (fo);	
insilmaril@166
  1309
	
insilmaril@408
  1310
	fo->load(flagsPath+"flag-info.png");
insilmaril@269
  1311
	// Original: xsldbg_output.png
insilmaril@269
  1312
	fo->setName("info");
insilmaril@366
  1313
	a=new QAction (fo->getPixmap(),fo->getName(),this);
insilmaril@366
  1314
	tb->addAction (a);
insilmaril@366
  1315
	fo->setAction (a);
insilmaril@366
  1316
	a->setCheckable(true);
insilmaril@366
  1317
	a->setObjectName(fo->getName());
insilmaril@366
  1318
	a->setToolTip(tr("Info","Standardflag"));
insilmaril@366
  1319
	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
insilmaril@269
  1320
	standardFlagsDefault->addFlag (fo);	
insilmaril@269
  1321
insilmaril@408
  1322
	fo->load(flagsPath+"flag-lifebelt.png");
insilmaril@269
  1323
	// Original khelpcenter.png
insilmaril@166
  1324
	fo->setName("lifebelt");
insilmaril@366
  1325
	a=new QAction (fo->getPixmap(),fo->getName(),this);
insilmaril@366
  1326
	tb->addAction (a);
insilmaril@366
  1327
	fo->setAction (a);
insilmaril@366
  1328
	a->setCheckable(true);
insilmaril@366
  1329
	a->setObjectName(fo->getName());
insilmaril@366
  1330
	a->setToolTip(tr("This will help","Standardflag"));
insilmaril@366
  1331
	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
insilmaril@166
  1332
	standardFlagsDefault->addFlag (fo);	
insilmaril@243
  1333
insilmaril@166
  1334
	delete (fo);
insilmaril@0
  1335
}
insilmaril@0
  1336
insilmaril@0
  1337
// Settings Actions
insilmaril@0
  1338
void Main::setupSettingsActions()
insilmaril@0
  1339
{
insilmaril@366
  1340
    QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
insilmaril@0
  1341
insilmaril@0
  1342
	QAction *a;
insilmaril@0
  1343
insilmaril@395
  1344
    a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
insilmaril@366
  1345
    a->setStatusTip ( tr( "Set application to open pdf files"));
insilmaril@366
  1346
    connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
insilmaril@366
  1347
	settingsMenu->addAction (a);
insilmaril@366
  1348
insilmaril@395
  1349
    a = new QAction( tr( "Set application to open external links","Settings action"), this);
insilmaril@366
  1350
    a->setStatusTip( tr( "Set application to open external links"));
insilmaril@366
  1351
    connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
insilmaril@366
  1352
	settingsMenu->addAction (a);
insilmaril@366
  1353
insilmaril@366
  1354
	settingsMenu->addSeparator();
insilmaril@395
  1355
    a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
insilmaril@366
  1356
    a->setStatusTip( tr( "Edit branch after adding it" ));
insilmaril@0
  1357
	a->setToggleAction(true);
insilmaril@366
  1358
	a->setOn ( settings.value ("/mapeditor/editmode/autoEdit",true).toBool());
insilmaril@366
  1359
	settingsMenu->addAction (a);
insilmaril@390
  1360
	actionSettingsAutoEdit=a;
insilmaril@0
  1361
insilmaril@395
  1362
    a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
insilmaril@366
  1363
    a->setStatusTip( tr( "Select branch after adding it" ));
insilmaril@0
  1364
	a->setToggleAction(true);
insilmaril@366
  1365
	a->setOn ( settings.value ("/mapeditor/editmode/autoSelectHeading",false).toBool() );
insilmaril@366
  1366
	settingsMenu->addAction (a);
insilmaril@390
  1367
	actionSettingsAutoSelectHeading=a;
insilmaril@0
  1368
	
insilmaril@395
  1369
    a= new QAction(tr( "Select existing heading","Settings action" ), this);
insilmaril@366
  1370
    a->setStatusTip( tr( "Select heading before editing" ));
insilmaril@0
  1371
	a->setToggleAction(true);
insilmaril@366
  1372
	a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
insilmaril@366
  1373
	settingsMenu->addAction (a);
insilmaril@390
  1374
	actionSettingsAutoSelectText=a;
insilmaril@0
  1375
	
insilmaril@395
  1376
    a= new QAction( tr( "Delete key","Settings action" ), this);
insilmaril@366
  1377
    a->setStatusTip( tr( "Delete key for deleting branches" ));
insilmaril@0
  1378
	a->setToggleAction(true);
insilmaril@366
  1379
	a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",false).toBool() );
insilmaril@366
  1380
	settingsMenu->addAction (a);
insilmaril@366
  1381
    connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
insilmaril@366
  1382
	actionSettingsUseDelKey=a;
insilmaril@366
  1383
insilmaril@395
  1384
    a= new QAction( tr( "Exclusive flags","Settings action" ), this);
insilmaril@366
  1385
    a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
insilmaril@0
  1386
	a->setToggleAction(true);
insilmaril@366
  1387
	a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
insilmaril@366
  1388
	settingsMenu->addAction (a);
insilmaril@103
  1389
	actionSettingsUseFlagGroups=a;
insilmaril@260
  1390
	
insilmaril@395
  1391
    a= new QAction( tr( "Use hide flags","Settings action" ), this);
insilmaril@366
  1392
    a->setStatusTip( tr( "Use hide flag during exports " ));
insilmaril@260
  1393
	a->setToggleAction(true);
insilmaril@366
  1394
	a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
insilmaril@366
  1395
	settingsMenu->addAction (a);
insilmaril@260
  1396
	actionSettingsUseHideExport=a;
insilmaril@0
  1397
}
insilmaril@0
  1398
insilmaril@0
  1399
// Test Actions
insilmaril@0
  1400
void Main::setupTestActions()
insilmaril@0
  1401
{
insilmaril@366
  1402
    QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
insilmaril@0
  1403
insilmaril@0
  1404
    QAction *a;
insilmaril@395
  1405
    a = new QAction( "Test function" , this);
insilmaril@395
  1406
    a->setStatusTip( "Call test function" );
insilmaril@393
  1407
	a->setShortcut (Qt::Key_F4 );
insilmaril@366
  1408
    connect( a, SIGNAL( triggered() ), this, SLOT( testFunction() ) );
insilmaril@366
  1409
	testMenu->addAction (a);
insilmaril@395
  1410
    a = new QAction( "Command" , this);
insilmaril@395
  1411
    a->setStatusTip( "Enter command to call in editor" );
insilmaril@393
  1412
	a->setShortcut (Qt::Key_F5 );
insilmaril@393
  1413
    connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
insilmaril@393
  1414
	testMenu->addAction (a);
insilmaril@0
  1415
}
insilmaril@0
  1416
insilmaril@0
  1417
// Help Actions
insilmaril@0
  1418
void Main::setupHelpActions()
insilmaril@0
  1419
{
insilmaril@395
  1420
    QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
insilmaril@0
  1421
insilmaril@0
  1422
    QAction *a;
insilmaril@395
  1423
    a = new QAction(  tr( "Open VYM Documentation (pdf) ","Help action" ), this );
insilmaril@366
  1424
    a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
insilmaril@366
  1425
    connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
insilmaril@366
  1426
	helpMenu->addAction (a);
insilmaril@366
  1427
insilmaril@395
  1428
    a = new QAction( tr( "About VYM","Help action" ), this);
insilmaril@404
  1429
    a->setStatusTip( tr( "About VYM")+vymName);
insilmaril@366
  1430
    connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
insilmaril@366
  1431
	helpMenu->addAction (a);
insilmaril@366
  1432
insilmaril@395
  1433
    a = new QAction( tr( "About QT","Help action" ), this);
insilmaril@366
  1434
    a->setStatusTip( tr( "Information about QT toolkit" ));
insilmaril@366
  1435
    connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
insilmaril@366
  1436
	helpMenu->addAction (a);
insilmaril@0
  1437
}
insilmaril@0
  1438
insilmaril@0
  1439
// Context Menus
insilmaril@0
  1440
void Main::setupContextMenus()
insilmaril@0
  1441
{
insilmaril@0
  1442
	QAction*a;
insilmaril@0
  1443
insilmaril@0
  1444
	// Context Menu for branch or mapcenter
insilmaril@366
  1445
	branchContextMenu =new QMenu (this);
insilmaril@98
  1446
insilmaril@98
  1447
		// Submenu "Add"
insilmaril@366
  1448
		branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
insilmaril@366
  1449
		branchAddContextMenu->addAction (actionEditPaste );
insilmaril@366
  1450
		branchAddContextMenu->addAction ( actionEditAddBranch );
insilmaril@394
  1451
		branchAddContextMenu->addAction ( actionEditAddBranchBefore );
insilmaril@366
  1452
		branchAddContextMenu->addAction ( actionEditAddBranchAbove);
insilmaril@366
  1453
		branchAddContextMenu->addAction ( actionEditAddBranchBelow );
insilmaril@366
  1454
		branchAddContextMenu->addSeparator();	
insilmaril@366
  1455
		branchAddContextMenu->addAction ( actionEditImportAdd );
insilmaril@366
  1456
		branchAddContextMenu->addAction ( actionEditImportReplace );
insilmaril@98
  1457
insilmaril@98
  1458
		// Submenu "Remove"
insilmaril@395
  1459
		branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
insilmaril@366
  1460
		branchRemoveContextMenu->addAction (actionEditCut);
insilmaril@366
  1461
		branchRemoveContextMenu->addAction ( actionEditDelete );
insilmaril@395
  1462
		branchRemoveContextMenu->addAction ( actionEditDeleteKeepChilds );
insilmaril@395
  1463
		branchRemoveContextMenu->addAction ( actionEditDeleteChilds );
insilmaril@98
  1464
		
insilmaril@98
  1465
insilmaril@0
  1466
	actionEditSaveBranch->addTo( branchContextMenu );
insilmaril@98
  1467
insilmaril@366
  1468
	branchContextMenu->addSeparator();	
insilmaril@366
  1469
	branchContextMenu->addAction ( actionFormatFrameNone );
insilmaril@366
  1470
	branchContextMenu->addAction ( actionFormatFrameRectangle);
insilmaril@398
  1471
	branchContextMenu->addAction ( actionFormatHideLinkUnselected );
insilmaril@366
  1472
insilmaril@366
  1473
	branchContextMenu->addSeparator();	
insilmaril@398
  1474
	branchContextMenu->addAction ( actionEditLoadImage);
insilmaril@366
  1475
	branchContextMenu->addAction ( actionFormatIncludeImagesVer );
insilmaril@366
  1476
	branchContextMenu->addAction ( actionFormatIncludeImagesHor );
insilmaril@366
  1477
insilmaril@366
  1478
	// Submenu for Links (URLs, vymLinks)
insilmaril@366
  1479
	branchLinksContextMenu =new QMenu (this);
insilmaril@366
  1480
insilmaril@366
  1481
		branchContextMenu->addSeparator();	
insilmaril@395
  1482
		branchLinksContextMenu=branchContextMenu->addMenu(tr("URLs and vymLinks","Context menu name"));	
insilmaril@366
  1483
		branchLinksContextMenu->addAction ( actionEditOpenURL );
insilmaril@366
  1484
		branchLinksContextMenu->addAction ( actionEditOpenURLTab );
insilmaril@366
  1485
		branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
insilmaril@366
  1486
		branchLinksContextMenu->addAction ( actionEditURL );
insilmaril@366
  1487
		branchLinksContextMenu->addAction ( actionEditHeading2URL );
insilmaril@366
  1488
		branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
insilmaril@366
  1489
		if (settings.value( "/mainwindow/showTestMenu",true).toBool() )
insilmaril@366
  1490
		{
insilmaril@366
  1491
			branchLinksContextMenu->addAction ( actionEditFATE2URL );
insilmaril@366
  1492
		}	
insilmaril@366
  1493
		branchLinksContextMenu->addSeparator();	
insilmaril@366
  1494
		branchLinksContextMenu->addAction ( actionEditOpenVymLink );
insilmaril@366
  1495
		branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
insilmaril@366
  1496
		branchLinksContextMenu->addAction ( actionEditVymLink );
insilmaril@366
  1497
		branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
insilmaril@366
  1498
		
insilmaril@366
  1499
insilmaril@366
  1500
	// Context Menu for XLinks in a branch menu
insilmaril@89
  1501
	// This will be populated "on demand" in MapEditor::updateActions
insilmaril@366
  1502
	branchContextMenu->addSeparator();	
insilmaril@395
  1503
	branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
insilmaril@395
  1504
	branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
insilmaril@366
  1505
	connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
insilmaril@366
  1506
	connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
insilmaril@366
  1507
 	
insilmaril@105
  1508
	
insilmaril@0
  1509
	// Context menu for floatimage
insilmaril@366
  1510
	floatimageContextMenu =new QMenu (this);
insilmaril@395
  1511
	a= new QAction (tr ("Save image","Context action"),this);
insilmaril@366
  1512
	connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
insilmaril@366
  1513
	floatimageContextMenu->addAction (a);
insilmaril@366
  1514
insilmaril@366
  1515
	floatimageContextMenu->addSeparator();	
insilmaril@0
  1516
	actionEditCopy->addTo( floatimageContextMenu );
insilmaril@0
  1517
	actionEditCut->addTo( floatimageContextMenu );
insilmaril@0
  1518
insilmaril@366
  1519
	floatimageContextMenu->addSeparator();	
insilmaril@366
  1520
	floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
insilmaril@366
  1521
insilmaril@0
  1522
	
insilmaril@0
  1523
	// Context menu for canvas
insilmaril@366
  1524
	canvasContextMenu =new QMenu (this);
insilmaril@0
  1525
	actionEditMapInfo->addTo( canvasContextMenu );
insilmaril@0
  1526
	canvasContextMenu->insertSeparator();	
insilmaril@0
  1527
	actionGroupFormatLinkStyles->addTo( canvasContextMenu );
insilmaril@0
  1528
	canvasContextMenu->insertSeparator();	
insilmaril@0
  1529
	actionFormatLinkColorHint->addTo( canvasContextMenu );
insilmaril@0
  1530
	actionFormatLinkColor->addTo( canvasContextMenu );
insilmaril@0
  1531
	actionFormatBackColor->addTo( canvasContextMenu );
insilmaril@408
  1532
	actionFormatBackImage->addTo( canvasContextMenu );
insilmaril@0
  1533
insilmaril@0
  1534
	// Menu for last opened files
insilmaril@401
  1535
	// Create actions
insilmaril@401
  1536
	for (int i = 0; i < MaxRecentFiles; ++i) 
insilmaril@0
  1537
	{
insilmaril@401
  1538
        recentFileActs[i] = new QAction(this);
insilmaril@401
  1539
        recentFileActs[i]->setVisible(false);
insilmaril@401
  1540
        fileLastMapsMenu->addAction(recentFileActs[i]);
insilmaril@401
  1541
        connect(recentFileActs[i], SIGNAL(triggered()),
insilmaril@401
  1542
                this, SLOT(fileLoadRecent()));
insilmaril@401
  1543
    }
insilmaril@401
  1544
	setupRecentMapsMenu();
insilmaril@0
  1545
}
insilmaril@0
  1546
insilmaril@401
  1547
void Main::setupRecentMapsMenu()
insilmaril@0
  1548
{
insilmaril@401
  1549
    QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
insilmaril@401
  1550
insilmaril@401
  1551
    int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
insilmaril@401
  1552
insilmaril@401
  1553
    for (int i = 0; i < numRecentFiles; ++i) {
insilmaril@401
  1554
        //QString text = tr("&%1 %2").arg(i + 1).arg(strippedName(files[i]));
insilmaril@401
  1555
        QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
insilmaril@401
  1556
        recentFileActs[i]->setText(text);
insilmaril@401
  1557
        recentFileActs[i]->setData(files[i]);
insilmaril@401
  1558
        recentFileActs[i]->setVisible(true);
insilmaril@401
  1559
    }
insilmaril@401
  1560
    for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
insilmaril@401
  1561
        recentFileActs[j]->setVisible(false);
insilmaril@0
  1562
}
insilmaril@0
  1563
insilmaril@0
  1564
void Main::hideEvent (QHideEvent * )
insilmaril@0
  1565
{
insilmaril@0
  1566
	if (!textEditor->isMinimized() ) textEditor->hide();
insilmaril@0
  1567
}
insilmaril@0
  1568
insilmaril@0
  1569
void Main::showEvent (QShowEvent * )
insilmaril@0
  1570
{
insilmaril@117
  1571
	if (textEditor->showWithMain()) textEditor->showNormal();
insilmaril@0
  1572
}
insilmaril@0
  1573
insilmaril@0
  1574
bool Main::reallyWriteDirectory(const QString &dir)
insilmaril@0
  1575
{
insilmaril@0
  1576
	QStringList eList = QDir(dir).entryList();
insilmaril@0
  1577
	if (eList.first() ==".")  eList.pop_front();	// remove "."
insilmaril@0
  1578
	if (eList.first() =="..") eList.pop_front();	// remove "."
insilmaril@0
  1579
	if (!eList.isEmpty())
insilmaril@0
  1580
	{
insilmaril@404
  1581
		QMessageBox mb( vymName,
insilmaril@395
  1582
			tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?","write directory").arg(dir),
insilmaril@0
  1583
		QMessageBox::Warning,
insilmaril@0
  1584
		QMessageBox::Yes ,
insilmaril@0
  1585
		QMessageBox::Cancel | QMessageBox::Default,
insilmaril@0
  1586
		QMessageBox::QMessageBox::NoButton );
insilmaril@0
  1587
insilmaril@0
  1588
		mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
insilmaril@0
  1589
		mb.setButtonText( QMessageBox::No, tr("Cancel"));
insilmaril@0
  1590
		switch( mb.exec() ) 
insilmaril@0
  1591
		{
insilmaril@0
  1592
			case QMessageBox::Yes:
insilmaril@0
  1593
				// save 
insilmaril@0
  1594
				return true;
insilmaril@0
  1595
			case QMessageBox::Cancel:
insilmaril@0
  1596
				// do nothing
insilmaril@0
  1597
				return false;
insilmaril@0
  1598
		}
insilmaril@0
  1599
	}
insilmaril@0
  1600
	return true;
insilmaril@0
  1601
}
insilmaril@0
  1602
insilmaril@0
  1603
QString Main::browseDirectory (const QString &caption)
insilmaril@0
  1604
{
insilmaril@404
  1605
	QFileDialog fd(this,caption);
insilmaril@404
  1606
	fd.setMode (QFileDialog::DirectoryOnly);
insilmaril@404
  1607
	fd.setCaption(vymName+ " - "+caption);
insilmaril@0
  1608
	fd.show();
insilmaril@0
  1609
	
insilmaril@0
  1610
	if ( fd.exec() == QDialog::Accepted )
insilmaril@0
  1611
		return fd.selectedFile();
insilmaril@0
  1612
	else
insilmaril@0
  1613
		return "";
insilmaril@0
  1614
}
insilmaril@0
  1615
insilmaril@0
  1616
MapEditor* Main::currentMapEditor() const
insilmaril@0
  1617
{
insilmaril@0
  1618
    if ( tabWidget->currentPage() &&
insilmaril@0
  1619
	 tabWidget->currentPage()->inherits( "MapEditor" ) )
insilmaril@0
  1620
		return (MapEditor*)tabWidget->currentPage();
insilmaril@0
  1621
    return NULL;	
insilmaril@0
  1622
}
insilmaril@0
  1623
insilmaril@0
  1624
insilmaril@0
  1625
void Main::editorChanged(QWidget *)
insilmaril@0
  1626
{
insilmaril@0
  1627
	// Unselect all possibly selected objects
insilmaril@0
  1628
	// (Important to update note editor)
insilmaril@0
  1629
	int i;
insilmaril@0
  1630
	MapEditor *me;
insilmaril@0
  1631
	for (i=0;i<=tabWidget->count() -1;i++)
insilmaril@0
  1632
	{
insilmaril@0
  1633
		
insilmaril@0
  1634
		me=(MapEditor*)tabWidget->page(i);
insilmaril@0
  1635
		me->unselect();
insilmaril@0
  1636
	}	
insilmaril@0
  1637
	currentMapEditor()->reselect();
insilmaril@0
  1638
insilmaril@0
  1639
	// Update actions to in menus and toolbars according to editor
insilmaril@407
  1640
	updateActions();
insilmaril@0
  1641
}
insilmaril@0
  1642
insilmaril@0
  1643
void Main::fileNew()
insilmaril@0
  1644
{
insilmaril@0
  1645
	QString fn="unnamed";
insilmaril@408
  1646
	MapEditor* me = new MapEditor ( NULL);
insilmaril@408
  1647
	tabWidget->addTab (me,fn);
insilmaril@408
  1648
	tabWidget->showPage(me);
insilmaril@408
  1649
	me->viewport()->setFocus();
insilmaril@408
  1650
	me->setAntiAlias (actionViewToggleAntiAlias->isOn());
insilmaril@408
  1651
	me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
insilmaril@408
  1652
	
insilmaril@366
  1653
	// For the very first map we do not have flagrows yet...
insilmaril@408
  1654
	me->select("mc:");
insilmaril@0
  1655
}
insilmaril@0
  1656
insilmaril@205
  1657
ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
insilmaril@0
  1658
{
insilmaril@205
  1659
	ErrorCode err=success;
insilmaril@0
  1660
	
insilmaril@0
  1661
	// fn is usually the archive, mapfile the file after uncompressing
insilmaril@0
  1662
	QString mapfile;
insilmaril@0
  1663
insilmaril@0
  1664
	// Make fn absolute (needed for unzip)
insilmaril@0
  1665
	fn=QDir (fn).absPath();
insilmaril@0
  1666
insilmaril@0
  1667
	MapEditor *me;
insilmaril@0
  1668
insilmaril@0
  1669
	if (lmode==NewMap)
insilmaril@0
  1670
	{
insilmaril@0
  1671
		// Check, if map is already loaded
insilmaril@0
  1672
		int i=0;
insilmaril@0
  1673
		while (i<=tabWidget->count() -1)
insilmaril@0
  1674
		{
insilmaril@0
  1675
			me=(MapEditor*)tabWidget->page(i);
insilmaril@0
  1676
			if (me->getFilePath() == fn)
insilmaril@0
  1677
			{
insilmaril@0
  1678
				// Already there, ask for confirmation
insilmaril@404
  1679
				QMessageBox mb( vymName,
insilmaril@159
  1680
					tr("The map %1\nis already opened."
insilmaril@0
  1681
					"Opening the same map in multiple editors may lead \n"
insilmaril@0
  1682
					"to confusion when finishing working with vym."
insilmaril@159
  1683
					"Do you want to").arg(fn),
insilmaril@0
  1684
					QMessageBox::Warning,
insilmaril@0
  1685
					QMessageBox::Yes | QMessageBox::Default,
insilmaril@0
  1686
					QMessageBox::Cancel | QMessageBox::Escape,
insilmaril@366
  1687
					QMessageBox::NoButton);
insilmaril@0
  1688
				mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
insilmaril@0
  1689
				mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
insilmaril@0
  1690
				switch( mb.exec() ) 
insilmaril@0
  1691
				{
insilmaril@0
  1692
					case QMessageBox::Yes:
insilmaril@0
  1693
						// load anyway
insilmaril@0
  1694
						i=tabWidget->count();
insilmaril@0
  1695
						break;
insilmaril@0
  1696
					case QMessageBox::Cancel:
insilmaril@0
  1697
						// do nothing
insilmaril@205
  1698
						return aborted;
insilmaril@0
  1699
						break;
insilmaril@0
  1700
				}
insilmaril@0
  1701
			}
insilmaril@0
  1702
			i++;
insilmaril@0
  1703
		}
insilmaril@0
  1704
	}
insilmaril@0
  1705
insilmaril@0
  1706
insilmaril@0
  1707
	// Try to load map
insilmaril@0
  1708
    if ( !fn.isEmpty() )
insilmaril@0
  1709
	{
insilmaril@0
  1710
		me = currentMapEditor();
insilmaril@0
  1711
		int tabIndex=tabWidget->currentPageIndex();
insilmaril@0
  1712
		// Check first, if mapeditor exists
insilmaril@0
  1713
		// If it is not default AND we want a new map, 
insilmaril@0
  1714
		// create a new mapeditor in a new tab
insilmaril@0
  1715
		if ( lmode==NewMap && (!me || !me->isDefault() ) )
insilmaril@0
  1716
		{
insilmaril@390
  1717
			me= new MapEditor ( NULL);
insilmaril@0
  1718
			tabWidget->addTab (me,fn);
insilmaril@0
  1719
			tabIndex=tabWidget->indexOf (me);
insilmaril@0
  1720
			tabWidget->setCurrentPage (tabIndex);
insilmaril@408
  1721
			me->setAntiAlias (actionViewToggleAntiAlias->isOn());
insilmaril@408
  1722
			me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
insilmaril@0
  1723
		}
insilmaril@0
  1724
		
insilmaril@0
  1725
		// Check, if file exists (important for creating new files
insilmaril@0
  1726
		// from command line
insilmaril@0
  1727
		if (!QFile(fn).exists() )
insilmaril@0
  1728
		{
insilmaril@404
  1729
			QMessageBox mb( vymName,
insilmaril@159
  1730
				tr("This map does not exist:\n  %1\nDo you want to create a new one?").arg(fn),
insilmaril@0
  1731
				QMessageBox::Question,
insilmaril@0
  1732
				QMessageBox::Yes ,
insilmaril@0
  1733
				QMessageBox::Cancel | QMessageBox::Default,
insilmaril@366
  1734
				QMessageBox::NoButton );
insilmaril@0
  1735
insilmaril@0
  1736
			mb.setButtonText( QMessageBox::Yes, tr("Create"));
insilmaril@0
  1737
			mb.setButtonText( QMessageBox::No, tr("Cancel"));
insilmaril@0
  1738
			switch( mb.exec() ) 
insilmaril@0
  1739
			{
insilmaril@0
  1740
				case QMessageBox::Yes:
insilmaril@0
  1741
					// Create new map
insilmaril@0
  1742
					currentMapEditor()->setFilePath(fn);
insilmaril@0
  1743
					tabWidget->setTabLabel (currentMapEditor(),
insilmaril@0
  1744
						currentMapEditor()->getFileName() );
insilmaril@0
  1745
					statusBar()->message( "Created " + fn , statusbarTime );
insilmaril@205
  1746
					return success;
insilmaril@0
  1747
						
insilmaril@0
  1748
				case QMessageBox::Cancel:
insilmaril@0
  1749
					// don't create new map
insilmaril@0
  1750
					statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
insilmaril@0
  1751
					fileCloseMap();
insilmaril@205
  1752
					return aborted;
insilmaril@0
  1753
			}
insilmaril@0
  1754
		}	
insilmaril@0
  1755
insilmaril@0
  1756
insilmaril@0
  1757
		//tabWidget->currentPage() won't be NULL here, because of above...
insilmaril@0
  1758
		tabWidget->showPage(me);
insilmaril@0
  1759
		me->viewport()->setFocus();
insilmaril@0
  1760
insilmaril@0
  1761
		// Create temporary directory for packing
insilmaril@377
  1762
		bool ok;
insilmaril@377
  1763
		QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
insilmaril@377
  1764
		if (!ok)
insilmaril@377
  1765
		{
insilmaril@377
  1766
			QMessageBox::critical( 0, tr( "Critical Load Error" ),
insilmaril@377
  1767
			   tr("Couldn't create temporary directory before load\n"));
insilmaril@377
  1768
			return aborted; 
insilmaril@377
  1769
		}
insilmaril@0
  1770
insilmaril@0
  1771
		// Try to unzip file
insilmaril@185
  1772
		err=unzipDir (tmpMapDir,fn);
insilmaril@185
  1773
		if (err==nozip)
insilmaril@0
  1774
		{
insilmaril@185
  1775
			mapfile=fn;
insilmaril@185
  1776
			me->setZipped(false);
insilmaril@0
  1777
		} else
insilmaril@0
  1778
		{
insilmaril@185
  1779
			me->setZipped(true);
insilmaril@185
  1780
			
insilmaril@185
  1781
			// Look for mapname.xml
insilmaril@185
  1782
			mapfile= fn.left(fn.findRev(".",-1,true));
insilmaril@185
  1783
			mapfile=mapfile.section( '/', -1 );
insilmaril@185
  1784
			QFile file( tmpMapDir + "/" + mapfile + ".xml");
insilmaril@185
  1785
			if (!file.exists() )
insilmaril@0
  1786
			{
insilmaril@185
  1787
				// mapname.xml does not exist, well, 
insilmaril@185
  1788
				// maybe some renamed the mapname.vym file...
insilmaril@185
  1789
				// Try to find any .xml in the toplevel 
insilmaril@185
  1790
				// directory of the .vym file
insilmaril@185
  1791
				QStringList flist=QDir (tmpMapDir).entryList("*.xml");
insilmaril@185
  1792
				if (flist.count()==1) 
insilmaril@0
  1793
				{
insilmaril@185
  1794
					// Only one entry, take this one
insilmaril@185
  1795
					mapfile=tmpMapDir + "/"+flist.first();
insilmaril@0
  1796
				} else
insilmaril@185
  1797
				{
insilmaril@185
  1798
					for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it ) 
insilmaril@185
  1799
						*it=tmpMapDir + "/" + *it;
insilmaril@185
  1800
					// TODO Multiple entries, load all (but only the first one into this ME)
insilmaril@185
  1801
					//mainWindow->fileLoadFromTmp (flist);
insilmaril@185
  1802
					//returnCode=1;	// Silently forget this attempt to load
insilmaril@185
  1803
					qWarning ("MainWindow::load (fn)  multimap found...");
insilmaril@185
  1804
				}	
insilmaril@0
  1805
					
insilmaril@185
  1806
				if (flist.isEmpty() )
insilmaril@185
  1807
				{
insilmaril@185
  1808
					QMessageBox::critical( 0, tr( "Critical Load Error" ),
insilmaril@185
  1809
							   tr("Couldn't find a map (*.xml) in .vym archive.\n"));
insilmaril@185
  1810
					err=aborted;				   
insilmaril@185
  1811
				}	
insilmaril@185
  1812
			} //file doesn't exist	
insilmaril@185
  1813
			else
insilmaril@185
  1814
				mapfile=file.name();
insilmaril@0
  1815
		}
insilmaril@0
  1816
insilmaril@185
  1817
		if (err!=aborted)
insilmaril@185
  1818
		{
insilmaril@185
  1819
			// Save existing filename in case  we import
insilmaril@185
  1820
			QString fn_org=me->getFilePath();
insilmaril@106
  1821
insilmaril@185
  1822
			// Finally load map into mapEditor
insilmaril@185
  1823
			me->setFilePath (mapfile,fn);
insilmaril@205
  1824
			err=me->load(mapfile,lmode);
insilmaril@106
  1825
insilmaril@185
  1826
			// Restore old (maybe empty) filepath, if this is an import
insilmaril@185
  1827
			if (lmode!=NewMap)
insilmaril@185
  1828
				me->setFilePath (fn_org);
insilmaril@185
  1829
		}	
insilmaril@0
  1830
insilmaril@185
  1831
		// Finally check for errors and go home
insilmaril@185
  1832
		if (err==aborted) 
insilmaril@185
  1833
		{
insilmaril@185
  1834
			if (lmode==NewMap) fileCloseMap();
insilmaril@185
  1835
			statusBar()->message( "Could not load " + fn, statusbarTime );
insilmaril@185
  1836
		} else 
insilmaril@0
  1837
		{
insilmaril@0
  1838
			if (lmode==NewMap)
insilmaril@0
  1839
			{
insilmaril@0
  1840
				me->setFilePath (fn);
insilmaril@0
  1841
				tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
insilmaril@205
  1842
				if (fn.left(9)!="/tmp/vym-")
insilmaril@205
  1843
				{
insilmaril@205
  1844
					// Only append to lastMaps if not loaded from a tmpDir
insilmaril@205
  1845
					// e.g. imported bookmarks are in a tmpDir
insilmaril@401
  1846
					addRecentMap(me->getFilePath() );
insilmaril@205
  1847
				}
insilmaril@0
  1848
				actionFilePrint->setEnabled (true);
insilmaril@0
  1849
			}	
insilmaril@0
  1850
			statusBar()->message( "Loaded " + fn, statusbarTime );
insilmaril@0
  1851
		}	
insilmaril@0
  1852
insilmaril@185
  1853
		// Delete tmpDir
insilmaril@185
  1854
		removeDir (QDir(tmpMapDir));
insilmaril@0
  1855
	}
insilmaril@205
  1856
	return err;
insilmaril@0
  1857
}
insilmaril@0
  1858
insilmaril@0
  1859
insilmaril@0
  1860
void Main::fileLoad(const LoadMode &lmode)
insilmaril@0
  1861
{
insilmaril@377
  1862
	QStringList filters;
insilmaril@389
  1863
	filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
insilmaril@377
  1864
	QFileDialog *fd=new QFileDialog( this);
insilmaril@366
  1865
	fd->setDir (lastFileDir);
insilmaril@377
  1866
	fd->setFileMode (QFileDialog::ExistingFiles);
insilmaril@377
  1867
	fd->setFilters (filters);
insilmaril@0
  1868
	switch (lmode)
insilmaril@0
  1869
	{
insilmaril@0
  1870
		case NewMap:
insilmaril@404
  1871
			fd->setCaption(vymName+ " - " +tr("Load vym map"));
insilmaril@0
  1872
			break;
insilmaril@0
  1873
		case ImportAdd:
insilmaril@404
  1874
			fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
insilmaril@0
  1875
			break;
insilmaril@0
  1876
		case ImportReplace:
insilmaril@404
  1877
			fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
insilmaril@0
  1878
			break;
insilmaril@0
  1879
	}
insilmaril@0
  1880
	fd->show();
insilmaril@0
  1881
insilmaril@0
  1882
	QString fn;
insilmaril@0
  1883
	if ( fd->exec() == QDialog::Accepted )
insilmaril@0
  1884
	{
insilmaril@377
  1885
		lastFileDir=fd->directory().path();
insilmaril@185
  1886
	    QStringList flist = fd->selectedFiles();
insilmaril@185
  1887
		QStringList::Iterator it = flist.begin();
insilmaril@185
  1888
		while( it != flist.end() ) 
insilmaril@185
  1889
		{
insilmaril@185
  1890
			fn = *it;
insilmaril@185
  1891
			fileLoad(*it, lmode);				   
insilmaril@185
  1892
			++it;
insilmaril@185
  1893
		}
insilmaril@0
  1894
	}
insilmaril@185
  1895
	delete (fd);
insilmaril@0
  1896
}
insilmaril@0
  1897
insilmaril@0
  1898
void Main::fileLoad()
insilmaril@0
  1899
{
insilmaril@0
  1900
	fileLoad (NewMap);
insilmaril@0
  1901
}
insilmaril@0
  1902
insilmaril@401
  1903
void Main::fileLoadRecent()
insilmaril@0
  1904
{
insilmaril@401
  1905
    QAction *action = qobject_cast<QAction *>(sender());
insilmaril@401
  1906
    if (action)
insilmaril@401
  1907
        fileLoad (action->data().toString(), NewMap);
insilmaril@401
  1908
}
insilmaril@401
  1909
insilmaril@401
  1910
void Main::addRecentMap (const QString &fileName)
insilmaril@401
  1911
{
insilmaril@401
  1912
insilmaril@401
  1913
    QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
insilmaril@401
  1914
    files.removeAll(fileName);
insilmaril@401
  1915
    files.prepend(fileName);
insilmaril@401
  1916
    while (files.size() > MaxRecentFiles)
insilmaril@401
  1917
        files.removeLast();
insilmaril@401
  1918
insilmaril@401
  1919
    settings.setValue("/mainwindow/recentFileList", files);
insilmaril@401
  1920
insilmaril@401
  1921
	setupRecentMapsMenu();
insilmaril@0
  1922
}
insilmaril@0
  1923
insilmaril@0
  1924
void Main::fileSave(const SaveMode &savemode)
insilmaril@0
  1925
{
insilmaril@0
  1926
	// tmp dir for zipping 
insilmaril@0
  1927
	QString tmpMapDir;
insilmaril@0
  1928
	
insilmaril@0
  1929
	// Error codes
insilmaril@205
  1930
	ErrorCode err=success;
insilmaril@0
  1931
	
insilmaril@0
  1932
	QString safeFilePath;
insilmaril@0
  1933
insilmaril@0
  1934
	bool saveZipped=currentMapEditor()->saveZipped();
insilmaril@0
  1935
insilmaril@151
  1936
	MapEditor *	me=currentMapEditor();
insilmaril@151
  1937
	if (me)
insilmaril@0
  1938
	{
insilmaril@151
  1939
		QString fn=me->getFilePath();
insilmaril@0
  1940
		// filename=unnamed, filepath="" in constructor...
insilmaril@0
  1941
		if ( !fn.isEmpty() ) 
insilmaril@0
  1942
		{	
insilmaril@0
  1943
			// We have a filepath, go on saving			
insilmaril@0
  1944
			// First remove existing file, we 
insilmaril@0
  1945
			// don't want to add to old zip archives
insilmaril@0
  1946
			QFile f(fn);
insilmaril@0
  1947
			if (f.exists() ) 
insilmaril@0
  1948
				if (!f.remove())
insilmaril@0
  1949
					QMessageBox::warning( 0, tr( "Save Error" ),
insilmaril@0
  1950
						fn+   tr("\ncould not be removed before saving"));
insilmaril@0
  1951
insilmaril@0
  1952
			// Look, if we should zip the data:
insilmaril@0
  1953
			if (!saveZipped)
insilmaril@0
  1954
			{
insilmaril@404
  1955
				QMessageBox mb( vymName,
insilmaril@159
  1956
					tr("The map %1\ndid not use the compressed "
insilmaril@0
  1957
					"vym file format.\nWriting it uncompressed will also write images \n"
insilmaril@0
  1958
					"and flags and thus may overwrite files in the "
insilmaril@159
  1959
					"given directory\n\nDo you want to write the map").arg(fn),
insilmaril@0
  1960
					QMessageBox::Warning,
insilmaril@0
  1961
					QMessageBox::Yes | QMessageBox::Default,
insilmaril@0
  1962
					QMessageBox::No ,
insilmaril@0
  1963
					QMessageBox::Cancel | QMessageBox::Escape);
insilmaril@0
  1964
				mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
insilmaril@0
  1965
				mb.setButtonText( QMessageBox::No, tr("uncompressed") );
insilmaril@0
  1966
				mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
insilmaril@0
  1967
				switch( mb.exec() ) 
insilmaril@0
  1968
				{
insilmaril@0
  1969
					case QMessageBox::Yes:
insilmaril@0
  1970
						// save compressed (default file format)
insilmaril@0
  1971
						saveZipped=true;
insilmaril@0
  1972
						break;
insilmaril@0
  1973
					case QMessageBox::No:
insilmaril@0
  1974
						// save uncompressed
insilmaril@0
  1975
						saveZipped=false;
insilmaril@0
  1976
						break;
insilmaril@0
  1977
					case QMessageBox::Cancel:
insilmaril@0
  1978
						// do nothing
insilmaril@0
  1979
						return;
insilmaril@0
  1980
						break;
insilmaril@0
  1981
				}
insilmaril@0
  1982
			}
insilmaril@0
  1983
insilmaril@0
  1984
			if (saveZipped)
insilmaril@0
  1985
			{
insilmaril@377
  1986
				// Create temporary directory for packing
insilmaril@377
  1987
				bool ok;
insilmaril@377
  1988
				QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
insilmaril@377
  1989
				if (!ok)
insilmaril@377
  1990
				{
insilmaril@377
  1991
					QMessageBox::critical( 0, tr( "Critical Load Error" ),
insilmaril@377
  1992
					   tr("Couldn't create temporary directory before save\n"));
insilmaril@377
  1993
					return; 
insilmaril@377
  1994
				}
insilmaril@377
  1995
insilmaril@151
  1996
				safeFilePath=me->getFilePath();
insilmaril@151
  1997
				me->setFilePath (tmpMapDir+"/"+
insilmaril@151
  1998
					me->getMapName()+ ".xml",
insilmaril@0
  1999
					safeFilePath);
insilmaril@151
  2000
				me->save (savemode);
insilmaril@151
  2001
				me->setFilePath (safeFilePath);
insilmaril@0
  2002
				
insilmaril@175
  2003
				zipDir (tmpMapDir,fn);
insilmaril@0
  2004
			} // save zipped
insilmaril@0
  2005
			else
insilmaril@0
  2006
			{
insilmaril@0
  2007
				// Save unzipped. 
insilmaril@151
  2008
				safeFilePath=me->getFilePath();
insilmaril@151
  2009
				me->setFilePath (fn, safeFilePath);
insilmaril@151
  2010
				me->save (savemode);
insilmaril@151
  2011
				me->setFilePath (safeFilePath);
insilmaril@0
  2012
			} // save zipped 	
insilmaril@0
  2013
		} // filepath available
insilmaril@0
  2014
		else
insilmaril@0
  2015
		{
insilmaril@0
  2016
			// We have  no filepath yet,
insilmaril@0
  2017
			// call fileSaveAs() now, this will call fileSave() 
insilmaril@0
  2018
			// again.
insilmaril@0
  2019
			fileSaveAs(savemode);
insilmaril@0
  2020
		}
insilmaril@0
  2021
    }
insilmaril@0
  2022
insilmaril@250
  2023
	if (saveZipped && !tmpMapDir.isEmpty())
insilmaril@0
  2024
		// Delete tmpDir
insilmaril@175
  2025
		removeDir (QDir(tmpMapDir));
insilmaril@0
  2026
insilmaril@0
  2027
	if (err==success)
insilmaril@151
  2028
	{
insilmaril@0
  2029
		statusBar()->message( 
insilmaril@159
  2030
			tr("Saved  %1").arg(me->getFilePath()), 
insilmaril@0
  2031
			statusbarTime );
insilmaril@401
  2032
		addRecentMap (me->getFilePath() );
insilmaril@151
  2033
	} else		
insilmaril@0
  2034
		statusBar()->message( 
insilmaril@159
  2035
			tr("Couldn't save ").arg(me->getFilePath()), 
insilmaril@0
  2036
			statusbarTime );
insilmaril@0
  2037
}
insilmaril@0
  2038
insilmaril@0
  2039
void Main::fileSave()
insilmaril@0
  2040
{
insilmaril@0
  2041
	fileSave (CompleteMap);
insilmaril@0
  2042
}
insilmaril@0
  2043
insilmaril@0
  2044
void Main::fileSaveAs(const SaveMode& savemode)
insilmaril@0
  2045
{
insilmaril@0
  2046
	QString fn;
insilmaril@0
  2047
insilmaril@0
  2048
	if (currentMapEditor())
insilmaril@0
  2049
	{
insilmaril@0
  2050
		if (savemode==CompleteMap)
insilmaril@366
  2051
			fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
insilmaril@0
  2052
		else		
insilmaril@366
  2053
			fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
insilmaril@0
  2054
		if ( !fn.isEmpty() ) 
insilmaril@0
  2055
		{
insilmaril@0
  2056
			// Check for existing file
insilmaril@0
  2057
			if (QFile (fn).exists())
insilmaril@0
  2058
			{
insilmaril@404
  2059
				QMessageBox mb( vymName,
insilmaril@159
  2060
					tr("The file %1\nexists already. Do you want to").arg(fn),
insilmaril@0
  2061
					QMessageBox::Warning,
insilmaril@0
  2062
					QMessageBox::Yes | QMessageBox::Default,
insilmaril@0
  2063
					QMessageBox::Cancel | QMessageBox::Escape,
insilmaril@366
  2064
					QMessageBox::NoButton);
insilmaril@0
  2065
				mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
insilmaril@0
  2066
				mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
insilmaril@0
  2067
				switch( mb.exec() ) 
insilmaril@0
  2068
				{
insilmaril@0
  2069
					case QMessageBox::Yes:
insilmaril@0
  2070
						// save 
insilmaril@0
  2071
						break;
insilmaril@0
  2072
					case QMessageBox::Cancel:
insilmaril@0
  2073
						// do nothing
insilmaril@0
  2074
						return;
insilmaril@0
  2075
						break;
insilmaril@0
  2076
				}
insilmaril@0
  2077
			} else
insilmaril@0
  2078
			{
insilmaril@0
  2079
				// New file, add extension to filename, if missing
insilmaril@0
  2080
				// This is always .vym or .vyp, depending on savemode
insilmaril@0
  2081
				if (savemode==CompleteMap)
insilmaril@0
  2082
				{
insilmaril@0
  2083
					if (!fn.contains (".vym") && !fn.contains (".xml"))
insilmaril@0
  2084
						fn +=".vym";
insilmaril@0
  2085
				} else		
insilmaril@0
  2086
				{
insilmaril@0
  2087
					if (!fn.contains (".vyp") && !fn.contains (".xml"))
insilmaril@0
  2088
						fn +=".vyp";
insilmaril@0
  2089
				}
insilmaril@0
  2090
			}
insilmaril@0
  2091
	
insilmaril@0
  2092
insilmaril@0
  2093
insilmaril@0
  2094
insilmaril@0
  2095
			// Save now
insilmaril@0
  2096
			currentMapEditor()->setFilePath(fn);
insilmaril@0
  2097
			fileSave(savemode);
insilmaril@0
  2098
insilmaril@0
  2099
			// Set name of tab
insilmaril@94
  2100
			if (savemode==CompleteMap)
insilmaril@94
  2101
				tabWidget->setTabLabel (currentMapEditor(),
insilmaril@94
  2102
					currentMapEditor()->getFileName() );
insilmaril@0
  2103
			return;
insilmaril@0
  2104
		} 
insilmaril@0
  2105
	}
insilmaril@0
  2106
}
insilmaril@0
  2107
insilmaril@0
  2108
void Main::fileSaveAs()
insilmaril@0
  2109
{
insilmaril@0
  2110
	fileSaveAs (CompleteMap);
insilmaril@0
  2111
}
insilmaril@0
  2112
insilmaril@205
  2113
void Main::fileImportKDEBookmarks()
insilmaril@205
  2114
{
insilmaril@205
  2115
	ImportKDEBookmarks im;
insilmaril@205
  2116
	im.transform();
insilmaril@205
  2117
	if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
insilmaril@205
  2118
		currentMapEditor()->setFilePath ("");
insilmaril@205
  2119
}
insilmaril@205
  2120
insilmaril@314
  2121
void Main::fileImportFirefoxBookmarks()
insilmaril@314
  2122
{
insilmaril@366
  2123
	Q3FileDialog *fd=new Q3FileDialog( this);
insilmaril@327
  2124
	fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
insilmaril@366
  2125
	fd->setMode (Q3FileDialog::ExistingFiles);
insilmaril@327
  2126
	fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
insilmaril@327
  2127
	fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
insilmaril@327
  2128
	fd->show();
insilmaril@327
  2129
insilmaril@327
  2130
	if ( fd->exec() == QDialog::Accepted )
insilmaril@327
  2131
	{
insilmaril@327
  2132
		ImportFirefoxBookmarks im;
insilmaril@327
  2133
	    QStringList flist = fd->selectedFiles();
insilmaril@327
  2134
		QStringList::Iterator it = flist.begin();
insilmaril@327
  2135
		while( it != flist.end() ) 
insilmaril@327
  2136
		{
insilmaril@327
  2137
			im.setFile (*it);
insilmaril@327
  2138
			if (im.transform() && 
insilmaril@327
  2139
				success==fileLoad (im.getTransformedFile(),NewMap) && 
insilmaril@327
  2140
				currentMapEditor() )
insilmaril@327
  2141
				currentMapEditor()->setFilePath ("");
insilmaril@327
  2142
			++it;
insilmaril@327
  2143
		}
insilmaril@327
  2144
	}
insilmaril@327
  2145
	delete (fd);
insilmaril@314
  2146
}
insilmaril@314
  2147
insilmaril@215
  2148
void Main::fileImportMM()
insilmaril@215
  2149
{
insilmaril@215
  2150
	ImportMM im;
insilmaril@215
  2151
insilmaril@366
  2152
	Q3FileDialog *fd=new Q3FileDialog( this);
insilmaril@366
  2153
	fd->setDir (lastFileDir);
insilmaril@366
  2154
	fd->setMode (Q3FileDialog::ExistingFiles);
insilmaril@215
  2155
	fd->addFilter ("Mind Manager (*.mmap)");
insilmaril@215
  2156
	fd->setCaption(tr("Import")+" "+"Mind Manager");
insilmaril@215
  2157
	fd->show();
insilmaril@215
  2158
insilmaril@215
  2159
	if ( fd->exec() == QDialog::Accepted )
insilmaril@215
  2160
	{
insilmaril@215
  2161
		lastFileDir=fd->dirPath();
insilmaril@215
  2162
	    QStringList flist = fd->selectedFiles();
insilmaril@215
  2163
		QStringList::Iterator it = flist.begin();
insilmaril@215
  2164
		while( it != flist.end() ) 
insilmaril@215
  2165
		{
insilmaril@215
  2166
			im.setFile (*it);
insilmaril@215
  2167
			if (im.transform() && 
insilmaril@215
  2168
				success==fileLoad (im.getTransformedFile(),NewMap) && 
insilmaril@215
  2169
				currentMapEditor() )
insilmaril@215
  2170
				currentMapEditor()->setFilePath ("");
insilmaril@215
  2171
insilmaril@215
  2172
			++it;
insilmaril@215
  2173
		}
insilmaril@215
  2174
	}
insilmaril@215
  2175
	delete (fd);
insilmaril@215
  2176
insilmaril@215
  2177
}
insilmaril@215
  2178
insilmaril@215
  2179
void Main::fileImportDir()
insilmaril@215
  2180
{
insilmaril@215
  2181
	if (currentMapEditor())
insilmaril@215
  2182
		currentMapEditor()->importDir();	
insilmaril@215
  2183
}
insilmaril@215
  2184
insilmaril@0
  2185
void Main::fileExportXML()
insilmaril@0
  2186
{
insilmaril@0
  2187
	if (currentMapEditor())
insilmaril@0
  2188
	{
insilmaril@0
  2189
		QString dir=browseDirectory(tr("Export XML to directory"));
insilmaril@0
  2190
		if (dir !="" && reallyWriteDirectory(dir) )
insilmaril@0
  2191
			currentMapEditor()->exportXML(dir);
insilmaril@0
  2192
	}	
insilmaril@0
  2193
}
insilmaril@0
  2194
insilmaril@0
  2195
insilmaril@0
  2196
void Main::fileExportXHTML()
insilmaril@0
  2197
{
insilmaril@260
  2198
	MapEditor *me=currentMapEditor();
insilmaril@0
  2199
	QString dir;
insilmaril@260
  2200
	if (me)
insilmaril@0
  2201
	{
insilmaril@0
  2202
		ExportXHTMLDialog dia(this);
insilmaril@260
  2203
		dia.setFilePath (me->getFilePath() );
insilmaril@260
  2204
		dia.setMapName (me->getMapName() );
insilmaril@0
  2205
		dia.readSettings();
insilmaril@0
  2206
		
insilmaril@0
  2207
		if (dia.exec()==QDialog::Accepted)
insilmaril@0
  2208
		{
insilmaril@0
  2209
			QString dir=dia.getDir();
insilmaril@0
  2210
			// Check, if warnings should be used before overwriting
insilmaril@0
  2211
			// the output directory
insilmaril@0
  2212
			bool ok;
insilmaril@0
  2213
			if (dia.warnings()) 
insilmaril@0
  2214
				ok=reallyWriteDirectory(dir);
insilmaril@0
  2215
			else
insilmaril@0
  2216
				ok=true;
insilmaril@0
  2217
insilmaril@0
  2218
			if (ok)
insilmaril@0
  2219
			{
insilmaril@260
  2220
				me->exportXML (dia.getDir() );
insilmaril@260
  2221
				dia.doExport(me->getMapName() );
insilmaril@0
  2222
				if (dia.hasChanged())
insilmaril@260
  2223
					me->setChanged();
insilmaril@0
  2224
			}	
insilmaril@0
  2225
		}
insilmaril@0
  2226
	}	
insilmaril@0
  2227
}
insilmaril@0
  2228
insilmaril@366
  2229
void Main::fileExportImage()
insilmaril@0
  2230
{
insilmaril@260
  2231
	MapEditor *me=currentMapEditor();
insilmaril@260
  2232
	if (me)
insilmaril@0
  2233
	{
insilmaril@366
  2234
		QStringList fl;
insilmaril@366
  2235
		QFileDialog *fd=new QFileDialog (this);
insilmaril@366
  2236
		fd->setCaption (tr("Export map as image"));
insilmaril@366
  2237
		fd->setFileMode(QFileDialog::AnyFile);
insilmaril@366
  2238
		fd->setFilters  (imageIO.getFilters() );
insilmaril@366
  2239
		fd->setDirectory (lastImageDir);
insilmaril@366
  2240
		if (fd->exec())
insilmaril@366
  2241
		{
insilmaril@366
  2242
			fl=fd->selectedFiles();
insilmaril@366
  2243
			qWarning ("Selected "+fl.first()+"  filter: "+fd->selectedFilter());
insilmaril@366
  2244
			me->exportImage (fl.first(), imageIO.getType (fd->selectedFilter() ) );
insilmaril@366
  2245
		} 
insilmaril@0
  2246
	}
insilmaril@0
  2247
}
insilmaril@0
  2248
insilmaril@0
  2249
void Main::fileExportASCII()
insilmaril@0
  2250
{
insilmaril@260
  2251
	MapEditor *me=currentMapEditor();
insilmaril@260
  2252
	if (me)
insilmaril@228
  2253
	{
insilmaril@228
  2254
		ExportASCII ex;
insilmaril@260
  2255
		ex.setMapCenter(me->getMapCenter());
insilmaril@228
  2256
		ex.addFilter ("TXT (*.txt)");
insilmaril@404
  2257
		ex.setCaption(vymName+ " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
insilmaril@260
  2258
		if (ex.execDialog() ) 
insilmaril@260
  2259
		{
insilmaril@260
  2260
			me->setExportMode(true);
insilmaril@260
  2261
			ex.doExport();
insilmaril@260
  2262
			me->setExportMode(false);
insilmaril@260
  2263
		}
insilmaril@228
  2264
	}
insilmaril@0
  2265
}
insilmaril@0
  2266
insilmaril@163
  2267
void Main::fileExportLaTeX()
insilmaril@163
  2268
{
insilmaril@260
  2269
	MapEditor *me=currentMapEditor();
insilmaril@260
  2270
	if (me)
insilmaril@228
  2271
	{
insilmaril@228
  2272
		ExportLaTeX ex;
insilmaril@260
  2273
		ex.setMapCenter(me->getMapCenter());
insilmaril@228
  2274
		ex.addFilter ("Tex (*.tex)");
insilmaril@404
  2275
		ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
insilmaril@260
  2276
		if (ex.execDialog() ) 
insilmaril@260
  2277
		{
insilmaril@260
  2278
			me->setExportMode(true);
insilmaril@260
  2279
			ex.doExport();
insilmaril@260
  2280
			me->setExportMode(false);
insilmaril@260
  2281
		}
insilmaril@228
  2282
	}
insilmaril@228
  2283
}
insilmaril@228
  2284
insilmaril@243
  2285
void Main::fileExportKDEBookmarks()
insilmaril@243
  2286
{
insilmaril@243
  2287
	ExportKDEBookmarks ex;
insilmaril@260
  2288
	MapEditor *me=currentMapEditor();
insilmaril@260
  2289
	if (me)
insilmaril@243
  2290
	{
insilmaril@260
  2291
		ex.setMapCenter (me->getMapCenter() );
insilmaril@243
  2292
		ex.doExport();
insilmaril@243
  2293
	}	
insilmaril@243
  2294
}
insilmaril@243
  2295
insilmaril@228
  2296
void Main::fileExportTaskjuggler()
insilmaril@228
  2297
{
insilmaril@228
  2298
	ExportTaskjuggler ex;
insilmaril@260
  2299
	MapEditor *me=currentMapEditor();
insilmaril@260
  2300
	if (me)
insilmaril@228
  2301
	{
insilmaril@260
  2302
		ex.setMapCenter (me->getMapCenter() );
insilmaril@404
  2303
		ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
insilmaril@243
  2304
		ex.addFilter ("Taskjuggler (*.tjp)");
insilmaril@260
  2305
		if (ex.execDialog() ) 
insilmaril@260
  2306
		{
insilmaril@260
  2307
			me->setExportMode(true);
insilmaril@260
  2308
			ex.doExport();
insilmaril@260
  2309
			me->setExportMode(false);
insilmaril@260
  2310
		}
insilmaril@228
  2311
	}	
insilmaril@163
  2312
}
insilmaril@163
  2313
insilmaril@163
  2314
void Main::fileExportOOPresentation()
insilmaril@163
  2315
{
insilmaril@404
  2316
	ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
insilmaril@366
  2317
	// TODO add preview in dialog
insilmaril@185
  2318
	//ImagePreview *p =new ImagePreview (fd);
insilmaril@185
  2319
	//fd->setContentsPreviewEnabled( TRUE );
insilmaril@185
  2320
	//fd->setContentsPreview( p, p );
insilmaril@185
  2321
	//fd->setPreviewMode( QFileDialog::Contents );
insilmaril@404
  2322
	fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
insilmaril@366
  2323
	fd->setDir (QDir().current());
insilmaril@357
  2324
	if (fd->foundConfig())
insilmaril@357
  2325
	{
insilmaril@357
  2326
		fd->show();
insilmaril@185
  2327
insilmaril@357
  2328
		if ( fd->exec() == QDialog::Accepted )
insilmaril@357
  2329
		{
insilmaril@357
  2330
			QString fn=fd->selectedFile();
insilmaril@366
  2331
			if (!fn.contains (".odp"))
insilmaril@366
  2332
				fn +=".odp";
insilmaril@366
  2333
insilmaril@357
  2334
			//lastImageDir=fn.left(fn.findRev ("/"));
insilmaril@357
  2335
			if (currentMapEditor())
insilmaril@357
  2336
				currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());	
insilmaril@357
  2337
		}
insilmaril@357
  2338
	} else
insilmaril@185
  2339
	{
insilmaril@357
  2340
		QMessageBox::warning(0, 
insilmaril@366
  2341
		tr("Warning"),
insilmaril@366
  2342
		tr("Couldn't find configuration for export to Open Office\n"));
insilmaril@185
  2343
	}
insilmaril@163
  2344
}
insilmaril@163
  2345
insilmaril@0
  2346
void Main::fileCloseMap()
insilmaril@0
  2347
{
insilmaril@0
  2348
	if (currentMapEditor())
insilmaril@0
  2349
	{
insilmaril@0
  2350
		if (currentMapEditor()->hasChanged())
insilmaril@0
  2351
		{
insilmaril@404
  2352
			QMessageBox mb( vymName,
insilmaril@159
  2353
				tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
insilmaril@0
  2354
				QMessageBox::Warning,
insilmaril@0
  2355
				QMessageBox::Yes | QMessageBox::Default,
insilmaril@0
  2356
				QMessageBox::No,
insilmaril@0
  2357
				QMessageBox::Cancel | QMessageBox::Escape );
insilmaril@0
  2358
			mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
insilmaril@0
  2359
			mb.setButtonText( QMessageBox::No, tr("Discard changes"));
insilmaril@0
  2360
			switch( mb.exec() ) 
insilmaril@0
  2361
			{
insilmaril@0
  2362
				case QMessageBox::Yes:
insilmaril@0
  2363
					// save and close
insilmaril@0
  2364
					fileSave(CompleteMap);
insilmaril@0
  2365
					break;
insilmaril@0
  2366
				case QMessageBox::No:
insilmaril@0
  2367
				// close  without saving
insilmaril@0
  2368
					break;
insilmaril@0
  2369
				case QMessageBox::Cancel:
insilmaril@0
  2370
					// do nothing
insilmaril@0
  2371
				return;
insilmaril@0
  2372
			}
insilmaril@0
  2373
		} 
insilmaril@0
  2374
		currentMapEditor()->closeMap();
insilmaril@0
  2375
		tabWidget->removePage(currentMapEditor());
insilmaril@0
  2376
		if (tabWidget->count()==0)
insilmaril@0
  2377
			actionFilePrint->setEnabled (false);
insilmaril@0
  2378
	}	
insilmaril@0
  2379
}
insilmaril@0
  2380
insilmaril@0
  2381
void Main::filePrint()
insilmaril@0
  2382
{
insilmaril@0
  2383
	if (currentMapEditor())
insilmaril@0
  2384
		currentMapEditor()->print();
insilmaril@0
  2385
}
insilmaril@0
  2386
insilmaril@0
  2387
void Main::fileExitVYM()
insilmaril@0
  2388
{
insilmaril@0
  2389
	// Check if one or more editors have changed
insilmaril@0
  2390
	MapEditor *me;
insilmaril@0
  2391
	int i;
insilmaril@0
  2392
	for (i=0;i<=tabWidget->count() -1;i++)
insilmaril@0
  2393
	{
insilmaril@0
  2394
		
insilmaril@0
  2395
		me=(MapEditor*)tabWidget->page(i);
insilmaril@0
  2396
insilmaril@0
  2397
		// If something changed, ask what to do
insilmaril@0
  2398
		if (me->isUnsaved())
insilmaril@0
  2399
		{
insilmaril@0
  2400
			tabWidget->setCurrentPage(i);
insilmaril@404
  2401
			QMessageBox mb( vymName,
insilmaril@0
  2402
				tr("This map is not saved yet. Do you want to"),
insilmaril@0
  2403
				QMessageBox::Warning,
insilmaril@0
  2404
				QMessageBox::Yes | QMessageBox::Default,
insilmaril@0
  2405
				QMessageBox::No,
insilmaril@0
  2406
				QMessageBox::Cancel | QMessageBox::Escape );
insilmaril@0
  2407
			mb.setButtonText( QMessageBox::Yes, tr("Save map") );
insilmaril@0
  2408
			mb.setButtonText( QMessageBox::No, tr("Discard changes") );
insilmaril@366
  2409
			mb.setModal (true);
insilmaril@0
  2410
			mb.show();
insilmaril@0
  2411
			mb.setActiveWindow();
insilmaril@0
  2412
			switch( mb.exec() ) {
insilmaril@0
  2413
				case QMessageBox::Yes:
insilmaril@0
  2414
					// save (the changed editors) and exit
insilmaril@0
  2415
					fileSave(CompleteMap);
insilmaril@0
  2416
					break;
insilmaril@0
  2417
				case QMessageBox::No:
insilmaril@0
  2418
					// exit without saving
insilmaril@0
  2419
					break;
insilmaril@0
  2420
				case QMessageBox::Cancel:
insilmaril@0
  2421
					// don't save and don't exit
insilmaril@0
  2422
				return;
insilmaril@0
  2423
			}
insilmaril@0
  2424
		}
insilmaril@0
  2425
	} // loop over all MEs	
insilmaril@0
  2426
    qApp->quit();
insilmaril@0
  2427
}
insilmaril@0
  2428
insilmaril@0
  2429
void Main::editUndo()
insilmaril@0
  2430
{
insilmaril@0
  2431
	if (currentMapEditor())
insilmaril@0
  2432
		currentMapEditor()->undo();
insilmaril@0
  2433
}
insilmaril@0
  2434
insilmaril@163
  2435
void Main::editRedo()	   
insilmaril@0
  2436
{
insilmaril@163
  2437
	if (currentMapEditor())
insilmaril@163
  2438
		currentMapEditor()->redo();
insilmaril@0
  2439
}
insilmaril@0
  2440
insilmaril@404
  2441
void Main::gotoHistoryStep (int i)	   
insilmaril@404
  2442
{
insilmaril@404
  2443
	if (currentMapEditor())
insilmaril@404
  2444
		currentMapEditor()->gotoHistoryStep (i);
insilmaril@404
  2445
}
insilmaril@404
  2446
insilmaril@0
  2447
void Main::editCopy()
insilmaril@0
  2448
{
insilmaril@0
  2449
	if (currentMapEditor())
insilmaril@0
  2450
		currentMapEditor()->copy();
insilmaril@0
  2451
}
insilmaril@0
  2452
insilmaril@0
  2453
void Main::editPaste()
insilmaril@0
  2454
{
insilmaril@0
  2455
	if (currentMapEditor())
insilmaril@0
  2456
		currentMapEditor()->paste();
insilmaril@0
  2457
}
insilmaril@0
  2458
insilmaril@0
  2459
void Main::editCut()
insilmaril@0
  2460
{
insilmaril@0
  2461
	if (currentMapEditor())
insilmaril@0
  2462
		currentMapEditor()->cut();
insilmaril@0
  2463
}
insilmaril@0
  2464
insilmaril@0
  2465
void Main::editOpenFindWindow()
insilmaril@0
  2466
{
insilmaril@0
  2467
	findWindow->popup();
insilmaril@0
  2468
	findWindow->raise();
insilmaril@0
  2469
	findWindow->setActiveWindow();
insilmaril@0
  2470
}
insilmaril@0
  2471
insilmaril@0
  2472
void Main::editFind(QString s)
insilmaril@0
  2473
{
insilmaril@0
  2474
	bool cs=false;
insilmaril@0
  2475
	BranchObj *bo=currentMapEditor()->findText(s, cs);
insilmaril@0
  2476
	if (bo)
insilmaril@0
  2477
	{	
insilmaril@0
  2478
		statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
insilmaril@0
  2479
	} else
insilmaril@0
  2480
	{
insilmaril@0
  2481
		QMessageBox::information( findWindow, tr( "VYM -Information:" ),
insilmaril@349
  2482
							   tr("No matches found for \"%1\"").arg(s));
insilmaril@0
  2483
	}	
insilmaril@0
  2484
}
insilmaril@0
  2485
insilmaril@0
  2486
void Main::editFindChanged()
insilmaril@0
  2487
{	// Notify editor, to abort the current find process
insilmaril@0
  2488
	currentMapEditor()->findReset();
insilmaril@0
  2489
}
insilmaril@0
  2490
insilmaril@366
  2491
void Main::openTabs(QStringList urls)
insilmaril@366
  2492
{
insilmaril@366
  2493
	if (!urls.isEmpty())
insilmaril@366
  2494
	{	
insilmaril@366
  2495
		bool success=true;
insilmaril@366
  2496
		QStringList args;
insilmaril@366
  2497
		QString browser=settings.value("/mainwindow/readerURL" ).toString();
insilmaril@366
  2498
		QProcess *p;
insilmaril@366
  2499
		if (!procBrowser ||  procBrowser->state()!=QProcess::Running)
insilmaril@366
  2500
		{
insilmaril@366
  2501
			QString u=urls.takeFirst();
insilmaril@366
  2502
			procBrowser = new QProcess( this );
insilmaril@366
  2503
			args<<u;
insilmaril@366
  2504
			procBrowser->start(browser,args);
insilmaril@366
  2505
			if ( !procBrowser->waitForStarted())
insilmaril@366
  2506
			{
insilmaril@366
  2507
				// try to set path to browser
insilmaril@366
  2508
				QMessageBox::warning(0, 
insilmaril@366
  2509
					tr("Warning"),
insilmaril@366
  2510
					tr("Couldn't find a viewer to open %1.\n").arg(u)+
insilmaril@366
  2511
					tr("Please use Settings->")+tr("Set application to open an URL"));
insilmaril@366
  2512
				return;
insilmaril@366
  2513
			}
insilmaril@366
  2514
			sleep (3);
insilmaril@366
  2515
		}
insilmaril@366
  2516
		if (browser.contains("konqueror"))
insilmaril@366
  2517
		{
insilmaril@366
  2518
			for (int i=0; i<urls.size(); i++)
insilmaril@366
  2519
			{
insilmaril@366
  2520
				// Open new browser
insilmaril@366
  2521
				// Try to open new tab in existing konqueror started previously by vym
insilmaril@366
  2522
				p=new QProcess (this);
insilmaril@366
  2523
				args.clear();
insilmaril@366
  2524
				args<< QString("konqueror-%1").arg(procBrowser->pid())<< 
insilmaril@366
  2525
					"konqueror-mainwindow#1"<< 
insilmaril@366
  2526
					"newTab" << 
insilmaril@366
  2527
					urls.at(i);
insilmaril@366
  2528
				p->start ("dcop",args);
insilmaril@366
  2529
				if ( !p->waitForStarted() ) success=false;
insilmaril@366
  2530
			}
insilmaril@366
  2531
			if (!success)
insilmaril@366
  2532
				QMessageBox::warning(0, 
insilmaril@366
  2533
					tr("Warning"),
insilmaril@366
  2534
					tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
insilmaril@366
  2535
			return;		
insilmaril@366
  2536
		} else if (browser.contains ("firefox") || browser.contains ("mozilla") )
insilmaril@366
  2537
		{
insilmaril@366
  2538
			for (int i=0; i<urls.size(); i++)
insilmaril@366
  2539
			{
insilmaril@366
  2540
				// Try to open new tab in firefox
insilmaril@366
  2541
				p=new QProcess (this);
insilmaril@366
  2542
				args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
insilmaril@366
  2543
				p->start (browser,args);
insilmaril@366
  2544
				if ( !p->waitForStarted() ) success=false;
insilmaril@366
  2545
			}			
insilmaril@366
  2546
			if (!success)
insilmaril@366
  2547
				QMessageBox::warning(0, 
insilmaril@366
  2548
					tr("Warning"),
insilmaril@366
  2549
					tr("Couldn't start %1 to open a new tab").arg(browser));
insilmaril@366
  2550
			return;		
insilmaril@366
  2551
		}			
insilmaril@366
  2552
		QMessageBox::warning(0, 
insilmaril@366
  2553
			tr("Warning"),
insilmaril@366
  2554
			tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
insilmaril@366
  2555
	}	
insilmaril@366
  2556
}
insilmaril@366
  2557
insilmaril@0
  2558
void Main::editOpenURL()
insilmaril@0
  2559
{
insilmaril@266
  2560
	// Open new browser
insilmaril@0
  2561
	if (currentMapEditor())
insilmaril@266
  2562
	{	
insilmaril@266
  2563
	    QString url=currentMapEditor()->getURL();
insilmaril@366
  2564
		QStringList args;
insilmaril@266
  2565
		if (url=="") return;
insilmaril@366
  2566
		QString browser=settings.value("/mainwindow/readerURL" ).toString();
insilmaril@266
  2567
		procBrowser = new QProcess( this );
insilmaril@366
  2568
		args<<url;
insilmaril@366
  2569
		procBrowser->start(browser,args);
insilmaril@366
  2570
		if ( !procBrowser->waitForStarted())
insilmaril@266
  2571
		{
insilmaril@266
  2572
			// try to set path to browser
insilmaril@266
  2573
			QMessageBox::warning(0, 
insilmaril@266
  2574
				tr("Warning"),
insilmaril@266
  2575
				tr("Couldn't find a viewer to open %1.\n").arg(url)+
insilmaril@266
  2576
				tr("Please use Settings->")+tr("Set application to open an URL"));
insilmaril@266
  2577
			settingsURL() ; 
insilmaril@266
  2578
		}	
insilmaril@266
  2579
	}	
insilmaril@266
  2580
}
insilmaril@266
  2581
void Main::editOpenURLTab()
insilmaril@266
  2582
{
insilmaril@266
  2583
	if (currentMapEditor())
insilmaril@266
  2584
	{	
insilmaril@366
  2585
	    QStringList urls;
insilmaril@366
  2586
		urls.append(currentMapEditor()->getURL());
insilmaril@366
  2587
		openTabs (urls);
insilmaril@266
  2588
	}	
insilmaril@0
  2589
}
insilmaril@366
  2590
void Main::editOpenMultipleURLTabs()
insilmaril@366
  2591
{
insilmaril@366
  2592
	if (currentMapEditor())
insilmaril@366
  2593
	{	
insilmaril@366
  2594
	    QStringList urls;
insilmaril@366
  2595
		urls=currentMapEditor()->getURLs();
insilmaril@366
  2596
		openTabs (urls);
insilmaril@366
  2597
	}	
insilmaril@366
  2598
}
insilmaril@366
  2599
insilmaril@0
  2600
insilmaril@0
  2601
void Main::editURL()
insilmaril@0
  2602
{
insilmaril@0
  2603
	if (currentMapEditor())
insilmaril@0
  2604
	    currentMapEditor()->editURL();
insilmaril@0
  2605
}
insilmaril@0
  2606
insilmaril@0
  2607
void Main::editHeading2URL()
insilmaril@0
  2608
{
insilmaril@0
  2609
	if (currentMapEditor())
insilmaril@0
  2610
	    currentMapEditor()->editHeading2URL();
insilmaril@0
  2611
}
insilmaril@0
  2612
insilmaril@0
  2613
void Main::editBugzilla2URL()
insilmaril@0
  2614
{
insilmaril@0
  2615
	if (currentMapEditor())
insilmaril@0
  2616
	    currentMapEditor()->editBugzilla2URL();
insilmaril@0
  2617
}
insilmaril@0
  2618
insilmaril@175
  2619
void Main::editFATE2URL()
insilmaril@175
  2620
{
insilmaril@175
  2621
	if (currentMapEditor())
insilmaril@175
  2622
	    currentMapEditor()->editFATE2URL();
insilmaril@175
  2623
}
insilmaril@175
  2624
insilmaril@394
  2625
void Main::editHeadingFinished()
insilmaril@394
  2626
{
insilmaril@394
  2627
	// only called from editHeading(), so there is a currentME
insilmaril@394
  2628
	MapEditor *me=currentMapEditor();
insilmaril@394
  2629
insilmaril@394
  2630
#if defined(Q_OS_MACX)
insilmaril@394
  2631
#else
insilmaril@394
  2632
	me->setHeading(lineedit->text());
insilmaril@394
  2633
		
insilmaril@394
  2634
	lineedit->releaseKeyboard();
insilmaril@394
  2635
	lineedit->hide();
insilmaril@394
  2636
	setFocus();
insilmaril@394
  2637
#endif	
insilmaril@394
  2638
	if (!prevSelection.isEmpty()) me->select(prevSelection);
insilmaril@394
  2639
	prevSelection="";
insilmaril@394
  2640
}
insilmaril@394
  2641
insilmaril@366
  2642
void Main::editHeading()
insilmaril@0
  2643
{
insilmaril@394
  2644
	if (currentMapEditor())
insilmaril@0
  2645
	{
insilmaril@394
  2646
		MapEditor *me=currentMapEditor();
insilmaril@394
  2647
		QString oldSel=me->getSelectString();
insilmaril@394
  2648
insilmaril@394
  2649
		if (lineedit->isVisible())
insilmaril@394
  2650
			editHeadingFinished();
insilmaril@394
  2651
		else
insilmaril@366
  2652
		{
insilmaril@366
  2653
			bool ok;
insilmaril@366
  2654
			QPoint p;
insilmaril@366
  2655
			QString s=currentMapEditor()->getHeading(ok,p);
insilmaril@366
  2656
insilmaril@366
  2657
			if (ok)
insilmaril@366
  2658
			{
insilmaril@366
  2659
#if defined(Q_OS_MACX)
insilmaril@408
  2660
				p=currentMapEditor()->mapTo (this,p);
insilmaril@366
  2661
				QDialog *d =new QDialog(NULL);
insilmaril@366
  2662
				QLineEdit *le=new QLineEdit (d);
insilmaril@366
  2663
				d->setWindowFlags (Qt::FramelessWindowHint);
insilmaril@394
  2664
				d->setGeometry(p.x(),p.y(),230,25);
insilmaril@394
  2665
				le->resize (d->width()-10,d->height());
insilmaril@366
  2666
				le->setText (s);
insilmaril@366
  2667
				le->selectAll();
insilmaril@366
  2668
				connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
insilmaril@366
  2669
				d->activateWindow();
insilmaril@366
  2670
				d->exec();
insilmaril@366
  2671
				currentMapEditor()->setHeading (le->text());
insilmaril@394
  2672
				delete (le);
insilmaril@394
  2673
				delete (d);
insilmaril@394
  2674
				editHeadingFinished();
insilmaril@366
  2675
#else
insilmaril@408
  2676
				p=currentMapEditor()->mapTo (this,p);
insilmaril@394
  2677
				lineedit->setGeometry(p.x(),p.y(),230,25);
insilmaril@366
  2678
				lineedit->setText(s);
insilmaril@366
  2679
				lineedit->setCursorPosition(1);
insilmaril@366
  2680
				lineedit->selectAll();
insilmaril@366
  2681
				lineedit->show();
insilmaril@366
  2682
				lineedit->grabKeyboard();
insilmaril@366
  2683
				lineedit->setFocus();
insilmaril@366
  2684
#endif
insilmaril@366
  2685
			}
insilmaril@366
  2686
		}
insilmaril@394
  2687
	} // currentMapEditor()	
insilmaril@366
  2688
}
insilmaril@366
  2689
insilmaril@366
  2690
void Main::openVymLinks(const QStringList &vl)
insilmaril@366
  2691
{
insilmaril@366
  2692
	for (int j=0; j<vl.size(); j++)
insilmaril@366
  2693
	{
insilmaril@0
  2694
		// compare path with already loaded maps
insilmaril@0
  2695
		int index=-1;
insilmaril@0
  2696
		int i;
insilmaril@0
  2697
		MapEditor *me;
insilmaril@0
  2698
		for (i=0;i<=tabWidget->count() -1;i++)
insilmaril@0
  2699
		{
insilmaril@0
  2700
			me=(MapEditor*)tabWidget->page(i);
insilmaril@366
  2701
			if (vl.at(j)==me->getFilePath() )
insilmaril@0
  2702
			{
insilmaril@0
  2703
				index=i;
insilmaril@0
  2704
				break;
insilmaril@0
  2705
			}
insilmaril@0
  2706
		}	
insilmaril@0
  2707
		if (index<0)
insilmaril@0
  2708
		// Load map
insilmaril@0
  2709
		{
insilmaril@366
  2710
			if (!QFile(vl.at(j)).exists() )
insilmaril@0
  2711
				QMessageBox::critical( 0, tr( "Critical Error" ),
insilmaril@366
  2712
				   tr("Couldn't open map %1").arg(vl.at(j)));
insilmaril@0
  2713
			else
insilmaril@0
  2714
			{
insilmaril@366
  2715
				fileLoad (vl.at(j), NewMap);
insilmaril@0
  2716
				tabWidget->setCurrentPage (tabWidget->count()-1);	
insilmaril@0
  2717
			}
insilmaril@0
  2718
		} else
insilmaril@0
  2719
			// Go to tab containing the map
insilmaril@0
  2720
			tabWidget->setCurrentPage (index);	
insilmaril@0
  2721
	}
insilmaril@0
  2722
}
insilmaril@0
  2723
insilmaril@366
  2724
void Main::editOpenVymLink()
insilmaril@366
  2725
{
insilmaril@366
  2726
	if (currentMapEditor())
insilmaril@366
  2727
	{
insilmaril@366
  2728
		QStringList vl;
insilmaril@366
  2729
		vl.append(currentMapEditor()->getVymLink());	
insilmaril@366
  2730
		openVymLinks (vl);
insilmaril@366
  2731
	}
insilmaril@366
  2732
}
insilmaril@366
  2733
insilmaril@366
  2734
void Main::editOpenMultipleVymLinks()
insilmaril@366
  2735
{
insilmaril@366
  2736
	QString currentVymLink;
insilmaril@366
  2737
	if (currentMapEditor())
insilmaril@366
  2738
	{
insilmaril@366
  2739
		QStringList vl=currentMapEditor()->getVymLinks();
insilmaril@366
  2740
		openVymLinks (vl);
insilmaril@366
  2741
	}
insilmaril@366
  2742
}
insilmaril@366
  2743
insilmaril@0
  2744
void Main::editVymLink()
insilmaril@0
  2745
{
insilmaril@0
  2746
	if (currentMapEditor())
insilmaril@0
  2747
		currentMapEditor()->editVymLink();	
insilmaril@0
  2748
}
insilmaril@0
  2749
insilmaril@0
  2750
void Main::editDeleteVymLink()
insilmaril@0
  2751
{
insilmaril@0
  2752
	if (currentMapEditor())
insilmaril@0
  2753
		currentMapEditor()->deleteVymLink();	
insilmaril@0
  2754
}
insilmaril@0
  2755
insilmaril@243
  2756
void Main::editToggleHideExport()
insilmaril@243
  2757
{
insilmaril@243
  2758
	if (currentMapEditor())
insilmaril@294
  2759
		currentMapEditor()->toggleHideExport();	
insilmaril@243
  2760
}
insilmaril@243
  2761
insilmaril@0
  2762
void Main::editMapInfo()
insilmaril@0
  2763
{
insilmaril@0
  2764
	if (currentMapEditor())
insilmaril@0
  2765
		currentMapEditor()->editMapInfo();	
insilmaril@0
  2766
}
insilmaril@0
  2767
insilmaril@0
  2768
void Main::editMoveUp()
insilmaril@0
  2769
{
insilmaril@420
  2770
	cout << "Main editMoveUp begin\n";
insilmaril@0
  2771
	if (currentMapEditor())
insilmaril@0
  2772
	    currentMapEditor()->moveBranchUp();
insilmaril@420
  2773
	cout << "Main editMoveUp end\n";
insilmaril@0
  2774
}
insilmaril@0
  2775
insilmaril@0
  2776
void Main::editMoveDown()
insilmaril@0
  2777
{
insilmaril@0
  2778
	if (currentMapEditor())
insilmaril@0
  2779
		currentMapEditor()->moveBranchDown();
insilmaril@0
  2780
}
insilmaril@0
  2781
insilmaril@0
  2782
void Main::editToggleScroll()
insilmaril@0
  2783
{
insilmaril@0
  2784
	if (currentMapEditor())
insilmaril@0
  2785
	{
insilmaril@0
  2786
		currentMapEditor()->toggleScroll();	
insilmaril@0
  2787
	}	
insilmaril@0
  2788
}
insilmaril@0
  2789
insilmaril@0
  2790
void Main::editUnScrollAll()
insilmaril@0
  2791
{
insilmaril@0
  2792
	if (currentMapEditor())
insilmaril@394
  2793
		currentMapEditor()->unScrollAll();	
insilmaril@394
  2794
}
insilmaril@394
  2795
insilmaril@394
  2796
void Main::editNewBranch()
insilmaril@394
  2797
{
insilmaril@394
  2798
	MapEditor *me=currentMapEditor();
insilmaril@394
  2799
	if (!lineedit->isVisible() && me)
insilmaril@0
  2800
	{
insilmaril@394
  2801
		BranchObj *bo=(BranchObj*)me->getSelection();
insilmaril@394
  2802
		BranchObj *newbo=me->addNewBranch(0);
insilmaril@394
  2803
insilmaril@394
  2804
		if (newbo) 
insilmaril@394
  2805
			me->select (newbo->getSelectString());
insilmaril@394
  2806
		else
insilmaril@394
  2807
			return;
insilmaril@394
  2808
insilmaril@394
  2809
		if (actionSettingsAutoEdit->isOn())
insilmaril@394
  2810
		{
insilmaril@394
  2811
			if (!actionSettingsAutoSelectHeading->isOn())
insilmaril@394
  2812
				prevSelection=bo->getSelectString();
insilmaril@394
  2813
			editHeading();
insilmaril@394
  2814
		}
insilmaril@0
  2815
	}	
insilmaril@0
  2816
}
insilmaril@0
  2817
insilmaril@394
  2818
void Main::editNewBranchBefore()
insilmaril@0
  2819
{
insilmaril@394
  2820
	MapEditor *me=currentMapEditor();
insilmaril@394
  2821
	if (!lineedit->isVisible() && me)
insilmaril@394
  2822
	{
insilmaril@394
  2823
		BranchObj *bo=(BranchObj*)me->getSelection();
insilmaril@394
  2824
		BranchObj *newbo=me->addNewBranchBefore();
insilmaril@394
  2825
insilmaril@394
  2826
		if (newbo) 
insilmaril@394
  2827
			me->select (newbo->getSelectString());
insilmaril@394
  2828
		else
insilmaril@394
  2829
			return;
insilmaril@394
  2830
insilmaril@394
  2831
		if (actionSettingsAutoEdit->isOn())
insilmaril@394
  2832
		{
insilmaril@394
  2833
			if (!actionSettingsAutoSelectHeading->isOn())
insilmaril@394
  2834
				prevSelection=bo->getSelectString();
insilmaril@394
  2835
			editHeading();
insilmaril@394
  2836
		}
insilmaril@394
  2837
	}	
insilmaril@98
  2838
}
insilmaril@98
  2839
insilmaril@0
  2840
void Main::editNewBranchAbove()
insilmaril@0
  2841
{
insilmaril@394
  2842
	MapEditor *me=currentMapEditor();
insilmaril@394
  2843
	if (!lineedit->isVisible() && me)
insilmaril@394
  2844
	{