Skip to content

Commit 38aec35

Browse files
committed
refactor(lazy-images): clean up code
1 parent b2f607b commit 38aec35

2 files changed

Lines changed: 6 additions & 10 deletions

File tree

‎sqlite3__examples/view_many_images__lazy__delegates__async_load_images/utils_PyQt6/ListImagesWidget.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ def __init__(
1616
self,
1717
icon_width: int,
1818
icon_height: int,
19-
image_cache: dict[str, QImage | None],
19+
image_cache: dict[str, QImage],
2020
file_name_index: int,
2121
) -> None:
2222
super().__init__()
2323

24-
self.image_cache: dict[str, QImage | None] = image_cache
24+
self.image_cache: dict[str, QImage] = image_cache
2525

2626
self.setMovement(QListView.Movement.Static)
2727
self.setDragEnabled(False)

‎sqlite3__examples/view_many_images__lazy__delegates__async_load_images/utils_PyQt6/ThumbnailDelegate.py‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def __init__(
4343
view: QAbstractItemView,
4444
width: int,
4545
height: int,
46-
image_cache: dict[str, QImage | None],
46+
image_cache: dict[str, QImage],
4747
file_name_index: int = 0,
4848
) -> None:
4949
super().__init__()
@@ -53,7 +53,7 @@ def __init__(
5353
self.title_height: int = 20
5454
self.title_margin: int = 5
5555
self.view: QAbstractItemView = view
56-
self.image_cache: dict[str, QImage | None] = image_cache
56+
self.image_cache: dict[str, QImage] = image_cache
5757
self.file_name_index: int = file_name_index
5858

5959
def _on_about_image(
@@ -121,13 +121,9 @@ def paint(
121121
if file_name in self.image_cache:
122122
img = self.image_cache[file_name]
123123
if img and not img.isNull():
124-
painter.drawImage(
125-
rect.topLeft(),
126-
# QRect(rect.left(), rect.top(), rect.width(), rect.height() - self.title_height),
127-
img,
128-
)
124+
painter.drawImage(rect.topLeft(), img)
129125
else:
130-
self.image_cache[file_name] = None
126+
self.image_cache[file_name] = QImage()
131127

132128
worker = ThumbnailWorker(file_name, self.width, self.height)
133129
worker.signals.about_image.connect(

0 commit comments

Comments
 (0)