mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-06 02:33:42 +02:00
Edit Book: Fix Saved searches panel not working well with very long search/replace expressions
This commit is contained in:
parent
bacca244ea
commit
fb815c0bdb
1 changed files with 16 additions and 6 deletions
|
|
@ -14,7 +14,7 @@
|
|||
QWidget, QToolBar, Qt, QHBoxLayout, QSize, QIcon, QGridLayout, QLabel, QTimer,
|
||||
QPushButton, pyqtSignal, QComboBox, QCheckBox, QSizePolicy, QVBoxLayout, QFont,
|
||||
QLineEdit, QToolButton, QListView, QFrame, QApplication, QStyledItemDelegate,
|
||||
QAbstractListModel, QModelIndex, QMenu, QItemSelection, QStackedLayout)
|
||||
QAbstractListModel, QModelIndex, QMenu, QItemSelection, QStackedLayout, QScrollArea)
|
||||
|
||||
import regex
|
||||
|
||||
|
|
@ -491,6 +491,17 @@ def keyPressEvent(self, ev):
|
|||
return QWidget.keyPressEvent(self, ev)
|
||||
# }}}
|
||||
|
||||
class SearchDescription(QScrollArea):
|
||||
|
||||
def __init__(self, parent):
|
||||
QScrollArea.__init__(self, parent)
|
||||
self.label = QLabel(' \n \n ')
|
||||
self.setWidget(self.label)
|
||||
self.setWidgetResizable(True)
|
||||
self.label.setTextFormat(Qt.PlainText)
|
||||
self.label.setWordWrap(True)
|
||||
self.set_text = self.label.setText
|
||||
|
||||
class SearchesModel(QAbstractListModel):
|
||||
|
||||
def __init__(self, parent):
|
||||
|
|
@ -867,10 +878,9 @@ def pb(text, tooltip=None):
|
|||
d.setFrameStyle(QFrame.HLine)
|
||||
v.addWidget(d)
|
||||
|
||||
self.description = d = QLabel(' \n \n ')
|
||||
d.setTextFormat(Qt.PlainText)
|
||||
d.setWordWrap(True)
|
||||
self.description = d = SearchDescription(self)
|
||||
mw.v.addWidget(d)
|
||||
mw.v.setStretch(0, 10)
|
||||
|
||||
self.ib = b = pb(_('&Import'), _('Import saved searches'))
|
||||
b.clicked.connect(self.import_searches)
|
||||
|
|
@ -1056,7 +1066,7 @@ def add_predefined_search(self, state):
|
|||
self.edit_search_widget.search_name.setFocus(Qt.OtherFocusReason)
|
||||
|
||||
def show_details(self):
|
||||
self.description.setText(' \n \n ')
|
||||
self.description.set_text(' \n \n ')
|
||||
i = self.searches.currentIndex()
|
||||
if i.isValid():
|
||||
try:
|
||||
|
|
@ -1069,7 +1079,7 @@ def show_details(self):
|
|||
ts = _('(Case sensitive: {0} Dot All: {1})').format(cs, da)
|
||||
else:
|
||||
ts = _('(Case sensitive: {0} [Normal search])').format(cs)
|
||||
self.description.setText(_('{2} {3}\nFind: {0}\nReplace: {1}').format(
|
||||
self.description.set_text(_('{2} {3}\nFind: {0}\nReplace: {1}').format(
|
||||
search.get('find', ''), search.get('replace', ''), search.get('name', ''), ts))
|
||||
|
||||
def import_searches(self):
|
||||
|
|
|
|||
Loading…
Reference in a new issue