refactor database and media handling to use icon paths instead of flags
This commit is contained in:
@@ -39,7 +39,7 @@ class DatabaseManager:
|
||||
CREATE TABLE IF NOT EXISTS colors (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
name TEXT UNIQUE NOT NULL,
|
||||
has_icon INTEGER DEFAULT 0
|
||||
icon_path TEXT NOT NULL
|
||||
)
|
||||
"""
|
||||
)
|
||||
@@ -62,13 +62,13 @@ class DatabaseManager:
|
||||
# -------------------------
|
||||
# Operacje na kolorach
|
||||
# -------------------------
|
||||
def add_color(self, name: str, has_icon: bool = False):
|
||||
def add_color(self, name: str, icon_path: str):
|
||||
if self.conn is None:
|
||||
raise RuntimeError("Database not connected")
|
||||
cur = self.conn.cursor()
|
||||
cur.execute(
|
||||
"INSERT OR IGNORE INTO colors (name, has_icon) VALUES (?, ?)",
|
||||
(name, int(has_icon)),
|
||||
"INSERT OR IGNORE INTO colors (name, icon_path) VALUES (?, ?)",
|
||||
(name, icon_path),
|
||||
)
|
||||
self.conn.commit()
|
||||
|
||||
@@ -95,11 +95,11 @@ class DatabaseManager:
|
||||
cur.execute("UPDATE colors SET name = ? WHERE name = ?", (new_name, old_name))
|
||||
self.conn.commit()
|
||||
|
||||
def update_color_icon_flag(self, name: str, has_icon: bool):
|
||||
def update_color_icon(self, name: str, icon_path: str):
|
||||
if self.conn is None:
|
||||
raise RuntimeError("Database not connected")
|
||||
cur = self.conn.cursor()
|
||||
cur.execute("UPDATE colors SET has_icon = ? WHERE name = ?", (int(has_icon), name))
|
||||
cur.execute("UPDATE colors SET icon_path = ? WHERE name = ?", (icon_path, name))
|
||||
self.conn.commit()
|
||||
|
||||
def delete_color(self, name: str):
|
||||
|
||||
Reference in New Issue
Block a user