refresh table when updated
This commit is contained in:
committed by
Thomas Peetz
parent
245ee2378e
commit
c8ea7c4188
Binary file not shown.
|
Before Width: | Height: | Size: 513 B |
Binary file not shown.
|
Before Width: | Height: | Size: 524 B |
Binary file not shown.
|
Before Width: | Height: | Size: 836 B |
Binary file not shown.
|
Before Width: | Height: | Size: 544 B |
+1
-2
@@ -6,8 +6,7 @@ from pathlib import Path
|
||||
|
||||
import yaml
|
||||
from PySide6.QtGui import QAction, QIcon
|
||||
from PySide6.QtSql import QSqlDatabase
|
||||
from PySide6.QtWidgets import QWidget, QVBoxLayout, QMenu, QMessageBox, QTabWidget, QTableView
|
||||
from PySide6.QtWidgets import QWidget, QVBoxLayout, QMenu, QMessageBox, QTabWidget, QTableView, QHBoxLayout, QCheckBox
|
||||
from PySide6.QtWidgets import QApplication, QLabel, QMainWindow
|
||||
from platformdirs import PlatformDirs
|
||||
|
||||
|
||||
+30
-6
@@ -11,7 +11,6 @@ class MediaFileTableModel(QAbstractTableModel):
|
||||
super().__init__()
|
||||
self.main_window = main_window
|
||||
self._data = []
|
||||
self.status_bar = main_window.statusBar
|
||||
self.mariadb_conn = mariadb.connect(
|
||||
host=db_config['mariadb']['host'],
|
||||
port=db_config['mariadb']['port'],
|
||||
@@ -24,12 +23,37 @@ class MediaFileTableModel(QAbstractTableModel):
|
||||
def refresh(self):
|
||||
data = []
|
||||
cursor = self.mariadb_conn.cursor()
|
||||
cursor.execute("SELECT id, url, review, should_download, file_name, cloud_link FROM media_file")
|
||||
filter_rule = ""
|
||||
print(self.main_window.filter["download"].isChecked())
|
||||
if self.main_window.filter["download"].isChecked():
|
||||
print(self.main_window.filter["download"].isChecked())
|
||||
filter_rule = "WHERE should_download is true"
|
||||
if self.main_window.filter["review"].isChecked():
|
||||
if len(filter_rule) > 0:
|
||||
filter_rule += " AND "
|
||||
else:
|
||||
filter_rule += "WHERE "
|
||||
filter_rule += "review is true"
|
||||
print(f"{filter_rule=}")
|
||||
try:
|
||||
cursor.execute(f"SELECT id, url, review, should_download, file_name, cloud_link FROM media_file {filter_rule}")
|
||||
except mariadb.Error as error:
|
||||
print(error)
|
||||
rows = cursor.fetchall()
|
||||
for row in rows:
|
||||
data.append(list(row))
|
||||
self.status_bar.showMessage(f"{len(rows)} Einträge geladen", 3000)
|
||||
self._data = data
|
||||
print(len(rows))
|
||||
if len(rows) > 0:
|
||||
self.beginResetModel()
|
||||
for row in rows:
|
||||
data.append(list(row))
|
||||
self._data = data
|
||||
self.endResetModel()
|
||||
else:
|
||||
self._data = None
|
||||
try:
|
||||
self.layoutChanged.emit()
|
||||
except:
|
||||
|
||||
self.main_window.statusBar.showMessage(f"{len(rows)} Einträge geladen", 3000)
|
||||
|
||||
def rowCount(self, parent=QModelIndex()):
|
||||
# The length of the outer list.
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 634 B |
Reference in New Issue
Block a user