mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
Switch to using a string list model
This commit is contained in:
parent
d1242fd29c
commit
22a6e41f6d
@ -6,17 +6,18 @@ __copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
|||||||
|
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from gettext import pgettext
|
from gettext import pgettext
|
||||||
|
|
||||||
from qt.core import (
|
from qt.core import (
|
||||||
Qt, QMenu, QIcon, QDialog, QGridLayout, QLabel, QLineEdit, QComboBox, QFrame,
|
QAbstractItemView, QAction, QComboBox, QDialog, QDialogButtonBox, QFrame,
|
||||||
QDialogButtonBox, QSize, QVBoxLayout, QListWidget, QRadioButton, QAction, QTextBrowser, QAbstractItemView)
|
QGridLayout, QIcon, QLabel, QLineEdit, QListView, QMenu, QRadioButton, QSize,
|
||||||
|
QStringListModel, Qt, QTextBrowser, QVBoxLayout
|
||||||
|
)
|
||||||
|
|
||||||
from calibre.gui2 import error_dialog, question_dialog, gprefs
|
from calibre.gui2 import error_dialog, gprefs, question_dialog
|
||||||
from calibre.gui2.dialogs.confirm_delete import confirm
|
from calibre.gui2.dialogs.confirm_delete import confirm
|
||||||
from calibre.gui2.widgets import ComboBoxWithHelp
|
from calibre.gui2.widgets import ComboBoxWithHelp
|
||||||
from calibre.utils.icu import sort_key
|
from calibre.utils.icu import sort_key
|
||||||
from calibre.utils.search_query_parser import ParseException
|
|
||||||
from calibre.utils.localization import localize_user_manual_link
|
from calibre.utils.localization import localize_user_manual_link
|
||||||
|
from calibre.utils.search_query_parser import ParseException
|
||||||
|
|
||||||
|
|
||||||
class SelectNames(QDialog): # {{{
|
class SelectNames(QDialog): # {{{
|
||||||
@ -29,8 +30,9 @@ class SelectNames(QDialog): # {{{
|
|||||||
self.la = la = QLabel(_('Create a Virtual library based on %s') % txt)
|
self.la = la = QLabel(_('Create a Virtual library based on %s') % txt)
|
||||||
l.addWidget(la)
|
l.addWidget(la)
|
||||||
|
|
||||||
self._names = QListWidget(self)
|
self.model = QStringListModel(sorted(names, key=sort_key))
|
||||||
self._names.addItems(sorted(names, key=sort_key))
|
self._names = QListView(self)
|
||||||
|
self._names.setModel(self.model)
|
||||||
self._names.setSelectionMode(QAbstractItemView.SelectionMode.MultiSelection)
|
self._names.setSelectionMode(QAbstractItemView.SelectionMode.MultiSelection)
|
||||||
l.addWidget(self._names)
|
l.addWidget(self._names)
|
||||||
|
|
||||||
@ -49,8 +51,8 @@ class SelectNames(QDialog): # {{{
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def names(self):
|
def names(self):
|
||||||
for item in self._names.selectedItems():
|
for index in self._names.selectedIndexes():
|
||||||
yield str(item.data(Qt.ItemDataRole.DisplayRole) or '')
|
yield index.data(Qt.ItemDataRole.DisplayRole) or ''
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def match_type(self):
|
def match_type(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user