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