summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/assignmentList.cpp15
-rw-r--r--src/assignmentList.h4
2 files changed, 18 insertions, 1 deletions
diff --git a/src/assignmentList.cpp b/src/assignmentList.cpp
index ef040a8..909b023 100644
--- a/src/assignmentList.cpp
+++ b/src/assignmentList.cpp
@@ -71,6 +71,9 @@ void AssignmentList::displayWidgets() {
QList<Group *> groups = BackendDB::loadGroups();
int i;
+ // clear out old layouts if they exist
+ this->recursiveClear(ui.groups_layout);
+
for(i = 0; i < groups.size(); ++i) {
if(groups[i]->hidden) continue;
// TODO set right click behavior
@@ -89,7 +92,8 @@ void AssignmentList::displayWidgets() {
// Open the 'addGroup' form
void AssignmentList::addGroup() {
AddGroupForm create_new_group_dialog;
- create_new_group_dialog.exec();
+ if(create_new_group_dialog.exec() == QDialog::Accepted)
+ this->displayWidgets();
}
// Open the 'editGroup; form
@@ -113,3 +117,12 @@ void AssignmentList::aboutDialog() {
QMessageBox about;
about.about(this, "About Assignment List", "Created by Louie S. - 2023");
}
+
+void AssignmentList::recursiveClear(QLayout *layout) {
+ QLayoutItem *child;
+ while((child = layout->takeAt(0)) != nullptr) {
+ if(child->layout()) this->recursiveClear(child->layout());
+ delete child->widget();
+ delete child;
+ }
+}
diff --git a/src/assignmentList.h b/src/assignmentList.h
index 6544dd0..c21ca15 100644
--- a/src/assignmentList.h
+++ b/src/assignmentList.h
@@ -33,6 +33,10 @@ class AssignmentList : public QMainWindow {
void drawGroups();
void drawEntries();
+ // helpers
+ // used to clear out the grid layout when a refresh occurs
+ void recursiveClear(QLayout *layout);
+
private slots:
void preferences();
void reload();