Skip to content

Commit

Permalink
move more stl usage to qt
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Dec 25, 2015
1 parent 4530c2a commit 5f1959b
Show file tree
Hide file tree
Showing 19 changed files with 51 additions and 76 deletions.
10 changes: 3 additions & 7 deletions src/analysis/network/qgslinevectorlayerdirector.cpp
Expand Up @@ -28,10 +28,6 @@
#include <QString>
#include <QtAlgorithms>

//standard includes
#include <limits>
#include <algorithm>

class QgsPointCompare
{
public:
Expand Down Expand Up @@ -318,7 +314,7 @@ void QgsLineVectorLayerDirector::makeGraph( QgsGraphBuilderInterface *builder, c

if ( !isFirstPoint )
{
std::map< double, QgsPoint > pointsOnArc;
QMap< double, QgsPoint > pointsOnArc;
pointsOnArc[ 0.0 ] = pt1;
pointsOnArc[ pt1.sqrDist( pt2 )] = pt2;

Expand Down Expand Up @@ -347,14 +343,14 @@ void QgsLineVectorLayerDirector::makeGraph( QgsGraphBuilderInterface *builder, c
}
}

std::map< double, QgsPoint >::iterator pointsIt;
QMap< double, QgsPoint >::iterator pointsIt;
QgsPoint pt1;
QgsPoint pt2;
int pt1idx = -1, pt2idx = -1;
bool isFirstPoint = true;
for ( pointsIt = pointsOnArc.begin(); pointsIt != pointsOnArc.end(); ++pointsIt )
{
pt2 = pointsIt->second;
pt2 = *pointsIt;
tmp = my_binary_search( points.begin(), points.end(), pt2, pointCompare );
pt2 = *tmp;
pt2idx = tmp - points.begin();
Expand Down
4 changes: 0 additions & 4 deletions src/app/qgsabout.cpp
Expand Up @@ -27,10 +27,6 @@
#include <QSqlDatabase>
#include <QTcpSocket>

/* Uncomment this block to use preloaded images
#include <map>
std::map<QString, QPixmap> mugs;
*/
#ifdef Q_OS_MACX
QgsAbout::QgsAbout( QWidget *parent )
: QgsOptionsDialogBase( "about", parent, Qt::WindowSystemMenuHint ) // Modeless dialog with close button only
Expand Down
12 changes: 6 additions & 6 deletions src/app/qgscustomprojectiondialog.cpp
Expand Up @@ -403,7 +403,7 @@ void QgsCustomProjectionDialog::on_buttonBox_accepted()

//Check if all CRS are valid:
QgsCoordinateReferenceSystem CRS;
for ( size_t i = 0; i < customCRSids.size(); ++i )
for ( int i = 0; i < customCRSids.size(); ++i )
{
CRS.createFromProj4( customCRSparameters[i] );
if ( !CRS.isValid() )
Expand All @@ -415,19 +415,19 @@ void QgsCustomProjectionDialog::on_buttonBox_accepted()
}
//Modify the CRS changed:
bool save_success = true;
for ( size_t i = 0; i < customCRSids.size(); ++i )
for ( int i = 0; i < customCRSids.size(); ++i )
{
CRS.createFromProj4( customCRSparameters[i] );
//Test if we just added this CRS (if it has no existing ID)
if ( customCRSids[i] == "" )
{
save_success = save_success && saveCRS( CRS, customCRSnames[i], "", true );
save_success &= saveCRS( CRS, customCRSnames[i], "", true );
}
else
{
if ( existingCRSnames[customCRSids[i]] != customCRSnames[i] || existingCRSparameters[customCRSids[i]] != customCRSparameters[i] )
{
save_success = save_success && saveCRS( CRS, customCRSnames[i], customCRSids[i], false );
save_success &= saveCRS( CRS, customCRSnames[i], customCRSids[i], false );
}
}
if ( ! save_success )
Expand All @@ -436,9 +436,9 @@ void QgsCustomProjectionDialog::on_buttonBox_accepted()
}
}
QgsDebugMsg( "We remove the deleted CRS." );
for ( size_t i = 0; i < deletedCRSs.size(); ++i )
for ( int i = 0; i < deletedCRSs.size(); ++i )
{
save_success = save_success && deleteCRS( deletedCRSs[i] );
save_success &= deleteCRS( deletedCRSs[i] );
if ( ! save_success )
{
QgsDebugMsg( QString( "Problem for layer '%1'" ).arg( customCRSparameters[i] ) );
Expand Down
10 changes: 5 additions & 5 deletions src/app/qgscustomprojectiondialog.h
Expand Up @@ -59,13 +59,13 @@ class APP_EXPORT QgsCustomProjectionDialog : public QDialog, private Ui::QgsCust
QMap <QString, QString> existingCRSparameters;
QMap <QString, QString> existingCRSnames;

//These three vectors store the value updated with the current modifications
std::vector<QString> customCRSnames;
std::vector<QString> customCRSids;
std::vector<QString> customCRSparameters;
//These three list store the value updated with the current modifications
QStringList customCRSnames;
QStringList customCRSids;
QStringList customCRSparameters;

//vector saving the CRS to be deleted
std::vector<QString> deletedCRSs;
QStringList deletedCRSs;

//Columns in the tree widget
enum columns { QGIS_CRS_NAME_COLUMN, QGIS_CRS_ID_COLUMN, QGIS_CRS_PARAMETERS_COLUMN };
Expand Down
12 changes: 6 additions & 6 deletions src/core/pal/pal.cpp
Expand Up @@ -478,7 +478,7 @@ namespace pal
/*
* BIG MACHINE
*/
std::list<LabelPosition*>* Pal::labeller( double bbox[4], PalStat **stats, bool displayAll )
QList<LabelPosition*>* Pal::labeller( double bbox[4], PalStat **stats, bool displayAll )
{
#ifdef _DEBUG_
std::cout << "LABELLER (selection)" << std::endl;
Expand Down Expand Up @@ -508,7 +508,7 @@ namespace pal
// nothing to be done => return an empty result set
if ( stats )
( *stats ) = new PalStat();
return new std::list<LabelPosition*>();
return new QList<LabelPosition*>();
}

std::cout << "PAL EXTRACT: " << t.elapsed() / 1000.0 << " s" << std::endl;
Expand Down Expand Up @@ -548,7 +548,7 @@ namespace pal
//prob->post_optimization();


std::list<LabelPosition*> * solution = prob->getSolution( displayAll );
QList<LabelPosition*> * solution = prob->getSolution( displayAll );

if ( stats )
*stats = prob->getStats();
Expand Down Expand Up @@ -581,10 +581,10 @@ namespace pal
return extract( bbox[0], bbox[1], bbox[2], bbox[3] );
}

std::list<LabelPosition*>* Pal::solveProblem( Problem* prob, bool displayAll )
QList<LabelPosition*>* Pal::solveProblem( Problem* prob, bool displayAll )
{
if ( !prob )
return new std::list<LabelPosition*>();
return new QList<LabelPosition*>();

prob->reduce();

Expand All @@ -599,7 +599,7 @@ namespace pal
}
catch ( InternalException::Empty )
{
return new std::list<LabelPosition*>();
return new QList<LabelPosition*>();
}

return prob->getSolution( displayAll );
Expand Down
4 changes: 2 additions & 2 deletions src/core/pal/pal.h
Expand Up @@ -153,7 +153,7 @@ namespace pal
*
* @return A list of label to display on map
*/
std::list<LabelPosition*> *labeller( double bbox[4], PalStat **stats, bool displayAll );
QList<LabelPosition*> *labeller( double bbox[4], PalStat **stats, bool displayAll );

typedef bool ( *FnIsCancelled )( void* ctx );

Expand All @@ -165,7 +165,7 @@ namespace pal

Problem* extractProblem( double bbox[4] );

std::list<LabelPosition*>* solveProblem( Problem* prob, bool displayAll );
QList<LabelPosition*>* solveProblem( Problem* prob, bool displayAll );

/**
*\brief Set flag show partial label
Expand Down
6 changes: 3 additions & 3 deletions src/core/pal/problem.cpp
Expand Up @@ -2614,11 +2614,11 @@ namespace pal
return l1->getWidth() * l1->getHeight() > l2->getWidth() * l2->getHeight();
}

std::list<LabelPosition*> * Problem::getSolution( bool returnInactive )
QList<LabelPosition*> * Problem::getSolution( bool returnInactive )
{

int i;
std::list<LabelPosition*> *solList = new std::list<LabelPosition*>();
QList<LabelPosition*> *solList = new QList<LabelPosition*>();

if ( nbft == 0 )
{
Expand All @@ -2642,7 +2642,7 @@ namespace pal
// if features collide, order by size, so smaller ones appear on top
if ( returnInactive )
{
solList->sort( compareLabelArea );
qSort( solList->begin(), solList->end(), compareLabelArea );
}

return solList;
Expand Down
2 changes: 1 addition & 1 deletion src/core/pal/problem.h
Expand Up @@ -136,7 +136,7 @@ namespace pal
*/
void chain_search();

std::list<LabelPosition*> * getSolution( bool returnInactive );
QList<LabelPosition*> * getSolution( bool returnInactive );

PalStat * getStats();

Expand Down
4 changes: 2 additions & 2 deletions src/core/qgslabelingenginev2.cpp
Expand Up @@ -243,7 +243,7 @@ void QgsLabelingEngineV2::run( QgsRenderContext& context )
// do the labeling itself
double bbox[] = { extent.xMinimum(), extent.yMinimum(), extent.xMaximum(), extent.yMaximum() };

std::list<pal::LabelPosition*>* labels;
QList<pal::LabelPosition*>* labels;
pal::Problem *problem;
try
{
Expand Down Expand Up @@ -307,7 +307,7 @@ void QgsLabelingEngineV2::run( QgsRenderContext& context )
painter->setRenderHint( QPainter::Antialiasing );

// draw the labels
std::list<pal::LabelPosition*>::iterator it = labels->begin();
QList<pal::LabelPosition*>::iterator it = labels->begin();
for ( ; it != labels->end(); ++it )
{
if ( context.renderingStopped() )
Expand Down
4 changes: 0 additions & 4 deletions src/gui/qgsmapcanvas.h
Expand Up @@ -20,10 +20,6 @@

#include "qgsconfig.h"

#include <list>
#include <memory>
#include <deque>

#include "qgsexpressioncontext.h"
#include "qgsrectangle.h"
#include "qgspoint.h"
Expand Down
2 changes: 1 addition & 1 deletion src/providers/spatialite/qgsspatialiteprovider.h
Expand Up @@ -180,7 +180,7 @@ class QgsSpatiaLiteProvider: public QgsVectorDataProvider

/**
Changes geometries of existing features
@param geometry_map A std::map containing the feature IDs to change the geometries of.
@param geometry_map A map containing the feature IDs to change the geometries of.
the second map parameter being the new geometries themselves
@return true in case of success and false in case of failure
*/
Expand Down
10 changes: 3 additions & 7 deletions src/providers/spatialite/qgsspatialitesourceselect.h
Expand Up @@ -23,12 +23,8 @@
#include "qgscontexthelp.h"

#include <QThread>

#include <vector>
#include <list>
#include <utility>

#include <QMap>
#include <QList>
#include <QPair>
#include <QIcon>
#include <QFileDialog>
Expand Down Expand Up @@ -108,8 +104,8 @@ class QgsSpatiaLiteSourceSelect: public QDialog, private Ui::QgsDbSourceSelectBa
dbssColumns,
};

typedef std::pair < QString, QString > geomPair;
typedef std::list < geomPair > geomCol;
typedef QPair< QString, QString > geomPair;
typedef QList< geomPair > geomCol;

// Set the position of the database connection list to the last
// used one.
Expand Down
1 change: 1 addition & 0 deletions src/providers/virtual/qgsvirtuallayerprovider.cpp
Expand Up @@ -30,6 +30,7 @@ extern "C"
#include <qgsvectorlayer.h>
#include <qgsmaplayerregistry.h>
#include <qgsdatasourceuri.h>

#include "qgsvirtuallayerprovider.h"
#include "qgsvirtuallayersqlitemodule.h"
#include "qgsvirtuallayerqueryparser.h"
Expand Down
5 changes: 3 additions & 2 deletions src/providers/virtual/qgsvirtuallayerqueryparser.cpp
Expand Up @@ -3,6 +3,7 @@
#include "qgsvirtuallayerblob.h"

#include <QRegExp>
#include <QtDebug>

namespace QgsVirtualLayerQueryParser
{
Expand Down Expand Up @@ -157,7 +158,7 @@ namespace QgsVirtualLayerQueryParser

if ( !isValidColumnName( columnName ) )
{
std::cout << "Invalid name: " << columnName.toLocal8Bit().constData() << std::endl;
qWarning() << "Invalid name: " << columnName;
hasInvalidName = true;

// add an unnamed column
Expand Down Expand Up @@ -208,7 +209,7 @@ namespace QgsVirtualLayerQueryParser
qs += ", ";
}
qs += " FROM _tview LIMIT 1";
std::cout << qs.toLocal8Bit().constData() << std::endl;
qWarning() << qs;

Sqlite::Query q( db, qs );
if ( q.step() == SQLITE_ROW )
Expand Down
14 changes: 7 additions & 7 deletions src/providers/wfs/qgswfsprovider.cpp
Expand Up @@ -866,7 +866,7 @@ int QgsWFSProvider::describeFeatureTypeFile( const QString& uri, QString& geomet
return 0;
}

std::list<QString> thematicAttributes;
QStringList thematicAttributes;

//if this fails (e.g. no schema file), try to guess the geometry attribute and the names of the thematic attributes from the .gml file
if ( guessAttributesFromFile( uri, geometryAttribute, thematicAttributes, geomType ) != 0 )
Expand All @@ -876,10 +876,10 @@ int QgsWFSProvider::describeFeatureTypeFile( const QString& uri, QString& geomet

fields.clear();
int i = 0;
for ( std::list<QString>::const_iterator it = thematicAttributes.begin(); it != thematicAttributes.end(); ++it, ++i )
Q_FOREACH ( const QString &name, thematicAttributes )
{
// TODO: is this correct?
fields[i] = QgsField( *it, QVariant::String, "unknown" );
fields[i++] = QgsField( name, QVariant::String, "unknown" );
}
return 0;
}
Expand Down Expand Up @@ -995,7 +995,7 @@ int QgsWFSProvider::readAttributesFromSchema( QDomDocument& schemaDoc, QString&
return 0;
}

int QgsWFSProvider::guessAttributesFromFile( const QString& uri, QString& geometryAttribute, std::list<QString>& thematicAttributes, QGis::WkbType& geomType ) const
int QgsWFSProvider::guessAttributesFromFile( const QString& uri, QString& geometryAttribute, QStringList &thematicAttributes, QGis::WkbType& geomType ) const
{
QFile gmlFile( uri );
if ( !gmlFile.open( QIODevice::ReadOnly ) )
Expand Down Expand Up @@ -1085,7 +1085,7 @@ int QgsWFSProvider::getExtentFromGML2( QgsRectangle* extent, const QDomElement&
QDomNode coordinatesNode = childNode.firstChild();
if ( coordinatesNode.localName() == "coordinates" )
{
std::list<QgsPoint> boundingPoints;
QList<QgsPoint> boundingPoints;
if ( readGML2Coordinates( boundingPoints, coordinatesNode.toElement() ) != 0 )
{
return 5;
Expand All @@ -1096,7 +1096,7 @@ int QgsWFSProvider::getExtentFromGML2( QgsRectangle* extent, const QDomElement&
return 6;
}

std::list<QgsPoint>::const_iterator it = boundingPoints.begin();
QList<QgsPoint>::const_iterator it = boundingPoints.begin();
extent->setXMinimum( it->x() );
extent->setYMinimum( it->y() );
++it;
Expand Down Expand Up @@ -1256,7 +1256,7 @@ int QgsWFSProvider::getFeaturesFromGML2( const QDomElement& wfsCollectionElement
return 0;
}

int QgsWFSProvider::readGML2Coordinates( std::list<QgsPoint>& coords, const QDomElement& elem ) const
int QgsWFSProvider::readGML2Coordinates( QList<QgsPoint>& coords, const QDomElement& elem ) const
{
QString coordSeparator = ",";
QString tupelSeparator = " ";
Expand Down
4 changes: 2 additions & 2 deletions src/providers/wfs/qgswfsprovider.h
Expand Up @@ -237,7 +237,7 @@ class QgsWFSProvider : public QgsVectorDataProvider
/** Reads the name of the geometry attribute, the thematic attributes and their types from a dom document. Returns 0 in case of success*/
int readAttributesFromSchema( QDomDocument& schemaDoc, QString& geometryAttribute, QgsFields& fields, QGis::WkbType& geomType );
/** This method tries to guess the geometry attribute and the other attribute names from the .gml file if no schema is present. Returns 0 in case of success*/
int guessAttributesFromFile( const QString& uri, QString& geometryAttribute, std::list<QString>& thematicAttributes, QGis::WkbType& geomType ) const;
int guessAttributesFromFile( const QString& uri, QString& geometryAttribute, QStringList &thematicAttributes, QGis::WkbType& geomType ) const;

//GML2 specific methods
int getExtentFromGML2( QgsRectangle* extent, const QDomElement& wfsCollectionElement ) const;
Expand All @@ -247,7 +247,7 @@ class QgsWFSProvider : public QgsVectorDataProvider
@param coords list where the found coordinates are appended
@param elem the <gml:coordinates> element
@return 0 in case of success*/
int readGML2Coordinates( std::list<QgsPoint>& coords, const QDomElement& elem ) const;
int readGML2Coordinates( QList<QgsPoint> &coords, const QDomElement& elem ) const;
/** Tries to create a QgsCoordinateReferenceSystem object and assign it to mSourceCRS. Returns 0 in case of success*/
int setCRSFromGML2( const QDomElement& wfsCollectionElement );

Expand Down

0 comments on commit 5f1959b

Please sign in to comment.