-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add support for deleting variables #180
Conversation
dab055f
to
f3585d3
Compare
damnit/gui/table.py
Outdated
@@ -44,6 +46,10 @@ def __init__(self) -> None: | |||
self._columns_widget.itemChanged.connect(self.item_changed) | |||
self._columns_widget.model().rowsMoved.connect(self.item_moved) | |||
|
|||
self._columns_widget.setContextMenuPolicy(Qt.CustomContextMenu) | |||
self._columns_widget.customContextMenuRequested.connect(self.show_delete_menu) | |||
delete_action = QtWidgets.QAction("Delete") |
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.
delete_action = QtWidgets.QAction("Delete") |
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.
Oops 🙈 Removed in 82a5e55.
Looks good enough to me, since we don't plan to maintain this ui. |
Sure, added a comment in 82a5e55. |
LGTM |
This is mildly cursed because it will reload the database upon deletion. For two reasons: - There are lingering bugs surrounding moving columns after changing the number of variables, and I don't want to deal with that right now. - Laziness My justification is that deleting a variable is something that will (hopefully) occur rarely, and occur when writing the context file for the first time while the database is likely to be empty-ish.
82a5e55
to
7b38c13
Compare
I just realized... what would happen if multiple clients are connected to the same database. The other clients don't know the variable is deleted and may try to access the data. Will it crash? |
Oh dear, that is an excellent point 🤦 I'll make another PR to broadcast a deletion message. |
This is mildly cursed because it will reload the database upon deletion. For two reasons:
My justification is that deleting a variable is something that will (hopefully) occur rarely, and occur when writing the context file for the first time while the database is likely to be empty-ish (so it won't take an obnoxious amount of time to reload). Plus, loading databases isn't too awful with the v1 format.
Another thing I'm unsure about is the location of the
api.delete_variable()
function. I put it inapi.py
because I have vague ideas about having a writable wrapper for a future read-only API (exposed to users through a separate package), but I couldn't think of a nice way to fit that into theVariableData
/RunVariables
classes. I also considered merging it withDamnitDB.delete_variable()
but thenDamnitDB
would come to mean 'database and HDF5 files' while it's currently just 'database'. Not sure how I feel about that.Demo:
Fixes #69.