Skip to content

Commit

Permalink
qgsprovidercountcalcevent api cleanups
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@9538 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Oct 24, 2008
1 parent eca978f commit bb9c89a
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 23 deletions.
6 changes: 3 additions & 3 deletions src/core/qgsprovidercountcalcevent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsprovidercountcalcevent.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ class CORE_EXPORT QgsProviderCountCalcEvent : public QEvent

public:

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

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


private:
Expand Down
10 changes: 5 additions & 5 deletions src/providers/ogr/qgsogrprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

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

/**
Expand Down Expand Up @@ -549,7 +549,7 @@ bool QgsOgrProvider::addFeature( QgsFeature& f )
{
f.setFeatureId( OGR_F_GetFID( feature ) );
}
++numberFeatures;
++featuresCounted;
OGR_F_Destroy( feature );
return returnValue;
}
Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/providers/ogr/qgsogrprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/providers/postgres/qgspostgrescountthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/providers/postgres/qgspostgrescountthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

};

Expand Down
14 changes: 7 additions & 7 deletions src/providers/postgres/qgspostgresprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" );
Expand Down Expand Up @@ -686,7 +686,7 @@ QGis::WkbType QgsPostgresProvider::geometryType() const
*/
long QgsPostgresProvider::featureCount() const
{
return numberFeatures;
return featuresCounted;
}

const QgsField &QgsPostgresProvider::field( int index ) const
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/providers/postgres/qgspostgresprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bb9c89a

Please sign in to comment.