Skip to content

Commit a08ba94

Browse files
committed
Let leaflet inherit injected babelData_.debugLevel.
Ordering fixes. Remove debug code that clobbered output file.
1 parent d373988 commit a08ba94

File tree

6 files changed

+24
-37
lines changed

6 files changed

+24
-37
lines changed

gui/gmapdlg.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ void GMapDialog::appendRouteInfo(QStandardItem* it, const GpxRoute& rte)
141141
}
142142

143143
//------------------------------------------------------------------------
144-
GMapDialog::GMapDialog(QWidget* parent, const Gpx& mapData, QPlainTextEdit* te): QDialog(parent), gpx_(mapData)
144+
GMapDialog::GMapDialog(QWidget* parent, const Gpx& mapData, int debugLevel, QPlainTextEdit* te): QDialog(parent), debugLevel_(debugLevel), gpx_(mapData)
145145
{
146146
ui_.setupUi(this);
147147
this->setWindowTitle(QString(appName) + " " + QString("Google Maps"));
@@ -216,7 +216,7 @@ GMapDialog::GMapDialog(QWidget* parent, const Gpx& mapData, QPlainTextEdit* te):
216216
//------------------------------------------------------------------------
217217
void GMapDialog::trace(const QString& label, const QStandardItem* it)
218218
{
219-
if constexpr(debug_) {
219+
if (debugLevel_ > 0) {
220220
QDebug qdb(QtDebugMsg);
221221
qdb.nospace().noquote() << label + ": ";
222222
qdb.quote();
@@ -309,7 +309,7 @@ void GMapDialog::itemClickedX(const QStandardItem* it)
309309
//-------------------------------------------------------------------------
310310
void GMapDialog::selectionChangedX(const QItemSelection& sel, const QItemSelection& desel)
311311
{
312-
if constexpr(debug_) {
312+
if (debugLevel_ > 0) {
313313
qDebug() << "selectionChangedX";
314314
}
315315
for (const QModelIndexList idxs = desel.indexes(); const auto& idx : idxs) {
@@ -404,7 +404,7 @@ void GMapDialog::showChildContextMenu(const QString& text, const QStandardItem*
404404
//------------------------------------------------------------------------
405405
void GMapDialog::showContextMenu(const QPoint& pt)
406406
{
407-
if constexpr(debug_) {
407+
if (debugLevel_ > 0) {
408408
qDebug() << "showContextMenu";
409409
}
410410
QModelIndex idx = ui_.treeView->indexAt(pt);

gui/gmapdlg.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ class GMapDialog: public QDialog
4141
{
4242
Q_OBJECT
4343
public:
44-
GMapDialog(QWidget* parent, const Gpx& mapData, QPlainTextEdit* te);
44+
GMapDialog(QWidget* parent, const Gpx& mapData, int debugLevel, QPlainTextEdit* te);
4545

4646
private:
47-
static constexpr bool debug_ = false;
47+
int debugLevel_;
4848

4949
Ui_GMapDlg ui_;
5050
Map* mapWidget_;
@@ -60,7 +60,7 @@ class GMapDialog: public QDialog
6060

6161
static QString formatLength(double l);
6262

63-
static void trace(const QString& label, const QStandardItem* it);
63+
void trace(const QString& label, const QStandardItem* it);
6464
void expandCollapseAll(QStandardItem* top, bool exp);
6565
void showHideAll(QStandardItem* top, bool ck);
6666
void showHideChild(const QStandardItem* child);

gui/leafletdlg.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232
#include <QtGlobal>
3333
#include "appname.h"
3434
#include "gpx.h"
35+
#include "latlng.h"
3536
#include "leafletdlg.h"
3637
#include "leafletmap.h"
37-
#include "latlng.h"
3838
#include "ui_leafletdlg.h"
3939

4040
//------------------------------------------------------------------------
@@ -144,8 +144,9 @@ LeafletMapDialog::appendRouteInfo(QStandardItem* it, const GpxRoute& rte)
144144

145145
//------------------------------------------------------------------------
146146
LeafletMapDialog::LeafletMapDialog(QWidget* parent,
147-
const Gpx& mapData, const QString& geojsonData, QPlainTextEdit* te) :
147+
const Gpx& mapData, const QString& geojsonData, int debugLevel, QPlainTextEdit* te) :
148148
QDialog(parent),
149+
debugLevel_(debugLevel),
149150
gpx_(mapData)
150151
{
151152
ui_.setupUi(this);
@@ -269,7 +270,7 @@ void LeafletMapDialog::trackClicked(int i)
269270
void
270271
LeafletMapDialog::trace(const QString& label, const QStandardItem* it)
271272
{
272-
if constexpr(debug_) {
273+
if (debugLevel_ > 0) {
273274
QDebug qdb(QtDebugMsg);
274275
qdb.nospace().noquote() << label + ": ";
275276
qdb.quote();

gui/leafletdlg.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ class LeafletMapDialog: public QDialog
4040
Q_OBJECT
4141

4242
public:
43-
LeafletMapDialog(QWidget* parent, const Gpx& mapData, const QString& geojsonData, QPlainTextEdit* te);
43+
LeafletMapDialog(QWidget* parent, const Gpx& mapData, const QString& geojsonData, int debugLevel, QPlainTextEdit* te);
4444

4545

4646
private:
47-
static constexpr bool debug_ = false;
47+
int debugLevel_;
4848
Ui::LeafletMapDlg ui_;
4949
LeafletMap* mapWidget_;
5050
QStandardItemModel* model_;

gui/leafletmap.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@
3030
#include <QWebEnginePage>
3131
#include <QWebEngineProfile>
3232
#include <QWebEngineSettings>
33-
#include <QWebEngineView>
3433
#include <QWebEngineUrlRequestInterceptor>
34+
#include <QWebEngineView>
3535
#include <Qt>
3636

3737
#include <string>
3838
#include <vector>
3939

4040
#include "appname.h"
4141
#include "gpx.h"
42-
#include "leafletmap.h"
4342
#include "latlng.h"
43+
#include "leafletmap.h"
4444
#include "markerclicker.h"
4545
#include "webenginepage.h"
4646

gui/mainwindow.cc

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@
1919
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
2020
// USA.
2121
//
22-
#include <QJsonArray>
23-
#include <QJsonDocument>
24-
#include <QJsonObject>
25-
#include <QJsonValue>
26-
#include <QStyle> // for QStyle
27-
#include <QIcon> // for QIcon
2822
#include "mainwindow.h"
2923
#include <QAbstractButton> // for QAbstractButton
3024
#include <QAction> // for QAction
@@ -42,6 +36,7 @@
4236
#include <QFileDialog> // for QFileDialog
4337
#include <QFileInfo> // for QFileInfo
4438
#include <QGradientStop> // for QBrush
39+
#include <QIcon> // for QIcon
4540
#include <QImage> // for QImage
4641
#include <QLibraryInfo> // for QLibraryInfo
4742
#include <QLocale> // for QLocale
@@ -53,6 +48,7 @@
5348
#include <QRadioButton> // for QRadioButton
5449
#include <QSettings> // for QSettings
5550
#include <QStackedWidget> // for QStackedWidget
51+
#include <QStyle> // for QStyle
5652
#include <QString> // for QString, operator+, operator==, operator!=
5753
#include <QStringList> // for QStringList
5854
#include <QTemporaryFile> // for QTemporaryFile
@@ -78,7 +74,7 @@
7874
#ifndef DISABLE_MAPPREVIEW
7975
#include "gpx.h" // for Gpx
8076
#include "gmapdlg.h" // for GMapDialog
81-
#include "leafletdlg.h" // for LeafletMapDialog
77+
#include "leafletdlg.h" // for LeafletMapDialog
8278
#endif
8379
#include "help.h" // for ShowHelp
8480
#include "optionsdlg.h" // for OptionsDlg
@@ -244,10 +240,7 @@ MainWindow::MainWindow(QWidget* parent): QMainWindow(parent)
244240

245241
//--- Restore from registry
246242
restoreSettings();
247-
// RJL
248-
babelData_.debugLevel_ = 9;
249-
babelData_.outputFileName_= "/dev/null";
250-
// RJL
243+
251244

252245
#ifndef DISABLE_UPGRADE_CHECK
253246
upgrade = new UpgradeCheck(this, formatList_, babelData_);
@@ -263,10 +256,7 @@ babelData_.outputFileName_= "/dev/null";
263256
vm.exec();
264257
babelData_.ignoreVersionMismatch_ = vm.neverAgain();
265258
}
266-
// RJL
267-
babelData_.debugLevel_ = 9;
268-
babelData_.outputFileName_= "/dev/null";
269-
// RJL
259+
270260
}
271261

272262
void MainWindow::switchTranslator(QTranslator& translator, const QString& filename)
@@ -905,10 +895,7 @@ void MainWindow::applyActionX()
905895
}
906896

907897
QStringList args;
908-
// RJL
909-
babelData_.debugLevel_ = 9;
910-
babelData_.outputFileName_= "/dev/null";
911-
// end RJL
898+
912899
if (babelData_.debugLevel_ >=0) {
913900
args << QString("-D%1").arg(babelData_.debugLevel_);
914901
}
@@ -959,8 +946,7 @@ babelData_.outputFileName_= "/dev/null";
959946
babelData_.outputFileFormat_ : babelData_.outputDeviceFormat_));
960947
args << "-o";
961948
args << (formatList_[fidx].getName() + MakeOptions(formatList_[fidx].getOutputOptions()));
962-
// RJL
963-
babelData_.outputFileName_= "/dev/null";
949+
964950

965951
// output file or device option
966952
if (outIsFile) {
@@ -1024,7 +1010,7 @@ qDebug() << "useGoogleMaps" << useGoogleMaps << "useLeafletMaps" << useLeafletMa
10241010
} else {
10251011
this->hide();
10261012
if (useGoogleMaps) {
1027-
GMapDialog dlg(nullptr, mapData, babelData_.debugLevel_ >=1 ? ui_.outputWindow : nullptr);
1013+
GMapDialog dlg(nullptr, mapData, babelData_.debugLevel_, babelData_.debugLevel_ >=1 ? ui_.outputWindow : nullptr);
10281014
dlg.show();
10291015
dlg.exec();
10301016
} else if (useLeafletMaps) {
@@ -1033,7 +1019,7 @@ qDebug() << "useGoogleMaps" << useGoogleMaps << "useLeafletMaps" << useLeafletMa
10331019
// This uses MainWindow::generateGeoJsonWithIndices to include GUI-specific properties
10341020
// like 'originalIndex' which are not present in the CLI's geojson writer output.
10351021
geojsonData = generateGeoJsonWithIndices(mapData);
1036-
LeafletMapDialog dlg(nullptr, mapData, geojsonData, babelData_.debugLevel_ >=1 ? ui_.outputWindow : nullptr);
1022+
LeafletMapDialog dlg(nullptr, mapData, geojsonData, babelData_.debugLevel_, babelData_.debugLevel_ >=1 ? ui_.outputWindow : nullptr);
10371023
dlg.show();
10381024
dlg.exec();
10391025
}

0 commit comments

Comments
 (0)