summaryrefslogtreecommitdiff
path: root/src/rule.py
blob: 6ecf7d73af4995d5ce01435a632d7058b6057f51 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40

from PyQt5.QtCore import QDate
from PyQt5.QtWidgets import QComboBox, QDateTimeEdit, QHBoxLayout, QLineEdit


class Rule:
    def __init__(self, id, entry_id, when, date, color = "", highlight = ""):
        self.id = id
        self.entry_id = entry_id
        self.when = when
        self.date = date
        self.color = color
        self.highlight = highlight

    def buildLayout(self):
        output = QHBoxLayout()
        
        when_widget = QComboBox()
        when_widget.addItems(["Before", "After"])
        when_widget.setCurrentIndex(0 if self.when.lower() == "before" else 1)
        output.addWidget(when_widget)

        date_widget = QDateTimeEdit(QDate.currentDate())
        date_widget.setDisplayFormat("MM/dd/yyyy")
        date_widget.setDate(self.date)
        output.addWidget(date_widget)

        output.addStretch()

        # TODO Consider making this a color selector widget
        color_widget = QLineEdit()
        color_widget.setPlaceholderText("Color")
        output.addWidget(color_widget)

        # TODO Consider making this a color selector widget
        highlight_widget = QLineEdit()
        highlight_widget.setPlaceholderText("Highlight")
        output.addWidget(highlight_widget)

        return output