From 9c05cd5b5e9250f3cfd04a98370595db8ef8f697 Mon Sep 17 00:00:00 2001 From: Louie S Date: Wed, 28 Feb 2024 18:39:48 -0500 Subject: Working add_group_form --- src/add_group_form.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'src/add_group_form.cpp') diff --git a/src/add_group_form.cpp b/src/add_group_form.cpp index 5662208..75ecd29 100644 --- a/src/add_group_form.cpp +++ b/src/add_group_form.cpp @@ -1,30 +1,33 @@ #include +#include + #include "add_group_form.h" +#include "backend/db_sqlite.h" AddGroupForm::AddGroupForm() { // load uic ui.setupUi(this); - - // setup dialog button connections - QObject::connect(ui.buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); - QObject::connect(ui.buttonBox, &QDialogButtonBox::accepted, this, &AddGroupForm::handleSubmit); } -void AddGroupForm::handleSubmit() { +void AddGroupForm::accept() { QString name_text = ui.new_group_name->text(); QString column_text = ui.new_group_column->currentText(); QString link_text = ui.new_group_link->text(); QMessageBox error_message; + int new_id; if(name_text.isEmpty()) { + qDebug() << "Gets here"; error_message.setIcon(QMessageBox::Warning); error_message.setWindowTitle("Error Message"); error_message.setText("Name cannot be blank"); - error_message.setParent(this); - error_message.show(); + error_message.exec(); + return; } - // TODO insert into database - this->close(); + new_id = BackendDB::insertGroup(Group(0, name_text, column_text, link_text)); + // TODO redraw the main window + + QDialog::accept(); } -- cgit