Skip to content
Permalink
Browse files

FIX 37847 New feature is hidden when created from attribute table

  • Loading branch information
suricactus committed Sep 9, 2020
1 parent a51c201 commit 3f678970e21591bdfe6de6c48b77609e4671ffb2
@@ -623,6 +623,7 @@ void QgsAttributeTableDialog::mActionAddFeatureViaAttributeTable_triggered()
if ( action.addFeature() )
{
masterModel->reload( masterModel->index( 0, 0 ), masterModel->index( masterModel->rowCount() - 1, masterModel->columnCount() - 1 ) );
mMainView->setCurrentEditSelection( QgsFeatureIds() << action.feature()->id() );
}
}

@@ -643,6 +644,7 @@ void QgsAttributeTableDialog::mActionAddFeatureViaAttributeForm_triggered()
if ( action.addFeature() )
{
masterModel->reload( masterModel->index( 0, 0 ), masterModel->index( masterModel->rowCount() - 1, masterModel->columnCount() - 1 ) );
mMainView->setCurrentEditSelection( QgsFeatureIds() << action.feature()->id() );
}
}

@@ -61,6 +61,12 @@ class APP_EXPORT QgsFeatureAction : public QAction
*/
void setForceSuppressFormPopup( bool force );

/**
* Returns the current feature. It might be nullptr feature, so it's safe to use this method only
* right after`addFeature()` returned true.
*/
QgsFeature *feature() const { return mFeature; }

signals:

/**
@@ -189,18 +189,27 @@ void QgsFeatureListView::selectAll()
void QgsFeatureListView::setEditSelection( const QgsFeatureIds &fids )
{
QItemSelection selection;
QModelIndex firstModelIdx;

const auto constFids = fids;
for ( QgsFeatureId fid : constFids )
{
selection.append( QItemSelectionRange( mModel->mapToMaster( mModel->fidToIdx( fid ) ) ) );
QModelIndex modelIdx = mModel->fidToIdx( fid );

if ( ! firstModelIdx.isValid() )
firstModelIdx = modelIdx;

selection.append( QItemSelectionRange( mModel->mapToMaster( firstModelIdx ) ) );
}

bool ok = true;
emit aboutToChangeEditSelection( ok );

if ( ok )
{
mCurrentEditSelectionModel->select( selection, QItemSelectionModel::ClearAndSelect );
scrollTo( firstModelIdx );
}
}

void QgsFeatureListView::setEditSelection( const QModelIndex &index, QItemSelectionModel::SelectionFlags command )
@@ -212,7 +221,10 @@ void QgsFeatureListView::setEditSelection( const QModelIndex &index, QItemSelect
Q_ASSERT( index.model() == mModel->masterModel() || !index.isValid() );

if ( ok )
{
mCurrentEditSelectionModel->select( index, command );
scrollTo( index );
}
}

void QgsFeatureListView::repaintRequested( const QModelIndexList &indexes )

0 comments on commit 3f67897

Please sign in to comment.
You can’t perform that action at this time.