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