mainwindow.cpp
author insilmaril
Wed, 30 Aug 2006 12:16:25 +0000
branchqt4-port
changeset 17 557239819c45
parent 16 41c3d7f9f532
child 18 70c41284cb48
permissions -rw-r--r--
Fixed editing of headings. 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* actionSettingsPasteNewHeading;
insilmaril@0
   126
extern QAction* actionSettingsUseDelKey;
insilmaril@2
   127
extern QAction* actionSettingsUseFlagGroups;
insilmaril@2
   128
extern QAction* actionSettingsUseHideExport;
insilmaril@0
   129
insilmaril@4
   130
extern QMenu* branchContextMenu;
insilmaril@4
   131
extern QMenu* branchAddContextMenu;
insilmaril@4
   132
extern QMenu* branchRemoveContextMenu;
insilmaril@17
   133
extern QMenu* branchLinksContextMenu;
insilmaril@17
   134
extern QMenu* branchXLinksContextMenuEdit;
insilmaril@17
   135
extern QMenu* branchXLinksContextMenuFollow;
insilmaril@4
   136
extern QMenu* floatimageContextMenu;
insilmaril@4
   137
extern QMenu* canvasContextMenu;
insilmaril@4
   138
extern QMenu* fileLastMapsMenu;
insilmaril@4
   139
extern QMenu* fileImportMenu;
insilmaril@4
   140
extern QMenu* fileExportMenu;
insilmaril@0
   141
insilmaril@0
   142
insilmaril@0
   143
extern Settings settings;
insilmaril@0
   144
extern Options options;
insilmaril@4
   145
extern ImageIO imageIO;
insilmaril@4
   146
insilmaril@2
   147
extern QDir vymBaseDir;
insilmaril@4
   148
extern QDir lastImageDir;
insilmaril@11
   149
extern QDir lastFileDir;
insilmaril@2
   150
extern QString iconPath;
insilmaril@2
   151
extern QString flagsPath;
insilmaril@0
   152
insilmaril@2
   153
Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
insilmaril@3
   154
    QMainWindow(parent,name,f)
insilmaril@0
   155
{
insilmaril@0
   156
	mainWindow=this;
insilmaril@0
   157
insilmaril@0
   158
	setCaption ("VYM - View Your Mind");
insilmaril@0
   159
insilmaril@0
   160
	// Load window settings
insilmaril@13
   161
	resize (settings.value( "/mainwindow/geometry/size",QSize (800,600)).toSize());
insilmaril@13
   162
	move   (settings.value( "/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
insilmaril@0
   163
insilmaril@0
   164
insilmaril@2
   165
	// Create unique temporary directory
insilmaril@2
   166
	tmpVymDir=makeUniqueDir ("/tmp/vym-XXXXXX");
insilmaril@2
   167
insilmaril@2
   168
	// Create direcctory for clipboard
insilmaril@2
   169
	clipboardDir=tmpVymDir+"/clipboard";
insilmaril@2
   170
	QDir d(clipboardDir);
insilmaril@2
   171
	d.mkdir (clipboardDir,true);
insilmaril@2
   172
	makeSubDirs (clipboardDir);
insilmaril@2
   173
	clipboardEmpty=true;
insilmaril@2
   174
insilmaril@2
   175
	procBrowser=NULL;
insilmaril@2
   176
insilmaril@2
   177
	// FIXME not used currently
insilmaril@2
   178
	// Set random seed (random used for object IDs)
insilmaril@2
   179
    // QTime t = QTime::currentTime();		// set random seed
insilmaril@2
   180
    // srand( t.hour()*12+t.minute()*60+t.second()*60 );
insilmaril@2
   181
insilmaril@2
   182
insilmaril@0
   183
	// Initialize some settings, which are platform dependant
insilmaril@0
   184
	QString p,s;
insilmaril@0
   185
insilmaril@0
   186
		// application to open URLs
insilmaril@13
   187
		p="/mainwindow/readerURL";
insilmaril@0
   188
		#if defined(Q_OS_LINUX)
insilmaril@13
   189
			s=settings.value (p,"konqueror").toString();
insilmaril@0
   190
		#else
insilmaril@0
   191
			#if defined(Q_OS_MACX)
insilmaril@13
   192
				s=settings.value (p,"/usr/bin/open").toString();
insilmaril@0
   193
			#else
insilmaril@13
   194
				s=settings.value (p,"mozilla");
insilmaril@0
   195
			#endif
insilmaril@0
   196
		#endif
insilmaril@13
   197
		settings.setValue( p,s);
insilmaril@0
   198
insilmaril@0
   199
		// application to open PDFs
insilmaril@13
   200
		p="/mainwindow/readerPDF";
insilmaril@0
   201
		#if defined(Q_OS_LINUX)
insilmaril@13
   202
			s=settings.value (p,"acroread").toString();
insilmaril@0
   203
		#else
insilmaril@0
   204
			#if defined(Q_OS_MACX)
insilmaril@13
   205
				s=settings.value (p,"/usr/bin/open").toString();
insilmaril@0
   206
			#else
insilmaril@13
   207
				s=settings.value (p,"acroread").toString();
insilmaril@0
   208
			#endif
insilmaril@0
   209
		#endif
insilmaril@13
   210
		settings.setValue( p,s);
insilmaril@0
   211
insilmaril@0
   212
	
insilmaril@0
   213
	maxLastMaps=9;
insilmaril@0
   214
insilmaril@0
   215
	// Create tab widget which holds the maps
insilmaril@0
   216
	tabWidget= new QTabWidget (this);
insilmaril@0
   217
	connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ), 
insilmaril@0
   218
		this, SLOT( editorChanged( QWidget * ) ) );
insilmaril@0
   219
insilmaril@16
   220
	lineedit=new QLineEdit (this);
insilmaril@16
   221
	lineedit->hide();
insilmaril@16
   222
insilmaril@0
   223
	setCentralWidget(tabWidget);	
insilmaril@0
   224
insilmaril@0
   225
    setupFileActions();
insilmaril@0
   226
    setupEditActions();
insilmaril@0
   227
    setupFormatActions();
insilmaril@0
   228
    setupViewActions();
insilmaril@2
   229
    setupModeActions();
insilmaril@0
   230
	setupFlagActions();
insilmaril@0
   231
    setupSettingsActions();
insilmaril@0
   232
	setupContextMenus();
insilmaril@13
   233
    if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
insilmaril@0
   234
    setupHelpActions();
insilmaril@0
   235
    
insilmaril@0
   236
    statusBar();
insilmaril@0
   237
insilmaril@13
   238
	restoreState (settings.value("/mainwindow/state",0).toByteArray());
insilmaril@0
   239
insilmaril@0
   240
	// Initialize Find window
insilmaril@0
   241
	findWindow=new FindWindow(NULL,"findwindow");
insilmaril@0
   242
	connect (findWindow, SIGNAL( findButton(QString) ), 
insilmaril@0
   243
		this, SLOT(editFind(QString) ) );	
insilmaril@0
   244
	connect (findWindow, SIGNAL( somethingChanged() ), 
insilmaril@0
   245
		this, SLOT(editFindChanged() ) );	
insilmaril@0
   246
insilmaril@2
   247
	// Connect TextEditor, so that we can update flags if text changes
insilmaril@2
   248
	connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
insilmaril@2
   249
insilmaril@0
   250
	updateGeometry();
insilmaril@0
   251
}
insilmaril@0
   252
insilmaril@0
   253
Main::~Main()
insilmaril@0
   254
{
insilmaril@0
   255
	// Save Settings
insilmaril@13
   256
	settings.setValue ( "/mainwindow/geometry/size", size() );
insilmaril@13
   257
	settings.setValue ( "/mainwindow/geometry/pos", pos() );
insilmaril@13
   258
insilmaril@13
   259
	settings.setValue ("/mainwindow/state",saveState(0));
insilmaril@13
   260
insilmaril@13
   261
	settings.setValue( "/version/version", __VYM_VERSION );
insilmaril@13
   262
	settings.setValue( "/version/builddate", __BUILD_DATE );
insilmaril@13
   263
insilmaril@17
   264
	settings.setValue( "/mapeditor/editmode/autoSelectHeading",actionSettingsAutoselectHeading->isOn() );
insilmaril@17
   265
	settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoselectText->isOn() );
insilmaril@17
   266
	settings.setValue( "/mapeditor/editmode/pasteNewHeading",actionSettingsPasteNewHeading->isOn() );
insilmaril@17
   267
	settings.setValue( "/mapeditor/editmode/autoEdit",actionSettingsAutoedit->isOn() );
insilmaril@13
   268
	settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
insilmaril@13
   269
	settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
insilmaril@13
   270
	settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
insilmaril@0
   271
insilmaril@0
   272
	QString s;
insilmaril@0
   273
	int maps=lastMaps.count();
insilmaril@13
   274
	settings.setValue( "/lastMaps/number",maps );
insilmaril@0
   275
	for (int i=1;i<=maps;i++)
insilmaril@0
   276
	{
insilmaril@13
   277
		s=QString("/lastMaps/map-%1").arg(i);
insilmaril@0
   278
		if (!s.isEmpty() && i<=maxLastMaps) 
insilmaril@13
   279
			settings.setValue (s, lastMaps.at(i-1));
insilmaril@0
   280
	}
insilmaril@0
   281
insilmaril@0
   282
insilmaril@0
   283
	// To make the texteditor save its settings, call the destructor
insilmaril@0
   284
	delete (textEditor);
insilmaril@2
   285
insilmaril@2
   286
	// Remove temporary directory
insilmaril@2
   287
	removeDir (QDir(tmpVymDir));
insilmaril@0
   288
}
insilmaril@0
   289
insilmaril@0
   290
void Main::loadCmdLine()
insilmaril@0
   291
{
insilmaril@0
   292
	/* TODO draw some kind of splashscreen while loading...
insilmaril@0
   293
	if (qApp->argc()>1)
insilmaril@0
   294
	{
insilmaril@0
   295
	}
insilmaril@0
   296
	*/
insilmaril@0
   297
	
insilmaril@0
   298
	QStringList flist=options.getFileList();
insilmaril@0
   299
	QStringList::Iterator it=flist.begin();
insilmaril@0
   300
insilmaril@0
   301
	while (it !=flist.end() )
insilmaril@0
   302
	{
insilmaril@0
   303
		fileLoad (*it, NewMap);
insilmaril@0
   304
		*it++;
insilmaril@0
   305
	}	
insilmaril@0
   306
}
insilmaril@0
   307
insilmaril@0
   308
insilmaril@0
   309
void Main::statusMessage(const QString &s)
insilmaril@0
   310
{
insilmaril@0
   311
	statusBar()->message (s);
insilmaril@0
   312
}
insilmaril@0
   313
insilmaril@0
   314
void Main::closeEvent (QCloseEvent* )
insilmaril@0
   315
{
insilmaril@0
   316
	fileExitVYM();
insilmaril@0
   317
}
insilmaril@0
   318
insilmaril@0
   319
// File Actions
insilmaril@0
   320
void Main::setupFileActions()
insilmaril@0
   321
{
insilmaril@13
   322
	QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
insilmaril@13
   323
    QToolBar *tb = addToolBar( tr ("&Map") );
insilmaril@0
   324
insilmaril@0
   325
    QAction *a;
insilmaril@2
   326
    a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New..." ),this);
insilmaril@2
   327
	a->setStatusTip ( tr( "New map","File menu" ) );
insilmaril@2
   328
	a->setShortcut ( Qt::CTRL + Qt::Key_N );
insilmaril@0
   329
    a->addTo( tb );
insilmaril@4
   330
	fileMenu->addAction (a);
insilmaril@13
   331
    connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
insilmaril@0
   332
	
insilmaril@2
   333
    a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ),this);
insilmaril@2
   334
	a->setStatusTip (tr( "Open","File menu" ) );
insilmaril@2
   335
	a->setShortcut ( Qt::CTRL + Qt::Key_O );
insilmaril@0
   336
    a->addTo( tb );
insilmaril@4
   337
	fileMenu->addAction (a);
insilmaril@13
   338
    connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
insilmaril@0
   339
	
insilmaril@4
   340
	fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent"));
insilmaril@4
   341
	fileMenu->addSeparator();
insilmaril@0
   342
	
insilmaril@2
   343
    a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save..." ), this);
insilmaril@2
   344
	a->setStatusTip ( tr( "Save" ));
insilmaril@2
   345
	a->setShortcut (Qt::CTRL + Qt::Key_S );
insilmaril@0
   346
    a->addTo( tb );
insilmaril@4
   347
	fileMenu->addAction (a);
insilmaril@13
   348
    connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
insilmaril@0
   349
	actionFileSave=a;
insilmaril@0
   350
	
insilmaril@2
   351
    a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As..." ), this);
insilmaril@2
   352
	a->setStatusTip (tr( "Save &As" ) );
insilmaril@4
   353
	fileMenu->addAction (a);
insilmaril@13
   354
    connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
insilmaril@0
   355
insilmaril@4
   356
	fileMenu->addSeparator();
insilmaril@4
   357
insilmaril@4
   358
	fileImportMenu = fileMenu->addMenu (tr("Import"));
insilmaril@2
   359
insilmaril@2
   360
	a = new QAction(tr("KDE Bookmarks"), this);
insilmaril@2
   361
	a->setStatusTip ( tr( "Import")+" "+tr("KDE Bookmarks" ));
insilmaril@4
   362
	a->addTo (fileImportMenu);
insilmaril@13
   363
	connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) );
insilmaril@13
   364
insilmaril@13
   365
    if (settings.value( "/mainwindow/showTestMenu",false).toBool()) 
insilmaril@2
   366
	{
insilmaril@2
   367
		a = new QAction( QPixmap(), tr("Firefox Bookmarks"),this);
insilmaril@2
   368
		a->setStatusTip (tr( "Import")+" "+tr("Firefox Bookmarks" ) );
insilmaril@4
   369
		a->addTo (fileImportMenu);
insilmaril@13
   370
		connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
insilmaril@2
   371
	}	
insilmaril@2
   372
insilmaril@2
   373
	a = new QAction("Mind Manager...",this);
insilmaril@2
   374
	a->setStatusTip ( tr( "Import")+" Mind Manager"  );
insilmaril@4
   375
	fileImportMenu->addAction (a);
insilmaril@13
   376
	connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
insilmaril@2
   377
insilmaril@2
   378
    a = new QAction( tr( "Import Dir"+QString("...") ), this);
insilmaril@2
   379
	a->setStatusTip (tr( "Import directory structure (experimental)" ) );
insilmaril@4
   380
	fileImportMenu->addAction (a);
insilmaril@13
   381
    connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
insilmaril@0
   382
insilmaril@4
   383
	fileExportMenu = fileMenu->addMenu (tr("Export"));
insilmaril@4
   384
insilmaril@4
   385
	a = new QAction( tr("Image")+QString("..."), this);
insilmaril@4
   386
	a->setStatusTip( tr( "Export map as image" ));
insilmaril@13
   387
	connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
insilmaril@4
   388
	fileExportMenu->addAction (a);
insilmaril@4
   389
insilmaril@4
   390
	a = new QAction( "Open Office"+QString("..."), this);
insilmaril@4
   391
	a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office " ));
insilmaril@13
   392
	connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
insilmaril@4
   393
	fileExportMenu->addAction (a);
insilmaril@4
   394
insilmaril@4
   395
	a = new QAction(  "Webpage (XHTML)...",this );
insilmaril@4
   396
	a->setShortcut (Qt::ALT + Qt::Key_X);
insilmaril@4
   397
	a->setStatusTip ( tr( "Export as")+" webpage (XHTML)");
insilmaril@13
   398
    connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
insilmaril@4
   399
	fileExportMenu->addAction (a);
insilmaril@4
   400
insilmaril@4
   401
    a = new QAction( "Text (ASCII)...", this);
insilmaril@4
   402
	a->setStatusTip ( tr( "Export as")+" ASCII"+" "+tr("(still experimental)" ));
insilmaril@13
   403
    connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
insilmaril@4
   404
	fileExportMenu->addAction (a);
insilmaril@4
   405
insilmaril@4
   406
	a = new QAction( tr("KDE Bookmarks"), this);
insilmaril@4
   407
	a->setStatusTip( tr( "Export as")+" "+tr("KDE Bookmarks" ));
insilmaril@13
   408
	connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
insilmaril@4
   409
	fileExportMenu->addAction (a);
insilmaril@4
   410
insilmaril@4
   411
    a = new QAction( "Taskjuggler...", this );
insilmaril@4
   412
    a->setStatusTip( tr( "Export as")+" Taskjuggler"+" "+tr("(still experimental)" ));
insilmaril@13
   413
    connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
insilmaril@4
   414
	fileExportMenu->addAction (a);
insilmaril@4
   415
insilmaril@4
   416
    a = new QAction( "LaTeX...", this);
insilmaril@4
   417
    a->setStatusTip( tr( "Export as")+" LaTeX"+" "+tr("(still experimental)" ));
insilmaril@13
   418
    connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
insilmaril@4
   419
	fileExportMenu->addAction (a);
insilmaril@4
   420
insilmaril@4
   421
	a = new QAction( "XML..." , this );
insilmaril@4
   422
	a->setStatusTip (tr( "Export as")+" XML");
insilmaril@13
   423
    connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
