mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-15 00:02:52 -04:00
Fix wrong usage of mFeatureSelectionMgr in the abstract class
This commit is contained in:
parent
a54483457c
commit
ebddedd955
@ -75,12 +75,6 @@ Sets the editor ``context``
|
||||
QgsAttributeEditorContext editorContext( ) const;
|
||||
%Docstring
|
||||
Returns the attribute editor context.
|
||||
%End
|
||||
|
||||
QgsIFeatureSelectionManager *featureSelectionManager();
|
||||
%Docstring
|
||||
The feature selection manager is responsible for the selected features
|
||||
which are currently being edited.
|
||||
%End
|
||||
|
||||
bool showLabel() const;
|
||||
@ -168,11 +162,6 @@ Adds a new feature with given ``geometry``
|
||||
void deleteFeature( QgsFeatureId fid = QgsFeatureId() );
|
||||
%Docstring
|
||||
Delete a feature with given ``fid``
|
||||
%End
|
||||
|
||||
void deleteSelectedFeatures();
|
||||
%Docstring
|
||||
Deletes the currently selected features
|
||||
%End
|
||||
|
||||
void linkFeature();
|
||||
@ -190,19 +179,14 @@ Called when the link feature dialog is confirmed by the user
|
||||
Unlinks a feature with given ``fid``
|
||||
%End
|
||||
|
||||
void unlinkSelectedFeatures();
|
||||
%Docstring
|
||||
Unlinks the selected features from the relation
|
||||
%End
|
||||
|
||||
void duplicateFeature();
|
||||
void duplicateFeature( const QgsFeatureId &fid );
|
||||
%Docstring
|
||||
Duplicates a feature
|
||||
%End
|
||||
|
||||
void zoomToSelectedFeatures();
|
||||
void duplicateFeatures( const QgsFeatureIds &fids );
|
||||
%Docstring
|
||||
Zooms to the selected features
|
||||
Duplicates features
|
||||
%End
|
||||
|
||||
protected:
|
||||
|
@ -64,6 +64,12 @@ Define the view mode for the dual view
|
||||
QgsDualView::ViewMode viewMode();
|
||||
%Docstring
|
||||
Gets the view mode for the dual view
|
||||
%End
|
||||
|
||||
QgsIFeatureSelectionManager *featureSelectionManager();
|
||||
%Docstring
|
||||
The feature selection manager is responsible for the selected features
|
||||
which are currently being edited.
|
||||
%End
|
||||
|
||||
void setEditorContext( const QgsAttributeEditorContext &context );
|
||||
@ -84,6 +90,36 @@ Defines the buttons which are shown
|
||||
Buttons visibleButtons() const;
|
||||
%Docstring
|
||||
Returns the buttons which are shown
|
||||
%End
|
||||
|
||||
void duplicateFeature() /Deprecated/;
|
||||
%Docstring
|
||||
Duplicates a feature
|
||||
|
||||
.. deprecated:: QGIS 3.18
|
||||
use duplicateSelectedFeatures() instead
|
||||
%End
|
||||
|
||||
void duplicateSelectedFeatures();
|
||||
%Docstring
|
||||
Duplicates the selected features
|
||||
|
||||
.. versionadded:: 3.18
|
||||
%End
|
||||
|
||||
void unlinkSelectedFeatures();
|
||||
%Docstring
|
||||
Unlinks the selected features from the relation
|
||||
%End
|
||||
|
||||
void deleteSelectedFeatures();
|
||||
%Docstring
|
||||
Deletes the currently selected features
|
||||
%End
|
||||
|
||||
void zoomToSelectedFeatures();
|
||||
%Docstring
|
||||
Zooms to the selected features
|
||||
%End
|
||||
|
||||
virtual QVariantMap config() const;
|
||||
|
@ -116,11 +116,6 @@ QgsAttributeEditorContext QgsAbstractRelationEditorWidget::editorContext() const
|
||||
return mEditorContext;
|
||||
}
|
||||
|
||||
QgsIFeatureSelectionManager *QgsAbstractRelationEditorWidget::featureSelectionManager()
|
||||
{
|
||||
return mFeatureSelectionMgr;
|
||||
}
|
||||
|
||||
void QgsAbstractRelationEditorWidget::setFeature( const QgsFeature &feature, bool update )
|
||||
{
|
||||
mFeature = feature;
|
||||
@ -277,12 +272,6 @@ void QgsAbstractRelationEditorWidget::deleteFeature( const QgsFeatureId fid )
|
||||
deleteFeatures( QgsFeatureIds() << fid );
|
||||
}
|
||||
|
||||
void QgsAbstractRelationEditorWidget::deleteSelectedFeatures()
|
||||
{
|
||||
QgsFeatureIds selectedFids = mFeatureSelectionMgr->selectedFeatureIds();
|
||||
deleteFeatures( selectedFids );
|
||||
}
|
||||
|
||||
void QgsAbstractRelationEditorWidget::deleteFeatures( const QgsFeatureIds &fids )
|
||||
{
|
||||
bool deleteFeatures = true;
|
||||
@ -495,11 +484,6 @@ void QgsAbstractRelationEditorWidget::unlinkFeature( const QgsFeatureId fid )
|
||||
unlinkFeatures( QgsFeatureIds() << fid );
|
||||
}
|
||||
|
||||
void QgsAbstractRelationEditorWidget::unlinkSelectedFeatures()
|
||||
{
|
||||
unlinkFeatures( mFeatureSelectionMgr->selectedFeatureIds() );
|
||||
}
|
||||
|
||||
void QgsAbstractRelationEditorWidget::unlinkFeatures( const QgsFeatureIds &fids )
|
||||
{
|
||||
if ( mNmRelation.isValid() )
|
||||
@ -567,11 +551,16 @@ void QgsAbstractRelationEditorWidget::unlinkFeatures( const QgsFeatureIds &fids
|
||||
}
|
||||
}
|
||||
|
||||
void QgsAbstractRelationEditorWidget::duplicateFeature()
|
||||
void QgsAbstractRelationEditorWidget::duplicateFeature( const QgsFeatureId &fid )
|
||||
{
|
||||
duplicateFeatures( QgsFeatureIds() << fid );
|
||||
}
|
||||
|
||||
void QgsAbstractRelationEditorWidget::duplicateFeatures( const QgsFeatureIds &fids )
|
||||
{
|
||||
QgsVectorLayer *layer = mRelation.referencingLayer();
|
||||
|
||||
QgsFeatureIterator fit = layer->getFeatures( QgsFeatureRequest().setFilterFids( mFeatureSelectionMgr->selectedFeatureIds() ) );
|
||||
QgsFeatureIterator fit = layer->getFeatures( QgsFeatureRequest().setFilterFids( fids ) );
|
||||
QgsFeature f;
|
||||
while ( fit.nextFeature( f ) )
|
||||
{
|
||||
@ -580,18 +569,6 @@ void QgsAbstractRelationEditorWidget::duplicateFeature()
|
||||
}
|
||||
}
|
||||
|
||||
void QgsAbstractRelationEditorWidget::zoomToSelectedFeatures()
|
||||
{
|
||||
QgsMapCanvas *c = mEditorContext.mapCanvas();
|
||||
if ( !c )
|
||||
return;
|
||||
|
||||
c->zoomToFeatureIds(
|
||||
mNmRelation.isValid() ? mNmRelation.referencedLayer() : mRelation.referencingLayer(),
|
||||
mFeatureSelectionMgr->selectedFeatureIds()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include "qgscollapsiblegroupbox.h"
|
||||
#include "qgsdualview.h"
|
||||
#include "qgsrelation.h"
|
||||
#include "qgsvectorlayerselectionmanager.h"
|
||||
#include "qgis_sip.h"
|
||||
#include "qgis_gui.h"
|
||||
|
||||
@ -109,12 +108,6 @@ class GUI_EXPORT QgsAbstractRelationEditorWidget : public QWidget
|
||||
*/
|
||||
QgsAttributeEditorContext editorContext( ) const;
|
||||
|
||||
/**
|
||||
* The feature selection manager is responsible for the selected features
|
||||
* which are currently being edited.
|
||||
*/
|
||||
QgsIFeatureSelectionManager *featureSelectionManager();
|
||||
|
||||
/**
|
||||
* Defines if a title label should be shown for this widget.
|
||||
*/
|
||||
@ -202,11 +195,6 @@ class GUI_EXPORT QgsAbstractRelationEditorWidget : public QWidget
|
||||
*/
|
||||
void deleteFeature( QgsFeatureId fid = QgsFeatureId() );
|
||||
|
||||
/**
|
||||
* Deletes the currently selected features
|
||||
*/
|
||||
void deleteSelectedFeatures();
|
||||
|
||||
/**
|
||||
* Links a new feature to the relation
|
||||
*/
|
||||
@ -222,24 +210,18 @@ class GUI_EXPORT QgsAbstractRelationEditorWidget : public QWidget
|
||||
*/
|
||||
void unlinkFeature( QgsFeatureId fid = QgsFeatureId() );
|
||||
|
||||
/**
|
||||
* Unlinks the selected features from the relation
|
||||
*/
|
||||
void unlinkSelectedFeatures();
|
||||
|
||||
/**
|
||||
* Duplicates a feature
|
||||
*/
|
||||
void duplicateFeature();
|
||||
void duplicateFeature( const QgsFeatureId &fid );
|
||||
|
||||
/**
|
||||
* Zooms to the selected features
|
||||
* Duplicates features
|
||||
*/
|
||||
void zoomToSelectedFeatures();
|
||||
void duplicateFeatures( const QgsFeatureIds &fids );
|
||||
|
||||
protected:
|
||||
|
||||
QgsVectorLayerSelectionManager *mFeatureSelectionMgr = nullptr;
|
||||
QgsAttributeEditorContext mEditorContext;
|
||||
QgsRelation mRelation;
|
||||
QgsRelation mNmRelation;
|
||||
|
@ -213,7 +213,7 @@ QgsRelationEditorWidget::QgsRelationEditorWidget( const QVariantMap &config, QWi
|
||||
connect( mSaveEditsButton, &QAbstractButton::clicked, this, &QgsRelationEditorWidget::saveEdits );
|
||||
connect( mAddFeatureButton, &QAbstractButton::clicked, this, [this]() { addFeature(); } );
|
||||
connect( mAddFeatureGeometryButton, &QAbstractButton::clicked, this, &QgsRelationEditorWidget::addFeatureGeometry );
|
||||
connect( mDuplicateFeatureButton, &QAbstractButton::clicked, this, &QgsRelationEditorWidget::duplicateFeature );
|
||||
connect( mDuplicateFeatureButton, &QAbstractButton::clicked, this, &QgsRelationEditorWidget::duplicateSelectedFeatures );
|
||||
connect( mDeleteFeatureButton, &QAbstractButton::clicked, this, &QgsRelationEditorWidget::deleteSelectedFeatures );
|
||||
connect( mLinkFeatureButton, &QAbstractButton::clicked, this, &QgsRelationEditorWidget::linkFeature );
|
||||
connect( mUnlinkFeatureButton, &QAbstractButton::clicked, this, &QgsRelationEditorWidget::unlinkSelectedFeatures );
|
||||
@ -606,6 +606,43 @@ void QgsRelationEditorWidget::afterSetRelations()
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
QgsIFeatureSelectionManager *QgsRelationEditorWidget::featureSelectionManager()
|
||||
{
|
||||
return mFeatureSelectionMgr;
|
||||
}
|
||||
|
||||
void QgsRelationEditorWidget::unlinkSelectedFeatures()
|
||||
{
|
||||
unlinkFeatures( mFeatureSelectionMgr->selectedFeatureIds() );
|
||||
}
|
||||
|
||||
void QgsRelationEditorWidget::duplicateFeature()
|
||||
{
|
||||
duplicateFeatures( mFeatureSelectionMgr->selectedFeatureIds() );
|
||||
}
|
||||
|
||||
void QgsRelationEditorWidget::duplicateSelectedFeatures()
|
||||
{
|
||||
duplicateFeatures( mFeatureSelectionMgr->selectedFeatureIds() );
|
||||
}
|
||||
|
||||
void QgsRelationEditorWidget::deleteSelectedFeatures()
|
||||
{
|
||||
QgsFeatureIds selectedFids = mFeatureSelectionMgr->selectedFeatureIds();
|
||||
deleteFeatures( selectedFids );
|
||||
}
|
||||
|
||||
void QgsRelationEditorWidget::zoomToSelectedFeatures()
|
||||
{
|
||||
QgsMapCanvas *c = mEditorContext.mapCanvas();
|
||||
if ( !c )
|
||||
return;
|
||||
|
||||
c->zoomToFeatureIds(
|
||||
mNmRelation.isValid() ? mNmRelation.referencedLayer() : mRelation.referencingLayer(),
|
||||
mFeatureSelectionMgr->selectedFeatureIds()
|
||||
);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -125,6 +125,12 @@ class GUI_EXPORT QgsRelationEditorWidget : public QgsAbstractRelationEditorWidge
|
||||
//! Gets the view mode for the dual view
|
||||
QgsDualView::ViewMode viewMode() {return mViewMode;}
|
||||
|
||||
/**
|
||||
* The feature selection manager is responsible for the selected features
|
||||
* which are currently being edited.
|
||||
*/
|
||||
QgsIFeatureSelectionManager *featureSelectionManager();
|
||||
|
||||
/**
|
||||
* Sets the editor \a context
|
||||
* \note if context cadDockWidget is null, it won't be possible to digitize
|
||||
@ -142,6 +148,33 @@ class GUI_EXPORT QgsRelationEditorWidget : public QgsAbstractRelationEditorWidge
|
||||
*/
|
||||
Buttons visibleButtons() const;
|
||||
|
||||
/**
|
||||
* Duplicates a feature
|
||||
* \deprecated since QGIS 3.18, use duplicateSelectedFeatures() instead
|
||||
*/
|
||||
Q_DECL_DEPRECATED void duplicateFeature() SIP_DEPRECATED;
|
||||
|
||||
/**
|
||||
* Duplicates the selected features
|
||||
* \since QGIS 3.18
|
||||
*/
|
||||
void duplicateSelectedFeatures();
|
||||
|
||||
/**
|
||||
* Unlinks the selected features from the relation
|
||||
*/
|
||||
void unlinkSelectedFeatures();
|
||||
|
||||
/**
|
||||
* Deletes the currently selected features
|
||||
*/
|
||||
void deleteSelectedFeatures();
|
||||
|
||||
/**
|
||||
* Zooms to the selected features
|
||||
*/
|
||||
void zoomToSelectedFeatures();
|
||||
|
||||
/**
|
||||
* Returns the current configuration
|
||||
*/
|
||||
@ -197,6 +230,7 @@ class GUI_EXPORT QgsRelationEditorWidget : public QgsAbstractRelationEditorWidge
|
||||
QGridLayout *mRelationLayout = nullptr;
|
||||
QObjectUniquePtr<QgsMapToolDigitizeFeature> mMapToolDigitize;
|
||||
QButtonGroup *mViewModeButtonGroup = nullptr;
|
||||
QgsVectorLayerSelectionManager *mFeatureSelectionMgr = nullptr;
|
||||
|
||||
Buttons mButtonsVisibility = Button::AllButtons;
|
||||
bool mVisible = true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user