Skip to content

Commit c0a0f7d

Browse files
committedMay 15, 2019
add first/last buttons
1 parent f680466 commit c0a0f7d

File tree

9 files changed

+289
-56
lines changed

9 files changed

+289
-56
lines changed
 

‎images/images.qrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,8 @@
751751
<file>themes/default/mIconDataDefineColor.svg</file>
752752
<file>themes/default/mIconDataDefineColorOn.svg</file>
753753
<file>themes/default/mActionNewVirtualLayer.svg</file>
754+
<file>themes/default/mActionDoubleArrowRight.svg</file>
755+
<file>themes/default/mActionDoubleArrowLeft.svg</file>
754756
</qresource>
755757
<qresource prefix="/images/tips">
756758
<file alias="symbol_levels.png">qgis_tips/symbol_levels.png</file>
Lines changed: 81 additions & 0 deletions
Loading
Lines changed: 81 additions & 0 deletions
Loading

‎python/gui/auto_generated/attributetable/qgsfeaturelistview.sip.in

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,20 +172,36 @@ Select all currently visible features
172172
void repaintRequested( const QModelIndexList &indexes );
173173
void repaintRequested();
174174

175+
void editFirstFeature();
176+
%Docstring
177+
editFirstFeature will try to edit the first feature of the list
178+
179+
.. versionadded:: 3.8
180+
%End
181+
175182
void editNextFeature();
176183
%Docstring
177-
editNextFeature will try to edit next feature in form
184+
editNextFeature will try to edit next feature of the list
178185

179186
.. versionadded:: 3.8
180187
%End
181188

182189
void editPreviousFeature();
183190
%Docstring
184-
editPreviousFeature will try to edit previous feature in form
191+
editPreviousFeature will try to edit previous feature of the list
192+
193+
.. versionadded:: 3.8
194+
%End
195+
196+
void editLastFeature();
197+
%Docstring
198+
editLastFeature will try to edit the last feature of the list
185199

186200
.. versionadded:: 3.8
187201
%End
188202

203+
204+
189205
};
190206

