mainwindow.cpp
author insilmaril
Thu, 14 May 2009 12:42:58 +0000
changeset 768 382a444f5b0c
parent 767 6d2b32f305f9
child 769 a6931cd6309a
permissions -rw-r--r--
flag of NoteEditor works again
insilmaril@0
     1
#include "mainwindow.h"
insilmaril@0
     2
insilmaril@748
     3
#include <QtDBus/QtDBus>
insilmaril@366
     4
#include <QtGui>
insilmaril@390
     5
insilmaril@0
     6
#include <iostream>
insilmaril@611
     7
#include <typeinfo>
insilmaril@0
     8
insilmaril@205
     9
#include "aboutdialog.h"
insilmaril@421
    10
#include "branchpropwindow.h"
insilmaril@749
    11
#include "branchitem.h"
insilmaril@205
    12
#include "exportoofiledialog.h"
insilmaril@228
    13
#include "exports.h"
insilmaril@205
    14
#include "file.h"
insilmaril@767
    15
#include "flagrow.h"
insilmaril@377
    16
#include "historywindow.h"
insilmaril@205
    17
#include "imports.h"
insilmaril@0
    18
#include "mapeditor.h"
insilmaril@205
    19
#include "misc.h"
insilmaril@205
    20
#include "options.h"
insilmaril@0
    21
#include "process.h"
insilmaril@0
    22
#include "settings.h"
insilmaril@205
    23
#include "texteditor.h"
insilmaril@442
    24
#include "warningdialog.h"
insilmaril@0
    25
insilmaril@608
    26
#if defined(Q_OS_WIN32)
insilmaril@608
    27
// Define only this structure as opposed to
insilmaril@608
    28
// including full 'windows.h'. FindWindow
insilmaril@608
    29
// clashes with the one in Win32 API.
insilmaril@608
    30
typedef struct _PROCESS_INFORMATION
insilmaril@608
    31
{
insilmaril@608
    32
  long hProcess;
insilmaril@608
    33
  long hThread;
insilmaril@608
    34
  long dwProcessId;
insilmaril@608
    35
  long dwThreadId;
insilmaril@608
    36
} PROCESS_INFORMATION, *LPPROCESS_INFORMATION;
insilmaril@608
    37
#endif
insilmaril@608
    38
insilmaril@0
    39
extern TextEditor *textEditor;
insilmaril@0
    40
extern Main *mainWindow;
insilmaril@164
    41
extern QString tmpVymDir;
insilmaril@166
    42
extern QString clipboardDir;
insilmaril@491
    43
extern QString clipboardFile;
insilmaril@166
    44
extern bool clipboardEmpty;
insilmaril@0
    45
extern int statusbarTime;
insilmaril@767
    46
extern FlagRow *standardFlagsMaster;	
insilmaril@767
    47
extern FlagRow *systemFlagsMaster;
insilmaril@404
    48
extern QString vymName;
insilmaril@404
    49
extern QString vymVersion;
insilmaril@404
    50
extern QString vymBuildDate;
insilmaril@502
    51
extern bool debug;
insilmaril@0
    52
insilmaril@390
    53
QMenu* branchContextMenu;
insilmaril@390
    54
QMenu* branchAddContextMenu;
insilmaril@390
    55
QMenu* branchRemoveContextMenu;
insilmaril@390
    56
QMenu* branchLinksContextMenu;
insilmaril@390
    57
QMenu* branchXLinksContextMenuEdit;
insilmaril@390
    58
QMenu* branchXLinksContextMenuFollow;
insilmaril@390
    59
QMenu* floatimageContextMenu;
insilmaril@390
    60
QMenu* canvasContextMenu;
insilmaril@390
    61
QMenu* fileLastMapsMenu;
insilmaril@390
    62
QMenu* fileImportMenu;
insilmaril@390
    63
QMenu* fileExportMenu;
insilmaril@0
    64
insilmaril@0
    65
insilmaril@0
    66
extern Settings settings;
insilmaril@0
    67
extern Options options;
insilmaril@366
    68
extern ImageIO imageIO;
insilmaril@366
    69
insilmaril@269
    70
extern QDir vymBaseDir;
insilmaril@366
    71
extern QDir lastImageDir;
insilmaril@366
    72
extern QDir lastFileDir;
insilmaril@625
    73
#if defined(Q_OS_WIN32)
insilmaril@625
    74
extern QDir vymInstallDir;
insilmaril@625
    75
#endif
insilmaril@269
    76
extern QString iconPath;
insilmaril@269
    77
extern QString flagsPath;
insilmaril@0
    78
insilmaril@725
    79
insilmaril@366
    80
Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
insilmaril@0
    81
    QMainWindow(parent,name,f)
insilmaril@0
    82
{
insilmaril@0
    83
	mainWindow=this;
insilmaril@0
    84
insilmaril@0
    85
	setCaption ("VYM - View Your Mind");
insilmaril@0
    86
insilmaril@0
    87
	// Load window settings
insilmaril@625
    88
#if defined(Q_OS_WIN32)
insilmaril@625
    89
    if (settings.value("/mainwindow/geometry/maximized", false).toBool())
insilmaril@625
    90
    {
anng888@632
    91
        setWindowState(Qt::WindowMaximized);
insilmaril@625
    92
    }
insilmaril@625
    93
    else
insilmaril@625
    94
#endif
insilmaril@625
    95
    {
insilmaril@625
    96
        resize (settings.value("/mainwindow/geometry/size", QSize (800,600)).toSize());
insilmaril@625
    97
        move   (settings.value("/mainwindow/geometry/pos",  QPoint(300,100)).toPoint());
insilmaril@625
    98
    }
insilmaril@0
    99
insilmaril@394
   100
	// Sometimes we may need to remember old selections
insilmaril@394
   101
	prevSelection="";
insilmaril@394
   102
insilmaril@395
   103
	// Default color
insilmaril@395
   104
	currentColor=Qt::black;
insilmaril@395
   105
insilmaril@164
   106
	// Create unique temporary directory
insilmaril@366
   107
	bool ok;
insilmaril@608
   108
	tmpVymDir=makeTmpDir (ok,"vym");
insilmaril@366
   109
	if (!ok)
insilmaril@366
   110
	{
insilmaril@366
   111
		qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
insilmaril@366
   112
		exit (1);
insilmaril@366
   113
	}
insilmaril@502
   114
	if (debug) qDebug (QString("vym tmpDir=%1").arg(tmpVymDir) );
insilmaril@164
   115
insilmaril@166
   116
	// Create direcctory for clipboard
insilmaril@166
   117
	clipboardDir=tmpVymDir+"/clipboard";
insilmaril@502
   118
	clipboardFile="map.xml";
insilmaril@166
   119
	QDir d(clipboardDir);
insilmaril@166
   120
	d.mkdir (clipboardDir,true);
insilmaril@166
   121
	makeSubDirs (clipboardDir);
insilmaril@166
   122
	clipboardEmpty=true;
insilmaril@164
   123
insilmaril@266
   124
	procBrowser=NULL;
insilmaril@266
   125
insilmaril@486
   126
	// Satellite windows //////////////////////////////////////////
insilmaril@486
   127
	// history window
insilmaril@404
   128
	historyWindow=new HistoryWindow();
insilmaril@486
   129
	connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
insilmaril@486
   130
insilmaril@486
   131
	// properties window
insilmaril@421
   132
	branchPropertyWindow = new BranchPropertyWindow();
insilmaril@486
   133
	connect (branchPropertyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
insilmaril@486
   134
insilmaril@486
   135
	// Connect TextEditor, so that we can update flags if text changes
insilmaril@486
   136
	connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
insilmaril@486
   137
	connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
insilmaril@486
   138
insilmaril@486
   139
	// Connect HistoryWindow, so that we can update flags
insilmaril@486
   140
	connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
insilmaril@473
   141
insilmaril@421
   142
insilmaril@432
   143
	// Initialize script editor
insilmaril@432
   144
	scriptEditor = new SimpleScriptEditor();
insilmaril@432
   145
	scriptEditor->move (50,50);
insilmaril@432
   146
insilmaril@432
   147
	connect( scriptEditor, SIGNAL( runScript ( QString ) ), 
insilmaril@432
   148
		this, SLOT( runScript( QString ) ) );
insilmaril@432
   149
	
insilmaril@486
   150
insilmaril@486
   151
	// Initialize Find window
insilmaril@486
   152
	findWindow=new FindWindow(NULL);
insilmaril@486
   153
	findWindow->move (x(),y()+70);
insilmaril@486
   154
	connect (findWindow, SIGNAL( findButton(QString) ), 
insilmaril@486
   155
		this, SLOT(editFind(QString) ) );	
insilmaril@486
   156
	connect (findWindow, SIGNAL( somethingChanged() ), 
insilmaril@486
   157
		this, SLOT(editFindChanged() ) );	
insilmaril@486
   158
insilmaril@0
   159
	// Initialize some settings, which are platform dependant
insilmaril@0
   160
	QString p,s;
insilmaril@0
   161
insilmaril@0
   162
		// application to open URLs
insilmaril@366
   163
		p="/mainwindow/readerURL";
insilmaril@0
   164
		#if defined(Q_OS_LINUX)
insilmaril@608
   165
			s=settings.value (p,"xdg-open").toString();
insilmaril@0
   166
		#else
insilmaril@0
   167
			#if defined(Q_OS_MACX)
insilmaril@366
   168
				s=settings.value (p,"/usr/bin/open").toString();
insilmaril@608
   169
insilmaril@608
   170
            #else
insilmaril@608
   171
                #if defined(Q_OS_WIN32)
insilmaril@608
   172
                    // Assume that system has been set up so that
insilmaril@608
   173
                    // Explorer automagically opens up the URL
insilmaril@608
   174
                    // in the user's preferred browser.
insilmaril@608
   175
                    s=settings.value (p,"explorer").toString();
insilmaril@608
   176
                #else
insilmaril@608
   177
					s=settings.value (p,"mozilla").toString();
insilmaril@608
   178
				#endif
insilmaril@0
   179
			#endif
insilmaril@0
   180
		#endif
insilmaril@366
   181
		settings.setValue( p,s);
insilmaril@0
   182
insilmaril@0
   183
		// application to open PDFs
insilmaril@366
   184
		p="/mainwindow/readerPDF";
insilmaril@0
   185
		#if defined(Q_OS_LINUX)
insilmaril@608
   186
			s=settings.value (p,"xdg-open").toString();
insilmaril@0
   187
		#else
insilmaril@0
   188
			#if defined(Q_OS_MACX)
insilmaril@366
   189
				s=settings.value (p,"/usr/bin/open").toString();
insilmaril@625
   190
            #elif defined(Q_OS_WIN32)
insilmaril@625
   191
                s=settings.value (p,"acrord32").toString();
insilmaril@0
   192
			#else
insilmaril@366
   193
				s=settings.value (p,"acroread").toString();
insilmaril@0
   194
			#endif
insilmaril@0
   195
		#endif
insilmaril@366
   196
		settings.setValue( p,s);
insilmaril@0
   197
insilmaril@600
   198
	// width of xLinksMenu
insilmaril@600
   199
	xLinkMenuWidth=60;
insilmaril@0
   200
	
insilmaril@0
   201
	// Create tab widget which holds the maps
insilmaril@0
   202
	tabWidget= new QTabWidget (this);
insilmaril@0
   203
	connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ), 
insilmaril@0
   204
		this, SLOT( editorChanged( QWidget * ) ) );
insilmaril@0
   205
insilmaril@0
   206
	setCentralWidget(tabWidget);	
insilmaril@0
   207
insilmaril@0
   208
    setupFileActions();
insilmaril@0
   209
    setupEditActions();
insilmaril@0
   210
    setupFormatActions();
insilmaril@0
   211
    setupViewActions();
insilmaril@89
   212
    setupModeActions();
insilmaril@0
   213
	setupFlagActions();
insilmaril@528
   214
    setupNetworkActions();
insilmaril@0
   215
    setupSettingsActions();
insilmaril@0
   216
	setupContextMenus();
insilmaril@445
   217
	setupMacros();
insilmaril@366
   218
    if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
insilmaril@0
   219
    setupHelpActions();
insilmaril@0
   220
    
insilmaril@742
   221
	// Status bar and progress bar there
insilmaril@0
   222
    statusBar();
insilmaril@742
   223
	progressMax=0;
insilmaril@742
   224
	progressBar=new QProgressBar; 
insilmaril@742
   225
	progressBar->hide();
insilmaril@742
   226
	statusBar()->addPermanentWidget(progressBar);
insilmaril@0
   227
insilmaril@366
   228
	restoreState (settings.value("/mainwindow/state",0).toByteArray());
insilmaril@0
   229
insilmaril@0
   230
	updateGeometry();
insilmaril@0
   231
}
insilmaril@0
   232
insilmaril@0
   233
Main::~Main()
insilmaril@0
   234
{
insilmaril@0
   235
	// Save Settings
insilmaril@625
   236
#if defined(Q_OS_WIN32)
insilmaril@625
   237
    settings.setValue ("/mainwindow/geometry/maximized", isMaximized());
insilmaril@625
   238
#endif
insilmaril@625
   239
	settings.setValue ("/mainwindow/geometry/size", size());
insilmaril@625
   240
	settings.setValue ("/mainwindow/geometry/pos", pos());
insilmaril@366
   241
	settings.setValue ("/mainwindow/state",saveState(0));
insilmaril@366
   242
insilmaril@408
   243
	settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
insilmaril@408
   244
	settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
insilmaril@404
   245
	settings.setValue( "/version/version", vymVersion );
insilmaril@404
   246
	settings.setValue( "/version/builddate", vymBuildDate );
insilmaril@366
   247
insilmaril@742
   248
	settings.setValue( "/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
insilmaril@537
   249
	settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isOn() );
insilmaril@625
   250
	settings.setValue( "/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
insilmaril@390
   251
	settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
insilmaril@537
   252
	settings.setValue( "/mapeditor/editmode/autoEditNewBranch",actionSettingsAutoEditNewBranch->isOn() );
insilmaril@366
   253
	settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
insilmaril@366
   254
	settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
insilmaril@366
   255
	settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
insilmaril@0
   256
insilmaril@473
   257
	//TODO save scriptEditor settings
insilmaril@432
   258
insilmaril@404
   259
	// call the destructors
insilmaril@442
   260
	delete textEditor;
insilmaril@404
   261
	delete historyWindow;
insilmaril@473
   262
	delete branchPropertyWindow;
insilmaril@742
   263
	delete progressBar;
insilmaril@164
   264
insilmaril@164
   265
	// Remove temporary directory
insilmaril@164
   266
	removeDir (QDir(tmpVymDir));
insilmaril@0
   267
}
insilmaril@0
   268
insilmaril@0
   269
void Main::loadCmdLine()
insilmaril@0
   270
{
insilmaril@0
   271
	/* TODO draw some kind of splashscreen while loading...
insilmaril@0
   272
	if (qApp->argc()>1)
insilmaril@0
   273
	{
insilmaril@0
   274
	}
insilmaril@0
   275
	*/
insilmaril@0
   276
	
insilmaril@0
   277
	QStringList flist=options.getFileList();
insilmaril@0
   278
	QStringList::Iterator it=flist.begin();
insilmaril@0
   279
insilmaril@0
   280
	while (it !=flist.end() )
insilmaril@0
   281
	{
insilmaril@0
   282
		fileLoad (*it, NewMap);
insilmaril@0
   283
		*it++;
insilmaril@0
   284
	}	
insilmaril@0
   285
}
insilmaril@0
   286
insilmaril@0
   287
insilmaril@0
   288
void Main::statusMessage(const QString &s)
insilmaril@0
   289
{
insilmaril@742
   290
	// Surpress messages while progressbar during 
insilmaril@742
   291
	// load is active
insilmaril@742
   292
	if (progressMin==progressMax)
insilmaril@742
   293
		statusBar()->message( s);
insilmaril@742
   294
}
insilmaril@742
   295
insilmaril@742
   296
void Main::setProgressMinimum (int min)
insilmaril@742
   297
{
insilmaril@742
   298
	progressBar->setMinimum(min);
insilmaril@742
   299
	progressMin=min;
insilmaril@742
   300
}
insilmaril@742
   301
insilmaril@742
   302
void Main::setProgressMaximum (int max)
insilmaril@742
   303
{
insilmaril@742
   304
	progressBar->setMaximum(max);
insilmaril@742
   305
	progressMax=max;
insilmaril@742
   306
	if (max>0)
insilmaril@742
   307
	{
insilmaril@742
   308
		statusBar()->addPermanentWidget(progressBar);
insilmaril@742
   309
		progressBar->show();
insilmaril@742
   310
	}
insilmaril@742
   311
}
insilmaril@742
   312
insilmaril@742
   313
void Main::setProgressValue (int v)
insilmaril@742
   314
{
insilmaril@742
   315
	progressBar->setValue (v);
insilmaril@742
   316
}
insilmaril@742
   317
insilmaril@742
   318
void Main::removeProgressBar()
insilmaril@742
   319
{
insilmaril@742
   320
	if (progressMax>0)
insilmaril@742
   321
		statusBar()->removeWidget(progressBar);
insilmaril@742
   322
	progressMax=progressMin=0;
insilmaril@0
   323
}
insilmaril@0
   324
insilmaril@0
   325
void Main::closeEvent (QCloseEvent* )
insilmaril@0
   326
{
insilmaril@0
   327
	fileExitVYM();
insilmaril@0
   328
}
insilmaril@0
   329
insilmaril@0
   330
// File Actions
insilmaril@0
   331
void Main::setupFileActions()
insilmaril@0
   332
{
insilmaril@366
   333
	QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
insilmaril@366
   334
    QToolBar *tb = addToolBar( tr ("&Map") );
insilmaril@366
   335
	tb->setObjectName ("mapTB");
insilmaril@0
   336
insilmaril@0
   337
    QAction *a;
insilmaril@491
   338
    a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this);
insilmaril@395
   339
	a->setStatusTip ( tr( "New map","Status tip File menu" ) );
insilmaril@442
   340
	a->setShortcut ( Qt::CTRL + Qt::Key_N );		//New map
insilmaril@0
   341
    a->addTo( tb );
insilmaril@366
   342
	fileMenu->addAction (a);
insilmaril@366
   343
    connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
insilmaril@0
   344
	
insilmaril@494
   345
    a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this);
insilmaril@491
   346
	a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) );
insilmaril@491
   347
	a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N );		//New map
insilmaril@491
   348
	fileMenu->addAction (a);
insilmaril@491
   349
    connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) );
insilmaril@689
   350
	actionFileNewCopy=a;
insilmaril@491
   351
	
insilmaril@395
   352
    a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
insilmaril@395
   353
	a->setStatusTip (tr( "Open","Status tip File menu" ) );
insilmaril@442
   354
	a->setShortcut ( Qt::CTRL + Qt::Key_O );		//Open map
insilmaril@0
   355
    a->addTo( tb );
insilmaril@366
   356
	fileMenu->addAction (a);
insilmaril@366
   357
    connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
insilmaril@0
   358
	
insilmaril@395
   359
	fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
insilmaril@366
   360
	fileMenu->addSeparator();
insilmaril@0
   361
	
insilmaril@395
   362
    a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
insilmaril@395
   363
	a->setStatusTip ( tr( "Save","Status tip file menu" ));
insilmaril@442
   364
	a->setShortcut (Qt::CTRL + Qt::Key_S );			//Save map
insilmaril@0
   365
    a->addTo( tb );
insilmaril@366
   366
	fileMenu->addAction (a);
insilmaril@366
   367
    connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
insilmaril@0
   368
	actionFileSave=a;
insilmaril@0
   369
	
insilmaril@395
   370
    a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
insilmaril@395
   371
	a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
insilmaril@366
   372
	fileMenu->addAction (a);
insilmaril@366
   373
    connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
insilmaril@366
   374
insilmaril@366
   375
	fileMenu->addSeparator();
insilmaril@366
   376
insilmaril@395
   377
	fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
insilmaril@366
   378
insilmaril@742
   379
	a = new QAction(tr("KDE 3 Bookmarks"), this);
insilmaril@742
   380
	a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 3 bookmarks")));
insilmaril@366
   381
	a->addTo (fileImportMenu);
insilmaril@742
   382
	connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE3Bookmarks() ) );
insilmaril@742
   383
insilmaril@742
   384
	a = new QAction(tr("KDE 4 Bookmarks"), this);
insilmaril@742
   385
	a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 4 bookmarks")));
insilmaril@742
   386
	a->addTo (fileImportMenu);
insilmaril@742
   387
	connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE4Bookmarks() ) );
insilmaril@366
   388
insilmaril@366
   389
    if (settings.value( "/mainwindow/showTestMenu",false).toBool()) 
insilmaril@331
   390
	{
insilmaril@395
   391
		a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
insilmaril@395
   392
		a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
insilmaril@366
   393
		a->addTo (fileImportMenu);
insilmaril@366
   394
		connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
insilmaril@331
   395
	}	
insilmaril@314
   396
insilmaril@571
   397
	a = new QAction("Freemind...",this);
insilmaril@571
   398
	a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Freemind")  );
insilmaril@571
   399
	fileImportMenu->addAction (a);
insilmaril@571
   400
	connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFreemind() ) );
insilmaril@571
   401
insilmaril@366
   402
	a = new QAction("Mind Manager...",this);
insilmaril@395
   403
	a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager")  );
insilmaril@366
   404
	fileImportMenu->addAction (a);
insilmaril@366
   405
	connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
insilmaril@366
   406
insilmaril@395
   407
    a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
insilmaril@395
   408
	a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
insilmaril@366
   409
	fileImportMenu->addAction (a);
insilmaril@366
   410
    connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
insilmaril@366
   411
insilmaril@395
   412
	fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
insilmaril@395
   413
insilmaril@395
   414
	a = new QAction( tr("Image%1","File export menu").arg("..."), this);
insilmaril@395
   415
	a->setStatusTip( tr( "Export map as image","status tip file menu" ));
insilmaril@366
   416
	connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
insilmaril@366
   417
	fileExportMenu->addAction (a);
insilmaril@366
   418
insilmaril@395
   419
	a = new QAction( "Open Office...", this);
insilmaril@395
   420
	a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
insilmaril@366
   421
	connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
insilmaril@366
   422
	fileExportMenu->addAction (a);
insilmaril@366
   423
insilmaril@366
   424
	a = new QAction(  "Webpage (XHTML)...",this );
insilmaril@442
   425
	a->setShortcut (Qt::ALT + Qt::Key_X);			//Export XHTML
insilmaril@395
   426
	a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
insilmaril@366
   427
    connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
insilmaril@366
   428
	fileExportMenu->addAction (a);
insilmaril@366
   429
insilmaril@366
   430
    a = new QAction( "Text (ASCII)...", this);
insilmaril@395
   431
	a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
insilmaril@366
   432
    connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
insilmaril@366
   433
	fileExportMenu->addAction (a);
insilmaril@366
   434
insilmaril@497
   435
    a = new QAction( "Spreadsheet (CSV)...", this);
insilmaril@497
   436
	a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
insilmaril@497
   437
    connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
insilmaril@497
   438
	fileExportMenu->addAction (a);
insilmaril@497
   439
insilmaril@742
   440
	a = new QAction( tr("KDE 3 Bookmarks","File menu"), this);
insilmaril@742
   441
	a->setStatusTip( tr( "Export as %1").arg(tr("KDE 3 Bookmarks" )));
insilmaril@742
   442
	connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE3Bookmarks() ) );
insilmaril@742
   443
	fileExportMenu->addAction (a);
insilmaril@742
   444
insilmaril@742
   445
	a = new QAction( tr("KDE 4 Bookmarks","File menu"), this);
insilmaril@742
   446
	a->setStatusTip( tr( "Export as %1").arg(tr("KDE 4 Bookmarks" )));
insilmaril@742
   447
	connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE4Bookmarks() ) );
insilmaril@366
   448
	fileExportMenu->addAction (a);
insilmaril@366
   449
insilmaril@366
   450
    a = new QAction( "Taskjuggler...", this );
insilmaril@395
   451
    a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
insilmaril@366
   452
    connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
insilmaril@366
   453
	fileExportMenu->addAction (a);
insilmaril@366
   454
insilmaril@366
   455
    a = new QAction( "LaTeX...", this);
insilmaril@395
   456
    a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
insilmaril@366
   457
    connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
insilmaril@366
   458
	fileExportMenu->addAction (a);
insilmaril@366
   459
insilmaril@366
   460
	a = new QAction( "XML..." , this );
insilmaril@395
   461
	a->setStatusTip (tr( "Export as %1").arg("XML"));
insilmaril@366
   462
    connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
insilmaril@366
   463
	fileExportMenu->addAction (a);
insilmaril@366
   464
insilmaril@366
   465
	fileMenu->addSeparator();
insilmaril@366
   466
insilmaril@366
   467
    a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
insilmaril@395
   468
	a->setStatusTip ( tr( "Print" ,"File menu") );
insilmaril@442
   469
	a->setShortcut (Qt::CTRL + Qt::Key_P );			//Print map
insilmaril@0
   470
    a->addTo( tb );
insilmaril@366
   471
	fileMenu->addAction (a);
insilmaril@366
   472
    connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
insilmaril@0
   473
	actionFilePrint=a;
insilmaril@0
   474
insilmaril@395
   475
    a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
insilmaril@366
   476
	a->setStatusTip (tr( "Close Map" ) );
insilmaril@473
   477
	a->setShortcut (Qt::CTRL + Qt::Key_W );			//Close map
insilmaril@366
   478
	fileMenu->addAction (a);
insilmaril@366
   479
    connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
insilmaril@366
   480
insilmaril@404
   481
    a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
insilmaril@404
   482
	a->setStatusTip ( tr( "Exit")+" "+vymName );
insilmaril@442
   483
	a->setShortcut (Qt::CTRL + Qt::Key_Q );			//Quit vym
insilmaril@366
   484
	fileMenu->addAction (a);
insilmaril@366
   485
    connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
insilmaril@0
   486
}
insilmaril@0
   487
insilmaril@0
   488
insilmaril@0
   489
//Edit Actions
insilmaril@0
   490
void Main::setupEditActions()
insilmaril@0
   491
{
insilmaril@395
   492
    QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
insilmaril@0
   493
    tb->setLabel( "Edit Actions" );
insilmaril@366
   494
	tb->setObjectName ("actionsTB");
insilmaril@395
   495
    QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
insilmaril@0
   496
insilmaril@0
   497
    QAction *a;
insilmaril@102
   498
	QAction *alt;
insilmaril@395
   499
    a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
insilmaril@366
   500
    connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
insilmaril@366
   501
	a->setStatusTip (tr( "Undo" ) );
insilmaril@442
   502
	a->setShortcut ( Qt::CTRL + Qt::Key_Z );		//Undo last action
insilmaril@0
   503
	a->setEnabled (false);
insilmaril@366
   504
    tb->addAction (a);
insilmaril@366
   505
	editMenu->addAction (a);
insilmaril@723
   506
	actionUndo=a;
insilmaril@163
   507
    
insilmaril@395
   508
	a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this); 
