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