[QGIS Commit] r14560 - trunk/qgis/src/plugins/offline_editing
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Fri Nov 12 11:42:52 EST 2010
Author: mwalker
Date: 2010-11-12 08:42:52 -0800 (Fri, 12 Nov 2010)
New Revision: 14560
Modified:
trunk/qgis/src/plugins/offline_editing/offline_editing_plugin_gui.cpp
trunk/qgis/src/plugins/offline_editing/offline_editing_plugin_gui.h
trunk/qgis/src/plugins/offline_editing/offline_editing_plugin_guibase.ui
Log:
Offline editing plugin: add option to filter editable remote layers using capabilities
Modified: trunk/qgis/src/plugins/offline_editing/offline_editing_plugin_gui.cpp
===================================================================
--- trunk/qgis/src/plugins/offline_editing/offline_editing_plugin_gui.cpp 2010-11-12 16:34:45 UTC (rev 14559)
+++ trunk/qgis/src/plugins/offline_editing/offline_editing_plugin_gui.cpp 2010-11-12 16:42:52 UTC (rev 14560)
@@ -21,6 +21,8 @@
#include <qgscontexthelp.h>
#include <qgsmaplayer.h>
#include <qgsmaplayerregistry.h>
+#include <qgsvectordataprovider.h>
+#include <qgsvectorlayer.h>
#include <QFileDialog>
#include <QMessageBox>
@@ -39,15 +41,7 @@
mOfflineDbFile = "offline.sqlite";
ui_offlineDataPath->setText( QDir( mOfflineDataPath ).absoluteFilePath( mOfflineDbFile ) );
- QMap<QString, QgsMapLayer*> mapLayers = QgsMapLayerRegistry::instance()->mapLayers();
- for ( QMap<QString, QgsMapLayer*>::iterator layer_it = mapLayers.begin() ; layer_it != mapLayers.end(); ++layer_it )
- {
- if ( layer_it.value()->type() == QgsMapLayer::VectorLayer )
- {
- QListWidgetItem* item = new QListWidgetItem( layer_it.value()->name(), ui_layerList );
- item->setData( Qt::UserRole, QVariant( layer_it.key() ) );
- }
- }
+ updateLayerList( checkboxShowEditableLayers->checkState() == Qt::Checked );
}
QgsOfflineEditingPluginGui::~QgsOfflineEditingPluginGui()
@@ -69,6 +63,36 @@
return mSelectedLayerIds;
}
+void QgsOfflineEditingPluginGui::updateLayerList( bool filterEditableLayers )
+{
+ ui_layerList->clear();
+
+ QMap<QString, QgsMapLayer*> mapLayers = QgsMapLayerRegistry::instance()->mapLayers();
+ for ( QMap<QString, QgsMapLayer*>::iterator layer_it = mapLayers.begin() ; layer_it != mapLayers.end(); ++layer_it )
+ {
+ if ( layer_it.value()->type() == QgsMapLayer::VectorLayer )
+ {
+ QgsVectorLayer* layer = qobject_cast<QgsVectorLayer*>( layer_it.value() );
+
+ bool showLayer = true;
+ if ( filterEditableLayers )
+ {
+ int cap = layer->dataProvider()->capabilities();
+ showLayer = ( cap & QgsVectorDataProvider::AddFeatures ) &&
+ ( cap & QgsVectorDataProvider::DeleteFeatures ) &&
+ ( cap & QgsVectorDataProvider::ChangeAttributeValues ) &&
+ ( cap & QgsVectorDataProvider::AddAttributes ) &&
+ ( cap & QgsVectorDataProvider::ChangeGeometries );
+ }
+ if ( showLayer )
+ {
+ QListWidgetItem* item = new QListWidgetItem( layer->name(), ui_layerList );
+ item->setData( Qt::UserRole, QVariant( layer_it.key() ) );
+ }
+ }
+ }
+}
+
void QgsOfflineEditingPluginGui::on_butBrowse_clicked()
{
QString fileName = QFileDialog::getSaveFileName( this,
@@ -85,6 +109,11 @@
}
}
+void QgsOfflineEditingPluginGui::on_checkboxShowEditableLayers_stateChanged( int state )
+{
+ updateLayerList( checkboxShowEditableLayers->checkState() == Qt::Checked );
+}
+
void QgsOfflineEditingPluginGui::on_buttonBox_accepted()
{
if ( QFile( QDir( mOfflineDataPath ).absoluteFilePath( mOfflineDbFile ) ).exists() )
Modified: trunk/qgis/src/plugins/offline_editing/offline_editing_plugin_gui.h
===================================================================
--- trunk/qgis/src/plugins/offline_editing/offline_editing_plugin_gui.h 2010-11-12 16:34:45 UTC (rev 14559)
+++ trunk/qgis/src/plugins/offline_editing/offline_editing_plugin_gui.h 2010-11-12 16:42:52 UTC (rev 14560)
@@ -35,6 +35,8 @@
QStringList& selectedLayerIds();
private:
+ void updateLayerList( bool filterEditableLayers );
+
static const int context_id = 0;
QString mOfflineDataPath;
QString mOfflineDbFile;
@@ -42,6 +44,7 @@
private slots:
void on_butBrowse_clicked();
+ void on_checkboxShowEditableLayers_stateChanged( int state );
void on_buttonBox_accepted();
void on_buttonBox_rejected();
void on_buttonBox_helpRequested();
Modified: trunk/qgis/src/plugins/offline_editing/offline_editing_plugin_guibase.ui
===================================================================
--- trunk/qgis/src/plugins/offline_editing/offline_editing_plugin_guibase.ui 2010-11-12 16:34:45 UTC (rev 14559)
+++ trunk/qgis/src/plugins/offline_editing/offline_editing_plugin_guibase.ui 2010-11-12 16:42:52 UTC (rev 14560)
@@ -63,14 +63,28 @@
</layout>
</item>
<item>
- <widget class="QDialogButtonBox" name="buttonBox">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="standardButtons">
- <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
- </property>
- </widget>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QCheckBox" name="checkboxShowEditableLayers">
+ <property name="text">
+ <string>Show only editable layers</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
</item>
</layout>
</widget>
More information about the QGIS-commit
mailing list