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