mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-06 21:44:16 +02:00
[view.qt] enhancement: minor reduction in the table loading time
This commit is contained in:
@@ -27,6 +27,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||||||
- displaying a text warning before installing an unverified package (unverified = not verified by the system maintainers or a trustable source)
|
- displaying a text warning before installing an unverified package (unverified = not verified by the system maintainers or a trustable source)
|
||||||
- at the moment the following packaging formats are considered completely **unverified**: AppImage, AUR, native Web application
|
- at the moment the following packaging formats are considered completely **unverified**: AppImage, AUR, native Web application
|
||||||
- Snap supports both verified and unverified software
|
- Snap supports both verified and unverified software
|
||||||
|
- minor reduction in the table loading time
|
||||||
|
|
||||||
### Fixes
|
### Fixes
|
||||||
- AppImage
|
- AppImage
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import operator
|
|||||||
import os
|
import os
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
from threading import Lock
|
from threading import Lock
|
||||||
from typing import List, Optional
|
from typing import List, Optional, Dict
|
||||||
|
|
||||||
from PyQt5.QtCore import Qt, QSize
|
from PyQt5.QtCore import Qt, QSize
|
||||||
from PyQt5.QtGui import QPixmap, QIcon, QCursor
|
from PyQt5.QtGui import QPixmap, QIcon, QCursor
|
||||||
@@ -96,6 +96,7 @@ class PackagesTable(QTableWidget):
|
|||||||
self.lock_async_data = Lock()
|
self.lock_async_data = Lock()
|
||||||
self.setRowHeight(80, 80)
|
self.setRowHeight(80, 80)
|
||||||
self.cache_type_icon = {}
|
self.cache_type_icon = {}
|
||||||
|
self.cache_default_icon: Dict[str, QIcon] = dict()
|
||||||
self.i18n = self.window.i18n
|
self.i18n = self.window.i18n
|
||||||
|
|
||||||
def has_any_settings(self, pkg: PackageView):
|
def has_any_settings(self, pkg: PackageView):
|
||||||
@@ -399,6 +400,16 @@ class PackagesTable(QTableWidget):
|
|||||||
item.setToolTip(tooltip)
|
item.setToolTip(tooltip)
|
||||||
self.setCellWidget(pkg.table_index, col, item)
|
self.setCellWidget(pkg.table_index, col, item)
|
||||||
|
|
||||||
|
def _read_default_icon(self, pkgv: PackageView):
|
||||||
|
icon_path = pkgv.model.get_default_icon_path()
|
||||||
|
icon = self.cache_default_icon.get(icon_path)
|
||||||
|
|
||||||
|
if not icon:
|
||||||
|
icon = QIcon(icon_path)
|
||||||
|
self.cache_default_icon[icon_path] = icon
|
||||||
|
|
||||||
|
return icon
|
||||||
|
|
||||||
def _set_col_icon(self, col: int, pkg: PackageView):
|
def _set_col_icon(self, col: int, pkg: PackageView):
|
||||||
icon_path = pkg.model.get_disk_icon_path()
|
icon_path = pkg.model.get_disk_icon_path()
|
||||||
if pkg.model.installed and pkg.model.supports_disk_cache() and icon_path:
|
if pkg.model.installed and pkg.model.supports_disk_cache() and icon_path:
|
||||||
@@ -411,24 +422,24 @@ class PackagesTable(QTableWidget):
|
|||||||
icon = QIcon(pixmap)
|
icon = QIcon(pixmap)
|
||||||
self.icon_cache.add_non_existing(pkg.model.icon_url, {'icon': icon, 'bytes': icon_bytes})
|
self.icon_cache.add_non_existing(pkg.model.icon_url, {'icon': icon, 'bytes': icon_bytes})
|
||||||
else:
|
else:
|
||||||
icon = QIcon(pkg.model.get_default_icon_path())
|
icon = self._read_default_icon(pkg)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
icon = QIcon.fromTheme(icon_path)
|
icon = QIcon.fromTheme(icon_path)
|
||||||
|
|
||||||
if icon.isNull():
|
if icon.isNull():
|
||||||
icon = QIcon(pkg.model.get_default_icon_path())
|
icon = self._read_default_icon(pkg)
|
||||||
elif pkg.model.icon_url:
|
elif pkg.model.icon_url:
|
||||||
self.icon_cache.add_non_existing(pkg.model.icon_url, {'icon': icon, 'bytes': None})
|
self.icon_cache.add_non_existing(pkg.model.icon_url, {'icon': icon, 'bytes': None})
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
icon = QIcon(pkg.model.get_default_icon_path())
|
icon = self._read_default_icon(pkg)
|
||||||
|
|
||||||
elif not pkg.model.icon_url:
|
elif not pkg.model.icon_url:
|
||||||
icon = QIcon(pkg.model.get_default_icon_path())
|
icon = self._read_default_icon(pkg)
|
||||||
else:
|
else:
|
||||||
icon_data = self.icon_cache.get(pkg.model.icon_url)
|
icon_data = self.icon_cache.get(pkg.model.icon_url)
|
||||||
icon = icon_data['icon'] if icon_data else QIcon(pkg.model.get_default_icon_path())
|
icon = icon_data['icon'] if icon_data else self._read_default_icon(pkg)
|
||||||
|
|
||||||
col_icon = QLabel()
|
col_icon = QLabel()
|
||||||
col_icon.setProperty('icon', 'true')
|
col_icon.setProperty('icon', 'true')
|
||||||
|
|||||||
Reference in New Issue
Block a user