insilmaril@366
   509
	a->setStatusTip (tr( "Redo" ));
insilmaril@442
   510
	a->setShortcut (Qt::CTRL + Qt::Key_Y );			//Redo last action
insilmaril@366
   511
    tb->addAction (a);
insilmaril@366
   512
	editMenu->addAction (a);
insilmaril@366
   513
	connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
insilmaril@723
   514
	actionRedo=a;
insilmaril@163
   515
   
insilmaril@366
   516
	editMenu->addSeparator();
insilmaril@395
   517
    a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
insilmaril@366
   518
	a->setStatusTip ( tr( "Copy" ) );
insilmaril@442
   519
	a->setShortcut (Qt::CTRL + Qt::Key_C );			//Copy
insilmaril@0
   520
	a->setEnabled (false);
insilmaril@366
   521
    tb->addAction (a);
insilmaril@366
   522
	editMenu->addAction (a);
insilmaril@366
   523
    connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
insilmaril@723
   524
	actionCopy=a;
insilmaril@366
   525
	
insilmaril@395
   526
    a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
insilmaril@366
   527
	a->setStatusTip ( tr( "Cut" ) );
insilmaril@442
   528
	a->setShortcut (Qt::CTRL + Qt::Key_X );			//Cut
insilmaril@0
   529
	a->setEnabled (false);
insilmaril@366
   530
    tb->addAction (a);
insilmaril@366
   531
	editMenu->addAction (a);
insilmaril@723
   532
	actionCut=a;
insilmaril@366
   533
    connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
insilmaril@366
   534
	
insilmaril@395
   535
    a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
insilmaril@366
   536
    connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
insilmaril@366
   537
	a->setStatusTip ( tr( "Paste" ) );
insilmaril@442
   538
	a->setShortcut ( Qt::CTRL + Qt::Key_V );		//Paste
insilmaril@0
   539
	a->setEnabled (false);
insilmaril@366
   540
    tb->addAction (a);
insilmaril@366
   541
	editMenu->addAction (a);
insilmaril@723
   542
	actionPaste=a;
insilmaril@98
   543
insilmaril@753
   544
/*	FIXME-5
insilmaril@351
   545
    // Shortcuts to modify heading:
insilmaril@395
   546
    a = new QAction(tr( "Edit heading","Edit menu" ),this);
insilmaril@366
   547
	a->setStatusTip ( tr( "edit Heading" ));
insilmaril@442
   548
	a->setShortcut ( Qt::Key_Enter);				//Edit heading
insilmaril@366
   549
//	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   550
	addAction (a);
insilmaril@366
   551
    connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
insilmaril@351
   552
	actionListBranches.append(a);
insilmaril@395
   553
    a = new QAction( tr( "Edit heading","Edit menu" ), this);
insilmaril@366
   554
	a->setStatusTip (tr( "edit Heading" ));
insilmaril@442
   555
	a->setShortcut (Qt::Key_Return );				//Edit heading
insilmaril@366
   556
	//a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   557
	addAction (a);
insilmaril@366
   558
    connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
insilmaril@351
   559
	actionListBranches.append(a);
insilmaril@366
   560
	editMenu->addAction (a);
insilmaril@723
   561
	actionHeading=a;
insilmaril@723
   562
insilmaril@395
   563
    a = new QAction( tr( "Edit heading","Edit menu" ), this);
insilmaril@366
   564
	a->setStatusTip (tr( "edit Heading" ));
insilmaril@445
   565
	//a->setShortcut ( Qt::Key_F2 );					//Edit heading
insilmaril@366
   566
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   567
	addAction (a);
insilmaril@366
   568
    connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
insilmaril@351
   569
	actionListBranches.append(a);
insilmaril@723
   570
*/	
insilmaril@351
   571
    
insilmaril@351
   572
    // Shortcut to delete selection
insilmaril@395
   573
    a = new QAction( tr( "Delete Selection","Edit menu" ),this);
insilmaril@366
   574
	a->setStatusTip (tr( "Delete Selection" ));
insilmaril@442
   575
	a->setShortcut ( Qt::Key_Delete);				//Delete selection
insilmaril@366
   576
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   577
	addAction (a);
insilmaril@366
   578
    connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
insilmaril@723
   579
	actionDelete=a;
insilmaril@351
   580
    
insilmaril@684
   581
    // Shortcut to add mapcenter
insilmaril@753
   582
	a= new QAction(QPixmap(iconPath+"newmapcenter.png"),tr( "Add mapcenter","Canvas context menu" ), this);
insilmaril@753
   583
	a->setShortcut ( Qt::Key_M);	
insilmaril@753
   584
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@684
   585
    connect( a, SIGNAL( triggered() ), this, SLOT( editAddMapCenter() ) );
insilmaril@753
   586
	//actionListBranches.append(a);
insilmaril@753
   587
	tb->addAction (a);
insilmaril@723
   588
	actionAddMapCenter = a;
insilmaril@684
   589
insilmaril@684
   590
insilmaril@351
   591
    // Shortcut to add branch
insilmaril@395
   592
	alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
insilmaril@366
   593
	alt->setStatusTip ( tr( "Add a branch as child of selection" ));
insilmaril@442
   594
	alt->setShortcut (Qt::Key_A);					//Add branch
insilmaril@366
   595
	alt->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   596
	addAction (alt);
insilmaril@366
   597
	connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
insilmaril@395
   598
	a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
insilmaril@366
   599
	a->setStatusTip ( tr( "Add a branch as child of selection" ));
insilmaril@442
   600
	a->setShortcut (Qt::Key_Insert);				//Add branch
insilmaril@366
   601
	connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
insilmaril@351
   602
	actionListBranches.append(a);
insilmaril@351
   603
	#if defined (Q_OS_MACX)
insilmaril@366
   604
		// In OSX show different shortcut in menues, the keys work indepently always			
insilmaril@723
   605
		actionAddBranch=alt;
insilmaril@351
   606
	#else	
insilmaril@723
   607
		actionAddBranch=a;
insilmaril@351
   608
	#endif	
insilmaril@723
   609
	editMenu->addAction (actionAddBranch);
insilmaril@723
   610
	tb->addAction (actionAddBranch);
insilmaril@366
   611
insilmaril@351
   612
insilmaril@351
   613
    // Add branch by inserting it at selection
insilmaril@395
   614
	a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
insilmaril@366
   615
	a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
insilmaril@442
   616
	a->setShortcut (Qt::ALT + Qt::Key_Insert );		//Insert branch
insilmaril@366
   617
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   618
	addAction (a);
insilmaril@394
   619
    connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
insilmaril@351
   620
	a->setEnabled (false);
insilmaril@351
   621
	actionListBranches.append(a);
insilmaril@723
   622
	actionAddBranchBefore=a;
insilmaril@395
   623
	a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
insilmaril@366
   624
	a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
insilmaril@442
   625
	a->setShortcut ( Qt::ALT + Qt::Key_A );			//Insert branch
insilmaril@366
   626
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   627
	addAction (a);
insilmaril@394
   628
    connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
insilmaril@351
   629
	actionListBranches.append(a);
insilmaril@351
   630
insilmaril@351
   631
	// Add branch above
insilmaril@395
   632
    a = new QAction(tr( "Add branch above","Edit menu" ), this);
insilmaril@366
   633
	a->setStatusTip ( tr( "Add a branch above selection" ));
insilmaril@442
   634
	a->setShortcut (Qt::SHIFT+Qt::Key_Insert );		//Add branch above
insilmaril@366
   635
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   636
	addAction (a);
insilmaril@366
   637
    connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
insilmaril@351
   638
	a->setEnabled (false);
insilmaril@351
   639
	actionListBranches.append(a);
insilmaril@723
   640
	actionAddBranchAbove=a;
insilmaril@395
   641
    a = new QAction(tr( "Add branch above","Edit menu" ), this);
insilmaril@366
   642
	a->setStatusTip ( tr( "Add a branch above selection" ));
insilmaril@442
   643
	a->setShortcut (Qt::SHIFT+Qt::Key_A );			//Add branch above
insilmaril@366
   644
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   645
	addAction (a);
insilmaril@366
   646
    connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
insilmaril@351
   647
	actionListBranches.append(a);
insilmaril@351
   648
insilmaril@351
   649
	// Add branch below 
insilmaril@395
   650
    a = new QAction(tr( "Add branch below","Edit menu" ), this);
insilmaril@366
   651
	a->setStatusTip ( tr( "Add a branch below selection" ));
insilmaril@442
   652
	a->setShortcut (Qt::CTRL +Qt::Key_Insert );		//Add branch below
insilmaril@366
   653
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   654
	addAction (a);
insilmaril@366
   655
    connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
insilmaril@351
   656
	a->setEnabled (false);
insilmaril@351
   657
	actionListBranches.append(a);
insilmaril@723
   658
	actionAddBranchBelow=a;
insilmaril@395
   659
    a = new QAction(tr( "Add branch below","Edit menu" ), this);
insilmaril@366
   660
	a->setStatusTip ( tr( "Add a branch below selection" ));
insilmaril@442
   661
	a->setShortcut (Qt::CTRL +Qt::Key_A );			// Add branch below
insilmaril@366
   662
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   663
	addAction (a);
insilmaril@366
   664
    connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
insilmaril@351
   665
	actionListBranches.append(a);
insilmaril@351
   666
insilmaril@395
   667
    a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
insilmaril@366
   668
	a->setStatusTip ( tr( "Move branch up" ) );
insilmaril@442
   669
	a->setShortcut (Qt::Key_PageUp );				// Move branch up
insilmaril@0
   670
	a->setEnabled (false);
insilmaril@366
   671
    tb->addAction (a);
insilmaril@366
   672
	editMenu->addAction (a);
insilmaril@366
   673
    connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
insilmaril@723
   674
	actionMoveUp=a;
insilmaril@98
   675
insilmaril@395
   676
    a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
insilmaril@366
   677
    connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
insilmaril@366
   678
	a->setStatusTip (tr( "Move branch down" ) );
insilmaril@442
   679
	a->setShortcut ( Qt::Key_PageDown );			// Move branch down
insilmaril@0
   680
	a->setEnabled (false);
insilmaril@366
   681
    tb->addAction (a);
insilmaril@366
   682
	editMenu->addAction (a);
insilmaril@723
   683
	actionMoveDown=a;
insilmaril@98
   684
	
insilmaril@608
   685
	a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this );
insilmaril@608
   686
	connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) );
insilmaril@608
   687
	a->setEnabled (true);
insilmaril@608
   688
	a->addTo( tb );
insilmaril@613
   689
	editMenu->addAction (a);
insilmaril@723
   690
	actionSortChildren=a;
insilmaril@0
   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@763
   710
	a = new QAction( QPixmap(), tr( "Expand all branches","Edit menu" ), this);
insilmaril@763
   711
	a->setShortcut ( Qt::SHIFT + Qt::Key_X );		// Expand all branches 
insilmaril@763
   712
	a->setStatusTip (tr( "Expand all branches" )); 
insilmaril@763
   713
    connect( a, SIGNAL( triggered() ), this, SLOT( editExpandAll() ) );
insilmaril@763
   714
	actionExpandAll=a;
insilmaril@763
   715
	actionExpandAll->setEnabled (false);
insilmaril@763
   716
	actionExpandAll->setToggleAction(false);
insilmaril@763
   717
    //tb->addAction (actionExpandAll);
insilmaril@763
   718
    editMenu->addAction ( actionExpandAll);
insilmaril@763
   719
	addAction (a);
insilmaril@763
   720
	actionListBranches.append(actionExpandAll);
insilmaril@763
   721
insilmaril@763
   722
insilmaril@721
   723
    a = new QAction( tr( "Unscroll children","Edit menu" ), this);
insilmaril@473
   724
	a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
insilmaril@366
   725
	editMenu->addAction (a);
insilmaril@721
   726
    connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChildren() ) );
insilmaril@0
   727
	
insilmaril@366
   728
	editMenu->addSeparator();
insilmaril@366
   729
insilmaril@395
   730
	a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
insilmaril@366
   731
	a->setStatusTip (tr( "Find" ) );
insilmaril@442
   732
	a->setShortcut (Qt::CTRL + Qt::Key_F );				//Find
insilmaril@366
   733
	editMenu->addAction (a);
insilmaril@366
   734
    connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
insilmaril@0
   735
    
insilmaril@366
   736
	editMenu->addSeparator();
insilmaril@366
   737
insilmaril@395
   738
	a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
insilmaril@366
   739
	a->setShortcut (Qt::CTRL + Qt::Key_U );
insilmaril@366
   740
	a->setShortcut (tr( "Open URL" ));
insilmaril@366
   741
    tb->addAction (a);
insilmaril@366
   742
	addAction(a);
insilmaril@366
   743
    connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
insilmaril@723
   744
	actionOpenURL=a;
insilmaril@0
   745
insilmaril@395
   746
	a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
insilmaril@366
   747
	a->setStatusTip (tr( "Open URL in new tab" ));
insilmaril@528
   748
	//a->setShortcut (Qt::CTRL+Qt::Key_U );
insilmaril@366
   749
	addAction(a);
insilmaril@366
   750
    connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
insilmaril@723
   751
	actionOpenURLTab=a;
insilmaril@266
   752
insilmaril@395
   753
	a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
insilmaril@366
   754
	a->setStatusTip (tr( "Open all URLs in subtree" ));
insilmaril@366
   755
	addAction(a);
insilmaril@366
   756
	actionListBranches.append(a);
insilmaril@366
   757
    connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
insilmaril@723
   758
	actionOpenMultipleURLTabs=a;
insilmaril@366
   759
insilmaril@395
   760
	a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
insilmaril@366
   761
	a->setStatusTip ( tr( "Edit URL" ) );
insilmaril@528
   762
	a->setShortcut ( Qt::Key_U );
insilmaril@366
   763
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   764
	actionListBranches.append(a);
insilmaril@366
   765
	addAction(a);
insilmaril@366
   766
    connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
insilmaril@723
   767
	actionURL=a;
insilmaril@366
   768
	
insilmaril@528
   769
	a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
insilmaril@528
   770
	a->setStatusTip ( tr( "Edit local URL" ) );
insilmaril@528
   771
	a->setShortcut (Qt::SHIFT +  Qt::Key_U );
insilmaril@528
   772
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@528
   773
	actionListBranches.append(a);
insilmaril@528
   774
	addAction(a);
insilmaril@528
   775
    connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
insilmaril@723
   776
	actionLocalURL=a;
insilmaril@528
   777
	
insilmaril@395
   778
	a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
insilmaril@366
   779
	a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
insilmaril@0
   780
	a->setEnabled (false);
insilmaril@98
   781
	actionListBranches.append(a);
insilmaril@366
   782
    connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
insilmaril@723
   783
	actionHeading2URL=a;
insilmaril@366
   784
    
insilmaril@486
   785
	a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
insilmaril@486
   786
	a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
insilmaril@0
   787
	a->setEnabled (false);
insilmaril@98
   788
	actionListBranches.append(a);
insilmaril@366
   789
    connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
insilmaril@723
   790
	actionBugzilla2URL=a;
insilmaril@0
   791
    
insilmaril@486
   792
	a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
insilmaril@486
   793
	a->setStatusTip ( tr( "Create URL to Novell FATE" ));
insilmaril@0
   794
	a->setEnabled (false);
insilmaril@98
   795
	actionListBranches.append(a);
insilmaril@366
   796
    connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
insilmaril@723
   797
	actionFATE2URL=a;
insilmaril@366
   798
	
insilmaril@395
   799
    a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
insilmaril@366
   800
	a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
insilmaril@366
   801
    tb->addAction (a);
insilmaril@366
   802
	a->setEnabled (false);
insilmaril@366
   803
    connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
insilmaril@723
   804
	actionOpenVymLink=a;
insilmaril@366
   805
	
insilmaril@395
   806
    a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
insilmaril@366
   807
	a->setStatusTip ( tr( "Open all vym links in subtree" ));
insilmaril@175
   808
	a->setEnabled (false);
insilmaril@175
   809
	actionListBranches.append(a);
insilmaril@366
   810
    connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
insilmaril@723
   811
	actionOpenMultipleVymLinks=a;
insilmaril@0
   812
	
insilmaril@366
   813
insilmaril@395
   814
    a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
insilmaril@0
   815
	a->setEnabled (false);
insilmaril@366
   816
	a->setStatusTip ( tr( "Edit link to another vym map" ));
insilmaril@366
   817
    connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
insilmaril@98
   818
	actionListBranches.append(a);
insilmaril@723
   819
	actionVymLink=a;
insilmaril@0
   820
insilmaril@395
   821
    a = new QAction(tr( "Delete vym link","Edit menu" ),this);
insilmaril@366
   822
	a->setStatusTip ( tr( "Delete link to another vym map" ));
insilmaril@0
   823
	a->setEnabled (false);
insilmaril@366
   824
    connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
insilmaril@723
   825
	actionDeleteVymLink=a;
insilmaril@0
   826
insilmaril@395
   827
    a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
insilmaril@366
   828
	a->setStatusTip ( tr( "Hide object in exports" ) );
insilmaril@366
   829
	a->setShortcut (Qt::Key_H );
insilmaril@243
   830
	a->setToggleAction(true);
insilmaril@366
   831
    tb->addAction (a);
insilmaril@243
   832
	a->setEnabled (false);
insilmaril@366
   833
    connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
insilmaril@723
   834
	actionToggleHideExport=a;
insilmaril@243
   835
insilmaril@395
   836
    a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
insilmaril@366
   837
	a->setStatusTip ( tr( "Edit Map Info" ));
insilmaril@0
   838
	a->setEnabled (true);
insilmaril@366
   839
    connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
insilmaril@723
   840
	actionMapInfo=a;
insilmaril@0
   841
insilmaril@0
   842
	// Import at selection (adding to selection)
insilmaril@395
   843
    a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
insilmaril@366
   844
	a->setStatusTip (tr( "Add map at selection" ));
insilmaril@366
   845
    connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
insilmaril@0
   846
	a->setEnabled (false);
insilmaril@98
   847
	actionListBranches.append(a);
insilmaril@723
   848
	actionImportAdd=a;
insilmaril@0
   849
insilmaril@0
   850
	// Import at selection (replacing selection)
insilmaril@395
   851
    a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
insilmaril@366
   852
	a->setStatusTip (tr( "Replace selection with map" ));
insilmaril@366
   853
    connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
insilmaril@0
   854
	a->setEnabled (false);
insilmaril@98
   855
	actionListBranches.append(a);
insilmaril@723
   856
	actionImportReplace=a;
insilmaril@0
   857
insilmaril@0
   858
	// Save selection 
insilmaril@395
   859
    a = new QAction( tr( "Save selection","Edit menu" ), this);
insilmaril@366
   860
	a->setStatusTip (tr( "Save selection" ));
insilmaril@366
   861
    connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
insilmaril@0
   862
	a->setEnabled (false);
insilmaril@98
   863
	actionListBranches.append(a);
insilmaril@723
   864
	actionSaveBranch=a;
insilmaril@0
   865
insilmaril@721
   866
	// Only remove branch, not its children
insilmaril@395
   867
    a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
insilmaril@721
   868
	a->setStatusTip ( tr( "Remove only branch and keep its children" ));
insilmaril@366
   869
	a->setShortcut (Qt::ALT + Qt::Key_Delete );
insilmaril@721
   870
    connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChildren() ) );
insilmaril@98
   871
	a->setEnabled (false);
insilmaril@375
   872
	addAction (a);
insilmaril@98
   873
	actionListBranches.append(a);
insilmaril@723
   874
	actionDeleteKeepChildren=a;
insilmaril@721
   875
insilmaril@721
   876
	// Only remove children of a branch
insilmaril@721
   877
    a = new QAction( tr( "Remove children","Edit menu" ), this);
insilmaril@721
   878
	a->setStatusTip (tr( "Remove children of branch" ));
insilmaril@366
   879
	a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
insilmaril@721
   880
    connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChildren() ) );
insilmaril@98
   881
	a->setEnabled (false);
insilmaril@98
   882
	actionListBranches.append(a);
insilmaril@723
   883
	actionDeleteChildren=a;
insilmaril@98
   884
insilmaril@0
   885
    // Shortcuts for navigating with cursor:
insilmaril@395
   886
    a = new QAction(tr( "Select upper branch","Edit menu" ), this);
insilmaril@366
   887
	a->setStatusTip ( tr( "Select upper branch" ));
insilmaril@366
   888
	a->setShortcut (Qt::Key_Up );
insilmaril@366
   889
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   890
	addAction (a);
insilmaril@366
   891
    connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
insilmaril@395
   892
    a = new QAction( tr( "Select lower branch","Edit menu" ),this);
insilmaril@366
   893
	a->setStatusTip (tr( "Select lower branch" ));
insilmaril@366
   894
	a->setShortcut ( Qt::Key_Down );
insilmaril@366
   895
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   896
	addAction (a);
insilmaril@366
   897
    connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
insilmaril@395
   898
    a = new QAction(tr( "Select left branch","Edit menu" ), this);
insilmaril@366
   899
	a->setStatusTip ( tr( "Select left branch" ));
insilmaril@366
   900
	a->setShortcut (Qt::Key_Left );
insilmaril@366
   901
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   902
	addAction (a);
insilmaril@366
   903
    connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
insilmaril@395
   904
    a = new QAction( tr( "Select child branch","Edit menu" ), this);
insilmaril@366
   905
	a->setStatusTip (tr( "Select right branch" ));
insilmaril@366
   906
	a->setShortcut (Qt::Key_Right);
insilmaril@366
   907
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   908
	addAction (a);
insilmaril@366
   909
    connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
insilmaril@395
   910
    a = new QAction( tr( "Select first branch","Edit menu" ), this);
insilmaril@366
   911
	a->setStatusTip (tr( "Select first branch" ));
insilmaril@366
   912
	a->setShortcut (Qt::Key_Home );
insilmaril@366
   913
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   914
	addAction (a);
insilmaril@0
   915
	a->setEnabled (false);
insilmaril@366
   916
	editMenu->addAction (a);
insilmaril@98
   917
	actionListBranches.append(a);
insilmaril@723
   918
	actionSelectFirst=a;
insilmaril@366
   919
    connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
insilmaril@395
   920
    a = new QAction( tr( "Select last branch","Edit menu" ),this);
insilmaril@366
   921
	a->setStatusTip (tr( "Select last branch" ));
insilmaril@366
   922
	a->setShortcut ( Qt::Key_End );
insilmaril@366
   923
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@366
   924
	addAction (a);
insilmaril@366
   925
    connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
insilmaril@0
   926
	a->setEnabled (false);
insilmaril@366
   927
	editMenu->addAction (a);
insilmaril@98
   928
	actionListBranches.append(a);
insilmaril@723
   929
	actionSelectLast=a;
insilmaril@0
   930
insilmaril@395
   931
    a = new QAction( tr( "Add Image...","Edit menu" ), this);
insilmaril@366
   932
	a->setStatusTip (tr( "Add Image" ));
insilmaril@366
   933
    connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
insilmaril@723
   934
	actionLoadImage=a;
insilmaril@89
   935
insilmaril@473
   936
    a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
insilmaril@442
   937
	a->setStatusTip (tr( "Set properties for selection" ));
insilmaril@442
   938
	a->setShortcut ( Qt::CTRL + Qt::Key_I );		//Property window
insilmaril@442
   939
	a->setShortcutContext (Qt::WindowShortcut);
insilmaril@486
   940
	a->setToggleAction (true);
insilmaril@442
   941
	addAction (a);
insilmaril@473
   942
    connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
insilmaril@486
   943
	actionViewTogglePropertyWindow=a;
insilmaril@0
   944
}
insilmaril@0
   945
insilmaril@0
   946
// Format Actions
insilmaril@0
   947
void Main::setupFormatActions()
insilmaril@0
   948
{
insilmaril@395
   949
    QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
insilmaril@395
   950
insilmaril@395
   951
    QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
insilmaril@366
   952
	tb->setObjectName ("formatTB");
insilmaril@0
   953
    QAction *a;
insilmaril@0
   954
    QPixmap pix( 16,16);
insilmaril@366
   955
    pix.fill (Qt::black);
insilmaril@366
   956
    a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
insilmaril@366
   957
	a->setStatusTip ( tr( "Set Color" ));
insilmaril@366
   958
    connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
insilmaril@366
   959
    a->addTo( tb );
insilmaril@366
   960
	formatMenu->addAction (a);
insilmaril@366
   961
	actionFormatColor=a;
insilmaril@395
   962
    a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
insilmaril@366
   963
	a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
insilmaril@366
   964
	a->setShortcut (Qt::CTRL + Qt::Key_K );
insilmaril@366
   965
    connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
insilmaril@0
   966
	a->setEnabled (false);
insilmaril@0
   967
    a->addTo( tb );
insilmaril@366
   968
	formatMenu->addAction (a);
insilmaril@98
   969
	actionListBranches.append(a);
insilmaril@0
   970
	actionFormatPickColor=a;
insilmaril@366
   971
insilmaril@417
   972
    a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
insilmaril@366
   973
	a->setStatusTip ( tr( "Color branch" ) );
insilmaril@442
   974
	a->setShortcut (Qt::CTRL + Qt::Key_B);
insilmaril@417
   975
    connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
insilmaril@0
   976
	a->setEnabled (false);
insilmaril@0
   977
    a->addTo( tb );
insilmaril@366
   978
	formatMenu->addAction (a);
insilmaril@98
   979
	actionListBranches.append(a);
insilmaril@417
   980
	actionFormatColorSubtree=a;
insilmaril@417
   981
insilmaril@417
   982
    a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
insilmaril@366
   983
	a->setStatusTip ( tr( "Color Subtree" ));
insilmaril@366
   984
	a->setShortcut (Qt::CTRL + Qt::Key_T);
insilmaril@417
   985
    connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
insilmaril@0
   986
	a->setEnabled (false);
insilmaril@366
   987
	formatMenu->addAction (a);
insilmaril@0
   988
    a->addTo( tb );
insilmaril@98
   989
	actionListBranches.append(a);
insilmaril@0
   990
	actionFormatColorSubtree=a;
insilmaril@0
   991
insilmaril@366
   992
	formatMenu->addSeparator();
insilmaril@366
   993
	actionGroupFormatLinkStyles=new QActionGroup ( this);
insilmaril@0
   994
	actionGroupFormatLinkStyles->setExclusive (true);
insilmaril@366
   995
    a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
insilmaril@366
   996
	a->setStatusTip (tr( "Line" ));
insilmaril@0
   997
	a->setToggleAction(true);
insilmaril@366
   998
    connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
insilmaril@366
   999
	formatMenu->addAction (a);
insilmaril@0
  1000
	actionFormatLinkStyleLine=a;
insilmaril@505
  1001
    a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
insilmaril@366
  1002
	a->setStatusTip (tr( "Line" ));
insilmaril@0
  1003
	a->setToggleAction(true);
insilmaril@366
  1004
    connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
insilmaril@366
  1005
	formatMenu->addAction (a);
insilmaril@0
  1006
	actionFormatLinkStyleParabel=a;
insilmaril@366
  1007
    a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
insilmaril@366
  1008
	a->setStatusTip (tr( "PolyLine" ));
insilmaril@0
  1009
	a->setToggleAction(true);
insilmaril@366
  1010
    connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
insilmaril@366
  1011
	formatMenu->addAction (a);
insilmaril@0
  1012
	actionFormatLinkStylePolyLine=a;
insilmaril@505
  1013
    a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
insilmaril@366
  1014
	a->setStatusTip (tr( "PolyParabel" ) );
insilmaril@0
  1015
	a->setToggleAction(true);
insilmaril@366
  1016
	a->setChecked (true);
insilmaril@366
  1017
    connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
insilmaril@366
  1018
	formatMenu->addAction (a);
insilmaril@0
  1019
	actionFormatLinkStylePolyParabel=a;
insilmaril@0
  1020
	
insilmaril@395
  1021
    a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
insilmaril@366
  1022
	a->setStatusTip (tr( "Hide link" ));
insilmaril@160
  1023
	a->setToggleAction(true);
insilmaril@366
  1024
    connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
insilmaril@160
  1025
	actionFormatHideLinkUnselected=a;
insilmaril@160
  1026
insilmaril@366
  1027
	formatMenu->addSeparator();
insilmaril@395
  1028
    a= new QAction( tr( "&Use color of heading for link","Branch attribute" ),  this);
insilmaril@366
  1029
	a->setStatusTip (tr( "Use same color for links and headings" ));
insilmaril@0
  1030
	a->setToggleAction(true);
insilmaril@366
  1031
    connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
insilmaril@366
  1032
	formatMenu->addAction (a);
insilmaril@0
  1033
	actionFormatLinkColorHint=a;
insilmaril@366
  1034
insilmaril@366
  1035
    pix.fill (Qt::white);
insilmaril@366
  1036
    a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this  );
