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:
2026-05-04 11:32:39 +02:00
parent fae5560e2d
commit 9becd5a06d
2 changed files with 33 additions and 15 deletions
+24 -11
View File
@@ -358,14 +358,25 @@ class ProcessedDB:
self._con.commit() self._con.commit()
return paths return paths
def _get_markers_for(self, match: str, profile: str = "default") -> list[tuple[float, int, str, float]]: def _get_markers_for(self, match: str, profile: str = "default",
rows = self._con.execute( export_folder: str = "") -> list[tuple[float, int, str, float]]:
"SELECT start_time, output_path, clip_duration, clip_count, spread" if export_folder:
" FROM processed" rows = self._con.execute(
" WHERE filename = ? AND profile = ? AND scan_export = 0" "SELECT start_time, output_path, clip_duration, clip_count, spread"
" ORDER BY start_time", " FROM processed"
(match, profile), " WHERE filename = ? AND profile = ? AND scan_export = 0"
).fetchall() " 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]] = {} seen_times: dict[float, tuple[float, int, str, float]] = {}
n = 0 n = 0
for t, p, dur, cnt, spr in rows: for t, p, dur, cnt, spr in rows:
@@ -375,13 +386,15 @@ class ProcessedDB:
seen_times[t] = (t, n, p, span) seen_times[t] = (t, n, p, span)
return list(seen_times.values()) 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), ...] """Return [(start_time, marker_number, output_path, clip_span), ...]
for exact filename match, sorted by start_time. Empty list if no match. 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: if not self._enabled:
return [] 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" def get_manual_export_groups(self, filename: str, profile: str = "default"
) -> list[dict]: ) -> list[dict]:
+9 -4
View File
@@ -46,15 +46,18 @@ class _DBWorker(QThread):
"""Runs ProcessedDB fuzzy-match lookup off the main thread.""" """Runs ProcessedDB fuzzy-match lookup off the main thread."""
result = pyqtSignal(str, object, list) # (queried_filename, match|None, markers) 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__() super().__init__()
self._db = db self._db = db
self._filename = filename self._filename = filename
self._profile = profile self._profile = profile
self._export_folder = export_folder
def run(self): def run(self):
try: 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: except Exception:
markers = [] markers = []
self.result.emit(self._filename, self._filename if markers else None, 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. # Run DB fuzzy match off the main thread — can be slow on large databases.
filename = os.path.basename(self._file_path) 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.result.connect(self._on_db_result)
self._db_worker.start() self._db_worker.start()
@@ -4209,7 +4213,8 @@ class MainWindow(QMainWindow):
def _refresh_markers(self) -> None: def _refresh_markers(self) -> None:
filename = os.path.basename(self._file_path) 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) self._timeline.set_markers(markers)
def _refresh_playlist_checks(self) -> None: def _refresh_playlist_checks(self) -> None: