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