insilmaril@366
  1037
	a->setStatusTip (tr( "Set Link Color" ));
insilmaril@366
  1038
	formatMenu->addAction (a);
insilmaril@366
  1039
    connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
insilmaril@366
  1040
    actionFormatLinkColor=a;
insilmaril@366
  1041
insilmaril@442
  1042
    a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this  );
insilmaril@442
  1043
	a->setStatusTip (tr( "Set Selection Color" ));
insilmaril@442
  1044
	formatMenu->addAction (a);
insilmaril@442
  1045
    connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
insilmaril@442
  1046
    actionFormatSelectionColor=a;
insilmaril@442
  1047
insilmaril@366
  1048
    a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
insilmaril@366
  1049
	a->setStatusTip (tr( "Set Background Color" ));
insilmaril@366
  1050
	formatMenu->addAction (a);
insilmaril@366
  1051
    connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
insilmaril@366
  1052
    actionFormatBackColor=a;
insilmaril@408
  1053
insilmaril@408
  1054
    a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
insilmaril@408
  1055
	a->setStatusTip (tr( "Set Background image" ));
insilmaril@408
  1056
	formatMenu->addAction (a);
insilmaril@408
  1057
    connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
insilmaril@408
  1058
    actionFormatBackImage=a;
insilmaril@0
  1059
}
insilmaril@0
  1060
insilmaril@0
  1061
// View Actions
insilmaril@0
  1062
void Main::setupViewActions()
insilmaril@0
  1063
{
insilmaril@395
  1064
    QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
insilmaril@0
  1065
    tb->setLabel( "View Actions" );
insilmaril@366
  1066
	tb->setObjectName ("viewTB");
insilmaril@366
  1067
    QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
insilmaril@0
  1068
insilmaril@0
  1069
    QAction *a;
insilmaril@395
  1070
    a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
insilmaril@366
  1071
	a->setStatusTip ( tr( "Zoom reset" ) );
insilmaril@366
  1072
	a->setShortcut (Qt::CTRL + Qt::Key_0 );
insilmaril@0
  1073
    a->addTo( tb );
insilmaril@366
  1074
	viewMenu->addAction (a);
insilmaril@366
  1075
    connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
insilmaril@366
  1076
	
insilmaril@395
  1077
    a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
insilmaril@366
  1078
	a->setStatusTip (tr( "Zoom in" ));
insilmaril@366
  1079
	a->setShortcut (Qt::CTRL + Qt::Key_Plus);
insilmaril@0
  1080
    a->addTo( tb );
insilmaril@366
  1081
	viewMenu->addAction (a);
insilmaril@366
  1082
    connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
insilmaril@366
  1083
	
insilmaril@395
  1084
    a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
insilmaril@366
  1085
	a->setStatusTip (tr( "Zoom out" ));
insilmaril@366
  1086
	a->setShortcut (Qt::CTRL + Qt::Key_Minus );
insilmaril@0
  1087
    a->addTo( tb );
insilmaril@366
  1088
	viewMenu->addAction (a);
insilmaril@366
  1089
    connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
insilmaril@366
  1090
insilmaril@526
  1091
    a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
insilmaril@526
  1092
	a->setStatusTip (tr( "Show selection" ));
insilmaril@526
  1093
	a->setShortcut (Qt::Key_Period);
insilmaril@526
  1094
    a->addTo( tb );
insilmaril@526
  1095
	viewMenu->addAction (a);
insilmaril@526
  1096
    connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
insilmaril@526
  1097
insilmaril@486
  1098
	viewMenu->addSeparator();	
insilmaril@366
  1099
insilmaril@395
  1100
    a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
insilmaril@366
  1101
	a->setStatusTip ( tr( "Show Note Editor" ));
insilmaril@366
  1102
	a->setShortcut ( Qt::CTRL + Qt::Key_E );
insilmaril@0
  1103
	a->setToggleAction(true);
insilmaril@0
  1104
    a->addTo( tb );
insilmaril@366
  1105
	viewMenu->addAction (a);
insilmaril@366
  1106
    connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
insilmaril@0
  1107
	actionViewToggleNoteEditor=a;
insilmaril@294
  1108
insilmaril@442
  1109
    a = new QAction(QPixmap(iconPath+"history.png"),  tr( "History Window","View action" ),this );
insilmaril@442
  1110
	a->setStatusTip ( tr( "Show History Window" ));
insilmaril@366
  1111
	a->setShortcut ( Qt::CTRL + Qt::Key_H  );
insilmaril@407
  1112
	a->setToggleAction(true);
insilmaril@404
  1113
    a->addTo( tb );
insilmaril@366
  1114
	viewMenu->addAction (a);
insilmaril@366
  1115
    connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
insilmaril@294
  1116
	actionViewToggleHistoryWindow=a;
insilmaril@294
  1117
insilmaril@486
  1118
	viewMenu->addAction (actionViewTogglePropertyWindow);
insilmaril@486
  1119
insilmaril@486
  1120
	viewMenu->addSeparator();	
insilmaril@442
  1121
insilmaril@408
  1122
    a = new QAction(tr( "Antialiasing","View action" ),this );
insilmaril@408
  1123
	a->setStatusTip ( tr( "Antialiasing" ));
insilmaril@408
  1124
	a->setToggleAction(true);
insilmaril@408
  1125
	a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
insilmaril@408
  1126
	viewMenu->addAction (a);
insilmaril@408
  1127
    connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
insilmaril@408
  1128
	actionViewToggleAntiAlias=a;
insilmaril@408
  1129
insilmaril@408
  1130
    a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
insilmaril@408
  1131
	a->setStatusTip (a->text());
insilmaril@408
  1132
	a->setToggleAction(true);
insilmaril@408
  1133
	a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
insilmaril@408
  1134
	viewMenu->addAction (a);
insilmaril@408
  1135
    connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
insilmaril@408
  1136
	actionViewToggleSmoothPixmapTransform=a;
insilmaril@408
  1137
insilmaril@473
  1138
    a = new QAction(tr( "Next Map","View action" ), this);
insilmaril@408
  1139
	a->setStatusTip (a->text());
insilmaril@366
  1140
	a->setShortcut (Qt::ALT + Qt::Key_N );
insilmaril@366
  1141
	viewMenu->addAction (a);
insilmaril@366
  1142
    connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
insilmaril@366
  1143
insilmaril@473
  1144
    a = new QAction (tr( "Previous Map","View action" ), this );
insilmaril@408
  1145
	a->setStatusTip (a->text());
insilmaril@366
  1146
	a->setShortcut (Qt::ALT + Qt::Key_P );
insilmaril@366
  1147
	viewMenu->addAction (a);
insilmaril@366
  1148
    connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
insilmaril@0
  1149
}
insilmaril@0
  1150
insilmaril@89
  1151
// Mode Actions
insilmaril@89
  1152
void Main::setupModeActions()
insilmaril@89
  1153
{
insilmaril@89
  1154
    //QPopupMenu *menu = new QPopupMenu( this );
insilmaril@89
  1155
    //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
insilmaril@89
  1156
insilmaril@395
  1157
    QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
insilmaril@366
  1158
	tb->setObjectName ("modesTB");
insilmaril@89
  1159
    QAction *a;
insilmaril@366
  1160
	actionGroupModModes=new QActionGroup ( this);
insilmaril@89
  1161
	actionGroupModModes->setExclusive (true);
insilmaril@395
  1162
    a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
insilmaril@366
  1163
	a->setShortcut (Qt::Key_J);
insilmaril@366
  1164
    a->setStatusTip ( tr( "Use modifier to color branches" ));
insilmaril@89
  1165
	a->setToggleAction(true);
insilmaril@89
  1166
	a->addTo (tb);
insilmaril@89
  1167
	a->setOn(true);
insilmaril@89
  1168
	actionModModeColor=a;
insilmaril@104
  1169
	
insilmaril@395
  1170
    a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
insilmaril@366
  1171
	a->setShortcut( Qt::Key_K); 
insilmaril@366
  1172
    a->setStatusTip( tr( "Use modifier to copy" ));
insilmaril@104
  1173
	a->setToggleAction(true);
insilmaril@104
  1174
	a->addTo (tb);
insilmaril@104
  1175
	actionModModeCopy=a;
insilmaril@104
  1176
insilmaril@395
  1177
    a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
insilmaril@366
  1178
	a->setShortcut (Qt::Key_L);
insilmaril@366
  1179
    a->setStatusTip( tr( "Use modifier to draw xLinks" ));
insilmaril@89
  1180
	a->setToggleAction(true);
insilmaril@89
  1181
	a->addTo (tb);
insilmaril@390
  1182
	actionModModeXLink=a;
insilmaril@89
  1183
}
insilmaril@89
  1184
insilmaril@0
  1185
// Flag Actions
insilmaril@0
  1186
void Main::setupFlagActions()
insilmaril@0
  1187
{
insilmaril@166
  1188
	// Create System Flags
insilmaril@582
  1189
	QToolBar *tb=NULL;
insilmaril@767
  1190
insilmaril@767
  1191
	Flag *flag=new Flag;;
insilmaril@767
  1192
insilmaril@767
  1193
	flag->load(QPixmap(flagsPath+"flag-note.png"));
insilmaril@767
  1194
	setupFlag (flag,tb,"system-note",tr("Note","SystemFlag"));
insilmaril@767
  1195
insilmaril@767
  1196
	flag->load(QPixmap(flagsPath+"flag-url.png"));
insilmaril@767
  1197
	setupFlag (flag,tb,"system-url",tr("URL to Document ","SystemFlag"));
insilmaril@166
  1198
	
insilmaril@767
  1199
	flag->load(QPixmap(flagsPath+"flag-vymlink.png"));
insilmaril@767
  1200
	setupFlag (flag,tb,"system-vymLink",tr("Link to another vym map","SystemFlag"));
insilmaril@767
  1201
insilmaril@767
  1202
	flag->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
insilmaril@767
  1203
	setupFlag (flag,tb,"system-scrolledright",tr("subtree is scrolled","SystemFlag"));
insilmaril@166
  1204
	
insilmaril@767
  1205
	flag->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
insilmaril@767
  1206
	setupFlag (flag,tb,"system-tmpUnscrolledright",tr("subtree is temporary scrolled","SystemFlag"));
insilmaril@767
  1207
insilmaril@767
  1208
	flag->load(QPixmap(flagsPath+"flag-hideexport.png"));
insilmaril@767
  1209
	setupFlag (flag,tb,"system-hideInExport",tr("Hide object in exported maps","SystemFlag"));
insilmaril@243
  1210
insilmaril@166
  1211
	// Create Standard Flags
insilmaril@582
  1212
	tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
insilmaril@366
  1213
	tb->setObjectName ("standardFlagTB");
insilmaril@366
  1214
insilmaril@166
  1215
	
insilmaril@767
  1216
	flag->load(flagsPath+"flag-exclamationmark.png");
insilmaril@767
  1217
	flag->setGroup("standard-mark");
insilmaril@767
  1218
	setupFlag (flag,tb,"exclamationmark",tr("Take care!","Standardflag"));
insilmaril@767
  1219
	
insilmaril@767
  1220
	flag->load(flagsPath+"flag-questionmark.png");
insilmaril@767
  1221
	flag->setGroup("standard-mark");
insilmaril@767
  1222
	setupFlag (flag,tb,"questionmark",tr("Really?","Standardflag"));
insilmaril@767
  1223
insilmaril@767
  1224
	flag->load(flagsPath+"flag-hook-green.png");
insilmaril@767
  1225
	flag->setGroup("standard-hook");
insilmaril@767
  1226
	setupFlag (flag,tb,"hook-green",tr("ok!","Standardflag"));
insilmaril@767
  1227
insilmaril@767
  1228
	flag->load(flagsPath+"flag-cross-red.png");
insilmaril@767
  1229
	flag->setGroup("standard-hook");
insilmaril@767
  1230
	setupFlag (flag,tb,"cross-red",tr("Not ok!","Standardflag"));
insilmaril@767
  1231
	flag->unsetGroup();
insilmaril@767
  1232
insilmaril@767
  1233
	flag->load(flagsPath+"flag-stopsign.png");
insilmaril@767
  1234
	setupFlag (flag,tb,"stopsign",tr("This won't work!","Standardflag"));
insilmaril@767
  1235
insilmaril@767
  1236
	flag->load(flagsPath+"flag-smiley-good.png");
insilmaril@767
  1237
	flag->setGroup("standard-smiley");
insilmaril@767
  1238
	setupFlag (flag,tb,"smiley-good",tr("Good","Standardflag"));
insilmaril@767
  1239
insilmaril@767
  1240
	flag->load(flagsPath+"flag-smiley-sad.png");
insilmaril@767
  1241
	flag->setGroup("standard-smiley");
insilmaril@767
  1242
	setupFlag (flag,tb,"smiley-sad",tr("Bad","Standardflag"));
insilmaril@767
  1243
insilmaril@767
  1244
	flag->load(flagsPath+"flag-smiley-omg.png");
insilmaril@767
  1245
	flag->setGroup("standard-smiley");
insilmaril@767
  1246
	setupFlag (flag,tb,"smiley-omb",tr("Oh no!","Standardflag"));
insilmaril@269
  1247
	// Original omg.png (in KDE emoticons)
insilmaril@767
  1248
	flag->unsetGroup();
insilmaril@767
  1249
insilmaril@767
  1250
	flag->load(flagsPath+"flag-kalarm.png");
insilmaril@767
  1251
	setupFlag (flag,tb,"clock",tr("Time critical","Standardflag"));
insilmaril@767
  1252
insilmaril@767
  1253
	flag->load(flagsPath+"flag-phone.png");
insilmaril@767
  1254
	setupFlag (flag,tb,"phone",tr("Call...","Standardflag"));
insilmaril@767
  1255
insilmaril@767
  1256
	flag->load(flagsPath+"flag-lamp.png");
insilmaril@767
  1257
	setupFlag (flag,tb,"lamp",tr("Idea!","Standardflag"));
insilmaril@767
  1258
insilmaril@767
  1259
	flag->load(flagsPath+"flag-arrow-up.png");
insilmaril@767
  1260
	flag->setGroup("standard-arrow");
insilmaril@767
  1261
	setupFlag (flag,tb,"arrow-up",tr("Important","Standardflag"));
insilmaril@767
  1262
insilmaril@767
  1263
	flag->load(flagsPath+"flag-arrow-down.png");
insilmaril@767
  1264
	flag->setGroup("standard-arrow");
insilmaril@767
  1265
	setupFlag (flag,tb,"arrow-down",tr("Unimportant","Standardflag"));
insilmaril@767
  1266
insilmaril@767
  1267
	flag->load(flagsPath+"flag-arrow-2up.png");
insilmaril@767
  1268
	flag->setGroup("standard-arrow");
insilmaril@767
  1269
	setupFlag (flag,tb,"2arrow-up",tr("Very important!","Standardflag"));
insilmaril@767
  1270
insilmaril@767
  1271
	flag->load(flagsPath+"flag-arrow-2down.png");
insilmaril@767
  1272
	flag->setGroup("standard-arrow");
insilmaril@767
  1273
	setupFlag (flag,tb,"2arrow-down",tr("Very unimportant!","Standardflag"));
insilmaril@767
  1274
	flag->unsetGroup();
insilmaril@767
  1275
insilmaril@767
  1276
	flag->load(flagsPath+"flag-thumb-up.png");
insilmaril@767
  1277
	flag->setGroup("standard-thumb");
insilmaril@767
  1278
	setupFlag (flag,tb,"thumb-up",tr("I like this","Standardflag"));
insilmaril@767
  1279
insilmaril@767
  1280
	flag->load(flagsPath+"flag-thumb-down.png");
insilmaril@767
  1281
	flag->setGroup("standard-thumb");
insilmaril@767
  1282
	setupFlag (flag,tb,"thumb-down",tr("I do not like this","Standardflag"));
insilmaril@767
  1283
	flag->unsetGroup();
insilmaril@166
  1284
	
insilmaril@767
  1285
	flag->load(flagsPath+"flag-rose.png");
insilmaril@767
  1286
	setupFlag (flag,tb,"rose",tr("Rose","Standardflag"));
insilmaril@767
  1287
insilmaril@767
  1288
	flag->load(flagsPath+"flag-heart.png");
insilmaril@767
  1289
	setupFlag (flag,tb,"heart",tr("I just love...","Standardflag"));
insilmaril@767
  1290
insilmaril@767
  1291
	flag->load(flagsPath+"flag-present.png");
insilmaril@767
  1292
	setupFlag (flag,tb,"present",tr("Surprise!","Standardflag"));
insilmaril@767
  1293
insilmaril@767
  1294
	flag->load(flagsPath+"flag-flash.png");
insilmaril@767
  1295
	setupFlag (flag,tb,"flash",tr("Dangerous","Standardflag"));
insilmaril@564
  1296
	
insilmaril@564
  1297
	// Original: xsldbg_output.png
insilmaril@767
  1298
	flag->load(flagsPath+"flag-info.png");
insilmaril@767
  1299
	setupFlag (flag,tb,"inflag",tr("Info","Standardflag"));
insilmaril@564
  1300
insilmaril@564
  1301
	// Original khelpcenter.png
insilmaril@767
  1302
	flag->load(flagsPath+"flag-lifebelt.png");
insilmaril@767
  1303
	setupFlag (flag,tb,"lifebelt",tr("This will help","Standardflag"));
insilmaril@564
  1304
insilmaril@564
  1305
	// Freemind flags
insilmaril@564
  1306
insilmaril@767
  1307
	flag->load(flagsPath+"freemind/warning.png");
insilmaril@767
  1308
	setupFlag (flag,tb,  "freemind-warning",tr("Important","Freemind-Flag"));
insilmaril@564
  1309
insilmaril@564
  1310
	for (int i=1; i<8; i++)
insilmaril@564
  1311
	{
insilmaril@767
  1312
		flag->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
insilmaril@767
  1313
		setupFlag (flag,tb, QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
insilmaril@564
  1314
	}
insilmaril@564
  1315
insilmaril@767
  1316
	flag->load(flagsPath+"freemind/back.png");
insilmaril@767
  1317
	setupFlag (flag,tb,"freemind-back",tr("Back","Freemind-Flag"));
insilmaril@767
  1318
insilmaril@767
  1319
	flag->load(flagsPath+"freemind/forward.png");
insilmaril@767
  1320
	setupFlag (flag,tb,"freemind-forward",tr("forward","Freemind-Flag"));
insilmaril@767
  1321
insilmaril@767
  1322
	flag->load(flagsPath+"freemind/attach.png");
insilmaril@767
  1323
	setupFlag (flag,tb,"freemind-attach",tr("Look here","Freemind-Flag"));
insilmaril@767
  1324
insilmaril@767
  1325
	flag->load(flagsPath+"freemind/clanbomber.png");
insilmaril@767
  1326
	setupFlag (flag,tb,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
insilmaril@767
  1327
insilmaril@767
  1328
	flag->load(flagsPath+"freemind/desktopnew.png");
insilmaril@767
  1329
	setupFlag (flag,tb,"freemind-desktopnew",tr("Don't flagrget","Freemind-Flag"));
insilmaril@767
  1330
insilmaril@767
  1331
	flag->load(flagsPath+"freemind/flag.png");
insilmaril@767
  1332
	setupFlag (flag,tb,"freemind-flag",tr("Flag","Freemind-Flag"));
insilmaril@767
  1333
insilmaril@767
  1334
insilmaril@767
  1335
	flag->load(flagsPath+"freemind/gohome.png");
insilmaril@767
  1336
	setupFlag (flag,tb,"freemind-gohome",tr("Home","Freemind-Flag"));
insilmaril@767
  1337
insilmaril@767
  1338
insilmaril@767
  1339
	flag->load(flagsPath+"freemind/kaddressbook.png");
insilmaril@767
  1340
	setupFlag (flag,tb,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
insilmaril@767
  1341
insilmaril@767
  1342
	flag->load(flagsPath+"freemind/knotify.png");
insilmaril@767
  1343
	setupFlag (flag,tb,"freemind-knotify",tr("Music","Freemind-Flag"));
insilmaril@767
  1344
insilmaril@767
  1345
	flag->load(flagsPath+"freemind/korn.png");
insilmaril@767
  1346
	setupFlag (flag,tb,"freemind-korn",tr("Mailbox","Freemind-Flag"));
insilmaril@767
  1347
insilmaril@767
  1348
	flag->load(flagsPath+"freemind/mail.png");
insilmaril@767
  1349
	setupFlag (flag,tb,"freemind-mail",tr("Maix","Freemind-Flag"));
insilmaril@767
  1350
insilmaril@767
  1351
	flag->load(flagsPath+"freemind/password.png");
insilmaril@767
  1352
	setupFlag (flag,tb,"freemind-password",tr("Password","Freemind-Flag"));
insilmaril@767
  1353
insilmaril@767
  1354
	flag->load(flagsPath+"freemind/pencil.png");
insilmaril@767
  1355
	setupFlag (flag,tb,"freemind-pencil",tr("To be improved","Freemind-Flag"));
insilmaril@767
  1356
insilmaril@767
  1357
	flag->load(flagsPath+"freemind/stop.png");
insilmaril@767
  1358
	setupFlag (flag,tb,"freemind-stop",tr("Stop","Freemind-Flag"));
insilmaril@767
  1359
insilmaril@767
  1360
	flag->load(flagsPath+"freemind/wizard.png");
insilmaril@767
  1361
	setupFlag (flag,tb,"freemind-wizard",tr("Magic","Freemind-Flag"));
insilmaril@767
  1362
insilmaril@767
  1363
	flag->load(flagsPath+"freemind/xmag.png");
insilmaril@767
  1364
	setupFlag (flag,tb,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
insilmaril@767
  1365
insilmaril@767
  1366
	flag->load(flagsPath+"freemind/bell.png");
insilmaril@767
  1367
	setupFlag (flag,tb,"freemind-bell",tr("Reminder","Freemind-Flag"));
insilmaril@767
  1368
insilmaril@767
  1369
	flag->load(flagsPath+"freemind/bookmark.png");
insilmaril@767
  1370
	setupFlag (flag,tb,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
insilmaril@767
  1371
insilmaril@767
  1372
	flag->load(flagsPath+"freemind/penguin.png");
insilmaril@767
  1373
	setupFlag (flag,tb,"freemind-penguin",tr("Linux","Freemind-Flag"));
insilmaril@767
  1374
insilmaril@767
  1375
	flag->load(flagsPath+"freemind/licq.png");
insilmaril@767
  1376
	setupFlag (flag,tb,"freemind-licq",tr("Sweet","Freemind-Flag"));
insilmaril@564
  1377
}
insilmaril@564
  1378
insilmaril@767
  1379
void Main::setupFlag (Flag *flag, QToolBar *tb, const QString &name, const QString &tooltip)
insilmaril@564
  1380
{
insilmaril@767
  1381
	flag->setName(name);
insilmaril@767
  1382
	flag->setToolTip (tooltip);
insilmaril@767
  1383
	QAction *a;
insilmaril@582
  1384
	if (tb)
insilmaril@582
  1385
	{
insilmaril@767
  1386
		a=new QAction (flag->getPixmap(),name,this);
insilmaril@582
  1387
		// StandardFlag
insilmaril@582
  1388
		tb->addAction (a);
insilmaril@582
  1389
		a->setCheckable(true);
insilmaril@767
  1390
		a->setObjectName(name);
insilmaril@582
  1391
		a->setToolTip(tooltip);
insilmaril@582
  1392
		connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
insilmaril@767
  1393
		standardFlagsMaster->addFlag (flag);	
insilmaril@582
  1394
	} else
insilmaril@582
  1395
	{
insilmaril@582
  1396
		// SystemFlag
insilmaril@767
  1397
		systemFlagsMaster->addFlag (flag);	
insilmaril@582
  1398
	}
insilmaril@0
  1399
}
insilmaril@767
  1400
insilmaril@528
  1401
// Network Actions
insilmaril@528
  1402
void Main::setupNetworkActions()
insilmaril@528
  1403
{
insilmaril@528
  1404
	if (!settings.value( "/mainwindow/showTestMenu",false).toBool() ) 
insilmaril@528
  1405
		return;
insilmaril@635
  1406
    QMenu *netMenu = menuBar()->addMenu(  "Network" );
insilmaril@528
  1407
insilmaril@528
  1408
	QAction *a;
insilmaril@528
  1409
insilmaril@528
  1410
    a = new QAction(  "Start TCPserver for MapEditor",this);
insilmaril@528
  1411
    //a->setStatusTip ( "Set application to open pdf files"));
insilmaril@528
  1412
	a->setShortcut ( Qt::Key_T );		//New TCP server
insilmaril@528
  1413
    connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
insilmaril@528
  1414
	netMenu->addAction (a);
insilmaril@528
  1415
insilmaril@528
  1416
    a = new QAction(  "Connect MapEditor to server",this);
insilmaril@528
  1417
    //a->setStatusTip ( "Set application to open pdf files"));
insilmaril@528
  1418
	a->setShortcut ( Qt::Key_C );		// Connect to server
insilmaril@528
  1419
    connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
insilmaril@528
  1420
	netMenu->addAction (a);
insilmaril@528
  1421
}
insilmaril@528
  1422
	
insilmaril@0
  1423
// Settings Actions
insilmaril@0
  1424
void Main::setupSettingsActions()
insilmaril@0
  1425
{
insilmaril@366
  1426
    QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
insilmaril@0
  1427
insilmaril@0
  1428
	QAction *a;
insilmaril@0
  1429
insilmaril@395
  1430
    a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
insilmaril@366
  1431
    a->setStatusTip ( tr( "Set application to open pdf files"));
insilmaril@366
  1432
    connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
insilmaril@366
  1433
	settingsMenu->addAction (a);
insilmaril@366
  1434
insilmaril@395
  1435
    a = new QAction( tr( "Set application to open external links","Settings action"), this);
insilmaril@366
  1436
    a->setStatusTip( tr( "Set application to open external links"));
insilmaril@366
  1437
    connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
insilmaril@366
  1438
	settingsMenu->addAction (a);
insilmaril@366
  1439
insilmaril@473
  1440
    a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
insilmaril@450
  1441
    a->setStatusTip( tr( "Set path for macros"));
insilmaril@450
  1442
    connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
insilmaril@450
  1443
	settingsMenu->addAction (a);
insilmaril@450
  1444
insilmaril@473
  1445
    a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
insilmaril@473
  1446
    a->setStatusTip( tr( "Set number of undo levels"));
insilmaril@473
  1447
    connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
insilmaril@473
  1448
	settingsMenu->addAction (a);
insilmaril@473
  1449
insilmaril@366
  1450
	settingsMenu->addSeparator();
insilmaril@473
  1451
insilmaril@473
  1452
    a = new QAction( tr( "Autosave","Settings action"), this);
insilmaril@473
  1453
    a->setStatusTip( tr( "Autosave"));
insilmaril@473
  1454
	a->setToggleAction(true);
insilmaril@742
  1455
	a->setOn ( settings.value ("/mainwindow/autosave/use",false).toBool());
insilmaril@473
  1456
    connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
insilmaril@473
  1457
	settingsMenu->addAction (a);
insilmaril@473
  1458
	actionSettingsAutosaveToggle=a;
insilmaril@473
  1459
insilmaril@473
  1460
    a = new QAction( tr( "Autosave time","Settings action")+"...", this);
insilmaril@473
  1461
    a->setStatusTip( tr( "Autosave time"));
insilmaril@473
  1462
    connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
insilmaril@473
  1463
	settingsMenu->addAction (a);
insilmaril@473
  1464
	actionSettingsAutosaveTime=a;
insilmaril@473
  1465
insilmaril@628
  1466
    a = new QAction( tr( "Write backup file on save","Settings action"), this);
insilmaril@628
  1467
    a->setStatusTip( tr( "Write backup file on save"));
insilmaril@625
  1468
	a->setToggleAction(true);
insilmaril@625
  1469
	a->setOn ( settings.value ("/mainwindow/writeBackupFile",false).toBool());
insilmaril@625
  1470
    connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) );
insilmaril@625
  1471
	settingsMenu->addAction (a);
insilmaril@625
  1472
	actionSettingsWriteBackupFile=a;
insilmaril@625
  1473
insilmaril@473
  1474
	settingsMenu->addSeparator();
insilmaril@473
  1475
insilmaril@395
  1476
    a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
insilmaril@366
  1477
    a->setStatusTip( tr( "Edit branch after adding it" ));
insilmaril@0
  1478
	a->setToggleAction(true);
insilmaril@537
  1479
	a->setOn ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
insilmaril@366
  1480
	settingsMenu->addAction (a);
insilmaril@537
  1481
	actionSettingsAutoEditNewBranch=a;
insilmaril@0
  1482
insilmaril@395
  1483
    a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
insilmaril@366
  1484
    a->setStatusTip( tr( "Select branch after adding it" ));
insilmaril@0
  1485
	a->setToggleAction(true);
insilmaril@537
  1486
	a->setOn ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
insilmaril@366
  1487
	settingsMenu->addAction (a);
insilmaril@537
  1488
	actionSettingsAutoSelectNewBranch=a;
insilmaril@0
  1489
	
insilmaril@395
  1490
    a= new QAction(tr( "Select existing heading","Settings action" ), this);
insilmaril@366
  1491
    a->setStatusTip( tr( "Select heading before editing" ));
insilmaril@0
  1492
	a->setToggleAction(true);
insilmaril@366
  1493
	a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
insilmaril@366
  1494
	settingsMenu->addAction (a);
insilmaril@390
  1495
	actionSettingsAutoSelectText=a;
insilmaril@0
  1496
	
insilmaril@395
  1497
    a= new QAction( tr( "Delete key","Settings action" ), this);
insilmaril@366
  1498
    a->setStatusTip( tr( "Delete key for deleting branches" ));
insilmaril@0
  1499
	a->setToggleAction(true);
insilmaril@505
  1500
	a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
insilmaril@366
  1501
	settingsMenu->addAction (a);
insilmaril@366
  1502
    connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
insilmaril@366
  1503
	actionSettingsUseDelKey=a;
insilmaril@366
  1504
insilmaril@395
  1505
    a= new QAction( tr( "Exclusive flags","Settings action" ), this);
insilmaril@366
  1506
    a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
insilmaril@0
  1507
	a->setToggleAction(true);
insilmaril@366
  1508
	a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
insilmaril@366
  1509
	settingsMenu->addAction (a);
insilmaril@103
  1510
	actionSettingsUseFlagGroups=a;
insilmaril@260
  1511
	
insilmaril@395
  1512
    a= new QAction( tr( "Use hide flags","Settings action" ), this);
insilmaril@366
  1513
    a->setStatusTip( tr( "Use hide flag during exports " ));
insilmaril@260
  1514
	a->setToggleAction(true);
insilmaril@366
  1515
	a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
insilmaril@366
  1516
	settingsMenu->addAction (a);
insilmaril@260
  1517
	actionSettingsUseHideExport=a;
insilmaril@689
  1518
insilmaril@689
  1519
    a = new QAction( tr( "Animation","Settings action"), this);
insilmaril@689
  1520
    a->setStatusTip( tr( "Animation"));
insilmaril@689
  1521
	a->setToggleAction(true);
insilmaril@689
  1522
	a->setOn (settings.value("/animation/use",false).toBool() );
insilmaril@689
  1523
    connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) );
insilmaril@689
  1524
	if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
insilmaril@689
  1525
	{
insilmaril@689
  1526
		settingsMenu->addAction (a);
insilmaril@689
  1527
	}	
insilmaril@689
  1528
	actionSettingsUseAnimation=a;
insilmaril@0
  1529
}
insilmaril@0
  1530
insilmaril@0
  1531
// Test Actions
insilmaril@0
  1532
void Main::setupTestActions()
insilmaril@0
  1533
{
insilmaril@366
  1534
    QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
insilmaril@0
  1535
insilmaril@0
  1536
    QAction *a;
insilmaril@527
  1537
    a = new QAction( "Test function 1" , this);
insilmaril@527
  1538
    a->setStatusTip( "Call test function 1" );
insilmaril@527
  1539
	testMenu->addAction (a);
insilmaril@527
  1540
    connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
insilmaril@527
  1541
insilmaril@527
  1542
    a = new QAction( "Test function 2" , this);
insilmaril@527
  1543
    a->setStatusTip( "Call test function 2" );
insilmaril@366
  1544
	testMenu->addAction (a);
insilmaril@527
  1545
    connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
insilmaril@527
  1546
insilmaril@395
  1547
    a = new QAction( "Command" , this);
insilmaril@395
  1548
    a->setStatusTip( "Enter command to call in editor" );
insilmaril@393
  1549
    connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
insilmaril@393
  1550
	testMenu->addAction (a);
insilmaril@0
  1551
}
insilmaril@0
  1552
insilmaril@0
  1553
// Help Actions
insilmaril@0
  1554
void Main::setupHelpActions()
insilmaril@0
  1555
{
insilmaril@395
  1556
    QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
insilmaril@0
  1557
insilmaril@0
  1558
    QAction *a;
insilmaril@395
  1559
    a = new QAction(  tr( "Open VYM Documentation (pdf) ","Help action" ), this );
insilmaril@366
  1560
    a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
insilmaril@366
  1561
    connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
insilmaril@366
  1562
	helpMenu->addAction (a);
insilmaril@366
  1563
insilmaril@505
  1564
    a = new QAction(  tr( "Open VYM example maps ","Help action" ), this );
insilmaril@505
  1565
    a->setStatusTip( tr( "Open VYM example maps " ));
insilmaril@505
  1566
    connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
insilmaril@505
  1567
	helpMenu->addAction (a);
insilmaril@505
  1568
insilmaril@395
  1569
    a = new QAction( tr( "About VYM","Help action" ), this);
insilmaril@404
  1570
    a->setStatusTip( tr( "About VYM")+vymName);
insilmaril@366
  1571
    connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
insilmaril@366
  1572
	helpMenu->addAction (a);
insilmaril@366
  1573
insilmaril@395
  1574
    a = new QAction( tr( "About QT","Help action" ), this);
insilmaril@366
  1575
    a->setStatusTip( tr( "Information about QT toolkit" ));
insilmaril@366
  1576
    connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
insilmaril@366
  1577
	helpMenu->addAction (a);
insilmaril@0
  1578
}
insilmaril@0
  1579
insilmaril@0
  1580
// Context Menus
insilmaril@0
  1581
void Main::setupContextMenus()
insilmaril@0
  1582
{
insilmaril@0
  1583
	QAction*a;
insilmaril@0
  1584
insilmaril@0
  1585
	// Context Menu for branch or mapcenter
insilmaril@366
  1586
	branchContextMenu =new QMenu (this);
insilmaril@486
  1587
	branchContextMenu->addAction (actionViewTogglePropertyWindow);
insilmaril@421
  1588
	branchContextMenu->addSeparator();	
insilmaril@421
  1589
insilmaril@98
  1590
		// Submenu "Add"
insilmaril@366
  1591
		branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
insilmaril@723
  1592
		branchAddContextMenu->addAction (actionPaste );
insilmaril@753
  1593
		branchAddContextMenu->addAction ( actionAddMapCenter );
insilmaril@723
  1594
		branchAddContextMenu->addAction ( actionAddBranch );
insilmaril@723
  1595
		branchAddContextMenu->addAction ( actionAddBranchBefore );
insilmaril@723
  1596
		branchAddContextMenu->addAction ( actionAddBranchAbove);
insilmaril@723
  1597
		branchAddContextMenu->addAction ( actionAddBranchBelow );
insilmaril@366
  1598
		branchAddContextMenu->addSeparator();	
insilmaril@723
  1599
		branchAddContextMenu->addAction ( actionImportAdd );
insilmaril@723
  1600
		branchAddContextMenu->addAction ( actionImportReplace );
insilmaril@98
  1601
insilmaril@98
  1602
		// Submenu "Remove"
insilmaril@395
  1603
		branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
insilmaril@723
  1604
		branchRemoveContextMenu->addAction (actionCut);
insilmaril@723
  1605
		branchRemoveContextMenu->addAction ( actionDelete );
insilmaril@723
  1606
		branchRemoveContextMenu->addAction ( actionDeleteKeepChildren );
insilmaril@723
  1607
		branchRemoveContextMenu->addAction ( actionDeleteChildren );
insilmaril@98
  1608
		
insilmaril@98
  1609
insilmaril@723
  1610
	actionSaveBranch->addTo( branchContextMenu );
insilmaril@689
  1611
	actionFileNewCopy->addTo (branchContextMenu );
insilmaril@98
  1612
insilmaril@366
  1613
	branchContextMenu->addSeparator();	
insilmaril@723
  1614
	branchContextMenu->addAction ( actionLoadImage);
insilmaril@366
  1615
insilmaril@366
  1616
	// Submenu for Links (URLs, vymLinks)
insilmaril@366
  1617
	branchLinksContextMenu =new QMenu (this);
insilmaril@366
  1618
insilmaril@366
  1619
		branchContextMenu->addSeparator();	
insilmaril@473
  1620
		branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));	
