mainwindow.cpp
author insilmaril
Tue, 06 Nov 2007 13:54:41 +0000
changeset 615 497f19b3c1fe
parent 614 040f32294895
child 616 16d63fc9ae42
permissions -rw-r--r--
1.11.1 fixed undo/redo sorting of branches
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@269
    71
extern QString iconPath;
insilmaril@269
    72
extern QString flagsPath;
insilmaril@0
    73
insilmaril@366
    74
Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
insilmaril@0
    75
    QMainWindow(parent,name,f)
insilmaril@0
    76
{
insilmaril@0
    77
	mainWindow=this;
insilmaril@0
    78
insilmaril@0
    79
	setCaption ("VYM - View Your Mind");
insilmaril@0
    80
insilmaril@0
    81
	// Load window settings
insilmaril@366
    82
	resize (settings.value( "/mainwindow/geometry/size",QSize (800,600)).toSize());
insilmaril@366
    83
	move   (settings.value( "/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
insilmaril@0
    84
insilmaril@0
    85
insilmaril@394
    86
	// Sometimes we may need to remember old selections
insilmaril@394
    87
	prevSelection="";
insilmaril@394
    88
insilmaril@395
    89
	// Default color
insilmaril@395
    90
	currentColor=Qt::black;
insilmaril@395
    91
insilmaril@164
    92
	// Create unique temporary directory
insilmaril@366
    93
	bool ok;
insilmaril@608
    94
	tmpVymDir=makeTmpDir (ok,"vym");
insilmaril@366
    95
	if (!ok)
insilmaril@366
    96
	{
insilmaril@366
    97
		qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
insilmaril@366
    98
		exit (1);
insilmaril@366
    99
	}
insilmaril@502
   100
	if (debug) qDebug (QString("vym tmpDir=%1").arg(tmpVymDir) );
insilmaril@164
   101
insilmaril@166
   102
	// Create direcctory for clipboard
insilmaril@166
   103
	clipboardDir=tmpVymDir+"/clipboard";
insilmaril@502
   104
	clipboardFile="map.xml";
insilmaril@166
   105
	QDir d(clipboardDir);
insilmaril@166
   106
	d.mkdir (clipboardDir,true);
insilmaril@166
   107
	makeSubDirs (clipboardDir);
insilmaril@166
   108
	clipboardEmpty=true;
insilmaril@164
   109
insilmaril@266
   110
	procBrowser=NULL;
insilmaril@266
   111
insilmaril@486
   112
	// Satellite windows //////////////////////////////////////////
insilmaril@486
   113
insilmaril@486
   114
	// history window
insilmaril@404
   115
	historyWindow=new HistoryWindow();
insilmaril@486
   116
	connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
insilmaril@486
   117
insilmaril@486
   118
	// properties window
insilmaril@421
   119
	branchPropertyWindow = new BranchPropertyWindow();
insilmaril@486
   120
	connect (branchPropertyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
insilmaril@486
   121
insilmaril@486
   122
	// Connect TextEditor, so that we can update flags if text changes
insilmaril@486
   123
	connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
insilmaril@486
   124
	connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
insilmaril@486
   125
insilmaril@486
   126
	// Connect HistoryWindow, so that we can update flags
insilmaril@486
   127
	connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
insilmaril@473
   128
insilmaril@421
   129
insilmaril@432
   130
	// Initialize script editor
insilmaril@432
   131
	scriptEditor = new SimpleScriptEditor();
insilmaril@432
   132
	scriptEditor->move (50,50);
insilmaril@432
   133
insilmaril@432
   134
	connect( scriptEditor, SIGNAL( runScript ( QString ) ), 
insilmaril@432
   135
		this, SLOT( runScript( QString ) ) );
insilmaril@432
   136
	
insilmaril@486
   137
insilmaril@486
   138
	// Initialize Find window
insilmaril@486
   139
	findWindow=new FindWindow(NULL);
insilmaril@486
   140
	findWindow->move (x(),y()+70);
insilmaril@486
   141
	connect (findWindow, SIGNAL( findButton(QString) ), 
insilmaril@486
   142
		this, SLOT(editFind(QString) ) );	
insilmaril@486
   143
	connect (findWindow, SIGNAL( somethingChanged() ), 
insilmaril@486
   144
		this, SLOT(editFindChanged() ) );	
insilmaril@486
   145
insilmaril@0
   146
	// Initialize some settings, which are platform dependant
insilmaril@0
   147
	QString p,s;
insilmaril@0
   148
insilmaril@0
   149
		// application to open URLs
insilmaril@366
   150
		p="/mainwindow/readerURL";
insilmaril@0
   151
		#if defined(Q_OS_LINUX)
insilmaril@608
   152
			s=settings.value (p,"xdg-open").toString();
insilmaril@0
   153
		#else
insilmaril@0
   154
			#if defined(Q_OS_MACX)
insilmaril@366
   155
				s=settings.value (p,"/usr/bin/open").toString();
insilmaril@608
   156
insilmaril@608
   157
            #else
insilmaril@608
   158
                #if defined(Q_OS_WIN32)
insilmaril@608
   159
                    // Assume that system has been set up so that
insilmaril@608
   160
                    // Explorer automagically opens up the URL
insilmaril@608
   161
                    // in the user's preferred browser.
insilmaril@608
   162
                    s=settings.value (p,"explorer").toString();
insilmaril@608
   163
                #else
insilmaril@608
   164
					s=settings.value (p,"mozilla").toString();
insilmaril@608
   165
				#endif
insilmaril@0
   166
			#endif
insilmaril@0
   167
		#endif
insilmaril@366
   168
		settings.setValue( p,s);
insilmaril@0
   169
insilmaril@0
   170
		// application to open PDFs
insilmaril@366
   171
		p="/mainwindow/readerPDF";
insilmaril@0
   172
		#if defined(Q_OS_LINUX)
insilmaril@608
   173
			s=settings.value (p,"xdg-open").toString();
insilmaril@0
   174
		#else
insilmaril@0
   175
			#if defined(Q_OS_MACX)
insilmaril@366
   176
				s=settings.value (p,"/usr/bin/open").toString();
insilmaril@0
   177
			#else
insilmaril@366
   178
				s=settings.value (p,"acroread").toString();
insilmaril@0
   179
			#endif
insilmaril@0
   180
		#endif
insilmaril@366
   181
		settings.setValue( p,s);
insilmaril@0
   182
insilmaril@600
   183
	// width of xLinksMenu
insilmaril@600
   184
	xLinkMenuWidth=60;
insilmaril@0
   185
	
insilmaril@0
   186
	// Create tab widget which holds the maps
insilmaril@0
   187
	tabWidget= new QTabWidget (this);
insilmaril@0
   188
	connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ), 
insilmaril@0
   189
		this, SLOT( editorChanged( QWidget * ) ) );
insilmaril@0
   190
insilmaril@366
   191
	lineedit=new QLineEdit (this);
insilmaril@366
   192
	lineedit->hide();
insilmaril@366
   193
insilmaril@0
   194
	setCentralWidget(tabWidget);	
insilmaril@0
   195
insilmaril@0
   196
    setupFileActions();
insilmaril@0
   197
    setupEditActions();
insilmaril@0
   198
    setupFormatActions();
insilmaril@0
   199
    setupViewActions();
insilmaril@89
   200
    setupModeActions();
insilmaril@0
   201
	setupFlagActions();
insilmaril@528
   202
    setupNetworkActions();
insilmaril@0
   203
    setupSettingsActions();
insilmaril@0
   204
	setupContextMenus();
insilmaril@445
   205
	setupMacros();
insilmaril@366
   206
    if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
insilmaril@0
   207
    setupHelpActions();
insilmaril@0
   208
    
insilmaril@0
   209
    statusBar();
insilmaril@0
   210
insilmaril@366
   211
	restoreState (settings.value("/mainwindow/state",0).toByteArray());
insilmaril@0
   212
insilmaril@0
   213
	updateGeometry();
insilmaril@0
   214
}
insilmaril@0
   215
insilmaril@0
   216
Main::~Main()
insilmaril@0
   217
{
insilmaril@0
   218
	// Save Settings
insilmaril@366
   219
	settings.setValue ( "/mainwindow/geometry/size", size() );
insilmaril@366
   220
	settings.setValue ( "/mainwindow/geometry/pos", pos() );
insilmaril@366
   221
	settings.setValue ("/mainwindow/state",saveState(0));
insilmaril@366
   222
insilmaril@408
   223
	settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
insilmaril@408
   224
	settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
insilmaril@404
   225
	settings.setValue( "/version/version", vymVersion );
insilmaril@404
   226
	settings.setValue( "/version/builddate", vymBuildDate );
insilmaril@366
   227
insilmaril@491
   228
	settings.setValue( "/mapeditor/autosave/use",actionSettingsAutosaveToggle->isOn() );
insilmaril@537
   229
	settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isOn() );
insilmaril@390
   230
	settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
insilmaril@537
   231
	settings.setValue( "/mapeditor/editmode/autoEditNewBranch",actionSettingsAutoEditNewBranch->isOn() );
insilmaril@366
   232
	settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
insilmaril@366
   233
	settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
insilmaril@366
   234
	settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
insilmaril@0
   235
insilmaril@473
   236
	//TODO save scriptEditor settings
insilmaril@432
   237
insilmaril@404
   238
	// call the destructors
insilmaril@442
   239
	delete textEditor;
insilmaril@404
   240
	delete historyWindow;
insilmaril@473
   241
	delete branchPropertyWindow;
insilmaril@164
   242
insilmaril@164
   243
	// Remove temporary directory
insilmaril@164
   244
	removeDir (QDir(tmpVymDir));
insilmaril@0
   245
}
insilmaril@0
   246
insilmaril@0
   247
void Main::loadCmdLine()
insilmaril@0
   248
{
insilmaril@0
   249
	/* TODO draw some kind of splashscreen while loading...
insilmaril@0
   250
	if (qApp->argc()>1)
insilmaril@0
   251
	{
insilmaril@0
   252
	}
insilmaril@0
   253
	*/
insilmaril@0
   254
	
insilmaril@0
   255
	QStringList flist=options.getFileList();
insilmaril@0
   256
	QStringList::Iterator it=flist.begin();
insilmaril@0
   257
insilmaril@0
   258
	while (it !=flist.end() )
insilmaril@0
   259
	{
insilmaril@0
   260
		fileLoad (*it, NewMap);
insilmaril@0
   261
		*it++;
insilmaril@0
   262
	}	
insilmaril@0
   263
}
insilmaril@0
   264
insilmaril@0
   265
insilmaril@0
   266
void Main::statusMessage(const QString &s)
insilmaril@0
   267
{
insilmaril@502
   268
	statusBar()->message( s);
insilmaril@0
   269
}
insilmaril@0
   270
insilmaril@0
   271
void Main::closeEvent (QCloseEvent* )
insilmaril@0
   272
{
insilmaril@0
   273
	fileExitVYM();
insilmaril@0
   274
}
insilmaril@0
   275
insilmaril@0
   276
// File Actions
insilmaril@0
   277
void Main::setupFileActions()
insilmaril@0
   278
{
insilmaril@366
   279
	QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
insilmaril@366
   280
    QToolBar *tb = addToolBar( tr ("&Map") );
insilmaril@366
   281
	tb->setObjectName ("mapTB");
insilmaril@0
   282
insilmaril@0
   283
    QAction *a;
insilmaril@491
   284
    a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this);
insilmaril@395
   285
	a->setStatusTip ( tr( "New map","Status tip File menu" ) );
insilmaril@442
   286
	a->setShortcut ( Qt::CTRL + Qt::Key_N );		//New map
insilmaril@0
   287
    a->addTo( tb );
insilmaril@366
   288
	fileMenu->addAction (a);
insilmaril@366
   289
    connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
insilmaril@0
   290
	
insilmaril@494
   291
    a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this);
insilmaril@491
   292
	a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) );
insilmaril@491
   293
	a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N );		//New map
insilmaril@491
   294
	fileMenu->addAction (a);
insilmaril@491
   295
    connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) );
insilmaril@491
   296
	
insilmaril@395
   297
    a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
insilmaril@395
   298
	a->setStatusTip (tr( "Open","Status tip File menu" ) );
insilmaril@442
   299
	a->setShortcut ( Qt::CTRL + Qt::Key_O );		//Open map
insilmaril@0
   300
    a->addTo( tb );
insilmaril@366
   301
	fileMenu->addAction (a);
insilmaril@366
   302
    connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
insilmaril@0
   303
	
insilmaril@395
   304
	fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
insilmaril@366
   305
	fileMenu->addSeparator();
insilmaril@0
   306
	
insilmaril@395
   307
    a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
insilmaril@395
   308
	a->setStatusTip ( tr( "Save","Status tip file menu" ));
insilmaril@442
   309
	a->setShortcut (Qt::CTRL + Qt::Key_S );			//Save map
insilmaril@0
   310
    a->addTo( tb );
insilmaril@366
   311
	fileMenu->addAction (a);
insilmaril@366
   312
    connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
insilmaril@0
   313
	actionFileSave=a;
insilmaril@0
   314
	
insilmaril@395
   315
    a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
insilmaril@395
   316
	a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
insilmaril@366
   317
	fileMenu->addAction (a);
insilmaril@366
   318
    connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
insilmaril@366
   319
insilmaril@366
   320
	fileMenu->addSeparator();
insilmaril@366
   321
insilmaril@395
   322
	fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
insilmaril@366
   323
insilmaril@366
   324
	a = new QAction(tr("KDE Bookmarks"), this);
insilmaril@395
   325
	a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE bookmarks")));
insilmaril@366
   326
	a->addTo (fileImportMenu);
insilmaril@366
   327
	connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) );
insilmaril@366
   328
insilmaril@366
   329
    if (settings.value( "/mainwindow/showTestMenu",false).toBool()) 
insilmaril@331
   330
	{
insilmaril@395
   331
		a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
insilmaril@395
   332
		a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
insilmaril@366
   333
		a->addTo (fileImportMenu);
insilmaril@366
   334
		connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
insilmaril@331
   335
	}	
insilmaril@314
   336
insilmaril@571
   337
	a = new QAction("Freemind...",this);
insilmaril@571
   338
	a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Freemind")  );
insilmaril@571
   339
	fileImportMenu->addAction (a);
insilmaril@571
   340
	connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFreemind() ) );
insilmaril@571
   341
insilmaril@366
   342
	a = new QAction("Mind Manager...",this);
insilmaril@395
   343
	a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager")  );
insilmaril@366
   344
	fileImportMenu->addAction (a);
insilmaril@366
   345
	connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
insilmaril@366
   346
insilmaril@395
   347
    a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
insilmaril@395
   348
	a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
insilmaril@366
   349
	fileImportMenu->addAction (a);
insilmaril@366
   350
    connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
insilmaril@366
   351
insilmaril@395
   352
	fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
insilmaril@395
   353
insilmaril@395
   354
	a = new QAction( tr("Image%1","File export menu").arg("..."), this);
insilmaril@395
   355
	a->setStatusTip( tr( "Export map as image","status tip file menu" ));
insilmaril@366
   356
	connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
insilmaril@366
   357
	fileExportMenu->addAction (a);
insilmaril@366
   358
insilmaril@395
   359
	a = new QAction( "Open Office...", this);
insilmaril@395
   360
	a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
insilmaril@366
   361
	connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
insilmaril@366
   362
	fileExportMenu->addAction (a);
insilmaril@366
   363
insilmaril@366
   364
	a = new QAction(  "Webpage (XHTML)...",this );
insilmaril@442
   365
	a->setShortcut (Qt::ALT + Qt::Key_X);			//Export XHTML
insilmaril@395
   366
	a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
insilmaril@366
   367
    connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
insilmaril@366
   368
	fileExportMenu->addAction (a);
insilmaril@366
   369
insilmaril@366
   370
    a = new QAction( "Text (ASCII)...", this);
insilmaril@395
   371
	a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
insilmaril@366
   372
    connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
insilmaril@366
   373
	fileExportMenu->addAction (a);
insilmaril@366
   374
insilmaril@497
   375
    a = new QAction( "Spreadsheet (CSV)...", this);
insilmaril@497
   376
	a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
insilmaril@497
   377
    connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
insilmaril@497
   378
	fileExportMenu->addAction (a);
insilmaril@497
   379
insilmaril@395
   380
	a = new QAction( tr("KDE Bookmarks","File menu"), this);
insilmaril@395
   381
	a->setStatusTip( tr( "Export as %1").arg(tr("KDE Bookmarks" )));
insilmaril@366
   382
	connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
insilmaril@366
   383
	fileExportMenu->addAction (a);
insilmaril@366
   384
insilmaril@366
   385
    a = new QAction( "Taskjuggler...", this );
insilmaril@395
   386
    a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
insilmaril@366
   387
    connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
insilmaril@366
   388
	fileExportMenu->addAction (a);
insilmaril@366
   389
insilmaril@366
   390
    a = new QAction( "LaTeX...", this);
insilmaril@395
   391
    a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
insilmaril@366
   392
    connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
insilmaril@366
   393
	fileExportMenu->addAction (a);
insilmaril@366
   394
insilmaril@366
   395
	a = new QAction( "XML..." , this );
insilmaril@395
   396
	a->setStatusTip (tr( "Export as %1").arg("XML"));
insilmaril@366
   397
    connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
insilmaril@366
   398
	fileExportMenu->addAction (a);
insilmaril@366
   399
insilmaril@366
   400
	fileMenu->addSeparator();
insilmaril@366
   401
insilmaril@366
   402
    a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
insilmaril@395
   403
	a->setStatusTip ( tr( "Print" ,"File menu") );
insilmaril@442
   404
	a->setShortcut (Qt::CTRL + Qt::Key_P );			//Print map
insilmaril@0
   405
    a->addTo( tb );
insilmaril@366
   406
	fileMenu->addAction (a);
insilmaril@366
   407
    connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
insilmaril@0
   408
	actionFilePrint=a;
insilmaril@0
   409
insilmaril@395
   410
    a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
insilmaril@366
   411
	a->setStatusTip (tr( "Close Map" ) );
insilmaril@473
   412
	a->setShortcut (Qt::CTRL + Qt::Key_W );			//Close map
insilmaril@366
   413
	fileMenu->addAction (a);
insilmaril@366
   414
    connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
insilmaril@366
   415
insilmaril@404
   416
    a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
insilmaril@404
   417
	a->setStatusTip ( tr( "Exit")+" "+vymName );
insilmaril@442
   418
	a->setShortcut (Qt::CTRL + Qt::Key_Q );			//Quit vym
insilmaril@366
   419
	fileMenu->addAction (a);
insilmaril@366
   420
    connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
insilmaril@0
   421
}
insilmaril@0
   422
insilmaril@0
   423
insilmaril@0
   424
//Edit Actions
insilmaril@0
   425
void Main::setupEditActions()
insilmaril@0
   426
{
insilmaril@395
   427
    QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
insilmaril@0
   428
    tb->setLabel( "Edit Actions" );
insilmaril@366
   429
	tb->setObjectName ("actionsTB");
insilmaril@395
   430
    QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
insilmaril@0
   431
insilmaril@0
   432
    QAction *a;
insilmaril@102
   433
	QAction *alt;
insilmaril@395
   434
    a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
insilmaril@366
   435
    connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
insilmaril@366
   436
	a->setStatusTip (tr( "Undo" ) );
insilmaril@442
   437
	a->setShortcut ( Qt::CTRL + Qt::Key_Z );		//Undo last action
insilmaril@0
   438
	a->setEnabled (false);
insilmaril@366
   439
    tb->addAction (a);
insilmaril@366
   440
	editMenu->addAction (a);
insilmaril@0
   441
	actionEditUndo=a;
insilmaril@163
   442
    
insilmaril@395
   443
	a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this); 
