starring and viewed/new entries coloring
This commit is contained in:
parent
71b27c1452
commit
d37f451297
@ -12,7 +12,7 @@ def initdb(file):
|
||||
with sqlite3.connect(file) as connection:
|
||||
print("db connection", connection.total_changes)
|
||||
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()
|
||||
def rmdb(file,table):
|
||||
with sqlite3.connect(file) as connection:
|
||||
@ -93,7 +93,7 @@ def writedb(jobs):
|
||||
log("Hash already exist")
|
||||
else:
|
||||
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):
|
||||
with sqlite3.connect("../db/sqlite3.db",timeout=10) as connection:
|
||||
|
25
lib/gui.py
25
lib/gui.py
@ -16,14 +16,37 @@ Cantons = ["AG","ZH","BE","SG","SO"]
|
||||
class ColorDelegate(QStyledItemDelegate):
|
||||
currentRow = 0
|
||||
starred = 0
|
||||
|
||||
def __init__(self,main):
|
||||
super().__init__()
|
||||
print("initialice overload init of ColorDelegate")
|
||||
self.main = main
|
||||
def initStyleOption(self,option,index):
|
||||
#we have to rewrite this because it depends on viewport but it should depend on the model
|
||||
super().initStyleOption(option,index)
|
||||
data = index.data()
|
||||
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("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:
|
||||
# try:
|
||||
# value = float(data)
|
||||
|
Loading…
Reference in New Issue
Block a user