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

FIX: Check Validity of QAbstractTableModel Classes #1122

Merged
merged 3 commits into from
Nov 11, 2024

Conversation

zdomke
Copy link
Contributor

@zdomke zdomke commented Oct 24, 2024

This started with adding basic tests to check the validity of 3 QAbstractTableModel classes:

  • BasePlotAxesModel
  • BasePlotCurvesModel
  • PyDMArchiverTimePlotCurvesModel

I fixed the issues that came up when the models were declared invalid. These fixes include:

  • In flags(), the models check the validity of the given QModelIndex
  • In data() and setData(), returns None instead of an empty QVariant object. This is done because QVariant is not really needed in PyQt like it is in Qt. In some cases where it makes more sense, I replaced the QVariant with empty strings.
    • While this documentation suggests returning an invalid QVariant, it doesn't specify what an invalid QVariant should be
    • This documentation suggests that None is an invalid QVariant, and that is what we should use
    • pytest-qt's qtmodeltester fixture that I used to test the models' validity checks that None is being returned for invalid data() requests, not QVariant

Also added basic docstrings to flags() methods.

Copy link
Collaborator

@jbellister-slac jbellister-slac left a comment

Choose a reason for hiding this comment

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

Thanks!

@YektaY YektaY merged commit 1b3c197 into slaclab:master Nov 11, 2024
19 checks passed
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