diff options
author | Louie S <louie@example.com> | 2024-03-09 17:24:54 -0500 |
---|---|---|
committer | Louie S <louie@example.com> | 2024-03-09 17:24:54 -0500 |
commit | 10b83b465509d864d6946ef30f31ec0356fc78ff (patch) | |
tree | ff517783ad21ca98a5a1d710b2f62b8fb87fb0f3 | |
parent | afcae23cbf63b31a7ce111ffcd76c027b332bdf9 (diff) |
Edit group form skeleton
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/add_entry_form.cpp | 6 | ||||
-rw-r--r-- | src/add_entry_form.h | 5 | ||||
-rw-r--r-- | src/add_group_form.cpp | 4 | ||||
-rw-r--r-- | src/assignmentList.cpp | 2 | ||||
-rw-r--r-- | src/backend/db_sqlite.cpp | 2 | ||||
-rw-r--r-- | src/edit_entry_form.cpp | 2 | ||||
-rw-r--r-- | src/edit_entry_form.h | 2 | ||||
-rw-r--r-- | src/edit_group_form.cpp | 20 | ||||
-rw-r--r-- | src/edit_group_form.h | 25 | ||||
-rw-r--r-- | src/group.cpp | 2 | ||||
-rw-r--r-- | src/group.h | 5 | ||||
-rw-r--r-- | src/groupLayout.cpp | 7 |
13 files changed, 68 insertions, 16 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 2739256..d0009c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,6 +41,8 @@ set(project_sources "src/assignmentList.cpp" "src/assignmentList.h" "src/assignmentList.ui" + "src/edit_group_form.cpp" + "src/edit_group_form.h" "src/entry.cpp" "src/entry.h" "src/entryLayout.cpp" diff --git a/src/add_entry_form.cpp b/src/add_entry_form.cpp index 25a8af2..7c8e59d 100644 --- a/src/add_entry_form.cpp +++ b/src/add_entry_form.cpp @@ -5,8 +5,8 @@ #include "add_entry_form.h" #include "backend/db_sqlite.h" -AddEntryForm::AddEntryForm(int parent_id) : - parent_id(parent_id) +AddEntryForm::AddEntryForm(const Group &g) : + parent_group(g) { // load uic ui.setupUi(this); @@ -43,7 +43,7 @@ void AddEntryForm::accept() { if(!ui.entry_due_checkbox->isChecked()) due_text = QDateTime(); - new_id = database.insertEntry(Entry(0, this->parent_id, desc_text, due_text, due_alt_text, link_text, color_text, highlight_text)); + new_id = database.insertEntry(Entry(0, this->parent_group.id, desc_text, due_text, due_alt_text, link_text, color_text, highlight_text)); QDialog::accept(); } diff --git a/src/add_entry_form.h b/src/add_entry_form.h index 7cf1ad1..0aa6ea4 100644 --- a/src/add_entry_form.h +++ b/src/add_entry_form.h @@ -3,18 +3,19 @@ #include <QObject> +#include "group.h" #include "ui_entry_form.h" class AddEntryForm : public QDialog { Q_OBJECT public: - AddEntryForm(int parent_id); + AddEntryForm(const Group &g); private: Ui::entryDialog ui; - int parent_id; + Group parent_group; private slots: void accept(); diff --git a/src/add_group_form.cpp b/src/add_group_form.cpp index 98cdb63..8c799e2 100644 --- a/src/add_group_form.cpp +++ b/src/add_group_form.cpp @@ -16,7 +16,7 @@ AddGroupForm::AddGroupForm() { void AddGroupForm::accept() { QString name_text = ui.group_name->text(); - QString column_text = ui.group_column->currentText(); + Group::Column column_value = Group::Column(ui.group_column->currentIndex()); QString link_text = ui.group_link->text(); QMessageBox error_message; BackendDB database; @@ -31,7 +31,7 @@ void AddGroupForm::accept() { return; } - new_id = database.insertGroup(Group(0, name_text, column_text, link_text)); + new_id = database.insertGroup(Group(0, name_text, column_value, link_text)); QDialog::accept(); } diff --git a/src/assignmentList.cpp b/src/assignmentList.cpp index 15e6b47..32e6125 100644 --- a/src/assignmentList.cpp +++ b/src/assignmentList.cpp @@ -79,7 +79,7 @@ void AssignmentList::displayWidgets() { if(groups[i]->hidden) continue; new_group_layout = new GroupLayout(*groups[i]); new_group_layout->addLayout(this->drawEntries(groups[i]->id)); // add entries to layout - if(groups[i]->column.toLower() == "left") column_left->addLayout(new_group_layout); + if(groups[i]->column == Group::left) column_left->addLayout(new_group_layout); else column_right->addLayout(new_group_layout); } diff --git a/src/backend/db_sqlite.cpp b/src/backend/db_sqlite.cpp index f65cd8f..8a612a0 100644 --- a/src/backend/db_sqlite.cpp +++ b/src/backend/db_sqlite.cpp @@ -59,7 +59,7 @@ QList<Group *> BackendDB::loadGroups() { output.append(new Group( query.record().field("id").value().toInt(), query.record().field("name").value().toString(), - query.record().field("column").value().toString(), + Group::Column(query.record().field("column").value().toInt()), query.record().field("link").value().toString(), query.record().field("hidden").value().toBool())); } diff --git a/src/edit_entry_form.cpp b/src/edit_entry_form.cpp index 6a28b6f..68a29fe 100644 --- a/src/edit_entry_form.cpp +++ b/src/edit_entry_form.cpp @@ -2,7 +2,7 @@ #include "edit_entry_form.h" EditEntryForm::EditEntryForm(const Entry &e) : - e(e) + entry(e) { // load uic ui.setupUi(this); diff --git a/src/edit_entry_form.h b/src/edit_entry_form.h index e038175..6a10a40 100644 --- a/src/edit_entry_form.h +++ b/src/edit_entry_form.h @@ -16,7 +16,7 @@ class EditEntryForm : public QDialog { private: Ui::entryDialog ui; - Entry e; + Entry entry; private slots: void accept(); diff --git a/src/edit_group_form.cpp b/src/edit_group_form.cpp new file mode 100644 index 0000000..7f659d8 --- /dev/null +++ b/src/edit_group_form.cpp @@ -0,0 +1,20 @@ +#include "edit_group_form.h" + +EditGroupForm::EditGroupForm(const Group &g) : + group(g) +{ + // load uic + ui.setupUi(this); + + // set titles + this->setWindowTitle("Edit Group"); + ui.title->setText("Edit Group"); + + // widgets setup + ui.group_name->setText(this->group.name); + ui.group_column->setCurrentIndex(this->group.column); + ui.group_link->setText(this->group.link); +} + +void EditGroupForm::accept() { +} diff --git a/src/edit_group_form.h b/src/edit_group_form.h new file mode 100644 index 0000000..9b0112c --- /dev/null +++ b/src/edit_group_form.h @@ -0,0 +1,25 @@ +#ifndef EDITGROUPFORM_H +#define EDITGROUPFORM_H + +#include <QDialog> + +#include "group.h" +#include "ui_group_form.h" + +// form to edit/update a group +class EditGroupForm : public QDialog { + Q_OBJECT + + public: + EditGroupForm(const Group &g); + + private: + Ui::groupDialog ui; + + Group group; + + private slots: + void accept(); +}; + +#endif diff --git a/src/group.cpp b/src/group.cpp index d1c257f..61ecf2a 100644 --- a/src/group.cpp +++ b/src/group.cpp @@ -1,6 +1,6 @@ #include "group.h" -Group::Group(int id, QString name, QString column, QString link, bool hidden) : +Group::Group(int id, QString name, Group::Column column, QString link, bool hidden) : id(id), name(name), column(column), diff --git a/src/group.h b/src/group.h index ef23320..fe9158f 100644 --- a/src/group.h +++ b/src/group.h @@ -4,16 +4,17 @@ #include <QString> struct Group { + enum Column { left, right }; int id; QString name; - QString column; + Column column; QString link; bool hidden; Group( int id, QString name, - QString column = "left", + Column column = left, QString link = "", bool hidden = false ); diff --git a/src/groupLayout.cpp b/src/groupLayout.cpp index d2bc82a..3570623 100644 --- a/src/groupLayout.cpp +++ b/src/groupLayout.cpp @@ -5,6 +5,7 @@ #include <QDebug> #include "add_entry_form.h" +#include "edit_group_form.h" #include "groupLayout.h" #include "lib.h" @@ -48,13 +49,15 @@ void GroupLayout::showContextMenu() { } void GroupLayout::addEntry() { - AddEntryForm create_new_entry_dialog(this->group.id); + AddEntryForm create_new_entry_dialog(this->group); if(create_new_entry_dialog.exec() == QDialog::Accepted) getMainWindow()->displayWidgets(); } void GroupLayout::editGroup() { - qDebug() << "WIP"; + EditGroupForm edit_group_dialog(this->group); + if(edit_group_dialog.exec() == QDialog::Accepted) + getMainWindow()->displayWidgets(); } void GroupLayout::removeGroup() { |