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