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