mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
use single selection mode for fts results
This commit is contained in:
parent
282a9a2b63
commit
571e2b695e
@ -9,9 +9,9 @@ import traceback
|
|||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
from itertools import count
|
from itertools import count
|
||||||
from qt.core import (
|
from qt.core import (
|
||||||
QAbstractItemModel, QCheckBox, QDialog, QDialogButtonBox, QFont, QHBoxLayout,
|
QAbstractItemModel, QAbstractItemView, QCheckBox, QDialog, QDialogButtonBox,
|
||||||
QIcon, QModelIndex, QPushButton, QSize, Qt, QTreeView, QVBoxLayout, QWidget,
|
QFont, QHBoxLayout, QIcon, QModelIndex, QPushButton, QSize, QSplitter, Qt,
|
||||||
pyqtSignal
|
QTreeView, QVBoxLayout, QWidget, pyqtSignal
|
||||||
)
|
)
|
||||||
from threading import Event, Thread
|
from threading import Event, Thread
|
||||||
|
|
||||||
@ -243,6 +243,7 @@ class ResultsView(QTreeView):
|
|||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
|
self.setSelectionMode(QAbstractItemView.SelectionMode.SingleSelection)
|
||||||
self.setHeaderHidden(True)
|
self.setHeaderHidden(True)
|
||||||
self.m = ResultsModel(self)
|
self.m = ResultsModel(self)
|
||||||
self.m.search_complete.connect(self.search_complete)
|
self.m.search_complete.connect(self.search_complete)
|
||||||
@ -324,21 +325,39 @@ class SearchInputPanel(QWidget):
|
|||||||
self.search_signal.emit(text)
|
self.search_signal.emit(text)
|
||||||
|
|
||||||
|
|
||||||
|
class DetailsPanel(QWidget):
|
||||||
|
|
||||||
|
def __init__(self, parent=None):
|
||||||
|
super().__init__(parent)
|
||||||
|
|
||||||
|
|
||||||
class ResultsPanel(QWidget):
|
class ResultsPanel(QWidget):
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
self.l = l = QVBoxLayout(self)
|
self.l = l = QVBoxLayout(self)
|
||||||
l.setContentsMargins(0, 0, 0, 0)
|
l.setContentsMargins(0, 0, 0, 0)
|
||||||
|
self.splitter = s = QSplitter(self)
|
||||||
|
s.setChildrenCollapsible(False)
|
||||||
|
l.addWidget(s)
|
||||||
|
|
||||||
|
self.cw = cw = QWidget(self)
|
||||||
|
s.addWidget(cw)
|
||||||
|
l = QVBoxLayout(cw)
|
||||||
self.sip = sip = SearchInputPanel(parent=self)
|
self.sip = sip = SearchInputPanel(parent=self)
|
||||||
l.addWidget(sip)
|
l.addWidget(sip)
|
||||||
self.results_view = rv = ResultsView(parent=self)
|
self.results_view = rv = ResultsView(parent=self)
|
||||||
l.addWidget(rv)
|
l.addWidget(rv)
|
||||||
|
rv.selectionModel().selectionChanged.connect(self.selection_changed)
|
||||||
self.search = rv.search
|
self.search = rv.search
|
||||||
rv.search_started.connect(self.sip.start)
|
rv.search_started.connect(self.sip.start)
|
||||||
rv.search_complete.connect(self.sip.stop)
|
rv.search_complete.connect(self.sip.stop)
|
||||||
sip.search_signal.connect(self.search)
|
sip.search_signal.connect(self.search)
|
||||||
|
|
||||||
|
def selection_changed(self):
|
||||||
|
for i in self.results_view.selectionModel().selectedIndexes():
|
||||||
|
print(i.data(Qt.ItemDataRole.UserRole))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
from calibre.gui2 import Application
|
from calibre.gui2 import Application
|
||||||
|
Loading…
x
Reference in New Issue
Block a user