Skip to content

Commit

Permalink
OWFile: Add a button for resetting domain editor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
janezd committed Mar 2, 2019
1 parent c28c16c commit 707a449
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Orange/widgets/data/owfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ def __init__(self):
callback=lambda: self.browse_file(True), autoDefault=False)
gui.rubber(box)

gui.button(
box, self, "Reset", callback=self.reset_domain_edit)
self.apply_button = gui.button(
box, self, "Apply", callback=self.apply_domain_edit)
self.apply_button.setEnabled(False)
Expand Down Expand Up @@ -440,6 +442,10 @@ def retrieveSpecificSettings(self):
if hasattr(self.current_context, "modified_variables"):
self.variables[:] = self.current_context.modified_variables

def reset_domain_edit(self):
self.domain_editor.reset_domain()
self.apply_domain_edit()

def apply_domain_edit(self):
if self.data is None:
table = None
Expand Down
7 changes: 7 additions & 0 deletions Orange/widgets/utils/domaineditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ def set_orig_variables(self, variables):
def reset_variables(self):
self.set_variables(deepcopy(self.orig_variables))

def reset_variables(self):
self.set_variables(self.orig_variables)

def set_variables(self, variables):
self.modelAboutToBeReset.emit()
self.variables = variables
Expand Down Expand Up @@ -357,6 +360,10 @@ def set_domain(self, domain):
self.variables = self.parse_domain(domain)
self.model().set_orig_variables(self.variables)

def reset_domain(self):
self.model().reset_variables()
self.variables = self.model().variables

@staticmethod
def parse_domain(domain):
"""Convert domain into variable representation used by
Expand Down

0 comments on commit 707a449

Please sign in to comment.