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