From b4ca417b7e02f7cabba6689dc63eb7b733164fdf Mon Sep 17 00:00:00 2001 From: Louie S Date: Mon, 18 Sep 2023 14:31:14 -0400 Subject: rules working --- src/entry.py | 12 +++++++++++- src/main.py | 6 +++--- src/rule.py | 4 ++++ 3 files changed, 18 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/entry.py b/src/entry.py index 2a50cfd..6201667 100644 --- a/src/entry.py +++ b/src/entry.py @@ -1,7 +1,8 @@ from datetime import date -from PyQt5.QtCore import Qt +from PyQt5.QtCore import QDate, Qt from PyQt5.QtGui import QFont from PyQt5.QtWidgets import QHBoxLayout, QLabel +import src.globals as Globals class Entry: def __init__(self, id, parent_id, desc, due = "", due_alt = "", link = "", color = "", highlight = "", done = False, hidden = False): @@ -28,6 +29,15 @@ class Entry: body.setWordWrap(True) body.setToolTip("Right-Click for actions") + # Check rules + relevant_rules = list(filter(lambda r: r.entry_id == self.id, Globals.rules)) + for r in relevant_rules: + if (r.when.lower() == "before" and r.date > QDate.currentDate()) or (r.when.lower() == "after" and r.date <= QDate.currentDate()): + if r.color: + self.color = r.color + if r.highlight: + self.highlight = r.highlight + if self.done: bullet.setText("\u2713 ") bullet.setStyleSheet(""" diff --git a/src/main.py b/src/main.py index 008e310..fed6830 100644 --- a/src/main.py +++ b/src/main.py @@ -186,9 +186,9 @@ class AssignmentList(QMainWindow): def editRules(self, id): pass - need_redraw = RulesDialog(id) - if need_redraw: - self.drawGroups() + need_reload = RulesDialog(id) + if need_reload: + self.reload() def entryContextMenu(self, entry_id): menu = QMenu() diff --git a/src/rule.py b/src/rule.py index 6ecf7d7..414ccf0 100644 --- a/src/rule.py +++ b/src/rule.py @@ -30,11 +30,15 @@ class Rule: # TODO Consider making this a color selector widget color_widget = QLineEdit() color_widget.setPlaceholderText("Color") + if self.color: + color_widget.setText(self.color) output.addWidget(color_widget) # TODO Consider making this a color selector widget highlight_widget = QLineEdit() highlight_widget.setPlaceholderText("Highlight") + if self.highlight: + highlight_widget.setText(self.highlight) output.addWidget(highlight_widget) return output -- cgit