Navigation Menu

Skip to content

Commit

Permalink
Merge branch 'master' of github.com:qgis/Quantum-GIS
Browse files Browse the repository at this point in the history
  • Loading branch information
timlinux committed Nov 24, 2011
2 parents c02ccc9 + 9048107 commit 39a039d
Show file tree
Hide file tree
Showing 7 changed files with 253 additions and 150 deletions.
1 change: 1 addition & 0 deletions images/images.qrc
Expand Up @@ -203,6 +203,7 @@
<file>themes/default/propertyicons/rendering.png</file>
<file>themes/default/propertyicons/symbology.png</file>
<file>themes/default/propertyicons/transparency.png</file>
<file>themes/default/propertyicons/gdal.png</file>
<file>themes/default/qgis.xpm</file>
<file>themes/default/rendererCategorizedSymbol.png</file>
<file>themes/default/rendererGraduatedSymbol.png</file>
Expand Down
5 changes: 4 additions & 1 deletion src/app/qgsoptions.cpp 100644 → 100755
Expand Up @@ -67,7 +67,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
cmbSize->addItem( "32" );

QStringList styles = QStyleFactory::keys();
foreach(QString style, styles )
foreach( QString style, styles )
{
cmbStyle->addItem( style );
}
Expand Down Expand Up @@ -182,6 +182,8 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
cmbAttrTableBehaviour->addItem( tr( "Show features in current canvas" ) );
cmbAttrTableBehaviour->setCurrentIndex( settings.value( "/qgis/attributeTableBehaviour", 0 ).toInt() );

spinBoxAttrTableRowCache->setValue( settings.value( "/qgis/attributeTableRowCache", 10000 ).toInt() );

// set the display update threshold
spinBoxUpdateThreshold->setValue( settings.value( "/Map/updateThreshold" ).toInt() );
//set the default projection behaviour radio buttongs
Expand Down Expand Up @@ -584,6 +586,7 @@ void QgsOptions::saveOptions()
settings.setValue( "/qgis/showTips", cbxShowTips->isChecked() );
settings.setValue( "/qgis/dockAttributeTable", cbxAttributeTableDocked->isChecked() );
settings.setValue( "/qgis/attributeTableBehaviour", cmbAttrTableBehaviour->currentIndex() );
settings.setValue( "/qgis/attributeTableRowCache", spinBoxAttrTableRowCache->value() );
settings.setValue( "/qgis/dockIdentifyResults", cbxIdentifyResultsDocked->isChecked() );
settings.setValue( "/qgis/dockSnapping", cbxSnappingOptionsDocked->isChecked() );
settings.setValue( "/qgis/addPostgisDC", cbxAddPostgisDC->isChecked() );
Expand Down
4 changes: 3 additions & 1 deletion src/core/qgsproject.cpp 100644 → 100755
Expand Up @@ -1365,7 +1365,9 @@ QString QgsProject::readPath( QString src ) const
// where the source file had to exist and only the project directory was stripped
// from the filename.
QFileInfo pfi( fileName() );
Q_ASSERT( pfi.exists() );
if ( !pfi.exists() )
return src;

QFileInfo fi( pfi.canonicalPath() + "/" + src );

if ( !fi.exists() )
Expand Down
2 changes: 0 additions & 2 deletions src/gui/attributetable/qgsattributetablememorymodel.h
Expand Up @@ -81,8 +81,6 @@ class QgsAttributeTableMemoryModel : public QgsAttributeTableModel
* Loads the layer into the model
*/
virtual void loadLayer();

QHash<QgsFeatureId, QgsFeature> mFeatureMap;
};

#endif //QGSATTRIBUTETABLEMEMORYMODEL_H
33 changes: 32 additions & 1 deletion src/gui/attributetable/qgsattributetablemodel.cpp 100644 → 100755
Expand Up @@ -33,6 +33,9 @@ QgsAttributeTableModel::QgsAttributeTableModel( QgsVectorLayer *theLayer, QObjec
: QAbstractTableModel( parent )
{
mFeat.setFeatureId( std::numeric_limits<int>::min() );
mFeatureMap.clear();
mFeatureQueue.clear();

mLayer = theLayer;
loadAttributes();

Expand All @@ -50,9 +53,33 @@ bool QgsAttributeTableModel::featureAtId( QgsFeatureId fid ) const
QgsDebugMsgLevel( QString( "loading feature %1" ).arg( fid ), 3 );

if ( fid == std::numeric_limits<int>::min() )
{
return false;
}
else if ( mFeatureMap.contains( fid ) )
{
mFeat = mFeatureMap[ fid ];
return true;
}
else if ( mLayer->featureAtId( fid, mFeat, false, true ) )
{
QSettings settings;
int cacheSize = settings.value( "/qgis/attributeTableRowCache", "10000" ).toInt();

if ( mFeatureQueue.size() == cacheSize )
{
mFeatureMap.remove( mFeatureQueue.dequeue() );
}

mFeatureQueue.enqueue( fid );
mFeatureMap.insert( fid, mFeat );

return true;
}
else
return mLayer->featureAtId( fid, mFeat, false, true );
{
return false;
}
}

void QgsAttributeTableModel::featureDeleted( QgsFeatureId fid )
Expand Down Expand Up @@ -152,6 +179,10 @@ void QgsAttributeTableModel::layerDeleted()

void QgsAttributeTableModel::attributeValueChanged( QgsFeatureId fid, int idx, const QVariant &value )
{
if ( mFeatureMap.contains( fid ) )
{
mFeatureMap[ fid ].changeAttribute( fieldCol( idx ), value );
}
setData( index( idToRow( fid ), fieldCol( idx ) ), value, Qt::EditRole );
}

Expand Down
6 changes: 6 additions & 0 deletions src/gui/attributetable/qgsattributetablemodel.h
Expand Up @@ -21,6 +21,7 @@
#include <QModelIndex>
#include <QObject>
#include <QHash>
#include <QQueue>

#include "qgsfeature.h" // QgsAttributeMap
#include "qgsvectorlayer.h" // QgsAttributeList
Expand Down Expand Up @@ -196,6 +197,7 @@ class GUI_EXPORT QgsAttributeTableModel: public QAbstractTableModel
int mFieldCount;

mutable QgsFeature mFeat;
mutable QHash<QgsFeatureId, QgsFeature> mFeatureMap;

QgsAttributeList mAttributes;
QMap< int, const QMap<QString, QVariant> * > mValueMaps;
Expand Down Expand Up @@ -228,6 +230,10 @@ class GUI_EXPORT QgsAttributeTableModel: public QAbstractTableModel
* @return feature exists
*/
virtual bool featureAtId( QgsFeatureId fid ) const;

private:
mutable QQueue<QgsFeatureId> mFeatureQueue;

};


Expand Down

0 comments on commit 39a039d

Please sign in to comment.