insilmaril@366
   444
	a->setStatusTip (tr( "Redo" ));
insilmaril@442
   445
	a->setShortcut (Qt::CTRL + Qt::Key_Y );			//Redo last action
insilmaril@366
   446
    tb->addAction (a);
insilmaril@366
   447
	editMenu->addAction (a);
insilmaril@366
   448
	connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
insilmaril@366
   449
	actionEditRedo=a;
insilmaril@163
   450
   
insilmaril@366
   451
	editMenu->addSeparator();
insilmaril@395
   452
    a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
insilmaril@366
   453
	a->setStatusTip ( tr( "Copy" ) );
insilmaril@442
   454
	a->setShortcut (Qt::CTRL + Qt::Key_C );			//Copy
insilmaril@0
   455
	a->setEnabled (false);
insilmaril@366
   456
    tb->addAction (a);
insilmaril@366
   457
	editMenu->addAction (a);
insilmaril@366
   458
    connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
insilmaril@0
   459
	actionEditCopy=a;
insilmaril@366
   460
	
insilmaril@395
   461
    a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
insilmaril@366
   462
	a->setStatusTip ( tr( "Cut" ) );
insilmaril@442
   463
	a->setShortcut (Qt::CTRL + Qt::Key_X );			//Cut
insilmaril@0
   464
	a->setEnabled (false);
insilmaril@366
   465
    tb->addAction (a);
insilmaril@366
   466
	editMenu->addAction (a);
insilmaril@0
   467
	actionEditCut=a;
insilmaril@366
   468
    connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
insilmaril@366
   469
	
insilmaril@395
   470
    a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
insilmaril@366
   471
    connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
insilmaril@366
   472
	a->setStatusTip ( tr( "Paste" ) );
insilmaril@442
   473
	a->setShortcut ( Qt::CTRL + Qt::Key_V );		//Paste
insilmaril@0
   474
	a->setEnabled (false);
insilmaril@366
   475
    tb->addAction (a);
insilmaril@366
   476
	editMenu->addAction (a);
insilmaril@0
   477
	actionEditPaste=a;
insilmaril@98
   478
insilmaril@351
   479
    // Shortcuts to modify heading:
insilmaril@395
   480
    a = new QAction(tr( "Edit heading","Edit menu" ),this);
insilmaril@366
   481
	a->setStatusTip ( tr( "edit Heading" ));
insilmaril@442
   482
	a->setShortcut ( Qt::Key_Enter);				//Edit heading
insilmaril@366
   483
//	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   484
	addAction (a);
insilmaril@366
   485
    connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
insilmaril@351
   486
	actionListBranches.append(a);
insilmaril@395
   487
    a = new QAction( tr( "Edit heading","Edit menu" ), this);
insilmaril@366
   488
	a->setStatusTip (tr( "edit Heading" ));
insilmaril@442
   489
	a->setShortcut (Qt::Key_Return );				//Edit heading
insilmaril@366
   490
	//a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   491
	addAction (a);
insilmaril@366
   492
    connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
insilmaril@351
   493
	actionListBranches.append(a);
insilmaril@366
   494
	editMenu->addAction (a);
insilmaril@351
   495
	actionEditHeading=a;
insilmaril@395
   496
    a = new QAction( tr( "Edit heading","Edit menu" ), this);
insilmaril@366
   497
	a->setStatusTip (tr( "edit Heading" ));
insilmaril@445
   498
	//a->setShortcut ( Qt::Key_F2 );					//Edit heading
insilmaril@366
   499
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   500
	addAction (a);
insilmaril@366
   501
    connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
insilmaril@351
   502
	actionListBranches.append(a);
insilmaril@351
   503
    
insilmaril@351
   504
    // Shortcut to delete selection
insilmaril@395
   505
    a = new QAction( tr( "Delete Selection","Edit menu" ),this);
insilmaril@366
   506
	a->setStatusTip (tr( "Delete Selection" ));
insilmaril@442
   507
	a->setShortcut ( Qt::Key_Delete);				//Delete selection
insilmaril@366
   508
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   509
	addAction (a);
insilmaril@366
   510
    connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
insilmaril@351
   511
	actionEditDelete=a;
insilmaril@351
   512
    
insilmaril@351
   513
    // Shortcut to add branch
insilmaril@395
   514
	alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
insilmaril@366
   515
	alt->setStatusTip ( tr( "Add a branch as child of selection" ));
insilmaril@442
   516
	alt->setShortcut (Qt::Key_A);					//Add branch
insilmaril@366
   517
	alt->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   518
	addAction (alt);
insilmaril@366
   519
	connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
insilmaril@395
   520
	a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
insilmaril@366
   521
	a->setStatusTip ( tr( "Add a branch as child of selection" ));
insilmaril@442
   522
	a->setShortcut (Qt::Key_Insert);				//Add branch
insilmaril@366
   523
	connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
insilmaril@351
   524
	actionListBranches.append(a);
insilmaril@351
   525
	#if defined (Q_OS_MACX)
insilmaril@366
   526
		// In OSX show different shortcut in menues, the keys work indepently always			
insilmaril@351
   527
		actionEditAddBranch=alt;
insilmaril@351
   528
	#else	
insilmaril@351
   529
		actionEditAddBranch=a;
insilmaril@351
   530
	#endif	
insilmaril@366
   531
	editMenu->addAction (actionEditAddBranch);
insilmaril@366
   532
	tb->addAction (actionEditAddBranch);
insilmaril@366
   533
insilmaril@351
   534
insilmaril@351
   535
    // Add branch by inserting it at selection
insilmaril@395
   536
	a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
insilmaril@366
   537
	a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
insilmaril@442
   538
	a->setShortcut (Qt::ALT + Qt::Key_Insert );		//Insert branch
insilmaril@366
   539
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   540
	addAction (a);
insilmaril@394
   541
    connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
insilmaril@351
   542
	a->setEnabled (false);
insilmaril@351
   543
	actionListBranches.append(a);
insilmaril@394
   544
	actionEditAddBranchBefore=a;
insilmaril@395
   545
	a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
insilmaril@366
   546
	a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
insilmaril@442
   547
	a->setShortcut ( Qt::ALT + Qt::Key_A );			//Insert branch
insilmaril@366
   548
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   549
	addAction (a);
insilmaril@394
   550
    connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
insilmaril@351
   551
	actionListBranches.append(a);
insilmaril@351
   552
insilmaril@351
   553
	// Add branch above
insilmaril@395
   554
    a = new QAction(tr( "Add branch above","Edit menu" ), this);
insilmaril@366
   555
	a->setStatusTip ( tr( "Add a branch above selection" ));
insilmaril@442
   556
	a->setShortcut (Qt::SHIFT+Qt::Key_Insert );		//Add branch above
insilmaril@366
   557
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   558
	addAction (a);
insilmaril@366
   559
    connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
insilmaril@351
   560
	a->setEnabled (false);
insilmaril@351
   561
	actionListBranches.append(a);
insilmaril@351
   562
	actionEditAddBranchAbove=a;
insilmaril@395
   563
    a = new QAction(tr( "Add branch above","Edit menu" ), this);
insilmaril@366
   564
	a->setStatusTip ( tr( "Add a branch above selection" ));
insilmaril@442
   565
	a->setShortcut (Qt::SHIFT+Qt::Key_A );			//Add branch above
insilmaril@366
   566
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   567
	addAction (a);
insilmaril@366
   568
    connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
insilmaril@351
   569
	actionListBranches.append(a);
insilmaril@351
   570
insilmaril@351
   571
	// Add branch below 
insilmaril@395
   572
    a = new QAction(tr( "Add branch below","Edit menu" ), this);
insilmaril@366
   573
	a->setStatusTip ( tr( "Add a branch below selection" ));
insilmaril@442
   574
	a->setShortcut (Qt::CTRL +Qt::Key_Insert );		//Add branch below
insilmaril@366
   575
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   576
	addAction (a);
insilmaril@366
   577
    connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
insilmaril@351
   578
	a->setEnabled (false);
insilmaril@351
   579
	actionListBranches.append(a);
insilmaril@351
   580
	actionEditAddBranchBelow=a;
insilmaril@395
   581
    a = new QAction(tr( "Add branch below","Edit menu" ), this);
insilmaril@366
   582
	a->setStatusTip ( tr( "Add a branch below selection" ));
insilmaril@442
   583
	a->setShortcut (Qt::CTRL +Qt::Key_A );			// Add branch below
insilmaril@366
   584
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   585
	addAction (a);
insilmaril@366
   586
    connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
insilmaril@351
   587
	actionListBranches.append(a);
insilmaril@351
   588
insilmaril@395
   589
    a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
insilmaril@366
   590
	a->setStatusTip ( tr( "Move branch up" ) );
insilmaril@442
   591
	a->setShortcut (Qt::Key_PageUp );				// Move branch up
insilmaril@0
   592
	a->setEnabled (false);
insilmaril@366
   593
    tb->addAction (a);
insilmaril@366
   594
	editMenu->addAction (a);
insilmaril@366
   595
    connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
insilmaril@0
   596
	actionEditMoveUp=a;
insilmaril@98
   597
insilmaril@395
   598
    a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
insilmaril@366
   599
    connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
insilmaril@366
   600
	a->setStatusTip (tr( "Move branch down" ) );
insilmaril@442
   601
	a->setShortcut ( Qt::Key_PageDown );			// Move branch down
insilmaril@0
   602
	a->setEnabled (false);
insilmaril@366
   603
    tb->addAction (a);
insilmaril@366
   604
	editMenu->addAction (a);
insilmaril@0
   605
	actionEditMoveDown=a;
insilmaril@98
   606
	
insilmaril@608
   607
	a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this );
insilmaril@608
   608
	connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) );
insilmaril@608
   609
	a->setEnabled (true);
insilmaril@608
   610
	a->addTo( tb );
insilmaril@613
   611
	editMenu->addAction (a);
insilmaril@608
   612
	actionEditSortChildren=a;
insilmaril@0
   613
insilmaril@395
   614
	a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this);
insilmaril@366
   615
	a->setShortcut ( Qt::Key_ScrollLock );
insilmaril@366
   616
	a->setStatusTip (tr( "Scroll branch" ) );
insilmaril@366
   617
    connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
insilmaril@375
   618
insilmaril@395
   619
	alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
insilmaril@442
   620
	alt->setShortcut ( Qt::Key_S );					// Scroll branch
insilmaril@366
   621
	alt->setStatusTip (tr( "Scroll branch" )); 
insilmaril@366
   622
    connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
insilmaril@102
   623
	#if defined(Q_OS_MACX)
insilmaril@102
   624
		actionEditToggleScroll=alt;
insilmaril@102
   625
	#else	
insilmaril@102
   626
		actionEditToggleScroll=a;
insilmaril@102
   627
	#endif	
insilmaril@102
   628
	actionEditToggleScroll->setEnabled (false);
insilmaril@250
   629
	actionEditToggleScroll->setToggleAction(true);
insilmaril@366
   630
    tb->addAction (actionEditToggleScroll);
insilmaril@366
   631
    editMenu->addAction ( actionEditToggleScroll);
insilmaril@366
   632
	editMenu->addAction (actionEditToggleScroll);
insilmaril@375
   633
	addAction (a);
insilmaril@375
   634
	addAction (alt);
insilmaril@102
   635
	actionListBranches.append(actionEditToggleScroll);
insilmaril@0
   636
	
insilmaril@473
   637
    a = new QAction( tr( "Unscroll childs","Edit menu" ), this);
insilmaril@473
   638
	a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
insilmaril@366
   639
	editMenu->addAction (a);
insilmaril@473
   640
    connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChilds() ) );
insilmaril@0
   641
	
insilmaril@366
   642
	editMenu->addSeparator();
insilmaril@366
   643
insilmaril@395
   644
	a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
insilmaril@366
   645
	a->setStatusTip (tr( "Find" ) );
insilmaril@442
   646
	a->setShortcut (Qt::CTRL + Qt::Key_F );				//Find
insilmaril@366
   647
	editMenu->addAction (a);
insilmaril@366
   648
    connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
insilmaril@0
   649
    
insilmaril@366
   650
	editMenu->addSeparator();
insilmaril@366
   651
insilmaril@395
   652
	a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
insilmaril@366
   653
	a->setShortcut (Qt::CTRL + Qt::Key_U );
insilmaril@366
   654
	a->setShortcut (tr( "Open URL" ));
insilmaril@366
   655
    tb->addAction (a);
insilmaril@366
   656
	addAction(a);
insilmaril@366
   657
    connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
insilmaril@0
   658
	actionEditOpenURL=a;
insilmaril@0
   659
insilmaril@395
   660
	a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
insilmaril@366
   661
	a->setStatusTip (tr( "Open URL in new tab" ));
insilmaril@528
   662
	//a->setShortcut (Qt::CTRL+Qt::Key_U );
insilmaril@366
   663
	addAction(a);
insilmaril@366
   664
    connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
insilmaril@266
   665
	actionEditOpenURLTab=a;
insilmaril@266
   666
insilmaril@395
   667
	a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
insilmaril@366
   668
	a->setStatusTip (tr( "Open all URLs in subtree" ));
insilmaril@366
   669
	addAction(a);
insilmaril@366
   670
	actionListBranches.append(a);
insilmaril@366
   671
    connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
insilmaril@366
   672
	actionEditOpenMultipleURLTabs=a;
insilmaril@366
   673
insilmaril@395
   674
	a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
insilmaril@366
   675
	a->setStatusTip ( tr( "Edit URL" ) );
insilmaril@528
   676
	a->setShortcut ( Qt::Key_U );
insilmaril@366
   677
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   678
	actionListBranches.append(a);
insilmaril@366
   679
	addAction(a);
insilmaril@366
   680
    connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
insilmaril@366
   681
	actionEditURL=a;
insilmaril@366
   682
	
insilmaril@528
   683
	a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
insilmaril@528
   684
	a->setStatusTip ( tr( "Edit local URL" ) );
insilmaril@528
   685
	a->setShortcut (Qt::SHIFT +  Qt::Key_U );
insilmaril@528
   686
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@528
   687
	actionListBranches.append(a);
insilmaril@528
   688
	addAction(a);
insilmaril@528
   689
    connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
insilmaril@600
   690
	actionEditLocalURL=a;
insilmaril@528
   691
	
insilmaril@395
   692
	a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
insilmaril@366
   693
	a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
insilmaril@0
   694
	a->setEnabled (false);
insilmaril@98
   695
	actionListBranches.append(a);
insilmaril@366
   696
    connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
insilmaril@366
   697
	actionEditHeading2URL=a;
insilmaril@366
   698
    
insilmaril@486
   699
	a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
insilmaril@486
   700
	a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
insilmaril@0
   701
	a->setEnabled (false);
insilmaril@98
   702
	actionListBranches.append(a);
insilmaril@366
   703
    connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
insilmaril@366
   704
	actionEditBugzilla2URL=a;
insilmaril@0
   705
    
insilmaril@486
   706
	a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
insilmaril@486
   707
	a->setStatusTip ( tr( "Create URL to Novell FATE" ));
insilmaril@0
   708
	a->setEnabled (false);
insilmaril@98
   709
	actionListBranches.append(a);
insilmaril@366
   710
    connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
insilmaril@366
   711
	actionEditFATE2URL=a;
insilmaril@366
   712
	
insilmaril@395
   713
    a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
insilmaril@366
   714
	a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
insilmaril@366
   715
    tb->addAction (a);
insilmaril@366
   716
	a->setEnabled (false);
insilmaril@366
   717
    connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
insilmaril@366
   718
	actionEditOpenVymLink=a;
insilmaril@366
   719
	
insilmaril@395
   720
    a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
insilmaril@366
   721
	a->setStatusTip ( tr( "Open all vym links in subtree" ));
insilmaril@175
   722
	a->setEnabled (false);
insilmaril@175
   723
	actionListBranches.append(a);
insilmaril@366
   724
    connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
insilmaril@366
   725
	actionEditOpenMultipleVymLinks=a;
insilmaril@0
   726
	
insilmaril@366
   727
insilmaril@395
   728
    a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
insilmaril@0
   729
	a->setEnabled (false);
insilmaril@366
   730
	a->setStatusTip ( tr( "Edit link to another vym map" ));
insilmaril@366
   731
    connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
insilmaril@98
   732
	actionListBranches.append(a);
insilmaril@0
   733
	actionEditVymLink=a;
insilmaril@0
   734
insilmaril@395
   735
    a = new QAction(tr( "Delete vym link","Edit menu" ),this);
insilmaril@366
   736
	a->setStatusTip ( tr( "Delete link to another vym map" ));
insilmaril@0
   737
	a->setEnabled (false);
insilmaril@366
   738
    connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
insilmaril@0
   739
	actionEditDeleteVymLink=a;
insilmaril@0
   740
insilmaril@395
   741
    a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
insilmaril@366
   742
	a->setStatusTip ( tr( "Hide object in exports" ) );
insilmaril@366
   743
	a->setShortcut (Qt::Key_H );
insilmaril@243
   744
	a->setToggleAction(true);
insilmaril@366
   745
    tb->addAction (a);
insilmaril@243
   746
	a->setEnabled (false);
insilmaril@366
   747
    connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
insilmaril@243
   748
	actionEditToggleHideExport=a;
insilmaril@243
   749
insilmaril@395
   750
    a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
insilmaril@366
   751
	a->setStatusTip ( tr( "Edit Map Info" ));
insilmaril@0
   752
	a->setEnabled (true);
insilmaril@366
   753
    connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
insilmaril@0
   754
	actionEditMapInfo=a;
insilmaril@0
   755
insilmaril@0
   756
	// Import at selection (adding to selection)
insilmaril@395
   757
    a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
insilmaril@366
   758
	a->setStatusTip (tr( "Add map at selection" ));
insilmaril@366
   759
    connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
insilmaril@0
   760
	a->setEnabled (false);
insilmaril@98
   761
	actionListBranches.append(a);
insilmaril@0
   762
	actionEditImportAdd=a;
insilmaril@0
   763
insilmaril@0
   764
	// Import at selection (replacing selection)
insilmaril@395
   765
    a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
insilmaril@366
   766
	a->setStatusTip (tr( "Replace selection with map" ));
insilmaril@366
   767
    connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
insilmaril@0
   768
	a->setEnabled (false);
insilmaril@98
   769
	actionListBranches.append(a);
insilmaril@0
   770
	actionEditImportReplace=a;
insilmaril@0
   771
insilmaril@0
   772
	// Save selection 
insilmaril@395
   773
    a = new QAction( tr( "Save selection","Edit menu" ), this);
insilmaril@366
   774
	a->setStatusTip (tr( "Save selection" ));
insilmaril@366
   775
    connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
insilmaril@0
   776
	a->setEnabled (false);
insilmaril@98
   777
	actionListBranches.append(a);
insilmaril@0
   778
	actionEditSaveBranch=a;
insilmaril@0
   779
insilmaril@98
   780
	// Only remove branch, not its childs
insilmaril@395
   781
    a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
insilmaril@366
   782
	a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
insilmaril@366
   783
	a->setShortcut (Qt::ALT + Qt::Key_Delete );
insilmaril@395
   784
    connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChilds() ) );
insilmaril@98
   785
	a->setEnabled (false);
insilmaril@375
   786
	addAction (a);
insilmaril@98
   787
	actionListBranches.append(a);
insilmaril@395
   788
	actionEditDeleteKeepChilds=a;
insilmaril@98
   789
insilmaril@98
   790
	// Only remove childs of a branch
insilmaril@395
   791
    a = new QAction( tr( "Remove childs","Edit menu" ), this);
insilmaril@366
   792
	a->setStatusTip (tr( "Remove childs of branch" ));
