From 6c9d7e079cceade194b5faa6c65e98920be697ef Mon Sep 17 00:00:00 2001 From: Louie S Date: Fri, 15 Mar 2024 16:35:30 -0400 Subject: sorting implemented; functionality is now matching pyqt version --- src/rulesDialog.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/rulesDialog.cpp') diff --git a/src/rulesDialog.cpp b/src/rulesDialog.cpp index be8b9d3..7d5705e 100644 --- a/src/rulesDialog.cpp +++ b/src/rulesDialog.cpp @@ -32,10 +32,10 @@ void RulesDialog::updateRulesList() { int i; for(i = 0; i < ui.rules_layout->children().size(); ++i) { - this->rules[i]->when = Rule::When(qobject_cast(ui.rules_layout->children()[i])->when_widget->currentIndex()); - this->rules[i]->date = qobject_cast(ui.rules_layout->children()[i])->date_widget->dateTime(); - this->rules[i]->color = qobject_cast(ui.rules_layout->children()[i])->color_widget->text(); - this->rules[i]->highlight = qobject_cast(ui.rules_layout->children()[i])->highlight_widget->text(); + this->rules[i].when = Rule::When(qobject_cast(ui.rules_layout->children()[i])->when_widget->currentIndex()); + this->rules[i].date = qobject_cast(ui.rules_layout->children()[i])->date_widget->dateTime(); + this->rules[i].color = qobject_cast(ui.rules_layout->children()[i])->color_widget->text(); + this->rules[i].highlight = qobject_cast(ui.rules_layout->children()[i])->highlight_widget->text(); } } @@ -49,7 +49,7 @@ void RulesDialog::drawRules() { // Draw each rule for(i = 0; i < this->rules.size(); ++i) { - new_layout = new RuleLayout(*rules[i]); + new_layout = new RuleLayout(rules[i]); // connect delete button QObject::connect(new_layout->del_button, &QPushButton::released, this, [=](){ this->deleteRule(i); }); @@ -59,8 +59,8 @@ void RulesDialog::drawRules() { } void RulesDialog::addRule() { - Rule *new_rule = new Rule(0, this->entry_id, Rule::before); - RuleLayout *new_layout = new RuleLayout(*new_rule); + Rule new_rule = Rule(0, this->entry_id, Rule::before); + RuleLayout *new_layout = new RuleLayout(new_rule); // add new rule to the member variable this->rules.append(new_rule); @@ -76,8 +76,8 @@ void RulesDialog::deleteRule(int i) { this->updateRulesList(); // mark as needing to be deleted from database if id > 0 - if(this->rules[i]->id > 0) - this->deleted_rules.append(*this->rules[i]); + if(this->rules[i].id > 0) + this->deleted_rules.append(this->rules[i]); this->rules.removeAt(i); this->drawRules(); } @@ -91,11 +91,11 @@ void RulesDialog::accept() { // update rules in database for(i = 0; i < this->rules.size(); ++i) { // insert - this is a new rule - if(this->rules[i]->id == 0) - database.insertRule(*this->rules[i]); + if(this->rules[i].id == 0) + database.insertRule(this->rules[i]); // update - this is an existing rule else - database.updateRule(*this->rules[i]); + database.updateRule(this->rules[i]); } // delete deleted rules in database -- cgit