diff --git a/engine.py b/engine.py index 72a10dc..6a63dd8 100644 --- a/engine.py +++ b/engine.py @@ -501,4 +501,28 @@ class SorterEngine: cursor.execute("DELETE FROM categories WHERE name = ?", (name,)) cursor.execute("DELETE FROM staging_area WHERE target_category = ?", (name,)) conn.commit() - conn.close() \ No newline at end of file + conn.close() + + @staticmethod + def get_tagged_page_indices(all_images, page_size): + """ + Returns a Set of page numbers (0-indexed) that contain at least one staged image. + """ + staged = SorterEngine.get_staged_data() + if not staged: + return set() + + tagged_pages = set() + staged_keys = set(staged.keys()) + + # We iterate only through the staged items to find their page index + # This is faster than iterating all images if staged < total + # However, we need the index from the main list. + # Since we need order, iterating all_images once is safest and fast enough. + + for idx, img_path in enumerate(all_images): + if img_path in staged_keys: + page_idx = idx // page_size + tagged_pages.add(page_idx) + + return tagged_pages \ No newline at end of file