191207
/************************************************************************

‎src/gui/attributetable/qgsdualview.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ QgsDualView::QgsDualView( QWidget *parent )
6464

6565
connect( mNextFeatureButton, &QToolButton::clicked, mFeatureListView, &QgsFeatureListView::editNextFeature );
6666
connect( mPreviousFeatureButton, &QToolButton::clicked, mFeatureListView, &QgsFeatureListView::editPreviousFeature );
67+
connect( mFirstFeatureButton, &QToolButton::clicked, mFeatureListView, &QgsFeatureListView::editFirstFeature );
68+
connect( mLastFeatureButton, &QToolButton::clicked, mFeatureListView, &QgsFeatureListView::editLastFeature );
6769

6870
QButtonGroup *buttonGroup = new QButtonGroup( this );
6971
buttonGroup->setExclusive( false );
@@ -423,10 +425,14 @@ void QgsDualView::updateEditSelectionProgress( int progress, int count )
423425
mProgressCount->setText( QStringLiteral( "%1 / %2" ).arg( progress + 1 ).arg( count ) );
424426
mPreviousFeatureButton->setEnabled( progress > 0 );
425427
mNextFeatureButton->setEnabled( progress + 1 < count );
428+
mFirstFeatureButton->setEnabled( progress > 0 );
429+
mLastFeatureButton->setEnabled( progress + 1 < count );
426430
}
427431

428432
void QgsDualView::panOrZoomToFeature( const QgsFeatureIds &featureset )
429433
{
434+
//QgsDebugMsg("hey");
435+
430436
QgsMapCanvas *canvas = mFilterModel->mapCanvas();
431437
if ( canvas )
432438
{

‎src/gui/attributetable/qgsfeaturelistview.cpp

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -264,19 +264,19 @@ void QgsFeatureListView::keyPressEvent( QKeyEvent *event )
264264
switch ( event->key() )
265265
{
266266
case Qt::Key_Up:
267-
editNextOrPreviousFeature( Previous );
267+
editOtherFeature( Previous );
268268
break;
269269

270270
case Qt::Key_Down:
271-
editNextOrPreviousFeature( Next );
271+
editOtherFeature( Next );
272272
break;
273273

274274
default:
275275
QListView::keyPressEvent( event );
276276
}
277277
}
278278

279-
void QgsFeatureListView::editNextOrPreviousFeature( QgsFeatureListView::NextOrPrevious nextOrPrevious )
279+
void QgsFeatureListView::editOtherFeature( QgsFeatureListView::PositionInList positionInList )
280280
{
281281
int currentRow = 0;
282282
if ( 0 != mCurrentEditSelectionModel->selectedIndexes().count() )
@@ -288,29 +288,31 @@ void QgsFeatureListView::editNextOrPreviousFeature( QgsFeatureListView::NextOrPr
288288
QModelIndex newLocalIndex;
289289
QModelIndex newIndex;
290290

291-
switch ( nextOrPrevious )
291+
switch ( positionInList )
292292
{
293+
case First:
294+
newLocalIndex = mModel->index( 0, 0 );
295+
break;
296+
293297
case Previous:
294298
newLocalIndex = mModel->index( currentRow - 1, 0 );
295-
newIndex = mModel->mapToMaster( newLocalIndex );
296-
if ( newIndex.isValid() )
297-
{
298-
setEditSelection( newIndex, QItemSelectionModel::ClearAndSelect );
299-
scrollTo( newLocalIndex );
300-
}
301299
break;
302300

303301
case Next:
304302
newLocalIndex = mModel->index( currentRow + 1, 0 );
305-
newIndex = mModel->mapToMaster( newLocalIndex );
306-
if ( newIndex.isValid() )
307-
{
308-
setEditSelection( newIndex, QItemSelectionModel::ClearAndSelect );
309-
scrollTo( newLocalIndex );
310-
}
303+
break;
304+
305+
case Last:
306+
newLocalIndex = mModel->index( mModel->rowCount() - 1, 0 );
311307
break;
312308
}
313309

310+
newIndex = mModel->mapToMaster( newLocalIndex );
311+
if ( newIndex.isValid() )
312+
{
313+
setEditSelection( newIndex, QItemSelectionModel::ClearAndSelect );
314+
scrollTo( newLocalIndex );
315+
}
314316
}
315317

316318
void QgsFeatureListView::contextMenuEvent( QContextMenuEvent *event )

‎src/gui/attributetable/qgsfeaturelistview.h

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -186,16 +186,30 @@ class GUI_EXPORT QgsFeatureListView : public QListView
186186
void repaintRequested();
187187

188188
/**
189-
* editNextFeature will try to edit next feature in form
189+
* editFirstFeature will try to edit the first feature of the list
190190
* \since QGIS 3.8
191191
*/
192-
void editNextFeature() {editNextOrPreviousFeature( Next );}
192+
void editFirstFeature() {editOtherFeature( First );}
193193

194194
/**
195-
* editPreviousFeature will try to edit previous feature in form
195+
* editNextFeature will try to edit next feature of the list
196196
* \since QGIS 3.8
197197
*/
198-
void editPreviousFeature() {editNextOrPreviousFeature( Previous );}
198+
void editNextFeature() {editOtherFeature( Next );}
199+
200+
/**
201+
* editPreviousFeature will try to edit previous feature of the list
202+
* \since QGIS 3.8
203+
*/
204+
void editPreviousFeature() {editOtherFeature( Previous );}
205+
206+
/**
207+
* editLastFeature will try to edit the last feature of the list
208+
* \since QGIS 3.8
209+
*/
210+
void editLastFeature() {editOtherFeature( Last );}
211+
212+
199213

200214
private slots:
201215
void editSelectionChanged( const QItemSelection &deselected, const QItemSelection &selected );
@@ -211,13 +225,15 @@ class GUI_EXPORT QgsFeatureListView : public QListView
211225
private:
212226
void selectRow( const QModelIndex &index, bool anchor );
213227

214-
enum NextOrPrevious
228+
enum PositionInList
215229
{
230+
First,
216231
Next,
217-
Previous
232+
Previous,
233+
Last
218234
};
219235

220-
void editNextOrPreviousFeature( NextOrPrevious nextOrPrevious );
236+
void editOtherFeature( PositionInList positionInList );
221237

222238

223239
QgsFeatureListModel *mModel = nullptr;

