mainwindow.cpp
author insilmaril
Wed, 16 Jan 2008 15:45:20 +0000
changeset 660 d0e047b8d412
parent 658 9e196213c003
child 663 827d334d55f1
permissions -rw-r--r--
Fixed missing MapCenter
insilmaril@0
     1
#include "mainwindow.h"
insilmaril@0
     2
insilmaril@366
     3
#include <QtGui>
insilmaril@390
     4
insilmaril@0
     5
#include <iostream>
insilmaril@611
     6
#include <typeinfo>
insilmaril@0
     7
insilmaril@205
     8
#include "aboutdialog.h"
insilmaril@421
     9
#include "branchpropwindow.h"
insilmaril@205
    10
#include "exportoofiledialog.h"
insilmaril@228
    11
#include "exports.h"
insilmaril@205
    12
#include "file.h"
insilmaril@0
    13
#include "flagrowobj.h"
insilmaril@377
    14
#include "historywindow.h"
insilmaril@205
    15
#include "imports.h"
insilmaril@0
    16
#include "mapeditor.h"
insilmaril@205
    17
#include "misc.h"
insilmaril@205
    18
#include "options.h"
insilmaril@0
    19
#include "process.h"
insilmaril@0
    20
#include "settings.h"
insilmaril@205
    21
#include "texteditor.h"
insilmaril@442
    22
#include "warningdialog.h"
insilmaril@0
    23
insilmaril@608
    24
#if defined(Q_OS_WIN32)
insilmaril@608
    25
// Define only this structure as opposed to
insilmaril@608
    26
// including full 'windows.h'. FindWindow
insilmaril@608
    27
// clashes with the one in Win32 API.
insilmaril@608
    28
typedef struct _PROCESS_INFORMATION
insilmaril@608
    29
{
insilmaril@608
    30
  long hProcess;
insilmaril@608
    31
  long hThread;
insilmaril@608
    32
  long dwProcessId;
insilmaril@608
    33
  long dwThreadId;
insilmaril@608
    34
} PROCESS_INFORMATION, *LPPROCESS_INFORMATION;
insilmaril@608
    35
#endif
insilmaril@608
    36
insilmaril@0
    37
extern TextEditor *textEditor;
insilmaril@0
    38
extern Main *mainWindow;
insilmaril@164
    39
extern QString tmpVymDir;
insilmaril@166
    40
extern QString clipboardDir;
insilmaril@491
    41
extern QString clipboardFile;
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@404
    46
extern QString vymName;
insilmaril@404
    47
extern QString vymVersion;
insilmaril@404
    48
extern QString vymBuildDate;
insilmaril@502
    49
extern bool debug;
insilmaril@0
    50
insilmaril@390
    51
QMenu* branchContextMenu;
insilmaril@390
    52
QMenu* branchAddContextMenu;
insilmaril@390
    53
QMenu* branchRemoveContextMenu;
insilmaril@390
    54
QMenu* branchLinksContextMenu;
insilmaril@390
    55
QMenu* branchXLinksContextMenuEdit;
insilmaril@390
    56
QMenu* branchXLinksContextMenuFollow;
insilmaril@390
    57
QMenu* floatimageContextMenu;
insilmaril@390
    58
QMenu* canvasContextMenu;
insilmaril@390
    59
QMenu* fileLastMapsMenu;
insilmaril@390
    60
QMenu* fileImportMenu;
insilmaril@390
    61
QMenu* fileExportMenu;
insilmaril@0
    62
insilmaril@0
    63
insilmaril@0
    64
extern Settings settings;
insilmaril@0
    65
extern Options options;
insilmaril@366
    66
extern ImageIO imageIO;
insilmaril@366
    67
insilmaril@269
    68
extern QDir vymBaseDir;
insilmaril@366
    69
extern QDir lastImageDir;
insilmaril@366
    70
extern QDir lastFileDir;
insilmaril@625
    71
#if defined(Q_OS_WIN32)
insilmaril@625
    72
extern QDir vymInstallDir;
insilmaril@625
    73
#endif
insilmaril@269
    74
extern QString iconPath;
insilmaril@269
    75
extern QString flagsPath;
insilmaril@0
    76
insilmaril@366
    77
Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
insilmaril@0
    78
    QMainWindow(parent,name,f)
insilmaril@0
    79
{
insilmaril@0
    80
	mainWindow=this;
insilmaril@0
    81
insilmaril@0
    82
	setCaption ("VYM - View Your Mind");
insilmaril@0
    83
insilmaril@0
    84
	// Load window settings
insilmaril@625
    85
#if defined(Q_OS_WIN32)
insilmaril@625
    86
    if (settings.value("/mainwindow/geometry/maximized", false).toBool())
insilmaril@625
    87
    {
anng888@632
    88
        setWindowState(Qt::WindowMaximized);
insilmaril@625
    89
    }
insilmaril@625
    90
    else
insilmaril@625
    91
#endif
insilmaril@625
    92
    {
insilmaril@625
    93
        resize (settings.value("/mainwindow/geometry/size", QSize (800,600)).toSize());
insilmaril@625
    94
        move   (settings.value("/mainwindow/geometry/pos",  QPoint(300,100)).toPoint());
insilmaril@625
    95
    }
insilmaril@0
    96
insilmaril@394
    97
	// Sometimes we may need to remember old selections
insilmaril@394
    98
	prevSelection="";
insilmaril@394
    99
insilmaril@395
   100
	// Default color
insilmaril@395
   101
	currentColor=Qt::black;
insilmaril@395
   102
insilmaril@164
   103
	// Create unique temporary directory
insilmaril@366
   104
	bool ok;
insilmaril@608
   105
	tmpVymDir=makeTmpDir (ok,"vym");
insilmaril@366
   106
	if (!ok)
insilmaril@366
   107
	{
insilmaril@366
   108
		qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
insilmaril@366
   109
		exit (1);
insilmaril@366
   110
	}
insilmaril@502
   111
	if (debug) qDebug (QString("vym tmpDir=%1").arg(tmpVymDir) );
insilmaril@164
   112
insilmaril@166
   113
	// Create direcctory for clipboard
insilmaril@166
   114
	clipboardDir=tmpVymDir+"/clipboard";
insilmaril@502
   115
	clipboardFile="map.xml";
insilmaril@166
   116
	QDir d(clipboardDir);
insilmaril@166
   117
	d.mkdir (clipboardDir,true);
insilmaril@166
   118
	makeSubDirs (clipboardDir);
insilmaril@166
   119
	clipboardEmpty=true;
insilmaril@164
   120
insilmaril@266
   121
	procBrowser=NULL;
insilmaril@266
   122
insilmaril@486
   123
	// Satellite windows //////////////////////////////////////////
insilmaril@486
   124
insilmaril@486
   125
	// history window
insilmaril@404
   126
	historyWindow=new HistoryWindow();
insilmaril@486
   127
	connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
insilmaril@486
   128
insilmaril@486
   129
	// properties window
insilmaril@421
   130
	branchPropertyWindow = new BranchPropertyWindow();
insilmaril@486
   131
	connect (branchPropertyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
insilmaril@486
   132
insilmaril@486
   133
	// Connect TextEditor, so that we can update flags if text changes
insilmaril@486
   134
	connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
insilmaril@486
   135
	connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
insilmaril@486
   136
insilmaril@486
   137
	// Connect HistoryWindow, so that we can update flags
insilmaril@486
   138
	connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
insilmaril@473
   139
insilmaril@421
   140
insilmaril@432
   141
	// Initialize script editor
insilmaril@432
   142
	scriptEditor = new SimpleScriptEditor();
insilmaril@432
   143
	scriptEditor->move (50,50);
insilmaril@432
   144
insilmaril@432
   145
	connect( scriptEditor, SIGNAL( runScript ( QString ) ), 
insilmaril@432
   146
		this, SLOT( runScript( QString ) ) );
insilmaril@432
   147
	
insilmaril@486
   148
insilmaril@486
   149
	// Initialize Find window
insilmaril@486
   150
	findWindow=new FindWindow(NULL);
insilmaril@486
   151
	findWindow->move (x(),y()+70);
insilmaril@486
   152
	connect (findWindow, SIGNAL( findButton(QString) ), 
insilmaril@486
   153
		this, SLOT(editFind(QString) ) );	
insilmaril@486
   154
	connect (findWindow, SIGNAL( somethingChanged() ), 
insilmaril@486
   155
		this, SLOT(editFindChanged() ) );	
insilmaril@486
   156
insilmaril@0
   157
	// Initialize some settings, which are platform dependant
insilmaril@0
   158
	QString p,s;
insilmaril@0
   159
insilmaril@0
   160
		// application to open URLs
insilmaril@366
   161
		p="/mainwindow/readerURL";
insilmaril@0
   162
		#if defined(Q_OS_LINUX)
insilmaril@608
   163
			s=settings.value (p,"xdg-open").toString();
insilmaril@0
   164
		#else
insilmaril@0
   165
			#if defined(Q_OS_MACX)
insilmaril@366
   166
				s=settings.value (p,"/usr/bin/open").toString();
insilmaril@608
   167
insilmaril@608
   168
            #else
insilmaril@608
   169
                #if defined(Q_OS_WIN32)
insilmaril@608
   170
                    // Assume that system has been set up so that
insilmaril@608
   171
                    // Explorer automagically opens up the URL
insilmaril@608
   172
                    // in the user's preferred browser.
insilmaril@608
   173
                    s=settings.value (p,"explorer").toString();
insilmaril@608
   174
                #else
insilmaril@608
   175
					s=settings.value (p,"mozilla").toString();
insilmaril@608
   176
				#endif
insilmaril@0
   177
			#endif
insilmaril@0
   178
		#endif
insilmaril@366
   179
		settings.setValue( p,s);
insilmaril@0
   180
insilmaril@0
   181
		// application to open PDFs
insilmaril@366
   182
		p="/mainwindow/readerPDF";
insilmaril@0
   183
		#if defined(Q_OS_LINUX)
insilmaril@608
   184
			s=settings.value (p,"xdg-open").toString();
insilmaril@0
   185
		#else
insilmaril@0
   186
			#if defined(Q_OS_MACX)
insilmaril@366
   187
				s=settings.value (p,"/usr/bin/open").toString();
insilmaril@625
   188
            #elif defined(Q_OS_WIN32)
insilmaril@625
   189
                s=settings.value (p,"acrord32").toString();
insilmaril@0
   190
			#else
insilmaril@366
   191
				s=settings.value (p,"acroread").toString();
insilmaril@0
   192
			#endif
insilmaril@0
   193
		#endif
insilmaril@366
   194
		settings.setValue( p,s);
insilmaril@0
   195
insilmaril@600
   196
	// width of xLinksMenu
insilmaril@600
   197
	xLinkMenuWidth=60;
insilmaril@0
   198
	
insilmaril@0
   199
	// Create tab widget which holds the maps
insilmaril@0
   200
	tabWidget= new QTabWidget (this);
insilmaril@0
   201
	connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ), 
insilmaril@0
   202
		this, SLOT( editorChanged( QWidget * ) ) );
insilmaril@0
   203
insilmaril@366
   204
	lineedit=new QLineEdit (this);
insilmaril@366
   205
	lineedit->hide();
insilmaril@366
   206
insilmaril@0
   207
	setCentralWidget(tabWidget);	
insilmaril@0
   208
insilmaril@0
   209
    setupFileActions();
insilmaril@0
   210
    setupEditActions();
insilmaril@0
   211
    setupFormatActions();
insilmaril@0
   212
    setupViewActions();
insilmaril@89
   213
    setupModeActions();
insilmaril@0
   214
	setupFlagActions();
insilmaril@528
   215
    setupNetworkActions();
insilmaril@0
   216
    setupSettingsActions();
insilmaril@0
   217
	setupContextMenus();
insilmaril@445
   218
	setupMacros();
insilmaril@366
   219
    if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
insilmaril@0
   220
    setupHelpActions();
insilmaril@0
   221
    
insilmaril@0
   222
    statusBar();
insilmaril@0
   223
insilmaril@366
   224
	restoreState (settings.value("/mainwindow/state",0).toByteArray());
insilmaril@0
   225
insilmaril@0
   226
	updateGeometry();
insilmaril@0
   227
}
insilmaril@0
   228
insilmaril@0
   229
Main::~Main()
insilmaril@0
   230
{
insilmaril@0
   231
	// Save Settings
insilmaril@625
   232
#if defined(Q_OS_WIN32)
insilmaril@625
   233
    settings.setValue ("/mainwindow/geometry/maximized", isMaximized());
insilmaril@625
   234
#endif
insilmaril@625
   235
	settings.setValue ("/mainwindow/geometry/size", size());
insilmaril@625
   236
	settings.setValue ("/mainwindow/geometry/pos", pos());
insilmaril@366
   237
	settings.setValue ("/mainwindow/state",saveState(0));
insilmaril@366
   238
insilmaril@408
   239
	settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
insilmaril@408
   240
	settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
insilmaril@404
   241
	settings.setValue( "/version/version", vymVersion );
insilmaril@404
   242
	settings.setValue( "/version/builddate", vymBuildDate );
insilmaril@366
   243
insilmaril@491
   244
	settings.setValue( "/mapeditor/autosave/use",actionSettingsAutosaveToggle->isOn() );
insilmaril@537
   245
	settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isOn() );
insilmaril@625
   246
	settings.setValue( "/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
insilmaril@390
   247
	settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
insilmaril@537
   248
	settings.setValue( "/mapeditor/editmode/autoEditNewBranch",actionSettingsAutoEditNewBranch->isOn() );
insilmaril@366
   249
	settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
insilmaril@366
   250
	settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
insilmaril@366
   251
	settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
insilmaril@0
   252
insilmaril@473
   253
	//TODO save scriptEditor settings
insilmaril@432
   254
insilmaril@404
   255
	// call the destructors
insilmaril@442
   256
	delete textEditor;
insilmaril@404
   257
	delete historyWindow;
insilmaril@473
   258
	delete branchPropertyWindow;
insilmaril@164
   259
insilmaril@164
   260
	// Remove temporary directory
insilmaril@164
   261
	removeDir (QDir(tmpVymDir));
insilmaril@0
   262
}
insilmaril@0
   263
insilmaril@0
   264
void Main::loadCmdLine()
insilmaril@0
   265
{
insilmaril@0
   266
	/* TODO draw some kind of splashscreen while loading...
insilmaril@0
   267
	if (qApp->argc()>1)
insilmaril@0
   268
	{
insilmaril@0
   269
	}
insilmaril@0
   270
	*/
insilmaril@0
   271
	
insilmaril@0
   272
	QStringList flist=options.getFileList();
insilmaril@0
   273
	QStringList::Iterator it=flist.begin();
insilmaril@0
   274
insilmaril@0
   275
	while (it !=flist.end() )
insilmaril@0
   276
	{
insilmaril@0
   277
		fileLoad (*it, NewMap);
insilmaril@0
   278
		*it++;
insilmaril@0
   279
	}	
insilmaril@0
   280
}
insilmaril@0
   281
insilmaril@0
   282
insilmaril@0
   283
void Main::statusMessage(const QString &s)
insilmaril@0
   284
{
insilmaril@502
   285
	statusBar()->message( s);
insilmaril@0
   286
}
insilmaril@0
   287
insilmaril@0
   288
void Main::closeEvent (QCloseEvent* )
insilmaril@0
   289
{
insilmaril@0
   290
	fileExitVYM();
insilmaril@0
   291
}
insilmaril@0
   292
insilmaril@0
   293
// File Actions
insilmaril@0
   294
void Main::setupFileActions()
insilmaril@0
   295
{
insilmaril@366
   296
	QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
insilmaril@366
   297
    QToolBar *tb = addToolBar( tr ("&Map") );
insilmaril@366
   298
	tb->setObjectName ("mapTB");
insilmaril@0
   299
insilmaril@0
   300
    QAction *a;
insilmaril@491
   301
    a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this);
insilmaril@395
   302
	a->setStatusTip ( tr( "New map","Status tip File menu" ) );
insilmaril@442
   303
	a->setShortcut ( Qt::CTRL + Qt::Key_N );		//New map
insilmaril@0
   304
    a->addTo( tb );
insilmaril@366
   305
	fileMenu->addAction (a);
insilmaril@366
   306
    connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
insilmaril@0
   307
	
insilmaril@494
   308
    a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this);
insilmaril@491
   309
	a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) );
insilmaril@491
   310
	a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N );		//New map
insilmaril@491
   311
	fileMenu->addAction (a);
insilmaril@491
   312
    connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) );
insilmaril@491
   313
	
insilmaril@395
   314
    a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
insilmaril@395
   315
	a->setStatusTip (tr( "Open","Status tip File menu" ) );
insilmaril@442
   316
	a->setShortcut ( Qt::CTRL + Qt::Key_O );		//Open map
insilmaril@0
   317
    a->addTo( tb );
insilmaril@366
   318
	fileMenu->addAction (a);
insilmaril@366
   319
    connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
insilmaril@0
   320
	
insilmaril@395
   321
	fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
insilmaril@366
   322
	fileMenu->addSeparator();
insilmaril@0
   323
	
insilmaril@395
   324
    a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
insilmaril@395
   325
	a->setStatusTip ( tr( "Save","Status tip file menu" ));
insilmaril@442
   326
	a->setShortcut (Qt::CTRL + Qt::Key_S );			//Save map
insilmaril@0
   327
    a->addTo( tb );
insilmaril@366
   328
	fileMenu->addAction (a);
insilmaril@366
   329
    connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
insilmaril@0
   330
	actionFileSave=a;
insilmaril@0
   331
	
insilmaril@395
   332
    a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
insilmaril@395
   333
	a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
insilmaril@366
   334
	fileMenu->addAction (a);
insilmaril@366
   335
    connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
insilmaril@366
   336
insilmaril@366
   337
	fileMenu->addSeparator();
insilmaril@366
   338
insilmaril@395
   339
	fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
insilmaril@366
   340
insilmaril@366
   341
	a = new QAction(tr("KDE Bookmarks"), this);
insilmaril@395
   342
	a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE bookmarks")));
insilmaril@366
   343
	a->addTo (fileImportMenu);
insilmaril@366
   344
	connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) );
insilmaril@366
   345
insilmaril@366
   346
    if (settings.value( "/mainwindow/showTestMenu",false).toBool()) 
insilmaril@331
   347
	{
insilmaril@395
   348
		a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
insilmaril@395
   349
		a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
insilmaril@366
   350
		a->addTo (fileImportMenu);
insilmaril@366
   351
		connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
insilmaril@331
   352
	}	
insilmaril@314
   353
insilmaril@571
   354
	a = new QAction("Freemind...",this);
insilmaril@571
   355
	a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Freemind")  );
insilmaril@571
   356
	fileImportMenu->addAction (a);
insilmaril@571
   357
	connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFreemind() ) );
insilmaril@571
   358
insilmaril@366
   359
	a = new QAction("Mind Manager...",this);
insilmaril@395
   360
	a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager")  );
insilmaril@366
   361
	fileImportMenu->addAction (a);
insilmaril@366
   362
	connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
insilmaril@366
   363
insilmaril@395
   364
    a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
insilmaril@395
   365
	a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
insilmaril@366
   366
	fileImportMenu->addAction (a);
insilmaril@366
   367
    connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
insilmaril@366
   368
insilmaril@395
   369
	fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
insilmaril@395
   370
insilmaril@395
   371
	a = new QAction( tr("Image%1","File export menu").arg("..."), this);
insilmaril@395
   372
	a->setStatusTip( tr( "Export map as image","status tip file menu" ));
insilmaril@366
   373
	connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
insilmaril@366
   374
	fileExportMenu->addAction (a);
insilmaril@366
   375
insilmaril@395
   376
	a = new QAction( "Open Office...", this);
insilmaril@395
   377
	a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
insilmaril@366
   378
	connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
insilmaril@366
   379
	fileExportMenu->addAction (a);
insilmaril@366
   380
insilmaril@366
   381
	a = new QAction(  "Webpage (XHTML)...",this );
insilmaril@442
   382
	a->setShortcut (Qt::ALT + Qt::Key_X);			//Export XHTML
insilmaril@395
   383
	a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
insilmaril@366
   384
    connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
insilmaril@366
   385
	fileExportMenu->addAction (a);
insilmaril@366
   386
insilmaril@366
   387
    a = new QAction( "Text (ASCII)...", this);
insilmaril@395
   388
	a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
insilmaril@366
   389
    connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
insilmaril@366
   390
	fileExportMenu->addAction (a);
insilmaril@366
   391
insilmaril@497
   392
    a = new QAction( "Spreadsheet (CSV)...", this);
insilmaril@497
   393
	a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
insilmaril@497
   394
    connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
insilmaril@497
   395
	fileExportMenu->addAction (a);
insilmaril@497
   396
insilmaril@395
   397
	a = new QAction( tr("KDE Bookmarks","File menu"), this);
insilmaril@395
   398
	a->setStatusTip( tr( "Export as %1").arg(tr("KDE Bookmarks" )));
insilmaril@366
   399
	connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
insilmaril@366
   400
	fileExportMenu->addAction (a);
insilmaril@366
   401
insilmaril@366
   402
    a = new QAction( "Taskjuggler...", this );
insilmaril@395
   403
    a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
insilmaril@366
   404
    connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
insilmaril@366
   405
	fileExportMenu->addAction (a);
insilmaril@366
   406
insilmaril@366
   407
    a = new QAction( "LaTeX...", this);
insilmaril@395
   408
    a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
insilmaril@366
   409
    connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
insilmaril@366
   410
	fileExportMenu->addAction (a);
insilmaril@366
   411
insilmaril@366
   412
	a = new QAction( "XML..." , this );
insilmaril@395
   413
	a->setStatusTip (tr( "Export as %1").arg("XML"));
insilmaril@366
   414
    connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
insilmaril@366
   415
	fileExportMenu->addAction (a);
insilmaril@366
   416
insilmaril@366
   417
	fileMenu->addSeparator();
insilmaril@366
   418
insilmaril@366
   419
    a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
insilmaril@395
   420
	a->setStatusTip ( tr( "Print" ,"File menu") );
insilmaril@442
   421
	a->setShortcut (Qt::CTRL + Qt::Key_P );			//Print map
insilmaril@0
   422
    a->addTo( tb );
insilmaril@366
   423
	fileMenu->addAction (a);
insilmaril@366
   424
    connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
insilmaril@0
   425
	actionFilePrint=a;
insilmaril@0
   426
insilmaril@395
   427
    a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
insilmaril@366
   428
	a->setStatusTip (tr( "Close Map" ) );
insilmaril@473
   429
	a->setShortcut (Qt::CTRL + Qt::Key_W );			//Close map
insilmaril@366
   430
	fileMenu->addAction (a);
insilmaril@366
   431
    connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
insilmaril@366
   432
insilmaril@404
   433
    a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
insilmaril@404
   434
	a->setStatusTip ( tr( "Exit")+" "+vymName );
insilmaril@442
   435
	a->setShortcut (Qt::CTRL + Qt::Key_Q );			//Quit vym
insilmaril@366
   436
	fileMenu->addAction (a);
insilmaril@366
   437
    connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
insilmaril@0
   438
}
insilmaril@0
   439
insilmaril@0
   440
insilmaril@0
   441
//Edit Actions
insilmaril@0
   442
void Main::setupEditActions()
insilmaril@0
   443
{
insilmaril@395
   444
    QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
insilmaril@0
   445
    tb->setLabel( "Edit Actions" );
insilmaril@366
   446
	tb->setObjectName ("actionsTB");
insilmaril@395
   447
    QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
insilmaril@0
   448
insilmaril@0
   449
    QAction *a;
insilmaril@102
   450
	QAction *alt;
insilmaril@395
   451
    a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
insilmaril@366
   452
    connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
insilmaril@366
   453
	a->setStatusTip (tr( "Undo" ) );
insilmaril@442
   454
	a->setShortcut ( Qt::CTRL + Qt::Key_Z );		//Undo last action
insilmaril@0
   455
	a->setEnabled (false);
insilmaril@366
   456
    tb->addAction (a);
insilmaril@366
   457
	editMenu->addAction (a);
insilmaril@0
   458
	actionEditUndo=a;
insilmaril@163
   459
    
insilmaril@395
   460
	a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this); 
insilmaril@366
   461
	a->setStatusTip (tr( "Redo" ));
insilmaril@442
   462
	a->setShortcut (Qt::CTRL + Qt::Key_Y );			//Redo last action
insilmaril@366
   463
    tb->addAction (a);
insilmaril@366
   464
	editMenu->addAction (a);
insilmaril@366
   465
	connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
insilmaril@366
   466
	actionEditRedo=a;
insilmaril@163
   467
   
insilmaril@366
   468
	editMenu->addSeparator();
insilmaril@395
   469
    a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
insilmaril@366
   470
	a->setStatusTip ( tr( "Copy" ) );
insilmaril@442
   471
	a->setShortcut (Qt::CTRL + Qt::Key_C );			//Copy
insilmaril@0
   472
	a->setEnabled (false);
insilmaril@366
   473
    tb->addAction (a);
insilmaril@366
   474
	editMenu->addAction (a);
insilmaril@366
   475
    connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
insilmaril@0
   476
	actionEditCopy=a;
insilmaril@366
   477
	
insilmaril@395
   478
    a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
insilmaril@366
   479
	a->setStatusTip ( tr( "Cut" ) );
insilmaril@442
   480
	a->setShortcut (Qt::CTRL + Qt::Key_X );			//Cut
insilmaril@0
   481
	a->setEnabled (false);
insilmaril@366
   482
    tb->addAction (a);
insilmaril@366
   483
	editMenu->addAction (a);
insilmaril@0
   484
	actionEditCut=a;
insilmaril@366
   485
    connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
insilmaril@366
   486
	
insilmaril@395
   487
    a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
insilmaril@366
   488
    connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
insilmaril@366
   489
	a->setStatusTip ( tr( "Paste" ) );
insilmaril@442
   490
	a->setShortcut ( Qt::CTRL + Qt::Key_V );		//Paste
insilmaril@0
   491
	a->setEnabled (false);
insilmaril@366
   492
    tb->addAction (a);
insilmaril@366
   493
	editMenu->addAction (a);
insilmaril@0
   494
	actionEditPaste=a;
insilmaril@98
   495
insilmaril@351
   496
    // Shortcuts to modify heading:
insilmaril@395
   497
    a = new QAction(tr( "Edit heading","Edit menu" ),this);
insilmaril@366
   498
	a->setStatusTip ( tr( "edit Heading" ));
insilmaril@442
   499
	a->setShortcut ( Qt::Key_Enter);				//Edit heading
insilmaril@366
   500
//	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   501
	addAction (a);
insilmaril@366
   502
    connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
insilmaril@351
   503
	actionListBranches.append(a);
insilmaril@395
   504
    a = new QAction( tr( "Edit heading","Edit menu" ), this);
insilmaril@366
   505
	a->setStatusTip (tr( "edit Heading" ));
insilmaril@442
   506
	a->setShortcut (Qt::Key_Return );				//Edit heading
insilmaril@366
   507
	//a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   508
	addAction (a);
insilmaril@366
   509
    connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
insilmaril@351
   510
	actionListBranches.append(a);
insilmaril@366
   511
	editMenu->addAction (a);
insilmaril@351
   512
	actionEditHeading=a;
insilmaril@395
   513
    a = new QAction( tr( "Edit heading","Edit menu" ), this);
insilmaril@366
   514
	a->setStatusTip (tr( "edit Heading" ));
insilmaril@445
   515
	//a->setShortcut ( Qt::Key_F2 );					//Edit heading
insilmaril@366
   516
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   517
	addAction (a);
insilmaril@366
   518
    connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
insilmaril@351
   519
	actionListBranches.append(a);
insilmaril@351
   520
    
insilmaril@351
   521
    // Shortcut to delete selection
insilmaril@395
   522
    a = new QAction( tr( "Delete Selection","Edit menu" ),this);
