summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--add_entry_form.py14
-rw-r--r--db_sqlite.py12
-rw-r--r--edit_entry_form.py14
-rw-r--r--entry.py26
4 files changed, 53 insertions, 13 deletions
diff --git a/add_entry_form.py b/add_entry_form.py
index 495d1ab..a5cf7c2 100644
--- a/add_entry_form.py
+++ b/add_entry_form.py
@@ -44,10 +44,14 @@ class addEntryForm(QDialog):
entry_form_layout.addRow("Link:", self.new_entry_link)
# TODO:
- # color
- # highlight
# depends
+ self.new_entry_color = QLineEdit()
+ entry_form_layout.addRow("Color:", self.new_entry_color)
+
+ self.new_entry_highlight = QLineEdit()
+ entry_form_layout.addRow("Highlight:", self.new_entry_highlight)
+
# Submit and cancel buttons
buttons_h_box = QHBoxLayout()
buttons_h_box.addStretch()
@@ -71,6 +75,8 @@ class addEntryForm(QDialog):
due_text = self.new_entry_due.date() # due_text is a QDate
due_alt_text = self.new_entry_due_alt.text()
link_text = self.new_entry_link.text()
+ color_text = self.new_entry_color.text()
+ highlight_text = self.new_entry_highlight.text()
if not desc_text:
QMessageBox.warning(self, "Error Message",
@@ -79,8 +85,8 @@ class addEntryForm(QDialog):
QMessageBox.Close)
return
- new_id = DB.insertEntry(Entry(0, parent, desc_text, due_text, due_alt_text, link_text))
- Globals.entries.append(Entry(new_id, parent, desc_text, due_text, due_alt_text, link_text))
+ new_id = DB.insertEntry(Entry(0, parent, desc_text, due_text, due_alt_text, link_text, color_text, highlight_text))
+ Globals.entries.append(Entry(new_id, parent, desc_text, due_text, due_alt_text, link_text, color_text, highlight_text))
self.close()
if __name__ == "__main__":
diff --git a/db_sqlite.py b/db_sqlite.py
index 7fe2745..189ac57 100644
--- a/db_sqlite.py
+++ b/db_sqlite.py
@@ -58,6 +58,8 @@ def createTables():
due_date TEXT DEFAULT NULL,
alt_due_date VARCHAR(255) DEFAULT NULL,
link VARCHAR(255) DEFAULT NULL,
+ color VARCHAR(255) DEFAULT NULL,
+ highlight VARCHAR(255) DEFAULT NULL,
done TINYINT(1) DEFAULT FALSE,
hidden TINYINT(1) DEFAULT FALSE
)
@@ -108,6 +110,8 @@ def loadFromTables():
due_date,
record.field("alt_due_date").value(),
record.field("link").value(),
+ record.field("color").value(),
+ record.field("highlight").value(),
record.field("done").value(),
record.field("hidden").value()))
@@ -158,7 +162,7 @@ def insertEntry(new_entry):
query = QSqlQuery()
query.prepare("""
- INSERT INTO entries (parent_id, description, due_date, alt_due_date, link) VALUES (:p_id, :desc, :due, :alt_due, :link)
+ INSERT INTO entries (parent_id, description, due_date, alt_due_date, link, color, highlight) VALUES (:p_id, :desc, :due, :alt_due, :link, :color, :highlight)
""")
query.bindValue(":p_id", new_entry.parent_id)
query.bindValue(":desc", new_entry.desc)
@@ -171,6 +175,8 @@ def insertEntry(new_entry):
query.bindValue(":due", "")
query.bindValue(":alt_due", new_entry.due_alt)
query.bindValue(":link", new_entry.link)
+ query.bindValue(":color", new_entry.color)
+ query.bindValue(":highlight", new_entry.highlight)
success = query.exec_()
# DEBUG
#print(query.lastError().text())
@@ -230,6 +236,8 @@ def updateEntry(entry):
due_date = :due,
alt_due_date = :alt_due,
link = :link,
+ color = :color,
+ highlight = :highlight,
done = :done,
hidden = :hidden
WHERE id = :id
@@ -244,6 +252,8 @@ def updateEntry(entry):
query.bindValue(":due", "")
query.bindValue(":alt_due", entry.due_alt)
query.bindValue(":link", entry.link)
+ query.bindValue(":color", entry.color)
+ query.bindValue(":highlight", entry.highlight)
query.bindValue(":done", entry.done)
query.bindValue(":hidden", entry.hidden)
query.bindValue(":id", entry.id)
diff --git a/edit_entry_form.py b/edit_entry_form.py
index 9a30e1e..3e3503b 100644
--- a/edit_entry_form.py
+++ b/edit_entry_form.py
@@ -57,6 +57,14 @@ class editEntryForm(QDialog):
self.entry_link.setText(entry.link)
entry_form_layout.addRow("Link:", self.entry_link)
+ self.entry_color = QLineEdit()
+ self.entry_color.setText(entry.color)
+ entry_form_layout.addRow("Color:", self.entry_color)
+
+ self.entry_highlight = QLineEdit()
+ self.entry_highlight.setText(entry.highlight)
+ entry_form_layout.addRow("Highlight:", self.entry_highlight)
+
# Submit and cancel buttons
buttons_h_box = QHBoxLayout()
buttons_h_box.addStretch()
@@ -80,6 +88,8 @@ class editEntryForm(QDialog):
due_text = "" # due is unchecked
due_alt_text = self.entry_due_alt.text()
link_text = self.entry_link.text()
+ color_text = self.entry_color.text()
+ highlight_text = self.entry_highlight.text()
if not desc_text:
QMessageBox.warning(self, "Error Message",
@@ -94,11 +104,13 @@ class editEntryForm(QDialog):
entry.due = due_text
entry.due_alt = due_alt_text
entry.link = link_text
+ entry.color = color_text
+ entry.highlight = highlight_text
DB.updateEntry(entry)
# Update global variables
Globals.entries = list(filter(lambda e: e.id != self.id, Globals.entries))
- Globals.entries.append(Entry(self.id, entry.parent_id, desc_text, due_text, due_alt_text, link_text, entry.done, entry.hidden))
+ Globals.entries.append(Entry(self.id, entry.parent_id, desc_text, due_text, due_alt_text, link_text, color_text, highlight_text, entry.done, entry.hidden))
self.close()
if __name__ == "__main__":
diff --git a/entry.py b/entry.py
index 0254093..0ff173a 100644
--- a/entry.py
+++ b/entry.py
@@ -3,13 +3,15 @@ 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):
+ def __init__(self, id, parent_id, desc, due = "", due_alt = "", link = "", color = "", highlight = "", 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.color = color
+ self.highlight = highlight
self.done = done
self.hidden = hidden
@@ -31,11 +33,6 @@ class Entry:
color: green;
}
""")
- body.setStyleSheet("""
- QLabel{
- color: green;
- }
- """)
else:
bullet.setText("- ")
output.addWidget(bullet)
@@ -44,7 +41,7 @@ class Entry:
body.setText("{0}/{1}/{2}: ".format(self.due.month(), self.due.day(), self.due.year()))
if self.link:
body.setOpenExternalLinks(True)
- body.setText(body.text() + "<a href=\"{0}\">".format(self.link))
+ body.setText(body.text() + "<a href=\"{0}\" style=\"color: default; text-decoration: none;\">".format(self.link))
body.setText(body.text() + self.desc)
if self.link:
body.setText(body.text() + "</a>")
@@ -56,5 +53,20 @@ class Entry:
font = body.font()
font.setStrikeOut(True)
body.setFont(font)
+ body.setStyleSheet("""
+ QLabel{
+ color: green;
+ }
+ """)
+
+ else:
+ body.setStyleSheet("""
+ QLabel{{
+ color: {0};
+ background-color: {1};
+ }}""".format(
+ self.color if self.color else "black",
+ self.highlight if self.highlight else "none"
+ ))
return output