From d8da9f85ea048037cebce5b037cc512e82952211 Mon Sep 17 00:00:00 2001 From: Louie S Date: Sat, 16 Sep 2023 09:36:14 -0400 Subject: Move entry-drawing implementation to assignment-list.py --- add_entry_form.py | 2 +- assignment-list.py | 18 +++++++++++++++--- group.py | 19 ------------------- 3 files changed, 16 insertions(+), 23 deletions(-) diff --git a/add_entry_form.py b/add_entry_form.py index 46a0c61..87f35db 100644 --- a/add_entry_form.py +++ b/add_entry_form.py @@ -50,7 +50,7 @@ class addEntryForm(QDialog): close_button.clicked.connect(self.close) buttons_h_box.addWidget(close_button) submit_button = QPushButton("Submit") - submit_button.clicked.connect(lambda: self.handleSubmit(parent)) # TODO connect this to a real method + submit_button.clicked.connect(lambda: self.handleSubmit(parent)) buttons_h_box.addWidget(submit_button) buttons_h_box.addStretch() diff --git a/assignment-list.py b/assignment-list.py index 7b9762c..a330956 100755 --- a/assignment-list.py +++ b/assignment-list.py @@ -143,8 +143,12 @@ class AssignmentList(QMainWindow): if g.hidden: continue - # Include buttons at the bottom to edit the group g_layout = g.buildLayout() + + # Draw entries belonging to this group + g_layout.addLayout(self.drawEntries(g.id)) + + # Include buttons at the bottom to edit the group buttons_hbox = QHBoxLayout() add_entry_button = QPushButton() @@ -178,11 +182,19 @@ class AssignmentList(QMainWindow): self.groups_hbox.addStretch() # Implementation should be moved here from group.py if possible - def drawEntries(self): + def drawEntries(self, group_id): """ Redraw the entries of a specific group """ - pass + entries = list(filter(lambda e: e.parent_id == group_id, Globals.entries)) + entries_vbox = QVBoxLayout() + entries_vbox.setContentsMargins(5, 0, 0, 0) + + for e in entries: + entries_vbox.addWidget(e.buildLayout()) + # TODO find a good way to add modifier buttons + + return entries_vbox def aboutDialog(self): QMessageBox.about(self, "About Assignment List", diff --git a/group.py b/group.py index df194b8..372a38e 100644 --- a/group.py +++ b/group.py @@ -22,23 +22,4 @@ class Group: name.setFont(name_font) output.addWidget(name) - entries = self.getEntriesFromGroup() - entries_vbox = QVBoxLayout() - entries_vbox.setContentsMargins(5, 0, 0, 0) - - for e in entries: - entries_vbox.addWidget(e.buildLayout()) - output.addLayout(entries_vbox) - - return output - - def getEntriesFromGroup(self): - """ - Retrieve this group's entries - """ - output = [] - for e in Globals.entries: - if e.parent_id == self.id: - output.append(e) - return output -- cgit