Advanced Rule for column %(col)s: -
%(rule)s- ''')%dict(col=col, rule=prepare_string_for_xml(rule)) + if kind == 'color': + return _(''' +
Advanced Rule for column %(col)s: +
%(rule)s+ ''')%dict(col=col, rule=prepare_string_for_xml(rule)) + else: + return _(''' +
Advanced Rule: set %(typ)s for column %(col)s: +
%(rule)s+ ''')%dict(col=col, + typ=icon_rule_kinds[0][0] + if kind == icon_rule_kinds[0][1] else icon_rule_kinds[1][0], + rule=prepare_string_for_xml(rule)) + conditions = [self.condition_to_html(c) for c in rule.conditions] trans_kind = 'not found' @@ -761,7 +771,7 @@ class EditRules(QWidget): # {{{ ' what icon to use. Click the Add Rule button below' ' to get started.
You can change an existing rule by'
' double clicking it.'))
- self.add_advanced_button.setVisible(False)
+# self.add_advanced_button.setVisible(False)
def add_rule(self):
d = RuleEditor(self.model.fm, self.pref_name)
@@ -774,13 +784,23 @@ class EditRules(QWidget): # {{{
self.changed.emit()
def add_advanced(self):
- td = TemplateDialog(self, '', mi=self.mi, fm=self.fm, color_field='')
- if td.exec_() == td.Accepted:
- col, r = td.rule
- if r and col:
- idx = self.model.add_rule('color', col, r)
- self.rules_view.scrollTo(idx)
- self.changed.emit()
+ if self.pref_name == 'column_color_rules':
+ td = TemplateDialog(self, '', mi=self.mi, fm=self.fm, color_field='')
+ if td.exec_() == td.Accepted:
+ col, r = td.rule
+ if r and col:
+ idx = self.model.add_rule('color', col, r)
+ self.rules_view.scrollTo(idx)
+ self.changed.emit()
+ else:
+ td = TemplateDialog(self, '', mi=self.mi, fm=self.fm, icon_file='')
+ if td.exec_() == td.Accepted:
+ print(td.rule)
+ typ, col, r = td.rule
+ if typ and r and col:
+ idx = self.model.add_rule(typ, col, r)
+ self.rules_view.scrollTo(idx)
+ self.changed.emit()
def edit_rule(self, index):
try:
@@ -790,8 +810,12 @@ class EditRules(QWidget): # {{{
if isinstance(rule, Rule):
d = RuleEditor(self.model.fm, self.pref_name)
d.apply_rule(kind, col, rule)
- else:
+ elif self.pref_name == 'column_color_rules':
d = TemplateDialog(self, rule, mi=self.mi, fm=self.fm, color_field=col)
+ else:
+ d = TemplateDialog(self, rule, mi=self.mi, fm=self.fm, icon_file=col,
+ icon_rule_kind=kind)
+
if d.exec_() == d.Accepted:
if len(d.rule) == 2: # Convert template dialog rules to a triple
d.rule = ('color', d.rule[0], d.rule[1])
diff --git a/src/calibre/library/server/browse.py b/src/calibre/library/server/browse.py
index d25c34d52b..959248fdf8 100644
--- a/src/calibre/library/server/browse.py
+++ b/src/calibre/library/server/browse.py
@@ -749,6 +749,7 @@ class BrowseServer(object):
@Endpoint(mimetype='application/json; charset=utf-8')
def browse_booklist_page(self, ids=None, sort=None):
+ print('here')
if sort == 'null':
sort = None
if ids is None:
From eafa02f6f9ffc7991e92acb6b9fdf7324954bd93 Mon Sep 17 00:00:00 2001
From: Charles Haley <>
Date: Tue, 14 May 2013 16:44:28 +0200
Subject: [PATCH 2/4] Add user-setable device name to wireless device
---
src/calibre/devices/smart_device_app/driver.py | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/calibre/devices/smart_device_app/driver.py b/src/calibre/devices/smart_device_app/driver.py
index 6187f94b31..5fe60862e1 100644
--- a/src/calibre/devices/smart_device_app/driver.py
+++ b/src/calibre/devices/smart_device_app/driver.py
@@ -875,6 +875,9 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
self.client_device_kind = result.get('deviceKind', '')
self._debug('Client device kind', self.client_device_kind)
+ self.client_device_name = result.get('deviceName', self.client_device_kind)
+ self._debug('Client device name', self.client_device_name)
+
self.max_book_packet_len = result.get('maxBookContentPacketLen',
self.BASE_PACKET_LEN)
self._debug('max_book_packet_len', self.max_book_packet_len)
@@ -946,6 +949,8 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
return False
def get_gui_name(self):
+ if getattr(self, 'client_device_name', None):
+ return self.gui_name_template%(self.gui_name, self.client_device_name)
if getattr(self, 'client_device_kind', None):
return self.gui_name_template%(self.gui_name, self.client_device_kind)
return self.gui_name
From 2add5649efcd28d6dc2e5a8444ceb54d7148d131 Mon Sep 17 00:00:00 2001
From: Charles Haley <>
Date: Tue, 14 May 2013 16:45:23 +0200
Subject: [PATCH 3/4] Remove silly print statement
---
src/calibre/library/server/browse.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/calibre/library/server/browse.py b/src/calibre/library/server/browse.py
index 959248fdf8..d25c34d52b 100644
--- a/src/calibre/library/server/browse.py
+++ b/src/calibre/library/server/browse.py
@@ -749,7 +749,6 @@ class BrowseServer(object):
@Endpoint(mimetype='application/json; charset=utf-8')
def browse_booklist_page(self, ids=None, sort=None):
- print('here')
if sort == 'null':
sort = None
if ids is None:
From 4b3c9ba5402fed439b48700773ac8f3e7432a7a1 Mon Sep 17 00:00:00 2001
From: Charles Haley <>
Date: Tue, 14 May 2013 16:45:56 +0200
Subject: [PATCH 4/4] Changes after testing advance icon rules
---
src/calibre/gui2/dialogs/template_dialog.py | 7 ++++---
src/calibre/gui2/dialogs/template_dialog.ui | 9 ++++++---
src/calibre/gui2/preferences/coloring.py | 4 ++--
3 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/src/calibre/gui2/dialogs/template_dialog.py b/src/calibre/gui2/dialogs/template_dialog.py
index a7331f8c91..2bafc2812a 100644
--- a/src/calibre/gui2/dialogs/template_dialog.py
+++ b/src/calibre/gui2/dialogs/template_dialog.py
@@ -203,13 +203,13 @@ class TemplateHighlighter(QSyntaxHighlighter):
class TemplateDialog(QDialog, Ui_TemplateDialog):
def __init__(self, parent, text, mi=None, fm=None, color_field=None,
- icon_file=None, icon_rule_kind=None):
+ icon_field_key=None, icon_rule_kind=None):
QDialog.__init__(self, parent)
Ui_TemplateDialog.__init__(self)
self.setupUi(self)
self.coloring = color_field is not None
- self.iconing = icon_file is not None
+ self.iconing = icon_field_key is not None
cols = []
if fm is not None:
@@ -229,7 +229,7 @@ class TemplateDialog(QDialog, Ui_TemplateDialog):
self.color_layout.setVisible(True)
for n1, k1 in cols:
self.colored_field.addItem(n1, k1)
- self.colored_field.setCurrentIndex(self.colored_field.findText(color_field))
+ self.colored_field.setCurrentIndex(self.colored_field.findData(color_field))
colors = QColor.colorNames()
colors.sort()
self.color_name.addItems(colors)
@@ -250,6 +250,7 @@ class TemplateDialog(QDialog, Ui_TemplateDialog):
self.icon_with_text.setChecked(True)
if icon_rule_kind == 'icon_only':
self.icon_without_text.setChecked(True)
+ self.icon_field.setCurrentIndex(self.icon_field.findData(icon_field_key))
if mi:
self.mi = mi
diff --git a/src/calibre/gui2/dialogs/template_dialog.ui b/src/calibre/gui2/dialogs/template_dialog.ui
index 18c2a5ee35..db9cc16dd9 100644
--- a/src/calibre/gui2/dialogs/template_dialog.ui
+++ b/src/calibre/gui2/dialogs/template_dialog.ui
@@ -114,7 +114,7 @@