summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xassignment-list.py44
-rw-r--r--entry.py33
2 files changed, 61 insertions, 16 deletions
diff --git a/assignment-list.py b/assignment-list.py
index 6c9cfbd..673a209 100755
--- a/assignment-list.py
+++ b/assignment-list.py
@@ -93,13 +93,6 @@ class AssignmentList(QMainWindow):
self.create_edit_group_dialog = editGroupForm(id)
self.drawGroups()
- def editEntry(self, id):
- """
- Open the 'editEntry' form
- """
- self.create_edit_entry_dialog = editEntryForm(id)
- self.drawGroups()
-
def removeGroup(self, id):
"""
Delete a group with a given id
@@ -121,6 +114,27 @@ class AssignmentList(QMainWindow):
if old_count != len(Globals.entries):
self.drawGroups() # TODO see if we can do this with only redrawing a single group
+ def editEntry(self, id):
+ """
+ Open the 'editEntry' form
+ """
+ self.create_edit_entry_dialog = editEntryForm(id)
+ self.drawGroups()
+
+ def toggleDoneEntry(self, id):
+ """
+ Toggle the 'done' flag on the entry with the given id
+ """
+ entry = list(filter(lambda e: e.id == id, Globals.entries))[0]
+ if entry.done:
+ entry.done = False
+ else:
+ entry.done = True
+ DB.updateEntry(entry)
+ Globals.entries = list(filter(lambda e: e.id != id, Globals.entries))
+ Globals.entries.append(entry)
+ self.drawGroups()
+
def removeEntry(self, id):
"""
Delete an entry with a given id
@@ -147,6 +161,12 @@ class AssignmentList(QMainWindow):
recursiveClear(self.groups_hbox)
+ # Sort the groups
+ Globals.groups = sorted(Globals.groups, key=lambda g: g.id)
+
+ # Sort the entries (by due_date for now)
+ Globals.entries = sorted(Globals.entries, key=lambda e: (e.parent_id, e.due, e.id))
+
# Create columns as vertical boxes
column_left = QVBoxLayout()
column_right = QVBoxLayout()
@@ -208,7 +228,7 @@ class AssignmentList(QMainWindow):
if e.hidden:
continue
- entries_vbox.addWidget(e.buildLayout())
+ entries_vbox.addLayout(e.buildLayout())
# entry modifier buttons
buttons_hbox = QHBoxLayout()
@@ -218,6 +238,14 @@ class AssignmentList(QMainWindow):
edit_entry_button.clicked.connect((lambda id: lambda: self.editEntry(id))(e.id))
buttons_hbox.addWidget(edit_entry_button)
+ mark_done_button = QPushButton()
+ if e.done:
+ mark_done_button.setText("Not Done")
+ else:
+ mark_done_button.setText("Done")
+ mark_done_button.clicked.connect((lambda id: lambda: self.toggleDoneEntry(id))(e.id))
+ buttons_hbox.addWidget(mark_done_button)
+
del_entry_button = QPushButton()
del_entry_button.setText("Remove Entry")
del_entry_button.clicked.connect((lambda id: lambda: self.removeEntry(id))(e.id))
diff --git a/entry.py b/entry.py
index df3f566..261a32c 100644
--- a/entry.py
+++ b/entry.py
@@ -1,7 +1,6 @@
-import time
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QFont
-from PyQt5.QtWidgets import QLabel
+from PyQt5.QtWidgets import QHBoxLayout, QLabel
class Entry:
def __init__(self, id, parent_id, desc, due = "", due_alt = "", link = "", done = False, hidden = False):
@@ -15,13 +14,31 @@ class Entry:
self.hidden = hidden
def buildLayout(self):
- output = QLabel()
- output.setTextInteractionFlags(Qt.TextSelectableByMouse)
- output.setFont(QFont("Arial", 11))
+ output = QHBoxLayout()
+ bullet = QLabel()
+ body = QLabel()
+
+ body.setTextInteractionFlags(Qt.TextSelectableByMouse)
+
+ bullet.setFont(QFont("Arial", 11))
+ body.setFont(QFont("Arial", 11))
+
+ if self.done:
+ bullet.setText("\u2713 ")
+ else:
+ bullet.setText("- ")
+ output.addWidget(bullet)
- output.setText("- ")
if(self.due):
- output.setText(output.text() + "{0}/{1}/{2}: ".format(self.due.month(), self.due.day(), self.due.year()))
- output.setText(output.text() + self.desc)
+ body.setText("{0}/{1}/{2}: ".format(self.due.month(), self.due.day(), self.due.year()))
+ body.setText(body.text() + self.desc)
+ output.addWidget(body)
+
+ output.addStretch()
+
+ if self.done:
+ font = body.font()
+ font.setStrikeOut(True)
+ body.setFont(font)
return output