insilmaril@366
   523
	a->setStatusTip (tr( "Delete Selection" ));
insilmaril@442
   524
	a->setShortcut ( Qt::Key_Delete);				//Delete selection
insilmaril@366
   525
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   526
	addAction (a);
insilmaril@366
   527
    connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
insilmaril@351
   528
	actionEditDelete=a;
insilmaril@351
   529
    
insilmaril@351
   530
    // Shortcut to add branch
insilmaril@395
   531
	alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
insilmaril@366
   532
	alt->setStatusTip ( tr( "Add a branch as child of selection" ));
insilmaril@442
   533
	alt->setShortcut (Qt::Key_A);					//Add branch
insilmaril@366
   534
	alt->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   535
	addAction (alt);
insilmaril@366
   536
	connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
insilmaril@395
   537
	a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
insilmaril@366
   538
	a->setStatusTip ( tr( "Add a branch as child of selection" ));
insilmaril@442
   539
	a->setShortcut (Qt::Key_Insert);				//Add branch
insilmaril@366
   540
	connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
insilmaril@351
   541
	actionListBranches.append(a);
insilmaril@351
   542
	#if defined (Q_OS_MACX)
insilmaril@366
   543
		// In OSX show different shortcut in menues, the keys work indepently always			
insilmaril@351
   544
		actionEditAddBranch=alt;
insilmaril@351
   545
	#else	
insilmaril@351
   546
		actionEditAddBranch=a;
insilmaril@351
   547
	#endif	
insilmaril@366
   548
	editMenu->addAction (actionEditAddBranch);
insilmaril@366
   549
	tb->addAction (actionEditAddBranch);
insilmaril@366
   550
insilmaril@351
   551
insilmaril@351
   552
    // Add branch by inserting it at selection
insilmaril@395
   553
	a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
insilmaril@366
   554
	a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
insilmaril@442
   555
	a->setShortcut (Qt::ALT + Qt::Key_Insert );		//Insert branch
insilmaril@366
   556
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   557
	addAction (a);
insilmaril@394
   558
    connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
insilmaril@351
   559
	a->setEnabled (false);
insilmaril@351
   560
	actionListBranches.append(a);
insilmaril@394
   561
	actionEditAddBranchBefore=a;
insilmaril@395
   562
	a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
insilmaril@366
   563
	a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
insilmaril@442
   564
	a->setShortcut ( Qt::ALT + Qt::Key_A );			//Insert branch
insilmaril@366
   565
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   566
	addAction (a);
insilmaril@394
   567
    connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
insilmaril@351
   568
	actionListBranches.append(a);
insilmaril@351
   569
insilmaril@351
   570
	// Add branch above
insilmaril@395
   571
    a = new QAction(tr( "Add branch above","Edit menu" ), this);
insilmaril@366
   572
	a->setStatusTip ( tr( "Add a branch above selection" ));
insilmaril@442
   573
	a->setShortcut (Qt::SHIFT+Qt::Key_Insert );		//Add branch above
insilmaril@366
   574
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   575
	addAction (a);
insilmaril@366
   576
    connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
insilmaril@351
   577
	a->setEnabled (false);
insilmaril@351
   578
	actionListBranches.append(a);
insilmaril@351
   579
	actionEditAddBranchAbove=a;
insilmaril@395
   580
    a = new QAction(tr( "Add branch above","Edit menu" ), this);
insilmaril@366
   581
	a->setStatusTip ( tr( "Add a branch above selection" ));
insilmaril@442
   582
	a->setShortcut (Qt::SHIFT+Qt::Key_A );			//Add branch above
insilmaril@366
   583
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   584
	addAction (a);
insilmaril@366
   585
    connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
insilmaril@351
   586
	actionListBranches.append(a);
insilmaril@351
   587
insilmaril@351
   588
	// Add branch below 
insilmaril@395
   589
    a = new QAction(tr( "Add branch below","Edit menu" ), this);
insilmaril@366
   590
	a->setStatusTip ( tr( "Add a branch below selection" ));
insilmaril@442
   591
	a->setShortcut (Qt::CTRL +Qt::Key_Insert );		//Add branch below
insilmaril@366
   592
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   593
	addAction (a);
insilmaril@366
   594
    connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
insilmaril@351
   595
	a->setEnabled (false);
insilmaril@351
   596
	actionListBranches.append(a);
insilmaril@351
   597
	actionEditAddBranchBelow=a;
insilmaril@395
   598
    a = new QAction(tr( "Add branch below","Edit menu" ), this);
insilmaril@366
   599
	a->setStatusTip ( tr( "Add a branch below selection" ));
insilmaril@442
   600
	a->setShortcut (Qt::CTRL +Qt::Key_A );			// Add branch below
insilmaril@366
   601
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   602
	addAction (a);
insilmaril@366
   603
    connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
insilmaril@351
   604
	actionListBranches.append(a);
insilmaril@351
   605
insilmaril@395
   606
    a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
insilmaril@366
   607
	a->setStatusTip ( tr( "Move branch up" ) );
insilmaril@442
   608
	a->setShortcut (Qt::Key_PageUp );				// Move branch up
insilmaril@0
   609
	a->setEnabled (false);
insilmaril@366
   610
    tb->addAction (a);
insilmaril@366
   611
	editMenu->addAction (a);
insilmaril@366
   612
    connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
insilmaril@0
   613
	actionEditMoveUp=a;
insilmaril@98
   614
insilmaril@395
   615
    a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
insilmaril@366
   616
    connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
insilmaril@366
   617
	a->setStatusTip (tr( "Move branch down" ) );
insilmaril@442
   618
	a->setShortcut ( Qt::Key_PageDown );			// Move branch down
insilmaril@0
   619
	a->setEnabled (false);
insilmaril@366
   620
    tb->addAction (a);
insilmaril@366
   621
	editMenu->addAction (a);
insilmaril@0
   622
	actionEditMoveDown=a;
insilmaril@98
   623
	
insilmaril@608
   624
	a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this );
insilmaril@608
   625
	connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) );
insilmaril@608
   626
	a->setEnabled (true);
insilmaril@608
   627
	a->addTo( tb );
insilmaril@613
   628
	editMenu->addAction (a);
insilmaril@608
   629
	actionEditSortChildren=a;
insilmaril@0
   630
insilmaril@395
   631
	a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this);
insilmaril@366
   632
	a->setShortcut ( Qt::Key_ScrollLock );
insilmaril@366
   633
	a->setStatusTip (tr( "Scroll branch" ) );
insilmaril@366
   634
    connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
insilmaril@375
   635
insilmaril@395
   636
	alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
insilmaril@442
   637
	alt->setShortcut ( Qt::Key_S );					// Scroll branch
insilmaril@366
   638
	alt->setStatusTip (tr( "Scroll branch" )); 
insilmaril@366
   639
    connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
insilmaril@102
   640
	#if defined(Q_OS_MACX)
insilmaril@102
   641
		actionEditToggleScroll=alt;
insilmaril@102
   642
	#else	
insilmaril@102
   643
		actionEditToggleScroll=a;
insilmaril@102
   644
	#endif	
insilmaril@102
   645
	actionEditToggleScroll->setEnabled (false);
insilmaril@250
   646
	actionEditToggleScroll->setToggleAction(true);
insilmaril@366
   647
    tb->addAction (actionEditToggleScroll);
insilmaril@366
   648
    editMenu->addAction ( actionEditToggleScroll);
insilmaril@366
   649
	editMenu->addAction (actionEditToggleScroll);
insilmaril@375
   650
	addAction (a);
insilmaril@375
   651
	addAction (alt);
insilmaril@102
   652
	actionListBranches.append(actionEditToggleScroll);
insilmaril@0
   653
	
insilmaril@473
   654
    a = new QAction( tr( "Unscroll childs","Edit menu" ), this);
insilmaril@473
   655
	a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
insilmaril@366
   656
	editMenu->addAction (a);
insilmaril@473
   657
    connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChilds() ) );
insilmaril@0
   658
	
insilmaril@366
   659
	editMenu->addSeparator();
insilmaril@366
   660
insilmaril@395
   661
	a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
insilmaril@366
   662
	a->setStatusTip (tr( "Find" ) );
insilmaril@442
   663
	a->setShortcut (Qt::CTRL + Qt::Key_F );				//Find
insilmaril@366
   664
	editMenu->addAction (a);
insilmaril@366
   665
    connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
insilmaril@0
   666
    
insilmaril@366
   667
	editMenu->addSeparator();
insilmaril@366
   668
insilmaril@395
   669
	a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
insilmaril@366
   670
	a->setShortcut (Qt::CTRL + Qt::Key_U );
insilmaril@366
   671
	a->setShortcut (tr( "Open URL" ));
insilmaril@366
   672
    tb->addAction (a);
insilmaril@366
   673
	addAction(a);
insilmaril@366
   674
    connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
insilmaril@0
   675
	actionEditOpenURL=a;
insilmaril@0
   676
insilmaril@395
   677
	a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
insilmaril@366
   678
	a->setStatusTip (tr( "Open URL in new tab" ));
insilmaril@528
   679
	//a->setShortcut (Qt::CTRL+Qt::Key_U );
insilmaril@366
   680
	addAction(a);
insilmaril@366
   681
    connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
insilmaril@266
   682
	actionEditOpenURLTab=a;
insilmaril@266
   683
insilmaril@395
   684
	a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
insilmaril@366
   685
	a->setStatusTip (tr( "Open all URLs in subtree" ));
insilmaril@366
   686
	addAction(a);
insilmaril@366
   687
	actionListBranches.append(a);
insilmaril@366
   688
    connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
insilmaril@366
   689
	actionEditOpenMultipleURLTabs=a;
insilmaril@366
   690
insilmaril@395
   691
	a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
insilmaril@366
   692
	a->setStatusTip ( tr( "Edit URL" ) );
insilmaril@528
   693
	a->setShortcut ( Qt::Key_U );
insilmaril@366
   694
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   695
	actionListBranches.append(a);
insilmaril@366
   696
	addAction(a);
insilmaril@366
   697
    connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
insilmaril@366
   698
	actionEditURL=a;
insilmaril@366
   699
	
insilmaril@528
   700
	a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
insilmaril@528
   701
	a->setStatusTip ( tr( "Edit local URL" ) );
insilmaril@528
   702
	a->setShortcut (Qt::SHIFT +  Qt::Key_U );
insilmaril@528
   703
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@528
   704
	actionListBranches.append(a);
insilmaril@528
   705
	addAction(a);
insilmaril@528
   706
    connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
insilmaril@600
   707
	actionEditLocalURL=a;
insilmaril@528
   708
	
insilmaril@395
   709
	a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
insilmaril@366
   710
	a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
insilmaril@0
   711
	a->setEnabled (false);
insilmaril@98
   712
	actionListBranches.append(a);
insilmaril@366
   713
    connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
insilmaril@366
   714
	actionEditHeading2URL=a;
insilmaril@366
   715
    
insilmaril@486
   716
	a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
insilmaril@486
   717
	a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
insilmaril@0
   718
	a->setEnabled (false);
insilmaril@98
   719
	actionListBranches.append(a);
insilmaril@366
   720
    connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
insilmaril@366
   721
	actionEditBugzilla2URL=a;
insilmaril@0
   722
    
insilmaril@486
   723
	a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
insilmaril@486
   724
	a->setStatusTip ( tr( "Create URL to Novell FATE" ));
insilmaril@0
   725
	a->setEnabled (false);
insilmaril@98
   726
	actionListBranches.append(a);
insilmaril@366
   727
    connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
insilmaril@366
   728
	actionEditFATE2URL=a;
insilmaril@366
   729
	
insilmaril@395
   730
    a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
insilmaril@366
   731
	a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
insilmaril@366
   732
    tb->addAction (a);
insilmaril@366
   733
	a->setEnabled (false);
insilmaril@366
   734
    connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
insilmaril@366
   735
	actionEditOpenVymLink=a;
insilmaril@366
   736
	
insilmaril@395
   737
    a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
insilmaril@366
   738
	a->setStatusTip ( tr( "Open all vym links in subtree" ));
insilmaril@175
   739
	a->setEnabled (false);
insilmaril@175
   740
	actionListBranches.append(a);
insilmaril@366
   741
    connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
insilmaril@366
   742
	actionEditOpenMultipleVymLinks=a;
insilmaril@0
   743
	
insilmaril@366
   744
insilmaril@395
   745
    a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
insilmaril@0
   746
	a->setEnabled (false);
insilmaril@366
   747
	a->setStatusTip ( tr( "Edit link to another vym map" ));
insilmaril@366
   748
    connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
insilmaril@98
   749
	actionListBranches.append(a);
insilmaril@0
   750
	actionEditVymLink=a;
insilmaril@0
   751
insilmaril@395
   752
    a = new QAction(tr( "Delete vym link","Edit menu" ),this);
insilmaril@366
   753
	a->setStatusTip ( tr( "Delete link to another vym map" ));
insilmaril@0
   754
	a->setEnabled (false);
insilmaril@366
   755
    connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
insilmaril@0
   756
	actionEditDeleteVymLink=a;
insilmaril@0
   757
insilmaril@395
   758
    a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
insilmaril@366
   759
	a->setStatusTip ( tr( "Hide object in exports" ) );
insilmaril@366
   760
	a->setShortcut (Qt::Key_H );
insilmaril@243
   761
	a->setToggleAction(true);
insilmaril@366
   762
    tb->addAction (a);
insilmaril@243
   763
	a->setEnabled (false);
insilmaril@366
   764
    connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
insilmaril@243
   765
	actionEditToggleHideExport=a;
insilmaril@243
   766
insilmaril@395
   767
    a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
insilmaril@366
   768
	a->setStatusTip ( tr( "Edit Map Info" ));
insilmaril@0
   769
	a->setEnabled (true);
insilmaril@366
   770
    connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
insilmaril@0
   771
	actionEditMapInfo=a;
insilmaril@0
   772
insilmaril@0
   773
	// Import at selection (adding to selection)
insilmaril@395
   774
    a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
insilmaril@366
   775
	a->setStatusTip (tr( "Add map at selection" ));
insilmaril@366
   776
    connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
insilmaril@0
   777
	a->setEnabled (false);
insilmaril@98
   778
	actionListBranches.append(a);
insilmaril@0
   779
	actionEditImportAdd=a;
insilmaril@0
   780
insilmaril@0
   781
	// Import at selection (replacing selection)
insilmaril@395
   782
    a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
insilmaril@366
   783
	a->setStatusTip (tr( "Replace selection with map" ));
insilmaril@366
   784
    connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
insilmaril@0
   785
	a->setEnabled (false);
insilmaril@98
   786
	actionListBranches.append(a);
insilmaril@0
   787
	actionEditImportReplace=a;
insilmaril@0
   788
insilmaril@0
   789
	// Save selection 
insilmaril@395
   790
    a = new QAction( tr( "Save selection","Edit menu" ), this);
insilmaril@366
   791
	a->setStatusTip (tr( "Save selection" ));
insilmaril@366
   792
    connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
insilmaril@0
   793
	a->setEnabled (false);
insilmaril@98
   794
	actionListBranches.append(a);
insilmaril@0
   795
	actionEditSaveBranch=a;
insilmaril@0
   796
insilmaril@98
   797
	// Only remove branch, not its childs
insilmaril@395
   798
    a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
insilmaril@366
   799
	a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
insilmaril@366
   800
	a->setShortcut (Qt::ALT + Qt::Key_Delete );
insilmaril@395
   801
    connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChilds() ) );
insilmaril@98
   802
	a->setEnabled (false);
insilmaril@375
   803
	addAction (a);
insilmaril@98
   804
	actionListBranches.append(a);
insilmaril@395
   805
	actionEditDeleteKeepChilds=a;
insilmaril@98
   806
insilmaril@98
   807
	// Only remove childs of a branch
insilmaril@395
   808
    a = new QAction( tr( "Remove childs","Edit menu" ), this);
insilmaril@366
   809
	a->setStatusTip (tr( "Remove childs of branch" ));
insilmaril@366
   810
	a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
insilmaril@395
   811
    connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChilds() ) );
insilmaril@98
   812
	a->setEnabled (false);
insilmaril@98
   813
	actionListBranches.append(a);
insilmaril@395
   814
	actionEditDeleteChilds=a;
insilmaril@98
   815
insilmaril@0
   816
    // Shortcuts for navigating with cursor:
insilmaril@395
   817
    a = new QAction(tr( "Select upper branch","Edit menu" ), this);
insilmaril@366
   818
	a->setStatusTip ( tr( "Select upper branch" ));
insilmaril@366
   819
	a->setShortcut (Qt::Key_Up );
insilmaril@366
   820
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   821
	addAction (a);
insilmaril@366
   822
    connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
insilmaril@395
   823
    a = new QAction( tr( "Select lower branch","Edit menu" ),this);
insilmaril@366
   824
	a->setStatusTip (tr( "Select lower branch" ));
insilmaril@366
   825
	a->setShortcut ( Qt::Key_Down );
insilmaril@366
   826
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   827
	addAction (a);
insilmaril@366
   828
    connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
insilmaril@395
   829
    a = new QAction(tr( "Select left branch","Edit menu" ), this);
insilmaril@366
   830
	a->setStatusTip ( tr( "Select left branch" ));
insilmaril@366
   831
	a->setShortcut (Qt::Key_Left );
insilmaril@366
   832
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   833
	addAction (a);
insilmaril@366
   834
    connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
insilmaril@395
   835
    a = new QAction( tr( "Select child branch","Edit menu" ), this);
insilmaril@366
   836
	a->setStatusTip (tr( "Select right branch" ));
insilmaril@366
   837
	a->setShortcut (Qt::Key_Right);
insilmaril@366
   838
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   839
	addAction (a);
insilmaril@366
   840
    connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
insilmaril@395
   841
    a = new QAction( tr( "Select first branch","Edit menu" ), this);
insilmaril@366
   842
	a->setStatusTip (tr( "Select first branch" ));
insilmaril@366
   843
	a->setShortcut (Qt::Key_Home );
insilmaril@366
   844
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   845
	addAction (a);
insilmaril@0
   846
	a->setEnabled (false);
insilmaril@366
   847
	editMenu->addAction (a);
insilmaril@98
   848
	actionListBranches.append(a);
insilmaril@0
   849
	actionEditSelectFirst=a;
insilmaril@366
   850
    connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
insilmaril@395
   851
    a = new QAction( tr( "Select last branch","Edit menu" ),this);
insilmaril@366
   852
	a->setStatusTip (tr( "Select last branch" ));
insilmaril@366
   853
	a->setShortcut ( Qt::Key_End );
insilmaril@366
   854
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   855
	addAction (a);
insilmaril@366
   856
    connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
insilmaril@0
   857
	a->setEnabled (false);
insilmaril@366
   858
	editMenu->addAction (a);
insilmaril@98
   859
	actionListBranches.append(a);
insilmaril@0
   860
	actionEditSelectLast=a;
insilmaril@0
   861
insilmaril@395
   862
    a = new QAction( tr( "Add Image...","Edit menu" ), this);
insilmaril@366
   863
	a->setStatusTip (tr( "Add Image" ));
insilmaril@366
   864
    connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
insilmaril@0
   865
	actionEditLoadImage=a;
insilmaril@89
   866
insilmaril@473
   867
    a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
insilmaril@442
   868
	a->setStatusTip (tr( "Set properties for selection" ));
insilmaril@442
   869
	a->setShortcut ( Qt::CTRL + Qt::Key_I );		//Property window
insilmaril@442
   870
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@486
   871
	a->setToggleAction (true);
insilmaril@442
   872
	addAction (a);
insilmaril@473
   873
    connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
insilmaril@486
   874
	actionViewTogglePropertyWindow=a;
insilmaril@0
   875
}
insilmaril@0
   876
insilmaril@0
   877
// Format Actions
insilmaril@0
   878
void Main::setupFormatActions()
insilmaril@0
   879
{
insilmaril@395
   880
    QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
insilmaril@395
   881
insilmaril@395
   882
    QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
insilmaril@366
   883
	tb->setObjectName ("formatTB");
insilmaril@0
   884
    QAction *a;
insilmaril@0
   885
    QPixmap pix( 16,16);
insilmaril@366
   886
    pix.fill (Qt::black);
insilmaril@366
   887
    a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
insilmaril@366
   888
	a->setStatusTip ( tr( "Set Color" ));
insilmaril@366
   889
    connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
insilmaril@366
   890
    a->addTo( tb );
insilmaril@366
   891
	formatMenu->addAction (a);
insilmaril@366
   892
	actionFormatColor=a;
insilmaril@395
   893
    a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
insilmaril@366
   894
	a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
insilmaril@366
   895
	a->setShortcut (Qt::CTRL + Qt::Key_K );
insilmaril@366
   896
    connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
insilmaril@0
   897
	a->setEnabled (false);
insilmaril@0
   898
    a->addTo( tb );
insilmaril@366
   899
	formatMenu->addAction (a);
insilmaril@98
   900
	actionListBranches.append(a);
insilmaril@0
   901
	actionFormatPickColor=a;
insilmaril@366
   902
insilmaril@417
   903
    a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
insilmaril@366
   904
	a->setStatusTip ( tr( "Color branch" ) );
insilmaril@442
   905
	a->setShortcut (Qt::CTRL + Qt::Key_B);
insilmaril@417
   906
    connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
insilmaril@0
   907
	a->setEnabled (false);
insilmaril@0
   908
    a->addTo( tb );
insilmaril@366
   909
	formatMenu->addAction (a);
insilmaril@98
   910
	actionListBranches.append(a);
insilmaril@417
   911
	actionFormatColorSubtree=a;
insilmaril@417
   912
insilmaril@417
   913
    a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
insilmaril@366
   914
	a->setStatusTip ( tr( "Color Subtree" ));
insilmaril@366
   915
	a->setShortcut (Qt::CTRL + Qt::Key_T);
insilmaril@417
   916
    connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
insilmaril@0
   917
	a->setEnabled (false);
insilmaril@366
   918
	formatMenu->addAction (a);
insilmaril@0
   919
    a->addTo( tb );
insilmaril@98
   920
	actionListBranches.append(a);
insilmaril@0
   921
	actionFormatColorSubtree=a;
insilmaril@0
   922
insilmaril@366
   923
	formatMenu->addSeparator();
insilmaril@366
   924
	actionGroupFormatLinkStyles=new QActionGroup ( this);
insilmaril@0
   925
	actionGroupFormatLinkStyles->setExclusive (true);
insilmaril@366
   926
    a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
insilmaril@366
   927
	a->setStatusTip (tr( "Line" ));
insilmaril@0
   928
	a->setToggleAction(true);
insilmaril@366
   929
    connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
insilmaril@366
   930
	formatMenu->addAction (a);
insilmaril@0
   931
	actionFormatLinkStyleLine=a;
insilmaril@505
   932
    a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
insilmaril@366
   933
	a->setStatusTip (tr( "Line" ));
insilmaril@0
   934
	a->setToggleAction(true);
insilmaril@366
   935
    connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
insilmaril@366
   936
	formatMenu->addAction (a);
insilmaril@0
   937
	actionFormatLinkStyleParabel=a;
insilmaril@366
   938
    a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
insilmaril@366
   939
	a->setStatusTip (tr( "PolyLine" ));
insilmaril@0
   940
	a->setToggleAction(true);
insilmaril@366
   941
    connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
insilmaril@366
   942
	formatMenu->addAction (a);
insilmaril@0
   943
	actionFormatLinkStylePolyLine=a;
insilmaril@505
   944
    a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
insilmaril@366
   945
	a->setStatusTip (tr( "PolyParabel" ) );
insilmaril@0
   946
	a->setToggleAction(true);
insilmaril@366
   947
	a->setChecked (true);
insilmaril@366
   948
    connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
insilmaril@366
   949
	formatMenu->addAction (a);
insilmaril@0
   950
	actionFormatLinkStylePolyParabel=a;
insilmaril@0
   951
	
insilmaril@395
   952
    a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
insilmaril@366
   953
	a->setStatusTip (tr( "Hide link" ));
insilmaril@160
   954
	a->setToggleAction(true);
insilmaril@366
   955
    connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
insilmaril@160
   956
	actionFormatHideLinkUnselected=a;
insilmaril@160
   957
insilmaril@366
   958
	formatMenu->addSeparator();
insilmaril@395
   959
    a= new QAction( tr( "&Use color of heading for link","Branch attribute" ),  this);
insilmaril@366
   960
	a->setStatusTip (tr( "Use same color for links and headings" ));
insilmaril@0
   961
	a->setToggleAction(true);
insilmaril@366
   962
    connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
insilmaril@366
   963
	formatMenu->addAction (a);
insilmaril@0
   964
	actionFormatLinkColorHint=a;
insilmaril@366
   965
insilmaril@366
   966
    pix.fill (Qt::white);
insilmaril@366
   967
    a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this  );
insilmaril@366
   968
	a->setStatusTip (tr( "Set Link Color" ));
insilmaril@366
   969
	formatMenu->addAction (a);
insilmaril@366
   970
    connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
insilmaril@366
   971
    actionFormatLinkColor=a;
insilmaril@366
   972
insilmaril@442
   973
    a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this  );
insilmaril@442
   974
	a->setStatusTip (tr( "Set Selection Color" ));
insilmaril@442
   975
	formatMenu->addAction (a);
insilmaril@442
   976
    connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
insilmaril@442
   977
    actionFormatSelectionColor=a;
insilmaril@442
   978
insilmaril@366
   979
    a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
insilmaril@366
   980
	a->setStatusTip (tr( "Set Background Color" ));
insilmaril@366
   981
	formatMenu->addAction (a);
insilmaril@366
   982
    connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
insilmaril@366
   983
    actionFormatBackColor=a;
insilmaril@408
   984
insilmaril@408
   985
    a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
insilmaril@408
   986
	a->setStatusTip (tr( "Set Background image" ));
insilmaril@408
   987
	formatMenu->addAction (a);
insilmaril@408
   988
    connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
insilmaril@408
   989
    actionFormatBackImage=a;
insilmaril@0
   990
}
insilmaril@0
   991
insilmaril@0
   992
// View Actions
insilmaril@0
   993
