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