insilmaril@723
  1621
		branchLinksContextMenu->addAction ( actionOpenURL );
insilmaril@723
  1622
		branchLinksContextMenu->addAction ( actionOpenURLTab );
insilmaril@723
  1623
		branchLinksContextMenu->addAction ( actionOpenMultipleURLTabs );
insilmaril@723
  1624
		branchLinksContextMenu->addAction ( actionURL );
insilmaril@723
  1625
		branchLinksContextMenu->addAction ( actionLocalURL );
insilmaril@723
  1626
		branchLinksContextMenu->addAction ( actionHeading2URL );
insilmaril@723
  1627
		branchLinksContextMenu->addAction ( actionBugzilla2URL );
insilmaril@528
  1628
		if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
insilmaril@366
  1629
		{
insilmaril@723
  1630
			branchLinksContextMenu->addAction ( actionFATE2URL );
insilmaril@366
  1631
		}	
insilmaril@366
  1632
		branchLinksContextMenu->addSeparator();	
insilmaril@723
  1633
		branchLinksContextMenu->addAction ( actionOpenVymLink );
insilmaril@723
  1634
		branchLinksContextMenu->addAction ( actionOpenMultipleVymLinks );
insilmaril@723
  1635
		branchLinksContextMenu->addAction ( actionVymLink );
insilmaril@723
  1636
		branchLinksContextMenu->addAction ( actionDeleteVymLink );
insilmaril@366
  1637
		
insilmaril@366
  1638
insilmaril@366
  1639
	// Context Menu for XLinks in a branch menu
insilmaril@89
  1640
	// This will be populated "on demand" in MapEditor::updateActions
insilmaril@366
  1641
	branchContextMenu->addSeparator();	
insilmaril@395
  1642
	branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
insilmaril@395
  1643
	branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
insilmaril@366
  1644
	connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
insilmaril@366
  1645
	connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
insilmaril@366
  1646
 	
insilmaril@105
  1647
	
insilmaril@0
  1648
	// Context menu for floatimage
insilmaril@366
  1649
	floatimageContextMenu =new QMenu (this);
insilmaril@395
  1650
	a= new QAction (tr ("Save image","Context action"),this);
insilmaril@366
  1651
	connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
insilmaril@366
  1652
	floatimageContextMenu->addAction (a);
insilmaril@366
  1653
insilmaril@366
  1654
	floatimageContextMenu->addSeparator();	
insilmaril@723
  1655
	actionCopy->addTo( floatimageContextMenu );
insilmaril@723
  1656
	actionCut->addTo( floatimageContextMenu );
insilmaril@0
  1657
insilmaril@366
  1658
	floatimageContextMenu->addSeparator();	
insilmaril@366
  1659
	floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
insilmaril@366
  1660
insilmaril@0
  1661
	
insilmaril@0
  1662
	// Context menu for canvas
insilmaril@366
  1663
	canvasContextMenu =new QMenu (this);
insilmaril@753
  1664
	actionAddMapCenter->addTo( canvasContextMenu );
insilmaril@723
  1665
	actionMapInfo->addTo( canvasContextMenu );
insilmaril@0
  1666
	canvasContextMenu->insertSeparator();	
insilmaril@0
  1667
	actionGroupFormatLinkStyles->addTo( canvasContextMenu );
insilmaril@0
  1668
	canvasContextMenu->insertSeparator();	
insilmaril@0
  1669
	actionFormatLinkColorHint->addTo( canvasContextMenu );
insilmaril@0
  1670
	actionFormatLinkColor->addTo( canvasContextMenu );
insilmaril@442
  1671
	actionFormatSelectionColor->addTo( canvasContextMenu );
insilmaril@0
  1672
	actionFormatBackColor->addTo( canvasContextMenu );
insilmaril@746
  1673
	// actionFormatBackImage->addTo( canvasContextMenu );  //FIXME-4 makes vym too slow: postponed for later version 
insilmaril@0
  1674
insilmaril@0
  1675
	// Menu for last opened files
insilmaril@401
  1676
	// Create actions
insilmaril@401
  1677
	for (int i = 0; i < MaxRecentFiles; ++i) 
insilmaril@0
  1678
	{
insilmaril@445
  1679
        recentFileActions[i] = new QAction(this);
insilmaril@445
  1680
        recentFileActions[i]->setVisible(false);
insilmaril@445
  1681
        fileLastMapsMenu->addAction(recentFileActions[i]);
insilmaril@445
  1682
        connect(recentFileActions[i], SIGNAL(triggered()),
insilmaril@401
  1683
                this, SLOT(fileLoadRecent()));
insilmaril@401
  1684
    }
insilmaril@401
  1685
	setupRecentMapsMenu();
insilmaril@0
  1686
}
insilmaril@0
  1687
insilmaril@401
  1688
void Main::setupRecentMapsMenu()
insilmaril@0
  1689
{
insilmaril@401
  1690
    QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
insilmaril@401
  1691
insilmaril@401
  1692
    int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
insilmaril@401
  1693
insilmaril@401
  1694
    for (int i = 0; i < numRecentFiles; ++i) {
insilmaril@401
  1695
        QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
insilmaril@445
  1696
        recentFileActions[i]->setText(text);
insilmaril@445
  1697
        recentFileActions[i]->setData(files[i]);
insilmaril@445
  1698
        recentFileActions[i]->setVisible(true);
insilmaril@401
  1699
    }
insilmaril@401
  1700
    for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
insilmaril@445
  1701
        recentFileActions[j]->setVisible(false);
insilmaril@445
  1702
}
insilmaril@445
  1703
insilmaril@445
  1704
void Main::setupMacros()
insilmaril@445
  1705
{
insilmaril@445
  1706
    for (int i = 0; i <= 11; i++) 
insilmaril@445
  1707
	{
insilmaril@445
  1708
        macroActions[i] = new QAction(this);
insilmaril@445
  1709
        macroActions[i]->setData(i);
insilmaril@445
  1710
        addAction (macroActions[i]);
insilmaril@445
  1711
        connect(macroActions[i], SIGNAL(triggered()),
insilmaril@445
  1712
                this, SLOT(callMacro()));
insilmaril@445
  1713
	}			
insilmaril@445
  1714
	macroActions[0]->setShortcut ( Qt::Key_F1 );
insilmaril@445
  1715
	macroActions[1]->setShortcut ( Qt::Key_F2 );
insilmaril@445
  1716
	macroActions[2]->setShortcut ( Qt::Key_F3 );
insilmaril@445
  1717
	macroActions[3]->setShortcut ( Qt::Key_F4 );
insilmaril@445
  1718
	macroActions[4]->setShortcut ( Qt::Key_F5 );
insilmaril@445
  1719
	macroActions[5]->setShortcut ( Qt::Key_F6 );
insilmaril@445
  1720
	macroActions[6]->setShortcut ( Qt::Key_F7 );
insilmaril@445
  1721
	macroActions[7]->setShortcut ( Qt::Key_F8 );
insilmaril@445
  1722
	macroActions[8]->setShortcut ( Qt::Key_F9 );
insilmaril@445
  1723
	macroActions[9]->setShortcut ( Qt::Key_F10 );
insilmaril@445
  1724
	macroActions[10]->setShortcut ( Qt::Key_F11 );
insilmaril@445
  1725
	macroActions[11]->setShortcut ( Qt::Key_F12 );
insilmaril@0
  1726
}
insilmaril@0
  1727
insilmaril@0
  1728
void Main::hideEvent (QHideEvent * )
insilmaril@0
  1729
{
insilmaril@0
  1730
	if (!textEditor->isMinimized() ) textEditor->hide();
insilmaril@0
  1731
}
insilmaril@0
  1732
insilmaril@0
  1733
void Main::showEvent (QShowEvent * )
insilmaril@0
  1734
{
insilmaril@491
  1735
	if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
insilmaril@0
  1736
}
insilmaril@0
  1737
insilmaril@0
  1738
insilmaril@0
  1739
MapEditor* Main::currentMapEditor() const
insilmaril@0
  1740
{
insilmaril@725
  1741
    if ( tabWidget->currentPage())
insilmaril@725
  1742
		return tabModel.at(tabWidget->currentIndex())->getMapEditor();
insilmaril@0
  1743
    return NULL;	
insilmaril@0
  1744
}
insilmaril@0
  1745
insilmaril@721
  1746
VymModel* Main::currentModel() const
insilmaril@721
  1747
{
insilmaril@725
  1748
    if ( tabWidget->currentPage())
insilmaril@725
  1749
		return tabModel.at(tabWidget->currentIndex());
insilmaril@725
  1750
    return NULL;	
insilmaril@721
  1751
}
insilmaril@721
  1752
insilmaril@0
  1753
insilmaril@0
  1754
void Main::editorChanged(QWidget *)
insilmaril@0
  1755
{
insilmaril@0
  1756
	// Unselect all possibly selected objects
insilmaril@0
  1757
	// (Important to update note editor)
insilmaril@473
  1758
	for (int i=0;i<=tabWidget->count() -1;i++)
insilmaril@0
  1759
	{
insilmaril@725
  1760
		tabModel.at(i)->unselect();
insilmaril@0
  1761
	}	
insilmaril@724
  1762
	VymModel *m=currentModel();
insilmaril@724
  1763
	if (m) m->reselect();
insilmaril@0
  1764
insilmaril@0
  1765
	// Update actions to in menus and toolbars according to editor
insilmaril@407
  1766
	updateActions();
insilmaril@0
  1767
}
insilmaril@0
  1768
insilmaril@725
  1769
VymView *Main::createView (VymModel *model)
insilmaril@725
  1770
{
insilmaril@726
  1771
	VymView *vm=new VymView (model);
insilmaril@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@763
  1782
	tabWidget->addTab (createView (m),tr("unnamed","MainWindow: name for new and empty file"));
insilmaril@725
  1783
	tabWidget->setCurrentIndex (tabModel.count() );
insilmaril@408
  1784
	
insilmaril@366
  1785
	// For the very first map we do not have flagrows yet...
insilmaril@724
  1786
	m->select("mc:");
insilmaril@0
  1787
}
insilmaril@0
  1788
insilmaril@491
  1789
void Main::fileNewCopy()
insilmaril@491
  1790
{
insilmaril@491
  1791
	QString fn="unnamed";
insilmaril@725
  1792
	VymModel *srcModel=currentModel();
insilmaril@725
  1793
	if (srcModel)
insilmaril@491
  1794
	{
insilmaril@725
  1795
		srcModel->copy();
insilmaril@725
  1796
		fileNew();
insilmaril@725
  1797
		VymModel *dstModel=tabModel.last ();
insilmaril@725
  1798
		dstModel->select("mc:");
insilmaril@725
  1799
		dstModel->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
insilmaril@491
  1800
	}
insilmaril@491
  1801
}
insilmaril@491
  1802
