From 9852a0ec1b73e1bce0c3f77743b426b29550e01c Mon Sep 17 00:00:00 2001 From: Louie S Date: Thu, 29 Feb 2024 16:59:11 -0500 Subject: Add refresh after adding group --- src/assignmentList.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/assignmentList.cpp') 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 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; + } +} -- cgit