summaryrefslogtreecommitdiff
path: root/entry.py
blob: 261a32ce29f787da7c74af893cc9ca1021897e62 (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
41
42
43
44
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QFont
from PyQt5.QtWidgets import QHBoxLayout, QLabel

class Entry:
    def __init__(self, id, parent_id, desc, due = "", due_alt = "", link = "", done = False, hidden = False):
        self.id = id
        self.parent_id = parent_id
        self.desc = desc
        self.due = due
        self.due_alt = due_alt
        self.link = link
        self.done = done
        self.hidden = hidden

    def buildLayout(self):
        output = QHBoxLayout()
        bullet = QLabel()
        body = QLabel()

        body.setTextInteractionFlags(Qt.TextSelectableByMouse)

        bullet.setFont(QFont("Arial", 11))
        body.setFont(QFont("Arial", 11))

        if self.done:
            bullet.setText("\u2713 ")
        else:
            bullet.setText("- ")
        output.addWidget(bullet)

        if(self.due):
            body.setText("{0}/{1}/{2}: ".format(self.due.month(), self.due.day(), self.due.year()))
        body.setText(body.text() + self.desc)
        output.addWidget(body)

        output.addStretch()

        if self.done:
            font = body.font()
            font.setStrikeOut(True)
            body.setFont(font)

        return output