Skip to content

Commit

Permalink
Tidy up #includes
Browse files Browse the repository at this point in the history
Add tr() to some more user-visible text
Move from std::cerr/cout to QgsLogger


git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@5802 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
g_j_m committed Sep 10, 2006
1 parent f5c7f7e commit 60a3f5a
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 49 deletions.
4 changes: 2 additions & 2 deletions src/plugins/gps_importer/qgsbabelformat.cpp
Expand Up @@ -19,8 +19,8 @@

#include "qgsbabelformat.h"

#include <qregexp.h>
#include <qstring.h>
#include <QRegExp>
#include <QString>


QgsBabelFormat::QgsBabelFormat(const QString& name) :
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/gps_importer/qgsbabelformat.h
Expand Up @@ -20,9 +20,9 @@

#include <map>

#include <qstring.h>
#include <qstringlist.h>
#include <QStringList>

class QString;

class QgsBabelFormat {
public:
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/gps_importer/qgsgpsdevice.cpp
@@ -1,4 +1,4 @@
#include <qregexp.h>
#include <QRegExp>

#include "qgsgpsdevice.h"

Expand Down
4 changes: 2 additions & 2 deletions src/plugins/gps_importer/qgsgpsdevice.h
Expand Up @@ -21,8 +21,8 @@
#ifndef QGSGPSDEVICE_H
#define QGSGPSDEVICE_H

#include <qstring.h>
#include <qstringlist.h>
#include <QString>
#include <QStringList>

#include <qgsbabelformat.h>

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/gps_importer/qgsgpsdevicedialog.h
Expand Up @@ -15,7 +15,7 @@
#include "ui_qgsgpsdevicedialogbase.h"
#include "qgsgpsdevice.h"

#include <qstring.h>
#include <QString>


class QgsGPSDeviceDialog : public QDialog, private Ui::QgsGPSDeviceDialogBase
Expand Down
20 changes: 6 additions & 14 deletions src/plugins/gps_importer/qgsgpsplugin.cpp
Expand Up @@ -29,21 +29,13 @@
#include "qgsgpsplugin.h"


#include <qeventloop.h>
#include <QFileDialog>
#include <q3toolbar.h>
#include <qmenubar.h>
#include <qmessagebox.h>
#include <q3popupmenu.h>
#include <qlineedit.h>
#include <qaction.h>
#include <qapplication.h>
#include <qcursor.h>
#include <q3process.h>
#include <q3progressdialog.h>
#include <qsettings.h>
#include <qstringlist.h>
#include <qglobal.h>
#include <QMessageBox>
#include <QAction>
#include <Q3Process>
#include <Q3ProgressDialog>
#include <QSettings>
#include <QStringList>

//non qt includes
#include <cassert>
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/gps_importer/qgsgpsplugin.h
Expand Up @@ -22,7 +22,7 @@
#include "qgsbabelformat.h"
#include "qgsgpsdevice.h"
#include "../qgisplugin.h"
#include <qwidget.h>

#include <qgisapp.h>

class QgsVectorLayer;
Expand Down
13 changes: 7 additions & 6 deletions src/plugins/gps_importer/qgsgpsplugingui.cpp
Expand Up @@ -13,6 +13,7 @@
#include "qgsgpsdevicedialog.h"
#include "qgsmaplayer.h"
#include "qgsdataprovider.h"
#include <qgslogger.h>

//qt includes
#include <QFileDialog>
Expand Down Expand Up @@ -201,9 +202,9 @@ void QgsGPSPluginGui::on_pbnCancel_clicked()

void QgsGPSPluginGui::on_pbnGPXSelectFile_clicked()
{
std::cout << " Gps File Importer::pbnGPXSelectFile_clicked() " << std::endl;
QgsLogger::debug(" Gps File Importer::pbnGPXSelectFile_clicked() ");
QString myFileTypeQString;
QString myFilterString="GPS eXchange format (*.gpx)";
QString myFilterString=tr("GPS eXchange format (*.gpx)");
QSettings settings("QuantumGIS", "qgis");
QString dir = settings.readEntry("/Plugin-GPS/gpxdirectory");
if (dir.isEmpty())
Expand All @@ -214,7 +215,7 @@ void QgsGPSPluginGui::on_pbnGPXSelectFile_clicked()
dir, //initial dir
myFilterString, //filters to select
&myFileTypeQString); //the pointer to store selected filter
std::cout << "Selected filetype filter is : " << myFileTypeQString.toLocal8Bit().data() << std::endl;
QgsLogger::debug("Selected filetype filter is : " + myFileTypeQString);
leGPXFile->setText(myFileNameQString);
}