insilmaril@571
  1803
ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
insilmaril@0
  1804
{
insilmaril@205
  1805
	ErrorCode err=success;
insilmaril@0
  1806
	
insilmaril@0
  1807
	// fn is usually the archive, mapfile the file after uncompressing
insilmaril@0
  1808
	QString mapfile;
insilmaril@0
  1809
insilmaril@0
  1810
	// Make fn absolute (needed for unzip)
insilmaril@0
  1811
	fn=QDir (fn).absPath();
insilmaril@0
  1812
insilmaril@727
  1813
	VymModel *vm;
insilmaril@0
  1814
insilmaril@0
  1815
	if (lmode==NewMap)
insilmaril@0
  1816
	{
insilmaril@0
  1817
		// Check, if map is already loaded
insilmaril@0
  1818
		int i=0;
insilmaril@0
  1819
		while (i<=tabWidget->count() -1)
insilmaril@0
  1820
		{
insilmaril@725
  1821
			if (tabModel.at(i)->getFilePath() == fn)
insilmaril@0
  1822
			{
insilmaril@0
  1823
				// Already there, ask for confirmation
insilmaril@404
  1824
				QMessageBox mb( vymName,
insilmaril@159
  1825
					tr("The map %1\nis already opened."
insilmaril@0
  1826
					"Opening the same map in multiple editors may lead \n"
insilmaril@0
  1827
					"to confusion when finishing working with vym."
insilmaril@159
  1828
					"Do you want to").arg(fn),
insilmaril@0
  1829
					QMessageBox::Warning,
insilmaril@0
  1830
					QMessageBox::Yes | QMessageBox::Default,
insilmaril@0
  1831
					QMessageBox::Cancel | QMessageBox::Escape,
insilmaril@366
  1832
					QMessageBox::NoButton);
insilmaril@0
  1833
				mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
insilmaril@0
  1834
				mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
insilmaril@0
  1835
				switch( mb.exec() ) 
insilmaril@0
  1836
				{
insilmaril@0
  1837
					case QMessageBox::Yes:
insilmaril@725
  1838
						// end loop and load anyway
insilmaril@0
  1839
						i=tabWidget->count();
insilmaril@0
  1840
						break;
insilmaril@0
  1841
					case QMessageBox::Cancel:
insilmaril@0
  1842
						// do nothing
insilmaril@205
  1843
						return aborted;
insilmaril@0
  1844
						break;
insilmaril@0
  1845
				}
insilmaril@0
  1846
			}
insilmaril@0
  1847
			i++;
insilmaril@0
  1848
		}
insilmaril@0
  1849
	}
insilmaril@725
  1850
	
insilmaril@725
  1851
	int tabIndex=tabWidget->currentPageIndex();
insilmaril@0
  1852
insilmaril@0
  1853
	// Try to load map
insilmaril@0
  1854
    if ( !fn.isEmpty() )
insilmaril@0
  1855
	{
insilmaril@727
  1856
		vm = currentModel();
insilmaril@0
  1857
		// Check first, if mapeditor exists
insilmaril@0
  1858
		// If it is not default AND we want a new map, 
insilmaril@0
  1859
		// create a new mapeditor in a new tab
insilmaril@727
  1860
		if ( lmode==NewMap && (!vm || !vm->isDefault() )  )
insilmaril@0
  1861
		{
insilmaril@727
  1862
			vm=new VymModel;
insilmaril@727
  1863
			tabModel.append (vm);
insilmaril@763
  1864
			tabWidget->addTab (createView (vm),fn);
insilmaril@725
  1865
			tabIndex=tabWidget->count()-1;
insilmaril@0
  1866
			tabWidget->setCurrentPage (tabIndex);
insilmaril@0
  1867
		}
insilmaril@0
  1868
		
insilmaril@0
  1869
		// Check, if file exists (important for creating new files
insilmaril@0
  1870
		// from command line
insilmaril@0
  1871
		if (!QFile(fn).exists() )
insilmaril@0
  1872
		{
insilmaril@404
  1873
			QMessageBox mb( vymName,
insilmaril@159
  1874
				tr("This map does not exist:\n  %1\nDo you want to create a new one?").arg(fn),
insilmaril@0
  1875
				QMessageBox::Question,
insilmaril@0
  1876
				QMessageBox::Yes ,
insilmaril@0
  1877
				QMessageBox::Cancel | QMessageBox::Default,
insilmaril@366
  1878
				QMessageBox::NoButton );
insilmaril@0
  1879
insilmaril@0
  1880
			mb.setButtonText( QMessageBox::Yes, tr("Create"));
insilmaril@0
  1881
			mb.setButtonText( QMessageBox::No, tr("Cancel"));
insilmaril@0
  1882
			switch( mb.exec() ) 
insilmaril@0
  1883
			{
insilmaril@0
  1884
				case QMessageBox::Yes:
insilmaril@0
  1885
					// Create new map
insilmaril@721
  1886
					currentMapEditor()->getModel()->setFilePath(fn);
insilmaril@725
  1887
					tabWidget->setTabText (tabIndex,
insilmaril@721
  1888
						currentMapEditor()->getModel()->getFileName() );
insilmaril@0
  1889
					statusBar()->message( "Created " + fn , statusbarTime );
insilmaril@205
  1890
					return success;
insilmaril@0
  1891
						
insilmaril@0
  1892
				case QMessageBox::Cancel:
insilmaril@0
  1893
					// don't create new map
insilmaril@0
  1894
					statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
insilmaril@0
  1895
					fileCloseMap();
insilmaril@205
  1896
					return aborted;
insilmaril@0
  1897
			}
insilmaril@0
  1898
		}	
insilmaril@0
  1899
insilmaril@721
  1900
insilmaril@0
  1901
		//tabWidget->currentPage() won't be NULL here, because of above...
insilmaril@725
  1902
		tabWidget->setCurrentIndex (tabIndex);
insilmaril@746
  1903
		//FIXME-3 no me anymore... me->viewport()->setFocus();
insilmaril@0
  1904
insilmaril@185
  1905
		if (err!=aborted)
insilmaril@185
  1906
		{
insilmaril@185
  1907
			// Save existing filename in case  we import
insilmaril@727
  1908
			QString fn_org=vm->getFilePath();
insilmaril@106
  1909
insilmaril@185
  1910
			// Finally load map into mapEditor
insilmaril@727
  1911
			vm->setFilePath (fn);
insilmaril@727
  1912
			err=vm->load(fn,lmode,ftype);
insilmaril@106
  1913
insilmaril@185
  1914
			// Restore old (maybe empty) filepath, if this is an import
insilmaril@185
  1915
			if (lmode!=NewMap)
insilmaril@727
  1916
				vm->setFilePath (fn_org);
insilmaril@185
  1917
		}	
insilmaril@0
  1918
insilmaril@185
  1919
		// Finally check for errors and go home
insilmaril@185
  1920
		if (err==aborted) 
insilmaril@185
  1921
		{
insilmaril@185
  1922
			if (lmode==NewMap) fileCloseMap();
insilmaril@185
  1923
			statusBar()->message( "Could not load " + fn, statusbarTime );
insilmaril@185
  1924
		} else 
insilmaril@0
  1925
		{
insilmaril@0
  1926
			if (lmode==NewMap)
insilmaril@0
  1927
			{
insilmaril@727
  1928
				vm->setFilePath (fn);
insilmaril@727
  1929
				tabWidget->setTabText (tabIndex, vm->getFileName());
insilmaril@608
  1930
				if (!isInTmpDir (fn))
insilmaril@205
  1931
				{
insilmaril@205
  1932
					// Only append to lastMaps if not loaded from a tmpDir
insilmaril@205
  1933
					// e.g. imported bookmarks are in a tmpDir
insilmaril@727
  1934
					addRecentMap(vm->getFilePath() );
insilmaril@205
  1935
				}
insilmaril@0
  1936
				actionFilePrint->setEnabled (true);
insilmaril@0
  1937
			}	
insilmaril@0
  1938
			statusBar()->message( "Loaded " + fn, statusbarTime );
insilmaril@0
  1939
		}	
insilmaril@0
  1940
	}
insilmaril@205
  1941
	return err;
insilmaril@0
  1942
}
insilmaril@0
  1943
insilmaril@0
  1944
insilmaril@0
  1945
void Main::fileLoad(const LoadMode &lmode)
insilmaril@0
  1946
{
insilmaril@377
  1947
	QStringList filters;
insilmaril@389
  1948
	filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
insilmaril@377
  1949
	QFileDialog *fd=new QFileDialog( this);
insilmaril@366
  1950
	fd->setDir (lastFileDir);
insilmaril@377
  1951
	fd->setFileMode (QFileDialog::ExistingFiles);
insilmaril@377
  1952
	fd->setFilters (filters);
insilmaril@0
  1953
	switch (lmode)
insilmaril@0
  1954
	{
insilmaril@0
  1955
		case NewMap:
insilmaril@404
  1956
			fd->setCaption(vymName+ " - " +tr("Load vym map"));
insilmaril@0
  1957
			break;
insilmaril@0
  1958
		case ImportAdd:
insilmaril@404
  1959
			fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
insilmaril@0
  1960
			break;
insilmaril@0
  1961
		case ImportReplace:
insilmaril@404
  1962
			fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
insilmaril@0
  1963
			break;
insilmaril@0
  1964
	}
insilmaril@0
  1965
	fd->show();
insilmaril@0
  1966
insilmaril@0
  1967
	QString fn;
insilmaril@0
  1968
	if ( fd->exec() == QDialog::Accepted )
insilmaril@0
  1969
	{
insilmaril@377
  1970
		lastFileDir=fd->directory().path();
insilmaril@185
  1971
	    QStringList flist = fd->selectedFiles();
insilmaril@185
  1972
		QStringList::Iterator it = flist.begin();
insilmaril@185
  1973
		while( it != flist.end() ) 
insilmaril@185
  1974
		{
insilmaril@185
  1975
			fn = *it;
insilmaril@185
  1976
			fileLoad(*it, lmode);				   
insilmaril@185
  1977
			++it;
insilmaril@185
  1978
		}
insilmaril@0
  1979
	}
insilmaril@185
  1980
	delete (fd);
insilmaril@0
  1981
}
insilmaril@0
  1982
insilmaril@0
  1983
void Main::fileLoad()
insilmaril@0
  1984
{
insilmaril@0
  1985
	fileLoad (NewMap);
insilmaril@0
  1986
}
insilmaril@0
  1987
insilmaril@401
  1988
void Main::fileLoadRecent()
insilmaril@0
  1989
{
insilmaril@401
  1990
    QAction *action = qobject_cast<QAction *>(sender());
insilmaril@401
  1991
    if (action)
insilmaril@401
  1992
        fileLoad (action->data().toString(), NewMap);
insilmaril@401
  1993
}
insilmaril@401
  1994
insilmaril@401
  1995
void Main::addRecentMap (const QString &fileName)
insilmaril@401
  1996
{
insilmaril@401
  1997
insilmaril@401
  1998
    QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
insilmaril@401
  1999
    files.removeAll(fileName);
insilmaril@401
  2000
    files.prepend(fileName);
insilmaril@401
  2001
    while (files.size() > MaxRecentFiles)
insilmaril@401
  2002
        files.removeLast();
insilmaril@401
  2003
insilmaril@401
  2004
    settings.setValue("/mainwindow/recentFileList", files);
insilmaril@401
  2005
insilmaril@401
  2006
	setupRecentMapsMenu();
insilmaril@0
  2007
}
insilmaril@0
  2008
insilmaril@721
  2009
void Main::fileSave(VymModel *m, const SaveMode &savemode)
insilmaril@0
  2010
{
insilmaril@721
  2011
	if (!m) return;
insilmaril@721
  2012
insilmaril@721
  2013
	if ( m->getFilePath().isEmpty() ) 
insilmaril@676
  2014
	{
insilmaril@676
  2015
		// We have  no filepath yet,
insilmaril@676
  2016
		// call fileSaveAs() now, this will call fileSave() 
insilmaril@676
  2017
		// again.
insilmaril@676
  2018
		// First switch to editor
insilmaril@746
  2019
		//FIXME-3 needed???  tabWidget->setCurrentWidget (m->getMapEditor());
insilmaril@676
  2020
		fileSaveAs(savemode);
insilmaril@676
  2021
	}
insilmaril@676
  2022
insilmaril@721
  2023
	if (m->save (savemode)==success)
insilmaril@151
  2024
	{
insilmaril@0
  2025
		statusBar()->message( 
insilmaril@721
  2026
			tr("Saved  %1").arg(m->getFilePath()), 
insilmaril@0
  2027
			statusbarTime );
insilmaril@721
  2028
		addRecentMap (m->getFilePath() );
insilmaril@151
  2029
	} else		
insilmaril@0
  2030
		statusBar()->message( 
insilmaril@721
  2031
			tr("Couldn't save ").arg(m->getFilePath()), 
insilmaril@0
  2032
			statusbarTime );
insilmaril@0
  2033
}
insilmaril@0
  2034
insilmaril@0
  2035
void Main::fileSave()
insilmaril@0
  2036
{
insilmaril@721
  2037
	fileSave (currentModel(), CompleteMap);
insilmaril@473
  2038
}
insilmaril@473
  2039
insilmaril@721
  2040
void Main::fileSave(VymModel *m)
insilmaril@473
  2041
{
insilmaril@721
  2042
	fileSave (m,CompleteMap);
insilmaril@0
  2043
}
insilmaril@0
  2044
insilmaril@0
  2045
void Main::fileSaveAs(const SaveMode& savemode)
insilmaril@0
  2046
{
insilmaril@0
  2047
	QString fn;
insilmaril@0
  2048
insilmaril@0
  2049
	if (currentMapEditor())
insilmaril@0
  2050
	{
insilmaril@0
  2051
		if (savemode==CompleteMap)
insilmaril@366
  2052
			fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
insilmaril@0
  2053
		else		
insilmaril@366
  2054
			fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
insilmaril@0
  2055
		if ( !fn.isEmpty() ) 
insilmaril@0
  2056
		{
insilmaril@0
  2057
			// Check for existing file
insilmaril@0
  2058
			if (QFile (fn).exists())
insilmaril@0
  2059
			{
insilmaril@404
  2060
				QMessageBox mb( vymName,
insilmaril@159
  2061
					tr("The file %1\nexists already. Do you want to").arg(fn),
insilmaril@0
  2062
					QMessageBox::Warning,
insilmaril@0
  2063
					QMessageBox::Yes | QMessageBox::Default,
insilmaril@0
  2064
					QMessageBox::Cancel | QMessageBox::Escape,
insilmaril@366
  2065
					QMessageBox::NoButton);
insilmaril@0
  2066
				mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
insilmaril@0
  2067
				mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
insilmaril@0
  2068
				switch( mb.exec() ) 
insilmaril@0
  2069
				{
insilmaril@0
  2070
					case QMessageBox::Yes:
insilmaril@0
  2071
						// save 
insilmaril@0
  2072
						break;
insilmaril@0
  2073
					case QMessageBox::Cancel:
insilmaril@0
  2074
						// do nothing
insilmaril@0
  2075
						return;
insilmaril@0
  2076
						break;
insilmaril@0
  2077
				}
insilmaril@0
  2078
			} else
insilmaril@0
  2079
			{
insilmaril@0
  2080
				// New file, add extension to filename, if missing
insilmaril@0
  2081
				// This is always .vym or .vyp, depending on savemode
insilmaril@0
  2082
				if (savemode==CompleteMap)
insilmaril@0
  2083
				{
insilmaril@0
  2084
					if (!fn.contains (".vym") && !fn.contains (".xml"))
insilmaril@0
  2085
						fn +=".vym";
insilmaril@0
  2086
				} else		
insilmaril@0
  2087
				{
insilmaril@0
  2088
					if (!fn.contains (".vyp") && !fn.contains (".xml"))
insilmaril@0
  2089
						fn +=".vyp";
insilmaril@0
  2090
				}
insilmaril@0
  2091
			}
insilmaril@0
  2092
	
insilmaril@0
  2093
insilmaril@0
  2094
insilmaril@0
  2095
insilmaril@0
  2096
			// Save now
insilmaril@725
  2097
			VymModel *m=currentModel();
insilmaril@725
  2098
			m->setFilePath(fn);
insilmaril@725
  2099
			fileSave(m, savemode);
insilmaril@725
  2100
insilmaril@725
  2101
			// Set name of tab, assuming current tab is the one we just saved
insilmaril@94
  2102
			if (savemode==CompleteMap)
insilmaril@725
  2103
				tabWidget->setTabText (tabWidget->currentIndex(), m->getFileName() );
insilmaril@0
  2104
			return;
insilmaril@0
  2105
		} 
insilmaril@0
  2106
	}
insilmaril@0
  2107
}
insilmaril@0
  2108
insilmaril@0
  2109
void Main::fileSaveAs()
insilmaril@0
  2110
{
insilmaril@0
  2111
	fileSaveAs (CompleteMap);
insilmaril@0
  2112
}
insilmaril@0
  2113
insilmaril@742
  2114
void Main::fileImportKDE3Bookmarks()
insilmaril@205
  2115
{
insilmaril@742
  2116
	ImportKDE3Bookmarks im;
insilmaril@205
  2117
	im.transform();
insilmaril@742
  2118
	if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
insilmaril@742
  2119
		currentMapEditor()->getModel()->setFilePath ("");
insilmaril@742
  2120
}
insilmaril@742
  2121
insilmaril@742
  2122
void Main::fileImportKDE4Bookmarks()
insilmaril@742
  2123
{
insilmaril@742
  2124
	ImportKDE4Bookmarks im;
insilmaril@742
  2125
	im.transform();
insilmaril@742
  2126
	if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
insilmaril@721
  2127
		currentMapEditor()->getModel()->setFilePath ("");
insilmaril@205
  2128
}
insilmaril@205
  2129
insilmaril@314
  2130
void Main::fileImportFirefoxBookmarks()
insilmaril@314
  2131
{
insilmaril@366
  2132
	Q3FileDialog *fd=new Q3FileDialog( this);
insilmaril@327
  2133
	fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
insilmaril@366
  2134
	fd->setMode (Q3FileDialog::ExistingFiles);
insilmaril@327
  2135
	fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
insilmaril@327
  2136
	fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
insilmaril@327
  2137
	fd->show();
insilmaril@327
  2138
insilmaril@327
  2139
	if ( fd->exec() == QDialog::Accepted )
insilmaril@327
  2140
	{
insilmaril@327
  2141
		ImportFirefoxBookmarks im;
insilmaril@327
  2142
	    QStringList flist = fd->selectedFiles();
insilmaril@327
  2143
		QStringList::Iterator it = flist.begin();
insilmaril@327
  2144
		while( it != flist.end() ) 
insilmaril@327
  2145
		{
insilmaril@327
  2146
			im.setFile (*it);
insilmaril@327
  2147
			if (im.transform() && 
insilmaril@742
  2148
				aborted!=fileLoad (im.getTransformedFile(),NewMap,FreemindMap) && 
insilmaril@327
  2149
				currentMapEditor() )
insilmaril@721
  2150
				currentMapEditor()->getModel()->setFilePath ("");
insilmaril@327
  2151
			++it;
insilmaril@327
  2152
		}
insilmaril@327
  2153
	}
insilmaril@327
  2154
	delete (fd);
insilmaril@314
  2155
}
insilmaril@314
  2156
insilmaril@571
  2157
void Main::fileImportFreemind()
insilmaril@571
  2158
{
insilmaril@571
  2159
	QStringList filters;
insilmaril@571
  2160
	filters <<"Freemind map (*.mm)"<<"All files (*)";
insilmaril@571
  2161
	QFileDialog *fd=new QFileDialog( this);
insilmaril@571
  2162
	fd->setDir (lastFileDir);
insilmaril@571
  2163
	fd->setFileMode (QFileDialog::ExistingFiles);
insilmaril@571
  2164
	fd->setFilters (filters);
insilmaril@571
  2165
	fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
insilmaril@571
  2166
	fd->show();
insilmaril@571
  2167
insilmaril@571
  2168
	QString fn;
insilmaril@571
  2169
	if ( fd->exec() == QDialog::Accepted )
insilmaril@571
  2170
	{
insilmaril@571
  2171
		lastFileDir=fd->directory().path();
insilmaril@571
  2172
	    QStringList flist = fd->selectedFiles();
insilmaril@571
  2173
		QStringList::Iterator it = flist.begin();
insilmaril@571
  2174
		while( it != flist.end() ) 
insilmaril@571
  2175
		{
insilmaril@571
  2176
			fn = *it;
insilmaril@571
  2177
			if ( fileLoad (fn,NewMap, FreemindMap)  )
insilmaril@571
  2178
			{	
insilmaril@721
  2179
				currentMapEditor()->getModel()->setFilePath ("");
insilmaril@571
  2180
			}	
insilmaril@571
  2181
			++it;
insilmaril@571
  2182
		}
insilmaril@571
  2183
	}
insilmaril@571
  2184
	delete (fd);
insilmaril@571
  2185
}
insilmaril@571
  2186
insilmaril@571
  2187
insilmaril@215
  2188
void Main::fileImportMM()
insilmaril@215
  2189
{
insilmaril@215
  2190
	ImportMM im;
insilmaril@215
  2191
insilmaril@366
  2192
	Q3FileDialog *fd=new Q3FileDialog( this);
insilmaril@366
  2193
	fd->setDir (lastFileDir);
insilmaril@366
  2194
	fd->setMode (Q3FileDialog::ExistingFiles);
insilmaril@215
  2195
	fd->addFilter ("Mind Manager (*.mmap)");
insilmaril@215
  2196
	fd->setCaption(tr("Import")+" "+"Mind Manager");
insilmaril@215
  2197
	fd->show();
insilmaril@215
  2198
insilmaril@215
  2199
	if ( fd->exec() == QDialog::Accepted )
insilmaril@215
  2200
	{
insilmaril@215
  2201
		lastFileDir=fd->dirPath();
insilmaril@215
  2202
	    QStringList flist = fd->selectedFiles();
insilmaril@215
  2203
		QStringList::Iterator it = flist.begin();
insilmaril@215
  2204
		while( it != flist.end() ) 
insilmaril@215
  2205
		{
insilmaril@215
  2206
			im.setFile (*it);
insilmaril@215
  2207
			if (im.transform() && 
insilmaril@215
  2208
				success==fileLoad (im.getTransformedFile(),NewMap) && 
insilmaril@215
  2209
				currentMapEditor() )
insilmaril@721
  2210
				currentMapEditor()->getModel()->setFilePath ("");
insilmaril@215
  2211
			++it;
insilmaril@215
  2212
		}
insilmaril@215
  2213
	}
insilmaril@215
  2214
	delete (fd);
insilmaril@215
  2215
}
insilmaril@215
  2216
insilmaril@215
  2217
void Main::fileImportDir()
insilmaril@215
  2218
{
insilmaril@721
  2219
	VymModel *m=currentModel();
insilmaril@721
  2220
	if (m) m->importDir();
insilmaril@215
  2221
}
insilmaril@215
  2222
insilmaril@526
  2223
void Main::fileExportXML()	
insilmaril@0
  2224
{
insilmaril@721
  2225
	VymModel *m=currentModel();
insilmaril@721
  2226
	if (m) m->exportXML();
insilmaril@0
  2227
}
insilmaril@0
  2228
insilmaril@0
  2229
insilmaril@517
  2230
void Main::fileExportXHTML()	
insilmaril@0
  2231
{
insilmaril@721
  2232
	VymModel *m=currentModel();
insilmaril@721
  2233
	if (m) m->exportXHTML();
insilmaril@0
  2234
}
insilmaril@0
  2235
insilmaril@517
  2236
void Main::fileExportImage()	
insilmaril@0
  2237
{
insilmaril@721
  2238
	VymModel *m=currentModel();
insilmaril@721
  2239
	if (m) m->exportImage();
insilmaril@0
  2240
}
insilmaril@0
  2241
insilmaril@0
  2242
void Main::fileExportASCII()
insilmaril@0
  2243
{
insilmaril@721
  2244
	VymModel *m=currentModel();
insilmaril@721
  2245
	if (m) m->exportASCII();
insilmaril@0
  2246
}
insilmaril@0
  2247
insilmaril@756
  2248
void Main::fileExportCSV()	//FIXME-3 not scriptable yet
insilmaril@497
  2249
{
insilmaril@721
  2250
	VymModel *m=currentModel();
insilmaril@721
  2251
	if (m)
insilmaril@497
  2252
	{
insilmaril@497
  2253
		ExportCSV ex;
insilmaril@721
  2254
		ex.setModel (m);
insilmaril@497
  2255
		ex.addFilter ("CSV (*.csv)");
insilmaril@497
  2256
		ex.setDir(lastImageDir);
insilmaril@497
  2257
		ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
insilmaril@497
  2258
		if (ex.execDialog() ) 
insilmaril@497
  2259
		{
insilmaril@721
  2260
			m->setExportMode(true);
insilmaril@497
  2261
			ex.doExport();
insilmaril@721
  2262
			m->setExportMode(false);
insilmaril@497
  2263
		}
insilmaril@497
  2264
	}
insilmaril@497
  2265
}
insilmaril@497
  2266
insilmaril@756
  2267
void Main::fileExportLaTeX()	//FIXME-3 not scriptable yet
insilmaril@163
  2268
{
insilmaril@721
  2269
	VymModel *m=currentModel();
insilmaril@721
  2270
	if (m)
insilmaril@228
  2271
	{
insilmaril@228
  2272
		ExportLaTeX ex;
insilmaril@721
  2273
		ex.setModel (m);
insilmaril@228
  2274
		ex.addFilter ("Tex (*.tex)");
insilmaril@424
  2275
		ex.setDir(lastImageDir);
insilmaril@404
  2276
		ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
insilmaril@260
  2277
		if (ex.execDialog() ) 
insilmaril@260
  2278
		{
insilmaril@721
  2279
			m->setExportMode(true);
insilmaril@260
  2280
			ex.doExport();
insilmaril@721
  2281
			m->setExportMode(false);
insilmaril@260
  2282
		}
insilmaril@228
  2283
	}
insilmaril@228
  2284
}
insilmaril@228
  2285
insilmaril@756
  2286
void Main::fileExportKDE3Bookmarks()	//FIXME-3 not scriptable yet
insilmaril@243
  2287
{
insilmaril@742
  2288
	ExportKDE3Bookmarks ex;
insilmaril@742
  2289
	VymModel *m=currentModel();
insilmaril@742
  2290
	if (m)
insilmaril@742
  2291
	{
insilmaril@742
  2292
		ex.setModel (m);
insilmaril@742
  2293
		ex.doExport();
insilmaril@742
  2294
	}	
insilmaril@742
  2295
}
insilmaril@742
  2296
insilmaril@756
  2297
void Main::fileExportKDE4Bookmarks()	//FIXME-3 not scriptable yet
insilmaril@742
  2298
{
insilmaril@742
  2299
	ExportKDE4Bookmarks ex;
insilmaril@721
  2300
	VymModel *m=currentModel();
insilmaril@721
  2301
	if (m)
insilmaril@243
  2302
	{
insilmaril@721
  2303
		ex.setModel (m);
insilmaril@243
  2304
		ex.doExport();
insilmaril@243
  2305
	}	
insilmaril@243
  2306
}
insilmaril@243
  2307
insilmaril@756
  2308
void Main::fileExportTaskjuggler()	//FIXME-3 not scriptable yet
insilmaril@228
  2309
{
insilmaril@228
  2310
	ExportTaskjuggler ex;
insilmaril@721
  2311
	VymModel *m=currentModel();
insilmaril@721
  2312
	if (m)
insilmaril@228
  2313
	{
insilmaril@721
  2314
		ex.setModel (m);
insilmaril@404
  2315
		ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
insilmaril@424
  2316
		ex.setDir(lastImageDir);
insilmaril@243
  2317
		ex.addFilter ("Taskjuggler (*.tjp)");
insilmaril@260
  2318
		if (ex.execDialog() ) 
insilmaril@260
  2319
		{
insilmaril@721
  2320
			m->setExportMode(true);
insilmaril@260
  2321
			ex.doExport();
insilmaril@721
  2322
			m->setExportMode(false);
insilmaril@260
  2323
		}
insilmaril@228
  2324
	}	
insilmaril@163
  2325
}
insilmaril@163
  2326
insilmaril@756
  2327
void Main::fileExportOOPresentation()	//FIXME-3 not scriptable yet
insilmaril@163
  2328
{
insilmaril@404
  2329
	ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
insilmaril@366
  2330
	// TODO add preview in dialog
insilmaril@185
  2331
	//ImagePreview *p =new ImagePreview (fd);
insilmaril@185
  2332
	//fd->setContentsPreviewEnabled( TRUE );
insilmaril@185
  2333
	//fd->setContentsPreview( p, p );
insilmaril@185
  2334
	//fd->setPreviewMode( QFileDialog::Contents );
insilmaril@404
  2335
	fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
insilmaril@366
  2336
	fd->setDir (QDir().current());
insilmaril@357
  2337
	if (fd->foundConfig())
insilmaril@357
  2338
	{
insilmaril@357
  2339
		fd->show();
insilmaril@185
  2340
insilmaril@357
  2341
		if ( fd->exec() == QDialog::Accepted )
insilmaril@357
  2342
		{
insilmaril@357
  2343
			QString fn=fd->selectedFile();
insilmaril@366
  2344
			if (!fn.contains (".odp"))
insilmaril@366
  2345
				fn +=".odp";
insilmaril@366
  2346
insilmaril@357
  2347
			//lastImageDir=fn.left(fn.findRev ("/"));
insilmaril@721
  2348
			VymModel *m=currentModel();
insilmaril@721
  2349
			if (m) m->exportOOPresentation(fn,fd->selectedConfig());	
insilmaril@357
  2350
		}
insilmaril@357
  2351
	} else
insilmaril@185
  2352
	{
insilmaril@357
  2353
		QMessageBox::warning(0, 
insilmaril@366
  2354
		tr("Warning"),
insilmaril@366
  2355
		tr("Couldn't find configuration for export to Open Office\n"));
insilmaril@185
  2356
	}
insilmaril@163
  2357
}
insilmaril@163
  2358
insilmaril@0
  2359