void Main::setupViewActions()
insilmaril@0
   994
{
insilmaril@395
   995
    QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
insilmaril@0
   996
    tb->setLabel( "View Actions" );
insilmaril@366
   997
	tb->setObjectName ("viewTB");
insilmaril@366
   998
    QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
insilmaril@0
   999
insilmaril@0
  1000
    QAction *a;
insilmaril@395
  1001
    a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
insilmaril@366
  1002
	a->setStatusTip ( tr( "Zoom reset" ) );
insilmaril@366
  1003
	a->setShortcut (Qt::CTRL + Qt::Key_0 );
insilmaril@0
  1004
    a->addTo( tb );
insilmaril@366
  1005
	viewMenu->addAction (a);
insilmaril@366
  1006
    connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
insilmaril@366
  1007
	
insilmaril@395
  1008
    a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
insilmaril@366
  1009
	a->setStatusTip (tr( "Zoom in" ));
insilmaril@366
  1010
	a->setShortcut (Qt::CTRL + Qt::Key_Plus);
insilmaril@0
  1011
    a->addTo( tb );
insilmaril@366
  1012
	viewMenu->addAction (a);
insilmaril@366
  1013
    connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
insilmaril@366
  1014
	
insilmaril@395
  1015
    a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
insilmaril@366
  1016
	a->setStatusTip (tr( "Zoom out" ));
insilmaril@366
  1017
	a->setShortcut (Qt::CTRL + Qt::Key_Minus );
insilmaril@0
  1018
    a->addTo( tb );
insilmaril@366
  1019
	viewMenu->addAction (a);
insilmaril@366
  1020
    connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
insilmaril@366
  1021
insilmaril@526
  1022
    a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
insilmaril@526
  1023
	a->setStatusTip (tr( "Show selection" ));
insilmaril@526
  1024
	a->setShortcut (Qt::Key_Period);
insilmaril@526
  1025
    a->addTo( tb );
insilmaril@526
  1026
	viewMenu->addAction (a);
insilmaril@526
  1027
    connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
insilmaril@526
  1028
insilmaril@486
  1029
	viewMenu->addSeparator();	
insilmaril@366
  1030
insilmaril@395
  1031
    a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
insilmaril@366
  1032
	a->setStatusTip ( tr( "Show Note Editor" ));
insilmaril@366
  1033
	a->setShortcut ( Qt::CTRL + Qt::Key_E );
insilmaril@0
  1034
	a->setToggleAction(true);
insilmaril@0
  1035
    a->addTo( tb );
insilmaril@366
  1036
	viewMenu->addAction (a);
insilmaril@366
  1037
    connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
insilmaril@0
  1038
	actionViewToggleNoteEditor=a;
insilmaril@294
  1039
insilmaril@442
  1040
    a = new QAction(QPixmap(iconPath+"history.png"),  tr( "History Window","View action" ),this );
insilmaril@442
  1041
	a->setStatusTip ( tr( "Show History Window" ));
insilmaril@366
  1042
	a->setShortcut ( Qt::CTRL + Qt::Key_H  );
insilmaril@407
  1043
	a->setToggleAction(true);
insilmaril@404
  1044
    a->addTo( tb );
insilmaril@366
  1045
	viewMenu->addAction (a);
insilmaril@366
  1046
    connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
insilmaril@294
  1047
	actionViewToggleHistoryWindow=a;
insilmaril@294
  1048
insilmaril@486
  1049
	viewMenu->addAction (actionViewTogglePropertyWindow);
insilmaril@486
  1050
insilmaril@486
  1051
	viewMenu->addSeparator();	
insilmaril@442
  1052
insilmaril@408
  1053
    a = new QAction(tr( "Antialiasing","View action" ),this );
insilmaril@408
  1054
	a->setStatusTip ( tr( "Antialiasing" ));
insilmaril@408
  1055
	a->setToggleAction(true);
insilmaril@408
  1056
	a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
insilmaril@408
  1057
	viewMenu->addAction (a);
insilmaril@408
  1058
    connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
insilmaril@408
  1059
	actionViewToggleAntiAlias=a;
insilmaril@408
  1060
insilmaril@408
  1061
    a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
insilmaril@408
  1062
	a->setStatusTip (a->text());
insilmaril@408
  1063
	a->setToggleAction(true);
insilmaril@408
  1064
	a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
insilmaril@408
  1065
	viewMenu->addAction (a);
insilmaril@408
  1066
    connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
insilmaril@408
  1067
	actionViewToggleSmoothPixmapTransform=a;
insilmaril@408
  1068
insilmaril@473
  1069
    a = new QAction(tr( "Next Map","View action" ), this);
insilmaril@408
  1070
	a->setStatusTip (a->text());
insilmaril@366
  1071
	a->setShortcut (Qt::ALT + Qt::Key_N );
insilmaril@366
  1072
	viewMenu->addAction (a);
insilmaril@366
  1073
    connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
insilmaril@366
  1074
insilmaril@473
  1075
    a = new QAction (tr( "Previous Map","View action" ), this );
insilmaril@408
  1076
	a->setStatusTip (a->text());
insilmaril@366
  1077
	a->setShortcut (Qt::ALT + Qt::Key_P );
insilmaril@366
  1078
	viewMenu->addAction (a);
insilmaril@366
  1079
    connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
insilmaril@0
  1080
}
insilmaril@0
  1081
insilmaril@89
  1082
// Mode Actions
insilmaril@89
  1083
void Main::setupModeActions()
insilmaril@89
  1084
{
insilmaril@89
  1085
    //QPopupMenu *menu = new QPopupMenu( this );
insilmaril@89
  1086
    //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
insilmaril@89
  1087
insilmaril@395
  1088
    QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
insilmaril@366
  1089
	tb->setObjectName ("modesTB");
insilmaril@89
  1090
    QAction *a;
insilmaril@366
  1091
	actionGroupModModes=new QActionGroup ( this);
insilmaril@89
  1092
	actionGroupModModes->setExclusive (true);
insilmaril@395
  1093
    a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
insilmaril@366
  1094
	a->setShortcut (Qt::Key_J);
insilmaril@366
  1095
    a->setStatusTip ( tr( "Use modifier to color branches" ));
insilmaril@89
  1096
	a->setToggleAction(true);
insilmaril@89
  1097
	a->addTo (tb);
insilmaril@89
  1098
	a->setOn(true);
insilmaril@89
  1099
	actionModModeColor=a;
insilmaril@104
  1100
	
insilmaril@395
  1101
    a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
insilmaril@366
  1102
	a->setShortcut( Qt::Key_K); 
insilmaril@366
  1103
    a->setStatusTip( tr( "Use modifier to copy" ));
insilmaril@104
  1104
	a->setToggleAction(true);
insilmaril@104
  1105
	a->addTo (tb);
insilmaril@104
  1106
	actionModModeCopy=a;
insilmaril@104
  1107
insilmaril@395
  1108
    a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
insilmaril@366
  1109
	a->setShortcut (Qt::Key_L);
insilmaril@366
  1110
    a->setStatusTip( tr( "Use modifier to draw xLinks" ));
insilmaril@89
  1111
	a->setToggleAction(true);
insilmaril@89
  1112
	a->addTo (tb);
insilmaril@390
  1113
	actionModModeXLink=a;
insilmaril@89
  1114
}
insilmaril@89
  1115
insilmaril@0
  1116
// Flag Actions
insilmaril@0
  1117
