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