Skip to content

Commit

Permalink
owcsvimport: Clear on invalidate
Browse files Browse the repository at this point in the history
  • Loading branch information
irgolic committed Aug 6, 2021
1 parent 3a54a22 commit 797ab7b
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions Orange/widgets/data/owcsvimport.py
Original file line number Diff line number Diff line change
Expand Up @@ -1232,6 +1232,17 @@ def _invalidate(self):
self.__cancel_task()
# self.setBlocking(True)

def _update_buttons(self):
cbindex = self.recent_combo.currentIndex()
self.load_button.setEnabled(cbindex != -1)

import_enabled = (cbindex != -1 and
self.source == self.LOCAL_FILE and
self.reader is None)
self.import_options_button.setEnabled(import_enabled)

self._update_sheet_combo()

def commit(self):
"""
Commit the current state and submit the load task for execution.
Expand All @@ -1242,6 +1253,8 @@ def commit(self):
"""
self.__committimer.stop()
self.closeContext()
self._set_summary_text(None)
self._update_table(None)
if self.__watcher is not None:
self.__cancel_task()
self.error()
Expand Down Expand Up @@ -1269,6 +1282,9 @@ def commit(self):
self._use_reader()
return

self.reader = None
self._update_buttons()

task = state = TaskState()
state.future = ...
state.watcher = qconcurrent.FutureWatcher()
Expand All @@ -1294,12 +1310,6 @@ def _use_reader(self):
self.Outputs.data.send(None)
return

try:
self._update_sheet_combo()
except Exception:
self.Error.sheet_error()
return

options = self.current_item().options()
if options.sheet:
self.reader.select_sheet(options.sheet)
Expand All @@ -1314,12 +1324,17 @@ def _use_reader(self):
if warnings:
self.Warning.load_warning(warnings[-1].message.args[0])

self._update_buttons()
self.__clear_running_state()
self.data = data
self.openContext(data.domain)
self.apply_domain_edit()

def _update_sheet_combo(self):
if not hasattr(self.reader, 'sheets'):
self.sheet_box.hide()
return

if len(self.reader.sheets) < 2:
self.sheet_box.hide()
self.reader.select_sheet(None)
Expand Down

0 comments on commit 797ab7b

Please sign in to comment.