void Main::setupFlagActions()
insilmaril@0
  1118
{
insilmaril@166
  1119
	// Create System Flags
insilmaril@582
  1120
	QToolBar *tb=NULL;
insilmaril@582
  1121
	bool avis=true;
insilmaril@582
  1122
insilmaril@166
  1123
	systemFlagsDefault = new FlagRowObj ();
insilmaril@166
  1124
	systemFlagsDefault->setVisibility (false);
insilmaril@166
  1125
	systemFlagsDefault->setName ("systemFlagsDef");
insilmaril@166
  1126
insilmaril@166
  1127
	FlagObj *fo = new FlagObj ();
insilmaril@269
  1128
	fo->load(QPixmap(flagsPath+"flag-note.png"));
insilmaril@582
  1129
	setupFlag (fo,tb,avis,"note",tr("Note","SystemFlag"));
insilmaril@166
  1130
insilmaril@269
  1131
	fo->load(QPixmap(flagsPath+"flag-url.png"));
insilmaril@582
  1132
	setupFlag (fo,tb,avis,"url",tr("URL to Document ","SystemFlag"));
insilmaril@166
  1133
	
insilmaril@269
  1134
	fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
insilmaril@582
  1135
	setupFlag (fo,tb,avis,"vymLink",tr("Link to another vym map","SystemFlag"));
insilmaril@166
  1136
insilmaril@269
  1137
	fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
insilmaril@582
  1138
	setupFlag (fo,tb,avis,"scrolledright",tr("subtree is scrolled","SystemFlag"));
insilmaril@166
  1139
	
insilmaril@269
  1140
	fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
insilmaril@582
  1141
	setupFlag (fo,tb,avis,"tmpUnscrolledright",tr("subtree is temporary scrolled","SystemFlag"));
insilmaril@166
  1142
insilmaril@269
  1143
	fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
insilmaril@582
  1144
	setupFlag (fo,tb,avis,"hideInExport",tr("Hide object in exported maps","SystemFlag"));
insilmaril@243
  1145
insilmaril@166
  1146
	// Create Standard Flags
insilmaril@582
  1147
	tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
insilmaril@366
  1148
	tb->setObjectName ("standardFlagTB");
insilmaril@366
  1149
insilmaril@166
  1150
	standardFlagsDefault = new FlagRowObj ();
insilmaril@166
  1151
	standardFlagsDefault->setVisibility (false);
insilmaril@166
  1152
	standardFlagsDefault->setName ("standardFlagsDef");
insilmaril@366
  1153
	standardFlagsDefault->setToolBar (tb);
insilmaril@166
  1154
insilmaril@408
  1155
	fo->load(flagsPath+"flag-exclamationmark.png");
insilmaril@166
  1156
	fo->setGroup("standard-mark");
insilmaril@582
  1157
	setupFlag (fo,tb,avis,"exclamationmark",tr("Take care!","Standardflag"));
insilmaril@166
  1158
	
insilmaril@408
  1159
	fo->load(flagsPath+"flag-questionmark.png");
insilmaril@166
  1160
	fo->setGroup("standard-mark");
insilmaril@582
  1161
	setupFlag (fo,tb,avis,"questionmark",tr("Really?","Standardflag"));
insilmaril@166
  1162
insilmaril@408
  1163
	fo->load(flagsPath+"flag-hook-green.png");
insilmaril@166
  1164
	fo->setGroup("standard-hook");
insilmaril@582
  1165
	setupFlag (fo,tb,avis,"hook-green",tr("ok!","Standardflag"));
insilmaril@166
  1166
insilmaril@408
  1167
	fo->load(flagsPath+"flag-cross-red.png");
insilmaril@166
  1168
	fo->setGroup("standard-hook");
insilmaril@582
  1169
	setupFlag (fo,tb,avis,"cross-red",tr("Not ok!","Standardflag"));
insilmaril@582
  1170
	fo->unsetGroup();
insilmaril@166
  1171
insilmaril@408
  1172
	fo->load(flagsPath+"flag-stopsign.png");
insilmaril@582
  1173
	setupFlag (fo,tb,avis,"stopsign",tr("This won't work!","Standardflag"));
insilmaril@166
  1174
insilmaril@408
  1175
	fo->load(flagsPath+"flag-smiley-good.png");
insilmaril@166
  1176
	fo->setGroup("standard-smiley");
insilmaril@582
  1177
	setupFlag (fo,tb,avis,"smiley-good",tr("Good","Standardflag"));
insilmaril@166
  1178
insilmaril@408
  1179
	fo->load(flagsPath+"flag-smiley-sad.png");
insilmaril@166
  1180
	fo->setGroup("standard-smiley");
insilmaril@585
  1181
	setupFlag (fo,tb,avis,"smiley-sad",tr("Bad","Standardflag"));
insilmaril@166
  1182
insilmaril@408
  1183
	fo->load(flagsPath+"flag-smiley-omg.png");
insilmaril@582
  1184
	fo->setGroup("standard-smiley");
insilmaril@582
  1185
	setupFlag (fo,tb,avis,"smiley-omb",tr("Oh no!","Standardflag"));
insilmaril@269
  1186
	// Original omg.png (in KDE emoticons)
insilmaril@582
  1187
	fo->unsetGroup();
insilmaril@269
  1188
insilmaril@408
  1189
	fo->load(flagsPath+"flag-kalarm.png");
insilmaril@582
  1190
	setupFlag (fo,tb,avis,"clock",tr("Time critical","Standardflag"));
insilmaril@166
  1191
insilmaril@408
  1192
	fo->load(flagsPath+"flag-phone.png");
insilmaril@582
  1193
	setupFlag (fo,tb,avis,"phone",tr("Call...","Standardflag"));
insilmaril@269
  1194
insilmaril@408
  1195
	fo->load(flagsPath+"flag-lamp.png");
insilmaril@582
  1196
	setupFlag (fo,tb,avis,"lamp",tr("Idea!","Standardflag"));
insilmaril@166
  1197
insilmaril@408
  1198
	fo->load(flagsPath+"flag-arrow-up.png");
insilmaril@166
  1199
	fo->setGroup("standard-arrow");
insilmaril@582
  1200
	setupFlag (fo,tb,avis,"arrow-up",tr("Important","Standardflag"));
insilmaril@166
  1201
insilmaril@408
  1202
	fo->load(flagsPath+"flag-arrow-down.png");
insilmaril@166
  1203
	fo->setGroup("standard-arrow");
insilmaril@582
  1204
	setupFlag (fo,tb,avis,"arrow-down",tr("Unimportant","Standardflag"));
insilmaril@166
  1205
insilmaril@408
  1206
	fo->load(flagsPath+"flag-arrow-2up.png");
insilmaril@269
  1207
	fo->setGroup("standard-arrow");
insilmaril@582
  1208
	setupFlag (fo,tb,avis,"2arrow-up",tr("Very important!","Standardflag"));
insilmaril@269
  1209
insilmaril@408
  1210
	fo->load(flagsPath+"flag-arrow-2down.png");
insilmaril@269
  1211
	fo->setGroup("standard-arrow");
insilmaril@614
  1212
	setupFlag (fo,tb,avis,"2arrow-down",tr("Very unimportant!","Standardflag"));
insilmaril@582
  1213
	fo->unsetGroup();
insilmaril@269
  1214
insilmaril@408
  1215
	fo->load(flagsPath+"flag-thumb-up.png");
insilmaril@166
  1216
	fo->setGroup("standard-thumb");
insilmaril@582
  1217
	setupFlag (fo,tb,avis,"thumb-up",tr("I like this","Standardflag"));
insilmaril@166
  1218
insilmaril@408
  1219
	fo->load(flagsPath+"flag-thumb-down.png");
insilmaril@166
  1220
	fo->setGroup("standard-thumb");
insilmaril@582
  1221
	setupFlag (fo,tb,avis,"thumb-down",tr("I do not like this","Standardflag"));
insilmaril@582
  1222
	fo->unsetGroup();
insilmaril@166
  1223
	
insilmaril@408
  1224
	fo->load(flagsPath+"flag-rose.png");
insilmaril@582
  1225
	setupFlag (fo,tb,avis,"rose",tr("Rose","Standardflag"));
insilmaril@269
  1226
insilmaril@408
  1227
	fo->load(flagsPath+"flag-heart.png");
insilmaril@582
  1228
	setupFlag (fo,tb,avis,"heart",tr("I just love...","Standardflag"));
insilmaril@564
  1229
insilmaril@408
  1230
	fo->load(flagsPath+"flag-present.png");
insilmaril@582
  1231
	setupFlag (fo,tb,avis,"present",tr("Surprise!","Standardflag"));
insilmaril@564
  1232
insilmaril@564
  1233
	fo->load(flagsPath+"flag-flash.png");
insilmaril@582
  1234
	setupFlag (fo,tb,avis,"flash",tr("Dangerous","Standardflag"));
insilmaril@564
  1235
	
insilmaril@564
  1236
	// Original: xsldbg_output.png
insilmaril@564
  1237
	fo->load(flagsPath+"flag-info.png");
insilmaril@582
  1238
	setupFlag (fo,tb,avis,"info",tr("Info","Standardflag"));
insilmaril@564
  1239
insilmaril@564
  1240
	// Original khelpcenter.png
insilmaril@564
  1241
	fo->load(flagsPath+"flag-lifebelt.png");
insilmaril@582
  1242
	setupFlag (fo,tb,avis,"lifebelt",tr("This will help","Standardflag"));
insilmaril@564
  1243
insilmaril@564
  1244
	// Freemind flags
insilmaril@564
  1245
insilmaril@582
  1246
	avis=false;
insilmaril@582
  1247
insilmaril@564
  1248
	fo->load(flagsPath+"freemind/warning.png");
insilmaril@582
  1249
	setupFlag (fo,tb, avis, "freemind-warning",tr("Important","Freemind-Flag"));
insilmaril@564
  1250
insilmaril@564
  1251
	for (int i=1; i<8; i++)
insilmaril@564
  1252
	{
insilmaril@564
  1253
		fo->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
insilmaril@582
  1254
		setupFlag (fo,tb, avis,QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
insilmaril@564
  1255
	}
insilmaril@564
  1256
insilmaril@564
  1257
	fo->load(flagsPath+"freemind/back.png");
insilmaril@582
  1258
	setupFlag (fo,tb,avis,"freemind-back",tr("Back","Freemind-Flag"));
insilmaril@564
  1259
insilmaril@564
  1260
	fo->load(flagsPath+"freemind/forward.png");
insilmaril@582
  1261
	setupFlag (fo,tb,avis,"freemind-forward",tr("Forward","Freemind-Flag"));
insilmaril@564
  1262
insilmaril@564
  1263
	fo->load(flagsPath+"freemind/attach.png");
insilmaril@582
  1264
	setupFlag (fo,tb,avis,"freemind-attach",tr("Look here","Freemind-Flag"));
insilmaril@564
  1265
insilmaril@564
  1266
	fo->load(flagsPath+"freemind/clanbomber.png");
insilmaril@582
  1267
	setupFlag (fo,tb,avis,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
insilmaril@564
  1268
insilmaril@564
  1269
	fo->load(flagsPath+"freemind/desktopnew.png");
insilmaril@582
  1270
	setupFlag (fo,tb,avis,"freemind-desktopnew",tr("Don't forget","Freemind-Flag"));
insilmaril@564
  1271
insilmaril@564
  1272
	fo->load(flagsPath+"freemind/flag.png");
insilmaril@582
  1273
	setupFlag (fo,tb,avis,"freemind-flag",tr("Flag","Freemind-Flag"));
insilmaril@564
  1274
insilmaril@564
  1275
insilmaril@564
  1276
	fo->load(flagsPath+"freemind/gohome.png");
insilmaril@582
  1277
	setupFlag (fo,tb,avis,"freemind-gohome",tr("Home","Freemind-Flag"));
insilmaril@564
  1278
insilmaril@564
  1279
insilmaril@564
  1280
	fo->load(flagsPath+"freemind/kaddressbook.png");
insilmaril@582
  1281
	setupFlag (fo,tb,avis,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
insilmaril@564
  1282
insilmaril@564
  1283
	fo->load(flagsPath+"freemind/knotify.png");
insilmaril@582
  1284
	setupFlag (fo,tb,avis,"freemind-knotify",tr("Music","Freemind-Flag"));
insilmaril@564
  1285
insilmaril@564
  1286
	fo->load(flagsPath+"freemind/korn.png");
insilmaril@582
  1287
	setupFlag (fo,tb,avis,"freemind-korn",tr("Mailbox","Freemind-Flag"));
insilmaril@564
  1288
insilmaril@564
  1289
	fo->load(flagsPath+"freemind/mail.png");
insilmaril@582
  1290
	setupFlag (fo,tb,avis,"freemind-mail",tr("Maix","Freemind-Flag"));
insilmaril@564
  1291
insilmaril@564
  1292
	fo->load(flagsPath+"freemind/password.png");
insilmaril@582
  1293
	setupFlag (fo,tb,avis,"freemind-password",tr("Password","Freemind-Flag"));
insilmaril@564
  1294
insilmaril@564
  1295
	fo->load(flagsPath+"freemind/pencil.png");
insilmaril@582
  1296
	setupFlag (fo,tb,avis,"freemind-pencil",tr("To be improved","Freemind-Flag"));
insilmaril@564
  1297
insilmaril@564
  1298
	fo->load(flagsPath+"freemind/stop.png");
insilmaril@582
  1299
	setupFlag (fo,tb,avis,"freemind-stop",tr("Stop","Freemind-Flag"));
insilmaril@564
  1300
insilmaril@564
  1301
	fo->load(flagsPath+"freemind/wizard.png");
insilmaril@582
  1302
	setupFlag (fo,tb,avis,"freemind-wizard",tr("Magic","Freemind-Flag"));
insilmaril@564
  1303
insilmaril@564
  1304
	fo->load(flagsPath+"freemind/xmag.png");
insilmaril@582
  1305
	setupFlag (fo,tb,avis,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
insilmaril@564
  1306
insilmaril@564
  1307
	fo->load(flagsPath+"freemind/bell.png");
insilmaril@582
  1308
	setupFlag (fo,tb,avis,"freemind-bell",tr("Reminder","Freemind-Flag"));
insilmaril@564
  1309
insilmaril@564
  1310
	fo->load(flagsPath+"freemind/bookmark.png");
insilmaril@582
  1311
	setupFlag (fo,tb,avis,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
insilmaril@564
  1312
insilmaril@564
  1313
	fo->load(flagsPath+"freemind/penguin.png");
insilmaril@582
  1314
	setupFlag (fo,tb,avis,"freemind-penguin",tr("Linux","Freemind-Flag"));
insilmaril@564
  1315
insilmaril@564
  1316
	fo->load(flagsPath+"freemind/licq.png");
insilmaril@582
  1317
	setupFlag (fo,tb,avis,"freemind-licq",tr("Sweet","Freemind-Flag"));
insilmaril@564
  1318
insilmaril@564
  1319
	delete (fo);
insilmaril@564
  1320
}
insilmaril@564
  1321
insilmaril@582
  1322
void Main::setupFlag (FlagObj *fo, QToolBar *tb, bool aw, const QString &name, const QString &tooltip)
insilmaril@564
  1323
{
insilmaril@564
  1324
	fo->setName(name);
insilmaril@582
  1325
	fo->setToolTip (tooltip);
insilmaril@564
  1326
	QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
insilmaril@582
  1327
	if (tb)
insilmaril@582
  1328
	{
insilmaril@582
  1329
		// StandardFlag
insilmaril@582
  1330
		tb->addAction (a);
insilmaril@582
  1331
		fo->setAction (a);
insilmaril@582
  1332
		fo->setAlwaysVisible(aw);
insilmaril@582
  1333
		a->setCheckable(true);
insilmaril@582
  1334
		a->setObjectName(fo->getName());
insilmaril@582
  1335
		a->setToolTip(tooltip);
insilmaril@582
  1336
		connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
insilmaril@582
  1337
		standardFlagsDefault->addFlag (fo);	
insilmaril@582
  1338
	} else
insilmaril@582
  1339
	{
insilmaril@582
  1340
		// SystemFlag
insilmaril@582
  1341
		systemFlagsDefault->addFlag (fo);	
insilmaril@582
  1342
	}
insilmaril@0
  1343
}
insilmaril@528
  1344
// Network Actions
insilmaril@528
  1345
void Main::setupNetworkActions()
insilmaril@528
  1346
{
insilmaril@528
  1347
	if (!settings.value( "/mainwindow/showTestMenu",false).toBool() ) 
insilmaril@528
  1348
		return;
insilmaril@635
  1349
    QMenu *netMenu = menuBar()->addMenu(  "Network" );
insilmaril@528
  1350
insilmaril@528
  1351
	QAction *a;
insilmaril@528
  1352
insilmaril@528
  1353
    a = new QAction(  "Start TCPserver for MapEditor",this);
insilmaril@528
  1354
    //a->setStatusTip ( "Set application to open pdf files"));
insilmaril@528
  1355
	a->setShortcut ( Qt::Key_T );		//New TCP server
insilmaril@528
  1356
    connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
insilmaril@528
  1357
	netMenu->addAction (a);
insilmaril@528
  1358
insilmaril@528
  1359
    a = new QAction(  "Connect MapEditor to server",this);
insilmaril@528
  1360
    //a->setStatusTip ( "Set application to open pdf files"));
insilmaril@528
  1361
	a->setShortcut ( Qt::Key_C );		// Connect to server
insilmaril@528
  1362
    connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
insilmaril@528
  1363
	netMenu->addAction (a);
insilmaril@528
  1364
}
insilmaril@528
  1365
	
insilmaril@0
  1366
// Settings Actions
insilmaril@0
  1367
void Main::setupSettingsActions()
insilmaril@0
  1368
{
insilmaril@366
  1369
    QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
insilmaril@0
  1370
insilmaril@0
  1371
	QAction *a;
insilmaril@0
  1372
insilmaril@395
  1373
    a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
insilmaril@366
  1374
    a->setStatusTip ( tr( "Set application to open pdf files"));
insilmaril@366
  1375
    connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
insilmaril@366
  1376
	settingsMenu->addAction (a);
insilmaril@366
  1377
insilmaril@395
  1378
    a = new QAction( tr( "Set application to open external links","Settings action"), this);
insilmaril@366
  1379
    a->setStatusTip( tr( "Set application to open external links"));
insilmaril@366
  1380
    connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
insilmaril@366
  1381
	settingsMenu->addAction (a);
insilmaril@366
  1382
insilmaril@473
  1383
    a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
insilmaril@450
  1384
    a->setStatusTip( tr( "Set path for macros"));
insilmaril@450
  1385
    connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
insilmaril@450
  1386
	settingsMenu->addAction (a);
insilmaril@450
  1387
insilmaril@473
  1388
    a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
insilmaril@473
  1389
    a->setStatusTip( tr( "Set number of undo levels"));
insilmaril@473
  1390
    connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
insilmaril@473
  1391
	settingsMenu->addAction (a);
insilmaril@473
  1392
insilmaril@366
  1393
	settingsMenu->addSeparator();
insilmaril@473
  1394
insilmaril@473
  1395
    a = new QAction( tr( "Autosave","Settings action"), this);
insilmaril@473
  1396
    a->setStatusTip( tr( "Autosave"));
insilmaril@473
  1397
	a->setToggleAction(true);
insilmaril@628
  1398
	a->setOn ( settings.value ("/mapeditor/autosave/use",false).toBool());
insilmaril@473
  1399
    connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
insilmaril@473
  1400
	settingsMenu->addAction (a);
insilmaril@473
  1401
	actionSettingsAutosaveToggle=a;
insilmaril@473
  1402
insilmaril@473
  1403
    a = new QAction( tr( "Autosave time","Settings action")+"...", this);
insilmaril@473
  1404
    a->setStatusTip( tr( "Autosave time"));
insilmaril@473
  1405
    connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
insilmaril@473
  1406
	settingsMenu->addAction (a);
insilmaril@473
  1407
	actionSettingsAutosaveTime=a;
insilmaril@473
  1408
insilmaril@628
  1409
    a = new QAction( tr( "Write backup file on save","Settings action"), this);
insilmaril@628
  1410
    a->setStatusTip( tr( "Write backup file on save"));
insilmaril@625
  1411
	a->setToggleAction(true);
insilmaril@625
  1412
	a->setOn ( settings.value ("/mainwindow/writeBackupFile",false).toBool());
insilmaril@625
  1413
    connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) );
insilmaril@625
  1414
	settingsMenu->addAction (a);
insilmaril@625
  1415
	actionSettingsWriteBackupFile=a;
insilmaril@625
  1416
insilmaril@473
  1417
	settingsMenu->addSeparator();
insilmaril@473
  1418
insilmaril@395
  1419
    a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
insilmaril@366
  1420
    a->setStatusTip( tr( "Edit branch after adding it" ));
insilmaril@0
  1421
	a->setToggleAction(true);
insilmaril@537
  1422
	a->setOn ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
insilmaril@366
  1423
	settingsMenu->addAction (a);
insilmaril@537
  1424
	actionSettingsAutoEditNewBranch=a;
insilmaril@0
  1425
insilmaril@395
  1426
    a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
insilmaril@366
  1427
    a->setStatusTip( tr( "Select branch after adding it" ));
insilmaril@0
  1428
	a->setToggleAction(true);
insilmaril@537
  1429
	a->setOn ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
insilmaril@366
  1430
	settingsMenu->addAction (a);
insilmaril@537
  1431
	actionSettingsAutoSelectNewBranch=a;
insilmaril@0
  1432
	
insilmaril@395
  1433
    a= new QAction(tr( "Select existing heading","Settings action" ), this);
insilmaril@366
  1434
    a->setStatusTip( tr( "Select heading before editing" ));
insilmaril@0
  1435
	a->setToggleAction(true);
insilmaril@366
  1436
	a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
insilmaril@366
  1437
	settingsMenu->addAction (a);
insilmaril@390
  1438
	actionSettingsAutoSelectText=a;
insilmaril@0
  1439
	
insilmaril@395
  1440
    a= new QAction( tr( "Delete key","Settings action" ), this);
insilmaril@366
  1441
    a->setStatusTip( tr( "Delete key for deleting branches" ));
insilmaril@0
  1442
	a->setToggleAction(true);
insilmaril@505
  1443
	a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
insilmaril@366
  1444
	settingsMenu->addAction (a);
insilmaril@366
  1445
    connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
insilmaril@366
  1446
	actionSettingsUseDelKey=a;
insilmaril@366
  1447
insilmaril@395
  1448
    a= new QAction( tr( "Exclusive flags","Settings action" ), this);
insilmaril@366
  1449
    a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
insilmaril@0
  1450
	a->setToggleAction(true);
insilmaril@366
  1451
	a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
insilmaril@366
  1452
	settingsMenu->addAction (a);
insilmaril@103
  1453
	actionSettingsUseFlagGroups=a;
insilmaril@260
  1454
	
insilmaril@395
  1455
    a= new QAction( tr( "Use hide flags","Settings action" ), this);
insilmaril@366
  1456
    a->setStatusTip( tr( "Use hide flag during exports " ));
insilmaril@260
  1457
	a->setToggleAction(true);
insilmaril@366
  1458
	a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
insilmaril@366
  1459
	settingsMenu->addAction (a);
insilmaril@260
  1460
	actionSettingsUseHideExport=a;
insilmaril@0
  1461
}
insilmaril@0
  1462
insilmaril@0
  1463
// Test Actions
insilmaril@0
  1464
void Main::setupTestActions()
insilmaril@0
  1465
{
insilmaril@366
  1466
    QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
insilmaril@0
  1467
insilmaril@0
  1468
    QAction *a;
insilmaril@527
  1469
    a = new QAction( "Test function 1" , this);
insilmaril@527
  1470
    a->setStatusTip( "Call test function 1" );
insilmaril@527
  1471
	testMenu->addAction (a);
insilmaril@445
  1472
	//a->setShortcut (Qt::Key_F4 );
insilmaril@527
  1473
    connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
insilmaril@527
  1474
insilmaril@527
  1475
    a = new QAction( "Test function 2" , this);
insilmaril@527
  1476
    a->setStatusTip( "Call test function 2" );
insilmaril@527
  1477
	//a->setShortcut (Qt::Key_F4 );
insilmaril@366
  1478
	testMenu->addAction (a);
insilmaril@527
  1479
    connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
insilmaril@527
  1480
insilmaril@395
  1481
    a = new QAction( "Command" , this);
insilmaril@395
  1482
    a->setStatusTip( "Enter command to call in editor" );
insilmaril@445
  1483
	//a->setShortcut (Qt::Key_F5 );
insilmaril@393
  1484
    connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
insilmaril@393
  1485
	testMenu->addAction (a);
insilmaril@0
  1486
}
insilmaril@0
  1487
insilmaril@0
  1488
// Help Actions
insilmaril@0
  1489
void Main::setupHelpActions()
insilmaril@0
  1490
{
insilmaril@395
  1491
    QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
insilmaril@0
  1492
insilmaril@0
  1493
    QAction *a;
insilmaril@395
  1494
    a = new QAction(  tr( "Open VYM Documentation (pdf) ","Help action" ), this );
insilmaril@366
  1495
    a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
insilmaril@366
  1496
    connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
insilmaril@366
  1497
	helpMenu->addAction (a);
insilmaril@366
  1498
insilmaril@505
  1499
    a = new QAction(  tr( "Open VYM example maps ","Help action" ), this );
insilmaril@505
  1500
    a->setStatusTip( tr( "Open VYM example maps " ));
insilmaril@505
  1501
    connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
insilmaril@505
  1502
	helpMenu->addAction (a);
insilmaril@505
  1503
insilmaril@395
  1504
    a = new QAction( tr( "About VYM","Help action" ), this);
insilmaril@404
  1505
    a->setStatusTip( tr( "About VYM")+vymName);
insilmaril@366
  1506
    connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
insilmaril@366
  1507
	helpMenu->addAction (a);
insilmaril@366
  1508
insilmaril@395
  1509
    a = new QAction( tr( "About QT","Help action" ), this);
insilmaril@366
  1510
    a->setStatusTip( tr( "Information about QT toolkit" ));
insilmaril@366
  1511
    connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
insilmaril@366
  1512
	helpMenu->addAction (a);
insilmaril@0
  1513
}
insilmaril@0
  1514
insilmaril@0
  1515
// Context Menus
insilmaril@0
  1516
void Main::setupContextMenus()
insilmaril@0
  1517
{
insilmaril@0
  1518
	QAction*a;
insilmaril@0
  1519
insilmaril@0
  1520
	// Context Menu for branch or mapcenter
insilmaril@366
  1521
	branchContextMenu =new QMenu (this);
insilmaril@486
  1522
	branchContextMenu->addAction (actionViewTogglePropertyWindow);
insilmaril@421
  1523
	branchContextMenu->addSeparator();	
insilmaril@421
  1524
insilmaril@98
  1525
		// Submenu "Add"
insilmaril@366
  1526
		branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
insilmaril@366
  1527
		branchAddContextMenu->addAction (actionEditPaste );
insilmaril@366
  1528
		branchAddContextMenu->addAction ( actionEditAddBranch );
insilmaril@394
  1529
		branchAddContextMenu->addAction ( actionEditAddBranchBefore );
insilmaril@366
  1530
		branchAddContextMenu->addAction ( actionEditAddBranchAbove);
insilmaril@366
  1531
		branchAddContextMenu->addAction ( actionEditAddBranchBelow );
insilmaril@366
  1532
		branchAddContextMenu->addSeparator();	
insilmaril@366
  1533
		branchAddContextMenu->addAction ( actionEditImportAdd );
insilmaril@366
  1534
		branchAddContextMenu->addAction ( actionEditImportReplace );
insilmaril@98
  1535
insilmaril@98
  1536
		// Submenu "Remove"
insilmaril@395
  1537
		branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
insilmaril@366
  1538
		branchRemoveContextMenu->addAction (actionEditCut);
insilmaril@366
  1539
		branchRemoveContextMenu->addAction ( actionEditDelete );
insilmaril@395
  1540
		branchRemoveContextMenu->addAction ( actionEditDeleteKeepChilds );
insilmaril@395
  1541
		branchRemoveContextMenu->addAction ( actionEditDeleteChilds );
insilmaril@98
  1542
		
insilmaril@98
  1543
insilmaril@0
  1544
	actionEditSaveBranch->addTo( branchContextMenu );
insilmaril@98
  1545
insilmaril@366
  1546
	branchContextMenu->addSeparator();	
insilmaril@398
  1547
	branchContextMenu->addAction ( actionEditLoadImage);
insilmaril@366
  1548
insilmaril@366
  1549
	// Submenu for Links (URLs, vymLinks)
insilmaril@366
  1550
	branchLinksContextMenu =new QMenu (this);
insilmaril@366
  1551
insilmaril@366
  1552
		branchContextMenu->addSeparator();	
insilmaril@473
  1553
		branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));	
insilmaril@366
  1554
		branchLinksContextMenu->addAction ( actionEditOpenURL );
insilmaril@366
  1555
		branchLinksContextMenu->addAction ( actionEditOpenURLTab );
insilmaril@366
  1556
		branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
insilmaril@366
  1557
		branchLinksContextMenu->addAction ( actionEditURL );
insilmaril@600
  1558
		branchLinksContextMenu->addAction ( actionEditLocalURL );
insilmaril@366
  1559
		branchLinksContextMenu->addAction ( actionEditHeading2URL );
insilmaril@366
  1560
		branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
insilmaril@528
  1561
		if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
insilmaril@366
  1562
		{
insilmaril@366
  1563
			branchLinksContextMenu->addAction ( actionEditFATE2URL );
insilmaril@366
  1564
		}	
insilmaril@366
  1565
		branchLinksContextMenu->addSeparator();	
insilmaril@366
  1566
		branchLinksContextMenu->addAction ( actionEditOpenVymLink );
insilmaril@366
  1567
		branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
insilmaril@366
  1568
		branchLinksContextMenu->addAction ( actionEditVymLink );
insilmaril@366
  1569
		branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
insilmaril@366
  1570
		
insilmaril@366
  1571
insilmaril@366
  1572
	// Context Menu for XLinks in a branch menu
insilmaril@89
  1573
	// This will be populated "on demand" in MapEditor::updateActions
insilmaril@366
  1574
	branchContextMenu->addSeparator();	
insilmaril@395
  1575
	branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
insilmaril@395
  1576
	branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
insilmaril@366
  1577
	connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
insilmaril@366
  1578
	connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
insilmaril@366
  1579
 	
insilmaril@105
  1580
	
insilmaril@0
  1581
	// Context menu for floatimage
insilmaril@366
  1582
	floatimageContextMenu =new QMenu (this);
insilmaril@395
  1583
	a= new QAction (tr ("Save image","Context action"),this);
insilmaril@366
  1584
	connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
insilmaril@366
  1585
	floatimageContextMenu->addAction (a);
insilmaril@366
  1586
insilmaril@366
  1587
	floatimageContextMenu->addSeparator();	
insilmaril@0
  1588
	actionEditCopy->addTo( floatimageContextMenu );
insilmaril@0
  1589
	actionEditCut->addTo( floatimageContextMenu );
insilmaril@0
  1590
insilmaril@366
  1591
	floatimageContextMenu->addSeparator();	
insilmaril@366
  1592
	floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
insilmaril@366
  1593
insilmaril@0
  1594
	
insilmaril@0
  1595
	// Context menu for canvas
insilmaril@366
  1596
	canvasContextMenu =new QMenu (this);
insilmaril@0
  1597
	actionEditMapInfo->addTo( canvasContextMenu );
insilmaril@0
  1598
	canvasContextMenu->insertSeparator();	
insilmaril@0
  1599
	actionGroupFormatLinkStyles->addTo( canvasContextMenu );
insilmaril@0
  1600
	canvasContextMenu->insertSeparator();	
insilmaril@0
  1601
	actionFormatLinkColorHint->addTo( canvasContextMenu );
insilmaril@0
  1602
	actionFormatLinkColor->addTo( canvasContextMenu );
insilmaril@442
  1603
	actionFormatSelectionColor->addTo( canvasContextMenu );
insilmaril@0
  1604
	actionFormatBackColor->addTo( canvasContextMenu );
insilmaril@505
  1605
	// actionFormatBackImage->addTo( canvasContextMenu );  //FIXME makes vym too slow: postponed for later version 
insilmaril@0
  1606
insilmaril@0
  1607
	// Menu for last opened files
insilmaril@401
  1608
	// Create actions
insilmaril@401
  1609
	for (int i = 0; i < MaxRecentFiles; ++i) 
insilmaril@0
  1610
	{
insilmaril@445
  1611
        recentFileActions[i] = new QAction(this);
insilmaril@445
  1612
        recentFileActions[i]->setVisible(false);
insilmaril@445
  1613
        fileLastMapsMenu->addAction(recentFileActions[i]);
insilmaril@445
  1614
        connect(recentFileActions[i], SIGNAL(triggered()),
insilmaril@401
  1615
                this, SLOT(fileLoadRecent()));
insilmaril@401
  1616
    }
insilmaril@401
  1617
	setupRecentMapsMenu();
insilmaril@0
  1618
}
insilmaril@0
  1619
insilmaril@401
  1620
void Main::setupRecentMapsMenu()
insilmaril@0
  1621
{
insilmaril@401
  1622
    QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
insilmaril@401
  1623
insilmaril@401
  1624
    int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
insilmaril@401
  1625
insilmaril@401
  1626
    for (int i = 0; i < numRecentFiles; ++i) {
insilmaril@401
  1627
        QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
insilmaril@445
  1628
        recentFileActions[i]->setText(text);
insilmaril@445
  1629
        recentFileActions[i]->setData(files[i]);
insilmaril@445
  1630
        recentFileActions[i]->setVisible(true);
insilmaril@401
  1631
    }
insilmaril@401
  1632
    for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
insilmaril@445
  1633
        recentFileActions[j]->setVisible(false);
insilmaril@445
  1634
}
insilmaril@445
  1635
insilmaril@445
  1636
void Main::setupMacros()
insilmaril@445
  1637
{
insilmaril@445
  1638
    for (int i = 0; i <= 11; i++) 
insilmaril@445
  1639
	{
insilmaril@445
  1640
        macroActions[i] = new QAction(this);
insilmaril@445
  1641
        macroActions[i]->setData(i);
insilmaril@445
  1642
        addAction (macroActions[i]);
insilmaril@445
  1643
        connect(macroActions[i], SIGNAL(triggered()),
insilmaril@445
  1644
                this, SLOT(callMacro()));
insilmaril@445
  1645
	}			
insilmaril@445
  1646
	macroActions[0]->setShortcut ( Qt::Key_F1 );
insilmaril@445
  1647
	macroActions[1]->setShortcut ( Qt::Key_F2 );
insilmaril@445
  1648
	macroActions[2]->setShortcut ( Qt::Key_F3 );
insilmaril@445
  1649
	macroActions[3]->setShortcut ( Qt::Key_F4 );
insilmaril@445
  1650
	macroActions[4]->setShortcut ( Qt::Key_F5 );
insilmaril@445
  1651
	macroActions[5]->setShortcut ( Qt::Key_F6 );
insilmaril@445
  1652
	macroActions[6]->setShortcut ( Qt::Key_F7 );
insilmaril@445
  1653
	macroActions[7]->setShortcut ( Qt::Key_F8 );
insilmaril@445
  1654
	macroActions[8]->setShortcut ( Qt::Key_F9 );
insilmaril@445
  1655
	macroActions[9]->setShortcut ( Qt::Key_F10 );
insilmaril@445
  1656
	macroActions[10]->setShortcut ( Qt::Key_F11 );
insilmaril@445
  1657
	macroActions[11]->setShortcut ( Qt::Key_F12 );
insilmaril@0
  1658
}
insilmaril@0
  1659
insilmaril@0
  1660
void Main::hideEvent (QHideEvent * )
insilmaril@0
  1661
{
insilmaril@0
  1662
	if (!textEditor->isMinimized() ) textEditor->hide();
insilmaril@0
  1663
}
insilmaril@0
  1664
insilmaril@0
  1665
void Main::showEvent (QShowEvent * )
insilmaril@0
  1666
{
insilmaril@491
  1667
	if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
insilmaril@0
  1668
}
insilmaril@0
  1669
insilmaril@0
  1670
insilmaril@0
  1671
MapEditor* Main::currentMapEditor() const
insilmaril@0
  1672
{
insilmaril@0
  1673
    if ( tabWidget->currentPage() &&
insilmaril@0
  1674
	 tabWidget->currentPage()->inherits( "MapEditor" ) )
insilmaril@0
  1675
		return (MapEditor*)tabWidget->currentPage();
insilmaril@0
  1676
    return NULL;	
insilmaril@0
  1677
}
insilmaril@0
  1678
insilmaril@0
  1679
insilmaril@0
  1680
void Main::editorChanged(QWidget *)
insilmaril@0
  1681
{
insilmaril@0
  1682
	// Unselect all possibly selected objects
insilmaril@0
  1683
	// (Important to update note editor)
insilmaril@0
  1684
	MapEditor *me;
insilmaril@473
  1685
	for (int i=0;i<=tabWidget->count() -1;i++)
insilmaril@0
  1686
	{
insilmaril@0
  1687
		
insilmaril@0
  1688
		me=(MapEditor*)tabWidget->page(i);
insilmaril@0
  1689
		me->unselect();
insilmaril@0
  1690
	}	
insilmaril@0
  1691
	currentMapEditor()->reselect();
insilmaril@0
  1692
insilmaril@0
  1693
	// Update actions to in menus and toolbars according to editor
insilmaril@407
  1694
	updateActions();
insilmaril@0
  1695
}
insilmaril@0
  1696
insilmaril@0
  1697
void Main::fileNew()
insilmaril@0
  1698
{
insilmaril@0
  1699
	QString fn="unnamed";
insilmaril@408
  1700
	MapEditor* me = new MapEditor ( NULL);
insilmaril@408
  1701
	tabWidget->addTab (me,fn);
insilmaril@408
  1702
	tabWidget->showPage(me);
insilmaril@408
  1703
	me->viewport()->setFocus();
insilmaril@408
  1704
	me->setAntiAlias (actionViewToggleAntiAlias->isOn());
insilmaril@408
  1705
	me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
insilmaril@408
  1706
	
insilmaril@366
  1707
	// For the very first map we do not have flagrows yet...
insilmaril@408
  1708
	me->select("mc:");
insilmaril@0
  1709
}
insilmaril@0
  1710
insilmaril@491
  1711
void Main::fileNewCopy()
insilmaril@491
  1712
{
insilmaril@491
  1713
	QString fn="unnamed";
insilmaril@491
  1714
	MapEditor* oldME =currentMapEditor();
insilmaril@491
  1715
	if (oldME)
insilmaril@491
  1716
	{
insilmaril@491
  1717
		oldME->copy();
insilmaril@491
  1718
		MapEditor* newME = new MapEditor ( NULL);
insilmaril@491
  1719
		if (newME)
insilmaril@491
  1720
		{
insilmaril@491
  1721
			tabWidget->addTab (newME,fn);
insilmaril@491
  1722
			tabWidget->showPage(newME);
insilmaril@491
  1723
			newME->viewport()->setFocus();
insilmaril@491
  1724
			newME->setAntiAlias (actionViewToggleAntiAlias->isOn());
insilmaril@491
  1725
			newME->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
insilmaril@491
  1726
			// For the very first map we do not have flagrows yet...
insilmaril@491
  1727
			newME->select("mc:");
insilmaril@571
  1728
			newME->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
insilmaril@491
  1729
		}
insilmaril@491
  1730
insilmaril@491
  1731
	}
insilmaril@491
  1732
}
insilmaril@491
  1733
insilmaril@571
  1734
ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
insilmaril@0
  1735
{
insilmaril@205
  1736
	ErrorCode err=success;
insilmaril@0
  1737
	
insilmaril@0
  1738
	// fn is usually the archive, mapfile the file after uncompressing
insilmaril@0
  1739
	QString mapfile;
insilmaril@0
  1740
insilmaril@0
  1741
	// Make fn absolute (needed for unzip)
insilmaril@0
  1742
	fn=QDir (fn).absPath();
insilmaril@0
  1743
insilmaril@0
  1744
	MapEditor *me;
insilmaril@0
  1745
insilmaril@0
  1746
	if (lmode==NewMap)
insilmaril@0
  1747
	{
insilmaril@0
  1748
		// Check, if map is already loaded
insilmaril@0
  1749
		int i=0;
insilmaril@0
  1750
		while (i<=tabWidget->count() -1)
insilmaril@0
  1751
		{
insilmaril@0
  1752
			me=(MapEditor*)tabWidget->page(i);
insilmaril@0
  1753
			if (me->getFilePath() == fn)
insilmaril@0
  1754
			{
insilmaril@0
  1755
				// Already there, ask for confirmation
insilmaril@404
  1756
				QMessageBox mb( vymName,
insilmaril@159
  1757
					tr("The map %1\nis already opened."
insilmaril@0
  1758
					"Opening the same map in multiple editors may lead \n"
insilmaril@0
  1759
					"to confusion when finishing working with vym."
insilmaril@159
  1760
					"Do you want to").arg(fn),
insilmaril@0
  1761
					QMessageBox::Warning,
insilmaril@0
  1762
					QMessageBox::Yes | QMessageBox::Default,
insilmaril@0
  1763
					QMessageBox::Cancel | QMessageBox::Escape,
insilmaril@366
  1764
					QMessageBox::NoButton);
insilmaril@0
  1765
				mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
insilmaril@0
  1766
				mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
insilmaril@0
  1767
				switch( mb.exec() ) 
insilmaril@0
  1768
				{
insilmaril@0
  1769
					case QMessageBox::Yes:
insilmaril@0
  1770
						// load anyway
insilmaril@0
  1771
						i=tabWidget->count();
insilmaril@0
  1772
						break;
insilmaril@0
  1773
					case QMessageBox::Cancel:
insilmaril@0
  1774
						// do nothing
insilmaril@205
  1775
						return aborted;
insilmaril@0
  1776
						break;
insilmaril@0
  1777
				}
insilmaril@0
  1778
			}
insilmaril@0
  1779
			i++;
insilmaril@0
  1780
		}
insilmaril@0
  1781
	}
insilmaril@0
  1782
insilmaril@0
  1783
insilmaril@0
  1784
	// Try to load map
insilmaril@0
  1785
    if ( !fn.isEmpty() )
insilmaril@0
  1786
	{
insilmaril@0
  1787
		me = currentMapEditor();
insilmaril@0
  1788
		int tabIndex=tabWidget->currentPageIndex();
insilmaril@0
  1789
		// Check first, if mapeditor exists
insilmaril@0
  1790
		// If it is not default AND we want a new map, 
insilmaril@0
  1791
		// create a new mapeditor in a new tab
insilmaril@0
  1792
		if ( lmode==NewMap && (!me || !me->isDefault() ) )
insilmaril@0
  1793
		{
insilmaril@390
  1794
			me= new MapEditor ( NULL);
insilmaril@0
  1795
			tabWidget->addTab (me,fn);
insilmaril@0
  1796
			tabIndex=tabWidget->indexOf (me);
insilmaril@0
  1797
			tabWidget->setCurrentPage (tabIndex);
insilmaril@408
  1798
			me->setAntiAlias (actionViewToggleAntiAlias->isOn());
insilmaril@408
  1799
			me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
insilmaril@0
  1800
		}
insilmaril@0
  1801
		
insilmaril@0
  1802
		// Check, if file exists (important for creating new files
insilmaril@0
  1803
		// from command line
insilmaril@0
  1804
		if (!QFile(fn).exists() )
insilmaril@0
  1805
		{
insilmaril@404
  1806
			QMessageBox mb( vymName,
insilmaril@159
  1807
				tr("This map does not exist:\n  %1\nDo you want to create a new one?").arg(fn),
insilmaril@0
  1808
				QMessageBox::Question,
insilmaril@0
  1809
				QMessageBox::Yes ,
insilmaril@0
  1810
				QMessageBox::Cancel | QMessageBox::Default,
insilmaril@366
  1811
				QMessageBox::NoButton );
insilmaril@0
  1812
insilmaril@0
  1813
			mb.setButtonText( QMessageBox::Yes, tr("Create"));
insilmaril@0
  1814
			mb.setButtonText( QMessageBox::No, tr("Cancel"));
insilmaril@0
  1815
			switch( mb.exec() ) 
insilmaril@0
  1816
			{
insilmaril@0
  1817
				case QMessageBox::Yes:
insilmaril@0
  1818
					// Create new map
insilmaril@0
  1819
					currentMapEditor()->setFilePath(fn);
insilmaril@0
  1820
					tabWidget->setTabLabel (currentMapEditor(),
insilmaril@0
  1821
						currentMapEditor()->getFileName() );
insilmaril@0
  1822
					statusBar()->message( "Created " + fn , statusbarTime );
insilmaril@205
  1823
					return success;
insilmaril@0
  1824
						
insilmaril@0
  1825
				case QMessageBox::Cancel:
insilmaril@0
  1826
					// don't create new map
insilmaril@0
  1827
					statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
insilmaril@0
  1828
					fileCloseMap();
insilmaril@205
  1829
					return aborted;
insilmaril@0
  1830
			}
insilmaril@0
  1831
		}	
insilmaril@0
  1832
insilmaril@0
  1833
insilmaril@0
  1834
		//tabWidget->currentPage() won't be NULL here, because of above...
insilmaril@0
  1835
		tabWidget->showPage(me);
insilmaril@0
  1836
		me->viewport()->setFocus();
insilmaril@0
  1837
insilmaril@0
  1838
		// Create temporary directory for packing
insilmaril@377
  1839
		bool ok;
insilmaril@625
  1840
		QString tmpZipDir=makeTmpDir (ok,"vym-pack");
insilmaril@377
  1841
		if (!ok)
insilmaril@377
  1842
		{
insilmaril@377
  1843
			QMessageBox::critical( 0, tr( "Critical Load Error" ),
insilmaril@377
  1844
			   tr("Couldn't create temporary directory before load\n"));
insilmaril@377
  1845
			return aborted; 
insilmaril@377
  1846
		}
insilmaril@0
  1847
insilmaril@0
  1848
		// Try to unzip file
insilmaril@625
  1849
		err=unzipDir (tmpZipDir,fn);
insilmaril@185
  1850
		if (err==nozip)
insilmaril@0
  1851
		{
insilmaril@185
  1852
			mapfile=fn;
insilmaril@185
  1853
			me->setZipped(false);
insilmaril@0
  1854
		} else
insilmaril@0
  1855
		{
insilmaril@185
  1856
			me->setZipped(true);
insilmaril@185
  1857
			
insilmaril@185
  1858
			// Look for mapname.xml
insilmaril@185
  1859
			mapfile= fn.left(fn.findRev(".",-1,true));
insilmaril@185
  1860
			mapfile=mapfile.section( '/', -1 );
insilmaril@625
  1861
			QFile file( tmpZipDir + "/" + mapfile + ".xml");
insilmaril@185
  1862
			if (!file.exists() )
insilmaril@0
  1863
			{
insilmaril@185
  1864
				// mapname.xml does not exist, well, 
insilmaril@428
  1865
				// maybe someone renamed the mapname.vym file...
insilmaril@185
  1866
				// Try to find any .xml in the toplevel 
insilmaril@185
  1867
				// directory of the .vym file
insilmaril@625
  1868
				QStringList flist=QDir (tmpZipDir).entryList("*.xml");
insilmaril@185
  1869
				if (flist.count()==1) 
insilmaril@0
  1870
				{
insilmaril@185
  1871
					// Only one entry, take this one
insilmaril@625
  1872
					mapfile=tmpZipDir + "/"+flist.first();
insilmaril@0
  1873
				} else
insilmaril@185
  1874
				{
insilmaril@185
  1875
					for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it ) 
insilmaril@625
  1876
						*it=tmpZipDir + "/" + *it;
insilmaril@185
  1877
					// TODO Multiple entries, load all (but only the first one into this ME)
insilmaril@185
  1878
					//mainWindow->fileLoadFromTmp (flist);
insilmaril@185
  1879
					//returnCode=1;	// Silently forget this attempt to load
insilmaril@185
  1880
					qWarning ("MainWindow::load (fn)  multimap found...");
insilmaril@185
  1881
				}	
insilmaril@0
  1882
					
insilmaril@185
  1883
				if (flist.isEmpty() )
insilmaril@185
  1884
				{
insilmaril@185
  1885
					QMessageBox::critical( 0, tr( "Critical Load Error" ),
insilmaril@185
  1886
							   tr("Couldn't find a map (*.xml) in .vym archive.\n"));
insilmaril@185
  1887
					err=aborted;				   
insilmaril@185
  1888
				}	
insilmaril@185
  1889
			} //file doesn't exist	
insilmaril@185
  1890
			else
insilmaril@185
  1891
				mapfile=file.name();
insilmaril@0
  1892
		}
insilmaril@0
  1893
insilmaril@185
  1894
		if (err!=aborted)
insilmaril@185
  1895
		{
insilmaril@185
  1896
			// Save existing filename in case  we import
insilmaril@185
  1897
			QString fn_org=me->getFilePath();
insilmaril@106
  1898
insilmaril@185
  1899
			// Finally load map into mapEditor
insilmaril@185
  1900
			me->setFilePath (mapfile,fn);
insilmaril@571
  1901
			err=me->load(mapfile,lmode,ftype);
insilmaril@106
  1902
insilmaril@185
  1903
			// Restore old (maybe empty) filepath, if this is an import
insilmaril@185
  1904
			if (lmode!=NewMap)
insilmaril@185
  1905
				me->setFilePath (fn_org);
insilmaril@185
  1906
		}	
insilmaril@0
  1907
insilmaril@185
  1908
		// Finally check for errors and go home
insilmaril@185
  1909
		if (err==aborted) 
insilmaril@185
  1910
		{
insilmaril@185
  1911
			if (lmode==NewMap) fileCloseMap();
insilmaril@185
  1912
			statusBar()->message( "Could not load " + fn, statusbarTime );
insilmaril@185
  1913
		} else 
insilmaril@0
  1914
		{
insilmaril@0
  1915
			if (lmode==NewMap)
insilmaril@0
  1916
			{
insilmaril@0
  1917
				me->setFilePath (fn);
insilmaril@0
  1918
				tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
insilmaril@608
  1919
				if (!isInTmpDir (fn))
insilmaril@205
  1920
				{
insilmaril@205
  1921
					// Only append to lastMaps if not loaded from a tmpDir
insilmaril@205
  1922
					// e.g. imported bookmarks are in a tmpDir
insilmaril@401
  1923
					addRecentMap(me->getFilePath() );
insilmaril@205
  1924
				}
insilmaril@0
  1925
				actionFilePrint->setEnabled (true);
insilmaril@0
  1926
			}	
insilmaril@0
  1927
			statusBar()->message( "Loaded " + fn, statusbarTime );
insilmaril@0
  1928
		}	
insilmaril@0
  1929
insilmaril@185
  1930
		// Delete tmpDir
insilmaril@625
  1931
		removeDir (QDir(tmpZipDir));
insilmaril@0
  1932
	}
insilmaril@205
  1933
	return err;
insilmaril@0
  1934
}
insilmaril@0
  1935
