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