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