insilmaril@0
  1936
insilmaril@0
  1937
void Main::fileLoad(const LoadMode &lmode)
insilmaril@0
  1938
{
insilmaril@377
  1939
	QStringList filters;
insilmaril@389
  1940
	filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
insilmaril@377
  1941
	QFileDialog *fd=new QFileDialog( this);
insilmaril@366
  1942
	fd->setDir (lastFileDir);
insilmaril@377
  1943
	fd->setFileMode (QFileDialog::ExistingFiles);
insilmaril@377
  1944
	fd->setFilters (filters);
insilmaril@0
  1945
	switch (lmode)
insilmaril@0
  1946
	{
insilmaril@0
  1947
		case NewMap:
insilmaril@404
  1948
			fd->setCaption(vymName+ " - " +tr("Load vym map"));
insilmaril@0
  1949
			break;
insilmaril@0
  1950
		case ImportAdd:
insilmaril@404
  1951
			fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
insilmaril@0
  1952
			break;
insilmaril@0
  1953
		case ImportReplace:
insilmaril@404
  1954
			fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
insilmaril@0
  1955
			break;
insilmaril@0
  1956
	}
insilmaril@0
  1957
	fd->show();
insilmaril@0
  1958
insilmaril@0
  1959
	QString fn;
insilmaril@0
  1960
	if ( fd->exec() == QDialog::Accepted )
insilmaril@0
  1961
	{
insilmaril@377
  1962
		lastFileDir=fd->directory().path();
insilmaril@185
  1963
	    QStringList flist = fd->selectedFiles();
insilmaril@185
  1964
		QStringList::Iterator it = flist.begin();
insilmaril@185
  1965
		while( it != flist.end() ) 
insilmaril@185
  1966
		{
insilmaril@185
  1967
			fn = *it;
insilmaril@185
  1968
			fileLoad(*it, lmode);				   
insilmaril@185
  1969
			++it;
insilmaril@185
  1970
		}
insilmaril@0
  1971
	}
insilmaril@185
  1972
	delete (fd);
insilmaril@0
  1973
}
insilmaril@0
  1974
insilmaril@0
  1975
void Main::fileLoad()
insilmaril@0
  1976
{
insilmaril@0
  1977
	fileLoad (NewMap);
insilmaril@0
  1978
}
insilmaril@0
  1979
insilmaril@401
  1980
void Main::fileLoadRecent()
insilmaril@0
  1981
{
insilmaril@401
  1982
    QAction *action = qobject_cast<QAction *>(sender());
insilmaril@401
  1983
    if (action)
insilmaril@401
  1984
        fileLoad (action->data().toString(), NewMap);
insilmaril@401
  1985
}
insilmaril@401
  1986
insilmaril@401
  1987
void Main::addRecentMap (const QString &fileName)
insilmaril@401
  1988
{
insilmaril@401
  1989
insilmaril@401
  1990
    QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
insilmaril@401
  1991
    files.removeAll(fileName);
insilmaril@401
  1992
    files.prepend(fileName);
insilmaril@401
  1993
    while (files.size() > MaxRecentFiles)
insilmaril@401
  1994
        files.removeLast();
insilmaril@401
  1995
insilmaril@401
  1996
    settings.setValue("/mainwindow/recentFileList", files);
insilmaril@401
  1997
insilmaril@401
  1998
	setupRecentMapsMenu();
insilmaril@0
  1999
}
insilmaril@0
  2000
insilmaril@473
  2001
void Main::fileSave(MapEditor *me, const SaveMode &savemode)
insilmaril@0
  2002
{
insilmaril@0
  2003
	// tmp dir for zipping 
insilmaril@625
  2004
	QString tmpZipDir;
insilmaril@0
  2005
	
insilmaril@0
  2006
	// Error codes
insilmaril@205
  2007
	ErrorCode err=success;
insilmaril@0
  2008
	
insilmaril@0
  2009
	QString safeFilePath;
insilmaril@0
  2010
insilmaril@473
  2011
	bool saveZipped=me->saveZipped();
insilmaril@473
  2012
insilmaril@151
  2013
	if (me)
insilmaril@0
  2014
	{
insilmaril@151
  2015
		QString fn=me->getFilePath();
insilmaril@473
  2016
		// filename=unnamed, filepath="" in constructor of mapEditor
insilmaril@0
  2017
		if ( !fn.isEmpty() ) 
insilmaril@0
  2018
		{	
insilmaril@0
  2019
			// We have a filepath, go on saving			
insilmaril@0
  2020
insilmaril@0
  2021
			// Look, if we should zip the data:
insilmaril@0
  2022
			if (!saveZipped)
insilmaril@0
  2023
			{
insilmaril@404
  2024
				QMessageBox mb( vymName,
insilmaril@159
  2025
					tr("The map %1\ndid not use the compressed "
insilmaril@0
  2026
					"vym file format.\nWriting it uncompressed will also write images \n"
insilmaril@0
  2027
					"and flags and thus may overwrite files in the "
insilmaril@159
  2028
					"given directory\n\nDo you want to write the map").arg(fn),
insilmaril@0
  2029
					QMessageBox::Warning,
insilmaril@0
  2030
					QMessageBox::Yes | QMessageBox::Default,
insilmaril@0
  2031
					QMessageBox::No ,
insilmaril@0
  2032
					QMessageBox::Cancel | QMessageBox::Escape);
insilmaril@0
  2033
				mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
insilmaril@0
  2034
				mb.setButtonText( QMessageBox::No, tr("uncompressed") );
insilmaril@0
  2035
				mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
insilmaril@0
  2036
				switch( mb.exec() ) 
insilmaril@0
  2037
				{
insilmaril@0
  2038
					case QMessageBox::Yes:
insilmaril@0
  2039
						// save compressed (default file format)
insilmaril@0
  2040
						saveZipped=true;
insilmaril@0
  2041
						break;
insilmaril@0
  2042
					case QMessageBox::No:
insilmaril@0
  2043
						// save uncompressed
insilmaril@0
  2044
						saveZipped=false;
insilmaril@0
  2045
						break;
insilmaril@0
  2046
					case QMessageBox::Cancel:
insilmaril@0
  2047
						// do nothing
insilmaril@0
  2048
						return;
insilmaril@0
  2049
						break;
insilmaril@0
  2050
				}
insilmaril@615
  2051
				me->setZipped (saveZipped);
insilmaril@0
  2052
			}
insilmaril@0
  2053
insilmaril@625
  2054
			// First backup existing file, we 
insilmaril@625
  2055
			// don't want to add to old zip archives
insilmaril@625
  2056
			QFile f(fn);
insilmaril@625
  2057
			if (f.exists())
insilmaril@625
  2058
            {
insilmaril@625
  2059
				if (actionSettingsWriteBackupFile->isOn())
insilmaril@625
  2060
				{
insilmaril@625
  2061
					QString bfn(fn + "~");
insilmaril@625
  2062
					QFile bf(bfn);
insilmaril@625
  2063
					if (bf.exists() && !bf.remove())
insilmaril@625
  2064
					{
insilmaril@625
  2065
						QMessageBox::warning(0, tr("Save Error"),
insilmaril@625
  2066
											 bfn + tr("\ncould not be removed before saving"));
insilmaril@625
  2067
					}
insilmaril@625
  2068
					else if (!f.rename(bfn))
insilmaril@625
  2069
					{
insilmaril@625
  2070
						QMessageBox::warning(0, tr("Save Error"),
insilmaril@625
  2071
											 fn + tr("\ncould not be renamed before saving"));
insilmaril@625
  2072
					}
insilmaril@625
  2073
				}
insilmaril@625
  2074
            }
insilmaril@625
  2075
insilmaril@0
  2076
			if (saveZipped)
insilmaril@0
  2077
			{
insilmaril@377
  2078
				// Create temporary directory for packing
insilmaril@377
  2079
				bool ok;
insilmaril@625
  2080
				tmpZipDir=makeTmpDir (ok,"vym-zip");
insilmaril@377
  2081
				if (!ok)
insilmaril@377
  2082
				{
insilmaril@377
  2083
					QMessageBox::critical( 0, tr( "Critical Load Error" ),
insilmaril@377
  2084
					   tr("Couldn't create temporary directory before save\n"));
insilmaril@377
  2085
					return; 
insilmaril@377
  2086
				}
insilmaril@377
  2087
insilmaril@151
  2088
				safeFilePath=me->getFilePath();
insilmaril@625
  2089
				me->setFilePath (tmpZipDir+"/"+
insilmaril@151
  2090
					me->getMapName()+ ".xml",
insilmaril@0
  2091
					safeFilePath);
insilmaril@151
  2092
				me->save (savemode);
insilmaril@151
  2093
				me->setFilePath (safeFilePath);
insilmaril@0
  2094
				
insilmaril@625
  2095
				zipDir (tmpZipDir,fn);
insilmaril@0
  2096
			} // save zipped
insilmaril@0
  2097
			else
insilmaril@0
  2098
			{
insilmaril@0
  2099
				// Save unzipped. 
insilmaril@151
  2100
				safeFilePath=me->getFilePath();
insilmaril@151
  2101
				me->setFilePath (fn, safeFilePath);
insilmaril@151
  2102
				me->save (savemode);
insilmaril@151
  2103
				me->setFilePath (safeFilePath);
insilmaril@0
  2104
			} // save zipped 	
insilmaril@0
  2105
		} // filepath available
insilmaril@0
  2106
		else
insilmaril@0
  2107
		{
insilmaril@0
  2108
			// We have  no filepath yet,
insilmaril@0
  2109
			// call fileSaveAs() now, this will call fileSave() 
insilmaril@0
  2110
			// again.
insilmaril@473
  2111
			// First switch to editor
insilmaril@473
  2112
			tabWidget->setCurrentWidget (me);
insilmaril@0
  2113
			fileSaveAs(savemode);
insilmaril@0
  2114
		}
insilmaril@0
  2115
    }
insilmaril@0
  2116
insilmaril@625
  2117
	if (saveZipped && !tmpZipDir.isEmpty())
insilmaril@0
  2118
		// Delete tmpDir
insilmaril@625
  2119
		removeDir (QDir(tmpZipDir));
insilmaril@0
  2120
insilmaril@0
  2121
	if (err==success)
insilmaril@151
  2122
	{
insilmaril@0
  2123
		statusBar()->message( 
insilmaril@159
  2124
			tr("Saved  %1").arg(me->getFilePath()), 
insilmaril@0
  2125
			statusbarTime );
insilmaril@401
  2126
		addRecentMap (me->getFilePath() );
insilmaril@151
  2127
	} else		
insilmaril@0
  2128
		statusBar()->message( 
insilmaril@159
  2129
			tr("Couldn't save ").arg(me->getFilePath()), 
insilmaril@0
  2130
			statusbarTime );
insilmaril@0
  2131
}
insilmaril@0
  2132
insilmaril@0
  2133
void Main::fileSave()
insilmaril@0
  2134
{
insilmaril@473
  2135
	fileSave (currentMapEditor(), CompleteMap);
insilmaril@473
  2136
}
insilmaril@473
  2137
insilmaril@473
  2138
void Main::fileSave(MapEditor *me)
insilmaril@473
  2139
{
insilmaril@473
  2140
	fileSave (me,CompleteMap);
insilmaril@0
  2141
}
insilmaril@0
  2142
insilmaril@0
  2143
void Main::fileSaveAs(const SaveMode& savemode)
insilmaril@0
  2144
{
insilmaril@0
  2145
	QString fn;
insilmaril@0
  2146
insilmaril@0
  2147
	if (currentMapEditor())
insilmaril@0
  2148
	{
insilmaril@0
  2149
		if (savemode==CompleteMap)
insilmaril@366
  2150
			fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
insilmaril@0
  2151
		else		
insilmaril@366
  2152
			fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
insilmaril@0
  2153
		if ( !fn.isEmpty() ) 
insilmaril@0
  2154
		{
insilmaril@0
  2155
			// Check for existing file
insilmaril@0
  2156
			if (QFile (fn).exists())
insilmaril@0
  2157
			{
insilmaril@404
  2158
				QMessageBox mb( vymName,
insilmaril@159
  2159
					tr("The file %1\nexists already. Do you want to").arg(fn),
insilmaril@0
  2160
					QMessageBox::Warning,
insilmaril@0
  2161
					QMessageBox::Yes | QMessageBox::Default,
insilmaril@0
  2162
					QMessageBox::Cancel | QMessageBox::Escape,
insilmaril@366
  2163
					QMessageBox::NoButton);
insilmaril@0
  2164
				mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
insilmaril@0
  2165
				mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
insilmaril@0
  2166
				switch( mb.exec() ) 
insilmaril@0
  2167
				{
insilmaril@0
  2168
					case QMessageBox::Yes:
insilmaril@0
  2169
						// save 
insilmaril@0
  2170
						break;
insilmaril@0
  2171
					case QMessageBox::Cancel:
insilmaril@0
  2172
						// do nothing
insilmaril@0
  2173
						return;
insilmaril@0
  2174
						break;
insilmaril@0
  2175
				}
insilmaril@0
  2176
			} else
insilmaril@0
  2177
			{
insilmaril@0
  2178
				// New file, add extension to filename, if missing
insilmaril@0
  2179
				// This is always .vym or .vyp, depending on savemode
insilmaril@0
  2180
				if (savemode==CompleteMap)
insilmaril@0
  2181
				{
insilmaril@0
  2182
					if (!fn.contains (".vym") && !fn.contains (".xml"))
insilmaril@0
  2183
						fn +=".vym";
insilmaril@0
  2184
				} else		
insilmaril@0
  2185
				{
insilmaril@0
  2186
					if (!fn.contains (".vyp") && !fn.contains (".xml"))
insilmaril@0
  2187
						fn +=".vyp";
insilmaril@0
  2188
				}
insilmaril@0
  2189
			}
insilmaril@0
  2190
	
insilmaril@0
  2191
insilmaril@0
  2192
insilmaril@0
  2193
insilmaril@0
  2194
			// Save now
insilmaril@0
  2195
			currentMapEditor()->setFilePath(fn);
insilmaril@473
  2196
			fileSave(currentMapEditor(), savemode);
insilmaril@0
  2197
insilmaril@0
  2198
			// Set name of tab
insilmaril@94
  2199
			if (savemode==CompleteMap)
insilmaril@94
  2200
				tabWidget->setTabLabel (currentMapEditor(),
insilmaril@94
  2201
					currentMapEditor()->getFileName() );
insilmaril@0
  2202
			return;
insilmaril@0
  2203
		} 
insilmaril@0
  2204
	}
insilmaril@0
  2205
}
insilmaril@0
  2206
insilmaril@0
  2207
void Main::fileSaveAs()
insilmaril@0
  2208
{
insilmaril@0
  2209
	fileSaveAs (CompleteMap);
insilmaril@0
  2210
}
insilmaril@0
  2211
insilmaril@205
  2212
void Main::fileImportKDEBookmarks()
insilmaril@205
  2213
{
insilmaril@205
  2214
	ImportKDEBookmarks im;
insilmaril@205
  2215
	im.transform();
insilmaril@205
  2216
	if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
insilmaril@205
  2217
		currentMapEditor()->setFilePath ("");
insilmaril@205
  2218
}
insilmaril@205
  2219
insilmaril@314
  2220
void Main::fileImportFirefoxBookmarks()
insilmaril@314
  2221
{
insilmaril@366
  2222
	Q3FileDialog *fd=new Q3FileDialog( this);
insilmaril@327
  2223
	fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
insilmaril@366
  2224
	fd->setMode (Q3FileDialog::ExistingFiles);
insilmaril@327
  2225
	fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
insilmaril@327
  2226
	fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
insilmaril@327
  2227
	fd->show();
insilmaril@327
  2228
insilmaril@327
  2229
	if ( fd->exec() == QDialog::Accepted )
insilmaril@327
  2230
	{
insilmaril@327
  2231
		ImportFirefoxBookmarks im;
insilmaril@327
  2232
	    QStringList flist = fd->selectedFiles();
insilmaril@327
  2233
		QStringList::Iterator it = flist.begin();
insilmaril@327
  2234
		while( it != flist.end() ) 
insilmaril@327
  2235
		{
insilmaril@327
  2236
			im.setFile (*it);
insilmaril@327
  2237
			if (im.transform() && 
insilmaril@571
  2238
				success==fileLoad (im.getTransformedFile(),NewMap,FreemindMap) && 
insilmaril@327
  2239
				currentMapEditor() )
insilmaril@327
  2240
				currentMapEditor()->setFilePath ("");
insilmaril@327
  2241
			++it;
insilmaril@327
  2242
		}
insilmaril@327
  2243
	}
insilmaril@327
  2244
	delete (fd);
insilmaril@314
  2245
}
insilmaril@314
  2246
insilmaril@571
  2247
void Main::fileImportFreemind()
insilmaril@571
  2248
{
insilmaril@571
  2249
	QStringList filters;
insilmaril@571
  2250
	filters <<"Freemind map (*.mm)"<<"All files (*)";
insilmaril@571
  2251
	QFileDialog *fd=new QFileDialog( this);
insilmaril@571
  2252
	fd->setDir (lastFileDir);
insilmaril@571
  2253
	fd->setFileMode (QFileDialog::ExistingFiles);
insilmaril@571
  2254
	fd->setFilters (filters);
insilmaril@571
  2255
	fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
insilmaril@571
  2256
	fd->show();
insilmaril@571
  2257
insilmaril@571
  2258
	QString fn;
insilmaril@571
  2259
	if ( fd->exec() == QDialog::Accepted )
insilmaril@571
  2260
	{
insilmaril@571
  2261
		lastFileDir=fd->directory().path();
insilmaril@571
  2262
	    QStringList flist = fd->selectedFiles();
insilmaril@571
  2263
		QStringList::Iterator it = flist.begin();
insilmaril@571
  2264
		while( it != flist.end() ) 
insilmaril@571
  2265
		{
insilmaril@571
  2266
			fn = *it;
insilmaril@571
  2267
			if ( fileLoad (fn,NewMap, FreemindMap)  )
insilmaril@571
  2268
			{	
insilmaril@571
  2269
				currentMapEditor()->setFilePath ("");
insilmaril@571
  2270
			}	
insilmaril@571
  2271
			++it;
insilmaril@571
  2272
		}
insilmaril@571
  2273
	}
insilmaril@571
  2274
	delete (fd);
insilmaril@571
  2275
}
insilmaril@571
  2276
insilmaril@571
  2277
insilmaril@215
  2278
void Main::fileImportMM()
insilmaril@215
  2279
{
insilmaril@215
  2280
	ImportMM im;
insilmaril@215
  2281
insilmaril@366
  2282
	Q3FileDialog *fd=new Q3FileDialog( this);
insilmaril@366
  2283
	fd->setDir (lastFileDir);
insilmaril@366
  2284
	fd->setMode (Q3FileDialog::ExistingFiles);
insilmaril@215
  2285
	fd->addFilter ("Mind Manager (*.mmap)");
insilmaril@215
  2286
	fd->setCaption(tr("Import")+" "+"Mind Manager");
insilmaril@215
  2287
	fd->show();
insilmaril@215
  2288
insilmaril@215
  2289
	if ( fd->exec() == QDialog::Accepted )
insilmaril@215
  2290
	{
insilmaril@215
  2291
		lastFileDir=fd->dirPath();
insilmaril@215
  2292
	    QStringList flist = fd->selectedFiles();
insilmaril@215
  2293
		QStringList::Iterator it = flist.begin();
insilmaril@215
  2294
		while( it != flist.end() ) 
insilmaril@215
  2295
		{
insilmaril@215
  2296
			im.setFile (*it);
insilmaril@215
  2297
			if (im.transform() && 
insilmaril@215
  2298
				success==fileLoad (im.getTransformedFile(),NewMap) && 
insilmaril@215
  2299
				currentMapEditor() )
insilmaril@215
  2300
				currentMapEditor()->setFilePath ("");
insilmaril@215
  2301
insilmaril@215
  2302
			++it;
insilmaril@215
  2303
		}
insilmaril@215
  2304
	}
insilmaril@215
  2305
	delete (fd);
insilmaril@215
  2306
insilmaril@215
  2307
}
insilmaril@215
  2308
insilmaril@215
  2309
void Main::fileImportDir()
insilmaril@215
  2310
{
insilmaril@215
  2311
	if (currentMapEditor())
insilmaril@215
  2312
		currentMapEditor()->importDir();	
insilmaril@215
  2313
}
insilmaril@215
  2314
insilmaril@526
  2315
void Main::fileExportXML()	
insilmaril@0
  2316
{
insilmaril@526
  2317
	MapEditor *me=currentMapEditor();
insilmaril@526
  2318
	if (me) me->exportXML();
insilmaril@0
  2319
}
insilmaril@0
  2320
insilmaril@0
  2321
insilmaril@517
  2322
void Main::fileExportXHTML()	
insilmaril@0
  2323
{
insilmaril@260
  2324
	MapEditor *me=currentMapEditor();
insilmaril@517
  2325
	if (me) me->exportXHTML();
insilmaril@0
  2326
}
insilmaril@0
  2327
insilmaril@517
  2328
void Main::fileExportImage()	
insilmaril@0
  2329
{
insilmaril@260
  2330
	MapEditor *me=currentMapEditor();
insilmaril@514
  2331
	if (me) me->exportImage();
insilmaril@0
  2332
}
insilmaril@0
  2333
insilmaril@0
  2334
void Main::fileExportASCII()
insilmaril@0
  2335
{
insilmaril@260
  2336
	MapEditor *me=currentMapEditor();
insilmaril@514
  2337
	if (me) me->exportASCII();
insilmaril@0
  2338
}
insilmaril@0
  2339
insilmaril@517
  2340
void Main::fileExportCSV()	//FIXME not scriptable yet
insilmaril@497
  2341
{
insilmaril@497
  2342
	MapEditor *me=currentMapEditor();
insilmaril@497
  2343
	if (me)
insilmaril@497
  2344
	{
insilmaril@497
  2345
		ExportCSV ex;
insilmaril@645
  2346
		ex.setModel (me->getModel());
insilmaril@497
  2347
		ex.addFilter ("CSV (*.csv)");
insilmaril@497
  2348
		ex.setDir(lastImageDir);
insilmaril@497
  2349
		ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
insilmaril@497
  2350
		if (ex.execDialog() ) 
insilmaril@497
  2351
		{
insilmaril@497
  2352
			me->setExportMode(true);
insilmaril@497
  2353
			ex.doExport();
insilmaril@497
  2354
			me->setExportMode(false);
insilmaril@497
  2355
		}
insilmaril@497
  2356
	}
insilmaril@497
  2357
}
insilmaril@497
  2358
insilmaril@517
  2359
void Main::fileExportLaTeX()	//FIXME not scriptable yet
insilmaril@163
  2360
{
insilmaril@260
  2361
	MapEditor *me=currentMapEditor();
insilmaril@260
  2362
	if (me)
insilmaril@228
  2363
	{
insilmaril@228
  2364
		ExportLaTeX ex;
insilmaril@645
  2365
		ex.setModel (me->getModel());
insilmaril@228
  2366
		ex.addFilter ("Tex (*.tex)");
insilmaril@424
  2367
		ex.setDir(lastImageDir);
insilmaril@404
  2368
		ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
insilmaril@260
  2369
		if (ex.execDialog() ) 
insilmaril@260
  2370
		{
insilmaril@260
  2371
			me->setExportMode(true);
insilmaril@260
  2372
			ex.doExport();
insilmaril@260
  2373
			me->setExportMode(false);
insilmaril@260
  2374
		}
insilmaril@228
  2375
	}
insilmaril@228
  2376
}
insilmaril@228
  2377
insilmaril@517
  2378
void Main::fileExportKDEBookmarks()	//FIXME not scriptable yet
insilmaril@243
  2379
{
insilmaril@243
  2380
	ExportKDEBookmarks ex;
insilmaril@260
  2381
	MapEditor *me=currentMapEditor();
insilmaril@260
  2382
	if (me)
insilmaril@243
  2383
	{
insilmaril@645
  2384
		ex.setModel (me->getModel());
insilmaril@243
  2385
		ex.doExport();
insilmaril@243
  2386
	}	
insilmaril@243
  2387
}
insilmaril@243
  2388
insilmaril@517
  2389
void Main::fileExportTaskjuggler()	//FIXME not scriptable yet
insilmaril@228
  2390
{
insilmaril@228
  2391
	ExportTaskjuggler ex;
insilmaril@260
  2392
	MapEditor *me=currentMapEditor();
insilmaril@260
  2393
	if (me)
insilmaril@228
  2394
	{
insilmaril@645
  2395
		ex.setModel (me->getModel());
insilmaril@404
  2396
		ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
insilmaril@424
  2397
		ex.setDir(lastImageDir);
insilmaril@243
  2398
		ex.addFilter ("Taskjuggler (*.tjp)");
insilmaril@260
  2399
		if (ex.execDialog() ) 
insilmaril@260
  2400
		{
insilmaril@260
  2401
			me->setExportMode(true);
insilmaril@260
  2402
			ex.doExport();
insilmaril@260
  2403
			me->setExportMode(false);
insilmaril@260
  2404
		}
insilmaril@228
  2405
	}	
insilmaril@163
  2406
}
insilmaril@163
  2407
insilmaril@517
  2408
void Main::fileExportOOPresentation()	//FIXME not scriptable yet
insilmaril@163
  2409
{
insilmaril@404
  2410
	ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
insilmaril@366
  2411
	// TODO add preview in dialog
insilmaril@185
  2412
	//ImagePreview *p =new ImagePreview (fd);
insilmaril@185
  2413
	//fd->setContentsPreviewEnabled( TRUE );
insilmaril@185
  2414
	//fd->setContentsPreview( p, p );
insilmaril@185
  2415
	//fd->setPreviewMode( QFileDialog::Contents );
insilmaril@404
  2416
	fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
insilmaril@366
  2417
	fd->setDir (QDir().current());
insilmaril@357
  2418
	if (fd->foundConfig())
insilmaril@357
  2419
	{
insilmaril@357
  2420
		fd->show();
insilmaril@185
  2421
insilmaril@357
  2422
		if ( fd->exec() == QDialog::Accepted )
insilmaril@357
  2423
		{
insilmaril@357
  2424
			QString fn=fd->selectedFile();
insilmaril@366
  2425
			if (!fn.contains (".odp"))
insilmaril@366
  2426
				fn +=".odp";
insilmaril@366
  2427
insilmaril@357
  2428
			//lastImageDir=fn.left(fn.findRev ("/"));
insilmaril@357
  2429
			if (currentMapEditor())
insilmaril@357
  2430
				currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());	
insilmaril@357
  2431
		}
insilmaril@357
  2432
	} else
insilmaril@185
  2433
	{
insilmaril@357
  2434
		QMessageBox::warning(0, 
insilmaril@366
  2435
		tr("Warning"),
insilmaril@366
  2436
		tr("Couldn't find configuration for export to Open Office\n"));
insilmaril@185
  2437
	}
insilmaril@163
  2438
}
insilmaril@163
  2439
