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