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