[QGIS Commit] r13896 -
branches/threading-branch/src/app/attributetable
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Wed Jul 7 10:15:53 EDT 2010
Author: wonder
Date: 2010-07-07 14:15:53 +0000 (Wed, 07 Jul 2010)
New Revision: 13896
Modified:
branches/threading-branch/src/app/attributetable/qgsattributetablememorymodel.cpp
branches/threading-branch/src/app/attributetable/qgsattributetablememorymodel.h
branches/threading-branch/src/app/attributetable/qgsattributetablemodel.cpp
branches/threading-branch/src/app/attributetable/qgsattributetablemodel.h
branches/threading-branch/src/app/attributetable/qgsattributetableview.cpp
Log:
Made attribute table work correctly with memory model (providers not supporting featureAtId calls are loaded just once into memory)
Load layer once the model has been constructed and not in constructor (to avoid loading the layer multiple times).
Modified: branches/threading-branch/src/app/attributetable/qgsattributetablememorymodel.cpp
===================================================================
--- branches/threading-branch/src/app/attributetable/qgsattributetablememorymodel.cpp 2010-07-06 21:43:42 UTC (rev 13895)
+++ branches/threading-branch/src/app/attributetable/qgsattributetablememorymodel.cpp 2010-07-07 14:15:53 UTC (rev 13896)
@@ -43,10 +43,11 @@
( QgsVectorLayer *theLayer )
: QgsAttributeTableModel( theLayer )
{
- loadLayer();
+ // do not call virtual methods in constructors!
+ //loadLayer();
}
-bool QgsAttributeTableMemoryModel::featureAtId( int fid )
+bool QgsAttributeTableMemoryModel::featureAtId( int fid ) const
{
if ( mFeatureMap.contains( fid ) )
{
Modified: branches/threading-branch/src/app/attributetable/qgsattributetablememorymodel.h
===================================================================
--- branches/threading-branch/src/app/attributetable/qgsattributetablememorymodel.h 2010-07-06 21:43:42 UTC (rev 13895)
+++ branches/threading-branch/src/app/attributetable/qgsattributetablememorymodel.h 2010-07-07 14:15:53 UTC (rev 13896)
@@ -39,6 +39,11 @@
*/
QgsAttributeTableMemoryModel( QgsVectorLayer *theLayer );
+ /**
+ * Loads the layer into the model
+ */
+ virtual void loadLayer();
+
protected slots:
#if 0
/**
@@ -72,13 +77,8 @@
* @param fid feature id
* @return feature exists
*/
- virtual bool featureAtId( int fid );
+ virtual bool featureAtId( int fid ) const;
- /**
- * Loads the layer into the model
- */
- virtual void loadLayer();
-
QHash<int, QgsFeature> mFeatureMap;
};
Modified: branches/threading-branch/src/app/attributetable/qgsattributetablemodel.cpp
===================================================================
--- branches/threading-branch/src/app/attributetable/qgsattributetablemodel.cpp 2010-07-06 21:43:42 UTC (rev 13895)
+++ branches/threading-branch/src/app/attributetable/qgsattributetablemodel.cpp 2010-07-07 14:15:53 UTC (rev 13896)
@@ -43,7 +43,8 @@
//connect(mLayer, SIGNAL(featureDeleted(int)), this, SLOT( featureDeleted(int)));
//connect(mLayer, SIGNAL(featureAdded(int)), this, SLOT( featureAdded(int)));
- loadLayer();
+ // do not call virtual methods in constructors!
+ //loadLayer();
}
bool QgsAttributeTableModel::featureAtId( int fid ) const
Modified: branches/threading-branch/src/app/attributetable/qgsattributetablemodel.h
===================================================================
--- branches/threading-branch/src/app/attributetable/qgsattributetablemodel.h 2010-07-06 21:43:42 UTC (rev 13895)
+++ branches/threading-branch/src/app/attributetable/qgsattributetablemodel.h 2010-07-07 14:15:53 UTC (rev 13896)
@@ -128,6 +128,12 @@
/** Execute an action */
void executeAction( int action, const QModelIndex &idx ) const;
+ /**
+ * Loads the layer into the model
+ */
+ virtual void loadLayer();
+
+
signals:
/**
* Model has been changed
@@ -202,11 +208,6 @@
void initIdMaps();
/**
- * Loads the layer into the model
- */
- virtual void loadLayer();
-
- /**
* Gets mFieldCount, mAttributes and mValueMaps
*/
virtual void loadAttributes();
Modified: branches/threading-branch/src/app/attributetable/qgsattributetableview.cpp
===================================================================
--- branches/threading-branch/src/app/attributetable/qgsattributetableview.cpp 2010-07-06 21:43:42 UTC (rev 13895)
+++ branches/threading-branch/src/app/attributetable/qgsattributetableview.cpp 2010-07-07 14:15:53 UTC (rev 13896)
@@ -55,6 +55,9 @@
else
mModel = new QgsAttributeTableMemoryModel( layer );
+ // tell the model to get initialized
+ mModel->loadLayer();
+
mFilterModel = new QgsAttributeTableFilterModel( layer );
mFilterModel->setSourceModel( mModel );
setModel( mFilterModel );
More information about the QGIS-commit
mailing list