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