Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/qgis/Quantum-GIS
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Yakushev committed Jan 15, 2012
2 parents aa323ae + a6df30c commit c56d02f
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/app/qgsrasterlayerproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,7 @@ void QgsRasterLayerProperties::sync()
cboRed->setCurrentIndex( cboRed->findText( mRasterLayer->redBandName() ) );
cboGreen->setCurrentIndex( cboGreen->findText( mRasterLayer->greenBandName() ) );
cboBlue->setCurrentIndex( cboBlue->findText( mRasterLayer->blueBandName() ) );
cboGray->setCurrentIndex( cboGray->findText( mRasterLayer->grayBandName() ) );

//Display the current default contrast enhancement algorithm
mDefaultContrastEnhancementAlgorithm = myQSettings.value( "/Raster/defaultContrastEnhancementAlgorithm", "NoEnhancement" ).toString();
Expand Down
4 changes: 2 additions & 2 deletions src/gui/attributetable/qgsattributetablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ bool QgsAttributeTableModel::featureAtId( QgsFeatureId fid ) const
else if ( mLayer->featureAtId( fid, mFeat, false, true ) )
{
QSettings settings;
int cacheSize = settings.value( "/qgis/attributeTableRowCache", "10000" ).toInt();
int cacheSize = qMax( 1, settings.value( "/qgis/attributeTableRowCache", "10000" ).toInt() );

if ( mFeatureQueue.size() == cacheSize )
while ( mFeatureQueue.size() >= cacheSize )
{
mFeatureMap.remove( mFeatureQueue.dequeue() );
}
Expand Down
23 changes: 20 additions & 3 deletions src/providers/spatialite/qgsspatialiteprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ QgsSpatiaLiteProvider::QgsSpatiaLiteProvider( QString const &uri )
return;
}
enabledCapabilities = QgsVectorDataProvider::SelectAtId | QgsVectorDataProvider::SelectGeometryAtId;
if ( mTableBased && !mReadOnly )
if (( mTableBased | mViewBased ) && !mReadOnly )
{
// enabling editing only for Tables [excluding Views and VirtualShapes]
enabledCapabilities |= QgsVectorDataProvider::DeleteFeatures;
Expand Down Expand Up @@ -650,6 +650,23 @@ void QgsSpatiaLiteProvider::loadFields()
}
}

bool QgsSpatiaLiteProvider::hasTriggers()
{
int ret;
char **results;
int rows;
int columns;
char *errMsg = NULL;
QString sql;

sql = QString( "SELECT * FROM sqlite_master WHERE type='trigger' AND tbl_name=%1" )
.arg( quotedIdentifier( mTableName ) );

ret = sqlite3_get_table( sqliteHandle, sql.toUtf8().constData(), &results, &rows, &columns, &errMsg );
sqlite3_free_table( results );
return ( ret == SQLITE_OK && rows > 0 );
}


QString QgsSpatiaLiteProvider::storageType() const
{
Expand Down Expand Up @@ -4217,7 +4234,7 @@ bool QgsSpatiaLiteProvider::checkLayerType()
else if ( type == "view" )
{
mViewBased = true;
mReadOnly = true;
mReadOnly = !hasTriggers();
}
count++;
}
Expand Down Expand Up @@ -4321,7 +4338,7 @@ bool QgsSpatiaLiteProvider::checkLayerType()
if ( ret == SQLITE_OK && rows == 1 )
{
mViewBased = true;
mReadOnly = true;
mReadOnly = !hasTriggers();
count++;
}
if ( errMsg )
Expand Down
3 changes: 3 additions & 0 deletions src/providers/spatialite/qgsspatialiteprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,9 @@ class QgsSpatiaLiteProvider: public QgsVectorDataProvider
/** loads fields from input file to member attributeFields */
void loadFields();

/** Check if a table/view has any triggers. Triggers can be used on views to make them editable.*/
bool hasTriggers();

/** convert a QgsField to work with SL */
static bool convertField( QgsField &field );

Expand Down
3 changes: 3 additions & 0 deletions src/ui/qgsoptionsbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,9 @@
</item>
<item>
<widget class="QSpinBox" name="spinBoxAttrTableRowCache">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>100000</number>
</property>
Expand Down

0 comments on commit c56d02f

Please sign in to comment.