void Main::fileCloseMap()
insilmaril@0
  2360
{
insilmaril@625
  2361
	MapEditor *me = currentMapEditor();
insilmaril@721
  2362
	VymModel *m=currentModel();
insilmaril@721
  2363
	if (m)
insilmaril@0
  2364
	{
insilmaril@721
  2365
		if (m->hasChanged())
insilmaril@0
  2366
		{
insilmaril@404
  2367
			QMessageBox mb( vymName,
insilmaril@721
  2368
				tr("The map %1 has been modified but not saved yet. Do you want to").arg(me->getModel()->getFileName()),
insilmaril@0
  2369
				QMessageBox::Warning,
insilmaril@0
  2370
				QMessageBox::Yes | QMessageBox::Default,
insilmaril@0
  2371
				QMessageBox::No,
insilmaril@0
  2372
				QMessageBox::Cancel | QMessageBox::Escape );
insilmaril@0
  2373
			mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
insilmaril@0
  2374
			mb.setButtonText( QMessageBox::No, tr("Discard changes"));
insilmaril@0
  2375
			switch( mb.exec() ) 
insilmaril@0
  2376
			{
insilmaril@0
  2377
				case QMessageBox::Yes:
insilmaril@0
  2378
					// save and close
insilmaril@721
  2379
					fileSave(m, CompleteMap);
insilmaril@0
  2380
					break;
insilmaril@0
  2381
				case QMessageBox::No:
insilmaril@0
  2382
				// close  without saving
insilmaril@0
  2383
					break;
insilmaril@0
  2384
				case QMessageBox::Cancel:
insilmaril@0
  2385
					// do nothing
insilmaril@0
  2386
				return;
insilmaril@0
  2387
			}
insilmaril@0
  2388
		} 
insilmaril@725
  2389
		tabModel.removeAt (tabWidget->currentIndex() );
insilmaril@725
  2390
		tabWidget->removeTab (tabWidget->currentIndex() );
insilmaril@742
  2391
insilmaril@742
  2392
		// Remove mapEditor;
insilmaril@742
  2393
		// Better would be delete (me), but then we could have a Qt error:
insilmaril@742
  2394
		// "QObject: Do not delete object, 'MapEditor', during its event handler!"
insilmaril@742
  2395
		// So we only remove data now and call deconstructor when vym closes later
insilmaril@746
  2396
		// FIXME-3  this needs to be moved to vymview...   me->clear();
insilmaril@742
  2397
		// some model->clear is needed to free up memory ...
insilmaril@742
  2398
insilmaril@724
  2399
		updateActions();
insilmaril@625
  2400
	}
insilmaril@0
  2401
}
insilmaril@0
  2402
insilmaril@0
  2403
void Main::filePrint()
insilmaril@0
  2404
{
insilmaril@0
  2405
	if (currentMapEditor())
insilmaril@0
  2406
		currentMapEditor()->print();
insilmaril@0
  2407
}
insilmaril@0
  2408
insilmaril@0
  2409
void Main::fileExitVYM()
insilmaril@0
  2410
{
insilmaril@0
  2411
	// Check if one or more editors have changed
insilmaril@0
  2412
	int i;
insilmaril@725
  2413
	for (i=0;i<=tabModel.count() -1;i++)
insilmaril@0
  2414
	{
insilmaril@0
  2415
		// If something changed, ask what to do
insilmaril@725
  2416
		if (tabModel.at(i)->hasChanged())
insilmaril@0
  2417
		{
insilmaril@0
  2418
			tabWidget->setCurrentPage(i);
insilmaril@404
  2419
			QMessageBox mb( vymName,
insilmaril@0
  2420
				tr("This map is not saved yet. Do you want to"),
insilmaril@0
  2421
				QMessageBox::Warning,
insilmaril@0
  2422
				QMessageBox::Yes | QMessageBox::Default,
insilmaril@0
  2423
				QMessageBox::No,
insilmaril@0
  2424
				QMessageBox::Cancel | QMessageBox::Escape );
insilmaril@0
  2425
			mb.setButtonText( QMessageBox::Yes, tr("Save map") );
insilmaril@0
  2426
			mb.setButtonText( QMessageBox::No, tr("Discard changes") );
insilmaril@366
  2427
			mb.setModal (true);
insilmaril@0
  2428
			mb.show();
insilmaril@0
  2429
			mb.setActiveWindow();
insilmaril@0
  2430
			switch( mb.exec() ) {
insilmaril@0
  2431
				case QMessageBox::Yes:
insilmaril@0
  2432
					// save (the changed editors) and exit
insilmaril@721
  2433
					fileSave(currentModel(), CompleteMap);
insilmaril@0
  2434
					break;
insilmaril@0
  2435
				case QMessageBox::No:
insilmaril@0
  2436
					// exit without saving
insilmaril@0
  2437
					break;
insilmaril@0
  2438
				case QMessageBox::Cancel:
insilmaril@0
  2439
					// don't save and don't exit
insilmaril@0
  2440
				return;
insilmaril@0
  2441
			}
insilmaril@0
  2442
		}
insilmaril@0
  2443
	} // loop over all MEs	
insilmaril@0
  2444
    qApp->quit();
insilmaril@0
  2445
}
insilmaril@0
  2446
insilmaril@0
  2447
void Main::editUndo()
insilmaril@0
  2448
{
insilmaril@721
  2449
	VymModel *m=currentModel();
insilmaril@721
  2450
	if (m) m->undo();
insilmaril@0
  2451
}
insilmaril@0
  2452
insilmaril@163
  2453
void Main::editRedo()	   
insilmaril@0
  2454
{
insilmaril@721
  2455
	VymModel *m=currentModel();
insilmaril@721
  2456
	if (m) m->redo();
insilmaril@0
  2457
}
insilmaril@0
  2458
insilmaril@404
  2459
void Main::gotoHistoryStep (int i)	   
insilmaril@404
  2460
{
insilmaril@721
  2461
	VymModel *m=currentModel();
insilmaril@721
  2462
	if (m) m->gotoHistoryStep(i);
insilmaril@404
  2463
}
insilmaril@404
  2464
insilmaril@0
  2465
void Main::editCopy()
insilmaril@0
  2466
{
insilmaril@721
  2467
	VymModel *m=currentModel();
insilmaril@721
  2468
	if (m) m->copy();
insilmaril@0
  2469
}
insilmaril@0
  2470
insilmaril@0
  2471
void Main::editPaste()
insilmaril@0
  2472
{
insilmaril@721
  2473
	VymModel *m=currentModel();
insilmaril@721
  2474
	if (m) m->paste();
insilmaril@0
  2475
}
insilmaril@0
  2476
insilmaril@0
  2477
void Main::editCut()
insilmaril@0
  2478
{
insilmaril@721
  2479
	VymModel *m=currentModel();
insilmaril@721
  2480
	if (m) m->cut();
insilmaril@0
  2481
}
insilmaril@0
  2482
insilmaril@0
  2483
void Main::editOpenFindWindow()
insilmaril@0
  2484
{
insilmaril@0
  2485
	findWindow->popup();
insilmaril@0
  2486
	findWindow->raise();
insilmaril@0
  2487
	findWindow->setActiveWindow();
insilmaril@0
  2488
}
insilmaril@0
  2489
insilmaril@0
  2490
void Main::editFind(QString s)
insilmaril@0
  2491
{
insilmaril@721
  2492
	VymModel *m=currentModel();
insilmaril@721
  2493
	if (m)
insilmaril@0
  2494
	{
insilmaril@721
  2495
		bool cs=false;
insilmaril@753
  2496
		BranchItem *bi=m->findText(s, cs);
insilmaril@753
  2497
		if (bi)
insilmaril@721
  2498
		{	
insilmaril@753
  2499
			statusBar()->message( "Found: " + bi->getHeading(), statusbarTime );
insilmaril@721
  2500
		} else
insilmaril@721
  2501
		{
insilmaril@721
  2502
			QMessageBox::information( findWindow, tr( "VYM -Information:" ),
insilmaril@721
  2503
								   tr("No matches found for \"%1\"").arg(s));
insilmaril@721
  2504
		}	
insilmaril@721
  2505
	}
insilmaril@0
  2506
}
insilmaril@0
  2507
insilmaril@0
  2508
void Main::editFindChanged()
insilmaril@0
  2509
{	// Notify editor, to abort the current find process
insilmaril@721
  2510
	VymModel *m=currentModel();
insilmaril@721
  2511
	if (m) m->findReset();
insilmaril@0
  2512
}
insilmaril@0
  2513
insilmaril@366
  2514
void Main::openTabs(QStringList urls)
insilmaril@366
  2515
{
insilmaril@366
  2516
	if (!urls.isEmpty())
insilmaril@366
  2517
	{	
insilmaril@366
  2518
		bool success=true;
insilmaril@366
  2519
		QStringList args;
insilmaril@366
  2520
		QString browser=settings.value("/mainwindow/readerURL" ).toString();
insilmaril@366
  2521
		QProcess *p;
insilmaril@366
  2522
		if (!procBrowser ||  procBrowser->state()!=QProcess::Running)
insilmaril@366
  2523
		{
insilmaril@366
  2524
			QString u=urls.takeFirst();
insilmaril@366
  2525
			procBrowser = new QProcess( this );
insilmaril@366
  2526
			args<<u;
insilmaril@366
  2527
			procBrowser->start(browser,args);
insilmaril@366
  2528
			if ( !procBrowser->waitForStarted())
insilmaril@366
  2529
			{
insilmaril@366
  2530
				// try to set path to browser
insilmaril@366
  2531
				QMessageBox::warning(0, 
insilmaril@366
  2532
					tr("Warning"),
insilmaril@366
  2533
					tr("Couldn't find a viewer to open %1.\n").arg(u)+
insilmaril@366
  2534
					tr("Please use Settings->")+tr("Set application to open an URL"));
insilmaril@366
  2535
				return;
insilmaril@366
  2536
			}
insilmaril@608
  2537
#if defined(Q_OS_WIN32)
insilmaril@608
  2538
            // There's no sleep in VCEE, replace it with Qt's QThread::wait().
insilmaril@608
  2539
            this->thread()->wait(3000);
insilmaril@608
  2540
#else
insilmaril@366
  2541
			sleep (3);
insilmaril@608
  2542
#endif
insilmaril@366
  2543
		}
insilmaril@366
  2544
		if (browser.contains("konqueror"))
insilmaril@366
  2545
		{
insilmaril@366
  2546
			for (int i=0; i<urls.size(); i++)
insilmaril@366
  2547
			{
insilmaril@366
  2548
				// Open new browser
insilmaril@366
  2549
				// Try to open new tab in existing konqueror started previously by vym
insilmaril@366
  2550
				p=new QProcess (this);
insilmaril@366
  2551
				args.clear();
insilmaril@608
  2552
#if defined(Q_OS_WIN32)
insilmaril@608
  2553
                // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
insilmaril@608
  2554
                // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
insilmaril@608
  2555
				args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
insilmaril@608
  2556
					"konqueror-mainwindow#1"<<
insilmaril@608
  2557
					"newTab" <<
insilmaril@366
  2558
					urls.at(i);
insilmaril@608
  2559
#else
insilmaril@608
  2560
				args<< QString("konqueror-%1").arg(procBrowser->pid())<<
insilmaril@608
  2561
					"konqueror-mainwindow#1"<<
insilmaril@608
  2562
					"newTab" <<
insilmaril@608
  2563
					urls.at(i);
insilmaril@608
  2564
#endif
insilmaril@366
  2565
				p->start ("dcop",args);
insilmaril@748
  2566
				if (debug) cout << "MainWindo::openURLs  args="<<args.join(" ").toStdString()<<endl;
insilmaril@366
  2567
				if ( !p->waitForStarted() ) success=false;
insilmaril@366
  2568
			}
insilmaril@366
  2569
			if (!success)
insilmaril@366
  2570
				QMessageBox::warning(0, 
insilmaril@366
  2571
					tr("Warning"),
insilmaril@366
  2572
					tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
insilmaril@366
  2573
			return;		
insilmaril@366
  2574
		} else if (browser.contains ("firefox") || browser.contains ("mozilla") )
insilmaril@366
  2575
		{
insilmaril@366
  2576
			for (int i=0; i<urls.size(); i++)
insilmaril@366
  2577
			{
insilmaril@366
  2578
				// Try to open new tab in firefox
insilmaril@366
  2579
				p=new QProcess (this);
insilmaril@366
  2580
				args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
insilmaril@366
  2581
				p->start (browser,args);
insilmaril@366
  2582
				if ( !p->waitForStarted() ) success=false;
insilmaril@366
  2583
			}			
insilmaril@366
  2584
			if (!success)
insilmaril@366
  2585
				QMessageBox::warning(0, 
insilmaril@366
  2586
					tr("Warning"),
insilmaril@366
  2587
					tr("Couldn't start %1 to open a new tab").arg(browser));
insilmaril@366
  2588
			return;		
insilmaril@366
  2589
		}			
insilmaril@366
  2590
		QMessageBox::warning(0, 
insilmaril@366
  2591
			tr("Warning"),
insilmaril@366
  2592
			tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
insilmaril@366
  2593
	}	
insilmaril@366
  2594
}
insilmaril@366
  2595
insilmaril@0
  2596
void Main::editOpenURL()
insilmaril@0
  2597
{
insilmaril@266
  2598
	// Open new browser
insilmaril@721
  2599
	VymModel *m=currentModel();
insilmaril@721
  2600
	if (m)
insilmaril@266
  2601
	{	
insilmaril@721
  2602
	    QString url=m->getURL();
insilmaril@366
  2603
		QStringList args;
insilmaril@266
  2604
		if (url=="") return;
insilmaril@366
  2605
		QString browser=settings.value("/mainwindow/readerURL" ).toString();
insilmaril@266
  2606
		procBrowser = new QProcess( this );
insilmaril@366
  2607
		args<<url;
insilmaril@366
  2608
		procBrowser->start(browser,args);
insilmaril@366
  2609
		if ( !procBrowser->waitForStarted())
insilmaril@266
  2610
		{
insilmaril@266
  2611
			// try to set path to browser
insilmaril@266
  2612
			QMessageBox::warning(0, 
insilmaril@266
  2613
				tr("Warning"),
insilmaril@266
  2614
				tr("Couldn't find a viewer to open %1.\n").arg(url)+
insilmaril@266
  2615
				tr("Please use Settings->")+tr("Set application to open an URL"));
insilmaril@266
  2616
			settingsURL() ; 
insilmaril@266
  2617
		}	
insilmaril@266
  2618
	}	
insilmaril@266
  2619
}
insilmaril@266
  2620
void Main::editOpenURLTab()
insilmaril@266
  2621
{
insilmaril@721
  2622
	VymModel *m=currentModel();
insilmaril@721
  2623
	if (m)
insilmaril@266
  2624
	{	
insilmaril@366
  2625
	    QStringList urls;
insilmaril@721
  2626
		urls.append(m->getURL());
insilmaril@366
  2627
		openTabs (urls);
insilmaril@266
  2628
	}	
insilmaril@0
  2629
}
insilmaril@366
  2630
void Main::editOpenMultipleURLTabs()
insilmaril@366
  2631
{
insilmaril@721
  2632
	VymModel *m=currentModel();
insilmaril@721
  2633
	if (m)
insilmaril@366
  2634
	{	
insilmaril@366
  2635
	    QStringList urls;
insilmaril@721
  2636
		urls=m->getURLs();
insilmaril@366
  2637
		openTabs (urls);
insilmaril@366
  2638
	}	
insilmaril@366
  2639
}
insilmaril@366
  2640
insilmaril@0
  2641
insilmaril@0
  2642
void Main::editURL()
insilmaril@0
  2643
{
insilmaril@721
  2644
	VymModel *m=currentModel();
insilmaril@721
  2645
	if (m) m->editURL();
insilmaril@0
  2646
}
insilmaril@0
  2647
insilmaril@528
  2648
void Main::editLocalURL()
insilmaril@528
  2649
{
insilmaril@721
  2650
	VymModel *m=currentModel();
insilmaril@721
  2651
	if (m) m->editLocalURL();
insilmaril@528
  2652
}
insilmaril@528
  2653
insilmaril@0
  2654
void Main::editHeading2URL()
insilmaril@0
  2655
{
insilmaril@721
  2656
	VymModel *m=currentModel();
insilmaril@721
  2657
	if (m) m->editHeading2URL();
insilmaril@0
  2658
}
insilmaril@0
  2659
insilmaril@0
  2660
void Main::editBugzilla2URL()
insilmaril@0
  2661
{
insilmaril@721
  2662
	VymModel *m=currentModel();
insilmaril@721
  2663
	if (m) m->editBugzilla2URL();
insilmaril@0
  2664
}
insilmaril@0
  2665
insilmaril@175
  2666
void Main::editFATE2URL()
insilmaril@175
  2667
{
insilmaril@721
  2668
	VymModel *m=currentModel();
insilmaril@721
  2669
	if (m) m->editFATE2URL();
insilmaril@175
  2670
}
insilmaril@175
  2671
insilmaril@721
  2672
void Main::editHeadingFinished(VymModel *m)
insilmaril@394
  2673
{
insilmaril@721
  2674
	if (m)
insilmaril@721
  2675
	{
insilmaril@721
  2676
		if (!actionSettingsAutoSelectNewBranch->isOn() && 
insilmaril@721
  2677
			!prevSelection.isEmpty()) 
insilmaril@721
  2678
			m->select(prevSelection);
insilmaril@721
  2679
		prevSelection="";
insilmaril@721
  2680
	}
insilmaril@394
  2681
}
insilmaril@394
  2682
insilmaril@366
  2683
void Main::openVymLinks(const QStringList &vl)
insilmaril@366
  2684
{
insilmaril@366
  2685
	for (int j=0; j<vl.size(); j++)
insilmaril@366
  2686
	{
insilmaril@0
  2687
		// compare path with already loaded maps
insilmaril@0
  2688
		int index=-1;
insilmaril@0
  2689
		int i;
insilmaril@725
  2690
		for (i=0;i<=tabModel.count() -1;i++)
insilmaril@0
  2691
		{
insilmaril@725
  2692
			if (vl.at(j)==tabModel.at(i)->getFilePath() )
insilmaril@0
  2693
			{
insilmaril@0
  2694
				index=i;
insilmaril@0
  2695
				break;
insilmaril@0
  2696
			}
insilmaril@0
  2697
		}	
insilmaril@0
  2698
		if (index<0)
insilmaril@0
  2699
		// Load map
insilmaril@0
  2700
		{
insilmaril@366
  2701
			if (!QFile(vl.at(j)).exists() )
insilmaril@0
  2702
				QMessageBox::critical( 0, tr( "Critical Error" ),
insilmaril@366
  2703
				   tr("Couldn't open map %1").arg(vl.at(j)));
insilmaril@0
  2704
			else
insilmaril@0
  2705
			{
insilmaril@366
  2706
				fileLoad (vl.at(j), NewMap);
insilmaril@725
  2707
				tabWidget->setCurrentIndex (tabWidget->count()-1);	
insilmaril@0
  2708
			}
insilmaril@0
  2709
		} else
insilmaril@0
  2710
			// Go to tab containing the map
insilmaril@725
  2711
			tabWidget->setCurrentIndex (index);	
insilmaril@0
  2712
	}
insilmaril@0
  2713
}
insilmaril@0
  2714
insilmaril@366
  2715
void Main::editOpenVymLink()
insilmaril@366
  2716
{
insilmaril@721
  2717
	VymModel *m=currentModel();
insilmaril@721
  2718
	if (m)
insilmaril@366
  2719
	{
insilmaril@366
  2720
		QStringList vl;
insilmaril@721
  2721
		vl.append(m->getVymLink());	
insilmaril@366
  2722
		openVymLinks (vl);
insilmaril@366
  2723
	}
insilmaril@366
  2724
}
insilmaril@366
  2725
insilmaril@366
  2726
void Main::editOpenMultipleVymLinks()
insilmaril@366
  2727
{
insilmaril@366
  2728
	QString currentVymLink;
insilmaril@721
  2729
	VymModel *m=currentModel();
insilmaril@721
  2730
	if (m)
insilmaril@366
  2731
	{
insilmaril@721
  2732
		QStringList vl=m->getVymLinks();
insilmaril@366
  2733
		openVymLinks (vl);
insilmaril@366
  2734
	}
insilmaril@366
  2735
}
insilmaril@366
  2736
insilmaril@0
  2737
void Main::editVymLink()
insilmaril@0
  2738
{
insilmaril@721
  2739
	VymModel *m=currentModel();
insilmaril@721
  2740
	if (m)
insilmaril@721
  2741
		m->editVymLink();	
insilmaril@0
  2742
}
insilmaril@0
  2743
insilmaril@0
  2744
void Main::editDeleteVymLink()
insilmaril@0
  2745
{
insilmaril@721
  2746
	VymModel *m=currentModel();
insilmaril@721
  2747
	if (m) m->deleteVymLink();	
insilmaril@0
  2748
}
insilmaril@0
  2749
insilmaril@243
  2750
void Main::editToggleHideExport()
insilmaril@243
  2751
{
insilmaril@721
  2752
	VymModel *m=currentModel();
insilmaril@721
  2753
	if (m) m->toggleHideExport();	
insilmaril@243
  2754
}
insilmaril@243
  2755
insilmaril@0
  2756
void Main::editMapInfo()
insilmaril@0
  2757
{
insilmaril@721
  2758
	VymModel *m=currentModel();
insilmaril@721
  2759
insilmaril@721
  2760
	ExtraInfoDialog dia;
insilmaril@721
  2761
	dia.setMapName (m->getFileName() );
insilmaril@721
  2762
	dia.setAuthor (m->getAuthor() );
insilmaril@721
  2763
	dia.setComment(m->getComment() );
insilmaril@721
  2764
insilmaril@721
  2765
	// Calc some stats
insilmaril@721
  2766
	QString stats;
insilmaril@746
  2767
/* FIXME-2 no stats at the moment (view dependent...)
insilmaril@721
  2768
    stats+=tr("%1 items on map\n","Info about map").arg (mapScene->items().size(),6);
insilmaril@721
  2769
insilmaril@721
  2770
	uint b=0;
insilmaril@721
  2771
	uint f=0;
insilmaril@721
  2772
	uint n=0;
insilmaril@721
  2773
	uint xl=0;
insilmaril@721
  2774
	BranchObj *bo;
insilmaril@721
  2775
	bo=m->first();
insilmaril@721
  2776
	while (bo) 
insilmaril@721
  2777
	{
insilmaril@721
  2778
		if (!bo->getNote().isEmpty() ) n++;
insilmaril@721
  2779
		f+= bo->countFloatImages();
insilmaril@721
  2780
		b++;
insilmaril@721
  2781
		xl+=bo->countXLinks();
insilmaril@721
  2782
		bo=m->next(bo);
insilmaril@721
  2783
	}
insilmaril@721
  2784
    stats+=QString ("%1 xLinks \n").arg (xl,6);
insilmaril@721
  2785
    stats+=QString ("%1 notes\n").arg (n,6);
insilmaril@721
  2786
    stats+=QString ("%1 images\n").arg (f,6);
insilmaril@742
  2787
*/
insilmaril@749
  2788
    stats+=QString ("%1 branches\n").arg (m->branchCount(),6);
insilmaril@721
  2789
	dia.setStats (stats);
insilmaril@721
  2790
insilmaril@721
  2791
	// Finally show dialog
insilmaril@721
  2792
	if (dia.exec() == QDialog::Accepted)
insilmaril@721
  2793
	{
insilmaril@721
  2794
		m->setAuthor (dia.getAuthor() );
insilmaril@721
  2795
		m->setComment (dia.getComment() );
insilmaril@721
  2796
	}
insilmaril@0
  2797
}
insilmaril@0
  2798
insilmaril@0
  2799
void Main::editMoveUp()
insilmaril@0
  2800
{
insilmaril@721
  2801
	VymModel *m=currentModel();
insilmaril@767
  2802
	if (m) m->moveUp();
insilmaril@0
  2803
}
insilmaril@0
  2804
insilmaril@0
  2805
void Main::editMoveDown()
insilmaril@0
  2806
{
insilmaril@721
  2807
	VymModel *m=currentModel();
insilmaril@767
  2808
	if (m) m->moveDown();
insilmaril@0
  2809
}
insilmaril@0
  2810
insilmaril@608
  2811
void Main::editSortChildren()
insilmaril@608
  2812
{
insilmaril@721
  2813
	VymModel *m=currentModel();
insilmaril@721
  2814
	if (m) m->sortChildren();
insilmaril@608
  2815
}
insilmaril@608
  2816
insilmaril@0
  2817
void Main::editToggleScroll()
insilmaril@0
  2818
{
insilmaril@721
  2819
	VymModel *m=currentModel();
insilmaril@721
  2820
	if (m) m->toggleScroll();
insilmaril@721
  2821
}
insilmaril@721
  2822
insilmaril@763
  2823
void Main::editExpandAll()
insilmaril@763
  2824
{
insilmaril@763
  2825
	VymModel *m=currentModel();
insilmaril@763
  2826
	if (m) m->emitExpandAll();
insilmaril@763
  2827
}
insilmaril@763
  2828
insilmaril@721
  2829
void Main::editUnscrollChildren()
insilmaril@721
  2830
{
insilmaril@721
  2831
	VymModel *m=currentModel();
insilmaril@721
  2832
	if (m) m->unscrollChildren();
insilmaril@721
  2833
}
insilmaril@721
  2834
insilmaril@721
  2835
void Main::editAddMapCenter()
insilmaril@721
  2836
{
insilmaril@721
  2837
	VymModel *m=currentModel();
insilmaril@725
  2838
	if (m)
insilmaril@0
  2839
	{
insilmaril@753
  2840
		cout <<"Main::editAddMapCenter\n";
insilmaril@721
  2841
		m->addMapCenter ();
insilmaril@0
  2842
	}	
insilmaril@0
  2843
}
insilmaril@0
  2844
insilmaril@394
  2845
void Main::editNewBranch()
insilmaril@394
  2846
{
insilmaril@721
  2847
	VymModel *m=currentModel();
insilmaril@725
  2848
	if (m)
insilmaril@0
  2849
	{
insilmaril@753
  2850
		BranchItem *bi=m->createBranch();
insilmaril@753
  2851
insilmaril@753
  2852
		if (bi) 
insilmaril@753
  2853
			m->select (bi);
insilmaril@394
  2854
		else
insilmaril@394
  2855
			return;
insilmaril@394
  2856
insilmaril@537
  2857
		if (actionSettingsAutoEditNewBranch->isOn())
insilmaril@394
  2858
		{
insilmaril@721
  2859
			currentMapEditor()->editHeading();
insilmaril@534
  2860
			return;
insilmaril@534
  2861
		}	
insilmaril@534
  2862
		if (!prevSelection.isEmpty()) 
insilmaril@534
  2863
		{
insilmaril@721
  2864
			m->select(prevSelection);
insilmaril@534
  2865
			prevSelection="";
insilmaril@394
  2866
		}
insilmaril@0
  2867
	}	
insilmaril@0
  2868
}
insilmaril@0
  2869
insilmaril@394
  2870
void Main::editNewBranchBefore()
insilmaril@0
  2871
{
insilmaril@721
  2872
	VymModel *m=currentModel();
insilmaril@725
  2873
	if (m)
insilmaril@394
  2874
	{
insilmaril@753
  2875
		BranchItem *bi=m->createBranch(); //FIXME-1 missing: m->addNewBranchBefore();
insilmaril@753
  2876
insilmaril@753
  2877
		if (bi) 
insilmaril@753
  2878
			m->select (bi);
insilmaril@394
  2879
		else
insilmaril@394
  2880
			return;
insilmaril@394
  2881
insilmaril@537
  2882
		if (actionSettingsAutoEditNewBranch->isOn())
insilmaril@394
  2883
		{
insilmaril@537
  2884
			if (!actionSettingsAutoSelectNewBranch->isOn())
insilmaril@753
  2885
				prevSelection=m->getSelectString(bi); 
insilmaril@721
  2886
			currentMapEditor()->editHeading();
insilmaril@394
  2887
		}
insilmaril@394
  2888
	}	
insilmaril@98
  2889
}
insilmaril@98
  2890
insilmaril@0
  2891
void Main::editNewBranchAbove()
insilmaril@0
  2892
{
insilmaril@721
  2893
	VymModel *m=currentModel();
insilmaril@725
  2894
	if ( m)
insilmaril@394
  2895
	{
insilmaril@763
  2896
		BranchItem *bi=m->addNewBranch (-1);
insilmaril@753
  2897
insilmaril@753
  2898
insilmaril@753
  2899
		if (bi) 
insilmaril@753
  2900
			m->select (bi);
insilmaril@394
  2901
		else
insilmaril@394
  2902
			return;
insilmaril@394
  2903
insilmaril@537
  2904
		if (actionSettingsAutoEditNewBranch->isOn())
insilmaril@394
  2905
		{
insilmaril@537
  2906
			if (!actionSettingsAutoSelectNewBranch->isOn())
insilmaril@753
  2907
				prevSelection=m->getSelectString (bi);	
insilmaril@721
  2908
			currentMapEditor()->editHeading();
insilmaril@394
  2909
		}
insilmaril@394
  2910
	}	
insilmaril@0
  2911
}
insilmaril@0
  2912
insilmaril@0
  2913
void Main::editNewBranchBelow()
insilmaril@0
  2914
{
insilmaril@721
  2915
	VymModel *m=currentModel();
insilmaril@725
  2916
	if (m)
insilmaril@394
  2917
	{
insilmaril@763
  2918
		BranchItem *bi=m->addNewBranch (1);
insilmaril@753
  2919
insilmaril@753
  2920
		if (bi) 
insilmaril@753
  2921
			m->select (bi);
insilmaril@394
  2922
		else
insilmaril@394
  2923
			return;
insilmaril@394
  2924
insilmaril@537
  2925
		if (actionSettingsAutoEditNewBranch->isOn())
insilmaril@394
  2926
		{
insilmaril@537
  2927
			if (!actionSettingsAutoSelectNewBranch->isOn())
insilmaril@753
  2928
				prevSelection=m->getSelectString(bi);
insilmaril@721
  2929
			currentMapEditor()->editHeading();
insilmaril@394
  2930
		}
insilmaril@394
  2931
	}	
insilmaril@0
  2932
}
insilmaril@0
  2933
insilmaril@0
  2934
void Main::editImportAdd()
insilmaril@0
  2935
{
insilmaril@0
  2936
	fileLoad (ImportAdd);
insilmaril@0
  2937
}
insilmaril@0
  2938
insilmaril@0
  2939
void Main::editImportReplace()
insilmaril@0
  2940
{
insilmaril@0
  2941
	fileLoad (ImportReplace);
insilmaril@0
  2942
}
insilmaril@0
  2943
insilmaril@0
  2944
void Main::editSaveBranch()
insilmaril@0
  2945
{
insilmaril@0
  2946
	fileSaveAs (PartOfMap);
insilmaril@0
  2947
}
insilmaril@0
  2948
insilmaril@721
  2949
void Main::editDeleteKeepChildren()
insilmaril@98
  2950
{
insilmaril@721
  2951
	VymModel *m=currentModel();
insilmaril@721
  2952
	 if (m) m->deleteKeepChildren();
insilmaril@98
  2953
}
insilmaril@98
  2954
insilmaril@721
  2955
void Main::editDeleteChildren()
insilmaril@98
  2956
{
insilmaril@721
  2957
	VymModel *m=currentModel();
insilmaril@721
  2958
	if (m) m->deleteChildren();
insilmaril@98
  2959
}
insilmaril@98
  2960
insilmaril@0
  2961
void Main::editDeleteSelection()
insilmaril@0
  2962
{
insilmaril@721
  2963
	VymModel *m=currentModel();
insilmaril@721
  2964
	if (m && actionSettingsUseDelKey->isOn())
insilmaril@721
  2965
		m->deleteSelection();
insilmaril@0
  2966
}
insilmaril@0
  2967
insilmaril@0
  2968
void Main::editUpperBranch()
insilmaril@0
  2969
{
insilmaril@721
  2970
	VymModel *m=currentModel();
insilmaril@757
  2971
	if (m) m->selectUpperBranch();	// FIXME-3 check also lower... this probably should go into view...
insilmaril@0
  2972
}
insilmaril@0
  2973
insilmaril@757
  2974
void Main::editLowerBranch()	// FIXME-3 check also lower... this probably should go into view...
insilmaril@757
  2975
insilmaril@0
  2976
{
insilmaril@721
  2977
	VymModel *m=currentModel();
insilmaril@721
  2978
	if (m) m->selectLowerBranch();
insilmaril@0
  2979
}
insilmaril@0
  2980
insilmaril@0
  2981
void Main::editLeftBranch()
insilmaril@0
  2982
{
insilmaril@721
  2983
	VymModel *m=currentModel();
insilmaril@721
  2984
	if (m) m->selectLeftBranch();
insilmaril@0
  2985
}
insilmaril@0
  2986
insilmaril@0
  2987
void Main::editRightBranch()
insilmaril@0
  2988
{
insilmaril@721
  2989
	VymModel *m=currentModel();
insilmaril@721
  2990
	if (m) m->selectRightBranch();
insilmaril@0
  2991
}
insilmaril@0
  2992
insilmaril@0
  2993
void Main::editFirstBranch()
insilmaril@0
  2994
{
insilmaril@721
  2995
	VymModel *m=currentModel();
insilmaril@721
  2996
	if (m) m->selectFirstBranch();
insilmaril@0
  2997
}
insilmaril@0
  2998
insilmaril@0
  2999
void Main::editLastBranch()
insilmaril@0
  3000
{
insilmaril@721
  3001
	VymModel *m=currentModel();
insilmaril@721
  3002
	if (m) m->selectLastBranch();
insilmaril@0
  3003
}
insilmaril@0
  3004
insilmaril@0
  3005
void Main::editLoadImage()
insilmaril@0
  3006
{
insilmaril@721
  3007
	VymModel *m=currentModel();
insilmaril@721
  3008
	if (m) m->loadFloatImage();
insilmaril@0
  3009
}
insilmaril@0
  3010
insilmaril@366
  3011
void Main::editSaveImage()
insilmaril@0
  3012
{
insilmaril@721
  3013
	VymModel *m=currentModel();
insilmaril@721
  3014
	if (m) m->saveFloatImage();
insilmaril@0
  3015
}
insilmaril@0
  3016
insilmaril@366
  3017
void Main::editFollowXLink(QAction *a)
insilmaril@366
  3018
{
insilmaril@366
  3019
insilmaril@721
  3020
	VymModel *m=currentModel();
insilmaril@721
  3021
	if (m)
insilmaril@721
  3022
		m->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
insilmaril@366
  3023
}
insilmaril@366
  3024
insilmaril@366
  3025
void Main::editEditXLink(QAction *a)
insilmaril@89
  3026
{
insilmaril@721
  3027
	VymModel *m=currentModel();
insilmaril@721
  3028
	if (m)
insilmaril@721
  3029
		m->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
insilmaril@94
  3030
}
insilmaril@94
  3031
insilmaril@0
  3032
void Main::formatSelectColor()
insilmaril@0
  3033
{
insilmaril@721
  3034
	QColor col = QColorDialog::getColor((currentColor ), this );
insilmaril@721
  3035
	if ( !col.isValid() ) return;
insilmaril@721
  3036
	colorChanged( col );
insilmaril@0
  3037
}
insilmaril@0
  3038
insilmaril@0
  3039
void Main::formatPickColor()
insilmaril@0
  3040
{
insilmaril@721
  3041
	VymModel *m=currentModel();
insilmaril@721
  3042
	if (m)
insilmaril@721
  3043
		colorChanged( m->getCurrentHeadingColor() );
insilmaril@0
  3044
}
insilmaril@0
  3045
insilmaril@0
  3046
void Main::colorChanged(QColor c)
insilmaril@0
  3047
{
insilmaril@0
  3048
    QPixmap pix( 16, 16 );
insilmaril@0
  3049
    pix.fill( c );
insilmaril@0
  3050
    actionFormatColor->setIconSet( pix );
insilmaril@395
  3051
	currentColor=c;
insilmaril@0
  3052
}
insilmaril@0
  3053
insilmaril@0
  3054
void Main::formatColorBranch()
insilmaril@0
  3055
{
insilmaril@721
  3056
	VymModel *m=currentModel();
insilmaril@721
  3057
	if (m) m->colorBranch(currentColor);
insilmaril@0
  3058
}
insilmaril@0
  3059
insilmaril@417
  3060
void Main::formatColorSubtree()
insilmaril@417
  3061
{
insilmaril@721
  3062
	VymModel *m=currentModel();
insilmaril@721
  3063
	if (m) m->colorSubtree (currentColor);
insilmaril@417
  3064
}
insilmaril@417
  3065
insilmaril@0
  3066
void Main::formatLinkStyleLine()
insilmaril@0
  3067
{
insilmaril@721
  3068
	VymModel *m=currentModel();
insilmaril@721
  3069
	if (m)
insilmaril@625
  3070
    {
insilmaril@721
  3071
		m->setMapLinkStyle("StyleLine");
insilmaril@625
  3072
        actionFormatLinkStyleLine->setOn(true);
insilmaril@625
  3073
    }
insilmaril@0
  3074
}
insilmaril@0
  3075
insilmaril@0
  3076
void Main::formatLinkStyleParabel()
insilmaril@0
  3077
{
insilmaril@721
  3078
	VymModel *m=currentModel();
insilmaril@721
  3079
	if (m)
insilmaril@625
  3080
    {
insilmaril@721
  3081
		m->setMapLinkStyle("StyleParabel");
insilmaril@625
  3082
        actionFormatLinkStyleParabel->setOn(true);
insilmaril@625
  3083
    }
insilmaril@0
  3084
}
insilmaril@0
  3085
insilmaril@0
  3086
void Main::formatLinkStylePolyLine()
insilmaril@0
  3087
{
insilmaril@721
  3088
	VymModel *m=currentModel();
insilmaril@721
  3089
	if (m)
insilmaril@625
  3090
    {
insilmaril@721
  3091
		m->setMapLinkStyle("StylePolyLine");
insilmaril@625
  3092
        actionFormatLinkStylePolyLine->setOn(true);
insilmaril@625
  3093
    }
insilmaril@0
  3094
}
insilmaril@0
  3095
insilmaril@0
  3096
void Main::formatLinkStylePolyParabel()
insilmaril@0
  3097
{
insilmaril@721
  3098
	VymModel *m=currentModel();
insilmaril@721
  3099
	if (m)
insilmaril@625
  3100
    {
insilmaril@721
  3101
		m->setMapLinkStyle("StylePolyParabel");
insilmaril@625
  3102
        actionFormatLinkStylePolyParabel->setOn(true);
insilmaril@625
  3103
    }
insilmaril@0
  3104
}
insilmaril@0
  3105
insilmaril@0
  3106
void Main::formatSelectBackColor()
insilmaril@0
  3107
{
insilmaril@721
  3108
	VymModel *m=currentModel();
insilmaril@721
  3109
	if (m) m->selectMapBackgroundColor();
insilmaril@0
  3110
}
insilmaril@0
  3111
insilmaril@408
  3112
void Main::formatSelectBackImage()
insilmaril@408
  3113
{
insilmaril@721
  3114
	VymModel *m=currentModel();
insilmaril@721
  3115
	if (m)
insilmaril@721
  3116
		m->selectMapBackgroundImage();
insilmaril@408
  3117
}
insilmaril@408
  3118
insilmaril@0
  3119
void Main::formatSelectLinkColor()
insilmaril@0
  3120
{
insilmaril@721
  3121
	VymModel *m=currentModel();
insilmaril@721
  3122
	if (m)
insilmaril@721
  3123
	{
insilmaril@721
  3124
		QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
insilmaril@721
  3125
		m->setMapDefLinkColor( col );
insilmaril@721
  3126
	}
insilmaril@0
  3127
}
insilmaril@0
  3128
insilmaril@442
  3129
void Main::formatSelectSelectionColor()
insilmaril@442
  3130
{
insilmaril@721
  3131
	VymModel *m=currentModel();
insilmaril@721
  3132
	if (m)
insilmaril@721
  3133
	{
insilmaril@721
  3134
		QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
insilmaril@721
  3135
		m->setSelectionColor (col);
insilmaril@721
  3136
	}
insilmaril@721
  3137
insilmaril@442
  3138
}
insilmaril@442
  3139
insilmaril@0
  3140
void Main::formatToggleLinkColorHint()
insilmaril@0
  3141
{
insilmaril@721
  3142
	VymModel *m=currentModel();
insilmaril@721
  3143
	if (m) m->toggleMapLinkColorHint();
insilmaril@0
  3144
}
insilmaril@0
  3145
insilmaril@0
  3146
insilmaril@746
  3147
void Main::formatHideLinkUnselected()	//FIXME-3 get rid of this with imagepropertydialog
insilmaril@160
  3148
{
insilmaril@721
  3149
	VymModel *m=currentModel();
insilmaril@721
  3150
	if (m)
insilmaril@721
  3151
		m->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
insilmaril@160
  3152
}
insilmaril@160
  3153
insilmaril@0
  3154
void Main::viewZoomReset()
insilmaril@0
  3155
{
insilmaril@767
  3156
	MapEditor *me=currentMapEditor();
insilmaril@767
  3157
	if (me) me->setZoomFactorTarget (1);
insilmaril@0
  3158
}
insilmaril@0
  3159
insilmaril@0
  3160
void Main::viewZoomIn()
insilmaril@0
  3161
{
insilmaril@767
  3162
	MapEditor *me=currentMapEditor();
insilmaril@767
  3163
	if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*1.25);
insilmaril@0
  3164
}
insilmaril@0
  3165
insilmaril@0
  3166
void Main::viewZoomOut()
insilmaril@0
  3167
{
insilmaril@767
  3168
	MapEditor *me=currentMapEditor();
insilmaril@767
  3169
	if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*0.75);
insilmaril@0
  3170
}
insilmaril@89
  3171
