unfinished

This commit is contained in:
ccppi 2024-08-06 13:42:58 +02:00
parent 7b6dea99d4
commit 71b27c1452
3 changed files with 60 additions and 21 deletions

View File

@ -95,6 +95,13 @@ def writedb(jobs):
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) 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:
cursor = connection.cursor()
cursor.execute("UPDATE jobs SET viewed = '1' WHERE hash = ?",(hash1,))
print("modified rows: ",cursor.rowcount)
def isStillValid(file,skiprows): def isStillValid(file,skiprows):
rows = [0,0,0] rows = [0,0,0]
with sqlite3.connect(file,timeout=10) as connection: with sqlite3.connect(file,timeout=10) as connection:

View File

@ -17,27 +17,42 @@ class ColorDelegate(QStyledItemDelegate):
currentRow = 0 currentRow = 0
starred = 0 starred = 0
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
super().initStyleOption(option,index) super().initStyleOption(option,index)
data = index.data() data = index.data()
try: column = index.column()
value = float(data) print("index:",index)
except: print("column ",column)
pass print("data:", self.view.index.data())
#print("error not an integer") #if column == 0:
else: # try:
#print("data:",data) # value = float(data)
self.currentRow = index.row() # except:
#print("row: ",self.currentRow) # pass
if value == 1: # #print("error not an integer")
self.starred = 1 # else:
# #self.view.currentRow = index.row()
# #print("row: ",self.currentRow)
# if value == 1:
# self.starred = 1
# else:
# self.starred = 0
# if column == 8:
# try:
# value = float(data)
# except:
# pass
# else:
# if value == 1:
# self.starred = 2
# else:
# self.starred = 0
# if self.starred == 1:
# option.backgroundBrush = QtGui.QColor("red")
# elif self.starred == 2:
# option.backgroundBrush = QtGui.QColor("white")
# else:
# option.backgroundBrush = QtGui.QColor("green") # option.backgroundBrush = QtGui.QColor("green")
else:
self.starred = 0
#option.backgroundBrush = QtGui.QColor("grey")
if self.starred == 1:
option.backgroundBrush = QtGui.QColor("red")
else:
option.backgroundBrush = QtGui.QColor("white")
class ValidationWorker(QObject): class ValidationWorker(QObject):
finished = Signal() finished = Signal()
@ -96,14 +111,14 @@ class MainWindow(QMainWindow):
self.view = QTableView() self.view = QTableView()
self.view.setModel(self.model) self.view.setModel(self.model)
delegate = ColorDelegate(self.view) delegate = ColorDelegate(self)
self.view.setItemDelegate(delegate) self.view.setItemDelegate(delegate)
self.setProxyViewSettings() self.setProxyViewSettings()
self.view.activated.connect(self.cell_clicked) self.view.activated.connect(self.cell_clicked)
self.sel_model = self.view.selectionModel() self.sel_model = self.view.selectionModel()
self.sel_model.selectionChanged.connect(self.cell_selection_changed) self.sel_model.selectionChanged.connect(self.cell_clicked)
self.PValidate = QPushButton("links valid") self.PValidate = QPushButton("links valid")
self.PValidate.clicked.connect(self.runValidation) self.PValidate.clicked.connect(self.runValidation)
@ -221,6 +236,11 @@ class MainWindow(QMainWindow):
data = self.view.model().index(x,5).data() data = self.view.model().index(x,5).data()
print("cell clicked:",x," / ",y, "-->",data) print("cell clicked:",x," / ",y, "-->",data)
self.browser.setUrl(QUrl(data)) self.browser.setUrl(QUrl(data))
hash1 = self.view.model().index(x,7).data()
print("hash of selected: ",hash1)
#db.viewedEntry(hash1)
self.view.selectionModel().currentIndex()
self.model.setData({0,8},hash1,role=1001)
def customSQL(self,cmd): def customSQL(self,cmd):
print("Run SQL Query",cmd) print("Run SQL Query",cmd)

View File

@ -24,6 +24,7 @@ class SqlQueryModel_editable(QSqlQueryModel):
return fl return fl
def setData(self, index, value, role=Qt.EditRole): def setData(self, index, value, role=Qt.EditRole):
print("role: ",role)
if role == Qt.EditRole: if role == Qt.EditRole:
mycolumn = index.column() mycolumn = index.column()
if mycolumn in self.editables: if mycolumn in self.editables:
@ -39,6 +40,17 @@ class SqlQueryModel_editable(QSqlQueryModel):
else: else:
print(self.query().lastError().text()) print(self.query().lastError().text())
return result return result
elif role == 1001:
print("Atempt flaging view")
q = QSqlQuery("UPDATE jobs SET viewed = '1' WHERE hash = {}".format(value))
print("QSQLQuery: ", "UPDATE jobs SET viewed = '1' WHERE hash = {}".format(value))
result = q.exec_()
if result:
self.query().exec_()
# print("filter_value:",filter_value)
else:
print("Error:", self.query().lastError().text())
return result
return QSqlQueryModel.setData(self, index, value, role) return QSqlQueryModel.setData(self, index, value, role)