mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Tag mapper: When specifying the replacement tag allow completion from the tags in the currently open library
This commit is contained in:
parent
c560cb7481
commit
2198787a15
@ -513,7 +513,7 @@ class EditWithComplete(EnComboBox):
|
|||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
def text(self):
|
def text(self):
|
||||||
return str(self.lineEdit().text())
|
return self.lineEdit().text()
|
||||||
|
|
||||||
def selectAll(self):
|
def selectAll(self):
|
||||||
self.lineEdit().selectAll()
|
self.lineEdit().selectAll()
|
||||||
|
@ -2,17 +2,18 @@
|
|||||||
# License: GPLv3 Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPLv3 Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
|
|
||||||
from collections import OrderedDict
|
|
||||||
import textwrap
|
import textwrap
|
||||||
|
from collections import OrderedDict
|
||||||
from qt.core import (
|
from qt.core import (
|
||||||
QWidget, QVBoxLayout, QHBoxLayout, QPushButton, QLabel, QListWidget, QIcon, QDialog,
|
QAbstractItemView, QComboBox, QDialog, QDialogButtonBox, QHBoxLayout, QIcon,
|
||||||
QSize, QComboBox, QLineEdit, QListWidgetItem, QStyledItemDelegate, QAbstractItemView,
|
QInputDialog, QItemSelectionModel, QLabel, QLineEdit, QListWidget,
|
||||||
QStaticText, Qt, QStyle, QToolButton, QInputDialog, QMenu, pyqtSignal, QPalette, QItemSelectionModel, QDialogButtonBox
|
QListWidgetItem, QMenu, QPalette, QPushButton, QSize, QStaticText, QStyle,
|
||||||
|
QStyledItemDelegate, Qt, QToolButton, QVBoxLayout, QWidget, pyqtSignal
|
||||||
)
|
)
|
||||||
|
|
||||||
from calibre.ebooks.metadata.tag_mapper import map_tags, compile_pat
|
from calibre.ebooks.metadata.tag_mapper import compile_pat, map_tags
|
||||||
from calibre.gui2 import error_dialog, Application, question_dialog
|
from calibre.gui2 import Application, error_dialog, question_dialog
|
||||||
|
from calibre.gui2.complete2 import EditWithComplete
|
||||||
from calibre.gui2.ui import get_gui
|
from calibre.gui2.ui import get_gui
|
||||||
from calibre.gui2.widgets2 import Dialog
|
from calibre.gui2.widgets2 import Dialog
|
||||||
from calibre.utils.config import JSONConfig
|
from calibre.utils.config import JSONConfig
|
||||||
@ -37,6 +38,16 @@ class QueryEdit(QLineEdit):
|
|||||||
menu.exec(ev.globalPos())
|
menu.exec(ev.globalPos())
|
||||||
|
|
||||||
|
|
||||||
|
class SingleTagEdit(EditWithComplete):
|
||||||
|
|
||||||
|
def __init__(self, parent):
|
||||||
|
super().__init__(parent)
|
||||||
|
self.set_separator(None)
|
||||||
|
gui = get_gui()
|
||||||
|
if gui:
|
||||||
|
self.update_items_cache(gui.current_db.new_api.all_field_names('tags'))
|
||||||
|
|
||||||
|
|
||||||
class RuleEdit(QWidget):
|
class RuleEdit(QWidget):
|
||||||
|
|
||||||
ACTION_MAP = OrderedDict((
|
ACTION_MAP = OrderedDict((
|
||||||
@ -106,7 +117,7 @@ class RuleEdit(QWidget):
|
|||||||
l.addLayout(h)
|
l.addLayout(h)
|
||||||
self.la3 = la = QLabel(self.REPLACE_TEXT + '\xa0')
|
self.la3 = la = QLabel(self.REPLACE_TEXT + '\xa0')
|
||||||
h.addWidget(la)
|
h.addWidget(la)
|
||||||
self.replace = r = QLineEdit(self)
|
self.replace = r = SingleTagEdit(self)
|
||||||
h.addWidget(r)
|
h.addWidget(r)
|
||||||
self.regex_help = la = QLabel('<p>' + self.REGEXP_HELP_TEXT % localize_user_manual_link(
|
self.regex_help = la = QLabel('<p>' + self.REGEXP_HELP_TEXT % localize_user_manual_link(
|
||||||
'https://manual.calibre-ebook.com/regexp.html'))
|
'https://manual.calibre-ebook.com/regexp.html'))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user