insilmaril@526
  3172
void Main::viewCenter()
insilmaril@526
  3173
{
insilmaril@721
  3174
	VymModel *m=currentModel();
insilmaril@763
  3175
	if (m) m->emitShowSelection();
insilmaril@526
  3176
}
insilmaril@526
  3177
insilmaril@528
  3178
void Main::networkStartServer()
insilmaril@528
  3179
{
insilmaril@721
  3180
	VymModel *m=currentModel();
insilmaril@721
  3181
	if (m) m->newServer();
insilmaril@528
  3182
}
insilmaril@528
  3183
insilmaril@528
  3184
void Main::networkConnect()
insilmaril@528
  3185
{
insilmaril@721
  3186
	VymModel *m=currentModel();
insilmaril@721
  3187
	if (m) m->connectToServer();
insilmaril@528
  3188
}
insilmaril@528
  3189
insilmaril@0
  3190
bool Main::settingsPDF()
insilmaril@0
  3191
{
insilmaril@0
  3192
	// Default browser is set in constructor
insilmaril@0
  3193
	bool ok;
insilmaril@0
  3194
	QString text = QInputDialog::getText(
insilmaril@266
  3195
		"VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
insilmaril@366
  3196
		settings.value("/mainwindow/readerPDF").toString(), &ok, this );
insilmaril@0
  3197
	if (ok)
insilmaril@366
  3198
		settings.setValue ("/mainwindow/readerPDF",text);
insilmaril@0
  3199
	return ok;
insilmaril@0
  3200
}
insilmaril@0
  3201
insilmaril@0
  3202
insilmaril@0
  3203
bool Main::settingsURL()
insilmaril@0
  3204
{
insilmaril@0
  3205
	// Default browser is set in constructor
insilmaril@0
  3206
	bool ok;
insilmaril@0
  3207
	QString text = QInputDialog::getText(
insilmaril@266
  3208
		"VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
insilmaril@366
  3209
		settings.value("/mainwindow/readerURL").toString()
insilmaril@0
  3210
		, &ok, this );
insilmaril@0
  3211
	if (ok)
insilmaril@366
  3212
		settings.setValue ("/mainwindow/readerURL",text);
insilmaril@0
  3213
	return ok;
insilmaril@0
  3214
}
insilmaril@0
  3215
insilmaril@450
  3216
void Main::settingsMacroDir()
insilmaril@450
  3217
{
insilmaril@625
  3218
	QDir defdir(vymBaseDir.path() + "/macros");
insilmaril@450
  3219
	if (!defdir.exists())
insilmaril@450
  3220
		defdir=vymBaseDir;
insilmaril@450
  3221
	QDir dir=QFileDialog::getExistingDirectory (
insilmaril@450
  3222
		this,
insilmaril@450
  3223
		tr ("Directory with vym macros:"), 
insilmaril@450
  3224
		settings.value ("/macros/macroDir",defdir.path()).toString()
insilmaril@450
  3225
	);
insilmaril@450
  3226
	if (dir.exists())
insilmaril@625
  3227
		settings.setValue ("/macros/macroDir",dir.absolutePath());
insilmaril@450
  3228
}
insilmaril@450
  3229
insilmaril@473
  3230
void Main::settingsUndoLevels()
insilmaril@473
  3231
{
insilmaril@473
  3232
	bool ok;
insilmaril@473
  3233
	int i = QInputDialog::getInteger(
insilmaril@473
  3234
		this, 
insilmaril@473
  3235
		tr("QInputDialog::getInteger()"),
insilmaril@473
  3236
	    tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
insilmaril@473
  3237
	if (ok)
insilmaril@473
  3238
	{
insilmaril@473
  3239
		settings.setValue ("/mapeditor/stepsTotal",i);
insilmaril@473
  3240
		QMessageBox::information( this, tr( "VYM -Information:" ),
insilmaril@473
  3241
		   tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i)); 
insilmaril@473
  3242
   }	
insilmaril@473
  3243
}
insilmaril@473
  3244
insilmaril@473
  3245
