mainwindow.cpp
author insilmaril
Thu, 02 Apr 2009 09:57:36 +0000
branchrelease-1-12-maintained
changeset 64 4f305c07dd7c
parent 62 85683324f94a
child 76 a36a289372a6
permissions -rw-r--r--
Added sverige translation
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;