diff options
author | Louie S <louie@example.com> | 2024-03-15 16:12:05 -0400 |
---|---|---|
committer | Louie S <louie@example.com> | 2024-03-15 16:12:05 -0400 |
commit | 4c2c8bc81df55ab2f0112d16bfd1a9d236b51e6d (patch) | |
tree | 1b44d7e3cf55d22582bd697dce792f7994d3f616 /src/entryLayout.cpp | |
parent | d732bd0f74225828455c5863444b0211faf586d0 (diff) |
Load and apply rules to entries
Diffstat (limited to 'src/entryLayout.cpp')
-rw-r--r-- | src/entryLayout.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/entryLayout.cpp b/src/entryLayout.cpp index 54aa5f8..349a102 100644 --- a/src/entryLayout.cpp +++ b/src/entryLayout.cpp @@ -14,6 +14,7 @@ EntryLayout::EntryLayout(const Entry &e) : { QLabel *bullet = new QLabel(); QLabel *body = new QLabel(); + int i; // set styling this->setContentsMargins(2, 2, 2, 2); @@ -34,7 +35,20 @@ EntryLayout::EntryLayout(const Entry &e) : SLOT(showContextMenu())); // Check rules - // TODO + QList<Rule *> rules = this->loadRules(); + for(i = 0; i < rules.size(); ++i) { + if( + (rules[i]->when == Rule::before && + rules[i]->date > QDateTime::currentDateTime()) || + (rules[i]->when == Rule::after && + rules[i]->date <= QDateTime::currentDateTime()) + ) { + if(!rules[i]->color.isEmpty()) + this->entry.color = rules[i]->color; + if(!rules[i]->highlight.isEmpty()) + this->entry.highlight = rules[i]->highlight; + } + } // set conditional styling if(this->entry.done) { @@ -87,6 +101,12 @@ EntryLayout::EntryLayout(const Entry &e) : this->addWidget(body); } +QList<Rule *> EntryLayout::loadRules() { + BackendDB database; + + return database.loadRules(this->entry.id); +} + void EntryLayout::showContextMenu() { QMenu menu; |