insilmaril@0
  2440
void Main::fileCloseMap()
insilmaril@0
  2441
{
insilmaril@625
  2442
	MapEditor *me = currentMapEditor();
insilmaril@625
  2443
	if (me)
insilmaril@0
  2444
	{
insilmaril@625
  2445
		if (me->hasChanged())
insilmaril@0
  2446
		{
insilmaril@404
  2447
			QMessageBox mb( vymName,
insilmaril@625
  2448
				tr("The map %1 has been modified but not saved yet. Do you want to").arg(me->getFileName()),
insilmaril@0
  2449
				QMessageBox::Warning,
insilmaril@0
  2450
				QMessageBox::Yes | QMessageBox::Default,
insilmaril@0
  2451
				QMessageBox::No,
insilmaril@0
  2452
				QMessageBox::Cancel | QMessageBox::Escape );
insilmaril@0
  2453
			mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
insilmaril@0
  2454
			mb.setButtonText( QMessageBox::No, tr("Discard changes"));
insilmaril@0
  2455
			switch( mb.exec() ) 
insilmaril@0
  2456
			{
insilmaril@0
  2457
				case QMessageBox::Yes:
insilmaril@0
  2458
					// save and close
insilmaril@625
  2459
					fileSave(me, CompleteMap);
insilmaril@0
  2460
					break;
insilmaril@0
  2461
				case QMessageBox::No:
insilmaril@0
  2462
				// close  without saving
insilmaril@0
  2463
					break;
insilmaril@0
  2464
				case QMessageBox::Cancel:
insilmaril@0
  2465
					// do nothing
insilmaril@0
  2466
				return;
insilmaril@0
  2467
			}
insilmaril@0
  2468
		} 
insilmaril@625
  2469
		me->closeMap();
insilmaril@625
  2470
		tabWidget->removePage(me);
insilmaril@0
  2471
		if (tabWidget->count()==0)
insilmaril@0
  2472
			actionFilePrint->setEnabled (false);
insilmaril@625
  2473
        delete me;
insilmaril@625
  2474
	}
insilmaril@0
  2475
}
insilmaril@0
  2476
insilmaril@0
  2477
void Main::filePrint()
insilmaril@0
  2478
{
insilmaril@0
  2479
	if (currentMapEditor())
insilmaril@0
  2480
		currentMapEditor()->print();
insilmaril@0
  2481
}
insilmaril@0
  2482
insilmaril@0
  2483
void Main::fileExitVYM()
insilmaril@0
  2484
{
insilmaril@0
  2485
	// Check if one or more editors have changed
insilmaril@0
  2486
	MapEditor *me;
insilmaril@0
  2487
	int i;
insilmaril@0
  2488
	for (i=0;i<=tabWidget->count() -1;i++)
insilmaril@0
  2489
	{
insilmaril@0
  2490
		
insilmaril@0
  2491
		me=(MapEditor*)tabWidget->page(i);
insilmaril@0
  2492
insilmaril@0
  2493
		// If something changed, ask what to do
insilmaril@486
  2494
		if (me->hasChanged())
insilmaril@0
  2495
		{
insilmaril@0
  2496
			tabWidget->setCurrentPage(i);
insilmaril@404
  2497
			QMessageBox mb( vymName,
insilmaril@0
  2498
				tr("This map is not saved yet. Do you want to"),
insilmaril@0
  2499
				QMessageBox::Warning,
insilmaril@0
  2500
				QMessageBox::Yes | QMessageBox::Default,
insilmaril@0
  2501
				QMessageBox::No,
insilmaril@0
  2502
				QMessageBox::Cancel | QMessageBox::Escape );
insilmaril@0
  2503
			mb.setButtonText( QMessageBox::Yes, tr("Save map") );
insilmaril@0
  2504
			mb.setButtonText( QMessageBox::No, tr("Discard changes") );
insilmaril@366
  2505
			mb.setModal (true);
insilmaril@0
  2506
			mb.show();
insilmaril@0
  2507
			mb.setActiveWindow();
insilmaril@0
  2508
			switch( mb.exec() ) {
insilmaril@0
  2509
				case QMessageBox::Yes:
insilmaril@0
  2510
					// save (the changed editors) and exit
insilmaril@473
  2511
					fileSave(currentMapEditor(), CompleteMap);
insilmaril@0
  2512
					break;
insilmaril@0
  2513
				case QMessageBox::No:
insilmaril@0
  2514
					// exit without saving
insilmaril@0
  2515
					break;
insilmaril@0
  2516
				case QMessageBox::Cancel:
insilmaril@0
  2517
					// don't save and don't exit
insilmaril@0
  2518
				return;
insilmaril@0
  2519
			}
insilmaril@0
  2520
		}
insilmaril@0
  2521
	} // loop over all MEs	
insilmaril@0
  2522
    qApp->quit();
insilmaril@0
  2523
}
insilmaril@0
  2524
insilmaril@0
  2525
void Main::editUndo()
insilmaril@0
  2526
{
insilmaril@0
  2527
	if (currentMapEditor())
insilmaril@0
  2528
		currentMapEditor()->undo();
insilmaril@0
  2529
}
insilmaril@0
  2530
insilmaril@163
  2531
void Main::editRedo()	   
insilmaril@0
  2532
{
insilmaril@163
  2533
	if (currentMapEditor())
insilmaril@163
  2534
		currentMapEditor()->redo();
insilmaril@0
  2535
}
insilmaril@0
  2536
insilmaril@404
  2537
void Main::gotoHistoryStep (int i)	   
insilmaril@404
  2538
{
insilmaril@404
  2539
	if (currentMapEditor())
insilmaril@404
  2540
		currentMapEditor()->gotoHistoryStep (i);
insilmaril@404
  2541
}
insilmaril@404
  2542
insilmaril@0
  2543
void Main::editCopy()
insilmaril@0
  2544
{
insilmaril@0
  2545
	if (currentMapEditor())
insilmaril@0
  2546
		currentMapEditor()->copy();
insilmaril@0
  2547
}
insilmaril@0
  2548
insilmaril@0
  2549
void Main::editPaste()
insilmaril@0
  2550
{
insilmaril@0
  2551
	if (currentMapEditor())
insilmaril@0
  2552
		currentMapEditor()->paste();
insilmaril@0
  2553
}
insilmaril@0
  2554
insilmaril@0
  2555
void Main::editCut()
insilmaril@0
  2556
{
insilmaril@0
  2557
	if (currentMapEditor())
insilmaril@0
  2558
		currentMapEditor()->cut();
insilmaril@0
  2559
}
insilmaril@0
  2560
insilmaril@0
  2561
void Main::editOpenFindWindow()
insilmaril@0
  2562
{
insilmaril@0
  2563
	findWindow->popup();
insilmaril@0
  2564
	findWindow->raise();
insilmaril@0
  2565
	findWindow->setActiveWindow();
insilmaril@0
  2566
}
insilmaril@0
  2567
insilmaril@0
  2568
void Main::editFind(QString s)
insilmaril@0
  2569
{
insilmaril@0
  2570
	bool cs=false;
insilmaril@0
  2571
	BranchObj *bo=currentMapEditor()->findText(s, cs);
insilmaril@0
  2572
	if (bo)
insilmaril@0
  2573
	{	
insilmaril@0
  2574
		statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
insilmaril@0
  2575
	} else
insilmaril@0
  2576
	{
insilmaril@0
  2577
		QMessageBox::information( findWindow, tr( "VYM -Information:" ),
insilmaril@349
  2578
							   tr("No matches found for \"%1\"").arg(s));
insilmaril@0
  2579
	}	
insilmaril@0
  2580
}
insilmaril@0
  2581
insilmaril@0
  2582
void Main::editFindChanged()
insilmaril@0
  2583
{	// Notify editor, to abort the current find process
insilmaril@0
  2584
	currentMapEditor()->findReset();
insilmaril@0
  2585
}
insilmaril@0
  2586
insilmaril@366
  2587
