def populate_open_menu(self): m = self.open_menu m.clear() recent = get_session_pref('standalone_recently_opened', group=None, default=()) if recent: for entry in recent: try: path = os.path.abspath(entry['pathtoebook']) except Exception: continue if hasattr(set_book_path, 'pathtoebook') and path == os.path.abspath( set_book_path.pathtoebook): continue if os.path.exists(path): m.addAction('{}\t {}'.format( elided_text(entry['title'], pos='right', width=250), elided_text(os.path.basename(path), width=250))).triggered.connect( partial(self.open_book_at_path.emit, path)) else: self.web_view.remove_recently_opened(path)
def text_from_rule(rule, parent): try: query = elided_text(rule['query'], font=parent.font(), width=200, pos='right') text = _( 'If the property <i>{property}</i> <b>{match_type}</b> <b>{query}</b><br>{action}').format( property=rule['property'], action=ACTION_MAP[rule['action']], match_type=MATCH_TYPE_MAP[rule['match_type']], query=query) if rule['action_data']: ad = elided_text(rule['action_data'], font=parent.font(), width=200, pos='right') text += ' <code>%s</code>' % ad except Exception: import traceback traceback.print_exc() text = _('This rule is invalid, please remove it') return text
def text_from_rule(rule, parent): try: query = elided_text(rule['query'], font=parent.font(), width=200, pos='right') text = _('If the tag <b>{match_type}</b> <b>{query}</b>').format( match_type=MATCH_TYPE_MAP[rule['match_type']].text, query=prepare_string_for_xml(query)) for action in rule['actions']: text += '<br>' + ACTION_MAP[action['type']].short_text if action.get('data'): ad = elided_text(action['data'], font=parent.font(), width=200, pos='right') text += f' <code>{prepare_string_for_xml(ad)}</code>' except Exception: import traceback traceback.print_exc() text = _('This rule is invalid, please remove it') return text
def setup_ui(self): self.l = l = QFormLayout(self) l.addRow( QLabel(_('Print %s to a PDF file') % elided_text(self.book_title))) self.h = h = QHBoxLayout() self.file_name = f = QLineEdit(self) val = dynamic.get(self.OUTPUT_NAME, None) if not val: val = expanduser('~') else: val = os.path.dirname(val) f.setText(os.path.abspath(os.path.join(val, self.default_file_name))) self.browse_button = b = QToolButton(self) b.setIcon(QIcon(I('document_open.png'))), b.setToolTip( _('Choose location for PDF file')) b.clicked.connect(self.choose_file) h.addWidget(f), h.addWidget(b) f.setMinimumWidth(350) w = QLabel(_('&File:')) l.addRow(w, h), w.setBuddy(f) self.paper_size = ps = QComboBox(self) ps.addItems([ a.upper() for a in sorted(self.paper_size_map, key=numeric_sort_key) ]) previous_size = vprefs.get('print-to-pdf-page-size', None) if previous_size not in self.paper_size_map: previous_size = (QPrinter().pageLayout().pageSize().name() or '').lower() if previous_size not in self.paper_size_map: previous_size = 'a4' ps.setCurrentIndex(ps.findText(previous_size.upper())) l.addRow(_('Paper &size:'), ps) tmap = { 'left': _('&Left margin:'), 'top': _('&Top margin:'), 'right': _('&Right margin:'), 'bottom': _('&Bottom margin:'), } for edge in 'left top right bottom'.split(): m = QDoubleSpinBox(self) m.setSuffix(' ' + _('inches')) m.setMinimum(0), m.setMaximum(3), m.setSingleStep(0.1) val = vprefs.get('print-to-pdf-%s-margin' % edge, 1) m.setValue(val) setattr(self, '%s_margin' % edge, m) l.addRow(tmap[edge], m) self.pnum = pnum = QCheckBox(_('Add page &number to printed pages'), self) pnum.setChecked(vprefs.get('print-to-pdf-page-numbers', True)) l.addRow(pnum) self.show_file = sf = QCheckBox(_('&Open PDF file after printing'), self) sf.setChecked(vprefs.get('print-to-pdf-show-file', True)) l.addRow(sf) l.addRow(self.bb)
def text_from_rule(rule, parent): query = elided_text(rule['query'], font=parent.font(), width=200, pos='right') text = _( '<b>{action}</b> the tag, if it <i>{match_type}</i>: <b>{query}</b>').format( action=RuleEdit.ACTION_MAP[rule['action']], match_type=RuleEdit.MATCH_TYPE_MAP[rule['match_type']], query=query) if rule['action'] == 'replace': text += '<br>' + _('with the tag:') + ' <b>%s</b>' % rule['replace'] return text
def text_from_rule(rule, parent): query = elided_text(rule['query'], font=parent.font(), width=200, pos='right') text = _( '<b>{action}</b> the author name, if it <i>{match_type}</i>: <b>{query}</b>').format( action=RuleEdit.ACTION_MAP[rule['action']], match_type=RuleEdit.MATCH_TYPE_MAP[rule['match_type']], query=query) if rule['action'] == 'replace': text += '<br>' + _('to the name') + ' <b>%s</b>' % rule['replace'] return '<div style="white-space: nowrap">' + text + '</div>'
def show_context_menu(self, point): item = self.itemAt(point) if item is None or item in set(self.categories.itervalues()): return m = QMenu(self) sel = self.selectedItems() num = len(sel) container = current_container() ci = self.currentItem() if ci is not None: cn = unicode(ci.data(0, NAME_ROLE) or '') mt = unicode(ci.data(0, MIME_ROLE) or '') cat = unicode(ci.data(0, CATEGORY_ROLE) or '') n = elided_text(cn.rpartition('/')[-1]) m.addAction(QIcon(I('save.png')), _('Export %s') % n, partial(self.export, cn)) if cn not in container.names_that_must_not_be_changed and cn not in container.names_that_must_not_be_removed and mt not in OEB_FONTS: m.addAction(_('Replace %s with file...') % n, partial(self.replace, cn)) if num > 1: m.addAction(QIcon(I('save.png')), _('Export all %d selected files') % num, self.export_selected) m.addSeparator() m.addAction(QIcon(I('modified.png')), _('&Rename %s') % n, self.edit_current_item) if is_raster_image(mt): m.addAction(QIcon(I('default_cover.png')), _('Mark %s as cover image') % n, partial(self.mark_as_cover, cn)) elif current_container().SUPPORTS_TITLEPAGES and mt in OEB_DOCS and cat == 'text': m.addAction(QIcon(I('default_cover.png')), _('Mark %s as cover page') % n, partial(self.mark_as_titlepage, cn)) m.addSeparator() if num > 0: m.addSeparator() if num > 1: m.addAction(QIcon(I('modified.png')), _('&Bulk rename the selected files'), self.request_bulk_rename) m.addAction(QIcon(I('modified.png')), _('Change the file extension for the selected files'), self.request_change_ext) m.addAction(QIcon(I('trash.png')), ngettext( '&Delete the selected file', '&Delete the {} selected files', num).format(num), self.request_delete) m.addAction(QIcon(I('edit-copy.png')), ngettext( '&Copy the selected file to another editor instance', '&Copy the {} selected files to another editor instance', num).format(num), self.copy_selected_files) m.addSeparator() selected_map = defaultdict(list) for item in sel: selected_map[unicode(item.data(0, CATEGORY_ROLE) or '')].append(unicode(item.data(0, NAME_ROLE) or '')) for items in selected_map.itervalues(): items.sort(key=self.index_of_name) if selected_map['text']: m.addAction(QIcon(I('format-text-color.png')), _('Link &stylesheets...'), partial(self.link_stylesheets, selected_map['text'])) if len(selected_map['text']) > 1: m.addAction(QIcon(I('merge.png')), _('&Merge selected text files'), partial(self.start_merge, 'text', selected_map['text'])) if len(selected_map['styles']) > 1: m.addAction(QIcon(I('merge.png')), _('&Merge selected style files'), partial(self.start_merge, 'styles', selected_map['styles'])) if len(list(m.actions())) > 0: m.popup(self.mapToGlobal(point))
def mark_as_titlepage(self, name): first = unicode(self.categories['text'].child(0).data(0, NAME_ROLE) or '') == name move_to_start = False if not first: move_to_start = question_dialog(self, _('Not first item'), _( '%s is not the first text item. You should only mark the' ' first text item as cover. Do you want to make it the' ' first item?') % elided_text(name)) self.mark_requested.emit(name, 'titlepage:%r' % move_to_start)
def show_context_menu(self, point): item = self.itemAt(point) if item is None or item in set(self.categories.itervalues()): return m = QMenu(self) sel = self.selectedItems() num = len(sel) container = current_container() ci = self.currentItem() if ci is not None: cn = unicode(ci.data(0, NAME_ROLE) or '') mt = unicode(ci.data(0, MIME_ROLE) or '') cat = unicode(ci.data(0, CATEGORY_ROLE) or '') n = elided_text(cn.rpartition('/')[-1]) m.addAction(QIcon(I('save.png')), _('Export %s') % n, partial(self.export, cn)) if cn not in container.names_that_must_not_be_changed and cn not in container.names_that_must_not_be_removed and mt not in OEB_FONTS: m.addAction(_('Replace %s with file...') % n, partial(self.replace, cn)) if num > 1: m.addAction(QIcon(I('save.png')), _('Export all %d selected files') % num, self.export_selected) m.addSeparator() m.addAction(QIcon(I('modified.png')), _('&Rename %s') % n, self.edit_current_item) if is_raster_image(mt): m.addAction(QIcon(I('default_cover.png')), _('Mark %s as cover image') % n, partial(self.mark_as_cover, cn)) elif current_container().SUPPORTS_TITLEPAGES and mt in OEB_DOCS and cat == 'text': m.addAction(QIcon(I('default_cover.png')), _('Mark %s as cover page') % n, partial(self.mark_as_titlepage, cn)) m.addSeparator() if num > 0: m.addSeparator() if num > 1: m.addAction(QIcon(I('modified.png')), _('&Bulk rename the selected files'), self.request_bulk_rename) m.addAction(QIcon(I('modified.png')), _('Change the file extension for the selected files'), self.request_change_ext) m.addAction(QIcon(I('trash.png')), ngettext( '&Delete the selected file', '&Delete the {} selected files', num).format(num), self.request_delete) m.addSeparator() selected_map = defaultdict(list) for item in sel: selected_map[unicode(item.data(0, CATEGORY_ROLE) or '')].append(unicode(item.data(0, NAME_ROLE) or '')) for items in selected_map.itervalues(): items.sort(key=self.index_of_name) if selected_map['text']: m.addAction(QIcon(I('format-text-color.png')), _('Link &stylesheets...'), partial(self.link_stylesheets, selected_map['text'])) if len(selected_map['text']) > 1: m.addAction(QIcon(I('merge.png')), _('&Merge selected text files'), partial(self.start_merge, 'text', selected_map['text'])) if len(selected_map['styles']) > 1: m.addAction(QIcon(I('merge.png')), _('&Merge selected style files'), partial(self.start_merge, 'styles', selected_map['styles'])) if len(list(m.actions())) > 0: m.popup(self.mapToGlobal(point))
def populate_menu(menu, connect_action, file_type): file_type = file_type.lower() for entry in oprefs['entries'].get(file_type, ()): icon, text = entry_to_icon_text(entry) text = elided_text(text, pos='right') sa = registered_shortcuts.get(entry['uuid']) if sa is not None: text += '\t' + sa.shortcut().toString(QKeySequence.NativeText) ac = menu.addAction(icon, text) connect_action(ac, entry) return menu
def setup_ui(self): self.vl = vl = QVBoxLayout(self) self.l = l = QFormLayout() vl.addLayout(l) l.setContentsMargins(0, 0, 0, 0) l.addRow( QLabel(_('Print %s to a PDF file') % elided_text(self.book_title))) self.h = h = QHBoxLayout() self.file_name = f = QLineEdit(self) val = dynamic.get(self.OUTPUT_NAME, None) if not val: val = expanduser('~') else: val = os.path.dirname(val) f.setText(os.path.abspath(os.path.join(val, self.default_file_name))) self.browse_button = b = QToolButton(self) b.setIcon(QIcon(I('document_open.png'))), b.setToolTip( _('Choose location for PDF file')) b.clicked.connect(self.choose_file) h.addWidget(f), h.addWidget(b) f.setMinimumWidth(350) w = QLabel(_('&File:')) l.addRow(w, h), w.setBuddy(f) self.paper_size = ps = PaperSizes(self) ps.initialize() ps.set_value_for_config = vprefs.get('print-to-pdf-page-size', None) l.addRow(_('Paper &size:'), ps) tmap = { 'left': _('&Left margin:'), 'top': _('&Top margin:'), 'right': _('&Right margin:'), 'bottom': _('&Bottom margin:'), } for edge in 'left top right bottom'.split(): m = QDoubleSpinBox(self) m.setSuffix(' ' + _('inches')) m.setMinimum(0), m.setMaximum(3), m.setSingleStep(0.1) val = vprefs.get('print-to-pdf-%s-margin' % edge, 1) m.setValue(val) setattr(self, '%s_margin' % edge, m) l.addRow(tmap[edge], m) self.pnum = pnum = QCheckBox(_('Add page &number to printed pages'), self) pnum.setChecked(vprefs.get('print-to-pdf-page-numbers', True)) l.addRow(pnum) self.show_file = sf = QCheckBox(_('&Open PDF file after printing'), self) sf.setChecked(vprefs.get('print-to-pdf-show-file', True)) l.addRow(sf) vl.addStretch(10) vl.addWidget(self.bb)
def text_from_rule(rule, parent): query = elided_text(rule['query'], font=parent.font(), width=200, pos='right') text = _( '<b>{action}</b> the file, if the filename <i>{match_type}</i>: <b>{query}</b>' ).format(action=RuleEdit.ACTION_MAP[rule['action']], match_type=RuleEdit.MATCH_TYPE_MAP[rule['match_type']], query=query) return text
def mark_as_titlepage(self, name): first = str(self.categories['text'].child(0).data(0, NAME_ROLE) or '') == name move_to_start = False if not first: move_to_start = question_dialog(self, _('Not first item'), _( '%s is not the first text item. You should only mark the' ' first text item as cover. Do you want to make it the' ' first item?') % elided_text(name), skip_dialog_name='edit-book-mark-as-titlepage-move-confirm', skip_dialog_skip_precheck=False ) self.mark_requested.emit(name, 'titlepage:%r' % move_to_start)
def handle_merge_drop(self, target_node, names): category_node = target_node.parent() current_order = {category_node.child(i).data(0, NAME_ROLE):i for i in range(category_node.childCount())} names = sorted(names, key=lambda x: current_order.get(x, -1)) target_name = target_node.data(0, NAME_ROLE) if len(names) == 1: msg = _('Merge the file {0} into the file {1}?').format(elided_text(names[0]), elided_text(target_name)) else: msg = _('Merge the {0} selected files into the file {1}?').format(len(names), elided_text(target_name)) if question_dialog(self, _('Merge files'), msg, skip_dialog_name='edit-book-merge-on-drop'): names.append(target_name) names = sorted(names, key=lambda x: current_order.get(x, -1)) self.merge_requested.emit(target_node.data(0, CATEGORY_ROLE), names, target_name)
def setup_ui(self): self.l = l = QFormLayout(self) l.addRow(QLabel(_('Print %s to a PDF file') % elided_text(self.book_title))) self.h = h = QHBoxLayout() self.file_name = f = QLineEdit(self) val = dynamic.get(self.OUTPUT_NAME, None) if not val: val = expanduser('~') else: val = os.path.dirname(val) f.setText(os.path.abspath(os.path.join(val, self.default_file_name))) self.browse_button = b = QToolButton(self) b.setIcon(QIcon(I('document_open.png'))), b.setToolTip(_('Choose location for PDF file')) b.clicked.connect(self.choose_file) h.addWidget(f), h.addWidget(b) f.setMinimumWidth(350) w = QLabel(_('&File:')) l.addRow(w, h), w.setBuddy(f) self.paper_size = ps = QComboBox(self) ps.addItems([a.upper() for a in sorted(self.paper_size_map, key=numeric_sort_key)]) previous_size = vprefs.get('print-to-pdf-page-size', None) if previous_size not in self.paper_size_map: previous_size = (QPrinter().pageLayout().pageSize().name() or '').lower() if previous_size not in self.paper_size_map: previous_size = 'a4' ps.setCurrentIndex(ps.findText(previous_size.upper())) l.addRow(_('Paper &size:'), ps) tmap = { 'left':_('&Left margin:'), 'top':_('&Top margin:'), 'right':_('&Right margin:'), 'bottom':_('&Bottom margin:'), } for edge in 'left top right bottom'.split(): m = QDoubleSpinBox(self) m.setSuffix(' ' + _('inches')) m.setMinimum(0), m.setMaximum(3), m.setSingleStep(0.1) val = vprefs.get('print-to-pdf-%s-margin' % edge, 1) m.setValue(val) setattr(self, '%s_margin' % edge, m) l.addRow(tmap[edge], m) self.pnum = pnum = QCheckBox(_('Add page &number to printed pages'), self) pnum.setChecked(vprefs.get('print-to-pdf-page-numbers', True)) l.addRow(pnum) self.show_file = sf = QCheckBox(_('Open PDF file after printing'), self) sf.setChecked(vprefs.get('print-to-pdf-show-file', True)) l.addRow(sf) l.addRow(self.bb)
def build_menus(self, db): for ac in self.history_actions: self.view_menu.removeAction(ac) self.history_actions = [] history = db.new_api.pref('gui_view_history', []) if history: self.view_menu.insertAction(self.clear_sep2, self.clear_sep1) self.history_actions.append(self.clear_sep1) fm = self.gui.fontMetrics() for id_, title in history: ac = HistoryAction(id_, elided_text(title, font=fm, pos='right'), self.view_menu) self.view_menu.insertAction(self.clear_sep2, ac) ac.view_historical.connect(self.view_historical) self.history_actions.append(ac)
def build_menus(self, db): for ac in self.history_actions: self.view_menu.removeAction(ac) self.history_actions = [] history = db.prefs.get('gui_view_history', []) if history: self.view_menu.insertAction(self.clear_sep2, self.clear_sep1) self.history_actions.append(self.clear_sep1) fm = self.gui.fontMetrics() for id_, title in history: ac = HistoryAction(id_, elided_text(title, font=fm, pos='right'), self.view_menu) self.view_menu.insertAction(self.clear_sep2, ac) ac.view_historical.connect(self.view_historical) self.history_actions.append(ac)
def mark_as_titlepage(self, name): first = unicode(self.categories["text"].child(0).data(0, NAME_ROLE) or "") == name move_to_start = False if not first: move_to_start = question_dialog( self, _("Not first item"), _( "%s is not the first text item. You should only mark the" " first text item as cover. Do you want to make it the" " first item?" ) % elided_text(name), ) self.mark_requested.emit(name, "titlepage:%r" % move_to_start)
def elided_text(self, text, width=300): return elided_text(text, font=self.font(), width=width)
def fset(self, val): val = str(val or '') self.message.setText( elided_text(val, self.font(), self.message.minimumWidth() - 10))
def show_context_menu(self, point): item = self.itemAt(point) if item is None or item in set(self.categories.itervalues()): return m = QMenu(self) sel = self.selectedItems() num = len(sel) container = current_container() ci = self.currentItem() if ci is not None: cn = unicode(ci.data(0, NAME_ROLE) or "") mt = unicode(ci.data(0, MIME_ROLE) or "") cat = unicode(ci.data(0, CATEGORY_ROLE) or "") n = elided_text(cn.rpartition("/")[-1]) m.addAction(QIcon(I("save.png")), _("Export %s") % n, partial(self.export, cn)) if ( cn not in container.names_that_must_not_be_changed and cn not in container.names_that_must_not_be_removed and mt not in OEB_FONTS ): m.addAction(_("Replace %s with file...") % n, partial(self.replace, cn)) m.addSeparator() m.addAction(QIcon(I("modified.png")), _("&Rename %s") % n, self.edit_current_item) if is_raster_image(mt): m.addAction( QIcon(I("default_cover.png")), _("Mark %s as cover image") % n, partial(self.mark_as_cover, cn) ) elif current_container().SUPPORTS_TITLEPAGES and mt in OEB_DOCS and cat == "text": m.addAction( QIcon(I("default_cover.png")), _("Mark %s as cover page") % n, partial(self.mark_as_titlepage, cn) ) m.addSeparator() if num > 0: m.addSeparator() if num > 1: m.addAction(QIcon(I("modified.png")), _("&Bulk rename selected files"), self.request_bulk_rename) m.addAction(QIcon(I("trash.png")), _("&Delete the %d selected file(s)") % num, self.request_delete) m.addSeparator() selected_map = defaultdict(list) for item in sel: selected_map[unicode(item.data(0, CATEGORY_ROLE) or "")].append(unicode(item.data(0, NAME_ROLE) or "")) for items in selected_map.itervalues(): items.sort(key=self.index_of_name) if selected_map["text"]: m.addAction( QIcon(I("format-text-color.png")), _("Link &stylesheets..."), partial(self.link_stylesheets, selected_map["text"]), ) if len(selected_map["text"]) > 1: m.addAction( QIcon(I("merge.png")), _("&Merge selected text files"), partial(self.start_merge, "text", selected_map["text"]), ) if len(selected_map["styles"]) > 1: m.addAction( QIcon(I("merge.png")), _("&Merge selected style files"), partial(self.start_merge, "styles", selected_map["styles"]), ) if len(list(m.actions())) > 0: m.popup(self.mapToGlobal(point))
def build_item_context_menu(self, item): m = QMenu(self) sel = self.selectedItems() num = len(sel) container = current_container() ci = self.currentItem() if ci is not None: cn = str(ci.data(0, NAME_ROLE) or '') mt = str(ci.data(0, MIME_ROLE) or '') cat = str(ci.data(0, CATEGORY_ROLE) or '') n = elided_text(cn.rpartition('/')[-1]) m.addAction(QIcon(I('save.png')), _('Export %s') % n, partial(self.export, cn)) if cn not in container.names_that_must_not_be_changed and cn not in container.names_that_must_not_be_removed and mt not in OEB_FONTS: m.addAction(_('Replace %s with file...') % n, partial(self.replace, cn)) if num > 1: m.addAction(QIcon(I('save.png')), _('Export all %d selected files') % num, self.export_selected) if cn not in container.names_that_must_not_be_changed: self.add_open_with_actions(m, cn) m.addSeparator() m.addAction(QIcon(I('modified.png')), _('&Rename %s') % n, self.edit_current_item) if is_raster_image(mt): m.addAction(QIcon(I('default_cover.png')), _('Mark %s as cover image') % n, partial(self.mark_as_cover, cn)) elif current_container().SUPPORTS_TITLEPAGES and mt in OEB_DOCS and cat == 'text': m.addAction(QIcon(I('default_cover.png')), _('Mark %s as cover page') % n, partial(self.mark_as_titlepage, cn)) m.addSeparator() if num > 0: m.addSeparator() if num > 1: m.addAction(QIcon(I('modified.png')), _('&Bulk rename the selected files'), self.request_bulk_rename) m.addAction(QIcon(I('modified.png')), _('Change the file extension for the selected files'), self.request_change_ext) m.addAction(QIcon(I('trash.png')), ngettext( '&Delete the selected file', '&Delete the {} selected files', num).format(num), self.request_delete) m.addAction(QIcon(I('edit-copy.png')), ngettext( '&Copy the selected file to another editor instance', '&Copy the {} selected files to another editor instance', num).format(num), self.copy_selected_files) m.addSeparator() md = QApplication.instance().clipboard().mimeData() if md.hasUrls() and md.hasFormat(FILE_COPY_MIME): import json name_map = json.loads(bytes(md.data(FILE_COPY_MIME))) m.addAction(ngettext( _('Paste file from other editor instance'), _('Paste {} files from other editor instance'), len(name_map)).format(len(name_map)), self.paste_from_other_instance) selected_map = defaultdict(list) for item in sel: selected_map[str(item.data(0, CATEGORY_ROLE) or '')].append(str(item.data(0, NAME_ROLE) or '')) for items in selected_map.values(): items.sort(key=self.index_of_name) if selected_map['text']: m.addAction(QIcon(I('format-text-color.png')), _('Link &stylesheets...'), partial(self.link_stylesheets, selected_map['text'])) if len(selected_map['text']) > 1: m.addAction(QIcon(I('merge.png')), _('&Merge selected text files'), partial(self.start_merge, 'text', selected_map['text'])) if len(selected_map['styles']) > 1: m.addAction(QIcon(I('merge.png')), _('&Merge selected style files'), partial(self.start_merge, 'styles', selected_map['styles'])) return m
def text_from_rule(rule, parent): query = elided_text(rule['query'], font=parent.font(), width=200, pos='right') text = _( '<b>{action}</b> the file, if the filename <i>{match_type}</i>: <b>{query}</b>').format( action=RuleEdit.ACTION_MAP[rule['action']], match_type=RuleEdit.MATCH_TYPE_MAP[rule['match_type']], query=query) return text
def msg(self, val): val = unicode_type(val or '') self.message.setText(elided_text(val, self.font(), self.message.minimumWidth()-10))