From 09126ded986d4c37023258d52e39cfbc7167d9da Mon Sep 17 00:00:00 2001 From: Denis Rouzaud Date: Sun, 26 May 2019 22:21:10 -0500 Subject: [PATCH] make flashing independent from panning/zooming in attribte table in attribute editor mode (#29955) --- .../attributetable/qgsdualview.sip.in | 1 - src/gui/attributetable/qgsdualview.cpp | 31 +++++++++++-------- src/gui/attributetable/qgsdualview.h | 3 +- src/ui/qgsdualviewbase.ui | 19 ++++++++++-- 4 files changed, 36 insertions(+), 18 deletions(-) diff --git a/python/gui/auto_generated/attributetable/qgsdualview.sip.in b/python/gui/auto_generated/attributetable/qgsdualview.sip.in index f7a54f707b9..0ec57f62d48 100644 --- a/python/gui/auto_generated/attributetable/qgsdualview.sip.in +++ b/python/gui/auto_generated/attributetable/qgsdualview.sip.in @@ -38,7 +38,6 @@ and the attributes for the currently selected feature are shown in a form. enum FeatureListBrowsingAction { NoAction, - FlashFeature, PanToFeature, ZoomToFeature, }; diff --git a/src/gui/attributetable/qgsdualview.cpp b/src/gui/attributetable/qgsdualview.cpp index f95b8dd2448..fe18fd2a47f 100644 --- a/src/gui/attributetable/qgsdualview.cpp +++ b/src/gui/attributetable/qgsdualview.cpp @@ -83,14 +83,15 @@ QgsDualView::QgsDualView( QWidget *parent ) QButtonGroup *buttonGroup = new QButtonGroup( this ); buttonGroup->setExclusive( false ); - buttonGroup->addButton( mFlashButton, FlashFeature ); buttonGroup->addButton( mAutoPanButton, PanToFeature ); buttonGroup->addButton( mAutoZoomButton, ZoomToFeature ); - FeatureListBrowsingAction action = QgsSettings().enumValue( QStringLiteral( "/qgis/attributeTable/featureListBrowsingAction" ), FlashFeature ); + FeatureListBrowsingAction action = QgsSettings().enumValue( QStringLiteral( "/qgis/attributeTable/featureListBrowsingAction" ), NoAction ); QAbstractButton *bt = buttonGroup->button( static_cast( action ) ); if ( bt ) bt->setChecked( true ); connect( buttonGroup, qgis::overload< QAbstractButton *, bool >::of( &QButtonGroup::buttonToggled ), this, &QgsDualView::panZoomGroupButtonToggled ); + mFlashButton->setChecked( QgsSettings().value( QStringLiteral( "/qgis/attributeTable/featureListHighlightFeature" ), true ).toBool() ); + connect( mFlashButton, &QToolButton::clicked, this, &QgsDualView::flashButtonClicked ); } void QgsDualView::init( QgsVectorLayer *layer, QgsMapCanvas *mapCanvas, const QgsFeatureRequest &request, @@ -452,15 +453,14 @@ void QgsDualView::panOrZoomToFeature( const QgsFeatureIds &featureset ) QTimer::singleShot( 0, this, [ = ]() { canvas->panToFeatureIds( mLayer, featureset, false ); - canvas->flashFeatureIds( mLayer, featureset ); } ); else if ( mAutoZoomButton->isChecked() ) QTimer::singleShot( 0, this, [ = ]() { canvas->zoomToFeatureIds( mLayer, featureset ); - canvas->flashFeatureIds( mLayer, featureset ); } ); - else if ( mFlashButton->isChecked() ) + + if ( mFlashButton->isChecked() ) QTimer::singleShot( 0, this, [ = ]() { canvas->flashFeatureIds( mLayer, featureset ); @@ -474,19 +474,11 @@ void QgsDualView::panZoomGroupButtonToggled( QAbstractButton *button, bool check { QgsSettings().setEnumValue( QStringLiteral( "/qgis/attributeTable/featureListBrowsingAction" ), PanToFeature ); mAutoZoomButton->setChecked( false ); - mFlashButton->setChecked( false ); } else if ( button == mAutoZoomButton && checked ) { QgsSettings().setEnumValue( QStringLiteral( "/qgis/attributeTable/featureListBrowsingAction" ), ZoomToFeature ); mAutoPanButton->setChecked( false ); - mFlashButton->setChecked( false ); - } - else if ( button == mFlashButton && checked ) - { - QgsSettings().setEnumValue( QStringLiteral( "/qgis/attributeTable/featureListBrowsingAction" ), FlashFeature ); - mAutoZoomButton->setChecked( false ); - mAutoPanButton->setChecked( false ); } else { @@ -497,6 +489,18 @@ void QgsDualView::panZoomGroupButtonToggled( QAbstractButton *button, bool check panOrZoomToFeature( mFeatureListView->currentEditSelection() ); } +void QgsDualView::flashButtonClicked( bool clicked ) +{ + QgsSettings().setValue( QStringLiteral( "/qgis/attributeTable/featureListHighlightFeature" ), clicked ); + if ( !clicked ) + return; + + QgsMapCanvas *canvas = mFilterModel->mapCanvas(); + + if ( canvas ) + canvas->flashFeatureIds( mLayer, mFeatureListView->currentEditSelection() ); +} + void QgsDualView::featureListAboutToChangeEditSelection( bool &ok ) { if ( mLayer->isEditable() && !mAttributeForm->save() ) @@ -517,6 +521,7 @@ void QgsDualView::featureListCurrentEditSelectionChanged( const QgsFeature &feat setCurrentEditSelection( featureset ); panOrZoomToFeature( featureset ); + } else { diff --git a/src/gui/attributetable/qgsdualview.h b/src/gui/attributetable/qgsdualview.h index a9605cfbe0a..50b0202d144 100644 --- a/src/gui/attributetable/qgsdualview.h +++ b/src/gui/attributetable/qgsdualview.h @@ -72,7 +72,6 @@ class GUI_EXPORT QgsDualView : public QStackedWidget, private Ui::QgsDualViewBas enum FeatureListBrowsingAction { NoAction = 0, //!< No action is done - FlashFeature, //!< The feature is highlighted with a flash PanToFeature, //!< The map is panned to the center of the feature bounding-box ZoomToFeature, //!< The map is zoomed to contained the feature bounding-box }; @@ -372,6 +371,8 @@ class GUI_EXPORT QgsDualView : public QStackedWidget, private Ui::QgsDualViewBas void panZoomGroupButtonToggled( QAbstractButton *button, bool checked ); + void flashButtonClicked( bool clicked ); + private: /** diff --git a/src/ui/qgsdualviewbase.ui b/src/ui/qgsdualviewbase.ui index 7041f3cdd6d..d510c26d72f 100644 --- a/src/ui/qgsdualviewbase.ui +++ b/src/ui/qgsdualviewbase.ui @@ -132,6 +132,9 @@ + + 1 + 0 @@ -144,9 +147,6 @@ 0 - - 1 - @@ -278,6 +278,19 @@ + + + + Qt::Horizontal + + + + 20 + 20 + + + +