summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLouie S <louie@example.com>2024-02-29 16:59:11 -0500
committerLouie S <louie@example.com>2024-02-29 16:59:11 -0500
commit9852a0ec1b73e1bce0c3f77743b426b29550e01c (patch)
tree5c5d1ddf6c71674f36bfe8859eba30b692bed4c6 /src
parent9c05cd5b5e9250f3cfd04a98370595db8ef8f697 (diff)
Add refresh after adding group
Diffstat (limited to 'src')
-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();