insilmaril@366
   793
	a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
insilmaril@395
   794
    connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChilds() ) );
insilmaril@98
   795
	a->setEnabled (false);
insilmaril@98
   796
	actionListBranches.append(a);
insilmaril@395
   797
	actionEditDeleteChilds=a;
insilmaril@98
   798
insilmaril@0
   799
    // Shortcuts for navigating with cursor:
insilmaril@395
   800
    a = new QAction(tr( "Select upper branch","Edit menu" ), this);
insilmaril@366
   801
	a->setStatusTip ( tr( "Select upper branch" ));
insilmaril@366
   802
	a->setShortcut (Qt::Key_Up );
insilmaril@366
   803
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   804
	addAction (a);
insilmaril@366
   805
    connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
insilmaril@395
   806
    a = new QAction( tr( "Select lower branch","Edit menu" ),this);
insilmaril@366
   807
	a->setStatusTip (tr( "Select lower branch" ));
insilmaril@366
   808
	a->setShortcut ( Qt::Key_Down );
insilmaril@366
   809
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   810
	addAction (a);
insilmaril@366
   811
    connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
insilmaril@395
   812
    a = new QAction(tr( "Select left branch","Edit menu" ), this);
insilmaril@366
   813
	a->setStatusTip ( tr( "Select left branch" ));
insilmaril@366
   814
	a->setShortcut (Qt::Key_Left );
insilmaril@366
   815
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   816
	addAction (a);
insilmaril@366
   817
    connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
insilmaril@395
   818
    a = new QAction( tr( "Select child branch","Edit menu" ), this);
insilmaril@366
   819
	a->setStatusTip (tr( "Select right branch" ));
insilmaril@366
   820
	a->setShortcut (Qt::Key_Right);
insilmaril@366
   821
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   822
	addAction (a);
insilmaril@366
   823
    connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
insilmaril@395
   824
    a = new QAction( tr( "Select first branch","Edit menu" ), this);
insilmaril@366
   825
	a->setStatusTip (tr( "Select first branch" ));
insilmaril@366
   826
	a->setShortcut (Qt::Key_Home );
insilmaril@366
   827
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   828
	addAction (a);
insilmaril@0
   829
	a->setEnabled (false);
insilmaril@366
   830
	editMenu->addAction (a);
insilmaril@98
   831
	actionListBranches.append(a);
insilmaril@0
   832
	actionEditSelectFirst=a;
insilmaril@366
   833
    connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
insilmaril@395
   834
    a = new QAction( tr( "Select last branch","Edit menu" ),this);
insilmaril@366
   835
	a->setStatusTip (tr( "Select last branch" ));
insilmaril@366
   836
	a->setShortcut ( Qt::Key_End );
insilmaril@366
   837
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   838
	addAction (a);
insilmaril@366
   839
    connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
insilmaril@0
   840
	a->setEnabled (false);
insilmaril@366
   841
	editMenu->addAction (a);
insilmaril@98
   842
	actionListBranches.append(a);
insilmaril@0
   843
	actionEditSelectLast=a;
insilmaril@0
   844
insilmaril@395
   845
    a = new QAction( tr( "Add Image...","Edit menu" ), this);
insilmaril@366
   846
	a->setStatusTip (tr( "Add Image" ));
insilmaril@366
   847
    connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
insilmaril@0
   848
	actionEditLoadImage=a;
insilmaril@89
   849
insilmaril@473
   850
    a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
insilmaril@442
   851
	a->setStatusTip (tr( "Set properties for selection" ));
insilmaril@442
   852
	a->setShortcut ( Qt::CTRL + Qt::Key_I );		//Property window
insilmaril@442
   853
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@486
   854
	a->setToggleAction (true);
insilmaril@442
   855
	addAction (a);
insilmaril@473
   856
    connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
insilmaril@486
   857
	actionViewTogglePropertyWindow=a;
insilmaril@0
   858
}
insilmaril@0
   859
insilmaril@0
   860
// Format Actions
insilmaril@0
   861
void Main::setupFormatActions()
insilmaril@0
   862
{
insilmaril@395
   863
    QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
insilmaril@395
   864
insilmaril@395
   865
    QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
insilmaril@366
   866
	tb->setObjectName ("formatTB");
insilmaril@0
   867
    QAction *a;
insilmaril@0
   868
    QPixmap pix( 16,16);
insilmaril@366
   869
    pix.fill (Qt::black);
insilmaril@366
   870
    a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
insilmaril@366
   871
	a->setStatusTip ( tr( "Set Color" ));
insilmaril@366
   872
    connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
insilmaril@366
   873
    a->addTo( tb );
insilmaril@366
   874
	formatMenu->addAction (a);
insilmaril@366
   875
	actionFormatColor=a;
insilmaril@395
   876
    a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
insilmaril@366
   877
	a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
insilmaril@366
   878
	a->setShortcut (Qt::CTRL + Qt::Key_K );
insilmaril@366
   879
    connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
insilmaril@0
   880
	a->setEnabled (false);
insilmaril@0
   881
    a->addTo( tb );
insilmaril@366
   882
	formatMenu->addAction (a);
insilmaril@98
   883
	actionListBranches.append(a);
insilmaril@0
   884
	actionFormatPickColor=a;
insilmaril@366
   885
insilmaril@417
   886
    a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
insilmaril@366
   887
	a->setStatusTip ( tr( "Color branch" ) );
insilmaril@442
   888
	a->setShortcut (Qt::CTRL + Qt::Key_B);
insilmaril@417
   889
    connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
insilmaril@0
   890
	a->setEnabled (false);
insilmaril@0
   891
    a->addTo( tb );
insilmaril@366
   892
	formatMenu->addAction (a);
insilmaril@98
   893
	actionListBranches.append(a);
insilmaril@417
   894
	actionFormatColorSubtree=a;
insilmaril@417
   895
insilmaril@417
   896
    a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
insilmaril@366
   897
	a->setStatusTip ( tr( "Color Subtree" ));
insilmaril@366
   898
	a->setShortcut (Qt::CTRL + Qt::Key_T);
insilmaril@417
   899
    connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
insilmaril@0
   900
	a->setEnabled (false);
insilmaril@366
   901
	formatMenu->addAction (a);
insilmaril@0
   902
    a->addTo( tb );
insilmaril@98
   903
	actionListBranches.append(a);
insilmaril@0
   904
	actionFormatColorSubtree=a;
insilmaril@0
   905
insilmaril@366
   906
	formatMenu->addSeparator();
insilmaril@366
   907
	actionGroupFormatLinkStyles=new QActionGroup ( this);
insilmaril@0
   908
	actionGroupFormatLinkStyles->setExclusive (true);
insilmaril@366
   909
    a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
insilmaril@366
   910
	a->setStatusTip (tr( "Line" ));
insilmaril@0
   911
	a->setToggleAction(true);
insilmaril@366
   912
    connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
insilmaril@366
   913
	formatMenu->addAction (a);
insilmaril@0
   914
	actionFormatLinkStyleLine=a;
insilmaril@505
   915
    a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
insilmaril@366
   916
	a->setStatusTip (tr( "Line" ));
insilmaril@0
   917
	a->setToggleAction(true);
insilmaril@366
   918
    connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
insilmaril@366
   919
	formatMenu->addAction (a);
insilmaril@0
   920
	actionFormatLinkStyleParabel=a;
insilmaril@366
   921
    a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
insilmaril@366
   922
	a->setStatusTip (tr( "PolyLine" ));
insilmaril@0
   923
	a->setToggleAction(true);
insilmaril@366
   924
    connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
insilmaril@366
   925
	formatMenu->addAction (a);
insilmaril@0
   926
	actionFormatLinkStylePolyLine=a;
insilmaril@505
   927
    a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
insilmaril@366
   928
	a->setStatusTip (tr( "PolyParabel" ) );
insilmaril@0
   929
	a->setToggleAction(true);
insilmaril@366
   930
	a->setChecked (true);
insilmaril@366
   931
    connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
insilmaril@366
   932
	formatMenu->addAction (a);
insilmaril@0
   933
	actionFormatLinkStylePolyParabel=a;
insilmaril@0
   934
	
insilmaril@395
   935
    a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
insilmaril@366
   936
	a->setStatusTip (tr( "Hide link" ));
insilmaril@160
   937
	a->setToggleAction(true);
insilmaril@366
   938
    connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
insilmaril@160
   939
	actionFormatHideLinkUnselected=a;
insilmaril@160
   940
insilmaril@366
   941
	formatMenu->addSeparator();
insilmaril@395
   942
    a= new QAction( tr( "&Use color of heading for link","Branch attribute" ),  this);
insilmaril@366
   943
	a->setStatusTip (tr( "Use same color for links and headings" ));
insilmaril@0
   944
	a->setToggleAction(true);
insilmaril@366
   945
    connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
insilmaril@366
   946
	formatMenu->addAction (a);
insilmaril@0
   947
	actionFormatLinkColorHint=a;
insilmaril@366
   948
insilmaril@366
   949
    pix.fill (Qt::white);
insilmaril@366
   950
    a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this  );
insilmaril@366
   951
	a->setStatusTip (tr( "Set Link Color" ));
insilmaril@366
   952
	formatMenu->addAction (a);
insilmaril@366
   953
    connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
insilmaril@366
   954
    actionFormatLinkColor=a;
insilmaril@366
   955
insilmaril@442
   956
    a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this  );
insilmaril@442
   957
	a->setStatusTip (tr( "Set Selection Color" ));
insilmaril@442
   958
	formatMenu->addAction (a);
insilmaril@442
   959
    connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
insilmaril@442
   960
    actionFormatSelectionColor=a;
insilmaril@442
   961
insilmaril@366
   962
    a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
insilmaril@366
   963
	a->setStatusTip (tr( "Set Background Color" ));
insilmaril@366
   964
	formatMenu->addAction (a);
insilmaril@366
   965
    connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
insilmaril@366
   966
    actionFormatBackColor=a;
insilmaril@408
   967
insilmaril@408
   968
    a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
insilmaril@408
   969
	a->setStatusTip (tr( "Set Background image" ));
insilmaril@408
   970
	formatMenu->addAction (a);
insilmaril@408
   971
    connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
insilmaril@408
   972
    actionFormatBackImage=a;
insilmaril@0
   973
}
insilmaril@0
   974
insilmaril@0
   975
// View Actions
insilmaril@0
   976
void Main::setupViewActions()
insilmaril@0
   977
{
insilmaril@395
   978
    QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
insilmaril@0
   979
    tb->setLabel( "View Actions" );
insilmaril@366
   980
	tb->setObjectName ("viewTB");
insilmaril@366
   981
    QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
insilmaril@0
   982
insilmaril@0
   983
    QAction *a;
insilmaril@395
   984
    a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
insilmaril@366
   985
	a->setStatusTip ( tr( "Zoom reset" ) );
insilmaril@366
   986
	a->setShortcut (Qt::CTRL + Qt::Key_0 );
insilmaril@0
   987
    a->addTo( tb );
insilmaril@366
   988
	viewMenu->addAction (a);
insilmaril@366
   989
    connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
insilmaril@366
   990
	
insilmaril@395
   991
    a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
insilmaril@366
   992
	a->setStatusTip (tr( "Zoom in" ));
insilmaril@366
   993
	a->setShortcut (Qt::CTRL + Qt::Key_Plus);
insilmaril@0
   994
    a->addTo( tb );
insilmaril@366
   995
	viewMenu->addAction (a);
insilmaril@366
   996
    connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
insilmaril@366
   997
	
insilmaril@395
   998
    a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
insilmaril@366
   999
	a->setStatusTip (tr( "Zoom out" ));
insilmaril@366
  1000
	a->setShortcut (Qt::CTRL + Qt::Key_Minus );
insilmaril@0
  1001
    a->addTo( tb );
insilmaril@366
  1002
	viewMenu->addAction (a);
insilmaril@366
  1003
    connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
insilmaril@366
  1004
insilmaril@526
  1005
    a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
insilmaril@526
  1006
	a->setStatusTip (tr( "Show selection" ));
insilmaril@526
  1007
	a->setShortcut (Qt::Key_Period);
insilmaril@526
  1008
    a->addTo( tb );
insilmaril@526
  1009
	viewMenu->addAction (a);
insilmaril@526
  1010
    connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
insilmaril@526
  1011
insilmaril@486
  1012
	viewMenu->addSeparator();	
insilmaril@366
  1013
insilmaril@395
  1014
    a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
insilmaril@366
  1015
	a->setStatusTip ( tr( "Show Note Editor" ));
insilmaril@366
  1016
	a->setShortcut ( Qt::CTRL + Qt::Key_E );
insilmaril@0
  1017
	a->setToggleAction(true);
insilmaril@0
  1018
    a->addTo( tb );
insilmaril@366
  1019
	viewMenu->addAction (a);
insilmaril@366
  1020
    connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
insilmaril@0
  1021
	actionViewToggleNoteEditor=a;
insilmaril@294
  1022
insilmaril@442
  1023
    a = new QAction(QPixmap(iconPath+"history.png"),  tr( "History Window","View action" ),this );
insilmaril@442
  1024
	a->setStatusTip ( tr( "Show History Window" ));
insilmaril@366
  1025
	a->setShortcut ( Qt::CTRL + Qt::Key_H  );
insilmaril@407
  1026
	a->setToggleAction(true);
insilmaril@404
  1027
    a->addTo( tb );
insilmaril@366
  1028
	viewMenu->addAction (a);
insilmaril@366
  1029
    connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
insilmaril@294
  1030
	actionViewToggleHistoryWindow=a;
insilmaril@294
  1031
insilmaril@486
  1032
	viewMenu->addAction (actionViewTogglePropertyWindow);
insilmaril@486
  1033
insilmaril@486
  1034
	viewMenu->addSeparator();	
insilmaril@442
  1035
insilmaril@408
  1036
    a = new QAction(tr( "Antialiasing","View action" ),this );
insilmaril@408
  1037
	a->setStatusTip ( tr( "Antialiasing" ));
insilmaril@408
  1038
	a->setToggleAction(true);
insilmaril@408
  1039
	a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
insilmaril@408
  1040
	viewMenu->addAction (a);
insilmaril@408
  1041
    connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
insilmaril@408
  1042
	actionViewToggleAntiAlias=a;
insilmaril@408
  1043
insilmaril@408
  1044
    a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
insilmaril@408
  1045
	a->setStatusTip (a->text());
insilmaril@408
  1046
	a->setToggleAction(true);
insilmaril@408
  1047
	a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
insilmaril@408
  1048
	viewMenu->addAction (a);
insilmaril@408
  1049
    connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
insilmaril@408
  1050
	actionViewToggleSmoothPixmapTransform=a;
insilmaril@408
  1051
insilmaril@473
  1052
    a = new QAction(tr( "Next Map","View action" ), this);
insilmaril@408
  1053
	a->setStatusTip (a->text());
insilmaril@366
  1054
	a->setShortcut (Qt::ALT + Qt::Key_N );
insilmaril@366
  1055
	viewMenu->addAction (a);
insilmaril@366
  1056
    connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
insilmaril@366
  1057
insilmaril@473
  1058
    a = new QAction (tr( "Previous Map","View action" ), this );
insilmaril@408
  1059
	a->setStatusTip (a->text());
insilmaril@366
  1060
	a->setShortcut (Qt::ALT + Qt::Key_P );
insilmaril@366
  1061
	viewMenu->addAction (a);
insilmaril@366
  1062
    connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
insilmaril@0
  1063
}
insilmaril@0
  1064
insilmaril@89
  1065
// Mode Actions
insilmaril@89
  1066
void Main::setupModeActions()
insilmaril@89
  1067
{
insilmaril@89
  1068
    //QPopupMenu *menu = new QPopupMenu( this );
insilmaril@89
  1069
    //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
insilmaril@89
  1070
insilmaril@395
  1071
    QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
insilmaril@366
  1072
	tb->setObjectName ("modesTB");
insilmaril@89
  1073
    QAction *a;
insilmaril@366
  1074
	actionGroupModModes=new QActionGroup ( this);
insilmaril@89
  1075
	actionGroupModModes->setExclusive (true);
insilmaril@395
  1076
    a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
insilmaril@366
  1077
	a->setShortcut (Qt::Key_J);
insilmaril@366
  1078
    a->setStatusTip ( tr( "Use modifier to color branches" ));
insilmaril@89
  1079
	a->setToggleAction(true);
insilmaril@89
  1080
	a->addTo (tb);
insilmaril@89
  1081
	a->setOn(true);
insilmaril@89
  1082
	actionModModeColor=a;
insilmaril@104
  1083
	
insilmaril@395
  1084
    a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
insilmaril@366
  1085
	a->setShortcut( Qt::Key_K); 
insilmaril@366
  1086
    a->setStatusTip( tr( "Use modifier to copy" ));
insilmaril@104
  1087
	a->setToggleAction(true);
insilmaril@104
  1088
	a->addTo (tb);
insilmaril@104
  1089
	actionModModeCopy=a;
insilmaril@104
  1090
insilmaril@395
  1091
    a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
insilmaril@366
  1092
	a->setShortcut (Qt::Key_L);
insilmaril@366
  1093
    a->setStatusTip( tr( "Use modifier to draw xLinks" ));
insilmaril@89
  1094
	a->setToggleAction(true);
insilmaril@89
  1095
	a->addTo (tb);
insilmaril@390
  1096
	actionModModeXLink=a;
insilmaril@89
  1097
}
insilmaril@89
  1098
insilmaril@0
  1099
// Flag Actions
insilmaril@0
  1100
