Skip to content
Permalink
Browse files
qgsprovidercountcalcevent api cleanups
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@9538 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Oct 24, 2008
1 parent 8f4ac33 commit c14bf13156df1b1aa636d5593f1d340ed02c0e0b
@@ -20,15 +20,15 @@
#include "qgsprovidercountcalcevent.h"
#include "qgis.h"

QgsProviderCountCalcEvent::QgsProviderCountCalcEvent( long numberFeatures )
QgsProviderCountCalcEvent::QgsProviderCountCalcEvent( long featuresCounted )
: QEvent( static_cast<QEvent::Type>( QGis::ProviderCountCalcEvent ) ),
n( numberFeatures )
n( featuresCounted )
{
// NO-OP
}


long QgsProviderCountCalcEvent::numberFeatures() const
long QgsProviderCountCalcEvent::featuresCounted() const
{
return n;
}
@@ -44,9 +44,9 @@ class CORE_EXPORT QgsProviderCountCalcEvent : public QEvent

public:

QgsProviderCountCalcEvent( long numberFeatures );
QgsProviderCountCalcEvent( long featuresCounted );

long numberFeatures() const;
long featuresCounted() const;


private:
@@ -111,7 +111,7 @@ QgsOgrProvider::QgsOgrProvider( QString const & uri )

// getting the total number of features in the layer
// TODO: This can be expensive, do we really need it!
numberFeatures = OGR_L_GetFeatureCount( ogrLayer, TRUE );
featuresCounted = OGR_L_GetFeatureCount( ogrLayer, TRUE );

// check the validity of the layer

@@ -410,7 +410,7 @@ QGis::WkbType QgsOgrProvider::geometryType() const
*/
long QgsOgrProvider::featureCount() const
{
return numberFeatures;
return featuresCounted;
}

/**
@@ -549,7 +549,7 @@ bool QgsOgrProvider::addFeature( QgsFeature& f )
{
f.setFeatureId( OGR_F_GetFID( feature ) );
}
++numberFeatures;
++featuresCounted;
OGR_F_Destroy( feature );
return returnValue;
}
@@ -568,7 +568,7 @@ bool QgsOgrProvider::addFeatures( QgsFeatureList & flist )

// flush features
OGR_L_SyncToDisk( ogrLayer );
numberFeatures = OGR_L_GetFeatureCount( ogrLayer, TRUE ); //new feature count
featuresCounted = OGR_L_GetFeatureCount( ogrLayer, TRUE ); //new feature count
return returnvalue;
}

@@ -758,7 +758,7 @@ bool QgsOgrProvider::deleteFeatures( const QgsFeatureIds & id )
QString layerName = fileName.section( '.', 0, 0 );
QString sql = "REPACK " + layerName;
OGR_DS_ExecuteSQL( ogrDataSource, sql.toLocal8Bit().data(), NULL, NULL );
numberFeatures = OGR_L_GetFeatureCount( ogrLayer, TRUE ); //new feature count
featuresCounted = OGR_L_GetFeatureCount( ogrLayer, TRUE ); //new feature count
return returnvalue;
}

@@ -243,7 +243,7 @@ class QgsOgrProvider : public QgsVectorDataProvider
//! Flag to indicate that spatial intersect should be used in selecting features
bool mUseIntersect;
int geomType;
long numberFeatures;
long featuresCounted;

//! Selection rectangle
OGRGeometryH mSelectionRectangle;
@@ -97,10 +97,10 @@ void QgsPostgresCountThread::run()
QgsDebugMsg( "QgsPostgresCountThread: Query completed." );


numberFeatures = QString( PQgetvalue( result, 0, 0 ) ).toLong();
featuresCounted = QString( PQgetvalue( result, 0, 0 ) ).toLong();
PQclear( result );

QgsDebugMsg( QString( "QgsPostgresCountThread: Exact Number of features: %1" ).arg( numberFeatures ) );
QgsDebugMsg( QString( "QgsPostgresCountThread: Exact Number of features: %1" ).arg( featuresCounted ) );


// Send some events (instead of a signal) as it is thread-safe
@@ -111,7 +111,7 @@ void QgsPostgresCountThread::run()

QgsDebugMsg( QString( "About to create and dispatch event %1 to callback" ).arg( QGis::ProviderCountCalcEvent ) );

QgsProviderCountCalcEvent* e1 = new QgsProviderCountCalcEvent( numberFeatures );
QgsProviderCountCalcEvent* e1 = new QgsProviderCountCalcEvent( featuresCounted );
QApplication::postEvent(( QObject * )callbackObject, e1 );

// QApplication::postEvent(qApp->mainWidget(), e1);
@@ -120,7 +120,7 @@ class QgsPostgresCountThread : public QThread
/**
* Integer that contains the row count (including non-geometry rows) of the layer
*/
long numberFeatures;
long featuresCounted;

};

@@ -177,7 +177,7 @@ QgsPostgresProvider::QgsPostgresProvider( QString const & uri )
if ( !getGeometryDetails() ) // gets srid and geometry type
{
// the table is not a geometry table
numberFeatures = 0;
featuresCounted = 0;
valid = false;

QgsDebugMsg( "Invalid Postgres layer" );
@@ -686,7 +686,7 @@ QGis::WkbType QgsPostgresProvider::geometryType() const
*/
long QgsPostgresProvider::featureCount() const
{
return numberFeatures;
return featuresCounted;
}

const QgsField &QgsPostgresProvider::field( int index ) const
@@ -2209,11 +2209,11 @@ long QgsPostgresProvider::getFeatureCount()
QgsDebugMsg( "Approximate Number of features as text: " +
QString::fromUtf8( PQgetvalue( result, 0, 0 ) ) );

numberFeatures = QString::fromUtf8( PQgetvalue( result, 0, 0 ) ).toLong();
featuresCounted = QString::fromUtf8( PQgetvalue( result, 0, 0 ) ).toLong();

QgsDebugMsg( "Approximate Number of features: " + QString::number( numberFeatures ) );
QgsDebugMsg( "Approximate Number of features: " + QString::number( featuresCounted ) );

return numberFeatures;
return featuresCounted;
}

// TODO: use the estimateExtents procedure of PostGIS and PostgreSQL 8
@@ -2382,9 +2382,9 @@ void QgsPostgresProvider::customEvent( QEvent * e )

QgsDebugMsg( "count has been calculated" );

numberFeatures = (( QgsProviderCountCalcEvent* ) e )->numberFeatures();
featuresCounted = (( QgsProviderCountCalcEvent* ) e )->featuresCounted();

QgsDebugMsg( "count is " + QString::number( numberFeatures ) );
QgsDebugMsg( "count is " + QString::number( featuresCounted ) );

break;

@@ -405,7 +405,7 @@ class QgsPostgresProvider : public QgsVectorDataProvider
/**
* Number of features in the layer
*/
long numberFeatures;
long featuresCounted;

/**
* Feature queue that GetNextFeature will retrieve from

0 comments on commit c14bf13

Please sign in to comment.