insilmaril@4
   424
	fileExportMenu->addAction (a);
insilmaril@4
   425
insilmaril@4
   426
	fileMenu->addSeparator();
insilmaril@0
   427
insilmaril@2
   428
    a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
insilmaril@2
   429
	a->setStatusTip ( tr( "Print" ) );
insilmaril@2
   430
	a->setShortcut (Qt::CTRL + Qt::Key_P );
insilmaril@0
   431
    a->addTo( tb );
insilmaril@4
   432
	fileMenu->addAction (a);
insilmaril@13
   433
    connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
insilmaril@0
   434
	actionFilePrint=a;
insilmaril@0
   435
insilmaril@2
   436
    a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map" ), this);
insilmaril@2
   437
	a->setStatusTip (tr( "Close Map" ) );
insilmaril@2
   438
	a->setShortcut (Qt::ALT + Qt::Key_C );
insilmaril@4
   439
	fileMenu->addAction (a);
insilmaril@13
   440
    connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
insilmaril@2
   441
insilmaril@2
   442
    a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit")+" "+__VYM, this);
insilmaril@2
   443
	a->setStatusTip ( tr( "Exit")+" "+__VYM );
insilmaril@2
   444
	a->setShortcut (Qt::CTRL + Qt::Key_Q );
insilmaril@4
   445
	fileMenu->addAction (a);
insilmaril@13
   446
    connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
insilmaril@0
   447
}
insilmaril@0
   448
insilmaril@0
   449
insilmaril@0
   450
//Edit Actions
insilmaril@0
   451
void Main::setupEditActions()
insilmaril@0
   452
{
insilmaril@13
   453
    QToolBar *tb = addToolBar( tr ("&Actions") );
insilmaril@0
   454
    tb->setLabel( "Edit Actions" );
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@0
   867
    QAction *a;
insilmaril@0
   868
    QPixmap pix( 16,16);
insilmaril@2
   869
    pix.fill (Qt::black);
insilmaril@2
   870
    a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
insilmaril@2
   871
	a->setStatusTip ( tr( "Set Color" ));
insilmaril@13
   872
    connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
insilmaril@2
   873
    a->addTo( tb );
insilmaril@5
   874
	formatMenu->addAction (a);
insilmaril@2
   875
	actionFormatColor=a;
insilmaril@2
   876
    a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color" ), this);
insilmaril@2
   877
	a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
insilmaril@2
   878
	a->setShortcut (Qt::CTRL + Qt::Key_K );
insilmaril@13
   879
    connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
insilmaril@0
   880
	a->setEnabled (false);
insilmaril@0
   881
    a->addTo( tb );
insilmaril@5
   882
	formatMenu->addAction (a);
insilmaril@2
   883
	actionListBranches.append(a);
insilmaril@0
   884
	actionFormatPickColor=a;
insilmaril@2
   885
insilmaril@2
   886
    a= new QAction(QPixmap(iconPath+"formatcoloritem.png"), tr( "Color &branch" ), this);
insilmaril@2
   887
	a->setStatusTip ( tr( "Color branch" ) );
insilmaril@2
   888
	a->setShortcut (Qt::CTRL + Qt::Key_I);
insilmaril@13
   889
    connect( a, SIGNAL( triggered() ), this, SLOT( formatColorItem() ) );
insilmaril@0
   890
	a->setEnabled (false);
insilmaril@0
   891
    a->addTo( tb );
insilmaril@5
   892
	formatMenu->addAction (a);
insilmaril@2
   893
	actionListBranches.append(a);
insilmaril@0
   894
	actionFormatColorBranch=a;
insilmaril@2
   895
insilmaril@2
   896
    a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color sub&tree" ), this);
insilmaril@2
   897
	a->setStatusTip ( tr( "Color Subtree" ));
insilmaril@2
   898
	a->setShortcut (Qt::CTRL + Qt::Key_T);
insilmaril@13
   899
    connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
insilmaril@0
   900
	a->setEnabled (false);
insilmaril@5
   901
	formatMenu->addAction (a);
insilmaril@0
   902
    a->addTo( tb );
insilmaril@2
   903
	actionListBranches.append(a);
insilmaril@0
   904
	actionFormatColorSubtree=a;
insilmaril@0
   905
insilmaril@5
   906
	formatMenu->addSeparator();
insilmaril@3
   907
	actionGroupFormatLinkStyles=new QActionGroup ( this);
insilmaril@0
   908
	actionGroupFormatLinkStyles->setExclusive (true);
insilmaril@2
   909
    a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
insilmaril@2
   910
	a->setStatusTip (tr( "Line" ));
insilmaril@0
   911
	a->setToggleAction(true);
insilmaril@13
   912
    connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
insilmaril@5
   913
	formatMenu->addAction (a);
insilmaril@0
   914
	actionFormatLinkStyleLine=a;
insilmaril@2
   915
    a= new QAction( tr( "Linkstyle Parabel" ), actionGroupFormatLinkStyles);
insilmaril@2
   916
	a->setStatusTip (tr( "Line" ));
insilmaril@0
   917
	a->setToggleAction(true);
insilmaril@13
   918
    connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
insilmaril@5
   919
	formatMenu->addAction (a);
insilmaril@0
   920
	actionFormatLinkStyleParabel=a;
insilmaril@2
   921
    a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
insilmaril@2
   922
	a->setStatusTip (tr( "PolyLine" ));
insilmaril@0
   923
	a->setToggleAction(true);
insilmaril@13
   924
    connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
insilmaril@5
   925
	formatMenu->addAction (a);
insilmaril@0
   926
	actionFormatLinkStylePolyLine=a;
insilmaril@2
   927
    a= new QAction( tr( "Linkstyle Thick Parabel" ), actionGroupFormatLinkStyles);
insilmaril@2
   928
	a->setStatusTip (tr( "PolyParabel" ) );
insilmaril@0
   929
	a->setToggleAction(true);
insilmaril@5
   930
	a->setChecked (true);
insilmaril@13
   931
    connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
insilmaril@5
   932
	formatMenu->addAction (a);
insilmaril@0
   933
	actionFormatLinkStylePolyParabel=a;
insilmaril@0
   934
	
insilmaril@3
   935
	actionGroupFormatFrameTypes=new QActionGroup ( this);
insilmaril@0
   936
	actionGroupFormatFrameTypes->setExclusive (true);
insilmaril@2
   937
    a = new QAction( tr( "No Frame" ), actionGroupFormatFrameTypes );
insilmaril@2
   938
	a->setStatusTip (tr("No Frame"));
insilmaril@0
   939
	a->setToggleAction(true);
insilmaril@13
   940
    connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameNone() ) );
insilmaril@0
   941
	actionFormatFrameNone=a;
insilmaril@2
   942
    a = new QAction( tr( "Rectangle" ), actionGroupFormatFrameTypes);
insilmaril@2
   943
	a->setStatusTip (tr( "Rectangle" ));
insilmaril@0
   944
	a->setToggleAction(true);
insilmaril@13
   945
    connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameRectangle() ) );
insilmaril@0
   946
	actionFormatFrameRectangle=a;
insilmaril@0
   947
insilmaril@2
   948
    a = new QAction( tr( "Include images vertically" ),  actionFormatIncludeImagesVer);
insilmaril@2
   949
	a->setStatusTip ( tr ("Include top and bottom position of images into branch"));
insilmaril@2
   950
	a->setToggleAction(true);
insilmaril@13
   951
    connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesVer() ) );
insilmaril@2
   952
	actionFormatIncludeImagesVer=a;
insilmaril@2
   953
insilmaril@2
   954
    a = new QAction( tr( "Include images horizontally" ),  actionFormatIncludeImagesHor );
insilmaril@2
   955
	a->setStatusTip ( tr ("Include left and right position of images into branch"));
insilmaril@2
   956
	a->setToggleAction(true);
insilmaril@13
   957
    connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesHor() ) );
insilmaril@2
   958
	actionFormatIncludeImagesHor=a;
insilmaril@2
   959
insilmaril@2
   960
    a = new QAction( tr( "Hide link if object is not selected" ), actionFormatHideLinkUnselected);
insilmaril@2
   961
	a->setStatusTip (tr( "Hide link" ));
insilmaril@2
   962
	a->setToggleAction(true);
insilmaril@13
   963
    connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
insilmaril@2
   964
	actionFormatHideLinkUnselected=a;
insilmaril@2
   965
insilmaril@5
   966
	formatMenu->addSeparator();
insilmaril@2
   967
    a= new QAction( tr( "&Use color of heading for link" ),  this);
insilmaril@2
   968
	a->setStatusTip (tr( "Use same color for links and headings" ));
insilmaril@0
   969
	a->setToggleAction(true);
insilmaril@13
   970
    connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
insilmaril@5
   971
	formatMenu->addAction (a);
insilmaril@0
   972
	actionFormatLinkColorHint=a;
insilmaril@2
   973
insilmaril@2
   974
    pix.fill (Qt::white);
insilmaril@2
   975
    a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this  );
insilmaril@2
   976
	a->setStatusTip (tr( "Set Link Color" ));
insilmaril@5
   977
	formatMenu->addAction (a);
insilmaril@13
   978
    connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
insilmaril@2
   979
    actionFormatLinkColor=a;
insilmaril@2
   980
insilmaril@2
   981
    a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
insilmaril@2
   982
	a->setStatusTip (tr( "Set Background Color" ));
insilmaril@5
   983
	formatMenu->addAction (a);
insilmaril@13
   984
    connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
insilmaril@2
   985
    actionFormatBackColor=a;
insilmaril@0
   986
}
insilmaril@0
   987
insilmaril@0
   988
// View Actions
insilmaril@0
   989
void Main::setupViewActions()
insilmaril@0
   990
{
insilmaril@3
   991
    QToolBar *tb = addToolBar( tr("View Actions","Toolbars") );
insilmaril@0
   992
    tb->setLabel( "View Actions" );
insilmaril@5
   993
    QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
insilmaril@0
   994
insilmaril@0
   995
    QAction *a;
insilmaril@2
   996
    a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom" ), this);
insilmaril@2
   997
	a->setStatusTip ( tr( "Zoom reset" ) );
insilmaril@2
   998
	a->setShortcut (Qt::CTRL + Qt::Key_0 );
insilmaril@0
   999
    a->addTo( tb );
insilmaril@5
  1000
	viewMenu->addAction (a);
insilmaril@13
  1001
    connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
insilmaril@2
  1002
	
insilmaril@2
  1003
    a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in" ), this);
insilmaril@2
  1004
	a->setStatusTip (tr( "Zoom in" ));
insilmaril@2
  1005
	a->setShortcut (Qt::CTRL + Qt::Key_Plus);
insilmaril@0
  1006
    a->addTo( tb );
insilmaril@5
  1007
	viewMenu->addAction (a);
insilmaril@13
  1008
    connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
insilmaril@2
  1009
	
insilmaril@2
  1010
    a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out" ), this);
insilmaril@2
  1011
	a->setStatusTip (tr( "Zoom out" ));
insilmaril@2
  1012
	a->setShortcut (Qt::CTRL + Qt::Key_Minus );
insilmaril@0
  1013
    a->addTo( tb );
insilmaril@5
  1014
	viewMenu->addAction (a);
insilmaril@13
  1015
    connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
insilmaril@2
  1016
insilmaril@2
  1017
insilmaril@2
  1018
    a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor" ),this);
insilmaril@2
  1019
	a->setStatusTip ( tr( "Show Note Editor" ));
insilmaril@2
  1020
	a->setShortcut ( Qt::CTRL + Qt::Key_E );
insilmaril@0
  1021
	a->setToggleAction(true);
insilmaril@0
  1022
	if (textEditor->showWithMain())
insilmaril@0
  1023
		a->setOn(true);
insilmaril@0
  1024
	else	
insilmaril@0
  1025
		a->setOn(false);
insilmaril@0
  1026
    a->addTo( tb );
insilmaril@5
  1027
	viewMenu->addAction (a);
insilmaril@13
  1028
    connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
insilmaril@0
  1029
	actionViewToggleNoteEditor=a;
insilmaril@2
  1030
insilmaril@2
  1031
    a = new QAction(  tr( "Show history window" ),this );
insilmaril@2
  1032
	a->setStatusTip ( tr( "Show history window" ));
insilmaril@2
  1033
	a->setShortcut ( Qt::CTRL + Qt::Key_H  );
insilmaril@2
  1034
	a->setToggleAction(false);
insilmaril@5
  1035
	viewMenu->addAction (a);
insilmaril@13
  1036
    connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
insilmaril@2
  1037
	actionViewToggleHistoryWindow=a;
insilmaril@2
  1038
insilmaril@2
  1039
    a = new QAction(tr( "Next Window" ), this);
insilmaril@2
  1040
	a->setStatusTip ( tr( "&Next Window" ) );
insilmaril@2
  1041
	a->setShortcut (Qt::ALT + Qt::Key_N );
insilmaril@5
  1042
	viewMenu->addAction (a);
insilmaril@13
  1043
    connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
insilmaril@2
  1044
insilmaril@2
  1045
    a = new QAction (tr( "Previous Window" ), this );
insilmaril@2
  1046
	a->setStatusTip (tr( "&Previous Window" ));
insilmaril@2
  1047
	a->setShortcut (Qt::ALT + Qt::Key_P );
insilmaril@5
  1048
	viewMenu->addAction (a);
insilmaril@13
  1049
    connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
insilmaril@2
  1050
}
insilmaril@2
  1051
insilmaril@2
  1052
// Mode Actions
insilmaril@2
  1053
void Main::setupModeActions()
insilmaril@2
  1054
{
insilmaril@2
  1055
    //QPopupMenu *menu = new QPopupMenu( this );
insilmaril@2
  1056
    //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
insilmaril@2
  1057
insilmaril@3
  1058
    QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Toolbars") );
insilmaril@2
  1059
    QAction *a;
insilmaril@3
  1060
	actionGroupModModes=new QActionGroup ( this);
insilmaril@2
  1061
	actionGroupModModes->setExclusive (true);
insilmaril@2
  1062
    a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches" ), actionGroupModModes);
insilmaril@2
  1063
	a->setShortcut (Qt::Key_J);
insilmaril@2
  1064
    a->setStatusTip ( tr( "Use modifier to color branches" ));
insilmaril@2
  1065
	a->setToggleAction(true);
insilmaril@2
  1066
	a->addTo (tb);
insilmaril@2
  1067
	a->setOn(true);
insilmaril@2
  1068
	actionModModeColor=a;
insilmaril@2
  1069
	
insilmaril@2
  1070
    a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy" ), actionGroupModModes );
insilmaril@2
  1071
	a->setShortcut( Qt::Key_K); 
insilmaril@2
  1072
    a->setStatusTip( tr( "Use modifier to copy" ));
insilmaril@2
  1073
	a->setToggleAction(true);
insilmaril@2
  1074
	a->addTo (tb);
insilmaril@2
  1075
	actionModModeCopy=a;
insilmaril@2
  1076
insilmaril@2
  1077
    a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks" ), actionGroupModModes );
insilmaril@2
  1078
	a->setShortcut (Qt::Key_L);
insilmaril@2
  1079
    a->setStatusTip( tr( "Use modifier to draw xLinks" ));
insilmaril@2
  1080
	a->setToggleAction(true);
insilmaril@2
  1081
	a->addTo (tb);
insilmaril@2
  1082
	actionModModeLink=a;
insilmaril@0
  1083
}
insilmaril@0
  1084
insilmaril@0
  1085
// Flag Actions
insilmaril@0
  1086
