Skip to content

Commit 8b7c713

Browse files
author
g_j_m
committed
Tidy up #includes
Add tr() to some more user-visible text Move from std::cerr/cout to QgsLogger git-svn-id: http://svn.osgeo.org/qgis/trunk@5802 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent f0db600 commit 8b7c713

10 files changed

+46
-49
lines changed

src/plugins/gps_importer/qgsbabelformat.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020
#include "qgsbabelformat.h"
2121

22-
#include <qregexp.h>
23-
#include <qstring.h>
22+
#include <QRegExp>
23+
#include <QString>
2424

2525

2626
QgsBabelFormat::QgsBabelFormat(const QString& name) :

src/plugins/gps_importer/qgsbabelformat.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020

2121
#include <map>
2222

23-
#include <qstring.h>
24-
#include <qstringlist.h>
23+
#include <QStringList>
2524

25+
class QString;
2626

2727
class QgsBabelFormat {
2828
public:

src/plugins/gps_importer/qgsgpsdevice.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include <qregexp.h>
1+
#include <QRegExp>
22

33
#include "qgsgpsdevice.h"
44

src/plugins/gps_importer/qgsgpsdevice.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
#ifndef QGSGPSDEVICE_H
2222
#define QGSGPSDEVICE_H
2323

24-
#include <qstring.h>
25-
#include <qstringlist.h>
24+
#include <QString>
25+
#include <QStringList>
2626

2727
#include <qgsbabelformat.h>
2828

src/plugins/gps_importer/qgsgpsdevicedialog.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "ui_qgsgpsdevicedialogbase.h"
1616
#include "qgsgpsdevice.h"
1717

18-
#include <qstring.h>
18+
#include <QString>
1919

2020

2121
class QgsGPSDeviceDialog : public QDialog, private Ui::QgsGPSDeviceDialogBase

src/plugins/gps_importer/qgsgpsplugin.cpp

+6-14
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,13 @@
2929
#include "qgsgpsplugin.h"
3030

3131

32-
#include <qeventloop.h>
3332
#include <QFileDialog>
34-
#include <q3toolbar.h>
35-
#include <qmenubar.h>
36-
#include <qmessagebox.h>
37-
#include <q3popupmenu.h>
38-
#include <qlineedit.h>
39-
#include <qaction.h>
40-
#include <qapplication.h>
41-
#include <qcursor.h>
42-
#include <q3process.h>
43-
#include <q3progressdialog.h>
44-
#include <qsettings.h>
45-
#include <qstringlist.h>
46-
#include <qglobal.h>
33+
#include <QMessageBox>
34+
#include <QAction>
35+
#include <Q3Process>
36+
#include <Q3ProgressDialog>
37+
#include <QSettings>
38+
#include <QStringList>
4739

4840
//non qt includes
4941
#include <cassert>

src/plugins/gps_importer/qgsgpsplugin.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include "qgsbabelformat.h"
2323
#include "qgsgpsdevice.h"
2424
#include "../qgisplugin.h"
25-
#include <qwidget.h>
25+
2626
#include <qgisapp.h>
2727

2828
class QgsVectorLayer;

src/plugins/gps_importer/qgsgpsplugingui.cpp

+7-6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "qgsgpsdevicedialog.h"
1414
#include "qgsmaplayer.h"
1515
#include "qgsdataprovider.h"
16+
#include <qgslogger.h>
1617

1718
//qt includes
1819
#include <QFileDialog>
@@ -201,9 +202,9 @@ void QgsGPSPluginGui::on_pbnCancel_clicked()
201202

202203
void QgsGPSPluginGui::on_pbnGPXSelectFile_clicked()
203204
{
204-
std::cout << " Gps File Importer::pbnGPXSelectFile_clicked() " << std::endl;
205+
QgsLogger::debug(" Gps File Importer::pbnGPXSelectFile_clicked() ");
205206
QString myFileTypeQString;
206-
QString myFilterString="GPS eXchange format (*.gpx)";
207+
QString myFilterString=tr("GPS eXchange format (*.gpx)");
207208
QSettings settings("QuantumGIS", "qgis");
208209
QString dir = settings.readEntry("/Plugin-GPS/gpxdirectory");
209210
if (dir.isEmpty())
@@ -214,7 +215,7 @@ void QgsGPSPluginGui::on_pbnGPXSelectFile_clicked()
214215
dir, //initial dir
215216
myFilterString, //filters to select
216217
&myFileTypeQString); //the pointer to store selected filter
217-
std::cout << "Selected filetype filter is : " << myFileTypeQString.toLocal8Bit().data() << std::endl;
218+
QgsLogger::debug("Selected filetype filter is : " + myFileTypeQString);
218219
leGPXFile->setText(myFileNameQString);
219220
}
220221

