summaryrefslogtreecommitdiff
path: root/src/frontend/qtwidgets/editEntryForm.cpp
diff options
context:
space:
mode:
authorLouie S <louie@example.com>2024-07-23 20:37:48 -0400
committerLouie S <louie@example.com>2024-07-23 20:37:48 -0400
commitc34930425fadfc4083067b9306159cd8e8ecf6c6 (patch)
treed9c09709f1b9cf7e9bcf098d48c7036044098a7d /src/frontend/qtwidgets/editEntryForm.cpp
parentf820f439910ef0243e6b9aded293190341b058ac (diff)
Rearrange source file locations
Diffstat (limited to 'src/frontend/qtwidgets/editEntryForm.cpp')
-rw-r--r--src/frontend/qtwidgets/editEntryForm.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/frontend/qtwidgets/editEntryForm.cpp b/src/frontend/qtwidgets/editEntryForm.cpp
new file mode 100644
index 0000000..ca788ca
--- /dev/null
+++ b/src/frontend/qtwidgets/editEntryForm.cpp
@@ -0,0 +1,55 @@
+#include <QMessageBox>
+
+#include "../../backend/db_sqlite.h"
+#include "editEntryForm.h"
+
+EditEntryForm::EditEntryForm(const Entry &e) :
+ entry(e)
+{
+ // load uic
+ ui.setupUi(this);
+
+ // set titles
+ this->setWindowTitle("Edit Entry");
+ ui.title->setText("Edit Entry");
+
+ // widgets setup
+ ui.entry_desc->setText(this->entry.desc);
+ ui.entry_due->setDate(QDate::currentDate());
+ if(this->entry.due.isValid()) {
+ ui.entry_due->setDate(entry.due.date());
+ ui.entry_due_checkbox->setChecked(true);
+ }
+ else
+ ui.entry_due_checkbox->setChecked(false);
+ ui.entry_due_alt->setText(this->entry.due_alt);
+ ui.entry_link->setText(this->entry.link.toString());
+ ui.entry_color->setText(this->entry.color);
+ ui.entry_highlight->setText(this->entry.highlight);
+}
+
+void EditEntryForm::accept() {
+ this->entry.desc = ui.entry_desc->text();
+ if(ui.entry_due_checkbox->isChecked())
+ this->entry.due = ui.entry_due->dateTime();
+ else
+ this->entry.due = QDateTime();
+ this->entry.due_alt = ui.entry_due_alt->text();
+ this->entry.link = ui.entry_link->text();
+ this->entry.color = ui.entry_color->text();
+ this->entry.highlight = ui.entry_highlight->text();
+ QMessageBox error_message;
+ BackendDB database;
+
+ if(this->entry.desc.isEmpty()) {
+ error_message.setIcon(QMessageBox::Warning);
+ error_message.setWindowTitle("Error Message");
+ error_message.setText("Name cannot be blank");
+ error_message.exec();
+ return;
+ }
+
+ database.updateEntry(this->entry);
+
+ QDialog::accept();
+}