void Main::setupFlagActions()
insilmaril@0
  1087
{
insilmaril@2
  1088
	// Create System Flags
insilmaril@2
  1089
	systemFlagsDefault = new FlagRowObj ();
insilmaril@2
  1090
	systemFlagsDefault->setVisibility (false);
insilmaril@2
  1091
	systemFlagsDefault->setName ("systemFlagsDef");
insilmaril@2
  1092
insilmaril@2
  1093
	FlagObj *fo = new FlagObj ();
insilmaril@2
  1094
	fo->load(QPixmap(flagsPath+"flag-note.png"));
insilmaril@2
  1095
	fo->setName("note");
insilmaril@2
  1096
	fo->setToolTip(tr("Note","Systemflag"));
insilmaril@2
  1097
	systemFlagsDefault->addFlag (fo);	// makes deep copy
insilmaril@2
  1098
insilmaril@2
  1099
	fo->load(QPixmap(flagsPath+"flag-url.png"));
insilmaril@2
  1100
	fo->setName("url");
insilmaril@2
  1101
	fo->setToolTip(tr("WWW Document (external)","Systemflag"));
insilmaril@2
  1102
	systemFlagsDefault->addFlag (fo);
insilmaril@2
  1103
	
insilmaril@2
  1104
	fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
insilmaril@2
  1105
	fo->setName("vymLink");
insilmaril@2
  1106
	fo->setToolTip(tr("Link to another vym map","Systemflag"));
insilmaril@2
  1107
	systemFlagsDefault->addFlag (fo);	
insilmaril@2
  1108
insilmaril@2
  1109
	fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
insilmaril@2
  1110
	fo->setName("scrolledright");
insilmaril@2
  1111
	fo->setToolTip(tr("subtree is scrolled","Systemflag"));
insilmaril@2
  1112
	systemFlagsDefault->addFlag (fo);
insilmaril@2
  1113
	
insilmaril@2
  1114
	fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
insilmaril@2
  1115
	fo->setName("tmpUnscrolledright");
insilmaril@2
  1116
	fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
insilmaril@2
  1117
	systemFlagsDefault->addFlag (fo);
insilmaril@2
  1118
insilmaril@2
  1119
	fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
insilmaril@2
  1120
	fo->setName("hideInExport");
insilmaril@2
  1121
	fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
insilmaril@2
  1122
	systemFlagsDefault->addFlag (fo);
insilmaril@2
  1123
insilmaril@2
  1124
	// Create Standard Flags
insilmaril@3
  1125
	QToolBar *tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
insilmaril@13
  1126
	//FIXMEtoolbars.add (tb);
insilmaril@3
  1127
insilmaril@2
  1128
	standardFlagsDefault = new FlagRowObj ();
insilmaril@2
  1129
	standardFlagsDefault->setVisibility (false);
insilmaril@2
  1130
	standardFlagsDefault->setName ("standardFlagsDef");
insilmaril@3
  1131
	standardFlagsDefault->setToolBar (tb);
insilmaril@13
  1132
	tb->setObjectName ("standardFlagTB");
insilmaril@2
  1133
insilmaril@2
  1134
	fo->load(QPixmap(flagsPath+"flag-exclamationmark.png"));
insilmaril@2
  1135
	fo->setName ("exclamationmark");
insilmaril@2
  1136
	fo->setGroup("standard-mark");
insilmaril@3
  1137
	QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
insilmaril@3
  1138
	tb->addAction (a);
insilmaril@3
  1139
	fo->setAction (a);
insilmaril@3
  1140
	a->setCheckable(true);
insilmaril@3
  1141
	a->setObjectName(fo->getName());
insilmaril@3
  1142
	a->setToolTip(tr("Take care!","Standardflag"));
insilmaril@13
  1143
	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
insilmaril@2
  1144
	standardFlagsDefault->addFlag (fo);	// makes deep copy
insilmaril@2
  1145
	
insilmaril@2
  1146
	fo->load(QPixmap(flagsPath+"flag-questionmark.png"));
insilmaril@2
  1147
	fo->setName("questionmark");
insilmaril@2
  1148
	fo->setGroup("standard-mark");
insilmaril@3
  1149
	a=new QAction (fo->getPixmap(),fo->getName(),this);
insilmaril@3
  1150
	tb->addAction (a);
insilmaril@3
  1151
	fo->setAction (a);
insilmaril@3
  1152
	a->setCheckable(true);
insilmaril@3
  1153
	a->setObjectName(fo->getName());
insilmaril@3
  1154
	a->setToolTip(tr("Really?","Standardflag"));
insilmaril@13
  1155
	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
insilmaril@2
  1156
	standardFlagsDefault->addFlag (fo);	
insilmaril@2
  1157
insilmaril@2
  1158
	fo->load(QPixmap(flagsPath+"flag-hook-green.png"));
insilmaril@2
  1159
	fo->setName("hook-green");
insilmaril@2
  1160
	fo->setGroup("standard-hook");
insilmaril@3
  1161
	a=new QAction (fo->getPixmap(),fo->getName(),this);
insilmaril@3
  1162
	tb->addAction (a);
insilmaril@3
  1163
	fo->setAction (a);
insilmaril@3
  1164
	a->setCheckable(true);
insilmaril@3
  1165
	a->setObjectName(fo->getName());
insilmaril@3
  1166
	a->setToolTip(tr("ok!","Standardflag"));
insilmaril@13
  1167
	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
insilmaril@2
  1168
	standardFlagsDefault->addFlag (fo);	
insilmaril@2
  1169
insilmaril@2
  1170
	fo->load(QPixmap(flagsPath+"flag-cross-red.png"));
insilmaril@2
  1171
	fo->setName("cross-red");
insilmaril@2
  1172
	fo->setGroup("standard-hook");
insilmaril@3
  1173
	a=new QAction (fo->getPixmap(),fo->getName(),this);
insilmaril@3
  1174
	tb->addAction (a);
insilmaril@3
  1175
	fo->setAction (a);
insilmaril@3
  1176
	a->setCheckable(true);
insilmaril@3
  1177
	a->setObjectName(fo->getName());
insilmaril@3
  1178
	a->setToolTip(tr("Not ok!","Standardflag"));
insilmaril@13
  1179
	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
insilmaril@2
  1180
	standardFlagsDefault->addFlag (fo);	
insilmaril@2
  1181
insilmaril@2
  1182
	fo->load(QPixmap(flagsPath+"flag-stopsign.png"));
insilmaril@2
  1183
	fo->setName("stopsign");
insilmaril@3
  1184
	a=new QAction (fo->getPixmap(),fo->getName(),this);
insilmaril@3
  1185
	tb->addAction (a);
insilmaril@3
  1186
	fo->setAction (a);
insilmaril@3
  1187
	a->setCheckable(true);
insilmaril@3
  1188
	a->setObjectName(fo->getName());
insilmaril@3
  1189
	a->setToolTip(tr("This won't work!","Standardflag"));
insilmaril@13
  1190
	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
insilmaril@2
  1191
	standardFlagsDefault->addFlag (fo);	
insilmaril@2
  1192
insilmaril@2
  1193
	fo->load(QPixmap(flagsPath+"flag-smiley-good.png"));
insilmaril@2
  1194
	fo->setName("smiley-good");
insilmaril@2
  1195
	fo->setGroup("standard-smiley");
insilmaril@3
  1196
	a=new QAction (fo->getPixmap(),fo->getName(),this);
insilmaril@3
  1197
	tb->addAction (a);
insilmaril@3
  1198
	fo->setAction (a);
insilmaril@3
  1199
	a->setCheckable(true);
insilmaril@3
  1200
	a->setObjectName(fo->getName());
insilmaril@3
  1201
	a->setToolTip(tr("Good","Standardflag"));
insilmaril@13
  1202
	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
insilmaril@2
  1203
	standardFlagsDefault->addFlag (fo);	
insilmaril@2
  1204
insilmaril@2
  1205
	fo->load(QPixmap(flagsPath+"flag-smiley-sad.png"));
insilmaril@2
  1206
	fo->setName("smiley-sad");
insilmaril@2
  1207
	fo->setGroup("standard-smiley");
insilmaril@3
  1208
	a=new QAction (fo->getPixmap(),fo->getName(),this);
insilmaril@3
  1209
	tb->addAction (a);
insilmaril@3
  1210
	fo->setAction (a);
insilmaril@3
  1211
	a->setCheckable(true);
insilmaril@3
  1212
	a->setObjectName(fo->getName());
insilmaril@3
  1213
	a->setToolTip(tr("Bad","Standardflag"));
insilmaril@13
  1214
	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
insilmaril@2
  1215
	standardFlagsDefault->addFlag (fo);	
insilmaril@2
  1216
insilmaril@2
  1217
	fo->load(QPixmap(flagsPath+"flag-smiley-omg.png"));
insilmaril@2
  1218
	// Original omg.png (in KDE emoticons)
insilmaril@2
  1219
	fo->setName("smiley-omg");
insilmaril@2
  1220
	fo->setGroup("standard-smiley");
insilmaril@3
  1221
	a=new QAction (fo->getPixmap(),fo->getName(),this);
insilmaril@3
  1222
	tb->addAction (a);
insilmaril@3
  1223
	fo->setAction (a);
insilmaril@3
  1224
	a->setCheckable(true);
insilmaril@3
  1225
	a->setObjectName(fo->getName());
insilmaril@3
  1226
	a->setToolTip(tr("Oh no!","Standardflag"));
insilmaril@13
  1227
	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
insilmaril@2
  1228
	standardFlagsDefault->addFlag (fo);	
insilmaril@2
  1229
insilmaril@2
  1230
	fo->load(QPixmap(flagsPath+"flag-kalarm.png"));
insilmaril@2
  1231
	fo->setName("clock");
insilmaril@3
  1232
	a=new QAction (fo->getPixmap(),fo->getName(),this);
insilmaril@3
  1233
	tb->addAction (a);
insilmaril@3
  1234
	fo->setAction (a);
insilmaril@3
  1235
	a->setCheckable(true);
insilmaril@3
  1236
	a->setObjectName(fo->getName());
insilmaril@3
  1237
	a->setToolTip(tr("Time critical","Standardflag"));
insilmaril@13
  1238
	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
insilmaril@2
  1239
	standardFlagsDefault->addFlag (fo);	
insilmaril@2
  1240
insilmaril@2
  1241
	fo->load(QPixmap(flagsPath+"flag-phone.png"));
insilmaril@2
  1242
	fo->setName("phone");
insilmaril@3
  1243
	a=new QAction (fo->getPixmap(),fo->getName(),this);
insilmaril@3
  1244
	tb->addAction (a);
insilmaril@3
  1245
	fo->setAction (a);
insilmaril@3
  1246
	a->setCheckable(true);
insilmaril@3
  1247
	a->setObjectName(fo->getName());
insilmaril@3
  1248
	a->setToolTip(tr("Call...","Standardflag"));
insilmaril@13
  1249
	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
insilmaril@2
  1250
	standardFlagsDefault->addFlag (fo);	
insilmaril@2
  1251
insilmaril@2
  1252
	fo->load(QPixmap(flagsPath+"flag-lamp.png"));
insilmaril@2
  1253
	fo->setName("lamp");
insilmaril@3
  1254
	a=new QAction (fo->getPixmap(),fo->getName(),this);
insilmaril@3
  1255
	tb->addAction (a);
insilmaril@3
  1256
	fo->setAction (a);
insilmaril@3
  1257
	a->setCheckable(true);
insilmaril@3
  1258
	a->setObjectName(fo->getName());
insilmaril@3
  1259
	a->setToolTip(tr("Idea!","Standardflag"));
insilmaril@13
  1260
	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
insilmaril@2
  1261
	standardFlagsDefault->addFlag (fo);	
insilmaril@2
  1262
insilmaril@2
  1263
	fo->load(QPixmap(flagsPath+"flag-arrow-up.png"));
insilmaril@2
  1264
	fo->setName("arrow-up");
insilmaril@2
  1265
	fo->setGroup("standard-arrow");
insilmaril@3
  1266
	a=new QAction (fo->getPixmap(),fo->getName(),this);
insilmaril@3
  1267
	tb->addAction (a);
insilmaril@3
  1268
	fo->setAction (a);
insilmaril@3
  1269
	a->setCheckable(true);
insilmaril@3
  1270
	a->setObjectName(fo->getName());
insilmaril@3
  1271
	a->setToolTip(tr("Important","Standardflag"));
insilmaril@13
  1272
	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
insilmaril@2
  1273
	standardFlagsDefault->addFlag (fo);	
insilmaril@2
  1274
insilmaril@2
  1275
	fo->load(QPixmap(flagsPath+"flag-arrow-down.png"));
insilmaril@2
  1276
	fo->setName("arrow-down");
insilmaril@2
  1277
	fo->setGroup("standard-arrow");
insilmaril@3
  1278
	a=new QAction (fo->getPixmap(),fo->getName(),this);
insilmaril@3
  1279
	tb->addAction (a);
insilmaril@3
  1280
	fo->setAction (a);
insilmaril@3
  1281
	a->setCheckable(true);
insilmaril@3
  1282
	a->setObjectName(fo->getName());
insilmaril@3
  1283
	a->setToolTip(tr("Unimportant","Standardflag"));
insilmaril@13
  1284
	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
insilmaril@2
  1285
	standardFlagsDefault->addFlag (fo);	
insilmaril@2
  1286
insilmaril@2
  1287
	fo->load(QPixmap(flagsPath+"flag-arrow-2up.png"));
insilmaril@2
  1288
	fo->setName("2arrow-up");
insilmaril@2
  1289
	fo->setGroup("standard-arrow");
insilmaril@3
  1290
	a=new QAction (fo->getPixmap(),fo->getName(),this);
insilmaril@3
  1291
	tb->addAction (a);
insilmaril@3
  1292
	fo->setAction (a);
insilmaril@3
  1293
	a->setCheckable(true);
insilmaril@3
  1294
	a->setObjectName(fo->getName());
insilmaril@3
  1295
	a->setToolTip(tr("Very important!","Standardflag"));
insilmaril@13
  1296
	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
insilmaril@2
  1297
	standardFlagsDefault->addFlag (fo);	
insilmaril@2
  1298
insilmaril@2
  1299
	fo->load(QPixmap(flagsPath+"flag-arrow-2down.png"));
insilmaril@2
  1300
	fo->setName("2arrow-down");
insilmaril@2
  1301
	fo->setGroup("standard-arrow");
insilmaril@3
  1302
	a=new QAction (fo->getPixmap(),fo->getName(),this);
insilmaril@3
  1303
	tb->addAction (a);
insilmaril@3
  1304
	fo->setAction (a);
insilmaril@3
  1305
	a->setCheckable(true);
insilmaril@3
  1306
	a->setObjectName(fo->getName());
insilmaril@3
  1307
	a->setToolTip(tr("Very unimportant!","Standardflag"));
insilmaril@13
  1308
	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
insilmaril@2
  1309
	standardFlagsDefault->addFlag (fo);	
insilmaril@2
  1310
insilmaril@2
  1311
	fo->load(QPixmap(flagsPath+"flag-thumb-up.png"));
insilmaril@2
  1312
	fo->setName("thumb-up");
insilmaril@2
  1313
	fo->setGroup("standard-thumb");
insilmaril@3
  1314
	a=new QAction (fo->getPixmap(),fo->getName(),this);
insilmaril@3
  1315
	tb->addAction (a);
insilmaril@3
  1316
	fo->setAction (a);
insilmaril@3
  1317
	a->setCheckable(true);
insilmaril@3
  1318
	a->setObjectName(fo->getName());
insilmaril@3
  1319
	a->setToolTip(tr("I like this","Standardflag"));
insilmaril@13
  1320
	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
insilmaril@2
  1321
	standardFlagsDefault->addFlag (fo);	
insilmaril@2
  1322
insilmaril@2
  1323
	fo->load(QPixmap(flagsPath+"flag-thumb-down.png"));
insilmaril@2
  1324
	fo->setName("thumb-down");
insilmaril@2
  1325
	fo->setGroup("standard-thumb");
insilmaril@3
  1326
	a=new QAction (fo->getPixmap(),fo->getName(),this);
insilmaril@3
  1327
	tb->addAction (a);
insilmaril@3
  1328
	fo->setAction (a);
insilmaril@3
  1329
	a->setCheckable(true);
insilmaril@3
  1330
	a->setObjectName(fo->getName());
insilmaril@3
  1331
	a->setToolTip(tr("I do not like this","Standardflag"));
insilmaril@13
  1332
	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
insilmaril@2
  1333
	standardFlagsDefault->addFlag (fo);	
insilmaril@2
  1334
	
insilmaril@2
  1335
	fo->load(QPixmap(flagsPath+"flag-rose.png"));
insilmaril@2
  1336
	fo->setName("rose");
insilmaril@3
  1337
	a=new QAction (fo->getPixmap(),fo->getName(),this);
insilmaril@3
  1338
	tb->addAction (a);
insilmaril@3
  1339
	fo->setAction (a);
insilmaril@3
  1340
	a->setCheckable(true);
insilmaril@3
  1341
	a->setObjectName(fo->getName());
insilmaril@3
  1342
	a->setToolTip(tr("Rose","Standardflag"));
insilmaril@13
  1343
	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
insilmaril@2
  1344
	standardFlagsDefault->addFlag (fo);	
insilmaril@2
  1345
insilmaril@2
  1346
	fo->load(QPixmap(flagsPath+"flag-heart.png"));
insilmaril@2
  1347
	fo->setName("heart");
insilmaril@3
  1348
	a=new QAction (fo->getPixmap(),fo->getName(),this);
insilmaril@3
  1349
	tb->addAction (a);
insilmaril@3
  1350
	a->setCheckable(true);
insilmaril@3
  1351
	a->setObjectName(fo->getName());
insilmaril@3
  1352
	a->setToolTip(tr("I just love... ","Standardflag"));
insilmaril@13
  1353
	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
insilmaril@2
  1354
	standardFlagsDefault->addFlag (fo);	
insilmaril@2
  1355
insilmaril@2
  1356
	fo->load(QPixmap(flagsPath+"flag-present.png"));
insilmaril@2
  1357
	fo->setName("present");
insilmaril@3
  1358
	a=new QAction (fo->getPixmap(),fo->getName(),this);
insilmaril@3
  1359
	tb->addAction (a);
insilmaril@3
  1360
	fo->setAction (a);
insilmaril@3
  1361
	a->setCheckable(true);
insilmaril@3
  1362
	a->setObjectName(fo->getName());
insilmaril@3
  1363
	a->setToolTip(tr("Surprise!","Standardflag"));
insilmaril@13
  1364
	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
insilmaril@2
  1365
	standardFlagsDefault->addFlag (fo);	
insilmaril@2
  1366
insilmaril@2
  1367
	fo->load(QPixmap(flagsPath+"flag-flash.png"));
insilmaril@2
  1368
	fo->setName("flash");
insilmaril@3
  1369
	a=new QAction (fo->getPixmap(),fo->getName(),this);
insilmaril@3
  1370
	tb->addAction (a);
insilmaril@3
  1371
	fo->setAction (a);
insilmaril@3
  1372
	a->setCheckable(true);
insilmaril@3
  1373
	a->setObjectName(fo->getName());
insilmaril@3
  1374
	a->setToolTip(tr("Dangerous","Standardflag"));
insilmaril@13
  1375
	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
insilmaril@2
  1376
	standardFlagsDefault->addFlag (fo);	
insilmaril@2
  1377
	
insilmaril@2
  1378
	fo->load(QPixmap(flagsPath+"flag-info.png"));
insilmaril@2
  1379
	// Original: xsldbg_output.png
insilmaril@2
  1380
	fo->setName("info");
insilmaril@3
  1381
	a=new QAction (fo->getPixmap(),fo->getName(),this);
insilmaril@3
  1382
	tb->addAction (a);
insilmaril@3
  1383
	fo->setAction (a);
insilmaril@3
  1384
	a->setCheckable(true);
insilmaril@3
  1385
	a->setObjectName(fo->getName());
insilmaril@3
  1386
	a->setToolTip(tr("Info","Standardflag"));
insilmaril@13
  1387
	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
insilmaril@2
  1388
	standardFlagsDefault->addFlag (fo);	
insilmaril@2
  1389
insilmaril@2
  1390
	fo->load(QPixmap(flagsPath+"flag-lifebelt.png"));
insilmaril@2
  1391
	// Original khelpcenter.png
insilmaril@2
  1392
	fo->setName("lifebelt");
insilmaril@3
  1393
	a=new QAction (fo->getPixmap(),fo->getName(),this);
insilmaril@3
  1394
	tb->addAction (a);
insilmaril@3
  1395
	fo->setAction (a);
insilmaril@3
  1396
	a->setCheckable(true);
insilmaril@3
  1397
	a->setObjectName(fo->getName());
insilmaril@3
  1398
	a->setToolTip(tr("This will help","Standardflag"));
insilmaril@13
  1399
	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
insilmaril@2
  1400
	standardFlagsDefault->addFlag (fo);	
insilmaril@2
  1401
insilmaril@2
  1402
	delete (fo);
insilmaril@0
  1403
}
insilmaril@0
  1404
