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 #5433

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.

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

My future plan are:

  1. Port to 3.0 the same fix
  2. add test in 3.0 and backport to 3.0
    I suggest to merge the fix to have a fix for a working qgis version.

@luipir
Copy link
Contributor Author

luipir commented Oct 24, 2017

The actual test: testqgsattributetable.cpp does not cover this regression because does not control the value rendered in the QgsAttributeTableView
https://github.com/qgis/QGIS/blob/release-2_18/tests/src/app/testqgsattributetable.cpp

In this moment I'm not able to find the way to read the cell view content to compare with the expected an value.

// refresh table with updated values
// fixes https://issues.qgis.org/issues/17312
QgsAttributeTableModel* masterModel = mMainView->masterModel();
masterModel->reload( masterModel->index( 0, 0 ), masterModel->index( masterModel->rowCount() - 1, masterModel->columnCount() - 1 ) );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you kill the return above and put this in an else?
Is it possible to only reload the affected column (I guess this reloads everything)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, that's was my first solution, but I wasn't able to find the correct api to get the involved column from its name.
my first solution was gettin the column with:
int modelColumn = masterModel->fieldIdx( fieldindex );
Is it the correct way?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

    /**                                                                         
     * get field index from column                                              
     */                                                                         
    int fieldIdx( int col ) const;                                              
                                                                                
    /**                                                                         
     * get column from field index                                              
     */                                                                         
    int fieldCol( int idx ) const;

@luipir
Copy link
Contributor Author

luipir commented Oct 24, 2017

failed PyQgsComposerPicture not related with this PR!

@luipir
Copy link
Contributor Author

luipir commented Oct 24, 2017

@m-kuhn reloaded only related column get using masterModel->fieldCol()

@m-kuhn m-kuhn merged commit adeb992 into qgis:release-2_18 Oct 24, 2017
@m-kuhn
Copy link
Member

m-kuhn commented Oct 24, 2017

Thanks @luipir

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.

None yet

2 participants