void Main::openTabs(QStringList urls)
insilmaril@366
  2588
{
insilmaril@366
  2589
	if (!urls.isEmpty())
insilmaril@366
  2590
	{	
insilmaril@366
  2591
		bool success=true;
insilmaril@366
  2592
		QStringList args;
insilmaril@366
  2593
		QString browser=settings.value("/mainwindow/readerURL" ).toString();
insilmaril@366
  2594
		QProcess *p;
insilmaril@366
  2595
		if (!procBrowser ||  procBrowser->state()!=QProcess::Running)
insilmaril@366
  2596
		{
insilmaril@366
  2597
			QString u=urls.takeFirst();
insilmaril@366
  2598
			procBrowser = new QProcess( this );
insilmaril@366
  2599
			args<<u;
insilmaril@366
  2600
			procBrowser->start(browser,args);
insilmaril@366
  2601
			if ( !procBrowser->waitForStarted())
insilmaril@366
  2602
			{
insilmaril@366
  2603
				// try to set path to browser
insilmaril@366
  2604
				QMessageBox::warning(0, 
insilmaril@366
  2605
					tr("Warning"),
insilmaril@366
  2606
					tr("Couldn't find a viewer to open %1.\n").arg(u)+
insilmaril@366
  2607
					tr("Please use Settings->")+tr("Set application to open an URL"));
insilmaril@366
  2608
				return;
insilmaril@366
  2609
			}
insilmaril@608
  2610
#if defined(Q_OS_WIN32)
insilmaril@608
  2611
            // There's no sleep in VCEE, replace it with Qt's QThread::wait().
insilmaril@608
  2612
            this->thread()->wait(3000);
insilmaril@608
  2613
#else
insilmaril@366
  2614
			sleep (3);
insilmaril@608
  2615
#endif
insilmaril@366
  2616
		}
insilmaril@366
  2617
		if (browser.contains("konqueror"))
insilmaril@366
  2618
		{
insilmaril@366
  2619
			for (int i=0; i<urls.size(); i++)
insilmaril@366
  2620
			{
insilmaril@366
  2621
				// Open new browser
insilmaril@366
  2622
				// Try to open new tab in existing konqueror started previously by vym
insilmaril@366
  2623
				p=new QProcess (this);
insilmaril@366
  2624
				args.clear();
insilmaril@608
  2625
#if defined(Q_OS_WIN32)
insilmaril@608
  2626
                // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
insilmaril@608
  2627
                // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
insilmaril@608
  2628
				args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
insilmaril@608
  2629
					"konqueror-mainwindow#1"<<
insilmaril@608
  2630
					"newTab" <<
insilmaril@366
  2631
					urls.at(i);
insilmaril@608
  2632
#else
insilmaril@608
  2633
				args<< QString("konqueror-%1").arg(procBrowser->pid())<<
insilmaril@608
  2634
					"konqueror-mainwindow#1"<<
insilmaril@608
  2635
					"newTab" <<
insilmaril@608
  2636
					urls.at(i);
insilmaril@608
  2637
#endif
insilmaril@366
  2638
				p->start ("dcop",args);
insilmaril@658
  2639
				cout << qPrintable (args.join(" "))<<endl;
insilmaril@366
  2640
				if ( !p->waitForStarted() ) success=false;
insilmaril@366
  2641
			}
insilmaril@366
  2642
			if (!success)
insilmaril@366
  2643
				QMessageBox::warning(0, 
insilmaril@366
  2644
					tr("Warning"),
insilmaril@366
  2645
					tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
insilmaril@366
  2646
			return;		
insilmaril@366
  2647
		} else if (browser.contains ("firefox") || browser.contains ("mozilla") )
insilmaril@366
  2648
		{
insilmaril@366
  2649
			for (int i=0; i<urls.size(); i++)
insilmaril@366
  2650
			{
insilmaril@366
  2651
				// Try to open new tab in firefox
insilmaril@366
  2652
				p=new QProcess (this);
insilmaril@366
  2653
				args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
insilmaril@366
  2654
				p->start (browser,args);
insilmaril@366
  2655
				if ( !p->waitForStarted() ) success=false;
insilmaril@366
  2656
			}			
insilmaril@366
  2657
			if (!success)
insilmaril@366
  2658
				QMessageBox::warning(0, 
insilmaril@366
  2659
					tr("Warning"),
insilmaril@366
  2660
					tr("Couldn't start %1 to open a new tab").arg(browser));
insilmaril@366
  2661
			return;		
insilmaril@366
  2662
		}			
insilmaril@366
  2663
		QMessageBox::warning(0, 
insilmaril@366
  2664
			tr("Warning"),
insilmaril@366
  2665
			tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
insilmaril@366
  2666
	}	
insilmaril@366
  2667
}
insilmaril@366
  2668
insilmaril@0
  2669
void Main::editOpenURL()
insilmaril@0
  2670
{
insilmaril@266
  2671
	// Open new browser
insilmaril@0
  2672
	if (currentMapEditor())
insilmaril@266
  2673
	{	
insilmaril@266
  2674
	    QString url=currentMapEditor()->getURL();
insilmaril@366
  2675
		QStringList args;
insilmaril@266
  2676
		if (url=="") return;
insilmaril@366
  2677
		QString browser=settings.value("/mainwindow/readerURL" ).toString();
insilmaril@266
  2678
		procBrowser = new QProcess( this );
insilmaril@366
  2679
		args<<url;
insilmaril@366
  2680
		procBrowser->start(browser,args);
insilmaril@366
  2681
		if ( !procBrowser->waitForStarted())
insilmaril@266
  2682
		{
insilmaril@266
  2683
			// try to set path to browser
insilmaril@266
  2684
			QMessageBox::warning(0, 
insilmaril@266
  2685
				tr("Warning"),
insilmaril@266
  2686
				tr("Couldn't find a viewer to open %1.\n").arg(url)+
insilmaril@266
  2687
				tr("Please use Settings->")+tr("Set application to open an URL"));
insilmaril@266
  2688
			settingsURL() ; 
insilmaril@266
  2689
		}	
insilmaril@266
  2690
	}	
insilmaril@266
  2691
}
insilmaril@266
  2692
void Main::editOpenURLTab()
insilmaril@266
  2693
{
insilmaril@266
  2694
	if (currentMapEditor())
insilmaril@266
  2695
	{	
insilmaril@366
  2696
	    QStringList urls;
insilmaril@366
  2697
		urls.append(currentMapEditor()->getURL());
insilmaril@366
  2698
		openTabs (urls);
insilmaril@266
  2699
	}	
insilmaril@0
  2700
}
insilmaril@366
  2701
void Main::editOpenMultipleURLTabs()
insilmaril@366
  2702
{
insilmaril@366
  2703
	if (currentMapEditor())
insilmaril@366
  2704
	{	
insilmaril@366
  2705
	    QStringList urls;
insilmaril@366
  2706
		urls=currentMapEditor()->getURLs();
insilmaril@366
  2707
		openTabs (urls);
insilmaril@366
  2708
	}	
insilmaril@366
  2709
}
insilmaril@366
  2710
insilmaril@0
  2711
insilmaril@0
  2712
void Main::editURL()
insilmaril@0
  2713
{
insilmaril@0
  2714
	if (currentMapEditor())
insilmaril@0
  2715
	    currentMapEditor()->editURL();
insilmaril@0
  2716
}
insilmaril@0
  2717
insilmaril@528
  2718
void Main::editLocalURL()
insilmaril@528
  2719
{
insilmaril@528
  2720
	if (currentMapEditor())
insilmaril@528
  2721
	    currentMapEditor()->editLocalURL();
insilmaril@528
  2722
}
insilmaril@528
  2723
insilmaril@0
  2724
void Main::editHeading2URL()
insilmaril@0
  2725
{
insilmaril@0
  2726
	if (currentMapEditor())
insilmaril@0
  2727
	    currentMapEditor()->editHeading2URL();
insilmaril@0
  2728
}
insilmaril@0
  2729
insilmaril@0
  2730
void Main::editBugzilla2URL()
insilmaril@0
  2731
{
insilmaril@0
  2732
	if (currentMapEditor())
insilmaril@0
  2733
	    currentMapEditor()->editBugzilla2URL();
insilmaril@0
  2734
}
insilmaril@0
  2735
insilmaril@175
  2736
void Main::editFATE2URL()
insilmaril@175
  2737
{
insilmaril@175
  2738
	if (currentMapEditor())
insilmaril@175
  2739
	    currentMapEditor()->editFATE2URL();
insilmaril@175
  2740
}
insilmaril@175
  2741
insilmaril@394
  2742
void Main::editHeadingFinished()
insilmaril@394
  2743
{
insilmaril@394
  2744
	// only called from editHeading(), so there is a currentME
insilmaril@394
  2745
	MapEditor *me=currentMapEditor();
insilmaril@421
  2746
	if (me)
insilmaril@421
  2747
	{
insilmaril@491
  2748
		me->setStateEditHeading (false);
insilmaril@421
  2749
		QPoint p;	//Not used here, only to find out pos of branch
insilmaril@421
  2750
		bool ok;
insilmaril@421
  2751
		QString s=me->getHeading(ok,p);
insilmaril@394
  2752
insilmaril@625
  2753
#if defined(Q_OS_MACX) || defined(Q_OS_WIN32)
insilmaril@394
  2754
#else
insilmaril@421
  2755
		if (ok && s!=lineedit->text())
insilmaril@421
  2756
			me->setHeading(lineedit->text());
insilmaril@421
  2757
			
insilmaril@421
  2758
		lineedit->releaseKeyboard();
insilmaril@421
  2759
		lineedit->hide();
insilmaril@421
  2760
		setFocus();
insilmaril@394
  2761
#endif	
insilmaril@537
  2762
		if (!actionSettingsAutoSelectNewBranch->isOn() && 
insilmaril@537
  2763
			!prevSelection.isEmpty()) 
insilmaril@537
  2764
			me->select(prevSelection);
insilmaril@421
  2765
		prevSelection="";
insilmaril@421
  2766
	}
insilmaril@394
  2767
}
insilmaril@394
  2768
insilmaril@366
  2769
void Main::editHeading()
insilmaril@0
  2770
{
insilmaril@394
  2771
	if (currentMapEditor())
insilmaril@0
  2772
	{
insilmaril@394
  2773
		MapEditor *me=currentMapEditor();
insilmaril@394
  2774
		QString oldSel=me->getSelectString();
insilmaril@394
  2775
insilmaril@394
  2776
		if (lineedit->isVisible())
insilmaril@394
  2777
			editHeadingFinished();
insilmaril@394
  2778
		else
insilmaril@366
  2779
		{
insilmaril@366
  2780
			bool ok;
insilmaril@366
  2781
			QPoint p;
insilmaril@531
  2782
			QString s=me->getHeading(ok,p);
insilmaril@366
  2783
insilmaril@366
  2784
			if (ok)
insilmaril@366
  2785
			{
insilmaril@491
  2786
				me->setStateEditHeading (true);
insilmaril@625
  2787
#if defined(Q_OS_MACX) || defined(Q_OS_WIN32)
insilmaril@531
  2788
				p=me->mapToGlobal (p);
insilmaril@366
  2789
				QDialog *d =new QDialog(NULL);
insilmaril@366
  2790
				QLineEdit *le=new QLineEdit (d);
insilmaril@366
  2791
				d->setWindowFlags (Qt::FramelessWindowHint);
insilmaril@394
  2792
				d->setGeometry(p.x(),p.y(),230,25);
insilmaril@394
  2793
				le->resize (d->width()-10,d->height());
insilmaril@366
  2794
				le->setText (s);
insilmaril@366
  2795
				le->selectAll();
insilmaril@366
  2796
				connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
insilmaril@366
  2797
				d->activateWindow();
insilmaril@366
  2798
				d->exec();
insilmaril@531
  2799
				me->setHeading (le->text());
insilmaril@394
  2800
				delete (le);
insilmaril@394
  2801
				delete (d);
insilmaril@394
  2802
				editHeadingFinished();
insilmaril@366
  2803
#else
insilmaril@531
  2804
				p=me->mapTo (this,p);
insilmaril@394
  2805
				lineedit->setGeometry(p.x(),p.y(),230,25);
insilmaril@366
  2806
				lineedit->setText(s);
insilmaril@366
  2807
				lineedit->setCursorPosition(1);
insilmaril@366
  2808
				lineedit->selectAll();
insilmaril@366
  2809
				lineedit->show();
insilmaril@366
  2810
				lineedit->grabKeyboard();
insilmaril@366
  2811
				lineedit->setFocus();
insilmaril@366
  2812
#endif
insilmaril@366
  2813
			}
insilmaril@366
  2814
		}
insilmaril@394
  2815
	} // currentMapEditor()	
insilmaril@366
  2816
}
insilmaril@366
  2817
insilmaril@616
  2818
void Main::editAttributeFinished()
insilmaril@616
  2819
{
insilmaril@616
  2820
	// only called from editHeading(), so there is a currentME
insilmaril@616
  2821
insilmaril@616
  2822
	/*
insilmaril@616
  2823
	MapEditor *me=currentMapEditor();
insilmaril@616
  2824
	if (me)
insilmaril@616
  2825
	{
insilmaril@616
  2826
		me->setStateEditHeading (false);
insilmaril@616
  2827
		QPoint p;	//Not used here, only to find out pos of branch
insilmaril@616
  2828
		bool ok;
insilmaril@616
  2829
		QString s=me->getHeading(ok,p);
insilmaril@616
  2830
insilmaril@616
  2831
#if defined(Q_OS_MACX)
insilmaril@616
  2832
#else
insilmaril@616
  2833
		if (ok && s!=lineedit->text())
insilmaril@616
  2834
			me->setHeading(lineedit->text());
insilmaril@616
  2835
			
insilmaril@616
  2836
		lineedit->releaseKeyboard();
insilmaril@616
  2837
		lineedit->hide();
insilmaril@616
  2838
		setFocus();
insilmaril@616
  2839
#endif	
insilmaril@616
  2840
		if (!actionSettingsAutoSelectNewBranch->isOn() && 
insilmaril@616
  2841
			!prevSelection.isEmpty()) 
insilmaril@616
  2842
			me->select(prevSelection);
insilmaril@616
  2843
		prevSelection="";
insilmaril@616
  2844
	}
insilmaril@616
  2845
	*/
insilmaril@616
  2846
}
insilmaril@616
  2847
insilmaril@628
  2848
#include "attribute.h"
insilmaril@625
  2849
#include "attributedialog.h"
insilmaril@616
  2850
void Main::editAttribute()
insilmaril@616
  2851
{
insilmaril@628
  2852
	MapEditor *me=currentMapEditor();
insilmaril@628
  2853
	if (me)
insilmaril@628
  2854
	{
insilmaril@628
  2855
		BranchObj *bo=me->getSelectedBranch();
insilmaril@628
  2856
		if (bo)
insilmaril@628
  2857
		{
insilmaril@628
  2858
			AttributeDialog dia(this);
insilmaril@628
  2859
			dia.setTable (me->attributeTable() );
insilmaril@628
  2860
			dia.setBranch (bo);
insilmaril@638
  2861
			dia.setMode (Definition);
insilmaril@638
  2862
			dia.updateTable();
insilmaril@628
  2863
			dia.exec();
insilmaril@628
  2864
		}
insilmaril@628
  2865
	}	
insilmaril@616
  2866
	/*
insilmaril@616
  2867
	if (currentMapEditor())
insilmaril@616
  2868
	{
insilmaril@616
  2869
		MapEditor *me=currentMapEditor();
insilmaril@616
  2870
		QString oldSel=me->getSelectString();
insilmaril@616
  2871
insilmaril@616
  2872
		if (lineedit->isVisible())
insilmaril@616
  2873
			editAttributeFinished();
insilmaril@616
  2874
		else
insilmaril@616
  2875
		{
insilmaril@616
  2876
			bool ok;
insilmaril@616
  2877
			QPoint p;
insilmaril@616
  2878
			QString s=me->getHeading(ok,p);
insilmaril@616
  2879
insilmaril@616
  2880
			if (ok)
insilmaril@616
  2881
			{
insilmaril@616
  2882
				me->setStateEditHeading (true);
insilmaril@616
  2883
#if defined(Q_OS_MACX)
insilmaril@616
  2884
				p=me->mapToGlobal (p);
insilmaril@616
  2885
				QDialog *d =new QDialog(NULL);
insilmaril@616
  2886
				QLineEdit *le=new QLineEdit (d);
insilmaril@616
  2887
				d->setWindowFlags (Qt::FramelessWindowHint);
insilmaril@616
  2888
				d->setGeometry(p.x(),p.y(),230,25);
insilmaril@616
  2889
				le->resize (d->width()-10,d->height());
insilmaril@616
  2890
				le->setText (s);
insilmaril@616
  2891
				le->selectAll();
insilmaril@616
  2892
				connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
insilmaril@616
  2893
				d->activateWindow();
insilmaril@616
  2894
				d->exec();
insilmaril@616
  2895
				me->setHeading (le->text());
insilmaril@616
  2896
				delete (le);
insilmaril@616
  2897
				delete (d);
insilmaril@616
  2898
				editHeadingFinished();
insilmaril@616
  2899
#else
insilmaril@616
  2900
				p=me->mapTo (this,p);
insilmaril@616
  2901
				lineedit->setGeometry(p.x(),p.y(),230,25);
insilmaril@616
  2902
				lineedit->setText(s);
insilmaril@616
  2903
				lineedit->setCursorPosition(1);
insilmaril@616
  2904
				lineedit->selectAll();
insilmaril@616
  2905
				lineedit->show();
insilmaril@616
  2906
				lineedit->grabKeyboard();
insilmaril@616
  2907
				lineedit->setFocus();
insilmaril@616
  2908
#endif
insilmaril@616
  2909
			}
insilmaril@616
  2910
		} 
insilmaril@616
  2911
	} // currentMapEditor()	
insilmaril@616
  2912
insilmaril@616
  2913
	*/
insilmaril@616
  2914
}
insilmaril@616
  2915
insilmaril@366
  2916
void Main::openVymLinks(const QStringList &vl)
insilmaril@366
  2917
{
insilmaril@366
  2918
	for (int j=0; j<vl.size(); j++)
insilmaril@366
  2919
	{
insilmaril@0
  2920
		// compare path with already loaded maps
insilmaril@0
  2921
		int index=-1;
insilmaril@0
  2922
		int i;
insilmaril@0
  2923
		MapEditor *me;
insilmaril@0
  2924
		for (i=0;i<=tabWidget->count() -1;i++)
insilmaril@0
  2925
		{
insilmaril@0
  2926
			me=(MapEditor*)tabWidget->page(i);
insilmaril@366
  2927
			if (vl.at(j)==me->getFilePath() )
insilmaril@0
  2928
			{
insilmaril@0
  2929
				index=i;
insilmaril@0
  2930
				break;
insilmaril@0
  2931
			}
insilmaril@0
  2932
		}	
insilmaril@0
  2933
		if (index<0)
insilmaril@0
  2934
		// Load map
insilmaril@0
  2935
		{
insilmaril@366
  2936
			if (!QFile(vl.at(j)).exists() )
insilmaril@0
  2937
				QMessageBox::critical( 0, tr( "Critical Error" ),
insilmaril@366
  2938
				   tr("Couldn't open map %1").arg(vl.at(j)));
insilmaril@0
  2939
			else
insilmaril@0
  2940
			{
insilmaril@366
  2941
				fileLoad (vl.at(j), NewMap);
insilmaril@0
  2942
				tabWidget->setCurrentPage (tabWidget->count()-1);	
insilmaril@0
  2943
			}
insilmaril@0
  2944
		} else
insilmaril@0
  2945
			// Go to tab containing the map
insilmaril@0
  2946
			tabWidget->setCurrentPage (index);	
insilmaril@0
  2947
	}
insilmaril@0
  2948
}
insilmaril@0
  2949
insilmaril@366
  2950
void Main::editOpenVymLink()
insilmaril@366
  2951
{
insilmaril@366
  2952
	if (currentMapEditor())
insilmaril@366
  2953
	{
insilmaril@366
  2954
		QStringList vl;
insilmaril@366
  2955
		vl.append(currentMapEditor()->getVymLink());	
insilmaril@366
  2956
		openVymLinks (vl);
insilmaril@366
  2957
	}
insilmaril@366
  2958
}
insilmaril@366
  2959
insilmaril@366
  2960
void Main::editOpenMultipleVymLinks()
insilmaril@366
  2961
{
insilmaril@366
  2962
	QString currentVymLink;
insilmaril@366
  2963
	if (currentMapEditor())
insilmaril@366
  2964
	{
insilmaril@366
  2965
		QStringList vl=currentMapEditor()->getVymLinks();
insilmaril@366
  2966
		openVymLinks (vl);
insilmaril@366
  2967
	}
insilmaril@366
  2968
}
insilmaril@366
  2969
insilmaril@0
  2970
void Main::editVymLink()
insilmaril@0
  2971
{
insilmaril@0
  2972
	if (currentMapEditor())
insilmaril@0
  2973
		currentMapEditor()->editVymLink();	
insilmaril@0
  2974
}
insilmaril@0
  2975
insilmaril@0
  2976
void Main::editDeleteVymLink()
insilmaril@0
  2977
{
insilmaril@0
  2978
	if (currentMapEditor())
insilmaril@0
  2979
		currentMapEditor()->deleteVymLink();	
insilmaril@0
  2980
}
insilmaril@0
  2981
insilmaril@243
  2982
void Main::editToggleHideExport()
insilmaril@243
  2983
{
insilmaril@243
  2984
	if (currentMapEditor())
insilmaril@294
  2985
		currentMapEditor()->toggleHideExport();	
insilmaril@243
  2986
}
insilmaril@243
  2987
insilmaril@0
  2988
void Main::editMapInfo()
insilmaril@0
  2989
{
insilmaril@0
  2990
	if (currentMapEditor())
insilmaril@0
  2991
		currentMapEditor()->editMapInfo();	
insilmaril@0
  2992
}
insilmaril@0
  2993
insilmaril@0
  2994
void Main::editMoveUp()
insilmaril@0
  2995
{
insilmaril@0
  2996
	if (currentMapEditor())
insilmaril@0
  2997
	    currentMapEditor()->moveBranchUp();
insilmaril@0
  2998
}
insilmaril@0
  2999
insilmaril@0
  3000
void Main::editMoveDown()
insilmaril@0
  3001
{
insilmaril@0
  3002
	if (currentMapEditor())
insilmaril@0
  3003
		currentMapEditor()->moveBranchDown();
insilmaril@0
  3004
}
insilmaril@0
  3005
insilmaril@608
  3006
void Main::editSortChildren()
insilmaril@608
  3007
{
insilmaril@608
  3008
	if (currentMapEditor())
insilmaril@608
  3009
		currentMapEditor()->sortChildren();
insilmaril@608
  3010
}
insilmaril@608
  3011
insilmaril@0
  3012
void Main::editToggleScroll()
insilmaril@0
  3013
{
insilmaril@0
  3014
	if (currentMapEditor())
insilmaril@0
  3015
	{
insilmaril@0
  3016
		currentMapEditor()->toggleScroll();	
insilmaril@0
  3017
	}	
insilmaril@0
  3018
}
insilmaril@0
  3019
insilmaril@473
  3020
void Main::editUnscrollChilds()
insilmaril@0
  3021
{
insilmaril@0
  3022
	if (currentMapEditor())
insilmaril@428
  3023
		currentMapEditor()->unscrollChilds();	
insilmaril@394
  3024
}
insilmaril@394
  3025
insilmaril@394
  3026
void Main::editNewBranch()
insilmaril@394
  3027
{
insilmaril@394
  3028
	MapEditor *me=currentMapEditor();
insilmaril@394
  3029
	if (!lineedit->isVisible() && me)
insilmaril@0
  3030
	{
insilmaril@394
  3031
		BranchObj *bo=(BranchObj*)me->getSelection();
insilmaril@394
  3032
		BranchObj *newbo=me->addNewBranch(0);
insilmaril@394
  3033
insilmaril@534
  3034
		prevSelection=bo->getSelectString();
insilmaril@394
  3035
		if (newbo) 
insilmaril@394
  3036
			me->select (newbo->getSelectString());
insilmaril@394
  3037
		else
insilmaril@394
  3038
			return;
insilmaril@394
  3039
insilmaril@537
  3040
		if (actionSettingsAutoEditNewBranch->isOn())
insilmaril@394
  3041
		{
insilmaril@394
  3042
			editHeading();
insilmaril@534
  3043
			return;
insilmaril@534
  3044
		}	
insilmaril@534
  3045
		if (!prevSelection.isEmpty()) 
insilmaril@534
  3046
		{
insilmaril@534
  3047
			me->select(prevSelection);
insilmaril@534
  3048
			prevSelection="";
insilmaril@394
  3049
		}
insilmaril@534
  3050
insilmaril@0
  3051
	}	
insilmaril@0
  3052
}
insilmaril@0
  3053
insilmaril@394
  3054
void Main::editNewBranchBefore()
insilmaril@0
  3055
{
insilmaril@394
  3056
	MapEditor *me=currentMapEditor();
insilmaril@394
  3057
	if (!lineedit->isVisible() && me)
insilmaril@394
  3058
	{
insilmaril@394
  3059
		BranchObj *bo=(BranchObj*)me->getSelection();
insilmaril@394
  3060
		BranchObj *newbo=me->addNewBranchBefore();
insilmaril@394
  3061
insilmaril@394
  3062
		if (newbo) 
insilmaril@394
  3063
			me->select (newbo->getSelectString());
insilmaril@394
  3064
		else
insilmaril@394
  3065
			return;
insilmaril@394
  3066
insilmaril@537
  3067
		if (actionSettingsAutoEditNewBranch->isOn())
insilmaril@394
  3068
		{
insilmaril@537
  3069
			if (!actionSettingsAutoSelectNewBranch->isOn())
insilmaril@394
  3070
				prevSelection=bo->getSelectString();
insilmaril@394
  3071
			editHeading();
insilmaril@394
  3072
		}
insilmaril@394
  3073
	}	
insilmaril@98
  3074
}
insilmaril@98
  3075
insilmaril@0
  3076
void Main::editNewBranchAbove()
insilmaril@0
  3077
{
insilmaril@394
  3078
	MapEditor *me=currentMapEditor();
insilmaril@394
  3079
	if (!lineedit->isVisible() && me)
insilmaril@394
  3080
	{
insilmaril@394
  3081
		BranchObj *bo=(BranchObj*)me->getSelection();
insilmaril@394
  3082
		BranchObj *newbo=me->addNewBranch (-1);
insilmaril@394
  3083
insilmaril@394
  3084
		if (newbo) 
insilmaril@394
  3085
			me->select (newbo->getSelectString());
insilmaril@394
  3086
		else
insilmaril@394
  3087
			return;
insilmaril@394
  3088
insilmaril@537
  3089
		if (actionSettingsAutoEditNewBranch->isOn())
insilmaril@394
  3090
		{
insilmaril@537
  3091
			if (!actionSettingsAutoSelectNewBranch->isOn())
insilmaril@394
  3092
				prevSelection=bo->getSelectString();
insilmaril@394
  3093
			editHeading();
insilmaril@394
  3094
		}
insilmaril@394
  3095
	}	
insilmaril@0
  3096
}
insilmaril@0
  3097
insilmaril@0
  3098
void Main::editNewBranchBelow()
insilmaril@0
  3099
{
insilmaril@394
  3100
	MapEditor *me=currentMapEditor();
insilmaril@394
  3101
	if (!lineedit->isVisible() && me)
insilmaril@394
  3102
	{
insilmaril@394
  3103
		BranchObj *bo=(BranchObj*)me->getSelection();
insilmaril@394
  3104
		BranchObj *newbo=me->addNewBranch (1);
insilmaril@394
  3105
insilmaril@394
  3106
		if (newbo) 
insilmaril@394
  3107
			me->select (newbo->getSelectString());
insilmaril@394
  3108
		else
insilmaril@394
  3109
			return;
insilmaril@394
  3110
insilmaril@537
  3111
		if (actionSettingsAutoEditNewBranch->isOn())
insilmaril@394
  3112
		{
insilmaril@537
  3113
			if (!actionSettingsAutoSelectNewBranch->isOn())
insilmaril@394
  3114
				prevSelection=bo->getSelectString();
insilmaril@394
  3115
			editHeading();
insilmaril@394
  3116
		}
insilmaril@394
  3117
	}	
insilmaril@0
  3118
}
insilmaril@0
  3119
insilmaril@0
  3120
void Main::editImportAdd()
insilmaril@0
  3121
{
insilmaril@0
  3122
	fileLoad (ImportAdd);
insilmaril@0
  3123
}
insilmaril@0
  3124
insilmaril@0
  3125
void Main::editImportReplace()
insilmaril@0
  3126
{
insilmaril@0
  3127
	fileLoad (ImportReplace);
insilmaril@0
  3128
}
insilmaril@0
  3129
insilmaril@0
  3130
void Main::editSaveBranch()
insilmaril@0
  3131
{
insilmaril@0
  3132
	fileSaveAs (PartOfMap);
insilmaril@0
  3133
}
insilmaril@0
  3134
insilmaril@395
  3135
void Main::editDeleteKeepChilds()
insilmaril@98
  3136
{
insilmaril@98
  3137
	if (currentMapEditor())
insilmaril@395
  3138
		currentMapEditor()->deleteKeepChilds();
insilmaril@98
  3139
}
insilmaril@98
  3140
insilmaril@395
  3141
void Main::editDeleteChilds()
insilmaril@98
  3142
{
insilmaril@98
  3143
	if (currentMapEditor())
insilmaril@395
  3144
		currentMapEditor()->deleteChilds();
insilmaril@98
  3145
}
insilmaril@98
  3146
insilmaril@0
  3147
void Main::editDeleteSelection()
insilmaril@0
  3148
{
insilmaril@151
  3149
	if (currentMapEditor() && actionSettingsUseDelKey->isOn())
insilmaril@0
  3150
		currentMapEditor()->deleteSelection();
insilmaril@0
  3151
}
insilmaril@0
  3152
insilmaril@0
  3153
void Main::editUpperBranch()
insilmaril@0
  3154
{
insilmaril@0
  3155
	if (currentMapEditor())
insilmaril@0
  3156
		currentMapEditor()->selectUpperBranch();
insilmaril@0
  3157
}
insilmaril@0
  3158
insilmaril@0
  3159
void Main::editLowerBranch()
insilmaril@0
  3160
{
insilmaril@0
  3161
	if (currentMapEditor())
insilmaril@0
  3162
		currentMapEditor()->selectLowerBranch();
insilmaril@0
  3163
}
insilmaril@0
  3164
insilmaril@0
  3165
void Main::editLeftBranch()
insilmaril@0
  3166
{
insilmaril@0
  3167
	if (currentMapEditor())
insilmaril@0
  3168
		currentMapEditor()->selectLeftBranch();
insilmaril@0
  3169
}
insilmaril@0
  3170
insilmaril@0
  3171
void Main::editRightBranch()
insilmaril@0
  3172
{
insilmaril@0
  3173
	if (currentMapEditor())
insilmaril@0
  3174
		currentMapEditor()->selectRightBranch();
insilmaril@0
  3175
}
insilmaril@0
  3176
insilmaril@0
  3177
void Main::editFirstBranch()
insilmaril@0
  3178
{
insilmaril@0
  3179
	if (currentMapEditor())
insilmaril@0
  3180
		currentMapEditor()->selectFirstBranch();
insilmaril@0
  3181
}
insilmaril@0
  3182
insilmaril@0
  3183
void Main::editLastBranch()
insilmaril@0
  3184
{
insilmaril@0
  3185
	if (currentMapEditor())
insilmaril@0
  3186
		currentMapEditor()->selectLastBranch();
insilmaril@0
  3187
}
insilmaril@0
  3188
insilmaril@0
  3189
void Main::editLoadImage()
insilmaril@0
  3190
{
insilmaril@0
  3191
	if (currentMapEditor())
insilmaril@0
  3192
		currentMapEditor()->loadFloatImage();
insilmaril@0
  3193
}
insilmaril@0
  3194
insilmaril@366
  3195
void Main::editSaveImage()
insilmaril@0
  3196
{
insilmaril@0
  3197
	if (currentMapEditor())
insilmaril@366
  3198
		currentMapEditor()->saveFloatImage();
insilmaril@0
  3199
}
insilmaril@0
  3200
insilmaril@366
  3201
void Main::editFollowXLink(QAction *a)
insilmaril@366
  3202
{
insilmaril@366
  3203
insilmaril@366
  3204
	if (currentMapEditor())
insilmaril@366
  3205
		currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
insilmaril@366
  3206
}
insilmaril@366
  3207
insilmaril@366
  3208
void Main::editEditXLink(QAction *a)
insilmaril@89
  3209
{
insilmaril@89
  3210
	if (currentMapEditor())
insilmaril@366
  3211
		currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
insilmaril@94
  3212
}
insilmaril@94
  3213
insilmaril@0
  3214
void Main::formatSelectColor()
insilmaril@0
  3215
{
insilmaril@0
  3216
	if (currentMapEditor())
insilmaril@0
  3217
	{
insilmaril@395
  3218
		QColor col = QColorDialog::getColor((currentColor ), this );
insilmaril@0
  3219
		if ( !col.isValid() ) return;
insilmaril@0
  3220
		colorChanged( col );
insilmaril@0
  3221
	}	
insilmaril@0
  3222
}
insilmaril@0
  3223
insilmaril@0
  3224
void Main::formatPickColor()
insilmaril@0
  3225
{
insilmaril@0
  3226
	if (currentMapEditor())
insilmaril@395
  3227
		colorChanged( currentMapEditor()->getCurrentHeadingColor() );
insilmaril@0
  3228
}
insilmaril@0
  3229
insilmaril@0
  3230
void Main::colorChanged(QColor c)
insilmaril@0
  3231
{
insilmaril@0
  3232
    QPixmap pix( 16, 16 );
insilmaril@0
  3233
    pix.fill( c );
insilmaril@0
  3234
    actionFormatColor->setIconSet( pix );
insilmaril@395
  3235
	currentColor=c;
insilmaril@0
  3236
}
insilmaril@0
  3237
insilmaril@0
  3238
void Main::formatColorBranch()
insilmaril@0
  3239
{
insilmaril@0
  3240
	if (currentMapEditor())
insilmaril@395
  3241
		currentMapEditor()->colorBranch(currentColor);
insilmaril@0
  3242
}
insilmaril@0
  3243
insilmaril@417
  3244
void Main::formatColorSubtree()
insilmaril@417
  3245
{
insilmaril@417
  3246
	if (currentMapEditor())
insilmaril@417
  3247
		currentMapEditor()->colorSubtree (currentColor);
insilmaril@417
  3248
}
insilmaril@417
  3249
insilmaril@0
  3250
void Main::formatLinkStyleLine()
insilmaril@0
  3251
{
insilmaril@0
  3252
	if (currentMapEditor())
insilmaril@625
  3253
    {
insilmaril@398
  3254
		currentMapEditor()->setMapLinkStyle("StyleLine");
insilmaril@625
  3255
        actionFormatLinkStyleLine->setOn(true);
insilmaril@625
  3256
    }
insilmaril@0
  3257
}
insilmaril@0
  3258
insilmaril@0
  3259
void Main::formatLinkStyleParabel()
insilmaril@0
  3260
{
insilmaril@0
  3261
	if (currentMapEditor())
insilmaril@625
  3262
    {
insilmaril@398
  3263
		currentMapEditor()->setMapLinkStyle("StyleParabel");
insilmaril@625
  3264
        actionFormatLinkStyleParabel->setOn(true);
insilmaril@625
  3265
    }
insilmaril@0
  3266
}
insilmaril@0
  3267
insilmaril@0
  3268
void Main::formatLinkStylePolyLine()
insilmaril@0
  3269
{
insilmaril@0
  3270
	if (currentMapEditor())
insilmaril@625
  3271
    {
insilmaril@398
  3272
		currentMapEditor()->setMapLinkStyle("StylePolyLine");
insilmaril@625
  3273
        actionFormatLinkStylePolyLine->setOn(true);
insilmaril@625
  3274
    }
insilmaril@0
  3275
}
insilmaril@0
  3276
insilmaril@0
  3277
void Main::formatLinkStylePolyParabel()
insilmaril@0
  3278
{
insilmaril@0
  3279
	if (currentMapEditor())
insilmaril@625
  3280
    {
insilmaril@398
  3281
		currentMapEditor()->setMapLinkStyle("StylePolyParabel");
insilmaril@625
  3282
        actionFormatLinkStylePolyParabel->setOn(true);
insilmaril@625
  3283
    }
insilmaril@0
  3284
}
insilmaril@0
  3285
insilmaril@0
  3286
void Main::formatSelectBackColor()
insilmaril@0
  3287
{
insilmaril@0
  3288
	if (currentMapEditor())
insilmaril@398
  3289
		currentMapEditor()->selectMapBackgroundColor();
insilmaril@0
  3290
}
insilmaril@0
  3291
insilmaril@408
  3292
void Main::formatSelectBackImage()
insilmaril@408
  3293
{
insilmaril@408
  3294
	if (currentMapEditor())
insilmaril@408
  3295
		currentMapEditor()->selectMapBackgroundImage();
insilmaril@408
  3296
}
insilmaril@408
  3297
insilmaril@0
  3298
void Main::formatSelectLinkColor()
insilmaril@0
  3299
{
insilmaril@0
  3300
	if (currentMapEditor())
insilmaril@398
  3301
		currentMapEditor()->selectMapLinkColor();
insilmaril@0
  3302
}
insilmaril@0
  3303
insilmaril@442
  3304
void Main::formatSelectSelectionColor()
insilmaril@442
  3305
{
insilmaril@442
  3306
	if (currentMapEditor())
insilmaril@442
  3307
		currentMapEditor()->selectMapSelectionColor();
insilmaril@442
  3308
}
insilmaril@442
  3309
insilmaril@0
  3310
void Main::formatToggleLinkColorHint()
insilmaril@0
  3311
{
insilmaril@398
  3312
	currentMapEditor()->toggleMapLinkColorHint();
insilmaril@0
  3313
}
insilmaril@0
  3314
insilmaril@0
  3315
insilmaril@421
  3316
void Main::formatHideLinkUnselected()	//FIXME get rid of this with imagepropertydialog
insilmaril@160
  3317
{
insilmaril@160
  3318
	if (currentMapEditor())
insilmaril@160
  3319
		currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
insilmaril@160
  3320
}
insilmaril@160
  3321
insilmaril@0
  3322
void Main::viewZoomReset()
insilmaril@0
  3323
{
insilmaril@0
  3324
	if (currentMapEditor())
insilmaril@0
  3325
	{
insilmaril@366
  3326
		QMatrix m;
insilmaril@0
  3327
		m.reset();
insilmaril@408
  3328
		currentMapEditor()->setMatrix( m );
insilmaril@0
  3329
	}	
insilmaril@0
  3330
}
insilmaril@0
  3331
insilmaril@0
  3332
void Main::viewZoomIn()
insilmaril@0
  3333
{
insilmaril@0
  3334
	if (currentMapEditor())
insilmaril@0
  3335
	{
insilmaril@408
  3336
		QMatrix m = currentMapEditor()->matrix();
insilmaril@0
  3337
		m.scale( 1.25, 1.25 );
insilmaril@408
  3338
		currentMapEditor()->setMatrix( m );
insilmaril@0
  3339
	}	
insilmaril@0
  3340
}
insilmaril@0
  3341
insilmaril@0
  3342
void Main::viewZoomOut()
insilmaril@0
  3343
{
insilmaril@0
  3344
	if (currentMapEditor())
insilmaril@0
  3345
	{
insilmaril@408
  3346
		QMatrix m = currentMapEditor()->matrix();
insilmaril@0
  3347
		m.scale( 0.8, 0.8 );
insilmaril@408
  3348
		currentMapEditor()->setMatrix( m );
insilmaril@0
  3349
	}	
insilmaril@0
  3350
}
insilmaril@89
  3351
insilmaril@526
  3352
void Main::viewCenter()
insilmaril@526
  3353
{
insilmaril@526
  3354
	MapEditor *me=currentMapEditor();
insilmaril@526
  3355
	if (me)
insilmaril@526
  3356
	{
insilmaril@526
  3357
		me->ensureSelectionVisible();
insilmaril@526
  3358
	}	
insilmaril@526
  3359
}
insilmaril@526
  3360
insilmaril@528
  3361
void Main::networkStartServer()
insilmaril@528
  3362
{
insilmaril@528
  3363
	MapEditor *me=currentMapEditor();
insilmaril@528
  3364
	if (me) me->newServer();
insilmaril@528
  3365
}
insilmaril@528
  3366
insilmaril@528
  3367
void Main::networkConnect()
insilmaril@528
  3368
{
insilmaril@528
  3369
	MapEditor *me=currentMapEditor();
insilmaril@531
  3370
	if (me) me->connectToServer();
insilmaril@528
  3371
}
insilmaril@528
  3372
insilmaril@0
  3373
bool Main::settingsPDF()
insilmaril@0
  3374
{
insilmaril@0
  3375
	// Default browser is set in constructor
insilmaril@0
  3376
	bool ok;
insilmaril@0
  3377
	QString text = QInputDialog::getText(
insilmaril@266
  3378
		"VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
insilmaril@366
  3379
		settings.value("/mainwindow/readerPDF").toString(), &ok, this );
insilmaril@0
  3380
	if (ok)
insilmaril@366
  3381
		settings.setValue ("/mainwindow/readerPDF",text);
insilmaril@0
  3382
	return ok;
insilmaril@0
  3383
}
insilmaril@0
  3384
insilmaril@0
  3385
insilmaril@0
  3386
bool Main::settingsURL()
insilmaril@0
  3387
{
insilmaril@0
  3388
	// Default browser is set in constructor
insilmaril@0
  3389
	bool ok;
insilmaril@0
  3390
	QString text = QInputDialog::getText(
insilmaril@266
  3391
		"VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
insilmaril@366
  3392
		settings.value("/mainwindow/readerURL").toString()
insilmaril@0
  3393
		, &ok, this );
insilmaril@0
  3394
	if (ok)
insilmaril@366
  3395
		settings.setValue ("/mainwindow/readerURL",text);
insilmaril@0
  3396
	return ok;
insilmaril@0
  3397
}
insilmaril@0
  3398
insilmaril@450
  3399
void Main::settingsMacroDir()
insilmaril@450
  3400
{
insilmaril@625
  3401
	QDir defdir(vymBaseDir.path() + "/macros");
insilmaril@450
  3402
	if (!defdir.exists())
insilmaril@450
  3403
		defdir=vymBaseDir;
insilmaril@450
  3404
	QDir dir=QFileDialog::getExistingDirectory (
insilmaril@450
  3405
		this,
insilmaril@450
  3406
		tr ("Directory with vym macros:"), 
insilmaril@450
  3407
		settings.value ("/macros/macroDir",defdir.path()).toString()
insilmaril@450
  3408
	);
insilmaril@450
  3409
	if (dir.exists())
insilmaril@625
  3410
		settings.setValue ("/macros/macroDir",dir.absolutePath());
insilmaril@450
  3411
}
insilmaril@450
  3412
insilmaril@473
  3413
void Main::settingsUndoLevels()
insilmaril@473
  3414
{
insilmaril@473
  3415
	bool ok;
insilmaril@473
  3416
	int i = QInputDialog::getInteger(
insilmaril@473
  3417
		this, 
insilmaril@473
  3418
		tr("QInputDialog::getInteger()"),
insilmaril@473
  3419
	    tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
insilmaril@473
  3420
	if (ok)
insilmaril@473
  3421
	{
insilmaril@473
  3422
		settings.setValue ("/mapeditor/stepsTotal",i);
insilmaril@473
  3423
		QMessageBox::information( this, tr( "VYM -Information:" ),
insilmaril@473
  3424
		   tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i)); 
insilmaril@473
  3425
   }	
insilmaril@473
  3426
}
insilmaril@473
  3427
insilmaril@473
  3428
void Main::settingsAutosaveToggle()
insilmaril@473
  3429
{
insilmaril@531
  3430
	settings.setValue ("/mapeditor/autosave/use",actionSettingsAutosaveToggle->isOn() );
insilmaril@473
  3431
}
insilmaril@473
  3432
insilmaril@473
  3433
void Main::settingsAutosaveTime()
insilmaril@473
  3434
{
insilmaril@473
  3435
	bool ok;
insilmaril@473
  3436
	int i = QInputDialog::getInteger(
insilmaril@473
  3437
		this, 
insilmaril@473
  3438
		tr("QInputDialog::getInteger()"),
insilmaril@473
  3439
	    tr("Number of seconds before autosave:"), settings.value("/mapeditor/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
insilmaril@473
  3440
	if (ok)
insilmaril@473
  3441
	{
insilmaril@473
  3442
		settings.setValue ("/mapeditor/autosave/ms",i * 1000);
insilmaril@473
  3443
    }	
insilmaril@473
  3444
}
insilmaril@473
  3445
insilmaril@625
  3446
void Main::settingsWriteBackupFileToggle()
insilmaril@625
  3447
{
insilmaril@625
  3448
	settings.setValue ("/mapeditor/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
insilmaril@625
  3449
}
insilmaril@625
  3450
insilmaril@327
  3451
void Main::settingsToggleDelKey()
insilmaril@327
  3452
{
insilmaril@327
  3453
	if (actionSettingsUseDelKey->isOn())
insilmaril@327
  3454
	{
insilmaril@366
  3455
		actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
insilmaril@327
  3456
	} else
insilmaril@327
  3457
	{
insilmaril@327
  3458
		actionEditDelete->setAccel (QKeySequence (""));
insilmaril@327
  3459
	}
insilmaril@327
  3460
}
insilmaril@327
  3461
insilmaril@0
  3462
void Main::windowToggleNoteEditor()
insilmaril@0
  3463
{
insilmaril@502
  3464
	if (textEditor->isVisible() )
insilmaril@497
  3465
		windowHideNoteEditor();
insilmaril@497
  3466
	else
insilmaril@497
  3467
		windowShowNoteEditor();
insilmaril@0
  3468
}
insilmaril@0
  3469
insilmaril@294
  3470
void Main::windowToggleHistory()
insilmaril@294
  3471
{
insilmaril@404
  3472
	if (historyWindow->isVisible())
insilmaril@404
  3473
		historyWindow->hide();
insilmaril@404
  3474
	else	
insilmaril@404
  3475
		historyWindow->show();
insilmaril@404
  3476
insilmaril@404
  3477
}
insilmaril@404
  3478
insilmaril@473
  3479
void Main::windowToggleProperty()
insilmaril@473
  3480
{
insilmaril@473
  3481
	if (branchPropertyWindow->isVisible())
insilmaril@473
  3482
		branchPropertyWindow->hide();
insilmaril@473
  3483
	else	
insilmaril@473
  3484
		branchPropertyWindow->show();
insilmaril@486
  3485
insilmaril@473
  3486
	if(currentMapEditor())
insilmaril@473
  3487
	{
insilmaril@628
  3488
		BranchObj *bo=currentMapEditor()->getSelectedBranch();
insilmaril@628
  3489
		if (bo) 
insilmaril@473
  3490
		{
insilmaril@473
  3491
			branchPropertyWindow->setMapEditor(currentMapEditor());
insilmaril@628
  3492
			branchPropertyWindow->setBranch(bo);
insilmaril@473
  3493
			return;
insilmaril@473
  3494
		}
insilmaril@473
  3495
		
insilmaril@473
  3496
	}	
insilmaril@473
  3497
	branchPropertyWindow->setBranch(NULL);
insilmaril@473
  3498
}
insilmaril@473
  3499
insilmaril@408
  3500
void Main::windowToggleAntiAlias()
insilmaril@408
  3501
{
insilmaril@408
  3502
	bool b=actionViewToggleAntiAlias->isOn();
insilmaril@408
  3503
	MapEditor *me;
insilmaril@408
  3504
	for (int i=0;i<tabWidget->count();i++)
insilmaril@408
  3505
	{
insilmaril@408
  3506
		
insilmaril@408
  3507
		me=(MapEditor*)tabWidget->page(i);
insilmaril@408
  3508
		me->setAntiAlias(b);
insilmaril@408
  3509
	}	
insilmaril@408
  3510
insilmaril@408
  3511
}
insilmaril@408
  3512
insilmaril@408
  3513
void Main::windowToggleSmoothPixmap()
insilmaril@408
  3514
{
insilmaril@408
  3515
	bool b=actionViewToggleSmoothPixmapTransform->isOn();
insilmaril@408
  3516
	MapEditor *me;
insilmaril@408
  3517
	for (int i=0;i<tabWidget->count();i++)
insilmaril@408
  3518
	{
insilmaril@408
  3519
		
insilmaril@408
  3520
		me=(MapEditor*)tabWidget->page(i);
insilmaril@408
  3521
		me->setSmoothPixmap(b);
insilmaril@408
  3522
	}	
insilmaril@408
  3523
}
insilmaril@408
  3524
insilmaril@404
  3525
void Main::updateHistory(SimpleSettings &undoSet)
insilmaril@404
  3526
{
insilmaril@404
  3527
	historyWindow->update (undoSet);
insilmaril@294
  3528
}
insilmaril@294
  3529
insilmaril@160
  3530
void Main::updateNoteFlag()
insilmaril@160
  3531
{
insilmaril@160
  3532
	if (currentMapEditor())
insilmaril@160
  3533
		currentMapEditor()->updateNoteFlag();
insilmaril@160
  3534
}
insilmaril@160
  3535
insilmaril@442
  3536
void Main::updateSatellites(MapEditor *me)
insilmaril@442
  3537
{
insilmaril@442
  3538
	branchPropertyWindow->setMapEditor (me);
insilmaril@442
  3539
}
insilmaril@442
  3540
insilmaril@390
  3541
void Main::updateActions()
insilmaril@390
  3542
{
insilmaril@390
  3543
	MapEditor *me=currentMapEditor();
insilmaril@390
  3544
	if (!me) return;
insilmaril@390
  3545
insilmaril@491
  3546
	historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(currentMapEditor()->getFileName()));
insilmaril@407
  3547
insilmaril@390
  3548
	// updateActions is also called when NoteEditor is closed
insilmaril@486
  3549
	actionViewToggleNoteEditor->setOn (textEditor->isVisible());
insilmaril@486
  3550
	actionViewToggleHistoryWindow->setOn (historyWindow->isVisible());
insilmaril@486
  3551
	actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible());
insilmaril@390
  3552
insilmaril@473
  3553
	if (me->getMapLinkColorHint()==LinkableMapObj::HeadingColor) 
insilmaril@390
  3554
		actionFormatLinkColorHint->setOn(true);
insilmaril@390
  3555
	else	
insilmaril@390
  3556
		actionFormatLinkColorHint->setOn(false);
insilmaril@390
  3557
insilmaril@398
  3558
	switch (me->getMapLinkStyle())
insilmaril@390
  3559
	{
insilmaril@473
  3560
		case LinkableMapObj::Line: 
insilmaril@390
  3561
			actionFormatLinkStyleLine->setOn(true);
insilmaril@390
  3562
			break;
insilmaril@473
  3563
		case LinkableMapObj::Parabel:
insilmaril@390
  3564
			actionFormatLinkStyleParabel->setOn(true);
insilmaril@390
  3565
			break;
insilmaril@473
  3566
		case LinkableMapObj::PolyLine:	
insilmaril@390
  3567
			actionFormatLinkStylePolyLine->setOn(true);
insilmaril@390
  3568
			break;
insilmaril@473
  3569
		case LinkableMapObj::PolyParabel:	
insilmaril@390
  3570
			actionFormatLinkStylePolyParabel->setOn(true);
insilmaril@390
  3571
			break;
insilmaril@390
  3572
		default:
insilmaril@390
  3573
			break;
insilmaril@390
  3574
	}	
insilmaril@390
  3575
insilmaril@442
  3576
	// Update colors
insilmaril@390
  3577
	QPixmap pix( 16, 16 );
insilmaril@398
  3578
    pix.fill( me->getMapBackgroundColor() );
insilmaril@390
  3579
    actionFormatBackColor->setIconSet( pix );
insilmaril@442
  3580
    pix.fill( me->getSelectionColor() );
insilmaril@442
  3581
    actionFormatSelectionColor->setIconSet( pix );
insilmaril@398
  3582
    pix.fill( me->getMapDefLinkColor() );
insilmaril@390
  3583
    actionFormatLinkColor->setIconSet( pix );
insilmaril@390
  3584
insilmaril@442
  3585
insilmaril@486
  3586
	actionFileSave->setEnabled( me->hasChanged() );
insilmaril@390
  3587
	if (me->isUndoAvailable())
insilmaril@390
  3588
		actionEditUndo->setEnabled( true);
insilmaril@390
  3589
	else	
insilmaril@390
  3590
		actionEditUndo->setEnabled( false);
insilmaril@390
  3591
insilmaril@390
  3592
	if (me->isRedoAvailable())
insilmaril@390
  3593
		actionEditRedo->setEnabled( true);
insilmaril@390
  3594
	else	
insilmaril@390
  3595
		actionEditRedo->setEnabled( false);
insilmaril@390
  3596
insilmaril@390
  3597
	LinkableMapObj *selection=me->getSelection();
insilmaril@390
  3598
	if (selection)
insilmaril@390
  3599
	{
insilmaril@390
  3600
		if ( (typeid(*selection) == typeid(BranchObj)) || 
insilmaril@390
  3601
			(typeid(*selection) == typeid(MapCenterObj))  )
insilmaril@390
  3602
		{
insilmaril@390
  3603
			BranchObj *bo=(BranchObj*)selection;
insilmaril@390
  3604
			// Take care of links
insilmaril@390
  3605
			if (bo->countXLinks()==0)
insilmaril@390
  3606
			{
insilmaril@390
  3607
				branchXLinksContextMenuEdit->clear();
insilmaril@390
  3608
				branchXLinksContextMenuFollow->clear();
insilmaril@390
  3609
			} else
insilmaril@390
  3610
			{
insilmaril@390
  3611
				BranchObj *bot;
insilmaril@390
  3612
				QString s;
insilmaril@390
  3613
				branchXLinksContextMenuEdit->clear();
insilmaril@390
  3614
				branchXLinksContextMenuFollow->clear();
insilmaril@390
  3615
				for (int i=0; i<=bo->countXLinks();i++)
insilmaril@390
  3616
				{
insilmaril@390
  3617
					bot=bo->XLinkTargetAt(i);
insilmaril@390
  3618
					if (bot)
insilmaril@390
  3619
					{
insilmaril@390
  3620
						s=bot->getHeading();
insilmaril@600
  3621
						if (s.length()>xLinkMenuWidth)
insilmaril@600
  3622
							s=s.left(xLinkMenuWidth)+"...";
insilmaril@390
  3623
						branchXLinksContextMenuFollow->addAction (s);
insilmaril@390
  3624
						branchXLinksContextMenuEdit->addAction (s);
insilmaril@390
  3625
					}	
insilmaril@390
  3626
				}
insilmaril@390
  3627
			}
insilmaril@390
  3628
insilmaril@390
  3629
			standardFlagsDefault->setEnabled (true);
insilmaril@390
  3630
insilmaril@390
  3631
			actionEditToggleScroll->setEnabled (true);
insilmaril@390
  3632
			if ( bo->isScrolled() )
insilmaril@390
  3633
				actionEditToggleScroll->setOn(true);
insilmaril@390
  3634
			else	
insilmaril@390
  3635
				actionEditToggleScroll->setOn(false);
insilmaril@390
  3636
insilmaril@390
  3637
			if ( bo->getURL().isEmpty() )
insilmaril@390
  3638
			{
insilmaril@390
  3639
				actionEditOpenURL->setEnabled (false);
insilmaril@390
  3640
				actionEditOpenURLTab->setEnabled (false);
insilmaril@390
  3641
			}	
insilmaril@390
  3642
			else	
insilmaril@390
  3643
			{
insilmaril@390
  3644
				actionEditOpenURL->setEnabled (true);
insilmaril@390
  3645
				actionEditOpenURLTab->setEnabled (true);
insilmaril@390
  3646
			}
insilmaril@390
  3647
			if ( bo->getVymLink().isEmpty() )
insilmaril@390
  3648
			{
insilmaril@390
  3649
				actionEditOpenVymLink->setEnabled (false);
insilmaril@390
  3650
				actionEditDeleteVymLink->setEnabled (false);
insilmaril@390
  3651
			} else	
insilmaril@390
  3652
			{
insilmaril@390
  3653
				actionEditOpenVymLink->setEnabled (true);
insilmaril@390
  3654
				actionEditDeleteVymLink->setEnabled (true);
insilmaril@390
  3655
			}	
insilmaril@390
  3656
insilmaril@390
  3657
			if (bo->canMoveBranchUp()) 
insilmaril@390
  3658
				actionEditMoveUp->setEnabled (true);
insilmaril@390
  3659
			else	
insilmaril@390
  3660
				actionEditMoveUp->setEnabled (false);
insilmaril@390
  3661
			if (bo->canMoveBranchDown()) 
insilmaril@390
  3662
				actionEditMoveDown->setEnabled (true);
insilmaril@390
  3663
			else	
insilmaril@390
  3664
				actionEditMoveDown->setEnabled (false);
insilmaril@390
  3665
insilmaril@390
  3666
insilmaril@390
  3667
			actionEditToggleHideExport->setEnabled (true);	
insilmaril@390
  3668
			actionEditToggleHideExport->setOn (bo->hideInExport() );	
insilmaril@390
  3669
insilmaril@390
  3670
			actionEditCopy->setEnabled (true);	
insilmaril@390
  3671
			actionEditCut->setEnabled (true);	
insilmaril@390
  3672
			if (!clipboardEmpty)
insilmaril@390
  3673
				actionEditPaste->setEnabled (true);	
insilmaril@390
  3674
			else	
insilmaril@390
  3675
				actionEditPaste->setEnabled (false);	
insilmaril@406
  3676
			for (int i=0; i<actionListBranches.size(); ++i)	
insilmaril@406
  3677
				actionListBranches.at(i)->setEnabled(true);
insilmaril@390
  3678
			actionEditDelete->setEnabled (true);
insilmaril@390
  3679
			actionFormatHideLinkUnselected->setOn
insilmaril@390
  3680
				(selection->getHideLinkUnselected());
insilmaril@390
  3681
		}
insilmaril@390
  3682
		if ( (typeid(*selection) == typeid(FloatImageObj)) )
insilmaril@390
  3683
		{
insilmaril@390
  3684
			FloatObj *fo=(FloatImageObj*)selection;
insilmaril@390
  3685
insilmaril@390
  3686
			actionEditOpenURL->setEnabled (false);
insilmaril@390
  3687
			actionEditOpenVymLink->setEnabled (false);
insilmaril@390
  3688
			actionEditDeleteVymLink->setEnabled (false);	
insilmaril@390
  3689
			actionEditToggleHideExport->setEnabled (true);	
insilmaril@390
  3690
			actionEditToggleHideExport->setOn (fo->hideInExport() );	
insilmaril@390
  3691
insilmaril@390
  3692
insilmaril@390
  3693
			actionEditCopy->setEnabled (true);
insilmaril@390
  3694
			actionEditCut->setEnabled (true);	
insilmaril@390
  3695
			actionEditPaste->setEnabled (false);
insilmaril@406
  3696
			for (int i=0; i<actionListBranches.size(); ++i)	
insilmaril@406
  3697
				actionListBranches.at(i)->setEnabled(false);
insilmaril@390
  3698
			actionEditDelete->setEnabled (true);
insilmaril@390
  3699
			actionFormatHideLinkUnselected->setOn
insilmaril@390
  3700
				( selection->getHideLinkUnselected());
insilmaril@390
  3701
			actionEditMoveUp->setEnabled (false);
insilmaril@390
  3702
			actionEditMoveDown->setEnabled (false);
insilmaril@390
  3703
		}
insilmaril@390
  3704
insilmaril@390
  3705
	} else
insilmaril@390
  3706
	{
insilmaril@390
  3707
		actionEditCopy->setEnabled (false);	
insilmaril@390
  3708
		actionEditCut->setEnabled (false);	
insilmaril@390
  3709
		actionEditPaste->setEnabled (false);	
insilmaril@406
  3710
		for (int i=0; i<actionListBranches.size(); ++i)	
insilmaril@406
  3711
			actionListBranches.at(i)->setEnabled(false);
insilmaril@390
  3712
insilmaril@390
  3713
		actionEditToggleScroll->setEnabled (false);
insilmaril@390
  3714
		actionEditOpenURL->setEnabled (false);
insilmaril@390
  3715
		actionEditOpenVymLink->setEnabled (false);
insilmaril@390
  3716
		actionEditDeleteVymLink->setEnabled (false);	
insilmaril@390
  3717
		actionEditHeading2URL->setEnabled (false);	
insilmaril@390
  3718
		actionEditDelete->setEnabled (false);
insilmaril@390
  3719
		actionEditMoveUp->setEnabled (false);
insilmaril@390
  3720
		actionEditMoveDown->setEnabled (false);
insilmaril@390
  3721
		actionEditToggleHideExport->setEnabled (false);	
insilmaril@390
  3722
	}	
insilmaril@390
  3723
}
insilmaril@390
  3724
insilmaril@473
  3725
Main::ModMode Main::getModMode()
insilmaril@390
  3726
{
insilmaril@390
  3727
	if (actionModModeColor->isOn()) return ModModeColor;
insilmaril@390
  3728
	if (actionModModeCopy->isOn()) return ModModeCopy;
insilmaril@390
  3729
	if (actionModModeXLink->isOn()) return ModModeXLink;
insilmaril@390
  3730
	return ModModeNone;
insilmaril@390
  3731
}
insilmaril@390
  3732
insilmaril@537
  3733
bool Main::autoEditNewBranch()
insilmaril@390
  3734
{
insilmaril@537
  3735
	return actionSettingsAutoEditNewBranch->isOn();
insilmaril@390
  3736
}
insilmaril@390
  3737
insilmaril@537
  3738
bool Main::autoSelectNewBranch()
insilmaril@390
  3739
{
insilmaril@537
  3740
	return actionSettingsAutoSelectNewBranch->isOn();
insilmaril@390
  3741
}
insilmaril@390
  3742
insilmaril@390
  3743
bool Main::useFlagGroups()
insilmaril@390
  3744
{
insilmaril@390
  3745
	return actionSettingsUseFlagGroups->isOn();
insilmaril@390
  3746
}
insilmaril@390
  3747
insilmaril@0
  3748
void Main::windowShowNoteEditor()
insilmaril@0
  3749
{
insilmaril@497
  3750
	textEditor->setShowWithMain(true);
insilmaril@0
  3751
	textEditor->show();
insilmaril@0
  3752
	actionViewToggleNoteEditor->setOn (true);
insilmaril@0
  3753
}
insilmaril@0
  3754
insilmaril@0
  3755
void Main::windowHideNoteEditor()
insilmaril@0
  3756
{
insilmaril@497
  3757
	textEditor->setShowWithMain(false);
insilmaril@0
  3758
	textEditor->hide();
insilmaril@0
  3759
	actionViewToggleNoteEditor->setOn (false);
insilmaril@0
  3760
}
insilmaril@0
  3761
insilmaril@434
  3762
void Main::setScript (const QString &script)
insilmaril@434
  3763
{
insilmaril@434
  3764
	scriptEditor->setScript (script);
insilmaril@434
  3765
}
insilmaril@434
  3766
insilmaril@434
  3767
void Main::runScript (const QString &script)
insilmaril@432
  3768
{
insilmaril@432
  3769
	if (currentMapEditor())
insilmaril@432
  3770
		currentMapEditor()->runScript (script);
insilmaril@432
  3771
}
insilmaril@432
  3772
insilmaril@514
  3773
void Main::runScriptEverywhere (const QString &script)
insilmaril@514
  3774
{
insilmaril@514
  3775
	MapEditor *me;
insilmaril@514
  3776
	for (int i=0;i<=tabWidget->count() -1;i++)
insilmaril@514
  3777
	{
insilmaril@514
  3778
		me=(MapEditor*)tabWidget->page(i);
insilmaril@514
  3779
		if (me) me->runScript (script);
insilmaril@514
  3780
	}	
insilmaril@514
  3781
}
insilmaril@514
  3782
insilmaril@0
  3783
void Main::windowNextEditor()
insilmaril@0
  3784
{
insilmaril@0
  3785
	if (tabWidget->currentPageIndex() < tabWidget->count())
insilmaril@0
  3786
		tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
insilmaril@0
  3787
}
insilmaril@0
  3788
insilmaril@0
  3789
void Main::windowPreviousEditor()
insilmaril@0
  3790
{
insilmaril@0
  3791
	if (tabWidget->currentPageIndex() >0)
insilmaril@0
  3792
		tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
insilmaril@0
  3793
}
insilmaril@0
  3794
insilmaril@0
  3795
void Main::standardFlagChanged()
insilmaril@0
  3796
{
insilmaril@421
  3797
	if (currentMapEditor())
insilmaril@421
  3798
		currentMapEditor()->toggleStandardFlag(sender()->name());
insilmaril@0
  3799
}
insilmaril@0
  3800
insilmaril@527
  3801
void Main::testFunction1()
insilmaril@0
  3802
{
insilmaril@393
  3803
	if (!currentMapEditor()) return;
insilmaril@616
  3804
	//currentMapEditor()->testFunction1();
insilmaril@616
  3805
	editAttribute();
insilmaril@527
  3806
}
insilmaril@527
  3807
insilmaril@527
  3808
void Main::testFunction2()
insilmaril@527
  3809
{
insilmaril@527
  3810
	if (!currentMapEditor()) return;
insilmaril@564
  3811
	currentMapEditor()->testFunction2();
insilmaril@0
  3812
}
insilmaril@0
  3813
insilmaril@393
  3814
void Main::testCommand()
insilmaril@393
  3815
{
insilmaril@393
  3816
	if (!currentMapEditor()) return;
insilmaril@432
  3817
	scriptEditor->show();
insilmaril@432
  3818
	/*
insilmaril@393
  3819
	bool ok;
insilmaril@393
  3820
	QString com = QInputDialog::getText(
insilmaril@404
  3821
			vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
insilmaril@393
  3822
	if (ok) currentMapEditor()->parseAtom(com);
insilmaril@432
  3823
	*/
insilmaril@393
  3824
}
insilmaril@393
  3825
insilmaril@0
  3826
void Main::helpDoc()
insilmaril@0
  3827
{
insilmaril@395
  3828
	QString locale = QLocale::system().name();
insilmaril@395
  3829
	QString docname;
insilmaril@395
  3830
	if (locale.left(2)=="es")
insilmaril@395
  3831
		docname="vym_es.pdf";
insilmaril@395
  3832
	else	
insilmaril@395
  3833
		docname="vym.pdf";
insilmaril@420
  3834
insilmaril@420
  3835
	QStringList searchList;
insilmaril@395
  3836
	QDir docdir;
insilmaril@103
  3837
	#if defined(Q_OS_MACX)
insilmaril@537
  3838
		searchList << "./vym.app/Contents/Resources/doc";
insilmaril@625
  3839
    #elif defined(Q_OS_WIN32)
insilmaril@625
  3840
        searchList << vymInstallDir.path() + "/share/doc/packages/vym";
insilmaril@103
  3841
	#else
insilmaril@608
  3842
		#if defined(VYM_DOCDIR)
insilmaril@608
  3843
			searchList << VYM_DOCDIR;
insilmaril@608
  3844
		#endif
insilmaril@103
  3845
		// default path in SUSE LINUX
insilmaril@625
  3846
		searchList << "/usr/share/doc/packages/vym";
insilmaril@103
  3847
	#endif
insilmaril@0
  3848
insilmaril@420
  3849
	searchList << "doc";	// relative path for easy testing in tarball
insilmaril@420
  3850
	searchList << "doc/tex";	// Easy testing working on vym.tex
insilmaril@420
  3851
	searchList << "/usr/share/doc/vym";	// Debian
insilmaril@420
  3852
	searchList << "/usr/share/doc/packages";// Knoppix
insilmaril@420
  3853
insilmaril@420
  3854
	bool found=false;
insilmaril@420
  3855
	QFile docfile;
insilmaril@420
  3856
	for (int i=0; i<searchList.count(); ++i)
insilmaril@0
  3857
	{
insilmaril@625
  3858
		docfile.setFileName(searchList.at(i)+"/"+docname);
insilmaril@625
  3859
		if (docfile.exists())
insilmaril@0
  3860
		{
insilmaril@420
  3861
			found=true;
insilmaril@420
  3862
			break;
insilmaril@420
  3863
		}	
insilmaril@0
  3864
	}
insilmaril@625
  3865
insilmaril@420
  3866
	if (!found)
insilmaril@420
  3867
	{
insilmaril@420
  3868
		QMessageBox::critical(0, 
insilmaril@420
  3869
			tr("Critcal error"),
insilmaril@420
  3870
			tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
insilmaril@420
  3871
		return;
insilmaril@420
  3872
	}	
insilmaril@420
  3873
insilmaril@408
  3874
	QStringList args;
insilmaril@0
  3875
	Process *pdfProc = new Process();
insilmaril@625
  3876
    args << QDir::toNativeSeparators(docfile.fileName());
insilmaril@420
  3877
insilmaril@420
  3878
	pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
insilmaril@408
  3879
	if ( !pdfProc->waitForStarted() ) 
insilmaril@0
  3880
	{
insilmaril@0
  3881
		// error handling
insilmaril@266
  3882
		QMessageBox::warning(0, 
insilmaril@266
  3883
			tr("Warning"),
insilmaril@420
  3884
			tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
insilmaril@266
  3885
			tr("Please use Settings->")+tr("Set application to open PDF files"));
insilmaril@266
  3886
		settingsPDF();	
insilmaril@0
  3887
		return;
insilmaril@0
  3888
	}
insilmaril@0
  3889
}
insilmaril@0
  3890
insilmaril@0
  3891
insilmaril@505
  3892
void Main::helpDemo()
insilmaril@505
  3893
{
insilmaril@505
  3894
	QStringList filters;
insilmaril@505
  3895
	filters <<"VYM example map (*.vym)";
insilmaril@505
  3896
	QFileDialog *fd=new QFileDialog( this);
insilmaril@595
  3897
	#if defined(Q_OS_MACX)
insilmaril@595
  3898
		fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
insilmaril@595
  3899
	#else
insilmaril@595
  3900
		// default path in SUSE LINUX
insilmaril@595
  3901
		fd->setDir (QDir(vymBaseDir.path()+"/demos"));
insilmaril@595
  3902
	#endif
insilmaril@595
  3903
insilmaril@505
  3904
	fd->setFileMode (QFileDialog::ExistingFiles);
insilmaril@505
  3905
	fd->setFilters (filters);
insilmaril@505
  3906
	fd->setCaption(vymName+ " - " +tr("Load vym example map"));
insilmaril@505
  3907
	fd->show();
insilmaril@505
  3908
insilmaril@505
  3909
	QString fn;
insilmaril@505
  3910
	if ( fd->exec() == QDialog::Accepted )
insilmaril@505
  3911
	{
insilmaril@505
  3912
		lastFileDir=fd->directory().path();
insilmaril@505
  3913
	    QStringList flist = fd->selectedFiles();
insilmaril@505
  3914
		QStringList::Iterator it = flist.begin();
insilmaril@505
  3915
		while( it != flist.end() ) 
insilmaril@505
  3916
		{
insilmaril@505
  3917
			fn = *it;
insilmaril@505
  3918
			fileLoad(*it, NewMap);				   
insilmaril@505
  3919
			++it;
insilmaril@505
  3920
		}
insilmaril@505
  3921
	}
insilmaril@505
  3922
	delete (fd);
insilmaril@505
  3923
}
insilmaril@505
  3924
insilmaril@505
  3925
insilmaril@0
  3926
void Main::helpAbout()
insilmaril@0
  3927
{
insilmaril@148
  3928
	AboutDialog ad;
insilmaril@150
  3929
	ad.setName ("aboutwindow");
insilmaril@148
  3930
	ad.setMinimumSize(500,500);
insilmaril@148
  3931
	ad.resize (QSize (500,500));
insilmaril@148
  3932
	ad.exec();
insilmaril@0
  3933
}
insilmaril@0
  3934
insilmaril@0
  3935
void Main::helpAboutQT()
insilmaril@0
  3936
{
insilmaril@0
  3937
	QMessageBox::aboutQt( this, "Qt Application Example" );
insilmaril@0
  3938
}
insilmaril@0
  3939
insilmaril@445
  3940
void Main::callMacro ()
insilmaril@445
  3941
{
insilmaril@445
  3942
    QAction *action = qobject_cast<QAction *>(sender());
insilmaril@445
  3943
	int i=-1;
insilmaril@445
  3944
    if (action)
insilmaril@445
  3945
	{
insilmaril@445
  3946
        i=action->data().toInt();
insilmaril@447
  3947
		QString mDir (settings.value ("macros/macroDir").toString() );
insilmaril@447
  3948
insilmaril@447
  3949
		QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
insilmaril@447
  3950
		QFile f (fn);
insilmaril@447
  3951
		if ( !f.open( QIODevice::ReadOnly ) )
insilmaril@447
  3952
		{
insilmaril@447
  3953
			QMessageBox::warning(0, 
insilmaril@447
  3954
				tr("Warning"),
insilmaril@447
  3955
				tr("Couldn't find a macro at  %1.\n").arg(fn)+
insilmaril@447
  3956
				tr("Please use Settings->")+tr("Set directory for vym macros"));
insilmaril@447
  3957
			return;
insilmaril@447
  3958
		}	
insilmaril@447
  3959
insilmaril@447
  3960
		QTextStream ts( &f );
insilmaril@447
  3961
		QString m= ts.read();
insilmaril@447
  3962
insilmaril@445
  3963
		if (! m.isEmpty())
insilmaril@445
  3964
		{
insilmaril@658
  3965
			//cout <<"Main::callMacro  m="<<qPrintable (m)<<endl;
insilmaril@445
  3966
			currentMapEditor()->runScript (m);
insilmaril@445
  3967
		}	
insilmaril@445
  3968
	}	
insilmaril@445
  3969
}
insilmaril@445
  3970
insilmaril@608
  3971
insilmaril@608
  3972
insilmaril@608
  3973
//////////////////////////////////
insilmaril@608
  3974
/*
insilmaril@608
  3975
@@ -2544,18 +2576,27 @@
insilmaril@608
  3976
 				// Try to open new tab in existing konqueror started previously by vym
insilmaril@608
  3977
 				p=new QProcess (this);
insilmaril@608
  3978
 				args.clear();
insilmaril@608
  3979
-				args<< QString("konqueror-%1").arg(procBrowser->pid())<< 
insilmaril@608
  3980
-					"konqueror-mainwindow#1"<< 
insilmaril@608
  3981
-					"newTab" << 
insilmaril@608
  3982
+#if defined(Q_OS_WIN32)
insilmaril@608
  3983
+                // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
insilmaril@608
  3984
+                // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
insilmaril@608
  3985
+				args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
insilmaril@608
  3986
+					"konqueror-mainwindow#1"<<
insilmaril@608
  3987
+					"newTab" <<
insilmaril@608
  3988
 					urls.at(i);
insilmaril@608
  3989
+#else
insilmaril@608
  3990
+				args<< QString("konqueror-%1").arg(procBrowser->pid())<<
insilmaril@608
  3991
+					"konqueror-mainwindow#1"<<
insilmaril@608
  3992
+					"newTab" <<
insilmaril@608
  3993
+					urls.at(i);
insilmaril@608
  3994
+#endif
insilmaril@608
  3995
 				p->start ("dcop",args);
insilmaril@608
  3996
 				if ( !p->waitForStarted() ) success=false;
insilmaril@608
  3997
 			}
insilmaril@608
  3998
*/