insilmaril@0
  1405
// Settings Actions
insilmaril@0
  1406
void Main::setupSettingsActions()
insilmaril@0
  1407
{
insilmaril@5
  1408
    QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
insilmaril@0
  1409
insilmaril@0
  1410
	QAction *a;
insilmaril@0
  1411
insilmaril@2
  1412
    a = new QAction( tr( "Set application to open pdf files"), this);
insilmaril@2
  1413
    a->setStatusTip ( tr( "Set application to open pdf files"));
insilmaril@13
  1414
    connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
insilmaril@5
  1415
	settingsMenu->addAction (a);
insilmaril@0
  1416
insilmaril@2
  1417
    a = new QAction( tr( "Set application to open external links"), this);
insilmaril@2
  1418
    a->setStatusTip( tr( "Set application to open external links"));
insilmaril@13
  1419
    connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
insilmaril@5
  1420
	settingsMenu->addAction (a);
insilmaril@5
  1421
insilmaril@5
  1422
	settingsMenu->addSeparator();
insilmaril@2
  1423
    a = new QAction( tr( "Edit branch after adding it" ), this );
insilmaril@2
  1424
    a->setStatusTip( tr( "Edit branch after adding it" ));
insilmaril@0
  1425
	a->setToggleAction(true);
insilmaril@17
  1426
	a->setOn ( settings.value ("/mapeditor/editmode/autoEdit",true).toBool());
insilmaril@5
  1427
	settingsMenu->addAction (a);
insilmaril@0
  1428
	actionSettingsAutoedit=a;
insilmaril@0
  1429
insilmaril@2
  1430
    a= new QAction( tr( "Select branch after adding it" ), this );
insilmaril@2
  1431
    a->setStatusTip( tr( "Select branch after adding it" ));
insilmaril@0
  1432
	a->setToggleAction(true);
insilmaril@17
  1433
	a->setOn ( settings.value ("/mapeditor/editmode/autoSelectHeading",false).toBool() );
insilmaril@5
  1434
	settingsMenu->addAction (a);
insilmaril@0
  1435
	actionSettingsAutoselectHeading=a;
insilmaril@0
  1436
	
insilmaril@2
  1437
    a= new QAction(tr( "Select existing heading" ), this);
insilmaril@2
  1438
    a->setStatusTip( tr( "Select heading before editing" ));
insilmaril@0
  1439
	a->setToggleAction(true);
insilmaril@17
  1440
	a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
insilmaril@5
  1441
	settingsMenu->addAction (a);
insilmaril@0
  1442
	actionSettingsAutoselectText=a;
insilmaril@0
  1443
	
insilmaril@2
  1444
    a= new QAction(tr( "pasting into new branch" ), this );
insilmaril@2
  1445
    a->setStatusTip( tr( "Pasting into new branch" ));
insilmaril@0
  1446
	a->setToggleAction(true);
insilmaril@17
  1447
	a->setOn ( settings.value ("/mapeditor/editmode/newHeadingIsEmpty",true).toBool() );
insilmaril@5
  1448
	settingsMenu->addAction (a);
insilmaril@0
  1449
	actionSettingsPasteNewHeading=a;
insilmaril@0
  1450
	
insilmaril@2
  1451
    a= new QAction( tr( "Delete key" ), this);
insilmaril@2
  1452
    a->setStatusTip( tr( "Delete key for deleting branches" ));
insilmaril@0
  1453
	a->setToggleAction(true);
insilmaril@13
  1454
	a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",false).toBool() );
insilmaril@5
  1455
	settingsMenu->addAction (a);
insilmaril@13
  1456
    connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
insilmaril@0
  1457
	actionSettingsUseDelKey=a;
insilmaril@2
  1458
insilmaril@2
  1459
    a= new QAction( tr( "Exclusive flags" ), this);
insilmaril@2
  1460
    a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
insilmaril@2
  1461
	a->setToggleAction(true);
insilmaril@13
  1462
	a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
insilmaril@5
  1463
	settingsMenu->addAction (a);
insilmaril@2
  1464
	actionSettingsUseFlagGroups=a;
insilmaril@2
  1465
	
insilmaril@2
  1466
    a= new QAction( tr( "Use hide flags" ), this);
insilmaril@2
  1467
    a->setStatusTip( tr( "Use hide flag during exports " ));
insilmaril@2
  1468
	a->setToggleAction(true);
insilmaril@13
  1469
	a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
insilmaril@5
  1470
	settingsMenu->addAction (a);
insilmaril@2
  1471
	actionSettingsUseHideExport=a;
insilmaril@0
  1472
}
insilmaril@0
  1473
insilmaril@0
  1474
// Test Actions
insilmaril@0
  1475
void Main::setupTestActions()
insilmaril@0
  1476
{
insilmaril@5
  1477
    QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
insilmaril@0
  1478
insilmaril@0
  1479
    QAction *a;
insilmaril@2
  1480
    a = new QAction( tr( "test flag" ), this);
insilmaril@2
  1481
    a->setStatusTip( tr( "Call test function" ));
insilmaril@13
  1482
    connect( a, SIGNAL( triggered() ), this, SLOT( testFunction() ) );
insilmaril@5
  1483
	testMenu->addAction (a);
insilmaril@0
  1484
}
insilmaril@0
  1485
insilmaril@0
  1486
// Help Actions
insilmaril@0
  1487
void Main::setupHelpActions()
insilmaril@0
  1488
{
insilmaril@5
  1489
    QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help" ));
insilmaril@0
  1490
insilmaril@0
  1491
    QAction *a;
insilmaril@2
  1492
    a = new QAction(  tr( "Open VYM Documentation (pdf) " ), this );
insilmaril@2
  1493
    a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
insilmaril@13
  1494
    connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
insilmaril@5
  1495
	helpMenu->addAction (a);
insilmaril@0
  1496
insilmaril@2
  1497
    a = new QAction( tr( "About VYM" ), this);
insilmaril@2
  1498
    a->setStatusTip( tr( "About VYM")+" "__VYM);
insilmaril@13
  1499
    connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
insilmaril@5
  1500
	helpMenu->addAction (a);
insilmaril@0
  1501
insilmaril@2
  1502
    a = new QAction( tr( "About QT" ), this);
insilmaril@2
  1503
    a->setStatusTip( tr( "Information about QT toolkit" ));
insilmaril@13
  1504
    connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
insilmaril@5
  1505
	helpMenu->addAction (a);
insilmaril@0
  1506
}
insilmaril@0
  1507
insilmaril@0
  1508
// Context Menus
insilmaril@0
  1509
void Main::setupContextMenus()
insilmaril@0
  1510
{
insilmaril@0
  1511
	QAction*a;
insilmaril@0
  1512
insilmaril@0
  1513
	// Context Menu for branch or mapcenter
insilmaril@4
  1514
	branchContextMenu =new QMenu (this);
insilmaril@2
  1515
insilmaril@2
  1516
		// Submenu "Add"
insilmaril@4
  1517
		branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
insilmaril@4
  1518
		branchAddContextMenu->addAction (actionEditPaste );
insilmaril@4
  1519
		branchAddContextMenu->addAction ( actionEditAddBranch );
insilmaril@4
  1520
		branchAddContextMenu->addAction ( actionEditAddBranchHere );
insilmaril@4
  1521
		branchAddContextMenu->addAction ( actionEditAddBranchAbove);
insilmaril@4
  1522
		branchAddContextMenu->addAction ( actionEditAddBranchBelow );
insilmaril@4
  1523
		branchAddContextMenu->addSeparator();	
insilmaril@4
  1524
		branchAddContextMenu->addAction ( actionEditLoadImage);
insilmaril@4
  1525
		branchAddContextMenu->addSeparator();	
insilmaril@4
  1526
		branchAddContextMenu->addAction ( actionEditImportAdd );
insilmaril@4
  1527
		branchAddContextMenu->addAction ( actionEditImportReplace );
insilmaril@2
  1528
insilmaril@2
  1529
		// Submenu "Remove"
insilmaril@4
  1530
		branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove"));
insilmaril@4
  1531
		branchRemoveContextMenu->addAction (actionEditCut);
insilmaril@4
  1532
		branchRemoveContextMenu->addAction ( actionEditDelete );
insilmaril@4
  1533
		branchRemoveContextMenu->addAction ( actionEditRemoveBranchKeepChilds );
insilmaril@4
  1534
		branchRemoveContextMenu->addAction ( actionEditRemoveChilds );
insilmaril@2
  1535
		
insilmaril@2
  1536
insilmaril@0
  1537
	actionEditSaveBranch->addTo( branchContextMenu );
insilmaril@2
  1538
insilmaril@4
  1539
	branchContextMenu->addSeparator();	
insilmaril@5
  1540
	branchContextMenu->addAction ( actionFormatFrameNone );
insilmaril@5
  1541
	branchContextMenu->addAction ( actionFormatFrameRectangle);
insilmaril@5
  1542
insilmaril@5
  1543
	branchContextMenu->addSeparator();	
insilmaril@5
  1544
	branchContextMenu->addAction ( actionFormatIncludeImagesVer );
insilmaril@5
  1545
	branchContextMenu->addAction ( actionFormatIncludeImagesHor );
insilmaril@5
  1546
	branchContextMenu->addAction ( actionFormatHideLinkUnselected );
insilmaril@2
  1547
insilmaril@17
  1548
	// Submenu for Links (URLs, vymLinks)
insilmaril@17
  1549
	branchLinksContextMenu =new QMenu (this);
insilmaril@17
  1550
insilmaril@17
  1551
		branchContextMenu->addSeparator();	
insilmaril@17
  1552
		branchLinksContextMenu=branchContextMenu->addMenu(tr("URLs and vymLinks"));	
insilmaril@17
  1553
		branchLinksContextMenu->addAction ( actionEditOpenURL );
insilmaril@17
  1554
		branchLinksContextMenu->addAction ( actionEditOpenURLTab );
insilmaril@17
  1555
		branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
insilmaril@17
  1556
		branchLinksContextMenu->addAction ( actionEditURL );
insilmaril@17
  1557
		branchLinksContextMenu->addAction ( actionEditHeading2URL );
insilmaril@17
  1558
		branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
insilmaril@17
  1559
		if (settings.value( "/mainwindow/showTestMenu",true).toBool() )
insilmaril@17
  1560
		{
insilmaril@17
  1561
			branchLinksContextMenu->addAction ( actionEditFATE2URL );
insilmaril@17
  1562
		}	
insilmaril@17
  1563
		branchLinksContextMenu->addSeparator();	
insilmaril@17
  1564
		branchLinksContextMenu->addAction ( actionEditOpenVymLink );
insilmaril@17
  1565
		branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
insilmaril@17
  1566
		branchLinksContextMenu->addAction ( actionEditVymLink );
insilmaril@17
  1567
		branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
insilmaril@17
  1568
		
insilmaril@17
  1569
insilmaril@17
  1570
	// Context Menu for XLinks in a branch menu
insilmaril@2
  1571
	// This will be populated "on demand" in MapEditor::updateActions
insilmaril@5
  1572
	branchContextMenu->addSeparator();	
insilmaril@17
  1573
	branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink"));
insilmaril@17
  1574
	branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink"));
insilmaril@17
  1575
	connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
insilmaril@17
  1576
	connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
insilmaril@17
  1577
 	
insilmaril@2
  1578
	
insilmaril@0
  1579
	// Context menu for floatimage
insilmaril@4
  1580
	floatimageContextMenu =new QMenu (this);
insilmaril@11
  1581
	a= new QAction (tr ("Save image"),this);
insilmaril@11
  1582
	connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
insilmaril@11
  1583
	floatimageContextMenu->addAction (a);
insilmaril@2
  1584
insilmaril@4
  1585
	floatimageContextMenu->addSeparator();	
insilmaril@0
  1586
	actionEditCopy->addTo( floatimageContextMenu );
insilmaril@0
  1587
	actionEditCut->addTo( floatimageContextMenu );
insilmaril@0
  1588
insilmaril@4
  1589
	floatimageContextMenu->addSeparator();	
insilmaril@4
  1590
	floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
insilmaril@4
  1591
insilmaril@0
  1592
	
insilmaril@0
  1593
	// Context menu for canvas
insilmaril@4
  1594
	canvasContextMenu =new QMenu (this);
insilmaril@0
  1595
	actionEditMapInfo->addTo( canvasContextMenu );
insilmaril@0
  1596
	canvasContextMenu->insertSeparator();	
insilmaril@0
  1597
	actionGroupFormatLinkStyles->addTo( canvasContextMenu );
insilmaril@0
  1598
	canvasContextMenu->insertSeparator();	
insilmaril@0
  1599
	actionFormatLinkColorHint->addTo( canvasContextMenu );
insilmaril@0
  1600
	actionFormatLinkColor->addTo( canvasContextMenu );
insilmaril@0
  1601
	actionFormatBackColor->addTo( canvasContextMenu );
insilmaril@0
  1602
insilmaril@0
  1603
	// Menu for last opened files
insilmaril@0
  1604
	// Read settings initially
insilmaril@0
  1605
	QString s;
insilmaril@13
  1606
	int j=settings.readNumEntry( "/lastMaps/number",0);
insilmaril@0
  1607
	for (int i=1;i<=j;i++)
insilmaril@0
  1608
	{
insilmaril@13
  1609
		s=settings.value(QString("/lastMaps/map-%1").arg(i),"").toString();
insilmaril@0
  1610
		if (!s.isEmpty() && j<=maxLastMaps) 
insilmaril@0
  1611
			lastMaps.append(s);
insilmaril@0
  1612
	}
insilmaril@0
  1613
	setupLastMapsMenu();
insilmaril@7
  1614
	connect( fileLastMapsMenu, SIGNAL( triggered(QAction *) ), this, SLOT( fileLoadLast(QAction*) ) );
insilmaril@0
  1615
}
insilmaril@0
  1616
insilmaril@0
  1617
void Main::setupLastMapsMenu()
insilmaril@0
  1618
{
insilmaril@0
  1619
	// Remove double entries
insilmaril@0
  1620
	QStringList::Iterator it=lastMaps.begin();
insilmaril@0
  1621
	QStringList::Iterator jt;
insilmaril@0
  1622
	while (it!=lastMaps.end() )
insilmaril@0
  1623
	{
insilmaril@0
  1624
		jt=it;
insilmaril@0
  1625
		++jt;
insilmaril@0
  1626
		while (jt!=lastMaps.end() )
insilmaril@0
  1627
		{
insilmaril@0
  1628
			if (*it == *jt)		
insilmaril@0
  1629
				jt=lastMaps.remove(jt);
insilmaril@0
  1630
			else	
insilmaril@0
  1631
				jt++;
insilmaril@0
  1632
		}
insilmaril@0
  1633
		it++;
insilmaril@0
  1634
	}	
insilmaril@0
  1635
insilmaril@0
  1636
	// Limit length of list to maxLastMaps
insilmaril@0
  1637
	while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
insilmaril@0
  1638
	
insilmaril@0
  1639
	// build Menu from lastMaps string list
insilmaril@4
  1640
	fileLastMapsMenu->clear();
insilmaril@0
  1641
	for (it = lastMaps.begin(); it != lastMaps.end(); ++it ) 
insilmaril@4
  1642
		fileLastMapsMenu->addAction (*it );
insilmaril@0
  1643
}
insilmaril@0
  1644
