From afcae23cbf63b31a7ce111ffcd76c027b332bdf9 Mon Sep 17 00:00:00 2001 From: Louie S Date: Sat, 9 Mar 2024 16:53:38 -0500 Subject: Break entry/group/rule into sub-classes --- src/entryLayout.cpp | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 src/entryLayout.cpp (limited to 'src/entryLayout.cpp') diff --git a/src/entryLayout.cpp b/src/entryLayout.cpp new file mode 100644 index 0000000..37f09a9 --- /dev/null +++ b/src/entryLayout.cpp @@ -0,0 +1,79 @@ +#include + +#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() + "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() + ""); + 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); +} -- cgit