Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Be able to refresh the attribute table
  • Loading branch information
sbrunner committed Nov 7, 2015
1 parent 71a6a3d commit 594e5a2
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/app/qgsattributetabledialog.cpp
Expand Up @@ -212,6 +212,7 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *theLayer, QWid
mToggleEditingButton->blockSignals( false );

mSaveEditsButton->setEnabled( mToggleEditingButton->isEnabled() && mLayer->isEditable() );
mReloadButton->setEnabled( ! mLayer->isEditable() );
mAddAttribute->setEnabled(( canChangeAttributes || canAddAttributes ) && mLayer->isEditable() );
mDeleteSelectedButton->setEnabled( canDeleteFeatures && mLayer->isEditable() );
mAddFeature->setEnabled( canAddFeatures && mLayer->isEditable() );
Expand Down Expand Up @@ -579,6 +580,11 @@ void QgsAttributeTableDialog::on_mSaveEditsButton_clicked()
QgisApp::instance()->saveEdits( mLayer, true, true );
}

void QgsAttributeTableDialog::on_mReloadButton_clicked()
{
mMainView->masterModel()->layer()->dataProvider()->forceReload();
}

void QgsAttributeTableDialog::on_mAddFeature_clicked()
{
if ( !mLayer->isEditable() )
Expand Down Expand Up @@ -658,6 +664,7 @@ void QgsAttributeTableDialog::editingToggled()
mToggleEditingButton->blockSignals( true );
mToggleEditingButton->setChecked( mLayer->isEditable() );
mSaveEditsButton->setEnabled( mLayer->isEditable() );
mReloadButton->setEnabled( ! mLayer->isEditable() );
mToggleEditingButton->blockSignals( false );

bool canChangeAttributes = mLayer->dataProvider()->capabilities() & QgsVectorDataProvider::ChangeAttributeValues;
Expand Down
4 changes: 4 additions & 0 deletions src/app/qgsattributetabledialog.h
Expand Up @@ -86,6 +86,10 @@ class APP_EXPORT QgsAttributeTableDialog : public QDialog, private Ui::QgsAttrib
* Saves edits
*/
void on_mSaveEditsButton_clicked();
/**
* Reload the data
*/
void on_mReloadButton_clicked();

/**
* Inverts selection
Expand Down
4 changes: 3 additions & 1 deletion src/core/qgsvectordataprovider.h
Expand Up @@ -378,7 +378,9 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider
* This forces QGIS to reopen a file or connection.
* This can be required if the underlying file is replaced.
*/
virtual void forceReload() {}
virtual void forceReload() {
emit dataChanged();
}

protected:
void clearMinMaxCache();
Expand Down
42 changes: 42 additions & 0 deletions src/ui/qgsattributetabledialog.ui
Expand Up @@ -98,6 +98,32 @@
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="mReloadButton">
<property name="toolTip">
<string>Reload the table</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionRefresh.png</normaloff>:/images/themes/default/mActionRefresh.png</iconset>
</property>
<property name="iconSize">
<size>
<width>18</width>
<height>18</height>
</size>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
Expand Down Expand Up @@ -830,6 +856,22 @@
</hint>
</hints>
</connection>
<connection>
<sender>mToggleEditingButton</sender>
<signal>toggled(bool)</signal>
<receiver>mReloadButton</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>14</x>
<y>15</y>
</hint>
<hint type="destinationlabel">
<x>74</x>
<y>15</y>
</hint>
</hints>
</connection>
</connections>
<buttongroups>
<buttongroup name="mMainViewButtonGroup"/>
Expand Down

0 comments on commit 594e5a2

Please sign in to comment.