From 35927562a863aa0e29ba077d389691f66044853a Mon Sep 17 00:00:00 2001 From: janezd Date: Fri, 10 Feb 2023 21:03:00 +0100 Subject: [PATCH] Continuization: Delay before showing default behavior --- Orange/widgets/data/owcontinuize.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Orange/widgets/data/owcontinuize.py b/Orange/widgets/data/owcontinuize.py index 8f458074b5f..5ddc79224e1 100644 --- a/Orange/widgets/data/owcontinuize.py +++ b/Orange/widgets/data/owcontinuize.py @@ -6,7 +6,7 @@ import scipy.sparse as sp from AnyQt.QtCore import Qt, QSize, QAbstractListModel, QObject, \ - QItemSelectionModel + QItemSelectionModel, QTimer from AnyQt.QtGui import QColor from AnyQt.QtWidgets import QButtonGroup, QRadioButton, QListView @@ -126,6 +126,8 @@ def __init__(self, valid_type): valid_types=(valid_type, ), strict_type=True) def data(self, index, role=Qt.DisplayRole): + if role == Qt.ToolTipRole: + return None if role == self.FilterRole: name = super().data(index, Qt.DisplayRole) if not isinstance(name, str): @@ -214,7 +216,12 @@ def __init__(self, *args, **kwargs): self.default_view = None super().__init__(preferred_size=QSize(350, -1), *args, **kwargs) self.setItemDelegate(self.Delegate(self)) + self.force_hints = False + self.update_timer = QTimer() + self.update_timer.setInterval(500) + self.update_timer.setSingleShot(True) + self.update_timer.timeout.connect(self.viewport().update) def select_default(self): """Select the item representing default settings""" @@ -261,10 +268,12 @@ def __layout(self): def enterEvent(self, _): self.itemDelegate().set_default_hints(True) - self.viewport().update() + self.update_timer.start() def leaveEvent(self, _): self.itemDelegate().set_default_hints(False) + if self.update_timer.isActive(): + self.update_timer.stop() self.viewport().update()