insilmaril@0
  1645
void Main::hideEvent (QHideEvent * )
insilmaril@0
  1646
{
insilmaril@0
  1647
	if (!textEditor->isMinimized() ) textEditor->hide();
insilmaril@0
  1648
}
insilmaril@0
  1649
insilmaril@0
  1650
void Main::showEvent (QShowEvent * )
insilmaril@0
  1651
{
insilmaril@2
  1652
	if (textEditor->showWithMain()) textEditor->showNormal();
insilmaril@0
  1653
}
insilmaril@0
  1654
insilmaril@0
  1655
bool Main::reallyWriteDirectory(const QString &dir)
insilmaril@0
  1656
{
insilmaril@0
  1657
	QStringList eList = QDir(dir).entryList();
insilmaril@0
  1658
	if (eList.first() ==".")  eList.pop_front();	// remove "."
insilmaril@0
  1659
	if (eList.first() =="..") eList.pop_front();	// remove "."
insilmaril@0
  1660
	if (!eList.isEmpty())
insilmaril@0
  1661
	{
insilmaril@2
  1662
		QMessageBox mb( __VYM,
insilmaril@2
  1663
			tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?").arg(dir),
insilmaril@0
  1664
		QMessageBox::Warning,
insilmaril@0
  1665
		QMessageBox::Yes ,
insilmaril@0
  1666
		QMessageBox::Cancel | QMessageBox::Default,
insilmaril@0
  1667
		QMessageBox::QMessageBox::NoButton );
insilmaril@0
  1668
insilmaril@0
  1669
		mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
insilmaril@0
  1670
		mb.setButtonText( QMessageBox::No, tr("Cancel"));
insilmaril@0
  1671
		switch( mb.exec() ) 
insilmaril@0
  1672
		{
insilmaril@0
  1673
			case QMessageBox::Yes:
insilmaril@0
  1674
				// save 
insilmaril@0
  1675
				return true;
insilmaril@0
  1676
			case QMessageBox::Cancel:
insilmaril@0
  1677
				// do nothing
insilmaril@0
  1678
				return false;
insilmaril@0
  1679
		}
insilmaril@0
  1680
	}
insilmaril@0
  1681
	return true;
insilmaril@0
  1682
}
insilmaril@0
  1683
insilmaril@0
  1684
QString Main::browseDirectory (const QString &caption)
insilmaril@0
  1685
{
insilmaril@2
  1686
	Q3FileDialog fd(this,caption);
insilmaril@2
  1687
	fd.setMode (Q3FileDialog::DirectoryOnly);
insilmaril@2
  1688
	fd.setCaption(__VYM " - "+caption);
insilmaril@0
  1689
	fd.show();
insilmaril@0
  1690
	
insilmaril@0
  1691
	if ( fd.exec() == QDialog::Accepted )
insilmaril@0
  1692
		return fd.selectedFile();
insilmaril@0
  1693
	else
insilmaril@0
  1694
		return "";
insilmaril@0
  1695
}
insilmaril@0
  1696
insilmaril@0
  1697
MapEditor* Main::currentMapEditor() const
insilmaril@0
  1698
{
insilmaril@0
  1699
    if ( tabWidget->currentPage() &&
insilmaril@0
  1700
	 tabWidget->currentPage()->inherits( "MapEditor" ) )
insilmaril@0
  1701
		return (MapEditor*)tabWidget->currentPage();
insilmaril@0
  1702
    return NULL;	
insilmaril@0
  1703
}
insilmaril@0
  1704
insilmaril@0
  1705
//TODO not used now, maybe use this for overview window later
insilmaril@0
  1706
void Main::newView() 
insilmaril@0
  1707
{
insilmaril@0
  1708
    // Open a new view... have it delete when closed.
insilmaril@2
  1709
    Main *m = new Main(0, 0, Qt::WDestructiveClose);
insilmaril@0
  1710
    qApp->setMainWidget(m);
insilmaril@0
  1711
    m->show();
insilmaril@0
  1712
    qApp->setMainWidget(0);
insilmaril@0
  1713
}
insilmaril@0
  1714
insilmaril@0
  1715
void Main::editorChanged(QWidget *)
insilmaril@0
  1716
{
insilmaril@0
  1717
	// Unselect all possibly selected objects
insilmaril@0
  1718
	// (Important to update note editor)
insilmaril@0
  1719
	int i;
insilmaril@0
  1720
	MapEditor *me;
insilmaril@0
  1721
	for (i=0;i<=tabWidget->count() -1;i++)
insilmaril@0
  1722
	{
insilmaril@0
  1723
		
insilmaril@0
  1724
		me=(MapEditor*)tabWidget->page(i);
insilmaril@0
  1725
		me->unselect();
insilmaril@0
  1726
	}	
insilmaril@0
  1727
	currentMapEditor()->reselect();
insilmaril@0
  1728
insilmaril@0
  1729
	// Update actions to in menus and toolbars according to editor
insilmaril@0
  1730
	currentMapEditor()->updateActions();
insilmaril@0
  1731
}
insilmaril@0
  1732
insilmaril@0
  1733
void Main::fileNew()
insilmaril@0
  1734
{
insilmaril@0
  1735
	QString fn="unnamed";
insilmaril@2
  1736
	MapEditor* medit = new MapEditor ( NULL,true);
insilmaril@0
  1737
	tabWidget->addTab (medit,fn);
insilmaril@0
  1738
	tabWidget->showPage(medit);
insilmaril@0
  1739
	medit->viewport()->setFocus();
insilmaril@2
  1740
	// For the very first map we do not have flagrows yet...
insilmaril@0
  1741
	medit->select("mc:");
insilmaril@0
  1742
}
insilmaril@0
  1743
insilmaril@2
  1744
ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
insilmaril@0
  1745
{
insilmaril@2
  1746
	ErrorCode err=success;
insilmaril@0
  1747
	
insilmaril@0
  1748
	// fn is usually the archive, mapfile the file after uncompressing
insilmaril@0
  1749
	QString mapfile;
insilmaril@0
  1750
insilmaril@0
  1751
	// Make fn absolute (needed for unzip)
insilmaril@0
  1752
	fn=QDir (fn).absPath();
insilmaril@0
  1753
insilmaril@0
  1754
	MapEditor *me;
insilmaril@0
  1755
insilmaril@0
  1756
	if (lmode==NewMap)
insilmaril@0
  1757
	{
insilmaril@0
  1758
		// Check, if map is already loaded
insilmaril@0
  1759
		int i=0;
insilmaril@0
  1760
		while (i<=tabWidget->count() -1)
insilmaril@0
  1761
		{
insilmaril@0
  1762
			me=(MapEditor*)tabWidget->page(i);
insilmaril@0
  1763
			if (me->getFilePath() == fn)
insilmaril@0
  1764
			{
insilmaril@0
  1765
				// Already there, ask for confirmation
insilmaril@2
  1766
				QMessageBox mb( __VYM,
insilmaril@2
  1767
					tr("The map %1\nis already opened."
insilmaril@0
  1768
					"Opening the same map in multiple editors may lead \n"
insilmaril@0
  1769
					"to confusion when finishing working with vym."
insilmaril@2
  1770
					"Do you want to").arg(fn),
insilmaril@0
  1771
					QMessageBox::Warning,
insilmaril@0
  1772
					QMessageBox::Yes | QMessageBox::Default,
insilmaril@0
  1773
					QMessageBox::Cancel | QMessageBox::Escape,
insilmaril@2
  1774
					QMessageBox::NoButton);
insilmaril@0
  1775
				mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
insilmaril@0
  1776
				mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
insilmaril@0
  1777
				switch( mb.exec() ) 
insilmaril@0
  1778
				{
insilmaril@0
  1779
					case QMessageBox::Yes:
insilmaril@0
  1780
						// load anyway
insilmaril@0
  1781
						i=tabWidget->count();
insilmaril@0
  1782
						break;
insilmaril@0
  1783
					case QMessageBox::Cancel:
insilmaril@0
  1784
						// do nothing
insilmaril@2
  1785
						return aborted;
insilmaril@0
  1786
						break;
insilmaril@0
  1787
				}
insilmaril@0
  1788
			}
insilmaril@0
  1789
			i++;
insilmaril@0
  1790
		}
insilmaril@0
  1791
	}
insilmaril@0
  1792
insilmaril@0
  1793
insilmaril@0
  1794
	// Try to load map
insilmaril@0
  1795
    if ( !fn.isEmpty() )
insilmaril@0
  1796
	{
insilmaril@0
  1797
		me = currentMapEditor();
insilmaril@0
  1798
		int tabIndex=tabWidget->currentPageIndex();
insilmaril@0
  1799
		// Check first, if mapeditor exists
insilmaril@0
  1800
		// If it is not default AND we want a new map, 
insilmaril@0
  1801
		// create a new mapeditor in a new tab
insilmaril@0
  1802
		if ( lmode==NewMap && (!me || !me->isDefault() ) )
insilmaril@0
  1803
		{
insilmaril@3
  1804
			me= new MapEditor ( NULL,true);
insilmaril@0
  1805
			tabWidget->addTab (me,fn);
insilmaril@0
  1806
			tabIndex=tabWidget->indexOf (me);
insilmaril@0
  1807
			tabWidget->setCurrentPage (tabIndex);
insilmaril@0
  1808
		}
insilmaril@0
  1809
		
insilmaril@0
  1810
		// Check, if file exists (important for creating new files
insilmaril@0
  1811
		// from command line
insilmaril@0
  1812
		if (!QFile(fn).exists() )
insilmaril@0
  1813
		{
insilmaril@2
  1814
			QMessageBox mb( __VYM,
insilmaril@2
  1815
				tr("This map does not exist:\n  %1\nDo you want to create a new one?").arg(fn),
insilmaril@0
  1816
				QMessageBox::Question,
insilmaril@0
  1817
				QMessageBox::Yes ,
insilmaril@0
  1818
				QMessageBox::Cancel | QMessageBox::Default,
insilmaril@2
  1819
				QMessageBox::NoButton );
insilmaril@0
  1820
insilmaril@0
  1821
			mb.setButtonText( QMessageBox::Yes, tr("Create"));
insilmaril@0
  1822
			mb.setButtonText( QMessageBox::No, tr("Cancel"));
insilmaril@0
  1823
			switch( mb.exec() ) 
insilmaril@0
  1824
			{
insilmaril@0
  1825
				case QMessageBox::Yes:
insilmaril@0
  1826
					// Create new map
insilmaril@0
  1827
					currentMapEditor()->setFilePath(fn);
insilmaril@0
  1828
					tabWidget->setTabLabel (currentMapEditor(),
insilmaril@0
  1829
						currentMapEditor()->getFileName() );
insilmaril@0
  1830
					statusBar()->message( "Created " + fn , statusbarTime );
insilmaril@2
  1831
					return success;
insilmaril@0
  1832
						
insilmaril@0
  1833
				case QMessageBox::Cancel:
insilmaril@0
  1834
					// don't create new map
insilmaril@0
  1835
					statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
insilmaril@0
  1836
					fileCloseMap();
insilmaril@2
  1837
					return aborted;
insilmaril@0
  1838
			}
insilmaril@0
  1839
		}	
insilmaril@0
  1840
insilmaril@0
  1841
insilmaril@0
  1842
		//tabWidget->currentPage() won't be NULL here, because of above...
insilmaril@0
  1843
		tabWidget->showPage(me);
insilmaril@0
  1844
		me->viewport()->setFocus();
insilmaril@0
  1845
insilmaril@0
  1846
		// Create temporary directory for packing
insilmaril@0
  1847
		char tmpdir1[]="/tmp/vym-XXXXXX";	
insilmaril@0
  1848
		QString tmpMapDir=mkdtemp(tmpdir1);
insilmaril@0
  1849
insilmaril@0
  1850
		// Try to unzip file
insilmaril@2
  1851
		err=unzipDir (tmpMapDir,fn);
insilmaril@2
  1852
		if (err==nozip)
insilmaril@0
  1853
		{
insilmaril@2
  1854
			mapfile=fn;
insilmaril@2
  1855
			me->setZipped(false);
insilmaril@0
  1856
		} else
insilmaril@0
  1857
		{
insilmaril@2
  1858
			me->setZipped(true);
insilmaril@2
  1859
			
insilmaril@2
  1860
			// Look for mapname.xml
insilmaril@2
  1861
			mapfile= fn.left(fn.findRev(".",-1,true));
insilmaril@2
  1862
			mapfile=mapfile.section( '/', -1 );
insilmaril@2
  1863
			QFile file( tmpMapDir + "/" + mapfile + ".xml");
insilmaril@2
  1864
			if (!file.exists() )
insilmaril@0
  1865
			{
insilmaril@2
  1866
				// mapname.xml does not exist, well, 
insilmaril@2
  1867
				// maybe some renamed the mapname.vym file...
insilmaril@2
  1868
				// Try to find any .xml in the toplevel 
insilmaril@2
  1869
				// directory of the .vym file
insilmaril@2
  1870
				QStringList flist=QDir (tmpMapDir).entryList("*.xml");
insilmaril@2
  1871
				if (flist.count()==1) 
insilmaril@0
  1872
				{
insilmaril@2
  1873
					// Only one entry, take this one
insilmaril@2
  1874
					mapfile=tmpMapDir + "/"+flist.first();
insilmaril@0
  1875
				} else
insilmaril@2
  1876
				{
insilmaril@2
  1877
					for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it ) 
insilmaril@2
  1878
						*it=tmpMapDir + "/" + *it;
insilmaril@2
  1879
					// TODO Multiple entries, load all (but only the first one into this ME)
insilmaril@2
  1880
					//mainWindow->fileLoadFromTmp (flist);
insilmaril@2
  1881
					//returnCode=1;	// Silently forget this attempt to load
insilmaril@2
  1882
					qWarning ("MainWindow::load (fn)  multimap found...");
insilmaril@2
  1883
				}	
insilmaril@0
  1884
					
insilmaril@2
  1885
				if (flist.isEmpty() )
insilmaril@2
  1886
				{
insilmaril@2
  1887
					QMessageBox::critical( 0, tr( "Critical Load Error" ),
insilmaril@2
  1888
							   tr("Couldn't find a map (*.xml) in .vym archive.\n"));
insilmaril@2
  1889
					err=aborted;				   
insilmaril@2
  1890
				}	
insilmaril@2
  1891
			} //file doesn't exist	
insilmaril@2
  1892
			else
insilmaril@2
  1893
				mapfile=file.name();
insilmaril@0
  1894
		}
insilmaril@0
  1895
insilmaril@2
  1896
		if (err!=aborted)
insilmaril@2
  1897
		{
insilmaril@2
  1898
			// Save existing filename in case  we import
insilmaril@2
  1899
			QString fn_org=me->getFilePath();
insilmaril@0
  1900
insilmaril@2
  1901
			// Finally load map into mapEditor
insilmaril@2
  1902
			me->setFilePath (mapfile,fn);
insilmaril@2
  1903
			err=me->load(mapfile,lmode);
insilmaril@0
  1904
insilmaril@2
  1905
			// Restore old (maybe empty) filepath, if this is an import
insilmaril@2
  1906
			if (lmode!=NewMap)
insilmaril@2
  1907
				me->setFilePath (fn_org);
insilmaril@2
  1908
		}	
insilmaril@2
  1909
insilmaril@2
  1910
		// Finally check for errors and go home
insilmaril@2
  1911
		if (err==aborted) 
insilmaril@2
  1912
		{
insilmaril@2
  1913
			if (lmode==NewMap) fileCloseMap();
insilmaril@2
  1914
			statusBar()->message( "Could not load " + fn, statusbarTime );
insilmaril@2
  1915
		} else 
insilmaril@0
  1916
		{
insilmaril@0
  1917
			if (lmode==NewMap)
insilmaril@0
  1918
			{
insilmaril@0
  1919
				me->setFilePath (fn);
insilmaril@0
  1920
				tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
insilmaril@2
  1921
				if (fn.left(9)!="/tmp/vym-")
insilmaril@2
  1922
				{
insilmaril@2
  1923
					// Only append to lastMaps if not loaded from a tmpDir
insilmaril@2
  1924
					// e.g. imported bookmarks are in a tmpDir
insilmaril@2
  1925
					lastMaps.prepend(me->getFilePath() );
insilmaril@2
  1926
					setupLastMapsMenu();
insilmaril@2
  1927
				}
insilmaril@0
  1928
				actionFilePrint->setEnabled (true);
insilmaril@0
  1929
			}	
insilmaril@0
  1930
			statusBar()->message( "Loaded " + fn, statusbarTime );
insilmaril@0
  1931
		}	
insilmaril@0
  1932
insilmaril@2
  1933
		// Delete tmpDir
insilmaril@2
  1934
		removeDir (QDir(tmpMapDir));
insilmaril@0
  1935
	}
insilmaril@2
  1936
	return err;
insilmaril@0
  1937
}
insilmaril@0
  1938
insilmaril@0
  1939
insilmaril@0
  1940
