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")
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):
rows = [0,0,0]
with sqlite3.connect(file,timeout=10) as connection:

View File

@ -17,27 +17,42 @@ class ColorDelegate(QStyledItemDelegate):
currentRow = 0
starred = 0
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()
try:
value = float(data)
except:
pass
#print("error not an integer")
else:
#print("data:",data)
self.currentRow = index.row()
#print("row: ",self.currentRow)
if value == 1:
self.starred = 1
#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")
column = index.column()
print("index:",index)
print("column ",column)
print("data:", self.view.index.data())
#if column == 0:
# try:
# value = float(data)
# except:
# pass
# #print("error not an integer")
# 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")
class ValidationWorker(QObject):
finished = Signal()
@ -96,14 +111,14 @@ class MainWindow(QMainWindow):
self.view = QTableView()
self.view.setModel(self.model)
delegate = ColorDelegate(self.view)
delegate = ColorDelegate(self)
self.view.setItemDelegate(delegate)
self.setProxyViewSettings()
self.view.activated.connect(self.cell_clicked)
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.clicked.connect(self.runValidation)
@ -221,6 +236,11 @@ class MainWindow(QMainWindow):
data = self.view.model().index(x,5).data()
print("cell clicked:",x," / ",y, "-->",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):
print("Run SQL Query",cmd)

View File

@ -24,6 +24,7 @@ class SqlQueryModel_editable(QSqlQueryModel):
return fl
def setData(self, index, value, role=Qt.EditRole):
print("role: ",role)
if role == Qt.EditRole:
mycolumn = index.column()
if mycolumn in self.editables:
@ -39,6 +40,17 @@ class SqlQueryModel_editable(QSqlQueryModel):
else:
print(self.query().lastError().text())
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)