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