Move to chapter based reader
This commit is contained in:
16
main.py
16
main.py
@@ -2,6 +2,7 @@
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
from typing import cast
|
||||
|
||||
from PyQt6.QtCore import Qt, pyqtSlot
|
||||
from PyQt6.QtGui import (
|
||||
@@ -42,15 +43,13 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
model.setQuery(query)
|
||||
self.peopleView.setModel(model)
|
||||
self.peopleView.setModelColumn(1)
|
||||
# self.load_definition(word, PyDictionary.meaning(word))
|
||||
# self.wordButton.clicked.connect(self.wordAction)
|
||||
self.ReadButton.clicked.connect(self.readAction)
|
||||
self.bookBtn.clicked.connect(self.bookAction)
|
||||
self.createActions()
|
||||
self.show()
|
||||
return
|
||||
|
||||
def createActions(self):
|
||||
def createActions(self) -> None:
|
||||
query = QSqlQuery()
|
||||
query.prepare("SELECT * FROM books ORDER BY title")
|
||||
if not query.exec():
|
||||
@@ -63,11 +62,9 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
return
|
||||
|
||||
@pyqtSlot()
|
||||
def setBookAction(self):
|
||||
action = self.sender()
|
||||
print(action)
|
||||
def setBookAction(self) -> None:
|
||||
action = cast(QAction, self.sender())
|
||||
book_id = action.data()
|
||||
print(book_id)
|
||||
indexes = self.peopleView.selectedIndexes()
|
||||
if len(indexes) < 1:
|
||||
return
|
||||
@@ -164,8 +161,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
SQL_CMDS = [
|
||||
"PRAGMA foreign_keys=ON",
|
||||
"CREATE TABLE IF NOT EXISTS words "
|
||||
"(word_id INTEGER PRIMARY KEY AUTOINCREMENT, word TEXT, definition TEXT, "
|
||||
"translation TEXT)",
|
||||
"(word_id INTEGER PRIMARY KEY AUTOINCREMENT, word TEXT, definition TEXT)",
|
||||
"CREATE TABLE IF NOT EXISTS books "
|
||||
"(book_id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT, author TEXT, "
|
||||
"uuid TEXT, level INTEGER)",
|
||||
@@ -236,7 +232,7 @@ def schema_update(db: QSqlDatabase) -> None:
|
||||
if not query.exec(matches.group(1) + new_table_name + matches.group(3)):
|
||||
query_error(query)
|
||||
# step 5 transfer content
|
||||
coldefs = re.search(r"\((.+)\)", old).group(1).split(", ")
|
||||
coldefs = re.search(r"\((.+)\)", old).group(1).split(", ") # type: ignore[union-attr]
|
||||
cols = [x.split(" ")[0] for x in coldefs]
|
||||
if not query.exec(
|
||||
"INSERT INTO "
|
||||
|
||||
Reference in New Issue
Block a user