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