summaryrefslogtreecommitdiff
path: root/src/entryLayout.cpp
blob: 37f09a9494a39dec85015619911c00403ba5fd54 (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include <QLabel>

#include "entryLayout.h"

EntryLayout::EntryLayout(const Entry &e) :
	entry(e)
{
	QLabel *bullet = new QLabel();
	QLabel *body = new QLabel();

	// set styling
	this->setContentsMargins(2, 2, 2, 2);

	bullet->setFont(QFont("Arial", 11));
	bullet->setMaximumWidth(15);

	body->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse);
	body->setFont(QFont("Arial", 11));
	body->setWordWrap(true);
	body->setToolTip("Right-Click for actions");

	// Check rules
	// TODO

	// set conditional styling
	if(this->entry.done) {
		bullet->setText("\u2713");
		/*
		bullet->setStyleSheet(
				"QLabel {"
				"	color: green;"
				"}"
				);
		*/
	}
	else
		bullet->setText("- ");
	this->addWidget(bullet);

	if(!this->entry.due.isNull())
		body->setText(this->entry.due.toString("MM/dd/yyyy: "));
	else if(!this->entry.due_alt.isEmpty())
		body->setText(this->entry.due_alt + ": ");

	if(!this->entry.link.isEmpty()) {
		body->setOpenExternalLinks(true);
		body->setText(body->text() + "<a href=\"" + this->entry.link.toString() + "\" " "style=\"color: " + (this->entry.color.isEmpty() ? "default" : this->entry.color ) + ";\">");
	}
	body->setText(body->text() + this->entry.desc);
	if(!this->entry.link.isEmpty()) {
		body->setText(body->text() + "</a>");
		body->setToolTip(this->entry.link.toString());
	}

	if(this->entry.done) {
		QFont body_font = body->font();
		body_font.setStrikeOut(true);
		body->setFont(body_font);
		/*
		body->setStyleSheet(
				"QLabel {"
				"	color: green"
				"}"
				);
		*/
	}
	else {
		/*
		body->setStyleSheet(
				"QLabel {"
				"	color: " + (this->color.isEmpty() ? "default" : this->color) + ";"
				"	background-color: " + (this->highlight.isEmpty() ? "none" : this->highlight) + ";"
				"	font-weight: " + (this->due.isValid() && this->due <= QDateTime::currentDateTime() ? "bold" : "normal") + ";"
				";"
				);
		*/
	}
	this->addWidget(body);
}