starring and viewed/new entries coloring
This commit is contained in:
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)
|
||||
|
||||
Reference in New Issue
Block a user