People edit and improved Session
This commit is contained in:
49
main.py
49
main.py
@@ -1,10 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# TODO:
|
||||
# Start/Stop Session
|
||||
# Record all words examined
|
||||
# Record all words defined after start session
|
||||
# Record paragraph start and stop
|
||||
#
|
||||
# Add definition to definition
|
||||
# Follow definition links
|
||||
@@ -60,11 +57,12 @@ def query_error(query: QSqlQuery) -> None:
|
||||
)
|
||||
raise Exception("SQL Error")
|
||||
|
||||
|
||||
class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
def __init__(self) -> None:
|
||||
super(MainWindow, self).__init__()
|
||||
self.setupUi(self)
|
||||
#model = ModelOverride()
|
||||
# model = ModelOverride()
|
||||
model = QSqlQueryModel()
|
||||
query = QSqlQuery("SELECT * FROM people ORDER BY name")
|
||||
model.setQuery(query)
|
||||
@@ -76,16 +74,18 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
#
|
||||
# Action Connections
|
||||
#
|
||||
self.actionQuit.triggered.connect(self.close) # Y
|
||||
self.actionAddBook.triggered.connect(self.addBook) # Y
|
||||
self.actionEditBook.triggered.connect(self.editBook) # Y
|
||||
self.actionRead.triggered.connect(self.readBook) # Y
|
||||
self.actionQuit.triggered.connect(self.close) # Y
|
||||
self.actionAddBook.triggered.connect(self.addBook) # Y
|
||||
self.actionEditBook.triggered.connect(self.editBook) # Y
|
||||
self.actionRead.triggered.connect(self.readBook) # Y
|
||||
self.actionRead.enabledChanged.connect(self.readBtn.setEnabled)
|
||||
self.actionAddPerson.triggered.connect(self.addPerson) # Y
|
||||
self.actionEditPerson.triggered.connect(self.editPerson) # Y
|
||||
self.actionEditPerson.enabledChanged.connect(self.editBtn.setEnabled) # Y
|
||||
self.peopleView.doubleClicked.connect(self.editPerson) # Y
|
||||
self.peopleView.clicked.connect(self.selectedPerson) # Y
|
||||
self.actionAddPerson.triggered.connect(self.addPerson) # Y
|
||||
self.actionEditPerson.triggered.connect(self.editPerson) # Y
|
||||
self.actionEditPerson.enabledChanged.connect(
|
||||
self.editBtn.setEnabled
|
||||
) # Y
|
||||
self.peopleView.doubleClicked.connect(self.editPerson) # Y
|
||||
self.peopleView.clicked.connect(self.selectedPerson) # Y
|
||||
self.show()
|
||||
return
|
||||
|
||||
@@ -99,10 +99,9 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
else:
|
||||
self.actionRead.setEnabled(True)
|
||||
return
|
||||
|
||||
|
||||
@pyqtSlot(bool)
|
||||
def enablePerson(self, flag: bool) -> None:
|
||||
|
||||
if flag:
|
||||
self.editBtn.setEnabled(False)
|
||||
self.readBtn.setEnabled(False)
|
||||
@@ -110,19 +109,27 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
self.editBtn.setEnabled(True)
|
||||
self.readBtn.setEnabled(True)
|
||||
return
|
||||
|
||||
|
||||
@pyqtSlot()
|
||||
def addPerson(self) -> None:
|
||||
dlg = PersonDialog()
|
||||
dlg.exec()
|
||||
model = self.peopleView.model()
|
||||
model.setQuery(model.query())
|
||||
return
|
||||
|
||||
@pyqtSlot()
|
||||
@pyqtSlot(QModelIndex)
|
||||
def editPerson(self, index = None ) -> None:
|
||||
print("Edit a person")
|
||||
def editPerson(self, index=None) -> None:
|
||||
if not index:
|
||||
indexes = self.peopleView.selectedIndexes()
|
||||
if len(indexes) < 1:
|
||||
return
|
||||
index = indexes[0]
|
||||
dlg = PersonDialog(person_id=index.siblingAtColumn(0).data())
|
||||
dlg.exec()
|
||||
return
|
||||
|
||||
|
||||
@pyqtSlot()
|
||||
def addBook(self) -> None:
|
||||
directory = QFileDialog.getExistingDirectory()
|
||||
@@ -133,6 +140,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
def editBook(self) -> None:
|
||||
print("Edit Book")
|
||||
return
|
||||
|
||||
session = None
|
||||
setPerson = pyqtSignal(int)
|
||||
|
||||
@@ -171,7 +179,8 @@ SQL_CMDS = [
|
||||
#
|
||||
"CREATE TABLE IF NOT EXISTS people "
|
||||
"(person_id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, "
|
||||
"organization TEXT, book_id INTEGER REFERENCES books ON DELETE CASCADE)",
|
||||
"organization TEXT, book_id INTEGER REFERENCES books ON DELETE CASCADE, "
|
||||
"email TEXT)",
|
||||
#
|
||||
"CREATE TABLE IF NOT EXISTS person_book "
|
||||
"(person_id INTEGER REFERENCES people ON DELETE CASCADE, "
|
||||
|
||||
Reference in New Issue
Block a user