void Main::setupFlagActions()
insilmaril@0
  1101
{
insilmaril@166
  1102
	// Create System Flags
insilmaril@582
  1103
	QToolBar *tb=NULL;
insilmaril@582
  1104
	bool avis=true;
insilmaril@582
  1105
insilmaril@166
  1106
	systemFlagsDefault = new FlagRowObj ();
insilmaril@166
  1107
	systemFlagsDefault->setVisibility (false);
insilmaril@166
  1108
	systemFlagsDefault->setName ("systemFlagsDef");
insilmaril@166
  1109
insilmaril@166
  1110
	FlagObj *fo = new FlagObj ();
insilmaril@269
  1111
	fo->load(QPixmap(flagsPath+"flag-note.png"));
insilmaril@582
  1112
	setupFlag (fo,tb,avis,"note",tr("Note","SystemFlag"));
insilmaril@166
  1113
insilmaril@269
  1114
	fo->load(QPixmap(flagsPath+"flag-url.png"));
insilmaril@582
  1115
	setupFlag (fo,tb,avis,"url",tr("URL to Document ","SystemFlag"));
insilmaril@166
  1116
	
insilmaril@269
  1117
	fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
insilmaril@582
  1118
	setupFlag (fo,tb,avis,"vymLink",tr("Link to another vym map","SystemFlag"));
insilmaril@166
  1119
insilmaril@269
  1120
	fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
insilmaril@582
  1121
	setupFlag (fo,tb,avis,"scrolledright",tr("subtree is scrolled","SystemFlag"));
insilmaril@166
  1122
	
insilmaril@269
  1123
	fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
insilmaril@582
  1124
	setupFlag (fo,tb,avis,"tmpUnscrolledright",tr("subtree is temporary scrolled","SystemFlag"));
insilmaril@166
  1125
insilmaril@269
  1126
	fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
insilmaril@582
  1127
	setupFlag (fo,tb,avis,"hideInExport",tr("Hide object in exported maps","SystemFlag"));
insilmaril@243
  1128
insilmaril@166
  1129
	// Create Standard Flags
insilmaril@582
  1130
	tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
insilmaril@366
  1131
	tb->setObjectName ("standardFlagTB");
insilmaril@366
  1132
insilmaril@166
  1133
	standardFlagsDefault = new FlagRowObj ();
insilmaril@166
  1134
	standardFlagsDefault->setVisibility (false);
insilmaril@166
  1135
	standardFlagsDefault->setName ("standardFlagsDef");
insilmaril@366
  1136
	standardFlagsDefault->setToolBar (tb);
insilmaril@166
  1137
insilmaril@408
  1138
	fo->load(flagsPath+"flag-exclamationmark.png");
insilmaril@166
  1139
	fo->setGroup("standard-mark");
insilmaril@582
  1140
	setupFlag (fo,tb,avis,"exclamationmark",tr("Take care!","Standardflag"));
insilmaril@166
  1141
	
insilmaril@408
  1142
	fo->load(flagsPath+"flag-questionmark.png");
insilmaril@166
  1143
	fo->setGroup("standard-mark");
insilmaril@582
  1144
	setupFlag (fo,tb,avis,"questionmark",tr("Really?","Standardflag"));
insilmaril@166
  1145
insilmaril@408
  1146
	fo->load(flagsPath+"flag-hook-green.png");
insilmaril@166
  1147
	fo->setGroup("standard-hook");
insilmaril@582
  1148
	setupFlag (fo,tb,avis,"hook-green",tr("ok!","Standardflag"));
insilmaril@166
  1149
insilmaril@408
  1150
	fo->load(flagsPath+"flag-cross-red.png");
insilmaril@166
  1151
	fo->setGroup("standard-hook");
insilmaril@582
  1152
	setupFlag (fo,tb,avis,"cross-red",tr("Not ok!","Standardflag"));
insilmaril@582
  1153
	fo->unsetGroup();
insilmaril@166
  1154
insilmaril@408
  1155
	fo->load(flagsPath+"flag-stopsign.png");
insilmaril@582
  1156
	setupFlag (fo,tb,avis,"stopsign",tr("This won't work!","Standardflag"));
insilmaril@166
  1157
insilmaril@408
  1158
	fo->load(flagsPath+"flag-smiley-good.png");
insilmaril@166
  1159
	fo->setGroup("standard-smiley");
insilmaril@582
  1160
	setupFlag (fo,tb,avis,"smiley-good",tr("Good","Standardflag"));
insilmaril@166
  1161
insilmaril@408
  1162
	fo->load(flagsPath+"flag-smiley-sad.png");
insilmaril@166
  1163
	fo->setGroup("standard-smiley");
insilmaril@585
  1164
	setupFlag (fo,tb,avis,"smiley-sad",tr("Bad","Standardflag"));
insilmaril@166
  1165
insilmaril@408
  1166
	fo->load(flagsPath+"flag-smiley-omg.png");
insilmaril@582
  1167
	fo->setGroup("standard-smiley");
insilmaril@582
  1168
	setupFlag (fo,tb,avis,"smiley-omb",tr("Oh no!","Standardflag"));
insilmaril@269
  1169
	// Original omg.png (in KDE emoticons)
insilmaril@582
  1170
	fo->unsetGroup();
insilmaril@269
  1171
insilmaril@408
  1172
	fo->load(flagsPath+"flag-kalarm.png");
insilmaril@582
  1173
	setupFlag (fo,tb,avis,"clock",tr("Time critical","Standardflag"));
insilmaril@166
  1174
insilmaril@408
  1175
	fo->load(flagsPath+"flag-phone.png");
insilmaril@582
  1176
	setupFlag (fo,tb,avis,"phone",tr("Call...","Standardflag"));
insilmaril@269
  1177
insilmaril@408
  1178
	fo->load(flagsPath+"flag-lamp.png");
insilmaril@582
  1179
	setupFlag (fo,tb,avis,"lamp",tr("Idea!","Standardflag"));
insilmaril@166
  1180
insilmaril@408
  1181
	fo->load(flagsPath+"flag-arrow-up.png");
insilmaril@166
  1182
	fo->setGroup("standard-arrow");
insilmaril@582
  1183
	setupFlag (fo,tb,avis,"arrow-up",tr("Important","Standardflag"));
insilmaril@166
  1184
insilmaril@408
  1185
	fo->load(flagsPath+"flag-arrow-down.png");
insilmaril@166
  1186
	fo->setGroup("standard-arrow");
insilmaril@582
  1187
	setupFlag (fo,tb,avis,"arrow-down",tr("Unimportant","Standardflag"));
insilmaril@166
  1188
insilmaril@408
  1189
	fo->load(flagsPath+"flag-arrow-2up.png");
insilmaril@269
  1190
	fo->setGroup("standard-arrow");
insilmaril@582
  1191
	setupFlag (fo,tb,avis,"2arrow-up",tr("Very important!","Standardflag"));
insilmaril@269
  1192
insilmaril@408
  1193
	fo->load(flagsPath+"flag-arrow-2down.png");
insilmaril@269
  1194
	fo->setGroup("standard-arrow");
insilmaril@614
  1195
	setupFlag (fo,tb,avis,"2arrow-down",tr("Very unimportant!","Standardflag"));
insilmaril@582
  1196
	fo->unsetGroup();
insilmaril@269
  1197
insilmaril@408
  1198
	fo->load(flagsPath+"flag-thumb-up.png");
insilmaril@166
  1199
	fo->setGroup("standard-thumb");
insilmaril@582
  1200
	setupFlag (fo,tb,avis,"thumb-up",tr("I like this","Standardflag"));
insilmaril@166
  1201
insilmaril@408
  1202
	fo->load(flagsPath+"flag-thumb-down.png");
insilmaril@166
  1203
	fo->setGroup("standard-thumb");
insilmaril@582
  1204
	setupFlag (fo,tb,avis,"thumb-down",tr("I do not like this","Standardflag"));
insilmaril@582
  1205
	fo->unsetGroup();
insilmaril@166
  1206
	
insilmaril@408
  1207
	fo->load(flagsPath+"flag-rose.png");
insilmaril@582
  1208
	setupFlag (fo,tb,avis,"rose",tr("Rose","Standardflag"));
insilmaril@269
  1209
insilmaril@408
  1210
	fo->load(flagsPath+"flag-heart.png");
insilmaril@582
  1211
	setupFlag (fo,tb,avis,"heart",tr("I just love...","Standardflag"));
insilmaril@564
  1212
insilmaril@408
  1213
	fo->load(flagsPath+"flag-present.png");
insilmaril@582
  1214
	setupFlag (fo,tb,avis,"present",tr("Surprise!","Standardflag"));
insilmaril@564
  1215
insilmaril@564
  1216
	fo->load(flagsPath+"flag-flash.png");
insilmaril@582
  1217
	setupFlag (fo,tb,avis,"flash",tr("Dangerous","Standardflag"));
insilmaril@564
  1218
	
insilmaril@564
  1219
	// Original: xsldbg_output.png
insilmaril@564
  1220
	fo->load(flagsPath+"flag-info.png");
insilmaril@582
  1221
	setupFlag (fo,tb,avis,"info",tr("Info","Standardflag"));
insilmaril@564
  1222
insilmaril@564
  1223
	// Original khelpcenter.png
insilmaril@564
  1224
	fo->load(flagsPath+"flag-lifebelt.png");
insilmaril@582
  1225
	setupFlag (fo,tb,avis,"lifebelt",tr("This will help","Standardflag"));
insilmaril@564
  1226
insilmaril@564
  1227
	// Freemind flags
insilmaril@564
  1228
insilmaril@582
  1229
	avis=false;
insilmaril@582
  1230
insilmaril@564
  1231
	fo->load(flagsPath+"freemind/warning.png");
insilmaril@582
  1232
	setupFlag (fo,tb, avis, "freemind-warning",tr("Important","Freemind-Flag"));
insilmaril@564
  1233
insilmaril@564
  1234
	for (int i=1; i<8; i++)
insilmaril@564
  1235
	{
insilmaril@564
  1236
		fo->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
insilmaril@582
  1237
		setupFlag (fo,tb, avis,QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
insilmaril@564
  1238
	}
insilmaril@564
  1239
insilmaril@564
  1240
	fo->load(flagsPath+"freemind/back.png");
insilmaril@582
  1241
	setupFlag (fo,tb,avis,"freemind-back",tr("Back","Freemind-Flag"));
insilmaril@564
  1242
insilmaril@564
  1243
	fo->load(flagsPath+"freemind/forward.png");
insilmaril@582
  1244
	setupFlag (fo,tb,avis,"freemind-forward",tr("Forward","Freemind-Flag"));
insilmaril@564
  1245
insilmaril@564
  1246
	fo->load(flagsPath+"freemind/attach.png");
insilmaril@582
  1247
	setupFlag (fo,tb,avis,"freemind-attach",tr("Look here","Freemind-Flag"));
insilmaril@564
  1248
insilmaril@564
  1249
	fo->load(flagsPath+"freemind/clanbomber.png");
insilmaril@582
  1250
	setupFlag (fo,tb,avis,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
insilmaril@564
  1251
insilmaril@564
  1252
	fo->load(flagsPath+"freemind/desktopnew.png");
insilmaril@582
  1253
	setupFlag (fo,tb,avis,"freemind-desktopnew",tr("Don't forget","Freemind-Flag"));
insilmaril@564
  1254
insilmaril@564
  1255
	fo->load(flagsPath+"freemind/flag.png");
insilmaril@582
  1256
	setupFlag (fo,tb,avis,"freemind-flag",tr("Flag","Freemind-Flag"));
insilmaril@564
  1257
insilmaril@564
  1258
insilmaril@564
  1259
	fo->load(flagsPath+"freemind/gohome.png");
insilmaril@582
  1260
	setupFlag (fo,tb,avis,"freemind-gohome",tr("Home","Freemind-Flag"));
insilmaril@564
  1261
insilmaril@564
  1262
insilmaril@564
  1263
	fo->load(flagsPath+"freemind/kaddressbook.png");
insilmaril@582
  1264
	setupFlag (fo,tb,avis,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
insilmaril@564
  1265
insilmaril@564
  1266
	fo->load(flagsPath+"freemind/knotify.png");
insilmaril@582
  1267
	setupFlag (fo,tb,avis,"freemind-knotify",tr("Music","Freemind-Flag"));
insilmaril@564
  1268
insilmaril@564
  1269
	fo->load(flagsPath+"freemind/korn.png");
insilmaril@582
  1270
	setupFlag (fo,tb,avis,"freemind-korn",tr("Mailbox","Freemind-Flag"));
insilmaril@564
  1271
insilmaril@564
  1272
	fo->load(flagsPath+"freemind/mail.png");
insilmaril@582
  1273
	setupFlag (fo,tb,avis,"freemind-mail",tr("Maix","Freemind-Flag"));
insilmaril@564
  1274
insilmaril@564
  1275
	fo->load(flagsPath+"freemind/password.png");
insilmaril@582
  1276
	setupFlag (fo,tb,avis,"freemind-password",tr("Password","Freemind-Flag"));
insilmaril@564
  1277
insilmaril@564
  1278
	fo->load(flagsPath+"freemind/pencil.png");
insilmaril@582
  1279
	setupFlag (fo,tb,avis,"freemind-pencil",tr("To be improved","Freemind-Flag"));
insilmaril@564
  1280
insilmaril@564
  1281
	fo->load(flagsPath+"freemind/stop.png");
insilmaril@582
  1282
	setupFlag (fo,tb,avis,"freemind-stop",tr("Stop","Freemind-Flag"));
insilmaril@564
  1283
insilmaril@564
  1284
	fo->load(flagsPath+"freemind/wizard.png");
insilmaril@582
  1285
	setupFlag (fo,tb,avis,"freemind-wizard",tr("Magic","Freemind-Flag"));
insilmaril@564
  1286
insilmaril@564
  1287
	fo->load(flagsPath+"freemind/xmag.png");
insilmaril@582
  1288
	setupFlag (fo,tb,avis,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
insilmaril@564
  1289
insilmaril@564
  1290
	fo->load(flagsPath+"freemind/bell.png");
insilmaril@582
  1291
	setupFlag (fo,tb,avis,"freemind-bell",tr("Reminder","Freemind-Flag"));
insilmaril@564
  1292
insilmaril@564
  1293
	fo->load(flagsPath+"freemind/bookmark.png");
insilmaril@582
  1294
	setupFlag (fo,tb,avis,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
insilmaril@564
  1295
insilmaril@564
  1296
	fo->load(flagsPath+"freemind/penguin.png");
insilmaril@582
  1297
	setupFlag (fo,tb,avis,"freemind-penguin",tr("Linux","Freemind-Flag"));
insilmaril@564
  1298
insilmaril@564
  1299
	fo->load(flagsPath+"freemind/licq.png");
insilmaril@582
  1300
	setupFlag (fo,tb,avis,"freemind-licq",tr("Sweet","Freemind-Flag"));
insilmaril@564
  1301
insilmaril@564
  1302
	delete (fo);
insilmaril@564
  1303
}
insilmaril@564
  1304
insilmaril@582
  1305
void Main::setupFlag (FlagObj *fo, QToolBar *tb, bool aw, const QString &name, const QString &tooltip)
insilmaril@564
  1306
{
insilmaril@564
  1307
	fo->setName(name);
insilmaril@582
  1308
	fo->setToolTip (tooltip);
insilmaril@564
  1309
	QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
insilmaril@582
  1310
	if (tb)
insilmaril@582
  1311
	{
insilmaril@582
  1312
		// StandardFlag
insilmaril@582
  1313
		tb->addAction (a);
insilmaril@582
  1314
		fo->setAction (a);
insilmaril@582
  1315
		fo->setAlwaysVisible(aw);
insilmaril@582
  1316
		a->setCheckable(true);
insilmaril@582
  1317
		a->setObjectName(fo->getName());
insilmaril@582
  1318
		a->setToolTip(tooltip);
insilmaril@582
  1319
		connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
insilmaril@582
  1320
		standardFlagsDefault->addFlag (fo);	
insilmaril@582
  1321
	} else
insilmaril@582
  1322
	{
insilmaril@582
  1323
		// SystemFlag
insilmaril@582
  1324
		systemFlagsDefault->addFlag (fo);	
insilmaril@582
  1325
	}
insilmaril@0
  1326
}
insilmaril@528
  1327
// Network Actions
insilmaril@528
  1328
void Main::setupNetworkActions()
insilmaril@528
  1329
{
insilmaril@528
  1330
	if (!settings.value( "/mainwindow/showTestMenu",false).toBool() ) 
insilmaril@528
  1331
		return;
insilmaril@528
  1332
    QMenu *netMenu = menuBar()->addMenu(  "&Network" );
insilmaril@528
  1333
insilmaril@528
  1334
	QAction *a;
insilmaril@528
  1335
insilmaril@528
  1336
    a = new QAction(  "Start TCPserver for MapEditor",this);
insilmaril@528
  1337
    //a->setStatusTip ( "Set application to open pdf files"));
insilmaril@528
  1338
	a->setShortcut ( Qt::Key_T );		//New TCP server
insilmaril@528
  1339
    connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
insilmaril@528
  1340
	netMenu->addAction (a);
insilmaril@528
  1341
insilmaril@528
  1342
    a = new QAction(  "Connect MapEditor to server",this);
insilmaril@528
  1343
    //a->setStatusTip ( "Set application to open pdf files"));
insilmaril@528
  1344
	a->setShortcut ( Qt::Key_C );		// Connect to server
insilmaril@528
  1345
    connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
insilmaril@528
  1346
	netMenu->addAction (a);
insilmaril@528
  1347
}
insilmaril@528
  1348
	
insilmaril@0
  1349
// Settings Actions
insilmaril@0
  1350
void Main::setupSettingsActions()
insilmaril@0
  1351
{
insilmaril@366
  1352
    QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
insilmaril@0
  1353
insilmaril@0
  1354
	QAction *a;
insilmaril@0
  1355
insilmaril@395
  1356
    a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
insilmaril@366
  1357
    a->setStatusTip ( tr( "Set application to open pdf files"));
insilmaril@366
  1358
    connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
insilmaril@366
  1359
	settingsMenu->addAction (a);
insilmaril@366
  1360
insilmaril@395
  1361
    a = new QAction( tr( "Set application to open external links","Settings action"), this);
insilmaril@366
  1362
    a->setStatusTip( tr( "Set application to open external links"));
insilmaril@366
  1363
    connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
insilmaril@366
  1364
	settingsMenu->addAction (a);
insilmaril@366
  1365
insilmaril@473
  1366
    a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
insilmaril@450
  1367
    a->setStatusTip( tr( "Set path for macros"));
insilmaril@450
  1368
    connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
insilmaril@450
  1369
	settingsMenu->addAction (a);
insilmaril@450
  1370
insilmaril@473
  1371
    a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
insilmaril@473
  1372
    a->setStatusTip( tr( "Set number of undo levels"));
insilmaril@473
  1373
    connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
insilmaril@473
  1374
	settingsMenu->addAction (a);
insilmaril@473
  1375
insilmaril@366
  1376
	settingsMenu->addSeparator();
insilmaril@473
  1377
insilmaril@473
  1378
    a = new QAction( tr( "Autosave","Settings action"), this);
insilmaril@473
  1379
    a->setStatusTip( tr( "Autosave"));
insilmaril@473
  1380
	a->setToggleAction(true);
insilmaril@473
  1381
	a->setOn ( settings.value ("/mapeditor/autosave/use",true).toBool());
insilmaril@473
  1382
    connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
insilmaril@473
  1383
	settingsMenu->addAction (a);
insilmaril@473
  1384
	actionSettingsAutosaveToggle=a;
insilmaril@473
  1385
insilmaril@473
  1386
    a = new QAction( tr( "Autosave time","Settings action")+"...", this);
insilmaril@473
  1387
    a->setStatusTip( tr( "Autosave time"));
insilmaril@473
  1388
    connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
insilmaril@473
  1389
	settingsMenu->addAction (a);
insilmaril@473
  1390
	actionSettingsAutosaveTime=a;
insilmaril@473
  1391
insilmaril@473
  1392
	settingsMenu->addSeparator();
insilmaril@473
  1393
insilmaril@395
  1394
    a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
insilmaril@366
  1395
    a->setStatusTip( tr( "Edit branch after adding it" ));
insilmaril@0
  1396
	a->setToggleAction(true);
insilmaril@537
  1397
	a->setOn ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
insilmaril@366
  1398
	settingsMenu->addAction (a);
insilmaril@537
  1399
	actionSettingsAutoEditNewBranch=a;
insilmaril@0
  1400
insilmaril@395
  1401
    a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
insilmaril@366
  1402
    a->setStatusTip( tr( "Select branch after adding it" ));
insilmaril@0
  1403
	a->setToggleAction(true);
insilmaril@537
  1404
	a->setOn ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
insilmaril@366
  1405
	settingsMenu->addAction (a);
insilmaril@537
  1406
	actionSettingsAutoSelectNewBranch=a;
insilmaril@0
  1407
	
insilmaril@395
  1408
    a= new QAction(tr( "Select existing heading","Settings action" ), this);
insilmaril@366
  1409
    a->setStatusTip( tr( "Select heading before editing" ));
insilmaril@0
  1410
	a->setToggleAction(true);
insilmaril@366
  1411
	a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
insilmaril@366
  1412
	settingsMenu->addAction (a);
insilmaril@390
  1413
	actionSettingsAutoSelectText=a;
insilmaril@0
  1414
	
insilmaril@395
  1415
    a= new QAction( tr( "Delete key","Settings action" ), this);
insilmaril@366
  1416
    a->setStatusTip( tr( "Delete key for deleting branches" ));
insilmaril@0
  1417
	a->setToggleAction(true);
insilmaril@505
  1418
	a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
insilmaril@366
  1419
	settingsMenu->addAction (a);
insilmaril@366
  1420
    connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
insilmaril@366
  1421
	actionSettingsUseDelKey=a;
insilmaril@366
  1422
insilmaril@395
  1423
    a= new QAction( tr( "Exclusive flags","Settings action" ), this);
insilmaril@366
  1424
    a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
insilmaril@0
  1425
	a->setToggleAction(true);
insilmaril@366
  1426
	a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
insilmaril@366
  1427
	settingsMenu->addAction (a);
insilmaril@103
  1428
	actionSettingsUseFlagGroups=a;
insilmaril@260
  1429
	
insilmaril@395
  1430
    a= new QAction( tr( "Use hide flags","Settings action" ), this);
insilmaril@366
  1431
    a->setStatusTip( tr( "Use hide flag during exports " ));
insilmaril@260
  1432
	a->setToggleAction(true);
insilmaril@366
  1433
	a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
insilmaril@366
  1434
	settingsMenu->addAction (a);
insilmaril@260
  1435
	actionSettingsUseHideExport=a;
insilmaril@0
  1436
}
insilmaril@0
  1437
insilmaril@0
  1438
// Test Actions
insilmaril@0
  1439
void Main::setupTestActions()
insilmaril@0
  1440
{
insilmaril@366
  1441
    QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
insilmaril@0
  1442
insilmaril@0
  1443
    QAction *a;
insilmaril@527
  1444
    a = new QAction( "Test function 1" , this);
insilmaril@527
  1445
    a->setStatusTip( "Call test function 1" );
insilmaril@527
  1446
	testMenu->addAction (a);
insilmaril@445
  1447
	//a->setShortcut (Qt::Key_F4 );
insilmaril@527
  1448
    connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
insilmaril@527
  1449
insilmaril@527
  1450
    a = new QAction( "Test function 2" , this);
insilmaril@527
  1451
    a->setStatusTip( "Call test function 2" );
insilmaril@527
  1452
	//a->setShortcut (Qt::Key_F4 );
insilmaril@366
  1453
	testMenu->addAction (a);
insilmaril@527
  1454
    connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
insilmaril@527
  1455
insilmaril@395
  1456
    a = new QAction( "Command" , this);
insilmaril@395
  1457
    a->setStatusTip( "Enter command to call in editor" );
insilmaril@445
  1458
	//a->setShortcut (Qt::Key_F5 );
insilmaril@393
  1459
    connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
insilmaril@393
  1460
	testMenu->addAction (a);
insilmaril@0
  1461
}
insilmaril@0
  1462
insilmaril@0
  1463
// Help Actions
insilmaril@0
  1464
void Main::setupHelpActions()
insilmaril@0
  1465
{
insilmaril@395
  1466
    QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
insilmaril@0
  1467
insilmaril@0
  1468
    QAction *a;
insilmaril@395
  1469
    a = new QAction(  tr( "Open VYM Documentation (pdf) ","Help action" ), this );
insilmaril@366
  1470
    a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
insilmaril@366
  1471
    connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
insilmaril@366
  1472
	helpMenu->addAction (a);
insilmaril@366
  1473
insilmaril@505
  1474
    a = new QAction(  tr( "Open VYM example maps ","Help action" ), this );
insilmaril@505
  1475
    a->setStatusTip( tr( "Open VYM example maps " ));
insilmaril@505
  1476
    connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
insilmaril@505
  1477
	helpMenu->addAction (a);
insilmaril@505
  1478
insilmaril@395
  1479
    a = new QAction( tr( "About VYM","Help action" ), this);
insilmaril@404
  1480
    a->setStatusTip( tr( "About VYM")+vymName);
insilmaril@366
  1481
    connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
insilmaril@366
  1482
	helpMenu->addAction (a);
insilmaril@366
  1483
insilmaril@395
  1484
    a = new QAction( tr( "About QT","Help action" ), this);
insilmaril@366
  1485
    a->setStatusTip( tr( "Information about QT toolkit" ));
insilmaril@366
  1486
    connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
insilmaril@366
  1487
	helpMenu->addAction (a);
insilmaril@0
  1488
}
insilmaril@0
  1489
insilmaril@0
  1490
// Context Menus
insilmaril@0
  1491
void Main::setupContextMenus()
insilmaril@0
  1492
{
insilmaril@0
  1493
	QAction*a;
insilmaril@0
  1494
insilmaril@0
  1495
	// Context Menu for branch or mapcenter
insilmaril@366
  1496
	branchContextMenu =new QMenu (this);
insilmaril@486
  1497
	branchContextMenu->addAction (actionViewTogglePropertyWindow);
insilmaril@421
  1498
	branchContextMenu->addSeparator();	
insilmaril@421
  1499
insilmaril@98
  1500
		// Submenu "Add"
insilmaril@366
  1501
		branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
insilmaril@366
  1502
		branchAddContextMenu->addAction (actionEditPaste );
insilmaril@366
  1503
		branchAddContextMenu->addAction ( actionEditAddBranch );
insilmaril@394
  1504
		branchAddContextMenu->addAction ( actionEditAddBranchBefore );
insilmaril@366
  1505
		branchAddContextMenu->addAction ( actionEditAddBranchAbove);
insilmaril@366
  1506
		branchAddContextMenu->addAction ( actionEditAddBranchBelow );
insilmaril@366
  1507
		branchAddContextMenu->addSeparator();	
insilmaril@366
  1508
		branchAddContextMenu->addAction ( actionEditImportAdd );
insilmaril@366
  1509
		branchAddContextMenu->addAction ( actionEditImportReplace );
insilmaril@98
  1510
insilmaril@98
  1511
		// Submenu "Remove"
insilmaril@395
  1512
		branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
insilmaril@366
  1513
		branchRemoveContextMenu->addAction (actionEditCut);
insilmaril@366
  1514
		branchRemoveContextMenu->addAction ( actionEditDelete );
insilmaril@395
  1515
		branchRemoveContextMenu->addAction ( actionEditDeleteKeepChilds );
insilmaril@395
  1516
		branchRemoveContextMenu->addAction ( actionEditDeleteChilds );
insilmaril@98
  1517
		
insilmaril@98
  1518
insilmaril@0
  1519
	actionEditSaveBranch->addTo( branchContextMenu );
insilmaril@98
  1520
insilmaril@366
  1521
	branchContextMenu->addSeparator();	
insilmaril@398
  1522
	branchContextMenu->addAction ( actionEditLoadImage);
insilmaril@366
  1523
insilmaril@366
  1524
	// Submenu for Links (URLs, vymLinks)
insilmaril@366
  1525
	branchLinksContextMenu =new QMenu (this);
insilmaril@366
  1526
insilmaril@366
  1527
		branchContextMenu->addSeparator();	
insilmaril@473
  1528
		branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));	
insilmaril@366
  1529
		branchLinksContextMenu->addAction ( actionEditOpenURL );
insilmaril@366
  1530
		branchLinksContextMenu->addAction ( actionEditOpenURLTab );
insilmaril@366
  1531
		branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
insilmaril@366
  1532
		branchLinksContextMenu->addAction ( actionEditURL );
insilmaril@600
  1533
		branchLinksContextMenu->addAction ( actionEditLocalURL );
insilmaril@366
  1534
		branchLinksContextMenu->addAction ( actionEditHeading2URL );
insilmaril@366
  1535
		branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
insilmaril@528
  1536
		if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
insilmaril@366
  1537
		{
insilmaril@366
  1538
			branchLinksContextMenu->addAction ( actionEditFATE2URL );
insilmaril@366
  1539
		}	
insilmaril@366
  1540
		branchLinksContextMenu->addSeparator();	
insilmaril@366
  1541
		branchLinksContextMenu->addAction ( actionEditOpenVymLink );
insilmaril@366
  1542
		branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
insilmaril@366
  1543
		branchLinksContextMenu->addAction ( actionEditVymLink );
insilmaril@366
  1544
		branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
insilmaril@366
  1545
		
insilmaril@366
  1546
insilmaril@366
  1547
	// Context Menu for XLinks in a branch menu
insilmaril@89
  1548
	// This will be populated "on demand" in MapEditor::updateActions
insilmaril@366
  1549
	branchContextMenu->addSeparator();	
insilmaril@395
  1550
	branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
insilmaril@395
  1551
	branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
insilmaril@366
  1552
	connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
insilmaril@366
  1553
	connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
insilmaril@366
  1554
 	
insilmaril@105
  1555
	
insilmaril@0
  1556
	// Context menu for floatimage
insilmaril@366
  1557
	floatimageContextMenu =new QMenu (this);
insilmaril@395
  1558
	a= new QAction (tr ("Save image","Context action"),this);
insilmaril@366
  1559
	connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
insilmaril@366
  1560
	floatimageContextMenu->addAction (a);
insilmaril@366
  1561
insilmaril@366
  1562
	floatimageContextMenu->addSeparator();	
insilmaril@0
  1563
	actionEditCopy->addTo( floatimageContextMenu );
insilmaril@0
  1564
	actionEditCut->addTo( floatimageContextMenu );
insilmaril@0
  1565
insilmaril@366
  1566
	floatimageContextMenu->addSeparator();	
insilmaril@366
  1567
	floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
insilmaril@366
  1568
insilmaril@0
  1569
	
insilmaril@0
  1570
	// Context menu for canvas
insilmaril@366
  1571
	canvasContextMenu =new QMenu (this);
insilmaril@0
  1572
	actionEditMapInfo->addTo( canvasContextMenu );
insilmaril@0
  1573
	canvasContextMenu->insertSeparator();	
insilmaril@0
  1574
	actionGroupFormatLinkStyles->addTo( canvasContextMenu );
insilmaril@0
  1575
	canvasContextMenu->insertSeparator();	
insilmaril@0
  1576
	actionFormatLinkColorHint->addTo( canvasContextMenu );
insilmaril@0
  1577
	actionFormatLinkColor->addTo( canvasContextMenu );
insilmaril@442
  1578
	actionFormatSelectionColor->addTo( canvasContextMenu );
insilmaril@0
  1579
	actionFormatBackColor->addTo( canvasContextMenu );
insilmaril@505
  1580
	// actionFormatBackImage->addTo( canvasContextMenu );  //FIXME makes vym too slow: postponed for later version 
insilmaril@0
  1581
insilmaril@0
  1582
	// Menu for last opened files
insilmaril@401
  1583
	// Create actions
insilmaril@401
  1584
	for (int i = 0; i < MaxRecentFiles; ++i) 
insilmaril@0
  1585
	{
insilmaril@445
  1586
        recentFileActions[i] = new QAction(this);
insilmaril@445
  1587
        recentFileActions[i]->setVisible(false);
insilmaril@445
  1588
        fileLastMapsMenu->addAction(recentFileActions[i]);
insilmaril@445
  1589
        connect(recentFileActions[i], SIGNAL(triggered()),
insilmaril@401
  1590
                this, SLOT(fileLoadRecent()));
insilmaril@401
  1591
    }
insilmaril@401
  1592
	setupRecentMapsMenu();
insilmaril@0
  1593
}
insilmaril@0
  1594
insilmaril@401
  1595
void Main::setupRecentMapsMenu()
insilmaril@0
  1596
{
insilmaril@401
  1597
    QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
insilmaril@401
  1598
insilmaril@401
  1599
    int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
insilmaril@401
  1600
insilmaril@401
  1601
    for (int i = 0; i < numRecentFiles; ++i) {
insilmaril@401
  1602
        QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
insilmaril@445
  1603
        recentFileActions[i]->setText(text);
insilmaril@445
  1604
        recentFileActions[i]->setData(files[i]);
insilmaril@445
  1605
        recentFileActions[i]->setVisible(true);
insilmaril@401
  1606
    }
insilmaril@401
  1607
    for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
insilmaril@445
  1608
        recentFileActions[j]->setVisible(false);
insilmaril@445
  1609
}
insilmaril@445
  1610
insilmaril@445
  1611
void Main::setupMacros()
insilmaril@445
  1612
{
insilmaril@445
  1613
    for (int i = 0; i <= 11; i++) 
insilmaril@445
  1614
	{
insilmaril@445
  1615
        macroActions[i] = new QAction(this);
insilmaril@445
  1616
        macroActions[i]->setData(i);
insilmaril@445
  1617
        addAction (macroActions[i]);
insilmaril@445
  1618
        connect(macroActions[i], SIGNAL(triggered()),
insilmaril@445
  1619
                this, SLOT(callMacro()));
insilmaril@445
  1620
	}			
insilmaril@445
  1621
	macroActions[0]->setShortcut ( Qt::Key_F1 );
insilmaril@445
  1622
	macroActions[1]->setShortcut ( Qt::Key_F2 );
insilmaril@445
  1623
	macroActions[2]->setShortcut ( Qt::Key_F3 );
insilmaril@445
  1624
	macroActions[3]->setShortcut ( Qt::Key_F4 );
insilmaril@445
  1625
	macroActions[4]->setShortcut ( Qt::Key_F5 );
insilmaril@445
  1626
	macroActions[5]->setShortcut ( Qt::Key_F6 );
insilmaril@445
  1627
	macroActions[6]->setShortcut ( Qt::Key_F7 );
insilmaril@445
  1628
	macroActions[7]->setShortcut ( Qt::Key_F8 );
insilmaril@445
  1629
	macroActions[8]->setShortcut ( Qt::Key_F9 );
insilmaril@445
  1630
	macroActions[9]->setShortcut ( Qt::Key_F10 );
insilmaril@445
  1631
	macroActions[10]->setShortcut ( Qt::Key_F11 );
insilmaril@445
  1632
	macroActions[11]->setShortcut ( Qt::Key_F12 );
insilmaril@0
  1633
}
insilmaril@0
  1634
insilmaril@0
  1635
void Main::hideEvent (QHideEvent * )
insilmaril@0
  1636
{
insilmaril@0
  1637
	if (!textEditor->isMinimized() ) textEditor->hide();
insilmaril@0
  1638
}
insilmaril@0
  1639
insilmaril@0
  1640
void Main::showEvent (QShowEvent * )
insilmaril@0
  1641
{
insilmaril@491
  1642
	if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
insilmaril@0
  1643
}
insilmaril@0
  1644
insilmaril@0
  1645
insilmaril@0
  1646
MapEditor* Main::currentMapEditor() const
insilmaril@0
  1647
{
insilmaril@0
  1648
    if ( tabWidget->currentPage() &&
insilmaril@0
  1649
	 tabWidget->currentPage()->inherits( "MapEditor" ) )
insilmaril@0
  1650
		return (MapEditor*)tabWidget->currentPage();
insilmaril@0
  1651
    return NULL;	
insilmaril@0
  1652
}
insilmaril@0
  1653
insilmaril@0
  1654
insilmaril@0
  1655
void Main::editorChanged(QWidget *)
insilmaril@0
  1656
{
insilmaril@0
  1657
	// Unselect all possibly selected objects
insilmaril@0
  1658
	// (Important to update note editor)
insilmaril@0
  1659
	MapEditor *me;
insilmaril@473
  1660
	for (int i=0;i<=tabWidget->count() -1;i++)
insilmaril@0
  1661
	{
insilmaril@0
  1662
		
insilmaril@0
  1663
		me=(MapEditor*)tabWidget->page(i);
insilmaril@0
  1664
		me->unselect();
insilmaril@0
  1665
	}	
insilmaril@0
  1666
	currentMapEditor()->reselect();
insilmaril@0
  1667
insilmaril@0
  1668
	// Update actions to in menus and toolbars according to editor
insilmaril@407
  1669
	updateActions();
insilmaril@0
  1670
}
insilmaril@0
  1671
insilmaril@0
  1672
void Main::fileNew()
insilmaril@0
  1673
{
insilmaril@0
  1674
	QString fn="unnamed";
insilmaril@408
  1675
	MapEditor* me = new MapEditor ( NULL);
insilmaril@408
  1676
	tabWidget->addTab (me,fn);
insilmaril@408
  1677
	tabWidget->showPage(me);
insilmaril@408
  1678
	me->viewport()->setFocus();
insilmaril@408
  1679
	me->setAntiAlias (actionViewToggleAntiAlias->isOn());
insilmaril@408
  1680
	me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
insilmaril@408
  1681
	
insilmaril@366
  1682
	// For the very first map we do not have flagrows yet...
insilmaril@408
  1683
	me->select("mc:");
insilmaril@0
  1684
}
insilmaril@0
  1685
insilmaril@491
  1686
void Main::fileNewCopy()
insilmaril@491
  1687
{
insilmaril@491
  1688
	QString fn="unnamed";
insilmaril@491
  1689
	MapEditor* oldME =currentMapEditor();
insilmaril@491
  1690
	if (oldME)
insilmaril@491
  1691
	{
insilmaril@491
  1692
		oldME->copy();
insilmaril@491
  1693
		MapEditor* newME = new MapEditor ( NULL);
insilmaril@491
  1694
		if (newME)
insilmaril@491
  1695
		{
insilmaril@491
  1696
			tabWidget->addTab (newME,fn);
insilmaril@491
  1697
			tabWidget->showPage(newME);
insilmaril@491
  1698
			newME->viewport()->setFocus();
insilmaril@491
  1699
			newME->setAntiAlias (actionViewToggleAntiAlias->isOn());
insilmaril@491
  1700
			newME->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
insilmaril@491
  1701
			// For the very first map we do not have flagrows yet...
insilmaril@491
  1702
			newME->select("mc:");
insilmaril@571
  1703
			newME->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
insilmaril@491
  1704
		}
insilmaril@491
  1705
insilmaril@491
  1706
	}
insilmaril@491
  1707
}
insilmaril@491
  1708
insilmaril@571
  1709
ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
insilmaril@0
  1710
{
insilmaril@205
  1711
	ErrorCode err=success;
insilmaril@0
  1712
	
insilmaril@0
  1713
	// fn is usually the archive, mapfile the file after uncompressing
insilmaril@0
  1714
	QString mapfile;
insilmaril@0
  1715
insilmaril@0
  1716
	// Make fn absolute (needed for unzip)
insilmaril@0
  1717
	fn=QDir (fn).absPath();
insilmaril@0
  1718
insilmaril@0
  1719
	MapEditor *me;
insilmaril@0
  1720
insilmaril@0
  1721
	if (lmode==NewMap)
insilmaril@0
  1722
	{
insilmaril@0
  1723
		// Check, if map is already loaded
insilmaril@0
  1724
		int i=0;
insilmaril@0
  1725
		while (i<=tabWidget->count() -1)
insilmaril@0
  1726
		{
insilmaril@0
  1727
			me=(MapEditor*)tabWidget->page(i);
insilmaril@0
  1728
			if (me->getFilePath() == fn)
insilmaril@0
  1729
			{
insilmaril@0
  1730
				// Already there, ask for confirmation
insilmaril@404
  1731
				QMessageBox mb( vymName,
insilmaril@159
  1732
					tr("The map %1\nis already opened."
insilmaril@0
  1733
					"Opening the same map in multiple editors may lead \n"
insilmaril@0
  1734
					"to confusion when finishing working with vym."
insilmaril@159
  1735
					"Do you want to").arg(fn),
insilmaril@0
  1736
					QMessageBox::Warning,
insilmaril@0
  1737
					QMessageBox::Yes | QMessageBox::Default,
insilmaril@0
  1738
					QMessageBox::Cancel | QMessageBox::Escape,
insilmaril@366
  1739
					QMessageBox::NoButton);
insilmaril@0
  1740
				mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
insilmaril@0
  1741
				mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
insilmaril@0
  1742
				switch( mb.exec() ) 
insilmaril@0
  1743
				{
insilmaril@0
  1744
					case QMessageBox::Yes:
insilmaril@0
  1745
						// load anyway
insilmaril@0
  1746
						i=tabWidget->count();
insilmaril@0
  1747
						break;
insilmaril@0
  1748
					case QMessageBox::Cancel:
insilmaril@0
  1749
						// do nothing
insilmaril@205
  1750
						return aborted;
insilmaril@0
  1751
						break;
insilmaril@0
  1752
				}
insilmaril@0
  1753
			}
insilmaril@0
  1754
			i++;
insilmaril@0
  1755
		}
insilmaril@0
  1756
	}
insilmaril@0
  1757
insilmaril@0
  1758
insilmaril@0
  1759
	// Try to load map
insilmaril@0
  1760
    if ( !fn.isEmpty() )
insilmaril@0
  1761
	{
insilmaril@0
  1762
		me = currentMapEditor();
insilmaril@0
  1763
		int tabIndex=tabWidget->currentPageIndex();
insilmaril@0
  1764
		// Check first, if mapeditor exists
insilmaril@0
  1765
		// If it is not default AND we want a new map, 
insilmaril@0
  1766
		// create a new mapeditor in a new tab
insilmaril@0
  1767
		if ( lmode==NewMap && (!me || !me->isDefault() ) )
insilmaril@0
  1768
		{
insilmaril@390
  1769
			me= new MapEditor ( NULL);
insilmaril@0
  1770
			tabWidget->addTab (me,fn);
insilmaril@0
  1771
			tabIndex=tabWidget->indexOf (me);
insilmaril@0
  1772
			tabWidget->setCurrentPage (tabIndex);
insilmaril@408
  1773
			me->setAntiAlias (actionViewToggleAntiAlias->isOn());
insilmaril@408
  1774
			me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
insilmaril@0
  1775
		}
insilmaril@0
  1776
		
insilmaril@0
  1777
		// Check, if file exists (important for creating new files
insilmaril@0
  1778
		// from command line
insilmaril@0
  1779
		if (!QFile(fn).exists() )
insilmaril@0
  1780
		{
insilmaril@404
  1781
			QMessageBox mb( vymName,
insilmaril@159
  1782
				tr("This map does not exist:\n  %1\nDo you want to create a new one?").arg(fn),
insilmaril@0
  1783
				QMessageBox::Question,
insilmaril@0
  1784
				QMessageBox::Yes ,
insilmaril@0
  1785
				QMessageBox::Cancel | QMessageBox::Default,
insilmaril@366
  1786
				QMessageBox::NoButton );
insilmaril@0
  1787
insilmaril@0
  1788
			mb.setButtonText( QMessageBox::Yes, tr("Create"));
insilmaril@0
  1789
			mb.setButtonText( QMessageBox::No, tr("Cancel"));
insilmaril@0
  1790
			switch( mb.exec() ) 
insilmaril@0
  1791
			{
insilmaril@0
  1792
				case QMessageBox::Yes:
insilmaril@0
  1793
					// Create new map
insilmaril@0
  1794
					currentMapEditor()->setFilePath(fn);
insilmaril@0
  1795
					tabWidget->setTabLabel (currentMapEditor(),
insilmaril@0
  1796
						currentMapEditor()->getFileName() );
insilmaril@0
  1797
					statusBar()->message( "Created " + fn , statusbarTime );
insilmaril@205
  1798
					return success;
insilmaril@0
  1799
						
insilmaril@0
  1800
				case QMessageBox::Cancel:
insilmaril@0
  1801
					// don't create new map
insilmaril@0
  1802
					statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
insilmaril@0
  1803
					fileCloseMap();
insilmaril@205
  1804
					return aborted;
insilmaril@0
  1805
			}
insilmaril@0
  1806
		}	
insilmaril@0
  1807
insilmaril@0
  1808
insilmaril@0
  1809
		//tabWidget->currentPage() won't be NULL here, because of above...
insilmaril@0
  1810
		tabWidget->showPage(me);
insilmaril@0
  1811
		me->viewport()->setFocus();
insilmaril@0
  1812
insilmaril@0
  1813
		// Create temporary directory for packing
insilmaril@377
  1814
		bool ok;
insilmaril@608
  1815
		QString tmpMapDir=makeTmpDir (ok,"vym-pack");
insilmaril@377
  1816
		if (!ok)
insilmaril@377
  1817
		{
insilmaril@377
  1818
			QMessageBox::critical( 0, tr( "Critical Load Error" ),
insilmaril@377
  1819
			   tr("Couldn't create temporary directory before load\n"));
insilmaril@377
  1820
			return aborted; 
insilmaril@377
  1821
		}
insilmaril@0
  1822
insilmaril@0
  1823
		// Try to unzip file
insilmaril@185
  1824
		err=unzipDir (tmpMapDir,fn);
insilmaril@185
  1825
		if (err==nozip)
insilmaril@0
  1826
		{
insilmaril@185
  1827
			mapfile=fn;
insilmaril@185
  1828
			me->setZipped(false);
insilmaril@0
  1829
		} else
insilmaril@0
  1830
		{
insilmaril@185
  1831
			me->setZipped(true);
insilmaril@185
  1832
			
insilmaril@185
  1833
			// Look for mapname.xml
insilmaril@185
  1834
			mapfile= fn.left(fn.findRev(".",-1,true));
insilmaril@185
  1835
			mapfile=mapfile.section( '/', -1 );
insilmaril@185
  1836
			QFile file( tmpMapDir + "/" + mapfile + ".xml");
insilmaril@185
  1837
			if (!file.exists() )
insilmaril@0
  1838
			{
insilmaril@185
  1839
				// mapname.xml does not exist, well, 
insilmaril@428
  1840
				// maybe someone renamed the mapname.vym file...
insilmaril@185
  1841
				// Try to find any .xml in the toplevel 
insilmaril@185
  1842
				// directory of the .vym file
insilmaril@185
  1843
				QStringList flist=QDir (tmpMapDir).entryList("*.xml");
insilmaril@185
  1844
				if (flist.count()==1) 
insilmaril@0
  1845
				{
insilmaril@185
  1846
					// Only one entry, take this one
insilmaril@185
  1847
					mapfile=tmpMapDir + "/"+flist.first();
insilmaril@0
  1848
				} else
insilmaril@185
  1849
				{
insilmaril@185
  1850
					for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it ) 
insilmaril@185
  1851
						*it=tmpMapDir + "/" + *it;
insilmaril@185
  1852
					// TODO Multiple entries, load all (but only the first one into this ME)
insilmaril@185
  1853
					//mainWindow->fileLoadFromTmp (flist);
insilmaril@185
  1854
					//returnCode=1;	// Silently forget this attempt to load
insilmaril@185
  1855
					qWarning ("MainWindow::load (fn)  multimap found...");
insilmaril@185
  1856
				}	
insilmaril@0
  1857
					
insilmaril@185
  1858
				if (flist.isEmpty() )
insilmaril@185
  1859
				{
insilmaril@185
  1860
					QMessageBox::critical( 0, tr( "Critical Load Error" ),
insilmaril@185
  1861
							   tr("Couldn't find a map (*.xml) in .vym archive.\n"));
insilmaril@185
  1862
					err=aborted;				   
insilmaril@185
  1863
				}	
insilmaril@185
  1864
			} //file doesn't exist	
insilmaril@185
  1865
			else
insilmaril@185
  1866
				mapfile=file.name();
insilmaril@0
  1867
		}
insilmaril@0
  1868
insilmaril@185
  1869
		if (err!=aborted)
insilmaril@185
  1870
		{
insilmaril@185
  1871
			// Save existing filename in case  we import
insilmaril@185
  1872
			QString fn_org=me->getFilePath();
insilmaril@106
  1873
insilmaril@185
  1874
			// Finally load map into mapEditor
insilmaril@185
  1875
			me->setFilePath (mapfile,fn);
insilmaril@571
  1876
			err=me->load(mapfile,lmode,ftype);
insilmaril@106
  1877
insilmaril@185
  1878
			// Restore old (maybe empty) filepath, if this is an import
insilmaril@185
  1879
			if (lmode!=NewMap)
insilmaril@185
  1880
				me->setFilePath (fn_org);
insilmaril@185
  1881
		}	
insilmaril@0
  1882
insilmaril@185
  1883
		// Finally check for errors and go home
insilmaril@185
  1884
		if (err==aborted) 
insilmaril@185
  1885
		{
insilmaril@185
  1886
			if (lmode==NewMap) fileCloseMap();
insilmaril@185
  1887
			statusBar()->message( "Could not load " + fn, statusbarTime );
insilmaril@185
  1888
		} else 
insilmaril@0
  1889
		{
insilmaril@0
  1890
			if (lmode==NewMap)
insilmaril@0
  1891
			{
insilmaril@0
  1892
				me->setFilePath (fn);
insilmaril@0
  1893
				tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
insilmaril@608
  1894
				if (!isInTmpDir (fn))
insilmaril@205
  1895
				{
insilmaril@205
  1896
					// Only append to lastMaps if not loaded from a tmpDir
insilmaril@205
  1897
					// e.g. imported bookmarks are in a tmpDir
insilmaril@401
  1898
					addRecentMap(me->getFilePath() );
insilmaril@205
  1899
				}
insilmaril@0
  1900
				actionFilePrint->setEnabled (true);
insilmaril@0
  1901
			}	
insilmaril@0
  1902
			statusBar()->message( "Loaded " + fn, statusbarTime );
insilmaril@0
  1903
		}	
insilmaril@0
  1904
insilmaril@185
  1905
		// Delete tmpDir
insilmaril@185
  1906
		removeDir (QDir(tmpMapDir));
insilmaril@0
  1907
	}
insilmaril@205
  1908
	return err;
insilmaril@0
  1909
}
insilmaril@0
  1910
insilmaril@0
  1911
insilmaril@0
  1912
void Main::fileLoad(const LoadMode &lmode)
insilmaril@0
  1913
{
insilmaril@377
  1914
	QStringList filters;
insilmaril@389
  1915
	filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
insilmaril@377
  1916
	QFileDialog *fd=new QFileDialog( this);
insilmaril@366
  1917
	fd->setDir (lastFileDir);
insilmaril@377
  1918
	fd->setFileMode (QFileDialog::ExistingFiles);
insilmaril@377
  1919
	fd->setFilters (filters);
insilmaril@0
  1920
	switch (lmode)
insilmaril@0
  1921
	{
insilmaril@0
  1922
		case NewMap:
insilmaril@404
  1923
			fd->setCaption(vymName+ " - " +tr("Load vym map"));
insilmaril@0
  1924
			break;
insilmaril@0
  1925
		case ImportAdd:
insilmaril@404
  1926
			fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
insilmaril@0
  1927
			break;
insilmaril@0
  1928
		case ImportReplace:
insilmaril@404
  1929
			fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
insilmaril@0
  1930
			break;
insilmaril@0
  1931
	}
insilmaril@0
  1932
	fd->show();
insilmaril@0
  1933
insilmaril@0
  1934
	QString fn;
insilmaril@0
  1935
	if ( fd->exec() == QDialog::Accepted )
insilmaril@0
  1936
	{
insilmaril@377
  1937
		lastFileDir=fd->directory().path();
insilmaril@185
  1938
	    QStringList flist = fd->selectedFiles();
insilmaril@185
  1939
		QStringList::Iterator it = flist.begin();
insilmaril@185
  1940
		while( it != flist.end() ) 
insilmaril@185
  1941
		{
insilmaril@185
  1942
			fn = *it;
insilmaril@185
  1943
			fileLoad(*it, lmode);				   
insilmaril@185
  1944
			++it;
insilmaril@185
  1945
		}
insilmaril@0
  1946
	}
insilmaril@185
  1947
	delete (fd);
insilmaril@0
  1948
}
insilmaril@0
  1949
insilmaril@0
  1950
void Main::fileLoad()
insilmaril@0
  1951
{
insilmaril@0
  1952
	fileLoad (NewMap);
insilmaril@0
  1953
}
insilmaril@0
  1954
insilmaril@401
  1955
void Main::fileLoadRecent()
insilmaril@0
  1956
{
insilmaril@401
  1957
    QAction *action = qobject_cast<QAction *>(sender());
insilmaril@401
  1958
    if (action)
insilmaril@401
  1959
        fileLoad (action->data().toString(), NewMap);
insilmaril@401
  1960
}
insilmaril@401
  1961
insilmaril@401
  1962
void Main::addRecentMap (const QString &fileName)
insilmaril@401
  1963
{
insilmaril@401
  1964
insilmaril@401
  1965
    QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
insilmaril@401
  1966
    files.removeAll(fileName);
insilmaril@401
  1967
    files.prepend(fileName);
insilmaril@401
  1968
    while (files.size() > MaxRecentFiles)
insilmaril@401
  1969
        files.removeLast();
insilmaril@401
  1970
insilmaril@401
  1971
    settings.setValue("/mainwindow/recentFileList", files);
insilmaril@401
  1972
insilmaril@401
  1973
	setupRecentMapsMenu();
insilmaril@0
  1974
}
insilmaril@0
  1975
insilmaril@473
  1976
void Main::fileSave(MapEditor *me, const SaveMode &savemode)
insilmaril@0
  1977
{
insilmaril@0
  1978
	// tmp dir for zipping 
insilmaril@0
  1979
	QString tmpMapDir;
insilmaril@0
  1980
	
insilmaril@0
  1981
	// Error codes
insilmaril@205
  1982
	ErrorCode err=success;
insilmaril@0
  1983
	
insilmaril@0
  1984
	QString safeFilePath;
insilmaril@0
  1985
insilmaril@473
  1986
	bool saveZipped=me->saveZipped();
insilmaril@473
  1987
insilmaril@151
  1988
	if (me)
insilmaril@0
  1989
	{
insilmaril@151
  1990
		QString fn=me->getFilePath();
insilmaril@473
  1991
		// filename=unnamed, filepath="" in constructor of mapEditor
insilmaril@0
  1992
		if ( !fn.isEmpty() ) 
insilmaril@0
  1993
		{	
insilmaril@0
  1994
			// We have a filepath, go on saving			
insilmaril@0
  1995
			// First remove existing file, we 
insilmaril@0
  1996
			// don't want to add to old zip archives
insilmaril@0
  1997
			QFile f(fn);
insilmaril@0
  1998
			if (f.exists() ) 
insilmaril@0
  1999
				if (!f.remove())
insilmaril@0
  2000
					QMessageBox::warning( 0, tr( "Save Error" ),
insilmaril@0
  2001
						fn+   tr("\ncould not be removed before saving"));
insilmaril@0
  2002
insilmaril@0
  2003
			// Look, if we should zip the data:
insilmaril@0
  2004
			if (!saveZipped)
insilmaril@0
  2005
			{
insilmaril@404
  2006
				QMessageBox mb( vymName,
insilmaril@159
  2007
					tr("The map %1\ndid not use the compressed "
insilmaril@0
  2008
					"vym file format.\nWriting it uncompressed will also write images \n"
insilmaril@0
  2009
					"and flags and thus may overwrite files in the "
insilmaril@159
  2010
					"given directory\n\nDo you want to write the map").arg(fn),
insilmaril@0
  2011
					QMessageBox::Warning,
insilmaril@0
  2012
					QMessageBox::Yes | QMessageBox::Default,
insilmaril@0
  2013
					QMessageBox::No ,
insilmaril@0
  2014
					QMessageBox::Cancel | QMessageBox::Escape);
insilmaril@0
  2015
				mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
insilmaril@0
  2016
				mb.setButtonText( QMessageBox::No, tr("uncompressed") );
insilmaril@0
  2017
				mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
insilmaril@0
  2018
				switch( mb.exec() ) 
insilmaril@0
  2019
				{
insilmaril@0
  2020
					case QMessageBox::Yes:
insilmaril@0
  2021
						// save compressed (default file format)
insilmaril@0
  2022
						saveZipped=true;
insilmaril@0
  2023
						break;
insilmaril@0
  2024
					case QMessageBox::No:
insilmaril@0
  2025
						// save uncompressed
insilmaril@0
  2026
						saveZipped=false;
insilmaril@0
  2027
						break;
insilmaril@0
  2028
					case QMessageBox::Cancel:
insilmaril@0
  2029
						// do nothing
insilmaril@0
  2030
						return;
insilmaril@0
  2031
						break;
insilmaril@0
  2032
				}
insilmaril@615
  2033
				me->setZipped (saveZipped);
insilmaril@0
  2034
			}
insilmaril@0
  2035
insilmaril@0
  2036
			if (saveZipped)
insilmaril@0
  2037
			{
insilmaril@377
  2038
				// Create temporary directory for packing
insilmaril@377
  2039
				bool ok;
insilmaril@608
  2040
				QString tmpMapDir=makeTmpDir (ok,"vym-zip");
insilmaril@377
  2041
				if (!ok)
insilmaril@377
  2042
				{
insilmaril@377
  2043
					QMessageBox::critical( 0, tr( "Critical Load Error" ),
insilmaril@377
  2044
					   tr("Couldn't create temporary directory before save\n"));
insilmaril@377
  2045
					return; 
insilmaril@377
  2046
				}
insilmaril@377
  2047
insilmaril@151
  2048
				safeFilePath=me->getFilePath();
insilmaril@151
  2049
				me->setFilePath (tmpMapDir+"/"+
insilmaril@151
  2050
					me->getMapName()+ ".xml",
insilmaril@0
  2051
					safeFilePath);
insilmaril@151
  2052
				me->save (savemode);
insilmaril@151
  2053
				me->setFilePath (safeFilePath);
insilmaril@0
  2054
				
insilmaril@175
  2055
				zipDir (tmpMapDir,fn);
insilmaril@0
  2056
			} // save zipped
insilmaril@0
  2057
			else
insilmaril@0
  2058
			{
insilmaril@0
  2059
				// Save unzipped. 
insilmaril@151
  2060
				safeFilePath=me->getFilePath();
insilmaril@151
  2061
				me->setFilePath (fn, safeFilePath);
insilmaril@151
  2062
				me->save (savemode);
insilmaril@151
  2063
				me->setFilePath (safeFilePath);
insilmaril@0
  2064
			} // save zipped 	
insilmaril@0
  2065
		} // filepath available
insilmaril@0
  2066
		else
insilmaril@0
  2067
		{
insilmaril@0
  2068
			// We have  no filepath yet,
insilmaril@0
  2069
			// call fileSaveAs() now, this will call fileSave() 
insilmaril@0
  2070
			// again.
insilmaril@473
  2071
			// First switch to editor
insilmaril@473
  2072
			tabWidget->setCurrentWidget (me);
insilmaril@0
  2073
			fileSaveAs(savemode);
insilmaril@0
  2074
		}
insilmaril@0
  2075
    }
insilmaril@0
  2076
insilmaril@250
  2077
	if (saveZipped && !tmpMapDir.isEmpty())
insilmaril@0
  2078
		// Delete tmpDir
insilmaril@175
  2079
		removeDir (QDir(tmpMapDir));
insilmaril@0
  2080
insilmaril@0
  2081
	if (err==success)
insilmaril@151
  2082
	{
insilmaril@0
  2083
		statusBar()->message( 
insilmaril@159
  2084
			tr("Saved  %1").arg(me->getFilePath()), 
insilmaril@0
  2085
			statusbarTime );
insilmaril@401
  2086
		addRecentMap (me->getFilePath() );
insilmaril@151
  2087
	} else		
insilmaril@0
  2088
		statusBar()->message( 
insilmaril@159
  2089
			tr("Couldn't save ").arg(me->getFilePath()), 
insilmaril@0
  2090
			statusbarTime );
insilmaril@0
  2091
}
insilmaril@0
  2092
insilmaril@0
  2093
void Main::fileSave()
insilmaril@0
  2094
{
insilmaril@473
  2095
	fileSave (currentMapEditor(), CompleteMap);
insilmaril@473
  2096
}
insilmaril@473
  2097
insilmaril@473
  2098
void Main::fileSave(MapEditor *me)
insilmaril@473
  2099
{
insilmaril@473
  2100
	fileSave (me,CompleteMap);
insilmaril@0
  2101
}
insilmaril@0
  2102
insilmaril@0
  2103
void Main::fileSaveAs(const SaveMode& savemode)
insilmaril@0
  2104
{
insilmaril@0
  2105
	QString fn;
insilmaril@0
  2106
insilmaril@0
  2107
	if (currentMapEditor())
insilmaril@0
  2108
	{
insilmaril@0
  2109
		if (savemode==CompleteMap)
insilmaril@366
  2110
			fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
insilmaril@0
  2111
		else		
insilmaril@366
  2112
			fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
insilmaril@0
  2113
		if ( !fn.isEmpty() ) 
insilmaril@0
  2114
		{
insilmaril@0
  2115
			// Check for existing file
insilmaril@0
  2116
			if (QFile (fn).exists())
insilmaril@0
  2117
			{
insilmaril@404
  2118
				QMessageBox mb( vymName,
insilmaril@159
  2119
					tr("The file %1\nexists already. Do you want to").arg(fn),
insilmaril@0
  2120
					QMessageBox::Warning,
insilmaril@0
  2121
					QMessageBox::Yes | QMessageBox::Default,
insilmaril@0
  2122
					QMessageBox::Cancel | QMessageBox::Escape,
insilmaril@366
  2123
					QMessageBox::NoButton);
insilmaril@0
  2124
				mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
insilmaril@0
  2125
				mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
insilmaril@0
  2126
				switch( mb.exec() ) 
insilmaril@0
  2127
				{
insilmaril@0
  2128
					case QMessageBox::Yes:
insilmaril@0
  2129
						// save 
insilmaril@0
  2130
						break;
insilmaril@0
  2131
					case QMessageBox::Cancel:
insilmaril@0
  2132
						// do nothing
insilmaril@0
  2133
						return;
insilmaril@0
  2134
						break;
insilmaril@0
  2135
				}
insilmaril@0
  2136
			} else
insilmaril@0
  2137
			{
insilmaril@0
  2138
				// New file, add extension to filename, if missing
insilmaril@0
  2139
				// This is always .vym or .vyp, depending on savemode
insilmaril@0
  2140
				if (savemode==CompleteMap)
insilmaril@0
  2141
				{
insilmaril@0
  2142
					if (!fn.contains (".vym") && !fn.contains (".xml"))
insilmaril@0
  2143
						fn +=".vym";
insilmaril@0
  2144
				} else		
insilmaril@0
  2145
				{
insilmaril@0
  2146
					if (!fn.contains (".vyp") && !fn.contains (".xml"))
insilmaril@0
  2147
						fn +=".vyp";
insilmaril@0
  2148
				}
insilmaril@0
  2149
			}
insilmaril@0
  2150
	
insilmaril@0
  2151
insilmaril@0
  2152
insilmaril@0
  2153
insilmaril@0
  2154
			// Save now
insilmaril@0
  2155
			currentMapEditor()->setFilePath(fn);
insilmaril@473
  2156
			fileSave(currentMapEditor(), savemode);
insilmaril@0
  2157
insilmaril@0
  2158
			// Set name of tab
insilmaril@94
  2159
			if (savemode==CompleteMap)
insilmaril@94
  2160
				tabWidget->setTabLabel (currentMapEditor(),
insilmaril@94
  2161
					currentMapEditor()->getFileName() );
insilmaril@0
  2162
			return;
insilmaril@0
  2163
		} 
insilmaril@0
  2164
	}
insilmaril@0
  2165
}
insilmaril@0
  2166
insilmaril@0
  2167
void Main::fileSaveAs()
insilmaril@0
  2168
{
insilmaril@0
  2169
	fileSaveAs (CompleteMap);
insilmaril@0
  2170
}
insilmaril@0
  2171
insilmaril@205
  2172
void Main::fileImportKDEBookmarks()
insilmaril@205
  2173
{
insilmaril@205
  2174
	ImportKDEBookmarks im;
insilmaril@205
  2175
	im.transform();
insilmaril@205
  2176
	if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
insilmaril@205
  2177
		currentMapEditor()->setFilePath ("");
insilmaril@205
  2178
}
insilmaril@205
  2179
insilmaril@314
  2180
void Main::fileImportFirefoxBookmarks()
insilmaril@314
  2181
{
insilmaril@366
  2182
	Q3FileDialog *fd=new Q3FileDialog( this);
insilmaril@327
  2183
	fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
insilmaril@366
  2184
	fd->setMode (Q3FileDialog::ExistingFiles);
insilmaril@327
  2185
	fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
insilmaril@327
  2186
	fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
insilmaril@327
  2187
	fd->show();
insilmaril@327
  2188
insilmaril@327
  2189
	if ( fd->exec() == QDialog::Accepted )
insilmaril@327
  2190
	{
insilmaril@327
  2191
		ImportFirefoxBookmarks im;
insilmaril@327
  2192
	    QStringList flist = fd->selectedFiles();
insilmaril@327
  2193
		QStringList::Iterator it = flist.begin();
insilmaril@327
  2194
		while( it != flist.end() ) 
insilmaril@327
  2195
		{
insilmaril@327
  2196
			im.setFile (*it);
insilmaril@327
  2197
			if (im.transform() && 
insilmaril@571
  2198
				success==fileLoad (im.getTransformedFile(),NewMap,FreemindMap) && 
insilmaril@327
  2199
				currentMapEditor() )
insilmaril@327
  2200
				currentMapEditor()->setFilePath ("");
insilmaril@327
  2201
			++it;
insilmaril@327
  2202
		}
insilmaril@327
  2203
	}
insilmaril@327
  2204
	delete (fd);
insilmaril@314
  2205
}
insilmaril@314
  2206
insilmaril@571
  2207
void Main::fileImportFreemind()
insilmaril@571
  2208
{
insilmaril@571
  2209
	QStringList filters;
insilmaril@571
  2210
	filters <<"Freemind map (*.mm)"<<"All files (*)";
insilmaril@571
  2211
	QFileDialog *fd=new QFileDialog( this);
insilmaril@571
  2212
	fd->setDir (lastFileDir);
insilmaril@571
  2213
	fd->setFileMode (QFileDialog::ExistingFiles);
insilmaril@571
  2214
	fd->setFilters (filters);
insilmaril@571
  2215
	fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
insilmaril@571
  2216
	fd->show();
insilmaril@571
  2217
insilmaril@571
  2218
	QString fn;
insilmaril@571
  2219
	if ( fd->exec() == QDialog::Accepted )
insilmaril@571
  2220
	{
insilmaril@571
  2221
		lastFileDir=fd->directory().path();
insilmaril@571
  2222
	    QStringList flist = fd->selectedFiles();
insilmaril@571
  2223
		QStringList::Iterator it = flist.begin();
insilmaril@571
  2224
		while( it != flist.end() ) 
insilmaril@571
  2225
		{
insilmaril@571
  2226
			fn = *it;
insilmaril@571
  2227
			if ( fileLoad (fn,NewMap, FreemindMap)  )
insilmaril@571
  2228
			{	
insilmaril@571
  2229
				currentMapEditor()->setFilePath ("");
insilmaril@571
  2230
			}	
insilmaril@571
  2231
			++it;
insilmaril@571
  2232
		}
insilmaril@571
  2233
	}
insilmaril@571
  2234
	delete (fd);
insilmaril@571
  2235
}
insilmaril@571
  2236
insilmaril@571
  2237
insilmaril@215
  2238
void Main::fileImportMM()
insilmaril@215
  2239
{
insilmaril@215
  2240
	ImportMM im;
insilmaril@215
  2241
insilmaril@366
  2242
	Q3FileDialog *fd=new Q3FileDialog( this);
insilmaril@366
  2243
	fd->setDir (lastFileDir);
insilmaril@366
  2244
	fd->setMode (Q3FileDialog::ExistingFiles);
insilmaril@215
  2245
	fd->addFilter ("Mind Manager (*.mmap)");
insilmaril@215
  2246
	fd->setCaption(tr("Import")+" "+"Mind Manager");
insilmaril@215
  2247
	fd->show();
insilmaril@215
  2248
insilmaril@215
  2249
	if ( fd->exec() == QDialog::Accepted )
insilmaril@215
  2250
	{
insilmaril@215
  2251
		lastFileDir=fd->dirPath();
insilmaril@215
  2252
	    QStringList flist = fd->selectedFiles();
insilmaril@215
  2253
		QStringList::Iterator it = flist.begin();
insilmaril@215
  2254
		while( it != flist.end() ) 
insilmaril@215
  2255
		{
insilmaril@215
  2256
			im.setFile (*it);
insilmaril@215
  2257
			if (im.transform() && 
insilmaril@215
  2258
				success==fileLoad (im.getTransformedFile(),NewMap) && 
insilmaril@215
  2259
				currentMapEditor() )
insilmaril@215
  2260
				currentMapEditor()->setFilePath ("");
insilmaril@215
  2261
insilmaril@215
  2262
			++it;
insilmaril@215
  2263
		}
insilmaril@215
  2264
	}
insilmaril@215
  2265
	delete (fd);
insilmaril@215
  2266
insilmaril@215
  2267
}
insilmaril@215
  2268
insilmaril@215
  2269
void Main::fileImportDir()
insilmaril@215
  2270
{
insilmaril@215
  2271
	if (currentMapEditor())
insilmaril@215
  2272
		currentMapEditor()->importDir();	
insilmaril@215
  2273
}
insilmaril@215
  2274
insilmaril@526
  2275
void Main::fileExportXML()	
insilmaril@0
  2276
{
insilmaril@526
  2277
	MapEditor *me=currentMapEditor();
insilmaril@526
  2278
	if (me) me->exportXML();
insilmaril@0
  2279
}
insilmaril@0
  2280
insilmaril@0
  2281
insilmaril@517
  2282
void Main::fileExportXHTML()	
insilmaril@0
  2283
{
insilmaril@260
  2284
	MapEditor *me=currentMapEditor();
insilmaril@517
  2285
	if (me) me->exportXHTML();
insilmaril@0
  2286
}
insilmaril@0
  2287
insilmaril@517
  2288
void Main::fileExportImage()	
insilmaril@0
  2289
{
insilmaril@260
  2290
	MapEditor *me=currentMapEditor();
insilmaril@514
  2291
	if (me) me->exportImage();
insilmaril@0
  2292
}
insilmaril@0
  2293
insilmaril@0
  2294
void Main::fileExportASCII()
insilmaril@0
  2295
{
insilmaril@260
  2296
	MapEditor *me=currentMapEditor();
insilmaril@514
  2297
	if (me) me->exportASCII();
insilmaril@0
  2298
}
insilmaril@0
  2299
insilmaril@517
  2300
void Main::fileExportCSV()	//FIXME not scriptable yet
insilmaril@497
  2301
{
insilmaril@497
  2302
	MapEditor *me=currentMapEditor();
insilmaril@497
  2303
	if (me)
insilmaril@497
  2304
	{
insilmaril@497
  2305
		ExportCSV ex;
insilmaril@497
  2306
		ex.setMapCenter(me->getMapCenter());
insilmaril@497
  2307
		ex.addFilter ("CSV (*.csv)");
insilmaril@497
  2308
		ex.setDir(lastImageDir);
insilmaril@497
  2309
		ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
insilmaril@497
  2310
		if (ex.execDialog() ) 
insilmaril@497
  2311
		{
insilmaril@497
  2312
			me->setExportMode(true);
insilmaril@497
  2313
			ex.doExport();
insilmaril@497
  2314
			me->setExportMode(false);
insilmaril@497
  2315
		}
insilmaril@497
  2316
	}
insilmaril@497
  2317
}
insilmaril@497
  2318
insilmaril@517
  2319
void Main::fileExportLaTeX()	//FIXME not scriptable yet
insilmaril@163
  2320
{
insilmaril@260
  2321
	MapEditor *me=currentMapEditor();
insilmaril@260
  2322
	if (me)
insilmaril@228
  2323
	{
insilmaril@228
  2324
		ExportLaTeX ex;
insilmaril@260
  2325
		ex.setMapCenter(me->getMapCenter());
insilmaril@228
  2326
		ex.addFilter ("Tex (*.tex)");
insilmaril@424
  2327
		ex.setDir(lastImageDir);
insilmaril@404
  2328
		ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
insilmaril@260
  2329
		if (ex.execDialog() ) 
insilmaril@260
  2330
		{
insilmaril@260
  2331
			me->setExportMode(true);
insilmaril@260
  2332
			ex.doExport();
insilmaril@260
  2333
			me->setExportMode(false);
insilmaril@260
  2334
		}
insilmaril@228
  2335
	}
insilmaril@228
  2336
}
insilmaril@228
  2337
insilmaril@517
  2338
void Main::fileExportKDEBookmarks()	//FIXME not scriptable yet
insilmaril@243
  2339
{
insilmaril@243
  2340
	ExportKDEBookmarks ex;
insilmaril@260
  2341
	MapEditor *me=currentMapEditor();
insilmaril@260
  2342
	if (me)
insilmaril@243
  2343
	{
insilmaril@260
  2344
		ex.setMapCenter (me->getMapCenter() );
insilmaril@243
  2345
		ex.doExport();
insilmaril@243
  2346
	}	
insilmaril@243
  2347
}
insilmaril@243
  2348
insilmaril@517
  2349
void Main::fileExportTaskjuggler()	//FIXME not scriptable yet
insilmaril@228
  2350
{
insilmaril@228
  2351
	ExportTaskjuggler ex;
insilmaril@260
  2352
	MapEditor *me=currentMapEditor();
insilmaril@260
  2353
	if (me)
insilmaril@228
  2354
	{
insilmaril@260
  2355
		ex.setMapCenter (me->getMapCenter() );
insilmaril@404
  2356
		ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
insilmaril@424
  2357
		ex.setDir(lastImageDir);
insilmaril@243
  2358
		ex.addFilter ("Taskjuggler (*.tjp)");
insilmaril@260
  2359
		if (ex.execDialog() ) 
insilmaril@260
  2360
		{
insilmaril@260
  2361
			me->setExportMode(true);
insilmaril@260
  2362
			ex.doExport();
insilmaril@260
  2363
			me->setExportMode(false);
insilmaril@260
  2364
		}
insilmaril@228
  2365
	}	
insilmaril@163
  2366
}
insilmaril@163
  2367
insilmaril@517
  2368
void Main::fileExportOOPresentation()	//FIXME not scriptable yet
insilmaril@163
  2369
{
insilmaril@404
  2370
	ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
insilmaril@366
  2371
	// TODO add preview in dialog
insilmaril@185
  2372
	//ImagePreview *p =new ImagePreview (fd);
insilmaril@185
  2373
	//fd->setContentsPreviewEnabled( TRUE );
insilmaril@185
  2374
	//fd->setContentsPreview( p, p );
insilmaril@185
  2375
	//fd->setPreviewMode( QFileDialog::Contents );
insilmaril@404
  2376
	fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
insilmaril@366
  2377
	fd->setDir (QDir().current());
insilmaril@357
  2378
	if (fd->foundConfig())
insilmaril@357
  2379
	{
insilmaril@357
  2380
		fd->show();
insilmaril@185
  2381
insilmaril@357
  2382
		if ( fd->exec() == QDialog::Accepted )
insilmaril@357
  2383
		{
insilmaril@357
  2384
			QString fn=fd->selectedFile();
insilmaril@366
  2385
			if (!fn.contains (".odp"))
insilmaril@366
  2386
				fn +=".odp";
insilmaril@366
  2387
insilmaril@357
  2388
			//lastImageDir=fn.left(fn.findRev ("/"));
insilmaril@357
  2389
			if (currentMapEditor())
insilmaril@357
  2390
				currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());	
insilmaril@357
  2391
		}
insilmaril@357
  2392
	} else
insilmaril@185
  2393
	{
insilmaril@357
  2394
		QMessageBox::warning(0, 
insilmaril@366
  2395
		tr("Warning"),
insilmaril@366
  2396
		tr("Couldn't find configuration for export to Open Office\n"));
insilmaril@185
  2397
	}
insilmaril@163
  2398
}
insilmaril@163
  2399
insilmaril@0
  2400
void Main::fileCloseMap()
insilmaril@0
  2401
{
insilmaril@0
  2402
	if (currentMapEditor())
insilmaril@0
  2403
	{
insilmaril@0
  2404
		if (currentMapEditor()->hasChanged())
insilmaril@0
  2405
		{
insilmaril@404
  2406
			QMessageBox mb( vymName,
insilmaril@159
  2407
				tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
insilmaril@0
  2408
				QMessageBox::Warning,
insilmaril@0
  2409
				QMessageBox::Yes | QMessageBox::Default,
insilmaril@0
  2410
				QMessageBox::No,
insilmaril@0
  2411
				QMessageBox::Cancel | QMessageBox::Escape );
insilmaril@0
  2412
			mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
insilmaril@0
  2413
			mb.setButtonText( QMessageBox::No, tr("Discard changes"));
insilmaril@0
  2414
			switch( mb.exec() ) 
insilmaril@0
  2415
			{
insilmaril@0
  2416
				case QMessageBox::Yes:
insilmaril@0
  2417
					// save and close
insilmaril@473
  2418
					fileSave(currentMapEditor(), CompleteMap);
insilmaril@0
  2419
					break;
insilmaril@0
  2420
				case QMessageBox::No:
insilmaril@0
  2421
				// close  without saving
insilmaril@0
  2422
					break;
insilmaril@0
  2423
				case QMessageBox::Cancel:
insilmaril@0
  2424
					// do nothing
insilmaril@0
  2425
				return;
insilmaril@0
  2426
			}
insilmaril@0
  2427
		} 
insilmaril@0
  2428
		currentMapEditor()->closeMap();
insilmaril@0
  2429
		tabWidget->removePage(currentMapEditor());
insilmaril@0
  2430
		if (tabWidget->count()==0)
insilmaril@0
  2431
			actionFilePrint->setEnabled (false);
insilmaril@0
  2432
	}	
insilmaril@0
  2433
}
insilmaril@0
  2434
insilmaril@0
  2435
void Main::filePrint()
insilmaril@0
  2436
{
insilmaril@0
  2437
	if (currentMapEditor())
insilmaril@0
  2438
		currentMapEditor()->print();
insilmaril@0
  2439
}
insilmaril@0
  2440
insilmaril@0
  2441
void Main::fileExitVYM()
insilmaril@0
  2442
{
insilmaril@0
  2443
	// Check if one or more editors have changed
insilmaril@0
  2444
	MapEditor *me;
insilmaril@0
  2445
	int i;
insilmaril@0
  2446
	for (i=0;i<=tabWidget->count() -1;i++)
insilmaril@0
  2447
	{
insilmaril@0
  2448
		
insilmaril@0
  2449
		me=(MapEditor*)tabWidget->page(i);
insilmaril@0
  2450
insilmaril@0
  2451
		// If something changed, ask what to do
insilmaril@486
  2452
		if (me->hasChanged())
insilmaril@0
  2453
		{
insilmaril@0
  2454
			tabWidget->setCurrentPage(i);
insilmaril@404
  2455
			QMessageBox mb( vymName,
insilmaril@0
  2456
				tr("This map is not saved yet. Do you want to"),
insilmaril@0
  2457
				QMessageBox::Warning,
insilmaril@0
  2458
				QMessageBox::Yes | QMessageBox::Default,
insilmaril@0
  2459
				QMessageBox::No,
insilmaril@0
  2460
				QMessageBox::Cancel | QMessageBox::Escape );
insilmaril@0
  2461
			mb.setButtonText( QMessageBox::Yes, tr("Save map") );
insilmaril@0
  2462
			mb.setButtonText( QMessageBox::No, tr("Discard changes") );
insilmaril@366
  2463
			mb.setModal (true);
insilmaril@0
  2464
			mb.show();
insilmaril@0
  2465
			mb.setActiveWindow();
insilmaril@0
  2466
			switch( mb.exec() ) {
insilmaril@0
  2467
				case QMessageBox::Yes:
insilmaril@0
  2468
					// save (the changed editors) and exit
insilmaril@473
  2469
					fileSave(currentMapEditor(), CompleteMap);
insilmaril@0
  2470
					break;
insilmaril@0
  2471
				case QMessageBox::No:
insilmaril@0
  2472
					// exit without saving
insilmaril@0
  2473
					break;
insilmaril@0
  2474
				case QMessageBox::Cancel:
insilmaril@0
  2475
					// don't save and don't exit
insilmaril@0
  2476
				return;
insilmaril@0
  2477
			}
insilmaril@0
  2478
		}
insilmaril@0
  2479
	} // loop over all MEs	
insilmaril@0
  2480
    qApp->quit();
insilmaril@0
  2481
}
insilmaril@0
  2482
insilmaril@0
  2483
void Main::editUndo()
insilmaril@0
  2484
{
insilmaril@0
  2485
	if (currentMapEditor())
insilmaril@0
  2486
		currentMapEditor()->undo();
insilmaril@0
  2487
}
insilmaril@0
  2488
insilmaril@163
  2489
void Main::editRedo()	   
insilmaril@0
  2490
{
insilmaril@163
  2491
	if (currentMapEditor())
insilmaril@163
  2492
		currentMapEditor()->redo();
insilmaril@0
  2493
}
insilmaril@0
  2494
insilmaril@404
  2495
void Main::gotoHistoryStep (int i)	   
insilmaril@404
  2496
{
insilmaril@404
  2497
	if (currentMapEditor())
insilmaril@404
  2498
		currentMapEditor()->gotoHistoryStep (i);
insilmaril@404
  2499
}
insilmaril@404
  2500
insilmaril@0
  2501
void Main::editCopy()
insilmaril@0
  2502
{
insilmaril@0
  2503
	if (currentMapEditor())
insilmaril@0
  2504
		currentMapEditor()->copy();
insilmaril@0
  2505
}
insilmaril@0
  2506
insilmaril@0
  2507
void Main::editPaste()
insilmaril@0
  2508
{
insilmaril@0
  2509
	if (currentMapEditor())
insilmaril@0
  2510
		currentMapEditor()->paste();
insilmaril@0
  2511
}
insilmaril@0
  2512
insilmaril@0
  2513
void Main::editCut()
insilmaril@0
  2514
{
insilmaril@0
  2515
	if (currentMapEditor())
insilmaril@0
  2516
		currentMapEditor()->cut();
insilmaril@0
  2517
}
insilmaril@0
  2518
insilmaril@0
  2519
void Main::editOpenFindWindow()
insilmaril@0
  2520
{
insilmaril@0
  2521
	findWindow->popup();
insilmaril@0
  2522
	findWindow->raise();
insilmaril@0
  2523
	findWindow->setActiveWindow();
insilmaril@0
  2524
}
insilmaril@0
  2525
insilmaril@0
  2526
void Main::editFind(QString s)
insilmaril@0
  2527
{
insilmaril@0
  2528
	bool cs=false;
insilmaril@0
  2529
	BranchObj *bo=currentMapEditor()->findText(s, cs);
insilmaril@0
  2530
	if (bo)
insilmaril@0
  2531
	{	
insilmaril@0
  2532
		statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
insilmaril@0
  2533
	} else
insilmaril@0
  2534
	{
insilmaril@0
  2535
		QMessageBox::information( findWindow, tr( "VYM -Information:" ),
insilmaril@349
  2536
							   tr("No matches found for \"%1\"").arg(s));
insilmaril@0
  2537
	}	
insilmaril@0
  2538
}
insilmaril@0
  2539
insilmaril@0
  2540
void Main::editFindChanged()
insilmaril@0
  2541
{	// Notify editor, to abort the current find process
insilmaril@0
  2542
	currentMapEditor()->findReset();
insilmaril@0
  2543
}
insilmaril@0
  2544
insilmaril@366
  2545
void Main::openTabs(QStringList urls)
insilmaril@366
  2546
{
insilmaril@366
  2547
	if (!urls.isEmpty())
insilmaril@366
  2548
	{	
insilmaril@366
  2549
		bool success=true;
insilmaril@366
  2550
		QStringList args;
insilmaril@366
  2551
		QString browser=settings.value("/mainwindow/readerURL" ).toString();
insilmaril@366
  2552
		QProcess *p;
insilmaril@366
  2553
		if (!procBrowser ||  procBrowser->state()!=QProcess::Running)
insilmaril@366
  2554
		{
insilmaril@366
  2555
			QString u=urls.takeFirst();
insilmaril@366
  2556
			procBrowser = new QProcess( this );
insilmaril@366
  2557
			args<<u;
insilmaril@366
  2558
			procBrowser->start(browser,args);
insilmaril@366
  2559
			if ( !procBrowser->waitForStarted())
insilmaril@366
  2560
			{
insilmaril@366
  2561
				// try to set path to browser
insilmaril@366
  2562
				QMessageBox::warning(0, 
insilmaril@366
  2563
					tr("Warning"),
insilmaril@366
  2564
					tr("Couldn't find a viewer to open %1.\n").arg(u)+
insilmaril@366
  2565
					tr("Please use Settings->")+tr("Set application to open an URL"));
insilmaril@366
  2566
				return;
insilmaril@366
  2567
			}
insilmaril@608
  2568
#if defined(Q_OS_WIN32)
insilmaril@608
  2569
            // There's no sleep in VCEE, replace it with Qt's QThread::wait().
insilmaril@608
  2570
            this->thread()->wait(3000);
insilmaril@608
  2571
#else
insilmaril@366
  2572
			sleep (3);
insilmaril@608
  2573
#endif
insilmaril@366
  2574
		}
insilmaril@366
  2575
		if (browser.contains("konqueror"))
insilmaril@366
  2576
		{
insilmaril@366
  2577
			for (int i=0; i<urls.size(); i++)
insilmaril@366
  2578
			{
insilmaril@366
  2579
				// Open new browser
insilmaril@366
  2580
				// Try to open new tab in existing konqueror started previously by vym
insilmaril@366
  2581
				p=new QProcess (this);
insilmaril@366
  2582
				args.clear();
insilmaril@608
  2583
#if defined(Q_OS_WIN32)
insilmaril@608
  2584
                // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
insilmaril@608
  2585
                // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
insilmaril@608
  2586
				args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
insilmaril@608
  2587
					"konqueror-mainwindow#1"<<
insilmaril@608
  2588
					"newTab" <<
insilmaril@366
  2589
					urls.at(i);
insilmaril@608
  2590
#else
insilmaril@608
  2591
				args<< QString("konqueror-%1").arg(procBrowser->pid())<<
insilmaril@608
  2592
					"konqueror-mainwindow#1"<<
insilmaril@608
  2593
					"newTab" <<
insilmaril@608
  2594
					urls.at(i);
insilmaril@608
  2595
#endif
insilmaril@366
  2596
				p->start ("dcop",args);
insilmaril@608
  2597
				cout << args.join(" ").ascii()<<endl;
insilmaril@366
  2598
				if ( !p->waitForStarted() ) success=false;
insilmaril@366
  2599
			}
insilmaril@366
  2600
			if (!success)
insilmaril@366
  2601
				QMessageBox::warning(0, 
insilmaril@366
  2602
					tr("Warning"),
insilmaril@366
  2603
					tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
insilmaril@366
  2604
			return;		
insilmaril@366
  2605
		} else if (browser.contains ("firefox") || browser.contains ("mozilla") )
insilmaril@366
  2606
		{
insilmaril@366
  2607
			for (int i=0; i<urls.size(); i++)
insilmaril@366
  2608
			{
insilmaril@366
  2609
				// Try to open new tab in firefox
insilmaril@366
  2610
				p=new QProcess (this);
insilmaril@366
  2611
				args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
insilmaril@366
  2612
				p->start (browser,args);
insilmaril@366
  2613
				if ( !p->waitForStarted() ) success=false;
insilmaril@366
  2614
			}			
insilmaril@366
  2615
			if (!success)
insilmaril@366
  2616
				QMessageBox::warning(0, 
insilmaril@366
  2617
					tr("Warning"),
insilmaril@366
  2618
					tr("Couldn't start %1 to open a new tab").arg(browser));
insilmaril@366
  2619
			return;		
insilmaril@366
  2620
		}			
insilmaril@366
  2621
		QMessageBox::warning(0, 
insilmaril@366
  2622
			tr("Warning"),
insilmaril@366
  2623
			tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
insilmaril@366
  2624
	}	
insilmaril@366
  2625
}
insilmaril@366
  2626
insilmaril@0
  2627
void Main::editOpenURL()
insilmaril@0
  2628
{
insilmaril@266
  2629
	// Open new browser
insilmaril@0
  2630
	if (currentMapEditor())
insilmaril@266
  2631
	{	
insilmaril@266
  2632
	    QString url=currentMapEditor()->getURL();
insilmaril@366
  2633
		QStringList args;
insilmaril@266
  2634
		if (url=="") return;
insilmaril@366
  2635
		QString browser=settings.value("/mainwindow/readerURL" ).toString();
insilmaril@266
  2636
		procBrowser = new QProcess( this );
insilmaril@366
  2637
		args<<url;
insilmaril@366
  2638
		procBrowser->start(browser,args);
insilmaril@366
  2639
		if ( !procBrowser->waitForStarted())
insilmaril@266
  2640
		{
insilmaril@266
  2641
			// try to set path to browser
insilmaril@266
  2642
			QMessageBox::warning(0, 
insilmaril@266
  2643
				tr("Warning"),
insilmaril@266
  2644
				tr("Couldn't find a viewer to open %1.\n").arg(url)+
insilmaril@266
  2645
				tr("Please use Settings->")+tr("Set application to open an URL"));
insilmaril@266
  2646
			settingsURL() ; 
insilmaril@266
  2647
		}	
insilmaril@266
  2648
	}	
insilmaril@266
  2649
}
insilmaril@266
  2650
void Main::editOpenURLTab()
insilmaril@266
  2651
{
insilmaril@266
  2652
	if (currentMapEditor())
insilmaril@266
  2653
	{	
insilmaril@366
  2654
	    QStringList urls;
insilmaril@366
  2655
		urls.append(currentMapEditor()->getURL());
insilmaril@366
  2656
		openTabs (urls);
insilmaril@266
  2657
	}	
insilmaril@0
  2658
}
insilmaril@366
  2659
void Main::editOpenMultipleURLTabs()
insilmaril@366
  2660
{
insilmaril@366
  2661
	if (currentMapEditor())
insilmaril@366
  2662
	{	
insilmaril@366
  2663
	    QStringList urls;
insilmaril@366
  2664
		urls=currentMapEditor()->getURLs();
insilmaril@366
  2665
		openTabs (urls);
insilmaril@366
  2666
	}	
insilmaril@366
  2667
}
insilmaril@366
  2668
insilmaril@0
  2669
insilmaril@0
  2670
void Main::editURL()
insilmaril@0
  2671
{
insilmaril@0
  2672
	if (currentMapEditor())
insilmaril@0
  2673
	    currentMapEditor()->editURL();
insilmaril@0
  2674
}
insilmaril@0
  2675
insilmaril@528
  2676
void Main::editLocalURL()
insilmaril@528
  2677
{
insilmaril@528
  2678
	if (currentMapEditor())
insilmaril@528
  2679
	    currentMapEditor()->editLocalURL();
insilmaril@528
  2680
}
insilmaril@528
  2681
insilmaril@0
  2682
void Main::editHeading2URL()
insilmaril@0
  2683
{
insilmaril@0
  2684
	if (currentMapEditor())
insilmaril@0
  2685
	    currentMapEditor()->editHeading2URL();
insilmaril@0
  2686
}
insilmaril@0
  2687
insilmaril@0
  2688
void Main::editBugzilla2URL()
insilmaril@0
  2689
{
insilmaril@0
  2690
	if (currentMapEditor())
insilmaril@0
  2691
	    currentMapEditor()->editBugzilla2URL();
insilmaril@0
  2692
}
insilmaril@0
  2693
insilmaril@175
  2694
void Main::editFATE2URL()
insilmaril@175
  2695
{
insilmaril@175
  2696
	if (currentMapEditor())
insilmaril@175
  2697
	    currentMapEditor()->editFATE2URL();
insilmaril@175
  2698
}
insilmaril@175
  2699
insilmaril@394
  2700
void Main::editHeadingFinished()
insilmaril@394
  2701
{
insilmaril@394
  2702
	// only called from editHeading(), so there is a currentME
insilmaril@394
  2703
	MapEditor *me=currentMapEditor();
insilmaril@421
  2704
	if (me)
insilmaril@421
  2705
	{
insilmaril@491
  2706
		me->setStateEditHeading (false);
insilmaril@421
  2707
		QPoint p;	//Not used here, only to find out pos of branch
insilmaril@421
  2708
		bool ok;
insilmaril@421
  2709
		QString s=me->getHeading(ok,p);
insilmaril@394
  2710
insilmaril@394
  2711
#if defined(Q_OS_MACX)
insilmaril@394
  2712
#else
insilmaril@421
  2713
		if (ok && s!=lineedit->text())
insilmaril@421
  2714
			me->setHeading(lineedit->text());
insilmaril@421
  2715
			
insilmaril@421
  2716
		lineedit->releaseKeyboard();
insilmaril@421
  2717
		lineedit->hide();
insilmaril@421
  2718
		setFocus();
insilmaril@394
  2719
#endif	
insilmaril@537
  2720
		if (!actionSettingsAutoSelectNewBranch->isOn() && 
insilmaril@537
  2721
			!prevSelection.isEmpty()) 
insilmaril@537
  2722
			me->select(prevSelection);
insilmaril@421
  2723
		prevSelection="";
insilmaril@421
  2724
	}
insilmaril@394
  2725
}
insilmaril@394
  2726
insilmaril@366
  2727
void Main::editHeading()
insilmaril@0
  2728
{
insilmaril@394
  2729
	if (currentMapEditor())
insilmaril@0
  2730
	{
insilmaril@394
  2731
		MapEditor *me=currentMapEditor();
insilmaril@394
  2732
		QString oldSel=me->getSelectString();
insilmaril@394
  2733
insilmaril@394
  2734
		if (lineedit->isVisible())
insilmaril@394
  2735
			editHeadingFinished();
insilmaril@394
  2736
		else
insilmaril@366
  2737
		{
insilmaril@366
  2738
			bool ok;
insilmaril@366
  2739
			QPoint p;
insilmaril@531
  2740
			QString s=me->getHeading(ok,p);
insilmaril@366
  2741
insilmaril@366
  2742
			if (ok)
insilmaril@366
  2743
			{
insilmaril@491
  2744
				me->setStateEditHeading (true);
insilmaril@366
  2745
#if defined(Q_OS_MACX)
insilmaril@531
  2746
				p=me->mapToGlobal (p);
insilmaril@366
  2747
				QDialog *d =new QDialog(NULL);
insilmaril@366
  2748
				QLineEdit *le=new QLineEdit (d);
insilmaril@366
  2749
				d->setWindowFlags (Qt::FramelessWindowHint);
insilmaril@394
  2750
				d->setGeometry(p.x(),p.y(),230,25);
insilmaril@394
  2751
				le->resize (d->width()-10,d->height());
insilmaril@366
  2752
				le->setText (s);
insilmaril@366
  2753
				le->selectAll();
insilmaril@366
  2754
				connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
insilmaril@366
  2755
				d->activateWindow();
insilmaril@366
  2756
				d->exec();
insilmaril@531
  2757
				me->setHeading (le->text());
insilmaril@394
  2758
				delete (le);
insilmaril@394
  2759
				delete (d);
insilmaril@394
  2760
				editHeadingFinished();
insilmaril@366
  2761
#else
insilmaril@531
  2762
				p=me->mapTo (this,p);
insilmaril@394
  2763
				lineedit->setGeometry(p.x(),p.y(),230,25);
insilmaril@366
  2764
				lineedit->setText(s);
insilmaril@366
  2765
				lineedit->setCursorPosition(1);
insilmaril@366
  2766
				lineedit->selectAll();
insilmaril@366
  2767
				lineedit->show();
insilmaril@366
  2768
				lineedit->grabKeyboard();
insilmaril@366
  2769
				lineedit->setFocus();
insilmaril@366
  2770
#endif
insilmaril@366
  2771
			}
insilmaril@366
  2772
		}
insilmaril@394
  2773
	} // currentMapEditor()	
insilmaril@366
  2774
}
insilmaril@366
  2775
insilmaril@366
  2776
void Main::openVymLinks(const QStringList &vl)
insilmaril@366
  2777
{
insilmaril@366
  2778
	for (int j=0; j<vl.size(); j++)
insilmaril@366
  2779
	{
insilmaril@0
  2780
		// compare path with already loaded maps
insilmaril@0
  2781
		int index=-1;
insilmaril@0
  2782
		int i;
insilmaril@0
  2783
		MapEditor *me;
insilmaril@0
  2784
		for (i=0;i<=tabWidget->count() -1;i++)
insilmaril@0
  2785
		{
insilmaril@0
  2786
			me=(MapEditor*)tabWidget->page(i);
insilmaril@366
  2787
			if (vl.at(j)==me->getFilePath() )
insilmaril@0
  2788
			{
insilmaril@0
  2789
				index=i;
insilmaril@0
  2790
				break;
insilmaril@0
  2791
			}
insilmaril@0
  2792
		}	
insilmaril@0
  2793
		if (index<0)
insilmaril@0
  2794
		// Load map
insilmaril@0
  2795
		{
insilmaril@366
  2796
			if (!QFile(vl.at(j)).exists() )
insilmaril@0
  2797
				QMessageBox::critical( 0, tr( "Critical Error" ),
insilmaril@366
  2798
				   tr("Couldn't open map %1").arg(vl.at(j)));
insilmaril@0
  2799
			else
insilmaril@0
  2800
			{
insilmaril@366
  2801
				fileLoad (vl.at(j), NewMap);
insilmaril@0
  2802
				tabWidget->setCurrentPage (tabWidget->count()-1);	
insilmaril@0
  2803
			}
insilmaril@0
  2804
		} else
insilmaril@0
  2805
			// Go to tab containing the map
insilmaril@0
  2806
			tabWidget->setCurrentPage (index);	
insilmaril@0
  2807
	}
insilmaril@0
  2808
}
insilmaril@0
  2809
insilmaril@366
  2810
void Main::editOpenVymLink()
insilmaril@366
  2811
{
insilmaril@366
  2812
	if (currentMapEditor())
insilmaril@366
  2813
	{
insilmaril@366
  2814
		QStringList vl;
insilmaril@366
  2815
		vl.append(currentMapEditor()->getVymLink());	
insilmaril@366
  2816
		openVymLinks (vl);
insilmaril@366
  2817
	}
insilmaril@366
  2818
}
insilmaril@366
  2819
insilmaril@366
  2820
void Main::editOpenMultipleVymLinks()
insilmaril@366
  2821
{
insilmaril@366
  2822
	QString currentVymLink;
insilmaril@366
  2823
	if (currentMapEditor())
insilmaril@366
  2824
	{
insilmaril@366
  2825
		QStringList vl=currentMapEditor()->getVymLinks();
insilmaril@366
  2826
		openVymLinks (vl);
insilmaril@366
  2827
	}
insilmaril@366
  2828
}
insilmaril@366
  2829
insilmaril@0
  2830
void Main::editVymLink()
insilmaril@0
  2831
{
insilmaril@0
  2832
	if (currentMapEditor())
insilmaril@0
  2833
		currentMapEditor()->editVymLink();	
insilmaril@0
  2834
}
insilmaril@0
  2835
insilmaril@0
  2836
void Main::editDeleteVymLink()
insilmaril@0
  2837
{