Skip to content

Commit 56b8ce0

Browse files
committed
Merge pull request #2455 from sbrunner/refersh-attribut-table
Add "force reload" button to attribute table
2 parents 3daa404 + 594e5a2 commit 56b8ce0

File tree

4 files changed

+56
-1
lines changed

4 files changed

+56
-1
lines changed

src/app/qgsattributetabledialog.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *theLayer, QWid
212212
mToggleEditingButton->blockSignals( false );
213213

214214
mSaveEditsButton->setEnabled( mToggleEditingButton->isEnabled() && mLayer->isEditable() );
215+
mReloadButton->setEnabled( ! mLayer->isEditable() );
215216
mAddAttribute->setEnabled(( canChangeAttributes || canAddAttributes ) && mLayer->isEditable() );
216217
mDeleteSelectedButton->setEnabled( canDeleteFeatures && mLayer->isEditable() );
217218
mAddFeature->setEnabled( canAddFeatures && mLayer->isEditable() );
@@ -580,6 +581,11 @@ void QgsAttributeTableDialog::on_mSaveEditsButton_clicked()
580581
QgisApp::instance()->saveEdits( mLayer, true, true );
581582
}
582583

584+
void QgsAttributeTableDialog::on_mReloadButton_clicked()
585+
{
586+
mMainView->masterModel()->layer()->dataProvider()->forceReload();
587+
}
588+
583589
void QgsAttributeTableDialog::on_mAddFeature_clicked()
584590
{
585591
if ( !mLayer->isEditable() )
@@ -659,6 +665,7 @@ void QgsAttributeTableDialog::editingToggled()
659665
mToggleEditingButton->blockSignals( true );
660666
mToggleEditingButton->setChecked( mLayer->isEditable() );
661667
mSaveEditsButton->setEnabled( mLayer->isEditable() );
668+
mReloadButton->setEnabled( ! mLayer->isEditable() );
662669
mToggleEditingButton->blockSignals( false );
663670

664671
bool canChangeAttributes = mLayer->dataProvider()->capabilities() & QgsVectorDataProvider::ChangeAttributeValues;

src/app/qgsattributetabledialog.h

+4
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ class APP_EXPORT QgsAttributeTableDialog : public QDialog, private Ui::QgsAttrib
8686
* Saves edits
8787
*/
8888
void on_mSaveEditsButton_clicked();
89+
/**
90+
* Reload the data
91+
*/
92+
void on_mReloadButton_clicked();
8993

9094
/**
9195
* Inverts selection

src/core/qgsvectordataprovider.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,9 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider
378378
* This forces QGIS to reopen a file or connection.
379379
* This can be required if the underlying file is replaced.
380380
*/
381-
virtual void forceReload() {}
381+
virtual void forceReload() {
382+
emit dataChanged();
383+
}
382384

383385
protected:
384386
void clearMinMaxCache();

src/ui/qgsattributetabledialog.ui

+42
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,32 @@
9898
</property>
9999
</widget>
100100
</item>
101+
<item>
102+
<widget class="QToolButton" name="mReloadButton">
103+
<property name="toolTip">
104+
<string>Reload the table</string>
105+
</property>
106+
<property name="text">
107+
<string/>
108+
</property>
109+
<property name="icon">
110+
<iconset resource="../../images/images.qrc">
111+
<normaloff>:/images/themes/default/mActionRefresh.png</normaloff>:/images/themes/default/mActionRefresh.png</iconset>
112+
</property>
113+
<property name="iconSize">
114+
<size>
115+
<width>18</width>
116+
<height>18</height>
117+
</size>
118+
</property>
119+
<property name="checkable">
120+
<bool>false</bool>
121+
</property>
122+
<property name="autoRaise">
123+
<bool>true</bool>
124+
</property>
125+
</widget>
126+
</item>
101127
<item>
102128
<widget class="Line" name="line">
103129
<property name="orientation">
@@ -830,6 +856,22 @@
830856
</hint>
831857
</hints>
832858
</connection>
859+
<connection>
860+
<sender>mToggleEditingButton</sender>
861+
<signal>toggled(bool)</signal>
862+
<receiver>mReloadButton</receiver>
863+
<slot>setDisabled(bool)</slot>
864+
<hints>
865+
<hint type="sourcelabel">
866+
<x>14</x>
867+
<y>15</y>
868+
</hint>
869+
<hint type="destinationlabel">
870+
<x>74</x>
871+
<y>15</y>
872+
</hint>
873+
</hints>
874+
</connection>
833875
</connections>
834876
<buttongroups>
835877
<buttongroup name="mMainViewButtonGroup"/>

0 commit comments

Comments
 (0)