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