Skip to content

Commit

Permalink
Select Rows: Add time to calendar widget popup
Browse files Browse the repository at this point in the history
  • Loading branch information
janezd committed Jun 12, 2020
1 parent 5fc2f25 commit 208632b
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion Orange/widgets/data/owselectrows.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from AnyQt.QtWidgets import (
QWidget, QTableWidget, QHeaderView, QComboBox, QLineEdit, QToolButton,
QMessageBox, QMenu, QListView, QGridLayout, QPushButton, QSizePolicy,
QLabel, QHBoxLayout, QDateTimeEdit)
QLabel, QHBoxLayout, QDateTimeEdit, QCalendarWidget)
from AnyQt.QtGui import (QDoubleValidator, QStandardItemModel, QStandardItem,
QFontMetrics, QPalette)
from AnyQt.QtCore import Qt, QPoint, QPersistentModelIndex, QLocale, \
Expand Down Expand Up @@ -142,6 +142,30 @@ def _plural(s):
return s


class CalendarWidgetWithTime(QCalendarWidget):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
timeedit = QDateTimeEdit(displayFormat="hh:mm:ss")

self._time_layout = sublay = QHBoxLayout()
sublay.setContentsMargins(6, 6, 6, 6)
sublay.addStretch(1)
sublay.addWidget(QLabel("Time: "))
sublay.addWidget(timeedit)
sublay.addStretch(1)
self.layout().addLayout(sublay)

def minimumSize(self):
return self.sizeHint()

def sizeHint(self):
size = super().sizeHint()
size.setHeight(
size.height()
+ self._time_layout.sizeHint().height()
+ self.layout().spacing())
return size

class OWSelectRows(widget.OWWidget):
name = "Select Rows"
id = "Orange.widgets.data.file"
Expand Down Expand Up @@ -862,6 +886,8 @@ def set_format(self):
if self.have_date and self.have_time:
self.setDisplayFormat("yyyy-MM-dd hh:mm:ss")
self.setCalendarPopup(True)
self._calendarWidget = CalendarWidgetWithTime(self)
self.setCalendarWidget(self._calendarWidget)
c_format = "%Y-%m-%d %H:%M:%S"
min_datetime, max_datetime = self.find_range(self.column, c_format)
self.min_datetime = QDateTime.fromString(min_datetime, str_format)
Expand Down

0 comments on commit 208632b

Please sign in to comment.