-
Notifications
You must be signed in to change notification settings - Fork 269
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
refactor: Use enum type as switch argument in *TableModel #166
Conversation
aeb11d3
to
dae033e
Compare
dae033e
to
d4508f1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK.
It's not clear to me if data()
implementation should check for out of bounds. I think Qt views and proxy model behave correctly by querying data inside columnCount()
and rowCount()
.
As follow up:
- move
AddressTableModel::columns
member topriv
instance - drop
section < columns.size()
check inAddressTableModel::headerData
At least, these changes do not affect the current behavior, right? |
@jonasschnelli Maybe tag this pr with |
d4508f1
to
1d5d832
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 1d5d832, tested on macOS 11.1 Qt 5.15.2
This refactor brings a safer switch
statement design to the address, ban, peer, and transaction table models. It also brings us in accordance with the switch
design recommendation included in developer-notes.md.
The ability to leverage the -Wswitch
compiler warning, as mentioned in the OP, is another benefit of this refactor. An example of the benefit this brings can be shown by considering a scenario where a new Address type is introduced, and the author forgets to update the code to consider the new type. In such a scenario, the compiler will warn about this, thus preventing errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 1d5d832, tested on Ubuntu 20.04 Qt 5.12.8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code review ACK 1d5d832.
No problem. Changed it to the top PR commit. |
This PR makes code more maintainable by leveraging
-Wswitch
compiler warnings.Only the
RecentRequestsTableModel
is not refactored, because itsenum ColumnIndex
contains additionalNUMBER_OF_COLUMNS
value.No behavior change.