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