mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 18:24:30 -04:00
Use italic font for book titles
This commit is contained in:
parent
53da2ebd54
commit
282a9a2b63
@ -9,8 +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, QHBoxLayout, QIcon,
|
QAbstractItemModel, QCheckBox, QDialog, QDialogButtonBox, QFont, QHBoxLayout,
|
||||||
QModelIndex, QPushButton, QSize, Qt, QTreeView, QVBoxLayout, QWidget, pyqtSignal
|
QIcon, QModelIndex, QPushButton, QSize, Qt, QTreeView, QVBoxLayout, QWidget,
|
||||||
|
pyqtSignal
|
||||||
)
|
)
|
||||||
from threading import Event, Thread
|
from threading import Event, Thread
|
||||||
|
|
||||||
@ -89,6 +90,8 @@ class ResultsModel(QAbstractItemModel):
|
|||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
|
self.italic_font = parent.font() if parent else QFont()
|
||||||
|
self.italic_font.setItalic(True)
|
||||||
self.results = []
|
self.results = []
|
||||||
self.query_id_counter = count()
|
self.query_id_counter = count()
|
||||||
self.current_query_id = -1
|
self.current_query_id = -1
|
||||||
@ -212,11 +215,21 @@ class ResultsModel(QAbstractItemModel):
|
|||||||
return self.data_for_book(item, role)
|
return self.data_for_book(item, role)
|
||||||
return self.data_for_match(item, role)
|
return self.data_for_match(item, role)
|
||||||
|
|
||||||
|
def flags(self, index):
|
||||||
|
item = self.index_to_entry(index)
|
||||||
|
if item is None:
|
||||||
|
return 0
|
||||||
|
if isinstance(item, Results):
|
||||||
|
return Qt.ItemFlag.ItemIsEnabled
|
||||||
|
return Qt.ItemFlag.ItemIsSelectable | Qt.ItemFlag.ItemIsEnabled | Qt.ItemFlag.ItemNeverHasChildren
|
||||||
|
|
||||||
def data_for_book(self, item, role):
|
def data_for_book(self, item, role):
|
||||||
if role == Qt.ItemDataRole.DisplayRole:
|
if role == Qt.ItemDataRole.DisplayRole:
|
||||||
return item.title
|
return item.title
|
||||||
if role == Qt.ItemDataRole.UserRole:
|
if role == Qt.ItemDataRole.UserRole:
|
||||||
return item
|
return item
|
||||||
|
if role == Qt.ItemDataRole.FontRole:
|
||||||
|
return self.italic_font
|
||||||
|
|
||||||
def data_for_match(self, item, role):
|
def data_for_match(self, item, role):
|
||||||
if role == Qt.ItemDataRole.UserRole:
|
if role == Qt.ItemDataRole.UserRole:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user