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