@@ -40,7 +40,6 @@ QgsGrassVectorMapLayer::QgsGrassVectorMapLayer( QgsGrassVectorMap *map, int fiel
4040 : mField( field )
4141 , mValid( false )
4242 , mMap( map )
43- , mCidxFieldIndex( -1 )
4443 , mFieldInfo( 0 )
4544 , mDriver( 0 )
4645 , mHasTable( false )
@@ -52,7 +51,6 @@ QgsGrassVectorMapLayer::QgsGrassVectorMapLayer( QgsGrassVectorMap *map, int fiel
5251void QgsGrassVectorMapLayer::clear ()
5352{
5453 QgsDebugMsg ( " entered" );
55- mCidxFieldIndex = -1 ;
5654 mTableFields .clear ();
5755 mFields .clear ();
5856 mAttributeFields .clear ();
@@ -64,13 +62,22 @@ void QgsGrassVectorMapLayer::clear()
6462 mFieldInfo = 0 ;
6563}
6664
65+ int QgsGrassVectorMapLayer::cidxFieldIndex ()
66+ {
67+ if ( !mMap ->map () )
68+ {
69+ return -1 ;
70+ }
71+ return Vect_cidx_get_field_index ( mMap ->map (), mField );
72+ }
73+
6774int QgsGrassVectorMapLayer::cidxFieldNumCats ()
6875{
69- if ( !mMap ->map () || mCidxFieldIndex < 0 )
76+ if ( !mMap ->map () || cidxFieldIndex () < 0 )
7077 {
7178 return 0 ;
7279 }
73- return Vect_cidx_get_num_cats_by_index ( mMap ->map (), mCidxFieldIndex );
80+ return Vect_cidx_get_num_cats_by_index ( mMap ->map (), cidxFieldIndex () );
7481}
7582
7683void QgsGrassVectorMapLayer::load ()
@@ -89,8 +96,7 @@ void QgsGrassVectorMapLayer::load()
8996 return ;
9097 }
9198
92- mCidxFieldIndex = Vect_cidx_get_field_index ( mMap ->map (), mField );
93- QgsDebugMsg ( QString ( " mCidxFieldIndex = %1 cidxFieldNumCats() = %2" ).arg ( cidxFieldNumCats () ) );
99+ QgsDebugMsg ( QString ( " cidxFieldIndex() = %1 cidxFieldNumCats() = %2" ).arg ( cidxFieldIndex () ).arg ( cidxFieldNumCats () ) );
94100
95101 mFieldInfo = Vect_get_field ( mMap ->map (), mField ); // should work also with field = 0
96102
@@ -289,18 +295,18 @@ void QgsGrassVectorMapLayer::load()
289295 mTableFields .append ( QgsField ( " cat" , QVariant::Int, " integer" ) );
290296 QPair<double , double > minMax ( 0 , 0 );
291297
292- if ( mCidxFieldIndex >= 0 )
298+ if ( cidxFieldIndex () >= 0 )
293299 {
294300 int ncats, cat, type, id;
295301
296- ncats = Vect_cidx_get_num_cats_by_index ( mMap ->map (), mCidxFieldIndex );
302+ ncats = Vect_cidx_get_num_cats_by_index ( mMap ->map (), cidxFieldIndex () );
297303
298304 if ( ncats > 0 )
299305 {
300- Vect_cidx_get_cat_by_index ( mMap ->map (), mCidxFieldIndex , 0 , &cat, &type, &id );
306+ Vect_cidx_get_cat_by_index ( mMap ->map (), cidxFieldIndex () , 0 , &cat, &type, &id );
301307 minMax.first = cat;
302308
303- Vect_cidx_get_cat_by_index ( mMap ->map (), mCidxFieldIndex , ncats - 1 , &cat, &type, &id );
309+ Vect_cidx_get_cat_by_index ( mMap ->map (), cidxFieldIndex () , ncats - 1 , &cat, &type, &id );
304310 minMax.second = cat;
305311 }
306312 }
0 commit comments