Skip to content

Commit 594e5a2

Browse files
committedNov 7, 2015
Be able to refresh the attribute table
1 parent 71a6a3d commit 594e5a2

File tree

4 files changed

+56
-1
lines changed

4 files changed

+56
-1
lines changed
 

‎src/app/qgsattributetabledialog.cpp

Lines changed: 7 additions & 0 deletions
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() );
@@ -579,6 +580,11 @@ void QgsAttributeTableDialog::on_mSaveEditsButton_clicked()
579580
QgisApp::instance()->saveEdits( mLayer, true, true );
580581
}
581582

583+
void QgsAttributeTableDialog::on_mReloadButton_clicked()
584+
{
585+
mMainView->masterModel()->layer()->dataProvider()->forceReload();
586+
}
587+
582588
void QgsAttributeTableDialog::on_mAddFeature_clicked()
583589
{
584590
if ( !mLayer->isEditable() )
@@ -658,6 +664,7 @@ void QgsAttributeTableDialog::editingToggled()
658664
mToggleEditingButton->blockSignals( true );
659665
mToggleEditingButton->setChecked( mLayer->isEditable() );
660666
mSaveEditsButton->setEnabled( mLayer->isEditable() );
667+
mReloadButton->setEnabled( ! mLayer->isEditable() );
661668
mToggleEditingButton->blockSignals( false );
662669

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

‎src/app/qgsattributetabledialog.h

Lines changed: 4 additions & 0 deletions
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

Lines changed: 3 additions & 1 deletion
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

Lines changed: 42 additions & 0 deletions
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)
Please sign in to comment.