mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-27 00:33:48 -05:00
[node editor] Always show node editor panel upon activating the node tool
This commit is contained in:
parent
49096431bc
commit
88452637c9
@ -74,7 +74,7 @@ QgsVertexEditorModel::QgsVertexEditorModel( QgsVectorLayer *layer, QgsSelectedFe
|
||||
|
||||
int QgsVertexEditorModel::rowCount( const QModelIndex &parent ) const
|
||||
{
|
||||
if ( parent.isValid() )
|
||||
if ( parent.isValid() || !mSelectedFeature )
|
||||
return 0;
|
||||
|
||||
return mSelectedFeature->vertexMap().count();
|
||||
@ -88,7 +88,7 @@ int QgsVertexEditorModel::columnCount( const QModelIndex &parent ) const
|
||||
|
||||
QVariant QgsVertexEditorModel::data( const QModelIndex &index, int role ) const
|
||||
{
|
||||
if ( !index.isValid() ||
|
||||
if ( !index.isValid() || !mSelectedFeature ||
|
||||
( role != Qt::DisplayRole && role != Qt::EditRole && role != MIN_RADIUS_ROLE && role != Qt::FontRole ) )
|
||||
return QVariant();
|
||||
|
||||
@ -206,7 +206,7 @@ bool QgsVertexEditorModel::setData( const QModelIndex &index, const QVariant &va
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ( index.row() >= mSelectedFeature->vertexMap().count() )
|
||||
if ( !mSelectedFeature || index.row() >= mSelectedFeature->vertexMap().count() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -270,7 +270,7 @@ Qt::ItemFlags QgsVertexEditorModel::flags( const QModelIndex &index ) const
|
||||
|
||||
bool QgsVertexEditorModel::calcR( int row, double &r, double &minRadius ) const
|
||||
{
|
||||
if ( row <= 0 || row >= mSelectedFeature->vertexMap().count() - 1 )
|
||||
if ( row <= 0 || !mSelectedFeature || row >= mSelectedFeature->vertexMap().count() - 1 )
|
||||
return false;
|
||||
|
||||
const QgsVertexEntry *entry = mSelectedFeature->vertexMap().at( row );
|
||||
@ -333,7 +333,7 @@ void QgsVertexEditor::updateEditor( QgsVectorLayer *layer, QgsSelectedFeature *s
|
||||
|
||||
void QgsVertexEditor::updateTableSelection()
|
||||
{
|
||||
if ( mUpdatingVertexSelection )
|
||||
if ( !mSelectedFeature || mUpdatingVertexSelection )
|
||||
return;
|
||||
|
||||
mUpdatingTableSelection = true;
|
||||
@ -360,7 +360,7 @@ void QgsVertexEditor::updateTableSelection()
|
||||
|
||||
void QgsVertexEditor::updateVertexSelection( const QItemSelection &selected, const QItemSelection & )
|
||||
{
|
||||
if ( mUpdatingTableSelection )
|
||||
if ( !mSelectedFeature || mUpdatingTableSelection )
|
||||
return;
|
||||
|
||||
mUpdatingVertexSelection = true;
|
||||
|
@ -282,6 +282,15 @@ QgsVertexTool::~QgsVertexTool()
|
||||
delete mEndpointMarker;
|
||||
}
|
||||
|
||||
void QgsVertexTool::activate()
|
||||
{
|
||||
if ( QgisApp::instance() )
|
||||
{
|
||||
showVertexEditor();
|
||||
}
|
||||
QgsMapToolAdvancedDigitizing::activate();
|
||||
}
|
||||
|
||||
void QgsVertexTool::deactivate()
|
||||
{
|
||||
setHighlightedVertices( QList<Vertex>() );
|
||||
@ -1047,20 +1056,20 @@ void QgsVertexTool::onCachedGeometryDeleted( QgsFeatureId fid )
|
||||
void QgsVertexTool::showVertexEditor() //#spellok
|
||||
{
|
||||
QgsPointLocator::Match m = mLastMouseMoveMatch;
|
||||
if ( !m.isValid() || !m.layer() )
|
||||
return;
|
||||
|
||||
mSelectedFeature.reset( new QgsSelectedFeature( m.featureId(), m.layer(), mCanvas ) );
|
||||
for ( int i = 0; i < mSelectedVertices.length(); ++i )
|
||||
if ( m.isValid() || m.layer() )
|
||||
{
|
||||
if ( mSelectedVertices.at( i ).layer == m.layer() && mSelectedVertices.at( i ).fid == m.featureId() )
|
||||
mSelectedFeature.reset( new QgsSelectedFeature( m.featureId(), m.layer(), mCanvas ) );
|
||||
for ( int i = 0; i < mSelectedVertices.length(); ++i )
|
||||
{
|
||||
mSelectedFeature->selectVertex( mSelectedVertices.at( i ).vertexId );
|
||||
if ( mSelectedVertices.at( i ).layer == m.layer() && mSelectedVertices.at( i ).fid == m.featureId() )
|
||||
{
|
||||
mSelectedFeature->selectVertex( mSelectedVertices.at( i ).vertexId );
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( !mVertexEditor )
|
||||
{
|
||||
mVertexEditor.reset( new QgsVertexEditor( m.layer(), mSelectedFeature.get(), mCanvas ) );
|
||||
mVertexEditor.reset( new QgsVertexEditor( m.layer() ? m.layer() : currentVectorLayer(), mSelectedFeature ? mSelectedFeature.get() : nullptr, mCanvas ) );
|
||||
QgisApp::instance()->addDockWidget( Qt::LeftDockWidgetArea, mVertexEditor.get() );
|
||||
connect( mVertexEditor.get(), &QgsVertexEditor::deleteSelectedRequested, this, &QgsVertexTool::deleteVertexEditorSelection );
|
||||
connect( mVertexEditor.get(), &QgsVertexEditor::editorClosed, this, &QgsVertexTool::cleanupVertexEditor );
|
||||
@ -1070,7 +1079,10 @@ void QgsVertexTool::showVertexEditor() //#spellok
|
||||
mVertexEditor->updateEditor( m.layer(), mSelectedFeature.get() );
|
||||
}
|
||||
|
||||
connect( mSelectedFeature->layer(), &QgsVectorLayer::featureDeleted, this, &QgsVertexTool::cleanEditor );
|
||||
if ( mSelectedFeature )
|
||||
{
|
||||
connect( mSelectedFeature->layer(), &QgsVectorLayer::featureDeleted, this, &QgsVertexTool::cleanEditor );
|
||||
}
|
||||
}
|
||||
|
||||
void QgsVertexTool::cleanupVertexEditor()
|
||||
|
@ -85,12 +85,17 @@ class APP_EXPORT QgsVertexTool : public QgsMapToolAdvancedDigitizing
|
||||
//! Start addition of a new vertex on double-click
|
||||
void canvasDoubleClickEvent( QgsMapMouseEvent *e ) override;
|
||||
|
||||
void activate() override;
|
||||
|
||||
void deactivate() override;
|
||||
|
||||
void keyPressEvent( QKeyEvent *e ) override;
|
||||
|
||||
QgsGeometry cachedGeometry( const QgsVectorLayer *layer, QgsFeatureId fid );
|
||||
|
||||
//! Toggle the vertex editor
|
||||
void showVertexEditor(); //#spellok
|
||||
|
||||
private slots:
|
||||
//! update geometry of our feature
|
||||
void onCachedGeometryChanged( QgsFeatureId fid, const QgsGeometry &geom );
|
||||
@ -99,8 +104,6 @@ class APP_EXPORT QgsVertexTool : public QgsMapToolAdvancedDigitizing
|
||||
|
||||
void clearGeometryCache();
|
||||
|
||||
void showVertexEditor(); //#spellok
|
||||
|
||||
void deleteVertexEditorSelection();
|
||||
|
||||
void validationErrorFound( const QgsGeometry::Error &e );
|
||||
|
Loading…
x
Reference in New Issue
Block a user