Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
make flashing independent from panning/zooming in attribte table in a…
…ttribute editor mode (#29955)
  • Loading branch information
3nids committed May 27, 2019
1 parent 5ef63df commit 09126de
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 18 deletions.
Expand Up @@ -38,7 +38,6 @@ and the attributes for the currently selected feature are shown in a form.
enum FeatureListBrowsingAction
{
NoAction,
FlashFeature,
PanToFeature,
ZoomToFeature,
};
Expand Down
31 changes: 18 additions & 13 deletions src/gui/attributetable/qgsdualview.cpp
Expand Up @@ -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,
Expand Down Expand Up @@ -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 );
Expand All @@ -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
{
Expand All @@ -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() )
Expand All @@ -517,6 +521,7 @@ void QgsDualView::featureListCurrentEditSelectionChanged( const QgsFeature &feat
setCurrentEditSelection( featureset );

panOrZoomToFeature( featureset );

}
else
{
Expand Down
3 changes: 2 additions & 1 deletion src/gui/attributetable/qgsdualview.h
Expand Up @@ -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
};
Expand Down Expand Up @@ -372,6 +371,8 @@ class GUI_EXPORT QgsDualView : public QStackedWidget, private Ui::QgsDualViewBas

void panZoomGroupButtonToggled( QAbstractButton *button, bool checked );

void flashButtonClicked( bool clicked );

private:

/**
Expand Down
19 changes: 16 additions & 3 deletions src/ui/qgsdualviewbase.ui
Expand Up @@ -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>
Expand All @@ -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">
Expand Down Expand Up @@ -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">
Expand Down

0 comments on commit 09126de

Please sign in to comment.