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