Expand All @@ -231,11 +232,11 @@ void QgsGPSPluginGui::on_pbnIMPInput_clicked() {
std::map<QString, QgsBabelFormat*>::const_iterator iter;
iter = mImporters.find(mImpFormat);
if (iter == mImporters.end()) {
std::cerr << "Unknown file format selected: "
<< myFileType.left(myFileType.length() - 6).toLocal8Bit().data() << std::endl;
QgsLogger::warning("Unknown file format selected: " +
myFileType.left(myFileType.length() - 6));
}
else {
std::cerr << iter->first.toLocal8Bit().data() << " selected" << std::endl;
QgsLogger::debug(iter->first + " selected");
leIMPInput->setText(myFileName);
cmbIMPFeature->clear();
if (iter->second->supportsWaypoints())
Expand Down
22 changes: 12 additions & 10 deletions src/providers/gpx/gpsdata.cpp
Expand Up @@ -20,9 +20,10 @@

#include <QFile>
#include <QTextStream>
#include <QObject>

#include "gpsdata.h"

#include <qgslogger.h>

QString GPSObject::xmlify(const QString& str) {
QString tmp = str;
Expand Down Expand Up @@ -311,11 +312,11 @@ GPSData* GPSData::getData(const QString& filename) {
if (dataObjects.find(filename) == dataObjects.end()) {
QFile file(filename);
if (!file.open(QIODevice::ReadOnly)) {
qWarning("Couldn't open the data source: " + filename);
QgsLogger::warning(QObject::tr("Couldn't open the data source: ") + filename);
return 0;
}
GPSData* data = new GPSData;
std::cerr << "Loading file " << filename.toLocal8Bit().data() << std::endl;
QgsLogger::debug("Loading file " + filename);
GPXHandler handler(*data);
bool failed = false;

Expand All @@ -332,9 +333,10 @@ GPSData* GPSData::getData(const QString& filename) {
if (file.atEnd())
atEnd = 1;
if (!XML_Parse(p, buffer, readBytes, atEnd)) {
std::cerr<<"Parse error at line "
<<XML_GetCurrentLineNumber(p)<<": "
<<XML_ErrorString(XML_GetErrorCode(p))<<std::endl;
QgsLogger::warning(QObject::tr("Parse error at line ") +
QString("%1").arg(XML_GetCurrentLineNumber(p)) +
" : " +
QString(XML_ErrorString(XML_GetErrorCode(p))));
failed = true;
break;
}
Expand All @@ -347,7 +349,7 @@ GPSData* GPSData::getData(const QString& filename) {
dataObjects[filename] = std::pair<GPSData*, unsigned>(data, 0);
}
else
std::cerr << filename.toLocal8Bit().data() << " is already loaded"<<std::endl;
QgsLogger::debug(filename + " is already loaded");

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


bool GPXHandler::startElement(const XML_Char* qName, const XML_Char** attr) {
//std::cerr<<"<"<<qName<<">"<<std::endl;

if (!std::strcmp(qName, "gpx")) {
parseModes.push(ParsingDocument);
mData = GPSData();
Expand Down
22 changes: 12 additions & 10 deletions src/providers/gpx/qgsgpxprovider.cpp
Expand Up @@ -31,6 +31,7 @@

#include <QFile>
#include <QTextStream>
#include <QObject>

#include "qgis.h"
#include "qgsdataprovider.h"
Expand All @@ -39,6 +40,7 @@
#include "qgsrect.h"
#include "qgsgpxprovider.h"
#include "gpsdata.h"
#include <qgslogger.h>

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

const QString GPX_KEY = "gpx";

const QString GPX_DESCRIPTION = "GPS eXchange format provider";
const QString GPX_DESCRIPTION = QObject::tr("GPS eXchange format provider");


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

QString QgsGPXProvider::storageType()
{
return "GPS eXchange file";
return tr("GPS eXchange file");
}


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

QString QgsGPXProvider::minValue(int position) {
if (position >= fieldCount()) {
std::cerr<<"Warning: access requested to invalid position "
<<"in QgsGPXProvider::minValue(..)"<<std::endl;
QgsLogger::warning(tr("Warning: access requested to invalid position "
"in QgsGPXProvider::minValue(..)"));
}
if (mMinMaxCacheDirty) {
fillMinMaxCash();
Expand All @@ -504,8 +506,8 @@ QString QgsGPXProvider::minValue(int position) {

QString QgsGPXProvider::maxValue(int position) {
if (position >= fieldCount()) {
std::cerr<<"Warning: access requested to invalid position "
<<"in QgsGPXProvider::maxValue(..)"<<std::endl;
QgsLogger::warning(tr("Warning: access requested to invalid position "
"in QgsGPXProvider::maxValue(..)"));
}
if (mMinMaxCacheDirty) {
fillMinMaxCash();
Expand Down Expand Up @@ -826,7 +828,7 @@ size_t QgsGPXProvider::layerCount() const

QString QgsGPXProvider::getDefaultValue(const QString& attr, QgsFeature* f) {
if (attr == "source")
return "Digitized in QGIS";
return tr("Digitized in QGIS");
return "";
}

Expand Down

0 comments on commit 60a3f5a

Please sign in to comment.