void Main::fileLoad(const LoadMode &lmode)
insilmaril@0
  1941
{
insilmaril@2
  1942
	Q3FileDialog *fd=new Q3FileDialog( this);
insilmaril@11
  1943
	fd->setDir (lastFileDir);
insilmaril@2
  1944
	fd->setMode (Q3FileDialog::ExistingFiles);
insilmaril@0
  1945
	fd->addFilter ("XML (*.xml)");
insilmaril@0
  1946
	fd->addFilter ("VYM map (*.vym *.vyp)");
insilmaril@0
  1947
	switch (lmode)
insilmaril@0
  1948
	{
insilmaril@0
  1949
		case NewMap:
insilmaril@0
  1950
			fd->setCaption(tr("Load vym map"));
insilmaril@0
  1951
			break;
insilmaril@0
  1952
		case ImportAdd:
insilmaril@0
  1953
			fd->setCaption(tr("Import: Add vym map to selection"));
insilmaril@0
  1954
			break;
insilmaril@0
  1955
		case ImportReplace:
insilmaril@0
  1956
			fd->setCaption(tr("Import: Replace selection with vym map"));
insilmaril@0
  1957
			break;
insilmaril@0
  1958
	}
insilmaril@0
  1959
	fd->show();
insilmaril@0
  1960
insilmaril@0
  1961
	QString fn;
insilmaril@0
  1962
	if ( fd->exec() == QDialog::Accepted )
insilmaril@0
  1963
	{
insilmaril@0
  1964
		lastFileDir=fd->dirPath();
insilmaril@2
  1965
	    QStringList flist = fd->selectedFiles();
insilmaril@2
  1966
		QStringList::Iterator it = flist.begin();
insilmaril@2
  1967
		while( it != flist.end() ) 
insilmaril@2
  1968
		{
insilmaril@2
  1969
			fn = *it;
insilmaril@2
  1970
			fileLoad(*it, lmode);				   
insilmaril@2
  1971
			++it;
insilmaril@2
  1972
		}
insilmaril@0
  1973
	}
insilmaril@2
  1974
	delete (fd);
insilmaril@0
  1975
}
insilmaril@0
  1976
insilmaril@0
  1977
void Main::fileLoad()
insilmaril@0
  1978
{
insilmaril@0
  1979
	fileLoad (NewMap);
insilmaril@0
  1980
}
insilmaril@0
  1981
insilmaril@7
  1982
void Main::fileLoadLast(QAction *a)
insilmaril@0
  1983
{
insilmaril@7
  1984
	fileLoad(lastMaps.at(fileLastMapsMenu->actions().indexOf(a)) ,NewMap);
insilmaril@0
  1985
}
insilmaril@0
  1986
insilmaril@0
  1987
void Main::fileSave(const SaveMode &savemode)
insilmaril@0
  1988
{
insilmaril@0
  1989
	// tmp dir for zipping 
insilmaril@0
  1990
	QString tmpMapDir;
insilmaril@0
  1991
	
insilmaril@0
  1992
	// Error codes
insilmaril@2
  1993
	ErrorCode err=success;
insilmaril@0
  1994
	
insilmaril@0
  1995
	QString safeFilePath;
insilmaril@0
  1996
insilmaril@0
  1997
	bool saveZipped=currentMapEditor()->saveZipped();
insilmaril@0
  1998
insilmaril@2
  1999
	MapEditor *	me=currentMapEditor();
insilmaril@2
  2000
	if (me)
insilmaril@0
  2001
	{
insilmaril@2
  2002
		QString fn=me->getFilePath();
insilmaril@0
  2003
		// filename=unnamed, filepath="" in constructor...
insilmaril@0
  2004
		if ( !fn.isEmpty() ) 
insilmaril@0
  2005
		{	
insilmaril@0
  2006
			// We have a filepath, go on saving			
insilmaril@0
  2007
			// First remove existing file, we 
insilmaril@0
  2008
			// don't want to add to old zip archives
insilmaril@0
  2009
			QFile f(fn);
insilmaril@0
  2010
			if (f.exists() ) 
insilmaril@0
  2011
				if (!f.remove())
insilmaril@0
  2012
					QMessageBox::warning( 0, tr( "Save Error" ),
insilmaril@0
  2013
						fn+   tr("\ncould not be removed before saving"));
insilmaril@0
  2014
insilmaril@0
  2015
			// Look, if we should zip the data:
insilmaril@0
  2016
			if (!saveZipped)
insilmaril@0
  2017
			{
insilmaril@2
  2018
				QMessageBox mb( __VYM,
insilmaril@2
  2019
					tr("The map %1\ndid not use the compressed "
insilmaril@0
  2020
					"vym file format.\nWriting it uncompressed will also write images \n"
insilmaril@0
  2021
					"and flags and thus may overwrite files in the "
insilmaril@2
  2022
					"given directory\n\nDo you want to write the map").arg(fn),
insilmaril@0
  2023
					QMessageBox::Warning,
insilmaril@0
  2024
					QMessageBox::Yes | QMessageBox::Default,
insilmaril@0
  2025
					QMessageBox::No ,
insilmaril@0
  2026
					QMessageBox::Cancel | QMessageBox::Escape);
insilmaril@0
  2027
				mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
insilmaril@0
  2028
				mb.setButtonText( QMessageBox::No, tr("uncompressed") );
insilmaril@0
  2029
				mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
insilmaril@0
  2030
				switch( mb.exec() ) 
insilmaril@0
  2031
				{
insilmaril@0
  2032
					case QMessageBox::Yes:
insilmaril@0
  2033
						// save compressed (default file format)
insilmaril@0
  2034
						saveZipped=true;
insilmaril@0
  2035
						break;
insilmaril@0
  2036
					case QMessageBox::No:
insilmaril@0
  2037
						// save uncompressed
insilmaril@0
  2038
						saveZipped=false;
insilmaril@0
  2039
						break;
insilmaril@0
  2040
					case QMessageBox::Cancel:
insilmaril@0
  2041
						// do nothing
insilmaril@0
  2042
						return;
insilmaril@0
  2043
						break;
insilmaril@0
  2044
				}
insilmaril@0
  2045
			}
insilmaril@0
  2046
insilmaril@0
  2047
			if (saveZipped)
insilmaril@0
  2048
			{
insilmaril@0
  2049
				char tmpdir1[]="/tmp/vym-XXXXXX";	
insilmaril@0
  2050
				tmpMapDir=mkdtemp(tmpdir1);
insilmaril@0
  2051
			
insilmaril@2
  2052
				safeFilePath=me->getFilePath();
insilmaril@2
  2053
				me->setFilePath (tmpMapDir+"/"+
insilmaril@2
  2054
					me->getMapName()+ ".xml",
insilmaril@0
  2055
					safeFilePath);
insilmaril@2
  2056
				me->save (savemode);
insilmaril@2
  2057
				me->setFilePath (safeFilePath);
insilmaril@0
  2058
				
insilmaril@2
  2059
				zipDir (tmpMapDir,fn);
insilmaril@0
  2060
			} // save zipped
insilmaril@0
  2061
			else
insilmaril@0
  2062
			{
insilmaril@0
  2063
				// Save unzipped. 
insilmaril@2
  2064
				safeFilePath=me->getFilePath();
insilmaril@2
  2065
				me->setFilePath (fn, safeFilePath);
insilmaril@2
  2066
				me->save (savemode);
insilmaril@2
  2067
				me->setFilePath (safeFilePath);
insilmaril@0
  2068
			} // save zipped 	
insilmaril@0
  2069
		} // filepath available
insilmaril@0
  2070
		else
insilmaril@0
  2071
		{
insilmaril@0
  2072
			// We have  no filepath yet,
insilmaril@0
  2073
			// call fileSaveAs() now, this will call fileSave() 
insilmaril@0
  2074
			// again.
insilmaril@0
  2075
			fileSaveAs(savemode);
insilmaril@0
  2076
		}
insilmaril@0
  2077
    }
insilmaril@0
  2078
insilmaril@2
  2079
	if (saveZipped && !tmpMapDir.isEmpty())
insilmaril@0
  2080
		// Delete tmpDir
insilmaril@2
  2081
		removeDir (QDir(tmpMapDir));
insilmaril@0
  2082
insilmaril@0
  2083
	if (err==success)
insilmaril@2
  2084
	{
insilmaril@0
  2085
		statusBar()->message( 
insilmaril@2
  2086
			tr("Saved  %1").arg(me->getFilePath()), 
insilmaril@0
  2087
			statusbarTime );
insilmaril@2
  2088
		lastMaps.prepend(me->getFilePath() );
insilmaril@2
  2089
		setupLastMapsMenu();
insilmaril@2
  2090
	} else		
insilmaril@0
  2091
		statusBar()->message( 
insilmaril@2
  2092
			tr("Couldn't save ").arg(me->getFilePath()), 
insilmaril@0
  2093
			statusbarTime );
insilmaril@0
  2094
}
insilmaril@0
  2095
insilmaril@0
  2096
void Main::fileSave()
insilmaril@0
  2097
{
insilmaril@0
  2098
	fileSave (CompleteMap);
insilmaril@0
  2099
}
insilmaril@0
  2100
insilmaril@0
  2101
void Main::fileSaveAs(const SaveMode& savemode)
insilmaril@0
  2102
{
insilmaril@0
  2103
	QString fn;
insilmaril@0
  2104
insilmaril@0
  2105
	if (currentMapEditor())
insilmaril@0
  2106
	{
insilmaril@0
  2107
		if (savemode==CompleteMap)
insilmaril@2
  2108
			fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
insilmaril@0
  2109
		else		
insilmaril@2
  2110
			fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
insilmaril@0
  2111
		if ( !fn.isEmpty() ) 
insilmaril@0
  2112
		{
insilmaril@0
  2113
			// Check for existing file
insilmaril@0
  2114
			if (QFile (fn).exists())
insilmaril@0
  2115
			{
insilmaril@2
  2116
				QMessageBox mb( __VYM,
insilmaril@2
  2117
					tr("The file %1\nexists already. Do you want to").arg(fn),
insilmaril@0
  2118
					QMessageBox::Warning,
insilmaril@0
  2119
					QMessageBox::Yes | QMessageBox::Default,
insilmaril@0
  2120
					QMessageBox::Cancel | QMessageBox::Escape,
insilmaril@2
  2121
					QMessageBox::NoButton);
insilmaril@0
  2122
				mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
insilmaril@0
  2123
				mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
insilmaril@0
  2124
				switch( mb.exec() ) 
insilmaril@0
  2125
				{
insilmaril@0
  2126
					case QMessageBox::Yes:
insilmaril@0
  2127
						// save 
insilmaril@0
  2128
						break;
insilmaril@0
  2129
					case QMessageBox::Cancel:
insilmaril@0
  2130
						// do nothing
insilmaril@0
  2131
						return;
insilmaril@0
  2132
						break;
insilmaril@0
  2133
				}
insilmaril@0
  2134
			} else
insilmaril@0
  2135
			{
insilmaril@0
  2136
				// New file, add extension to filename, if missing
insilmaril@0
  2137
				// This is always .vym or .vyp, depending on savemode
insilmaril@0
  2138
				if (savemode==CompleteMap)
insilmaril@0
  2139
				{
insilmaril@0
  2140
					if (!fn.contains (".vym") && !fn.contains (".xml"))
insilmaril@0
  2141
						fn +=".vym";
insilmaril@0
  2142
				} else		
insilmaril@0
  2143
				{
insilmaril@0
  2144
					if (!fn.contains (".vyp") && !fn.contains (".xml"))
insilmaril@0
  2145
						fn +=".vyp";
insilmaril@0
  2146
				}
insilmaril@0
  2147
			}
insilmaril@0
  2148
	
insilmaril@0
  2149
insilmaril@0
  2150
insilmaril@0
  2151
insilmaril@0
  2152
			// Save now
insilmaril@0
  2153
			currentMapEditor()->setFilePath(fn);
insilmaril@0
  2154
			fileSave(savemode);
insilmaril@0
  2155
insilmaril@0
  2156
			// Set name of tab
insilmaril@2
  2157
			if (savemode==CompleteMap)
insilmaril@2
  2158
				tabWidget->setTabLabel (currentMapEditor(),
insilmaril@2
  2159
					currentMapEditor()->getFileName() );
insilmaril@0
  2160
			return;
insilmaril@0
  2161
		} 
insilmaril@0
  2162
	}
insilmaril@0
  2163
}
insilmaril@0
  2164
insilmaril@0
  2165
void Main::fileSaveAs()
insilmaril@0
  2166
{
insilmaril@0
  2167
	fileSaveAs (CompleteMap);
insilmaril@0
  2168
}
insilmaril@0
  2169
insilmaril@2
  2170
void Main::fileImportKDEBookmarks()
insilmaril@2
  2171
{
insilmaril@2
  2172
	ImportKDEBookmarks im;
insilmaril@2
  2173
	im.transform();
insilmaril@2
  2174
	if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
insilmaril@2
  2175
		currentMapEditor()->setFilePath ("");
insilmaril@2
  2176
}
insilmaril@2
  2177
insilmaril@2
  2178
void Main::fileImportFirefoxBookmarks()
insilmaril@2
  2179
{
insilmaril@2
  2180
	Q3FileDialog *fd=new Q3FileDialog( this);
insilmaril@2
  2181
	fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
insilmaril@2
  2182
	fd->setMode (Q3FileDialog::ExistingFiles);
insilmaril@2
  2183
	fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
insilmaril@2
  2184
	fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
insilmaril@2
  2185
	fd->show();
insilmaril@2
  2186
insilmaril@2
  2187
	if ( fd->exec() == QDialog::Accepted )
insilmaril@2
  2188
	{
insilmaril@2
  2189
		ImportFirefoxBookmarks im;
insilmaril@2
  2190
	    QStringList flist = fd->selectedFiles();
insilmaril@2
  2191
		QStringList::Iterator it = flist.begin();
insilmaril@2
  2192
		while( it != flist.end() ) 
insilmaril@2
  2193
		{
insilmaril@2
  2194
			im.setFile (*it);
insilmaril@2
  2195
			if (im.transform() && 
insilmaril@2
  2196
				success==fileLoad (im.getTransformedFile(),NewMap) && 
insilmaril@2
  2197
				currentMapEditor() )
insilmaril@2
  2198
				currentMapEditor()->setFilePath ("");
insilmaril@2
  2199
			++it;
insilmaril@2
  2200
		}
insilmaril@2
  2201
	}
insilmaril@2
  2202
	delete (fd);
insilmaril@2
  2203
}
insilmaril@2
  2204
insilmaril@2
  2205
void Main::fileImportMM()
insilmaril@2
  2206
{
insilmaril@2
  2207
	ImportMM im;
insilmaril@2
  2208
insilmaril@2
  2209
	Q3FileDialog *fd=new Q3FileDialog( this);
insilmaril@11
  2210
	fd->setDir (lastFileDir);
insilmaril@2
  2211
	fd->setMode (Q3FileDialog::ExistingFiles);
insilmaril@2
  2212
	fd->addFilter ("Mind Manager (*.mmap)");
insilmaril@2
  2213
	fd->setCaption(tr("Import")+" "+"Mind Manager");
insilmaril@2
  2214
	fd->show();
insilmaril@2
  2215
insilmaril@2
  2216
	if ( fd->exec() == QDialog::Accepted )
insilmaril@2
  2217
	{
insilmaril@2
  2218
		lastFileDir=fd->dirPath();
insilmaril@2
  2219
	    QStringList flist = fd->selectedFiles();
insilmaril@2
  2220
		QStringList::Iterator it = flist.begin();
insilmaril@2
  2221
		while( it != flist.end() ) 
insilmaril@2
  2222
		{
insilmaril@2
  2223
			im.setFile (*it);
insilmaril@2
  2224
			if (im.transform() && 
insilmaril@2
  2225
				success==fileLoad (im.getTransformedFile(),NewMap) && 
insilmaril@2
  2226
				currentMapEditor() )
insilmaril@2
  2227
				currentMapEditor()->setFilePath ("");
insilmaril@2
  2228
insilmaril@2
  2229
			++it;
insilmaril@2
  2230
		}
insilmaril@2
  2231
	}
insilmaril@2
  2232
	delete (fd);
insilmaril@2
  2233
insilmaril@2
  2234
}
insilmaril@2
  2235
insilmaril@0
  2236
void Main::fileImportDir()
insilmaril@0
  2237
{
insilmaril@0
  2238
	if (currentMapEditor())
insilmaril@0
  2239
		currentMapEditor()->importDir();	
insilmaril@0
  2240
}
insilmaril@0
  2241
insilmaril@0
  2242
void Main::fileExportXML()
insilmaril@0
  2243
{
insilmaril@0
  2244
	if (currentMapEditor())
insilmaril@0
  2245
	{
insilmaril@0
  2246
		QString dir=browseDirectory(tr("Export XML to directory"));
insilmaril@0
  2247
		if (dir !="" && reallyWriteDirectory(dir) )
insilmaril@0
  2248
			currentMapEditor()->exportXML(dir);
insilmaril@0
  2249
	}	
insilmaril@0
  2250
}
insilmaril@0
  2251
insilmaril@0
  2252
insilmaril@0
  2253
