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