This commit is contained in:
Christopher T. Johnson
2025-02-27 13:44:45 -05:00
parent 69fa955be1
commit 71b0a6a112
3 changed files with 27 additions and 15 deletions

View File

@@ -241,7 +241,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.loadButton.clicked.connect(self.loadCases) self.loadButton.clicked.connect(self.loadCases)
self.update_status.connect(self.statusBarUpdate) self.update_status.connect(self.statusBarUpdate)
self.update_status.emit() self.update_status.emit()
self.docketLabel.setText('') self.docketLabel.setText("")
return return
def closeEvent(self, event: QCloseEvent) -> None: def closeEvent(self, event: QCloseEvent) -> None:

View File

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

View File

@@ -35,8 +35,9 @@ def main() -> int:
updateDatabase(settings) updateDatabase(settings)
db = QSqlDatabase.addDatabase("QMYSQL") db = QSqlDatabase.addDatabase("QMYSQL")
db.setHostName(settings.value("hostname")) db.setHostName(settings.value("hostname"))
portStr = cast(str, settings.value("port", "3306")) port = settings.value("port", "3306")
db.setPort(int(portStr)) assert isinstance(port, str)
db.setPort(int(port))
db.setDatabaseName(settings.value("databasename", "scotus")) # type: ignore db.setDatabaseName(settings.value("databasename", "scotus")) # type: ignore
db.setUserName(settings.value("user", "scotus")) # type: ignore db.setUserName(settings.value("user", "scotus")) # type: ignore
db.setPassword(settings.value("password")) db.setPassword(settings.value("password"))