void Main::fileExportXHTML()
insilmaril@0
  2254
{
insilmaril@2
  2255
	MapEditor *me=currentMapEditor();
insilmaril@0
  2256
	QString dir;
insilmaril@2
  2257
	if (me)
insilmaril@0
  2258
	{
insilmaril@0
  2259
		ExportXHTMLDialog dia(this);
insilmaril@2
  2260
		dia.setFilePath (me->getFilePath() );
insilmaril@2
  2261
		dia.setMapName (me->getMapName() );
insilmaril@0
  2262
		dia.readSettings();
insilmaril@0
  2263
		
insilmaril@0
  2264
		if (dia.exec()==QDialog::Accepted)
insilmaril@0
  2265
		{
insilmaril@0
  2266
			QString dir=dia.getDir();
insilmaril@0
  2267
			// Check, if warnings should be used before overwriting
insilmaril@0
  2268
			// the output directory
insilmaril@0
  2269
			bool ok;
insilmaril@0
  2270
			if (dia.warnings()) 
insilmaril@0
  2271
				ok=reallyWriteDirectory(dir);
insilmaril@0
  2272
			else
insilmaril@0
  2273
				ok=true;
insilmaril@0
  2274
insilmaril@0
  2275
			if (ok)
insilmaril@0
  2276
			{
insilmaril@2
  2277
				me->exportXML (dia.getDir() );
insilmaril@2
  2278
				dia.doExport(me->getMapName() );
insilmaril@0
  2279
				if (dia.hasChanged())
insilmaril@2
  2280
					me->setChanged();
insilmaril@0
  2281
			}	
insilmaril@0
  2282
		}
insilmaril@0
  2283
	}	
insilmaril@0
  2284
}
insilmaril@0
  2285
insilmaril@4
  2286
void Main::fileExportImage()
insilmaril@0
  2287
{
insilmaril@2
  2288
	MapEditor *me=currentMapEditor();
insilmaril@2
  2289
	if (me)
insilmaril@0
  2290
	{
insilmaril@4
  2291
		QStringList fl;
insilmaril@4
  2292
		QFileDialog *fd=new QFileDialog (this);
insilmaril@4
  2293
		fd->setCaption (tr("Export map as image"));
insilmaril@4
  2294
		fd->setFileMode(QFileDialog::AnyFile);
insilmaril@4
  2295
		fd->setFilters  (imageIO.getFilters() );
insilmaril@4
  2296
		fd->setDirectory (lastImageDir);
insilmaril@4
  2297
		if (fd->exec())
insilmaril@4
  2298
		{
insilmaril@4
  2299
			fl=fd->selectedFiles();
insilmaril@4
  2300
			qWarning ("Selected "+fl.first()+"  filter: "+fd->selectedFilter());
insilmaril@4
  2301
			me->exportImage (fl.first(), imageIO.getType (fd->selectedFilter() ) );
insilmaril@4
  2302
		} 
insilmaril@0
  2303
	}
insilmaril@0
  2304
}
insilmaril@0
  2305
insilmaril@0
  2306
