Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions src/tagstudio/qt/ts_qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

"""A Qt driver for TagStudio."""

import contextlib
import ctypes
import math
import os
Expand Down Expand Up @@ -194,7 +193,7 @@ class QtDriver(DriverMixin, QObject):
applied_theme: Theme

lib: Library
cache_manager: CacheManager
cache_manager: CacheManager | None

browsing_history: History[BrowsingState]

Expand Down Expand Up @@ -539,7 +538,7 @@ def create_dupe_files_modal():

# TODO: Move this to a settings screen.
self.main_window.menu_bar.clear_thumb_cache_action.triggered.connect(
lambda: self.cache_manager.clear_cache()
lambda: unwrap(self.cache_manager).clear_cache()
)

# endregion
Expand Down Expand Up @@ -913,22 +912,21 @@ def delete_files_callback(self, origin_path: str | Path, origin_id: int | None =
origin_id(id): The entry ID associated with the widget making the call.
"""
entry: Entry | None = None
pending: list[tuple[int, Path]] = []
pending: list[tuple[int | None, Path]] = []
deleted_count: int = 0

selected = self.selected
library_dir = unwrap(self.lib.library_dir)

if len(selected) <= 1 and origin_path:
origin_id_ = origin_id
if not origin_id_:
with contextlib.suppress(IndexError):
origin_id_ = selected[0]
if origin_id_ is None:
origin_id_ = selected[0] if len(selected) > 0 else None

pending.append((origin_id_, Path(origin_path)))
else:
for item in selected:
entry = self.lib.get_entry(item)
entry = unwrap(self.lib.get_entry(item))
filepath: Path = entry.path
pending.append((item, filepath))

Expand All @@ -950,7 +948,8 @@ def delete_files_callback(self, origin_path: str | Path, origin_id: int | None =
self.main_window.status_bar.showMessage(msg)
self.main_window.status_bar.repaint()

self.lib.remove_entries([e_id])
if e_id is not None:
self.lib.remove_entries([e_id])
if delete_file(library_dir / f):
deleted_count += 1

Expand Down Expand Up @@ -1226,10 +1225,10 @@ def paste_fields_action_callback(self):
for field in self.copy_buffer["fields"]:
exists = False
for e in existing_fields:
if field.type_key == e.type_key and field.value == e.value:
if field == e:
exists = True
if not exists:
self.lib.add_field_to_entries(id, field_id=field.type_key, value=field.value)
self.lib.add_field_to_entries(id, field=field)
self.lib.add_tags_to_entries(id, self.copy_buffer["tags"])
if len(self.selected) > 1:
if TAG_ARCHIVED in self.copy_buffer["tags"]:
Expand Down
Loading