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