starring and viewed/new entries coloring

This commit is contained in:
ccppi 2024-08-07 09:56:07 +02:00
parent 71b27c1452
commit d37f451297
2 changed files with 26 additions and 3 deletions

View File

@ -12,7 +12,7 @@ def initdb(file):
with sqlite3.connect(file) as connection: with sqlite3.connect(file) as connection:
print("db connection", connection.total_changes) print("db connection", connection.total_changes)
cursor = connection.cursor() cursor = connection.cursor()
cursor.execute("CREATE TABLE jobs (star TEXT,tag INT ,title TEXT, location TEXT, company TEXT,link TEXT,pubdate TEXT,hash INT,viewed INT)") cursor.execute("CREATE TABLE jobs (star INT,tag INT ,title TEXT, location TEXT, company TEXT,link TEXT,pubdate TEXT,hash INT,viewed INT)")
sys.exit() sys.exit()
def rmdb(file,table): def rmdb(file,table):
with sqlite3.connect(file) as connection: with sqlite3.connect(file) as connection:
@ -93,7 +93,7 @@ def writedb(jobs):
log("Hash already exist") log("Hash already exist")
else: else:
print("NEW_ENTRY") print("NEW_ENTRY")
cursor.execute("INSERT INTO jobs (star,tag,title,company,location,link,pubdate,hash) VALUES (?,?,?,?,?,?,?,?,?)",(job.starred,job.tag,job.title,job.company,job.location,job.link,job.date,hash1,0)) cursor.execute("INSERT INTO jobs (star,tag,title,company,location,link,pubdate,hash,viewed) VALUES (?,?,?,?,?,?,?,?,?)",(job.starred,job.tag,job.title,job.company,job.location,job.link,job.date,hash1,0))
def viewedEntry(hash1): def viewedEntry(hash1):
with sqlite3.connect("../db/sqlite3.db",timeout=10) as connection: with sqlite3.connect("../db/sqlite3.db",timeout=10) as connection:

View File

@ -16,14 +16,37 @@ Cantons = ["AG","ZH","BE","SG","SO"]
class ColorDelegate(QStyledItemDelegate): class ColorDelegate(QStyledItemDelegate):
currentRow = 0 currentRow = 0
starred = 0 starred = 0
def __init__(self,main):
super().__init__()
print("initialice overload init of ColorDelegate")
self.main = main
def initStyleOption(self,option,index): def initStyleOption(self,option,index):
#we have to rewrite this because it depends on viewport but it should depend on the model #we have to rewrite this because it depends on viewport but it should depend on the model
super().initStyleOption(option,index) super().initStyleOption(option,index)
data = index.data() data = index.data()
column = index.column() column = index.column()
#flag_viewed = self.main.model.index(index.row(),8).data()
#flag_starred = self.main.model.index(index.row(),0).data()
flag_viewed = self.main.sel_model.model().index(index.row(),8).data()
try:
flag_starred = int(self.main.sel_model.model().index(index.row(),0).data())
except ValueError:
print("probably empty string asign zero")
flag_starred = 0
print("index:",index) print("index:",index)
print("column ",column) print("column ",column)
print("data:", self.view.index.data()) print("data:", flag_starred)
if flag_starred == 1:
print("Starred!!!!!")
option.backgroundBrush = QtGui.QColor("red")
elif flag_viewed != 1:
option.backgroundBrush = QtGui.QColor("green")
else:
option.backgroundBrush = QtGui.QColor("white")
#if column == 0: #if column == 0:
# try: # try:
# value = float(data) # value = float(data)