Lint picking
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from datetime import datetime, timedelta
|
||||
from typing import Optional, cast
|
||||
|
||||
from PyQt6.QtCore import QModelIndex, Qt, QTime, QTimer, pyqtSignal, pyqtSlot
|
||||
from PyQt6.QtGui import (
|
||||
@@ -11,7 +12,7 @@ from PyQt6.QtGui import (
|
||||
QTextDocument,
|
||||
)
|
||||
from PyQt6.QtSql import QSqlQuery
|
||||
from PyQt6.QtWidgets import QDialog
|
||||
from PyQt6.QtWidgets import QCheckBox, QDialog, QListView, QMessageBox
|
||||
|
||||
from main import query_error
|
||||
from ui.SessionDialog import Ui_Dialog
|
||||
@@ -25,7 +26,7 @@ class SessionDialog(QDialog, Ui_Dialog):
|
||||
|
||||
timer = QTimer()
|
||||
startTime = datetime.now()
|
||||
totalTime = 0 # seconds
|
||||
totalTime = timedelta(seconds=0)
|
||||
sessionStart = None
|
||||
sessionEnd = None
|
||||
blocks = QStandardItemModel()
|
||||
@@ -49,8 +50,11 @@ class SessionDialog(QDialog, Ui_Dialog):
|
||||
flag = index.data(SessionDialog.WordImportantRole)
|
||||
flag = 1 - flag
|
||||
model = index.model()
|
||||
assert model is not None
|
||||
model = cast(QStandardItemModel, model)
|
||||
model.setData(index, flag, SessionDialog.WordImportantRole)
|
||||
item = model.itemFromIndex(index)
|
||||
assert item is not None
|
||||
if flag:
|
||||
item.setForeground(Qt.GlobalColor.red)
|
||||
else:
|
||||
@@ -62,13 +66,13 @@ class SessionDialog(QDialog, Ui_Dialog):
|
||||
@pyqtSlot()
|
||||
def resetForm(self) -> None:
|
||||
self.nameLbl.setText("")
|
||||
self.totalTime = timedelta()
|
||||
self.totalTime = timedelta(seconds=0)
|
||||
self.wordView.model().clear()
|
||||
self.textBrowser.document().clear()
|
||||
return
|
||||
|
||||
@pyqtSlot(int)
|
||||
def setPerson(self, person_id) -> None:
|
||||
def setPerson(self, person_id: int) -> None:
|
||||
self.resetForm()
|
||||
self.person_id = person_id
|
||||
query = QSqlQuery()
|
||||
@@ -79,12 +83,12 @@ class SessionDialog(QDialog, Ui_Dialog):
|
||||
if not query.next():
|
||||
raise Exception(f"Bad person_id: {person_id}")
|
||||
self.nameLbl.setText(query.value("name"))
|
||||
self.totalTime = timedelta()
|
||||
self.totalTime = timedelta(seconds=0)
|
||||
self.wordView.model().clear()
|
||||
return
|
||||
|
||||
@pyqtSlot()
|
||||
def rejected(self) -> None:
|
||||
def rejected(self): # type: ignore[no-untyped-def]
|
||||
msg = QMessageBox()
|
||||
msg.setText("There is unsaved data.")
|
||||
msg.setInformativeText("Do you want to save the session?")
|
||||
@@ -100,7 +104,7 @@ class SessionDialog(QDialog, Ui_Dialog):
|
||||
super().reject()
|
||||
return
|
||||
self.accept()
|
||||
self.done()
|
||||
self.done(QDialog.DialogCode.Accepted)
|
||||
return
|
||||
|
||||
@pyqtSlot()
|
||||
@@ -164,7 +168,8 @@ class SessionDialog(QDialog, Ui_Dialog):
|
||||
|
||||
@pyqtSlot()
|
||||
def tickAction(self) -> None:
|
||||
delta = self.totalTime + (datetime.now() - self.startTime)
|
||||
td = datetime.now() - self.startTime
|
||||
delta = self.totalTime + td
|
||||
seconds = delta.seconds % 60
|
||||
minutes = int(delta.seconds / 60) % 60
|
||||
hours = int(delta.seconds / 3600)
|
||||
@@ -211,7 +216,7 @@ class SessionDialog(QDialog, Ui_Dialog):
|
||||
return
|
||||
|
||||
@pyqtSlot(int, int)
|
||||
def addBlock(self, section_id, block) -> None:
|
||||
def addBlock(self, section_id: int, block: int) -> None:
|
||||
if not self.activeBox.isChecked():
|
||||
return
|
||||
new_block = QStandardItem()
|
||||
@@ -265,5 +270,6 @@ class SessionDialog(QDialog, Ui_Dialog):
|
||||
#
|
||||
# End Slots
|
||||
#
|
||||
def isActive(self):
|
||||
return self.activeBox.isChecked()
|
||||
def isActive(self) -> bool:
|
||||
active: bool = self.activeBox.isChecked()
|
||||
return active
|
||||
|
||||
Reference in New Issue
Block a user