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