Lint
This commit is contained in:
@@ -13,7 +13,7 @@ from PySide6.QtCore import (
|
||||
QUrl,
|
||||
Signal,
|
||||
Slot,
|
||||
)
|
||||
)
|
||||
from PySide6.QtGui import (
|
||||
QMouseEvent,
|
||||
QPainter,
|
||||
@@ -58,23 +58,31 @@ class docketEntryDelegate(QStyledItemDelegate):
|
||||
doc.setTextWidth(options.rect.width())
|
||||
return QSize(int(doc.idealWidth()), int(doc.size().height()))
|
||||
|
||||
def paint(self, painter: QPainter, option: QStyleOptionViewItem, index: QModelIndex | QPersistentModelIndex) -> None:
|
||||
def paint(
|
||||
self,
|
||||
painter: QPainter,
|
||||
option: QStyleOptionViewItem,
|
||||
index: QModelIndex | QPersistentModelIndex,
|
||||
) -> None:
|
||||
options = cast(QStyleOptionViewItemInit, option)
|
||||
self.initStyleOption(options, index)
|
||||
painter.save()
|
||||
|
||||
|
||||
doc = QTextDocument()
|
||||
doc.setHtml(options.text)
|
||||
doc.setTextWidth(options.rect.width())
|
||||
|
||||
options.text = ''
|
||||
options.widget.style().drawControl(QStyle.ControlElement.CE_ItemViewItem, options, painter)
|
||||
options.text = ""
|
||||
options.widget.style().drawControl(
|
||||
QStyle.ControlElement.CE_ItemViewItem, options, painter
|
||||
)
|
||||
painter.translate(options.rect.left(), options.rect.top())
|
||||
clip = QRect(0,0, options.rect.width(), options.rect.height())
|
||||
clip = QRect(0, 0, options.rect.width(), options.rect.height())
|
||||
doc.drawContents(painter, clip)
|
||||
painter.restore()
|
||||
return
|
||||
|
||||
|
||||
|
||||
class docketTableView(QTableView):
|
||||
|
||||
manager: QNetworkAccessManager
|
||||
@@ -138,16 +146,19 @@ class docketTableView(QTableView):
|
||||
# We need to map our click position to a position within the cell.
|
||||
#
|
||||
pos = event.position()
|
||||
new_pos = QPointF(pos.x() - self.horizontalScrollBar().value(),
|
||||
pos.y() - self.verticalScrollBar().value())
|
||||
new_pos = QPointF(
|
||||
pos.x() - self.horizontalScrollBar().value(),
|
||||
pos.y() - self.verticalScrollBar().value(),
|
||||
)
|
||||
rowHeight = 0
|
||||
for row in range(0, index.row()):
|
||||
rowHeight += self.rowHeight(row)
|
||||
cell_pos = QPointF(new_pos.x() - self.columnWidth(0),
|
||||
new_pos.y() - rowHeight)
|
||||
cell_pos = QPointF(
|
||||
new_pos.x() - self.columnWidth(0), new_pos.y() - rowHeight
|
||||
)
|
||||
te = QTextEdit()
|
||||
te.setDocument(doc)
|
||||
anchor = te.anchorAt(cell_pos.toPoint())
|
||||
if anchor:
|
||||
self.anchorSignal.emit(index,anchor)
|
||||
self.anchorSignal.emit(index, anchor)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user