Skip to content
Permalink
Browse files

move more stl usage to qt

  • Loading branch information
jef-n committed Dec 25, 2015
1 parent 4530c2a commit 5f1959bc781a853a7856197efd6b5ec44089ea39
@@ -28,10 +28,6 @@
#include <QString>
#include <QtAlgorithms>

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

class QgsPointCompare
{
public:
@@ -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;

@@ -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();
@@ -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
@@ -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() )
@@ -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 )
@@ -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] ) );
@@ -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 };
@@ -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;
@@ -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;
@@ -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();
@@ -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();

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

return prob->getSolution( displayAll );
@@ -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 );

@@ -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
@@ -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 )
{
@@ -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;
@@ -136,7 +136,7 @@ namespace pal
*/
void chain_search();

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

PalStat * getStats();

@@ -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
{
@@ -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() )
@@ -20,10 +20,6 @@

#include "qgsconfig.h"

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

#include "qgsexpressioncontext.h"
#include "qgsrectangle.h"
#include "qgspoint.h"
@@ -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
*/
@@ -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>
@@ -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.
@@ -30,6 +30,7 @@ extern "C"
#include <qgsvectorlayer.h>
#include <qgsmaplayerregistry.h>
#include <qgsdatasourceuri.h>

#include "qgsvirtuallayerprovider.h"
#include "qgsvirtuallayersqlitemodule.h"
#include "qgsvirtuallayerqueryparser.h"
@@ -3,6 +3,7 @@
#include "qgsvirtuallayerblob.h"

#include <QRegExp>
#include <QtDebug>

namespace QgsVirtualLayerQueryParser
{
@@ -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
@@ -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 )
@@ -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 )
@@ -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;
}
@@ -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 ) )
@@ -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;
@@ -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;
@@ -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 = " ";
@@ -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;
@@ -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 );

0 comments on commit 5f1959b

Please sign in to comment.
You can’t perform that action at this time.