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