Skip to content
Permalink
Browse files

Merge pull request #38658 from suricactus/37847_scroll_to_f

FIX 37847 New feature is hidden when created from attribute table
  • Loading branch information
signedav committed Sep 10, 2020
2 parents 969f9f9 + 4257332 commit b5178d98537613a5110366e9bcae49d96e9cd9ad
@@ -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() );
}
}

@@ -314,4 +314,9 @@ void QgsFeatureAction::onFeatureSaved( const QgsFeature &feature )
}
}

QgsFeature QgsFeatureAction::feature() const
{
return mFeature ? *mFeature : QgsFeature();
}

QHash<QgsVectorLayer *, QgsAttributeMap> QgsFeatureAction::sLastUsedValues;
@@ -61,6 +61,11 @@ class APP_EXPORT QgsFeatureAction : public QAction
*/
void setForceSuppressFormPopup( bool force );

/**
* Returns the added feature or invalid feature in case addFeature() was not successful.
*/
QgsFeature feature() const;

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( modelIdx ) ) );
}

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 b5178d9

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