Skip to content

Commit

Permalink
Datasets: Skip domain-related code in derived widgets (e.i. SC Data s…
Browse files Browse the repository at this point in the history
…ets)
  • Loading branch information
janezd committed Nov 8, 2024
1 parent 39ef490 commit c2e0308
Showing 1 changed file with 27 additions and 10 deletions.
37 changes: 27 additions & 10 deletions Orange/widgets/data/owdatasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,8 @@ def __init__(self):
domain_combo = self.domain_combo = QComboBox()
domain_combo.addItem(self.GENERAL_DOMAIN_LABEL)
domain_combo.activated.connect(self._on_domain_changed)
layout.addWidget(domain_combo)
if self.core_widget:
layout.addWidget(domain_combo)

self.mainArea.layout().addLayout(layout)

Expand Down Expand Up @@ -334,6 +335,9 @@ def __init__(self):
proxy.setFilterKeyColumn(-1)
proxy.setFilterCaseSensitivity(Qt.CaseInsensitive)
self.view.setModel(proxy)
if not self.core_widget:
self.domain = ALL_DOMAINS
self.view.model().setDomain(self.domain)

if self.splitter_state:
self.splitter.restoreState(self.splitter_state)
Expand All @@ -350,6 +354,18 @@ def __init__(self):

self._on_language_changed()

# Single cell add-on has a data set widget that derives from this one
# although this class isn't defined as open. Adding the domain broke
# single-cell. A proper solution would be to split this widget into an
# (open) base class and a closed widget that adds the domain functionality.
# Yet, simply excluding three chunks of code makes this code simpler
# - which is better, if we assume that extending this widget is an anomaly.
@property
def core_widget(self):
# Compare by names; unit tests wrap widget classes in to detect
# missing onDeleteWidget calls
return type(self).__name__ == OWDataSets.__name__

def assign_delegates(self):
# NOTE: All columns must have size hinting delegates.
# QTreeView queries only the columns displayed in the viewport so
Expand Down Expand Up @@ -466,15 +482,16 @@ def update_model(self):
# for settings do not use os.path.join (Windows separator is different)
if file_path[-1] == self.selected_id:
current_index = i
self.domain = datainfo.domain
combo = self.domain_combo
if self.domain == GENERAL_DOMAIN:
combo.setCurrentIndex(0)
elif self.domain == ALL_DOMAINS:
combo.setCurrentIndex(combo.count() - 1)
else:
combo.setCurrentText(self.domain)
self._on_domain_changed()
if self.core_widget:
self.domain = datainfo.domain
combo = self.domain_combo
if self.domain == GENERAL_DOMAIN:
combo.setCurrentIndex(0)
elif self.domain == ALL_DOMAINS:
combo.setCurrentIndex(combo.count() - 1)
else:

Check warning on line 492 in Orange/widgets/data/owdatasets.py

View check run for this annotation

Codecov / codecov/patch

Orange/widgets/data/owdatasets.py#L492

Added line #L492 was not covered by tests
combo.setCurrentText(self.domain)
self._on_domain_changed()

Check warning on line 494 in Orange/widgets/data/owdatasets.py

View check run for this annotation

Codecov / codecov/patch

Orange/widgets/data/owdatasets.py#L494

Added line #L494 was not covered by tests

return model, current_index

Expand Down

0 comments on commit c2e0308

Please sign in to comment.