void Main::fileExportASCII()
insilmaril@0
  2307
{
insilmaril@2
  2308
	MapEditor *me=currentMapEditor();
insilmaril@2
  2309
	if (me)
insilmaril@2
  2310
	{
insilmaril@2
  2311
		ExportASCII ex;
insilmaril@2
  2312
		ex.setMapCenter(me->getMapCenter());
insilmaril@2
  2313
		ex.addFilter ("TXT (*.txt)");
insilmaril@2
  2314
		ex.setCaption(__VYM " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
insilmaril@2
  2315
		if (ex.execDialog() ) 
insilmaril@2
  2316
		{
insilmaril@2
  2317
			me->setExportMode(true);
insilmaril@2
  2318
			ex.doExport();
insilmaril@2
  2319
			me->setExportMode(false);
insilmaril@2
  2320
		}
insilmaril@2
  2321
	}
insilmaril@2
  2322
}
insilmaril@2
  2323
insilmaril@2
  2324
void Main::fileExportLaTeX()
insilmaril@2
  2325
{
insilmaril@2
  2326
	MapEditor *me=currentMapEditor();
insilmaril@2
  2327
	if (me)
insilmaril@2
  2328
	{
insilmaril@2
  2329
		ExportLaTeX ex;
insilmaril@2
  2330
		ex.setMapCenter(me->getMapCenter());
insilmaril@2
  2331
		ex.addFilter ("Tex (*.tex)");
insilmaril@2
  2332
		ex.setCaption(__VYM " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
insilmaril@2
  2333
		if (ex.execDialog() ) 
insilmaril@2
  2334
		{
insilmaril@2
  2335
			me->setExportMode(true);
insilmaril@2
  2336
			ex.doExport();
insilmaril@2
  2337
			me->setExportMode(false);
insilmaril@2
  2338
		}
insilmaril@2
  2339
	}
insilmaril@2
  2340
}
insilmaril@2
  2341
insilmaril@2
  2342
void Main::fileExportKDEBookmarks()
insilmaril@2
  2343
{
insilmaril@2
  2344
	ExportKDEBookmarks ex;
insilmaril@2
  2345
	MapEditor *me=currentMapEditor();
insilmaril@2
  2346
	if (me)
insilmaril@2
  2347
	{
insilmaril@2
  2348
		ex.setMapCenter (me->getMapCenter() );
insilmaril@2
  2349
		ex.doExport();
insilmaril@2
  2350
	}	
insilmaril@2
  2351
}
insilmaril@2
  2352
insilmaril@2
  2353
void Main::fileExportTaskjuggler()
insilmaril@2
  2354
{
insilmaril@2
  2355
	ExportTaskjuggler ex;
insilmaril@2
  2356
	MapEditor *me=currentMapEditor();
insilmaril@2
  2357
	if (me)
insilmaril@2
  2358
	{
insilmaril@2
  2359
		ex.setMapCenter (me->getMapCenter() );
insilmaril@2
  2360
		ex.setCaption ( __VYM " - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
insilmaril@2
  2361
		ex.addFilter ("Taskjuggler (*.tjp)");
insilmaril@2
  2362
		if (ex.execDialog() ) 
insilmaril@2
  2363
		{
insilmaril@2
  2364
			me->setExportMode(true);
insilmaril@2
  2365
			ex.doExport();
insilmaril@2
  2366
			me->setExportMode(false);
insilmaril@2
  2367
		}
insilmaril@2
  2368
	}	
insilmaril@2
  2369
}
insilmaril@2
  2370
insilmaril@2
  2371
void Main::fileExportOOPresentation()
insilmaril@2
  2372
{
insilmaril@2
  2373
	ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to")+" Open Office");
insilmaril@9
  2374
	// TODO add preview in dialog
insilmaril@2
  2375
	//ImagePreview *p =new ImagePreview (fd);
insilmaril@2
  2376
	//fd->setContentsPreviewEnabled( TRUE );
insilmaril@2
  2377
	//fd->setContentsPreview( p, p );
insilmaril@2
  2378
	//fd->setPreviewMode( QFileDialog::Contents );
insilmaril@2
  2379
	fd->setCaption(__VYM " - " +tr("Export to")+" Open Office");
insilmaril@9
  2380
	fd->setDir (QDir().current());
insilmaril@11
  2381
	if (fd->foundConfig())
insilmaril@2
  2382
	{
insilmaril@11
  2383
		fd->show();
insilmaril@11
  2384
insilmaril@11
  2385
		if ( fd->exec() == QDialog::Accepted )
insilmaril@11
  2386
		{
insilmaril@11
  2387
			QString fn=fd->selectedFile();
insilmaril@17
  2388
			if (!fn.contains (".odp"))
insilmaril@17
  2389
				fn +=".odp";
insilmaril@17
  2390
insilmaril@11
  2391
			//lastImageDir=fn.left(fn.findRev ("/"));
insilmaril@11
  2392
			if (currentMapEditor())
insilmaril@11
  2393
				currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());	
insilmaril@11
  2394
		}
insilmaril@11
  2395
	} else
insilmaril@11
  2396
	{
insilmaril@11
  2397
		QMessageBox::warning(0, 
insilmaril@11
  2398
		tr("Warning"),
insilmaril@11
  2399
		tr("Couldn't find configuration for export to Open Office\n"));
insilmaril@2
  2400
	}
insilmaril@0
  2401
}
insilmaril@0
  2402
insilmaril@0
  2403
void Main::fileCloseMap()
insilmaril@0
  2404
{
insilmaril@0
  2405
	if (currentMapEditor())
insilmaril@0
  2406
	{
insilmaril@0
  2407
		if (currentMapEditor()->hasChanged())
insilmaril@0
  2408
		{
insilmaril@2
  2409
			QMessageBox mb( __VYM,
insilmaril@2
  2410
				tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
insilmaril@0
  2411
				QMessageBox::Warning,
insilmaril@0
  2412
				QMessageBox::Yes | QMessageBox::Default,
insilmaril@0
  2413
				QMessageBox::No,
insilmaril@0
  2414
				QMessageBox::Cancel | QMessageBox::Escape );
insilmaril@0
  2415
			mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
insilmaril@0
  2416
			mb.setButtonText( QMessageBox::No, tr("Discard changes"));
insilmaril@0
  2417
			switch( mb.exec() ) 
insilmaril@0
  2418
			{
insilmaril@0
  2419
				case QMessageBox::Yes:
insilmaril@0
  2420
					// save and close
insilmaril@0
  2421
					fileSave(CompleteMap);
insilmaril@0
  2422
					break;
insilmaril@0
  2423
				case QMessageBox::No:
insilmaril@0
  2424
				// close  without saving
insilmaril@0
  2425
					break;
insilmaril@0
  2426
				case QMessageBox::Cancel:
insilmaril@0
  2427
					// do nothing
insilmaril@0
  2428
				return;
insilmaril@0
  2429
			}
insilmaril@0
  2430
		} 
insilmaril@0
  2431
		currentMapEditor()->closeMap();
insilmaril@0
  2432
		tabWidget->removePage(currentMapEditor());
insilmaril@0
  2433
		if (tabWidget->count()==0)
insilmaril@0
  2434
			actionFilePrint->setEnabled (false);
insilmaril@0
  2435
	}	
insilmaril@0
  2436
}
insilmaril@0
  2437
insilmaril@0
  2438
void Main::filePrint()
insilmaril@0
  2439
{
insilmaril@0
  2440
	if (currentMapEditor())
insilmaril@0
  2441
		currentMapEditor()->print();
insilmaril@0
  2442
}
insilmaril@0
  2443
insilmaril@0
  2444
void Main::fileExitVYM()
insilmaril@0
  2445
{
insilmaril@0
  2446
	// Check if one or more editors have changed
insilmaril@0
  2447
	MapEditor *me;
insilmaril@0
  2448
	int i;
insilmaril@0
  2449
	for (i=0;i<=tabWidget->count() -1;i++)
insilmaril@0
  2450
	{
insilmaril@0
  2451
		
insilmaril@0
  2452
		me=(MapEditor*)tabWidget->page(i);
insilmaril@0
  2453
insilmaril@0
  2454
		// If something changed, ask what to do
insilmaril@0
  2455
		if (me->isUnsaved())
insilmaril@0
  2456
		{
insilmaril@0
  2457
			tabWidget->setCurrentPage(i);
insilmaril@2
  2458
			QMessageBox mb( __VYM,
insilmaril@0
  2459
				tr("This map is not saved yet. Do you want to"),
insilmaril@0
  2460
				QMessageBox::Warning,
insilmaril@0
  2461
				QMessageBox::Yes | QMessageBox::Default,
insilmaril@0
  2462
				QMessageBox::No,
insilmaril@0
  2463
				QMessageBox::Cancel | QMessageBox::Escape );
insilmaril@0
  2464
			mb.setButtonText( QMessageBox::Yes, tr("Save map") );
insilmaril@0
  2465
			mb.setButtonText( QMessageBox::No, tr("Discard changes") );
insilmaril@16
  2466
			mb.setModal (true);
insilmaril@0
  2467
			mb.show();
insilmaril@0
  2468
			mb.setActiveWindow();
insilmaril@0
  2469
			switch( mb.exec() ) {
insilmaril@0
  2470
				case QMessageBox::Yes:
insilmaril@0
  2471
					// save (the changed editors) and exit
insilmaril@0
  2472
					fileSave(CompleteMap);
insilmaril@0
  2473
					break;
insilmaril@0
  2474
				case QMessageBox::No:
insilmaril@0
  2475
					// exit without saving
insilmaril@0
  2476
					break;
insilmaril@0
  2477
				case QMessageBox::Cancel:
insilmaril@0
  2478
					// don't save and don't exit
insilmaril@0
  2479
				return;
insilmaril@0
  2480
			}
insilmaril@0
  2481
		}
insilmaril@0
  2482
	} // loop over all MEs	
insilmaril@0
  2483
    qApp->quit();
insilmaril@0
  2484
}
insilmaril@0
  2485
insilmaril@0
  2486
void Main::editUndo()
insilmaril@0
  2487
{
insilmaril@0
  2488
	if (currentMapEditor())
insilmaril@0
  2489
		currentMapEditor()->undo();
insilmaril@0
  2490
}
insilmaril@0
  2491
insilmaril@2
  2492
void Main::editRedo()	   
insilmaril@0
  2493
{
insilmaril@2
  2494
	if (currentMapEditor())
insilmaril@2
  2495
		currentMapEditor()->redo();
insilmaril@0
  2496
}
insilmaril@0
  2497
insilmaril@0
  2498
void Main::editCopy()
insilmaril@0
  2499
{
insilmaril@0
  2500
	if (currentMapEditor())
insilmaril@0
  2501
		currentMapEditor()->copy();
insilmaril@0
  2502
}
insilmaril@0
  2503
insilmaril@0
  2504
void Main::editPaste()
insilmaril@0
  2505
{
insilmaril@0
  2506
	if (currentMapEditor())
insilmaril@0
  2507
		currentMapEditor()->paste();
insilmaril@0
  2508
}
insilmaril@0
  2509
insilmaril@0
  2510
void Main::editCut()
insilmaril@0
  2511
{
insilmaril@0
  2512
	if (currentMapEditor())
insilmaril@0
  2513
		currentMapEditor()->cut();
insilmaril@0
  2514
}
insilmaril@0
  2515
insilmaril@0
  2516
void Main::editOpenFindWindow()
insilmaril@0
  2517
{
insilmaril@0
  2518
	findWindow->popup();
insilmaril@0
  2519
	findWindow->raise();
insilmaril@0
  2520
	findWindow->setActiveWindow();
insilmaril@0
  2521
}
insilmaril@0
  2522
insilmaril@0
  2523
void Main::editFind(QString s)
insilmaril@0
  2524
{
insilmaril@0
  2525
	bool cs=false;
insilmaril@0
  2526
	BranchObj *bo=currentMapEditor()->findText(s, cs);
insilmaril@0
  2527
	if (bo)
insilmaril@0
  2528
	{	
insilmaril@0
  2529
		statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
insilmaril@0
  2530
	} else
insilmaril@0
  2531
	{
insilmaril@0
  2532
		QMessageBox::information( findWindow, tr( "VYM -Information:" ),
insilmaril@2
  2533
							   tr("No matches found for \"%1\"").arg(s));
insilmaril@0
  2534
	}	
insilmaril@0
  2535
}
insilmaril@0
  2536
insilmaril@0
  2537
void Main::editFindChanged()
insilmaril@0
  2538
{	// Notify editor, to abort the current find process
insilmaril@0
  2539
	currentMapEditor()->findReset();
insilmaril@0
  2540
}
insilmaril@0
  2541
insilmaril@16
  2542
void Main::openTabs(QStringList urls)
insilmaril@16
  2543
{
insilmaril@16
  2544
	if (!urls.isEmpty())
insilmaril@16
  2545
	{	
insilmaril@16
  2546
		bool success=true;
insilmaril@16
  2547
		QStringList args;
insilmaril@16
  2548
		QString browser=settings.value("/mainwindow/readerURL" ).toString();
insilmaril@16
  2549
		QProcess *p;
insilmaril@16
  2550
		if (!procBrowser ||  procBrowser->state()!=QProcess::Running)
insilmaril@16
  2551
		{
insilmaril@16
  2552
			QString u=urls.takeFirst();
insilmaril@16
  2553
			procBrowser = new QProcess( this );
insilmaril@16
  2554
			args<<u;
insilmaril@16
  2555
			procBrowser->start(browser,args);
insilmaril@16
  2556
			if ( !procBrowser->waitForStarted())
insilmaril@16
  2557
			{
insilmaril@16
  2558
				// try to set path to browser
insilmaril@16
  2559
				QMessageBox::warning(0, 
insilmaril@16
  2560
					tr("Warning"),
insilmaril@16
  2561
					tr("Couldn't find a viewer to open %1.\n").arg(u)+
insilmaril@16
  2562
					tr("Please use Settings->")+tr("Set application to open an URL"));
insilmaril@16
  2563
				return;
insilmaril@16
  2564
			}
insilmaril@16
  2565
			sleep (3);
insilmaril@16
  2566
		}
insilmaril@16
  2567
		if (browser.contains("konqueror"))
insilmaril@16
  2568
		{
insilmaril@16
  2569
			for (int i=0; i<urls.size(); i++)
insilmaril@16
  2570
			{
insilmaril@16
  2571
				// Open new browser
insilmaril@16
  2572
				// Try to open new tab in existing konqueror started previously by vym
insilmaril@16
  2573
				p=new QProcess (this);
insilmaril@16
  2574
				args.clear();
insilmaril@16
  2575
				args<< QString("konqueror-%1").arg(procBrowser->pid())<< 
insilmaril@16
  2576
					"konqueror-mainwindow#1"<< 
insilmaril@16
  2577
					"newTab" << 
insilmaril@16
  2578
					urls.at(i);
insilmaril@16
  2579
				p->start ("dcop",args);
insilmaril@16
  2580
				if ( !p->waitForStarted() ) success=false;
insilmaril@16
  2581
			}
insilmaril@16
  2582
			if (!success)
insilmaril@16
  2583
				QMessageBox::warning(0, 
insilmaril@16
  2584
					tr("Warning"),
insilmaril@16
  2585
					tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
insilmaril@16
  2586
			return;		
insilmaril@16
  2587
		} else if (browser.contains ("firefox") || browser.contains ("mozilla") )
insilmaril@16
  2588
		{
insilmaril@16
  2589
			for (int i=0; i<urls.size(); i++)
insilmaril@16
  2590
			{
insilmaril@16
  2591
				// Try to open new tab in firefox
insilmaril@16
  2592
				p=new QProcess (this);
insilmaril@16
  2593
				args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
insilmaril@16
  2594
				p->start (browser,args);
insilmaril@16
  2595
				if ( !p->waitForStarted() ) success=false;
insilmaril@16
  2596
			}			
insilmaril@16
  2597
			if (!success)
insilmaril@16
  2598
				QMessageBox::warning(0, 
insilmaril@16
  2599
					tr("Warning"),
insilmaril@16
  2600
					tr("Couldn't start %1 to open a new tab").arg(browser));
insilmaril@16
  2601
			return;		
insilmaril@16
  2602
		}			
insilmaril@16
  2603
		QMessageBox::warning(0, 
insilmaril@16
  2604
			tr("Warning"),
insilmaril@16
  2605
			tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
insilmaril@16
  2606
	}	
insilmaril@16
  2607
}
insilmaril@16
  2608
insilmaril@0
  2609
void Main::editOpenURL()
insilmaril@0
  2610
{
insilmaril@2
  2611
	// Open new browser
insilmaril@0
  2612
	if (currentMapEditor())
insilmaril@2
  2613
	{	
insilmaril@2
  2614
	    QString url=currentMapEditor()->getURL();
insilmaril@16
  2615
		QStringList args;
insilmaril@2
  2616
		if (url=="") return;
insilmaril@13
  2617
		QString browser=settings.value("/mainwindow/readerURL" ).toString();
insilmaril@16
  2618
		procBrowser = new QProcess( this );
insilmaril@16
  2619
		args<<url;
insilmaril@16
  2620
		procBrowser->start(browser,args);
insilmaril@16
  2621
		if ( !procBrowser->waitForStarted())
insilmaril@2
  2622
		{
insilmaril@2
  2623
			// try to set path to browser
insilmaril@2
  2624
			QMessageBox::warning(0, 
insilmaril@2
  2625
				tr("Warning"),
insilmaril@2
  2626
				tr("Couldn't find a viewer to open %1.\n").arg(url)+
insilmaril@2
  2627
				tr("Please use Settings->")+tr("Set application to open an URL"));
insilmaril@2
  2628
			settingsURL() ; 
insilmaril@2
  2629
		}	
insilmaril@2
  2630
	}	
insilmaril@2
  2631
}
insilmaril@2
  2632
void Main::editOpenURLTab()
insilmaril@2
  2633
{
insilmaril@2
  2634
	if (currentMapEditor())
insilmaril@2
  2635
	{	
insilmaril@16
  2636
	    QStringList urls;
insilmaril@16
  2637
		urls.append(currentMapEditor()->getURL());
insilmaril@16
  2638
		openTabs (urls);
insilmaril@2
  2639
	}	
insilmaril@0
  2640
}
insilmaril@16
  2641
void Main::editOpenMultipleURLTabs()
insilmaril@16
  2642
{
insilmaril@16
  2643
	if (currentMapEditor())
insilmaril@16
  2644
	{	
insilmaril@16
  2645
	    QStringList urls;
insilmaril@17
  2646
		urls=currentMapEditor()->getURLs();
insilmaril@16
  2647
		openTabs (urls);
insilmaril@16
  2648
	}	
insilmaril@16
  2649
}
insilmaril@16
  2650
insilmaril@0
  2651
insilmaril@0
  2652
void Main::editURL()
insilmaril@0
  2653
{
insilmaril@0
  2654
	if (currentMapEditor())
insilmaril@0
  2655
	    currentMapEditor()->editURL();
insilmaril@0
  2656
}
insilmaril@0
  2657
insilmaril@0
  2658
void Main::editHeading2URL()
insilmaril@0
  2659
{
insilmaril@0
  2660
	if (currentMapEditor())
insilmaril@0
  2661
	    currentMapEditor()->editHeading2URL();
insilmaril@0
  2662
}
insilmaril@0
  2663
insilmaril@0
  2664
void Main::editBugzilla2URL()
insilmaril@0
  2665
{
insilmaril@0
  2666
	if (currentMapEditor())
insilmaril@0
  2667
	    currentMapEditor()->editBugzilla2URL();
insilmaril@0
  2668
}
insilmaril@0
  2669
insilmaril@2
  2670
void Main::editFATE2URL()
insilmaril@2
  2671
{
insilmaril@2
  2672
	if (currentMapEditor())
insilmaril@2
  2673
	    currentMapEditor()->editFATE2URL();
insilmaril@2
  2674
}
insilmaril@2
  2675
insilmaril@16
  2676
void Main::editHeading()
insilmaril@16
  2677
{
insilmaril@16
  2678
	if (lineedit->isVisible())
insilmaril@16
  2679
	{
insilmaril@16
  2680
		if (currentMapEditor())
insilmaril@17
  2681
		{	
insilmaril@17
  2682
			MapEditor *me=currentMapEditor();
insilmaril@17
  2683
			QString oldSel=me->getSelectString();
insilmaril@17
  2684
			if (me->select (editSel))
insilmaril@17
  2685
				me->setHeading(lineedit->text());
insilmaril@17
  2686
			me->select (oldSel);
insilmaril@17
  2687
		}	
insilmaril@16
  2688
		lineedit->releaseKeyboard();
insilmaril@16
  2689
		lineedit->hide();
insilmaril@16
  2690
		setFocus();
insilmaril@16
  2691
	} else
insilmaril@16
  2692
	{
insilmaril@16
  2693
		if (currentMapEditor())
insilmaril@16
  2694
		{
insilmaril@16
  2695
			bool ok;
insilmaril@16
  2696
			QPoint p;
insilmaril@16
  2697
			QString s=currentMapEditor()->getHeading(ok,p);
insilmaril@16
  2698
insilmaril@16
  2699
			if (ok)
insilmaril@16
  2700
			{
insilmaril@16
  2701
#if defined(Q_OS_MACX)
insilmaril@16
  2702
				p = currentMapEditor()->mapToGlobal( currentMapEditor()->worldMatrix().map( p));
insilmaril@16
  2703
				QDialog *d =new QDialog(NULL);
insilmaril@16
  2704
				QLineEdit *le=new QLineEdit (d);
insilmaril@16
  2705
				d->setWindowFlags (Qt::FramelessWindowHint);
insilmaril@16
  2706
				d->setGeometry(p.x(),p.y(),200,25);
insilmaril@16
  2707
				le->resize (d->size());
insilmaril@16
  2708
				le->setText (s);
insilmaril@16
  2709
				le->selectAll();
insilmaril@16
  2710
				connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
insilmaril@16
  2711
				d->activateWindow();
insilmaril@16
  2712
				d->exec();
insilmaril@16
  2713
				currentMapEditor()->setHeading (le->text());
insilmaril@16
  2714
#else
insilmaril@16
  2715
				p = currentMapEditor()->mapTo(this, currentMapEditor()->worldMatrix().map( p));
insilmaril@16
  2716
				lineedit->setGeometry(p.x(),p.y(),200,25);
insilmaril@16
  2717
				lineedit->setText(s);
insilmaril@16
  2718
				lineedit->setCursorPosition(1);
insilmaril@16
  2719
				lineedit->selectAll();
insilmaril@16
  2720
				lineedit->show();
insilmaril@16
  2721
				lineedit->grabKeyboard();
insilmaril@16
  2722
				lineedit->setFocus();
insilmaril@17
  2723
insilmaril@17
  2724
				editSel=currentMapEditor()->getSelectString();
insilmaril@16
  2725
#endif
insilmaril@16
  2726
insilmaril@16
  2727
			}
insilmaril@16
  2728
		}
insilmaril@16
  2729
	}
insilmaril@16
  2730
}
insilmaril@16
  2731
insilmaril@17
  2732
void Main::openVymLinks(const QStringList &vl)
insilmaril@0
  2733
{
insilmaril@17
  2734
	for (int j=0; j<vl.size(); j++)
insilmaril@0
  2735
	{
insilmaril@0
  2736
		// compare path with already loaded maps
insilmaril@0
  2737
		int index=-1;
insilmaril@0
  2738
		int i;
insilmaril@0
  2739
		MapEditor *me;
insilmaril@0
  2740
		for (i=0;i<=tabWidget->count() -1;i++)
insilmaril@0
  2741
		{
insilmaril@0
  2742
			me=(MapEditor*)tabWidget->page(i);
insilmaril@17
  2743
			if (vl.at(j)==me->getFilePath() )
insilmaril@0
  2744
			{
insilmaril@0
  2745
				index=i;
insilmaril@0
  2746
				break;
insilmaril@0
  2747
			}
insilmaril@0
  2748
		}	
insilmaril@0
  2749
		if (index<0)
insilmaril@0
  2750
		// Load map
insilmaril@0
  2751
		{
insilmaril@17
  2752
			if (!QFile(vl.at(j)).exists() )
insilmaril@0
  2753
				QMessageBox::critical( 0, tr( "Critical Error" ),
insilmaril@17
  2754
				   tr("Couldn't open map %1").arg(vl.at(j)));
insilmaril@0
  2755
			else
insilmaril@0
  2756
			{
insilmaril@17
  2757
				fileLoad (vl.at(j), NewMap);
insilmaril@0
  2758
				tabWidget->setCurrentPage (tabWidget->count()-1);	
insilmaril@0
  2759
			}
insilmaril@0
  2760
		} else
insilmaril@0
  2761
			// Go to tab containing the map
insilmaril@0
  2762
			tabWidget->setCurrentPage (index);	
insilmaril@0
  2763
	}
insilmaril@0
  2764
}
insilmaril@0
  2765
insilmaril@17
  2766
void Main::editOpenVymLink()
insilmaril@17
  2767
{
insilmaril@17
  2768
	if (currentMapEditor())
insilmaril@17
  2769
	{
insilmaril@17
  2770
		QStringList vl;
insilmaril@17
  2771
		vl.append(currentMapEditor()->getVymLink());	
insilmaril@17
  2772
		openVymLinks (vl);
insilmaril@17
  2773
	}
insilmaril@17
  2774
}
insilmaril@17
  2775
insilmaril@17
  2776
void Main::editOpenMultipleVymLinks()
insilmaril@17
  2777
{
insilmaril@17
  2778
	QString currentVymLink;
insilmaril@17
  2779
	if (currentMapEditor())
insilmaril@17
  2780
	{
insilmaril@17
  2781
		QStringList vl=currentMapEditor()->getVymLinks();
insilmaril@17
  2782
		openVymLinks (vl);
insilmaril@17
  2783
	}
insilmaril@17
  2784
}
insilmaril@17
  2785
insilmaril@0
  2786
void Main::editVymLink()
insilmaril@0
  2787
{
insilmaril@0
  2788
	if (currentMapEditor())
insilmaril@0
  2789
		currentMapEditor()->editVymLink();	
insilmaril@0
  2790
}
insilmaril@0
  2791
insilmaril@0
  2792
void Main::editDeleteVymLink()
insilmaril@0
  2793
{
insilmaril@0
  2794
	if (currentMapEditor())
insilmaril@0
  2795
		currentMapEditor()->deleteVymLink();	
insilmaril@0
  2796
}
insilmaril@0
  2797
insilmaril@2
  2798
void Main::editToggleHideExport()
insilmaril@2
  2799
{
insilmaril@2
  2800
	if (currentMapEditor())
insilmaril@2
  2801
		currentMapEditor()->toggleHideExport();	
insilmaril@2
  2802
}
insilmaril@2
  2803
insilmaril@0
  2804
void Main::editMapInfo()
insilmaril@0
  2805
{
insilmaril@0
  2806
	if (currentMapEditor())
insilmaril@0
  2807
		currentMapEditor()->editMapInfo();	
insilmaril@0
  2808
}
insilmaril@0
  2809
insilmaril@0
  2810
void Main::editMoveUp()
insilmaril@0
  2811
{
insilmaril@0
  2812
	if (currentMapEditor())
insilmaril@0
  2813
	    currentMapEditor()->moveBranchUp();
insilmaril@0
  2814
}
insilmaril@0
  2815
insilmaril@0
  2816
void Main::editMoveDown()
insilmaril@0
  2817
{
insilmaril@0
  2818
	if (currentMapEditor())
insilmaril@0
  2819
		currentMapEditor()->moveBranchDown();
insilmaril@0
  2820
}
insilmaril@0
  2821
insilmaril@0
  2822
void Main::editToggleScroll()
insilmaril@0
  2823
{
insilmaril@0
  2824
	if (currentMapEditor())
insilmaril@0
  2825
	{
insilmaril@0
  2826
		currentMapEditor()->toggleScroll();	
insilmaril@0
  2827
	}	
insilmaril@0
  2828
}
insilmaril@0
  2829
insilmaril@0
  2830
void Main::editUnScrollAll()
insilmaril@0
  2831
{
insilmaril@0
  2832
	if (currentMapEditor())
insilmaril@0
  2833
	{
insilmaril@0
  2834
		currentMapEditor()->unScrollAll();	
insilmaril@0
  2835
	}	
insilmaril@0
  2836
}
insilmaril@0
  2837
insilmaril@0
  2838
void Main::editNewBranch()
insilmaril@0
  2839
{
insilmaril@16
  2840
insilmaril@16
  2841
	if (!lineedit->isVisible() && currentMapEditor())
insilmaril@0
  2842
		currentMapEditor()->addNewBranch(0);
insilmaril@0
  2843
}
insilmaril@0
  2844
insilmaril@2
  2845
void Main::editNewBranchHere()
insilmaril@2
  2846
{
insilmaril@2
  2847
	if (currentMapEditor())
insilmaril@2
  2848
		currentMapEditor()->addNewBranchHere();
insilmaril@2
  2849
}
insilmaril@2
  2850
insilmaril@0
  2851
void Main::editNewBranchAbove()
insilmaril@0
  2852
{
insilmaril@0
  2853
	if (currentMapEditor())
insilmaril@0
  2854
		currentMapEditor()->addNewBranch(-1);
insilmaril@0
  2855
}
insilmaril@0
  2856
insilmaril@0
  2857
void Main::editNewBranchBelow()
insilmaril@0
  2858
{
insilmaril@0
  2859
	if (currentMapEditor())
insilmaril@0
  2860
		currentMapEditor()->addNewBranch(1);
insilmaril@0
  2861
}
insilmaril@0
  2862
insilmaril@0
  2863
void Main::editImportAdd()
insilmaril@0
  2864
{
insilmaril@0
  2865
	fileLoad (ImportAdd);
insilmaril@0
  2866
}
insilmaril@0
  2867
insilmaril@0
  2868
void Main::editImportReplace()
insilmaril@0
  2869
{
insilmaril@0
  2870
	fileLoad (ImportReplace);
insilmaril@0
  2871
}
insilmaril@0
  2872
insilmaril@0
  2873
void Main::editSaveBranch()
insilmaril@0
  2874
{
insilmaril@0
  2875
	fileSaveAs (PartOfMap);
insilmaril@0
  2876
}
insilmaril@0
  2877
insilmaril@2
  2878
void Main::editRemoveBranchKeepChilds()
insilmaril@2
  2879
{
insilmaril@2
  2880
	if (currentMapEditor())
insilmaril@2
  2881
		currentMapEditor()->removeBranchKeepChilds();
insilmaril@2
  2882
}
insilmaril@2
  2883
insilmaril@2
  2884
void Main::editRemoveChilds()
insilmaril@2
  2885
{
insilmaril@2
  2886
	if (currentMapEditor())
insilmaril@2
  2887
		currentMapEditor()->removeChilds();
insilmaril@2
  2888
}
insilmaril@2
  2889
insilmaril@0
  2890
void Main::editDeleteSelection()
insilmaril@0
  2891
{
insilmaril@2
  2892
	if (currentMapEditor() && actionSettingsUseDelKey->isOn())
insilmaril@0
  2893
		currentMapEditor()->deleteSelection();
insilmaril@0
  2894
}
insilmaril@0
  2895
insilmaril@0
  2896
void Main::editUpperBranch()
insilmaril@0
  2897
{
insilmaril@0
  2898
	if (currentMapEditor())
insilmaril@0
  2899
		currentMapEditor()->selectUpperBranch();
insilmaril@0
  2900
}
insilmaril@0
  2901
insilmaril@0
  2902
void Main::editLowerBranch()
insilmaril@0
  2903
{
insilmaril@0
  2904
	if (currentMapEditor())