fix: filter timeline markers by current export folder
Subprofile exports (folder_suffix) created markers that interleaved with main folder markers, shifting their numbering. Now get_markers and _get_markers_for accept an export_folder parameter and use SQL LIKE to only return markers whose output_path is in that folder. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+24
-11
@@ -358,14 +358,25 @@ class ProcessedDB:
|
||||
self._con.commit()
|
||||
return paths
|
||||
|
||||
def _get_markers_for(self, match: str, profile: str = "default") -> list[tuple[float, int, str, float]]:
|
||||
rows = self._con.execute(
|
||||
"SELECT start_time, output_path, clip_duration, clip_count, spread"
|
||||
" FROM processed"
|
||||
" WHERE filename = ? AND profile = ? AND scan_export = 0"
|
||||
" ORDER BY start_time",
|
||||
(match, profile),
|
||||
).fetchall()
|
||||
def _get_markers_for(self, match: str, profile: str = "default",
|
||||
export_folder: str = "") -> list[tuple[float, int, str, float]]:
|
||||
if export_folder:
|
||||
rows = self._con.execute(
|
||||
"SELECT start_time, output_path, clip_duration, clip_count, spread"
|
||||
" FROM processed"
|
||||
" WHERE filename = ? AND profile = ? AND scan_export = 0"
|
||||
" AND output_path LIKE ?"
|
||||
" ORDER BY start_time",
|
||||
(match, profile, export_folder.rstrip("/") + "/%"),
|
||||
).fetchall()
|
||||
else:
|
||||
rows = self._con.execute(
|
||||
"SELECT start_time, output_path, clip_duration, clip_count, spread"
|
||||
" FROM processed"
|
||||
" WHERE filename = ? AND profile = ? AND scan_export = 0"
|
||||
" ORDER BY start_time",
|
||||
(match, profile),
|
||||
).fetchall()
|
||||
seen_times: dict[float, tuple[float, int, str, float]] = {}
|
||||
n = 0
|
||||
for t, p, dur, cnt, spr in rows:
|
||||
@@ -375,13 +386,15 @@ class ProcessedDB:
|
||||
seen_times[t] = (t, n, p, span)
|
||||
return list(seen_times.values())
|
||||
|
||||
def get_markers(self, filename: str, profile: str = "default") -> list[tuple[float, int, str, float]]:
|
||||
def get_markers(self, filename: str, profile: str = "default",
|
||||
export_folder: str = "") -> list[tuple[float, int, str, float]]:
|
||||
"""Return [(start_time, marker_number, output_path, clip_span), ...]
|
||||
for exact filename match, sorted by start_time. Empty list if no match.
|
||||
Excludes scan exports (shown via scan panel instead)."""
|
||||
Excludes scan exports (shown via scan panel instead).
|
||||
If export_folder is set, only markers in that folder are returned."""
|
||||
if not self._enabled:
|
||||
return []
|
||||
return self._get_markers_for(filename, profile)
|
||||
return self._get_markers_for(filename, profile, export_folder)
|
||||
|
||||
def get_manual_export_groups(self, filename: str, profile: str = "default"
|
||||
) -> list[dict]:
|
||||
|
||||
@@ -46,15 +46,18 @@ class _DBWorker(QThread):
|
||||
"""Runs ProcessedDB fuzzy-match lookup off the main thread."""
|
||||
result = pyqtSignal(str, object, list) # (queried_filename, match|None, markers)
|
||||
|
||||
def __init__(self, db: "ProcessedDB", filename: str, profile: str = "default"):
|
||||
def __init__(self, db: "ProcessedDB", filename: str, profile: str = "default",
|
||||
export_folder: str = ""):
|
||||
super().__init__()
|
||||
self._db = db
|
||||
self._filename = filename
|
||||
self._profile = profile
|
||||
self._export_folder = export_folder
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
markers = self._db._get_markers_for(self._filename, self._profile)
|
||||
markers = self._db._get_markers_for(
|
||||
self._filename, self._profile, self._export_folder)
|
||||
except Exception:
|
||||
markers = []
|
||||
self.result.emit(self._filename, self._filename if markers else None, markers)
|
||||
@@ -4193,7 +4196,8 @@ class MainWindow(QMainWindow):
|
||||
|
||||
# Run DB fuzzy match off the main thread — can be slow on large databases.
|
||||
filename = os.path.basename(self._file_path)
|
||||
self._db_worker = _DBWorker(self._db, filename, self._profile)
|
||||
self._db_worker = _DBWorker(self._db, filename, self._profile,
|
||||
self._txt_folder.text())
|
||||
self._db_worker.result.connect(self._on_db_result)
|
||||
self._db_worker.start()
|
||||
|
||||
@@ -4209,7 +4213,8 @@ class MainWindow(QMainWindow):
|
||||
|
||||
def _refresh_markers(self) -> None:
|
||||
filename = os.path.basename(self._file_path)
|
||||
markers = self._db.get_markers(filename, self._profile)
|
||||
markers = self._db.get_markers(filename, self._profile,
|
||||
self._txt_folder.text())
|
||||
self._timeline.set_markers(markers)
|
||||
|
||||
def _refresh_playlist_checks(self) -> None:
|
||||
|
||||
Reference in New Issue
Block a user