void Main::settingsAutosaveToggle()
insilmaril@473
  3246
{
insilmaril@742
  3247
	settings.setValue ("/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
insilmaril@473
  3248
}
insilmaril@473
  3249
insilmaril@473
  3250
void Main::settingsAutosaveTime()
insilmaril@473
  3251
{
insilmaril@473
  3252
	bool ok;
insilmaril@473
  3253
	int i = QInputDialog::getInteger(
insilmaril@473
  3254
		this, 
insilmaril@473
  3255
		tr("QInputDialog::getInteger()"),
insilmaril@742
  3256
	    tr("Number of seconds before autosave:"), settings.value("/mainwindow/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
insilmaril@473
  3257
	if (ok)
insilmaril@742
  3258
		settings.setValue ("/mainwindow/autosave/ms",i * 1000);
insilmaril@473
  3259
}
insilmaril@473
  3260
insilmaril@625
  3261
void Main::settingsWriteBackupFileToggle()
insilmaril@625
  3262
{
insilmaril@742
  3263
	settings.setValue ("/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
insilmaril@625
  3264
}
insilmaril@625
  3265
insilmaril@689
  3266
void Main::settingsToggleAnimation()
insilmaril@689
  3267
{
insilmaril@689
  3268
	settings.setValue ("/animation/use",actionSettingsUseAnimation->isOn() );
insilmaril@689
  3269
}
insilmaril@689
  3270
insilmaril@327
  3271
void Main::settingsToggleDelKey()
insilmaril@327
  3272
{
insilmaril@327
  3273
	if (actionSettingsUseDelKey->isOn())
insilmaril@327
  3274
	{
insilmaril@723
  3275
		actionDelete->setAccel (QKeySequence (Qt::Key_Delete));
insilmaril@327
  3276
	} else
insilmaril@327
  3277
	{
insilmaril@723
  3278
		actionDelete->setAccel (QKeySequence (""));
insilmaril@327
  3279
	}
insilmaril@327
  3280
}
insilmaril@327
  3281
insilmaril@0
  3282
void Main::windowToggleNoteEditor()
insilmaril@0
  3283
{
insilmaril@502
  3284
	if (textEditor->isVisible() )
insilmaril@497
  3285
		windowHideNoteEditor();
insilmaril@497
  3286
	else
insilmaril@497
  3287
		windowShowNoteEditor();
insilmaril@0
  3288
}
insilmaril@0
  3289
insilmaril@294
  3290
void Main::windowToggleHistory()
insilmaril@294
  3291
{
insilmaril@404
  3292
	if (historyWindow->isVisible())
insilmaril@404
  3293
		historyWindow->hide();
insilmaril@404
  3294
	else	
insilmaril@404
  3295
		historyWindow->show();
insilmaril@404
  3296
insilmaril@404
  3297
}
insilmaril@404
  3298
insilmaril@473
  3299
void Main::windowToggleProperty()
insilmaril@473
  3300
{
insilmaril@473
  3301
	if (branchPropertyWindow->isVisible())
insilmaril@473
  3302
		branchPropertyWindow->hide();
insilmaril@473
  3303
	else	
insilmaril@473
  3304
		branchPropertyWindow->show();
insilmaril@721
  3305
	branchPropertyWindow->setModel (currentModel() );
insilmaril@473
  3306
}
insilmaril@473
  3307
insilmaril@408
  3308
void Main::windowToggleAntiAlias()
insilmaril@408
  3309
{
insilmaril@408
  3310
	bool b=actionViewToggleAntiAlias->isOn();
insilmaril@408
  3311
	MapEditor *me;
insilmaril@725
  3312
	for (int i=0;i<tabModel.count();i++)
insilmaril@408
  3313
	{
insilmaril@725
  3314
		me=tabModel.at(i)->getMapEditor();
insilmaril@725
  3315
		if (me) me->setAntiAlias(b);
insilmaril@408
  3316
	}	
insilmaril@408
  3317
insilmaril@408
  3318
}
insilmaril@408
  3319
insilmaril@732
  3320
bool Main::isAliased()
insilmaril@732
  3321
{
insilmaril@732
  3322
	return actionViewToggleAntiAlias->isOn();
insilmaril@732
  3323
}
insilmaril@732
  3324
insilmaril@732
  3325
bool Main::hasSmoothPixmapTransform()
insilmaril@732
  3326
{
insilmaril@732
  3327
	return actionViewToggleSmoothPixmapTransform->isOn();
insilmaril@732
  3328
}
insilmaril@732
  3329
insilmaril@408
  3330
void Main::windowToggleSmoothPixmap()
insilmaril@408
  3331
{
insilmaril@408
  3332
	bool b=actionViewToggleSmoothPixmapTransform->isOn();
insilmaril@408
  3333
	MapEditor *me;
insilmaril@725
  3334
	for (int i=0;i<tabModel.count();i++)
insilmaril@408
  3335
	{
insilmaril@408
  3336
		
insilmaril@725
  3337
		me=tabModel.at(i)->getMapEditor();
insilmaril@725
  3338
		if (me) me->setSmoothPixmap(b);
insilmaril@408
  3339
	}	
insilmaril@408
  3340
}
insilmaril@408
  3341
insilmaril@404
  3342
void Main::updateHistory(SimpleSettings &undoSet)
insilmaril@404
  3343
{
insilmaril@404
  3344
	historyWindow->update (undoSet);
insilmaril@294
  3345
}
insilmaril@294
  3346
insilmaril@746
  3347
void Main::updateNoteFlag()	
insilmaril@160
  3348
{
insilmaril@721
  3349
	// this slot is connected to TextEditor::textHasChanged()
insilmaril@721
  3350
insilmaril@721
  3351
	VymModel *m=currentModel();
insilmaril@721
  3352
	if (m) m->updateNoteFlag();
insilmaril@160
  3353
}
insilmaril@160
  3354
insilmaril@753
  3355
void Main::updateNoteEditor(QModelIndex index )
insilmaril@746
  3356
{
insilmaril@754
  3357
	TreeItem *ti=((VymModel*)sender())->getItem(index);
insilmaril@754
  3358
	/*
insilmaril@753
  3359
	cout << "Main::updateNoteEditor model="<<sender();
insilmaril@754
  3360
	cout << "  item="<<ti->headingStd()<<" ("<<ti<<")"<<endl;
insilmaril@754
  3361
	*/
insilmaril@746
  3362
	textEditor->setNote (ti->getNoteObj() );
insilmaril@746
  3363
}
insilmaril@746
  3364
insilmaril@746
  3365
void Main::changeSelection (VymModel *model, const QItemSelection &newsel, const QItemSelection &oldsel)
insilmaril@746
  3366
{
insilmaril@768
  3367
	//branchPropertyWindow->setModel (model ); //FIXME-2 this used to be called from BranchObj::select(). Maybe use signal now...
insilmaril@748
  3368
insilmaril@746
  3369
	if (model && model==currentModel() )
insilmaril@746
  3370
	{
insilmaril@746
  3371
		// NoteEditor
insilmaril@746
  3372
		TreeItem *ti;
insilmaril@746
  3373
		if (!oldsel.indexes().isEmpty() )
insilmaril@746
  3374
		{
insilmaril@746
  3375
			ti=model->getItem(oldsel.indexes().first());
insilmaril@768
  3376
insilmaril@768
  3377
			// Don't update note if both treeItem and textEditor are empty
insilmaril@768
  3378
			//if (! (ti->hasEmptyNote() && textEditor->isEmpty() ))
insilmaril@768
  3379
			//	ti->setNoteObj (textEditor->getNoteObj(),false );
insilmaril@746
  3380
		} 
insilmaril@746
  3381
		if (!newsel.indexes().isEmpty() )
insilmaril@746
  3382
		{
insilmaril@746
  3383
			ti=model->getItem(newsel.indexes().first());
insilmaril@768
  3384
			if (!ti->hasEmptyNote() )
insilmaril@746
  3385
				textEditor->setNote(ti->getNoteObj() );
insilmaril@768
  3386
			else
insilmaril@768
  3387
				textEditor->setNote(NoteObj() );	//FIXME-4 maybe add a clear() to TE
insilmaril@746
  3388
		} else
insilmaril@746
  3389
			textEditor->setInactive();
insilmaril@746
  3390
insilmaril@768
  3391
		// Show URL and link in statusbar	
insilmaril@746
  3392
		QString status;
insilmaril@746
  3393
		QString s=model->getURL();
insilmaril@746
  3394
		if (!s.isEmpty() ) status+="URL: "+s+"  ";
insilmaril@746
  3395
		s=model->getVymLink();
insilmaril@746
  3396
		if (!s.isEmpty() ) status+="Link: "+s;
insilmaril@746
  3397
		if (!status.isEmpty() ) statusMessage (status);
insilmaril@768
  3398
insilmaril@768
  3399
		// Update Toolbar 
insilmaril@768
  3400
		//updateFlagsToolbar();  // FIXME-0, was so far in BranchObj
insilmaril@768
  3401
insilmaril@746
  3402
insilmaril@746
  3403
		updateActions();
insilmaril@746
  3404
	}
insilmaril@442
  3405
}
insilmaril@442
  3406
insilmaril@390
  3407
void Main::updateActions()
insilmaril@390
  3408
{
insilmaril@721
  3409
	VymModel  *m =currentModel();
insilmaril@724
  3410
	LinkableMapObj *selection;
insilmaril@724
  3411
	if (m) 
insilmaril@724
  3412
	{
insilmaril@724
  3413
		// Printing
insilmaril@724
  3414
		actionFilePrint->setEnabled (true);
insilmaril@724
  3415
insilmaril@724
  3416
		// Selection
insilmaril@735
  3417
		selection=m->getSelectedLMO();
insilmaril@724
  3418
insilmaril@724
  3419
		// Link style in context menu
insilmaril@724
  3420
		switch (m->getMapLinkStyle())
insilmaril@724
  3421
		{
insilmaril@724
  3422
			case LinkableMapObj::Line: 
insilmaril@724
  3423
				actionFormatLinkStyleLine->setOn(true);
insilmaril@724
  3424
				break;
insilmaril@724
  3425
			case LinkableMapObj::Parabel:
insilmaril@724
  3426
				actionFormatLinkStyleParabel->setOn(true);
insilmaril@724
  3427
				break;
insilmaril@724
  3428
			case LinkableMapObj::PolyLine:	
insilmaril@724
  3429
				actionFormatLinkStylePolyLine->setOn(true);
insilmaril@724
  3430
				break;
insilmaril@724
  3431
			case LinkableMapObj::PolyParabel:	
insilmaril@724
  3432
				actionFormatLinkStylePolyParabel->setOn(true);
insilmaril@724
  3433
				break;
insilmaril@724
  3434
			default:
insilmaril@724
  3435
				break;
insilmaril@724
  3436
		}		
insilmaril@724
  3437
insilmaril@724
  3438
		// Update colors
insilmaril@724
  3439
		QPixmap pix( 16, 16 );
insilmaril@724
  3440
		pix.fill( m->getMapBackgroundColor() );
insilmaril@724
  3441
		actionFormatBackColor->setIconSet( pix );
insilmaril@724
  3442
		pix.fill( m->getSelectionColor() );
insilmaril@724
  3443
		actionFormatSelectionColor->setIconSet( pix );
insilmaril@724
  3444
		pix.fill( m->getMapDefLinkColor() );
insilmaril@724
  3445
		actionFormatLinkColor->setIconSet( pix );
insilmaril@724
  3446
insilmaril@724
  3447
		// History window
insilmaril@724
  3448
		historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName()));
insilmaril@724
  3449
insilmaril@724
  3450
	} else
insilmaril@724
  3451
	{
insilmaril@724
  3452
		// Printing
insilmaril@724
  3453
		actionFilePrint->setEnabled (false);
insilmaril@724
  3454
insilmaril@724
  3455
		// Selection
insilmaril@724
  3456
		selection=NULL;
insilmaril@724
  3457
	}
insilmaril@407
  3458
insilmaril@390
  3459
	// updateActions is also called when NoteEditor is closed
insilmaril@486
  3460
	actionViewToggleNoteEditor->setOn (textEditor->isVisible());
insilmaril@486
  3461
	actionViewToggleHistoryWindow->setOn (historyWindow->isVisible());
insilmaril@486
  3462
	actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible());
insilmaril@390
  3463
insilmaril@724
  3464
	if (m && m->getMapLinkColorHint()==LinkableMapObj::HeadingColor) 
insilmaril@390
  3465
		actionFormatLinkColorHint->setOn(true);
insilmaril@390
  3466
	else	
insilmaril@390
  3467
		actionFormatLinkColorHint->setOn(false);
insilmaril@390
  3468
insilmaril@724
  3469
insilmaril@724
  3470
	if (m && m->hasChanged() )
insilmaril@724
  3471
		actionFileSave->setEnabled( true);
insilmaril@724
  3472
	else	
insilmaril@724
  3473
		actionFileSave->setEnabled( true);
insilmaril@724
  3474
	if (m && m->isUndoAvailable())
insilmaril@723
  3475
		actionUndo->setEnabled( true);
insilmaril@390
  3476
	else	
insilmaril@723
  3477
		actionUndo->setEnabled( false);
insilmaril@390
  3478
insilmaril@724
  3479
	if (m && m->isRedoAvailable())
insilmaril@723
  3480
		actionRedo->setEnabled( true);
insilmaril@390
  3481
	else	
insilmaril@723
  3482
		actionRedo->setEnabled( false);
insilmaril@390
  3483
insilmaril@753
  3484
	TreeItem *selti=m->getSelectedItem();
insilmaril@753
  3485
	BranchItem *selbi=m->getSelectedBranchItem();
insilmaril@753
  3486
	if (selti)
insilmaril@390
  3487
	{
insilmaril@753
  3488
		if (selbi)
insilmaril@390
  3489
		{
insilmaril@749
  3490
			// Take care of links  // FIXME-1
insilmaril@749
  3491
			/*
insilmaril@390
  3492
			if (bo->countXLinks()==0)
insilmaril@390
  3493
			{
insilmaril@390
  3494
				branchXLinksContextMenuEdit->clear();
insilmaril@390
  3495
				branchXLinksContextMenuFollow->clear();
insilmaril@390
  3496
			} else
insilmaril@390
  3497
			{
insilmaril@390
  3498
				BranchObj *bot;
insilmaril@390
  3499
				QString s;
insilmaril@390
  3500
				branchXLinksContextMenuEdit->clear();
insilmaril@390
  3501
				branchXLinksContextMenuFollow->clear();
insilmaril@390
  3502
				for (int i=0; i<=bo->countXLinks();i++)
insilmaril@390
  3503
				{
insilmaril@390
  3504
					bot=bo->XLinkTargetAt(i);
insilmaril@390
  3505
					if (bot)
insilmaril@390
  3506
					{
insilmaril@390
  3507
						s=bot->getHeading();
insilmaril@600
  3508
						if (s.length()>xLinkMenuWidth)
insilmaril@600
  3509
							s=s.left(xLinkMenuWidth)+"...";
insilmaril@390
  3510
						branchXLinksContextMenuFollow->addAction (s);
insilmaril@390
  3511
						branchXLinksContextMenuEdit->addAction (s);
insilmaril@390
  3512
					}	
insilmaril@390
  3513
				}
insilmaril@390
  3514
			}
insilmaril@749
  3515
			*/
insilmaril@390
  3516
insilmaril@723
  3517
			actionToggleScroll->setEnabled (true);
insilmaril@753
  3518
			if ( selbi->isScrolled() )
insilmaril@723
  3519
				actionToggleScroll->setOn(true);
insilmaril@390
  3520
			else	
insilmaril@723
  3521
				actionToggleScroll->setOn(false);
insilmaril@390
  3522
insilmaril@767
  3523
			if ( selti->getURL().isEmpty() )
insilmaril@390
  3524
			{
insilmaril@723
  3525
				actionOpenURL->setEnabled (false);
insilmaril@723
  3526
				actionOpenURLTab->setEnabled (false);
insilmaril@390
  3527
			}	
insilmaril@390
  3528
			else	
insilmaril@390
  3529
			{
insilmaril@723
  3530
				actionOpenURL->setEnabled (true);
insilmaril@723
  3531
				actionOpenURLTab->setEnabled (true);
insilmaril@390
  3532
			}
insilmaril@753
  3533
			if ( selti->getVymLink().isEmpty() )
insilmaril@390
  3534
			{
insilmaril@723
  3535
				actionOpenVymLink->setEnabled (false);
insilmaril@723
  3536
				actionDeleteVymLink->setEnabled (false);
insilmaril@390
  3537
			} else	
insilmaril@390
  3538
			{
insilmaril@723
  3539
				actionOpenVymLink->setEnabled (true);
insilmaril@723
  3540
				actionDeleteVymLink->setEnabled (true);
insilmaril@390
  3541
			}	
insilmaril@767
  3542
insilmaril@767
  3543
            if (selbi->canMoveUp()) 
insilmaril@723
  3544
				actionMoveUp->setEnabled (true);
insilmaril@390
  3545
			else	
insilmaril@723
  3546
				actionMoveUp->setEnabled (false);
insilmaril@767
  3547
			if (selbi->canMoveDown()) 
insilmaril@723
  3548
				actionMoveDown->setEnabled (true);
insilmaril@390
  3549
			else	
insilmaril@723
  3550
				actionMoveDown->setEnabled (false);
insilmaril@767
  3551
insilmaril@724
  3552
			actionSortChildren->setEnabled (true);
insilmaril@723
  3553
insilmaril@723
  3554
			actionToggleHideExport->setEnabled (true);	
insilmaril@753
  3555
			actionToggleHideExport->setOn (selbi->hideInExport() );	
insilmaril@723
  3556
insilmaril@724
  3557
			actionFileSave->setEnabled (true);	
insilmaril@723
  3558
			actionCopy->setEnabled (true);	
insilmaril@723
  3559
			actionCut->setEnabled (true);	
insilmaril@390
  3560
			if (!clipboardEmpty)
insilmaril@723
  3561
				actionPaste->setEnabled (true);	
insilmaril@390
  3562
			else	
insilmaril@723
  3563
				actionPaste->setEnabled (false);	
insilmaril@406
  3564
			for (int i=0; i<actionListBranches.size(); ++i)	
insilmaril@406
  3565
				actionListBranches.at(i)->setEnabled(true);
insilmaril@723
  3566
			actionDelete->setEnabled (true);
insilmaril@390
  3567
			actionFormatHideLinkUnselected->setOn
insilmaril@390
  3568
				(selection->getHideLinkUnselected());
insilmaril@390
  3569
		}
insilmaril@753
  3570
		if ( selti->getType()==TreeItem::Image)
insilmaril@390
  3571
		{
insilmaril@753
  3572
		/* FIXME-2
insilmaril@390
  3573
			FloatObj *fo=(FloatImageObj*)selection;
insilmaril@390
  3574
insilmaril@723
  3575
			actionOpenURL->setEnabled (false);
insilmaril@723
  3576
			actionOpenVymLink->setEnabled (false);
insilmaril@723
  3577
			actionDeleteVymLink->setEnabled (false);	
insilmaril@723
  3578
			actionToggleHideExport->setEnabled (true);	
insilmaril@723
  3579
			actionToggleHideExport->setOn (fo->hideInExport() );	
insilmaril@723
  3580
insilmaril@723
  3581
insilmaril@723
  3582
			actionCopy->setEnabled (true);
insilmaril@723
  3583
			actionCut->setEnabled (true);	
insilmaril@767
  3584
			actionPaste->setEnabled (false);	//FIXME-4 why not allowing copy of images?
insilmaril@406
  3585
			for (int i=0; i<actionListBranches.size(); ++i)	
insilmaril@406
  3586
				actionListBranches.at(i)->setEnabled(false);
insilmaril@723
  3587
			actionDelete->setEnabled (true);
insilmaril@390
  3588
			actionFormatHideLinkUnselected->setOn
insilmaril@390
  3589
				( selection->getHideLinkUnselected());
insilmaril@723
  3590
			actionMoveUp->setEnabled (false);
insilmaril@723
  3591
			actionMoveDown->setEnabled (false);
insilmaril@753
  3592
			*/
insilmaril@390
  3593
		}
insilmaril@390
  3594
insilmaril@390
  3595
	} else
insilmaril@390
  3596
	{
insilmaril@724
  3597
		actionFileSave->setEnabled (false);	
insilmaril@723
  3598
		actionCopy->setEnabled (false);	
insilmaril@723
  3599
		actionCut->setEnabled (false);	
insilmaril@723
  3600
		actionPaste->setEnabled (false);	
insilmaril@406
  3601
		for (int i=0; i<actionListBranches.size(); ++i)	
insilmaril@406
  3602
			actionListBranches.at(i)->setEnabled(false);
insilmaril@390
  3603
insilmaril@723
  3604
		actionToggleScroll->setEnabled (false);
insilmaril@723
  3605
		actionOpenURL->setEnabled (false);
insilmaril@723
  3606
		actionOpenVymLink->setEnabled (false);
insilmaril@723
  3607
		actionDeleteVymLink->setEnabled (false);	
insilmaril@723
  3608
		actionHeading2URL->setEnabled (false);	
insilmaril@723
  3609
		actionDelete->setEnabled (false);
insilmaril@723
  3610
		actionMoveUp->setEnabled (false);
insilmaril@723
  3611
		actionMoveDown->setEnabled (false);
insilmaril@724
  3612
		actionSortChildren->setEnabled (false);
insilmaril@723
  3613
		actionToggleHideExport->setEnabled (false);	
insilmaril@390
  3614
	}	
insilmaril@390
  3615
}
insilmaril@390
  3616
insilmaril@473
  3617
Main::ModMode Main::getModMode()
insilmaril@390
  3618
{
insilmaril@390
  3619
	if (actionModModeColor->isOn()) return ModModeColor;
insilmaril@390
  3620
	if (actionModModeCopy->isOn()) return ModModeCopy;
insilmaril@390
  3621
	if (actionModModeXLink->isOn()) return ModModeXLink;
insilmaril@390
  3622
	return ModModeNone;
insilmaril@390
  3623
}
insilmaril@390
  3624
insilmaril@537
  3625
bool Main::autoEditNewBranch()
insilmaril@390
  3626
{
insilmaril@537
  3627
	return actionSettingsAutoEditNewBranch->isOn();
insilmaril@390
  3628
}
insilmaril@390
  3629
insilmaril@537
  3630
bool Main::autoSelectNewBranch()
insilmaril@390
  3631
{
insilmaril@537
  3632
	return actionSettingsAutoSelectNewBranch->isOn();
insilmaril@390
  3633
}
insilmaril@390
  3634
insilmaril@0
  3635
void Main::windowShowNoteEditor()
insilmaril@0
  3636
{
insilmaril@497
  3637
	textEditor->setShowWithMain(true);
insilmaril@0
  3638
	textEditor->show();
insilmaril@0
  3639
	actionViewToggleNoteEditor->setOn (true);
insilmaril@0
  3640
}
insilmaril@0
  3641
insilmaril@0
  3642
void Main::windowHideNoteEditor()
insilmaril@0
  3643
{
insilmaril@497
  3644
	textEditor->setShowWithMain(false);
insilmaril@0
  3645
	textEditor->hide();
insilmaril@0
  3646
	actionViewToggleNoteEditor->setOn (false);
insilmaril@0
  3647
}
insilmaril@0
  3648
insilmaril@434
  3649
void Main::setScript (const QString &script)
insilmaril@434
  3650
{
insilmaril@434
  3651
	scriptEditor->setScript (script);
insilmaril@434
  3652
}
insilmaril@434
  3653
insilmaril@434
  3654
void Main::runScript (const QString &script)
insilmaril@432
  3655
{
insilmaril@721
  3656
	VymModel *m=currentModel();
insilmaril@721
  3657
	if (m) m->runScript (script);
insilmaril@432
  3658
}
insilmaril@432
  3659
insilmaril@514
  3660
void Main::runScriptEverywhere (const QString &script)
insilmaril@514
  3661
{
insilmaril@514
  3662
	MapEditor *me;
insilmaril@514
  3663
	for (int i=0;i<=tabWidget->count() -1;i++)
insilmaril@514
  3664
	{
insilmaril@514
  3665
		me=(MapEditor*)tabWidget->page(i);
insilmaril@721
  3666
		if (me) me->getModel()->runScript (script);
insilmaril@514
  3667
	}	
insilmaril@514
  3668
}
insilmaril@514
  3669
insilmaril@0
  3670
void Main::windowNextEditor()
insilmaril@0
  3671
{
insilmaril@725
  3672
	if (tabWidget->currentIndex() < tabWidget->count())
insilmaril@725
  3673
		tabWidget->setCurrentIndex (tabWidget->currentIndex() +1);
insilmaril@0
  3674
}
insilmaril@0
  3675
insilmaril@0
  3676
void Main::windowPreviousEditor()
insilmaril@0
  3677
{
insilmaril@725
  3678
	if (tabWidget->currentIndex() >0)
insilmaril@725
  3679
		tabWidget->setCurrentIndex (tabWidget->currentIndex() -1);
insilmaril@0
  3680
}
insilmaril@0
  3681
insilmaril@0
  3682
void Main::standardFlagChanged()
insilmaril@0
  3683
{
insilmaril@766
  3684
	if (currentModel())
insilmaril@767
  3685
	{
insilmaril@767
  3686
		if ( actionSettingsUseFlagGroups->isOn() )
insilmaril@767
  3687
			currentModel()->toggleStandardFlag(sender()->name(),standardFlagsMaster);
insilmaril@767
  3688
		else	
insilmaril@767
  3689
			currentModel()->toggleStandardFlag(sender()->name());
insilmaril@767
  3690
	}
insilmaril@0
  3691
}
insilmaril@0
  3692
insilmaril@527
  3693
void Main::testFunction1()
insilmaril@0
  3694
{
insilmaril@767
  3695
	if (!currentMapEditor()) return;
insilmaril@767
  3696
		currentMapEditor()->testFunction1();
insilmaril@689
  3697
	//editAttribute();
insilmaril@527
  3698
}
insilmaril@527
  3699
insilmaril@527
  3700
void Main::testFunction2()
insilmaril@527
  3701
{
insilmaril@527
  3702
	if (!currentMapEditor()) return;
insilmaril@564
  3703
	currentMapEditor()->testFunction2();
insilmaril@0
  3704
}
insilmaril@0
  3705
insilmaril@393
  3706
void Main::testCommand()
insilmaril@393
  3707
{
insilmaril@393
  3708
	if (!currentMapEditor()) return;
insilmaril@432
  3709
	scriptEditor->show();
insilmaril@432
  3710
	/*
insilmaril@393
  3711
	bool ok;
insilmaril@393
  3712
	QString com = QInputDialog::getText(
insilmaril@404
  3713
			vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
insilmaril@393
  3714
	if (ok) currentMapEditor()->parseAtom(com);
insilmaril@432
  3715
	*/
insilmaril@393
  3716
}
insilmaril@393
  3717
insilmaril@0
  3718
void Main::helpDoc()
insilmaril@0
  3719
{
insilmaril@395
  3720
	QString locale = QLocale::system().name();
insilmaril@395
  3721
	QString docname;
insilmaril@395
  3722
	if (locale.left(2)=="es")
insilmaril@395
  3723
		docname="vym_es.pdf";
insilmaril@395
  3724
	else	
insilmaril@395
  3725
		docname="vym.pdf";
insilmaril@420
  3726
insilmaril@420
  3727
	QStringList searchList;
insilmaril@395
  3728
	QDir docdir;
insilmaril@103
  3729
	#if defined(Q_OS_MACX)
insilmaril@537
  3730
		searchList << "./vym.app/Contents/Resources/doc";
insilmaril@625
  3731
    #elif defined(Q_OS_WIN32)
insilmaril@625
  3732
        searchList << vymInstallDir.path() + "/share/doc/packages/vym";
insilmaril@103
  3733
	#else
insilmaril@608
  3734
		#if defined(VYM_DOCDIR)
insilmaril@608
  3735
			searchList << VYM_DOCDIR;
insilmaril@608
  3736
		#endif
insilmaril@103
  3737
		// default path in SUSE LINUX
insilmaril@625
  3738
		searchList << "/usr/share/doc/packages/vym";
insilmaril@103
  3739
	#endif
insilmaril@0
  3740
insilmaril@420
  3741
	searchList << "doc";	// relative path for easy testing in tarball
insilmaril@420
  3742
	searchList << "doc/tex";	// Easy testing working on vym.tex
insilmaril@420
  3743
	searchList << "/usr/share/doc/vym";	// Debian
insilmaril@420
  3744
	searchList << "/usr/share/doc/packages";// Knoppix
insilmaril@420
  3745
insilmaril@420
  3746
	bool found=false;
insilmaril@420
  3747
	QFile docfile;
insilmaril@420
  3748
	for (int i=0; i<searchList.count(); ++i)
insilmaril@0
  3749
	{
insilmaril@625
  3750
		docfile.setFileName(searchList.at(i)+"/"+docname);
insilmaril@625
  3751
		if (docfile.exists())
insilmaril@0
  3752
		{
insilmaril@420
  3753
			found=true;
insilmaril@420
  3754
			break;
insilmaril@420
  3755
		}	
insilmaril@0
  3756
	}
insilmaril@625
  3757
insilmaril@420
  3758
	if (!found)
insilmaril@420
  3759
	{
insilmaril@420
  3760
		QMessageBox::critical(0, 
insilmaril@420
  3761
			tr("Critcal error"),
insilmaril@420
  3762
			tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
insilmaril@420
  3763
		return;
insilmaril@420
  3764
	}	
insilmaril@420
  3765
insilmaril@408
  3766
	QStringList args;
insilmaril@0
  3767
	Process *pdfProc = new Process();
insilmaril@625
  3768
    args << QDir::toNativeSeparators(docfile.fileName());
insilmaril@420
  3769
insilmaril@420
  3770
	pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
insilmaril@408
  3771
	if ( !pdfProc->waitForStarted() ) 
insilmaril@0
  3772
	{
insilmaril@0
  3773
		// error handling
insilmaril@266
  3774
		QMessageBox::warning(0, 
insilmaril@266
  3775
			tr("Warning"),
insilmaril@420
  3776
			tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
insilmaril@266
  3777
			tr("Please use Settings->")+tr("Set application to open PDF files"));
insilmaril@266
  3778
		settingsPDF();	
insilmaril@0
  3779
		return;
insilmaril@0
  3780
	}
insilmaril@0
  3781
}
insilmaril@0
  3782
insilmaril@0
  3783
insilmaril@505
  3784
void Main::helpDemo()
insilmaril@505
  3785
{
insilmaril@505
  3786
	QStringList filters;
insilmaril@505
  3787
	filters <<"VYM example map (*.vym)";
insilmaril@505
  3788
	QFileDialog *fd=new QFileDialog( this);
insilmaril@595
  3789
	#if defined(Q_OS_MACX)
insilmaril@595
  3790
		fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
insilmaril@595
  3791
	#else
insilmaril@595
  3792
		// default path in SUSE LINUX
insilmaril@595
  3793
		fd->setDir (QDir(vymBaseDir.path()+"/demos"));
insilmaril@595
  3794
	#endif
insilmaril@595
  3795
insilmaril@505
  3796
	fd->setFileMode (QFileDialog::ExistingFiles);
insilmaril@505
  3797
	fd->setFilters (filters);
insilmaril@505
  3798
	fd->setCaption(vymName+ " - " +tr("Load vym example map"));
insilmaril@505
  3799
	fd->show();
insilmaril@505
  3800
insilmaril@505
  3801
	QString fn;
insilmaril@505
  3802
	if ( fd->exec() == QDialog::Accepted )
insilmaril@505
  3803
	{
insilmaril@505
  3804
		lastFileDir=fd->directory().path();
insilmaril@505
  3805
	    QStringList flist = fd->selectedFiles();
insilmaril@505
  3806
		QStringList::Iterator it = flist.begin();
insilmaril@505
  3807
		while( it != flist.end() ) 
insilmaril@505
  3808
		{
insilmaril@505
  3809
			fn = *it;
insilmaril@505
  3810
			fileLoad(*it, NewMap);				   
insilmaril@505
  3811
			++it;
insilmaril@505
  3812
		}
insilmaril@505
  3813
	}
insilmaril@505
  3814
	delete (fd);
insilmaril@505
  3815
}
insilmaril@505
  3816
insilmaril@505
  3817
insilmaril@0
  3818
void Main::helpAbout()
insilmaril@0
  3819
{
insilmaril@148
  3820
	AboutDialog ad;
insilmaril@150
  3821
	ad.setName ("aboutwindow");
insilmaril@148
  3822
	ad.setMinimumSize(500,500);
insilmaril@148
  3823
	ad.resize (QSize (500,500));
insilmaril@148
  3824
	ad.exec();
insilmaril@0
  3825
}
insilmaril@0
  3826
insilmaril@0
  3827
void Main::helpAboutQT()
insilmaril@0
  3828
{
insilmaril@0
  3829
	QMessageBox::aboutQt( this, "Qt Application Example" );
insilmaril@0
  3830
}
insilmaril@0
  3831
insilmaril@445
  3832
void Main::callMacro ()
insilmaril@445
  3833
{
insilmaril@445
  3834
    QAction *action = qobject_cast<QAction *>(sender());
insilmaril@445
  3835
	int i=-1;
insilmaril@445
  3836
    if (action)
insilmaril@445
  3837
	{
insilmaril@445
  3838
        i=action->data().toInt();
insilmaril@447
  3839
		QString mDir (settings.value ("macros/macroDir").toString() );
insilmaril@447
  3840
insilmaril@447
  3841
		QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
insilmaril@447
  3842
		QFile f (fn);
insilmaril@447
  3843
		if ( !f.open( QIODevice::ReadOnly ) )
insilmaril@447
  3844
		{
insilmaril@447
  3845
			QMessageBox::warning(0, 
insilmaril@447
  3846
				tr("Warning"),
insilmaril@447
  3847
				tr("Couldn't find a macro at  %1.\n").arg(fn)+
insilmaril@447
  3848
				tr("Please use Settings->")+tr("Set directory for vym macros"));
insilmaril@447
  3849
			return;
insilmaril@447
  3850
		}	
insilmaril@447
  3851
insilmaril@447
  3852
		QTextStream ts( &f );
insilmaril@721
  3853
		QString macro= ts.read();
insilmaril@721
  3854
insilmaril@721
  3855
		if (! macro.isEmpty())
insilmaril@445
  3856
		{
insilmaril@721
  3857
			VymModel *m=currentModel();
insilmaril@721
  3858
			if (m) m->runScript(macro);
insilmaril@445
  3859
		}	
insilmaril@445
  3860
	}	
insilmaril@445
  3861
}
insilmaril@445
  3862