Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Attribute Table after field calculation: fixes #17312 #5438

Merged

Conversation

luipir
Copy link
Contributor

@luipir luipir commented Oct 24, 2017

Description

The attribute table is not updated because listener of endEditCommand does no more reload masterModel to avoid change row postion during editing.
This patch reload masterModel explicitly as done in other part of the same code.
Port to 3.x of 2.18 PR #5433

Checklist

Reviewing is a process done by project maintainers, mostly on a volunteer basis. We try to keep the overhead as small as possible and appreciate if you help us to do so by completing the following items. Feel free to ask in a comment if you have troubles with any of them.

  • Commit messages are descriptive and explain the rationale for changes
  • Commits which fix bugs include fixes #11111 in the commit message next to the description
  • Commits which add new features are tagged with [FEATURE] in the commit message
  • Commits which change the UI or existing user workflows are tagged with [needs-docs] in the commit message and containt sufficient information in the commit message to be documented
  • I have read the QGIS Coding Standards and this PR complies with them
  • This PR passes all existing unit tests (test results will be reported by travis-ci after opening this PR)
  • New unit tests have been added for core changes
  • I have run the scripts/prepare-commit.sh script before each commit

@luipir
Copy link
Contributor Author

luipir commented Oct 24, 2017

I can't find a way to test it. I don't find a way to get the value of the QgsAttributeTableView at a specified index other than getting the value from masterModel.
But masterModel is not aligned with the view if the reload is not executed. So I need to test the difference among the model and the view.

somethig like

  // run length calculation
  std::unique_ptr< QgsAttributeTableDialog > dlg( new QgsAttributeTableDialog( tempLayer.get() ) );
  dlg->mMainView->setView( QgsDualView::AttributeTable );

  tempLayer->startEditing();
  dlg->runFieldCalculation( tempLayer.get(), QStringLiteral( "col1" ), QStringLiteral( "$length" ) );
  // before commit chage check if masterModel has been update and related attribute table view
  QSettings s;
  s.setValue( QStringLiteral( "/qgis/attributeTableBehavior" ), QgsAttributeTableFilterModel::ShowAll );
  double expected = 26932.156;
  QModelIndex index = dlg->mMainView->tableView()->model()->index( 0, 1 );
  QVERIFY( index.isValid() );
  QGSCOMPARENEAR( index.data().toDouble(), expected, 0.001 );

@elpaso elpaso changed the title Update Attrribute Table after field calculation: fixes #17312 Update Attribute Table after field calculation: fixes #17312 Oct 24, 2017
@elpaso elpaso requested review from elpaso and removed request for elpaso October 27, 2017 16:06
@elpaso
Copy link
Contributor

elpaso commented Oct 31, 2017

@m-kuhn I see you merged the 2.18 backport, can we merge this for master too? (I didn't review)

@m-kuhn m-kuhn merged commit 192d6f9 into qgis:master Oct 31, 2017
@m-kuhn
Copy link
Member

m-kuhn commented Oct 31, 2017

Yes, thanks

@elpaso elpaso deleted the issue_17312_refreshAttrAfterCalc-3.x branch October 31, 2017 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants