From 336294fe358e23794a35c7122fd635aba077c9ad Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Sat, 10 Jul 2010 14:07:00 +0100 Subject: [PATCH 1/4] Recover from UI changes --- src/calibre/gui2/layout.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/calibre/gui2/layout.py b/src/calibre/gui2/layout.py index f3b650f531..7b70224872 100644 --- a/src/calibre/gui2/layout.py +++ b/src/calibre/gui2/layout.py @@ -12,6 +12,7 @@ from PyQt4.Qt import QIcon, Qt, QWidget, QAction, QToolBar, QSize, QVariant, \ from calibre.constants import __appname__, filesystem_encoding from calibre.gui2.search_box import SearchBox2, SavedSearchBox +from calibre.gui2.widgets import ComboBoxWithHelp from calibre.gui2.throbber import ThrobbingButton from calibre.gui2 import NONE from calibre import human_readable @@ -280,12 +281,7 @@ class SearchBar(QWidget): # {{{ self._layout = l = QHBoxLayout() self.setLayout(self._layout) - self.restriction_label = QLabel(_("&Restrict to:")) - l.addWidget(self.restriction_label) - self.restriction_label.setSizePolicy(QSizePolicy.Minimum, - QSizePolicy.Minimum) - - x = QComboBox(self) + x = ComboBoxWithHelp(self) x.setMaximumSize(QSize(150, 16777215)) x.setObjectName("search_restriction") x.setToolTip(_("Books display will be restricted to those matching the selected saved search")) @@ -344,7 +340,6 @@ class SearchBar(QWidget): # {{{ x.setToolTip(_("Delete current saved search")) self.label.setBuddy(parent.search) - self.restriction_label.setBuddy(parent.search_restriction) # }}} From f9896d01f31a638dc87b884600b90fd7cf4e147e Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Sat, 10 Jul 2010 15:40:38 +0100 Subject: [PATCH 2/4] Put GPL line back in (don't know how it disappeared) --- src/calibre/gui2/widgets.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/calibre/gui2/widgets.py b/src/calibre/gui2/widgets.py index e3874fdc3a..97758482fc 100644 --- a/src/calibre/gui2/widgets.py +++ b/src/calibre/gui2/widgets.py @@ -1,3 +1,4 @@ +__license__ = 'GPL v3' __copyright__ = '2008, Kovid Goyal ' ''' Miscellaneous widgets used in the GUI From 62a5b4d459a9dc9dbb24c99e411376c43cb79f6a Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Sun, 11 Jul 2010 10:04:49 +0100 Subject: [PATCH 3/4] Fixes to work around Qt strangeness with date editing --- src/calibre/gui2/custom_column_widgets.py | 9 +++++++-- src/calibre/gui2/library/delegates.py | 8 ++++---- src/calibre/library/caches.py | 4 ++-- src/calibre/utils/date.py | 2 +- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/calibre/gui2/custom_column_widgets.py b/src/calibre/gui2/custom_column_widgets.py index 2a9c81e8ee..58c2f15452 100644 --- a/src/calibre/gui2/custom_column_widgets.py +++ b/src/calibre/gui2/custom_column_widgets.py @@ -132,9 +132,11 @@ class DateEdit(QDateEdit): def focusInEvent(self, x): self.setSpecialValueText('') + QDateEdit.focusInEvent(self, x) def focusOutEvent(self, x): self.setSpecialValueText(_('Undefined')) + QDateEdit.focusOutEvent(self, x) class DateTime(Base): @@ -142,7 +144,10 @@ class DateTime(Base): self.widgets = [QLabel('&'+self.col_metadata['name']+':', parent), DateEdit(parent)] w = self.widgets[1] - w.setDisplayFormat('dd MMM yyyy') + format = self.col_metadata['display'].get('date_format','') + if not format: + format = 'dd MMM yyyy' + w.setDisplayFormat(format) w.setCalendarPopup(True) w.setMinimumDate(UNDEFINED_QDATE) w.setSpecialValueText(_('Undefined')) @@ -156,7 +161,7 @@ class DateTime(Base): def getter(self): val = self.widgets[1].date() - if val == UNDEFINED_QDATE: + if val <= UNDEFINED_QDATE: val = None else: val = qt_to_dt(val) diff --git a/src/calibre/gui2/library/delegates.py b/src/calibre/gui2/library/delegates.py index 529055ecd2..40f7a2e4e0 100644 --- a/src/calibre/gui2/library/delegates.py +++ b/src/calibre/gui2/library/delegates.py @@ -96,7 +96,7 @@ class DateDelegate(QStyledItemDelegate): # {{{ def displayText(self, val, locale): d = val.toDate() - if d == UNDEFINED_QDATE: + if d <= UNDEFINED_QDATE: return '' return format_date(d.toPyDate(), 'dd MMM yyyy') @@ -116,7 +116,7 @@ class PubDateDelegate(QStyledItemDelegate): # {{{ def displayText(self, val, locale): d = val.toDate() - if d == UNDEFINED_QDATE: + if d <= UNDEFINED_QDATE: return '' format = tweaks['gui_pubdate_display_format'] if format is None: @@ -194,7 +194,7 @@ class CcDateDelegate(QStyledItemDelegate): # {{{ def displayText(self, val, locale): d = val.toDate() - if d == UNDEFINED_QDATE: + if d <= UNDEFINED_QDATE: return '' return format_date(d.toPyDate(), self.format) @@ -217,7 +217,7 @@ class CcDateDelegate(QStyledItemDelegate): # {{{ def setModelData(self, editor, model, index): val = editor.date() - if val == UNDEFINED_QDATE: + if val <= UNDEFINED_QDATE: val = None model.setData(index, QVariant(val), Qt.EditRole) diff --git a/src/calibre/library/caches.py b/src/calibre/library/caches.py index d46ae23d90..af950a36fc 100644 --- a/src/calibre/library/caches.py +++ b/src/calibre/library/caches.py @@ -209,13 +209,13 @@ class ResultCache(SearchQueryParser): if query == 'false': for item in self._data: if item is None: continue - if item[loc] is None or item[loc] == UNDEFINED_DATE: + if item[loc] is None or item[loc] <= UNDEFINED_DATE: matches.add(item[0]) return matches if query == 'true': for item in self._data: if item is None: continue - if item[loc] is not None and item[loc] != UNDEFINED_DATE: + if item[loc] is not None and item[loc] > UNDEFINED_DATE: matches.add(item[0]) return matches diff --git a/src/calibre/utils/date.py b/src/calibre/utils/date.py index c5fba13f57..b25940d23d 100644 --- a/src/calibre/utils/date.py +++ b/src/calibre/utils/date.py @@ -44,7 +44,7 @@ parse_date_day_first = compute_locale_info_for_parse_date() utc_tz = _utc_tz = tzutc() local_tz = _local_tz = SafeLocalTimeZone() -UNDEFINED_DATE = datetime(101,1,1, tzinfo=utc_tz) +UNDEFINED_DATE = datetime(1000,1,1, tzinfo=utc_tz) def parse_date(date_string, assume_utc=False, as_utc=True, default=None): ''' From abdee7d012c253f198271a9ea838e3e447807f6c Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Sun, 11 Jul 2010 10:51:56 +0100 Subject: [PATCH 4/4] Disable editing metadata on the device view when automatic update is chosen. --- src/calibre/gui2/library/models.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/library/models.py b/src/calibre/gui2/library/models.py index 9f1a72b021..89008735fe 100644 --- a/src/calibre/gui2/library/models.py +++ b/src/calibre/gui2/library/models.py @@ -1216,7 +1216,9 @@ class DeviceBooksModel(BooksModel): # {{{ return done def set_editable(self, editable): - self.editable = editable + # Cannot edit if metadata is sent on connect. Reason: changes will + # revert to what is in the library on next connect. + self.editable = editable and prefs['manage_device_metadata']!='on_connect' def set_search_restriction(self, s): pass