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