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