@@ -231,11 +232,11 @@ void QgsGPSPluginGui::on_pbnIMPInput_clicked() {
231232
std::map<QString, QgsBabelFormat*>::const_iterator iter;
232233
iter = mImporters.find(mImpFormat);
233234
if (iter == mImporters.end()) {
234-
std::cerr << "Unknown file format selected: "
235-
<< myFileType.left(myFileType.length() - 6).toLocal8Bit().data() << std::endl;
235+
QgsLogger::warning("Unknown file format selected: " +
236+
myFileType.left(myFileType.length() - 6));
236237
}
237238
else {
238-
std::cerr << iter->first.toLocal8Bit().data() << " selected" << std::endl;
239+
QgsLogger::debug(iter->first + " selected");
239240
leIMPInput->setText(myFileName);
240241
cmbIMPFeature->clear();
241242
if (iter->second->supportsWaypoints())

src/providers/gpx/gpsdata.cpp

+12-10
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@
2020

2121
#include <QFile>
2222
#include <QTextStream>
23+
#include <QObject>
2324

2425
#include "gpsdata.h"
25-
26+
#include <qgslogger.h>
2627

2728
QString GPSObject::xmlify(const QString& str) {
2829
QString tmp = str;
@@ -311,11 +312,11 @@ GPSData* GPSData::getData(const QString& filename) {
311312
if (dataObjects.find(filename) == dataObjects.end()) {
312313
QFile file(filename);
313314
if (!file.open(QIODevice::ReadOnly)) {
314-
qWarning("Couldn't open the data source: " + filename);
315+
QgsLogger::warning(QObject::tr("Couldn't open the data source: ") + filename);
315316
return 0;
316317
}
317318
GPSData* data = new GPSData;
318-
std::cerr << "Loading file " << filename.toLocal8Bit().data() << std::endl;
319+
QgsLogger::debug("Loading file " + filename);
319320
GPXHandler handler(*data);
320321
bool failed = false;
321322

@@ -332,9 +333,10 @@ GPSData* GPSData::getData(const QString& filename) {
332333
if (file.atEnd())
333334
atEnd = 1;
334335
if (!XML_Parse(p, buffer, readBytes, atEnd)) {
335-
std::cerr<<"Parse error at line "
336-
<<XML_GetCurrentLineNumber(p)<<": "
337-
<<XML_ErrorString(XML_GetErrorCode(p))<<std::endl;
336+
QgsLogger::warning(QObject::tr("Parse error at line ") +
337+
QString("%1").arg(XML_GetCurrentLineNumber(p)) +
338+
" : " +
339+
QString(XML_ErrorString(XML_GetErrorCode(p))));
338340
failed = true;
339341
break;
340342
}
@@ -347,7 +349,7 @@ GPSData* GPSData::getData(const QString& filename) {
347349
dataObjects[filename] = std::pair<GPSData*, unsigned>(data, 0);
348350
}
349351
else
350-
std::cerr << filename.toLocal8Bit().data() << " is already loaded"<<std::endl;
352+
QgsLogger::debug(filename + " is already loaded");
351353

352354
// return a pointer and increase the reference count for that filename
353355
DataMap::iterator iter = dataObjects.find(filename);
@@ -362,9 +364,9 @@ void GPSData::releaseData(const QString& filename) {
362364
it if the reference count becomes 0 */
363365
DataMap::iterator iter = dataObjects.find(filename);
364366
if (iter != dataObjects.end()) {
365-
std::cerr << "unrefing " << filename.toLocal8Bit().data() << std::endl;
367+
QgsLogger::debug("unrefing " + filename);
366368
if (--(iter->second.second) == 0) {
367-
std::cerr << "No one's using " << filename.toLocal8Bit().data() << ", I'll erase it" << std::endl;
369+
QgsLogger::debug("No one's using " + filename + ", I'll erase it");
368370
delete iter->second.first;
369371
dataObjects.erase(iter);
370372
}
@@ -379,7 +381,7 @@ GPSData::DataMap GPSData::dataObjects;
379381

380382

381383
bool GPXHandler::startElement(const XML_Char* qName, const XML_Char** attr) {
382-
//std::cerr<<"<"<<qName<<">"<<std::endl;
384+
383385
if (!std::strcmp(qName, "gpx")) {
384386
parseModes.push(ParsingDocument);
385387
mData = GPSData();

src/providers/gpx/qgsgpxprovider.cpp

+12-10
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
#include <QFile>
3333
#include <QTextStream>
34+
#include <QObject>
3435

3536
#include "qgis.h"
3637
#include "qgsdataprovider.h"
@@ -39,6 +40,7 @@
3940
#include "qgsrect.h"
4041
#include "qgsgpxprovider.h"
4142
#include "gpsdata.h"
43+
#include <qgslogger.h>
4244

4345
#ifdef WIN32
4446
#define QGISEXTERN extern "C" __declspec( dllexport )
@@ -54,7 +56,7 @@ const char* QgsGPXProvider::attr[] = { "name", "elevation", "symbol", "number",
5456

5557
const QString GPX_KEY = "gpx";
5658

57-
const QString GPX_DESCRIPTION = "GPS eXchange format provider";
59+
const QString GPX_DESCRIPTION = QObject::tr("GPS eXchange format provider");
5860

5961

6062
QgsGPXProvider::QgsGPXProvider(QString const & uri) :
@@ -71,7 +73,7 @@ QgsGPXProvider::QgsGPXProvider(QString const & uri) :
7173
// get the filename and the type parameter from the URI
7274
int fileNameEnd = uri.find('?');
7375
if (fileNameEnd == -1 || uri.mid(fileNameEnd + 1, 5) != "type=") {
74-
std::cerr<<"Bad URI - you need to specify the feature type"<<std::endl;
76+
QgsLogger::warning(tr("Bad URI - you need to specify the feature type."));
7577
return;
7678
}
7779
QString typeStr = uri.mid(fileNameEnd + 6);
@@ -130,7 +132,7 @@ QgsGPXProvider::~QgsGPXProvider() {
130132

131133
QString QgsGPXProvider::storageType()
132134
{
133-
return "GPS eXchange file";
135+
return tr("GPS eXchange file");
134136
}
135137

136138

@@ -411,8 +413,8 @@ std::vector<QgsFeature>& QgsGPXProvider::identify(QgsRect * rect) {
411413
// reset the data source since we need to be able to read through
412414
// all features
413415
reset();
414-
std::cerr << "Attempting to identify features falling within "
415-
<< rect->stringRep().toLocal8Bit().data() << std::endl;
416+
QgsLogger::debug("Attempting to identify features falling within " +
417+
rect->stringRep());
416418
// select the features
417419
select(rect);
418420
// temporary fix to get this to compile under windows
@@ -492,8 +494,8 @@ void QgsGPXProvider::reset() {
492494

493495
QString QgsGPXProvider::minValue(int position) {
494496
if (position >= fieldCount()) {
495-
std::cerr<<"Warning: access requested to invalid position "
496-
<<"in QgsGPXProvider::minValue(..)"<<std::endl;
497+
QgsLogger::warning(tr("Warning: access requested to invalid position "
498+
"in QgsGPXProvider::minValue(..)"));
497499
}
498500
if (mMinMaxCacheDirty) {
499501
fillMinMaxCash();
@@ -504,8 +506,8 @@ QString QgsGPXProvider::minValue(int position) {
504506

505507
QString QgsGPXProvider::maxValue(int position) {
506508
if (position >= fieldCount()) {
507-
std::cerr<<"Warning: access requested to invalid position "
508-
<<"in QgsGPXProvider::maxValue(..)"<<std::endl;
509+
QgsLogger::warning(tr("Warning: access requested to invalid position "
510+
"in QgsGPXProvider::maxValue(..)"));
509511
}
510512
if (mMinMaxCacheDirty) {
511513
fillMinMaxCash();
@@ -826,7 +828,7 @@ size_t QgsGPXProvider::layerCount() const
826828

827829
QString QgsGPXProvider::getDefaultValue(const QString& attr, QgsFeature* f) {
828830
if (attr == "source")
829-
return "Digitized in QGIS";
831+
return tr("Digitized in QGIS");
830832
return "";
831833
}
832834

0 commit comments

Comments
 (0)