make flashing independent from panning/zooming in attribte table in attribute editor mode (#29955)

This commit is contained in:
Denis Rouzaud 2019-05-26 22:21:10 -05:00 committed by GitHub
parent 5ef63dfb45
commit 09126ded98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 18 deletions

View File

@ -38,7 +38,6 @@ and the attributes for the currently selected feature are shown in a form.
enum FeatureListBrowsingAction
{
NoAction,
FlashFeature,
PanToFeature,
ZoomToFeature,
};

View File

@ -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<int>( 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
{

View File

@ -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:
/**

View File

@ -132,6 +132,9 @@
</sizepolicy>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>1</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
@ -144,9 +147,6 @@
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>1</number>
</property>
<item>
<widget class="QToolButton" name="mFirstFeatureButton">
<property name="maximumSize">
@ -278,6 +278,19 @@
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="mAutoPanButton">
<property name="toolTip">