‎src/ui/qgsattributetabledialog.ui

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,10 @@
214214
<property name="checkable">
215215
<bool>true</bool>
216216
</property>
217-
<property name="autoRaise">
217+
<property name="checked">
218218
<bool>true</bool>
219219
</property>
220-
<property name="checked">
220+
<property name="autoRaise">
221221
<bool>true</bool>
222222
</property>
223223
<attribute name="buttonGroup">
@@ -693,35 +693,6 @@
693693
</tabstops>
694694
<resources>
695695
<include location="../../images/images.qrc"/>
696-
<include location="../../images/images.qrc"/>
697-
<include location="../../images/images.qrc"/>
698-
<include location="../../images/images.qrc"/>
699-
<include location="../../images/images.qrc"/>
700-
<include location="../../images/images.qrc"/>
701-
<include location="../../images/images.qrc"/>
702-
<include location="../../images/images.qrc"/>
703-
<include location="../../images/images.qrc"/>
704-
<include location="../../images/images.qrc"/>
705-
<include location="../../images/images.qrc"/>
706-
<include location="../../images/images.qrc"/>
707-
<include location="../../images/images.qrc"/>
708-
<include location="../../images/images.qrc"/>
709-
<include location="../../images/images.qrc"/>
710-
<include location="../../images/images.qrc"/>
711-
<include location="../../images/images.qrc"/>
712-
<include location="../../images/images.qrc"/>
713-
<include location="../../images/images.qrc"/>
714-
<include location="../../images/images.qrc"/>
715-
<include location="../../images/images.qrc"/>
716-
<include location="../../images/images.qrc"/>
717-
<include location="../../images/images.qrc"/>
718-
<include location="../../images/images.qrc"/>
719-
<include location="../../images/images.qrc"/>
720-
<include location="../../images/images.qrc"/>
721-
<include location="../../images/images.qrc"/>
722-
<include location="../../images/images.qrc"/>
723-
<include location="../../images/images.qrc"/>
724-
<include location="../../images/images.qrc"/>
725696
</resources>
726697
<connections>
727698
<connection>

‎src/ui/qgsdualviewbase.ui

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,34 @@
134134
<property name="bottomMargin">
135135
<number>0</number>
136136
</property>
137+
<item>
138+
<widget class="QPushButton" name="mFirstFeatureButton">
139+
<property name="maximumSize">
140+
<size>
141+
<width>24</width>
142+
<height>24</height>
143+
</size>
144+
</property>
145+
<property name="text">
146+
<string/>
147+
</property>
148+
<property name="icon">
149+
<iconset resource="../../images/images.qrc">
150+
<normaloff>:/images/themes/default/mActionDoubleArrowLeft.svg</normaloff>:/images/themes/default/mActionDoubleArrowLeft.svg</iconset>
151+
</property>
152+
<property name="flat">
153+
<bool>true</bool>
154+
</property>
155+
</widget>
156+
</item>
137157
<item>
138158
<widget class="QPushButton" name="mPreviousFeatureButton">
159+
<property name="maximumSize">
160+
<size>
161+
<width>24</width>
162+
<height>24</height>
163+
</size>
164+
</property>
139165
<property name="text">
140166
<string/>
141167
</property>
@@ -241,6 +267,18 @@
241267
</item>
242268
<item>
243269
<widget class="QPushButton" name="mNextFeatureButton">
270+
<property name="sizePolicy">
271+
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
272+
<horstretch>0</horstretch>
273+
<verstretch>0</verstretch>
274+
</sizepolicy>
275+
</property>
276+
<property name="maximumSize">
277+
<size>
278+
<width>24</width>
279+
<height>24</height>
280+
</size>
281+
</property>
244282
<property name="text">
245283
<string/>
246284
</property>
@@ -253,6 +291,26 @@
253291
</property>
254292
</widget>
255293
</item>
294+
<item>
295+
<widget class="QPushButton" name="mLastFeatureButton">
296+
<property name="maximumSize">
297+
<size>
298+
<width>24</width>
299+
<height>24</height>
300+
</size>
301+
</property>
302+
<property name="text">
303+
<string/>
304+
</property>
305+
<property name="icon">
306+
<iconset resource="../../images/images.qrc">
307+
<normaloff>:/images/themes/default/mActionDoubleArrowRight.svg</normaloff>:/images/themes/default/mActionDoubleArrowRight.svg</iconset>
308+
</property>
309+
<property name="flat">
310+
<bool>true</bool>
311+
</property>
312+
</widget>
313+
</item>
256314
</layout>
257315
</widget>
258316
</item>

0 commit comments

Comments
 (0)
Please sign in to comment.