refactoring memory and disk cache abstractions

This commit is contained in:
Vinicius Moreira
2019-08-30 17:26:35 -03:00
parent 71959e8e04
commit bd17594723
12 changed files with 215 additions and 63 deletions

View File

@@ -7,8 +7,8 @@ from PyQt5.QtGui import QPixmap, QIcon, QCursor
from PyQt5.QtNetwork import QNetworkAccessManager, QNetworkRequest
from PyQt5.QtWidgets import QTableWidget, QTableView, QMenu, QAction, QTableWidgetItem, QToolButton, QWidget, \
QHeaderView, QLabel, QHBoxLayout, QPushButton, QToolBar
from bauh_api.abstract.cache import MemoryCache
from bauh_api.abstract.model import PackageStatus
from bauh_api.util.cache import Cache
from bauh.core import resource
from bauh.util import util
@@ -75,7 +75,7 @@ class UpdateToggleButton(QWidget):
class AppsTable(QTableWidget):
def __init__(self, parent: QWidget, icon_cache: Cache, disk_cache: bool, download_icons: bool):
def __init__(self, parent: QWidget, icon_cache: MemoryCache, disk_cache: bool, download_icons: bool):
super(AppsTable, self).__init__()
self.setParent(parent)
self.window = parent

View File

@@ -4,13 +4,13 @@ from functools import reduce
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QColor
from PyQt5.QtWidgets import QDialog, QVBoxLayout, QTableWidget, QTableWidgetItem, QHeaderView
from bauh_api.abstract.cache import MemoryCache
from bauh_api.abstract.model import PackageHistory
from bauh_api.util.cache import Cache
class HistoryDialog(QDialog):
def __init__(self, history: PackageHistory, icon_cache: Cache, locale_keys: dict):
def __init__(self, history: PackageHistory, icon_cache: MemoryCache, locale_keys: dict):
super(HistoryDialog, self).__init__()
self.setWindowTitle('{} - {} '.format(locale_keys['popup.history.title'], history.pkg.base_data.name))

View File

@@ -2,7 +2,7 @@ from PyQt5.QtCore import QSize
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QDialog, QVBoxLayout, QGroupBox, \
QLineEdit, QLabel, QGridLayout, QPushButton, QPlainTextEdit, QToolBar
from bauh_api.util.cache import Cache
from bauh_api.abstract.cache import MemoryCache
from bauh.util import util
@@ -11,7 +11,7 @@ IGNORED_ATTRS = {'name', '__app__'}
class InfoDialog(QDialog):
def __init__(self, app: dict, icon_cache: Cache, locale_keys: dict, screen_size: QSize()):
def __init__(self, app: dict, icon_cache: MemoryCache, locale_keys: dict, screen_size: QSize()):
super(InfoDialog, self).__init__()
self.setWindowTitle(app['__app__'].model.base_data.name)
self.screen_size = screen_size

View File

@@ -5,12 +5,12 @@ from typing import List, Type, Set
import requests
from PyQt5.QtCore import QThread, pyqtSignal
from bauh_api.abstract.cache import MemoryCache
from bauh_api.abstract.controller import SoftwareManager
from bauh_api.abstract.handler import ProcessWatcher
from bauh_api.abstract.model import PackageStatus, SoftwarePackage
from bauh_api.abstract.view import InputViewComponent, MessageType
from bauh_api.exception import NoInternetException
from bauh_api.util.cache import Cache
from bauh.view.qt.view_model import PackageView
@@ -127,7 +127,7 @@ class RefreshApps(AsyncAction):
class UninstallApp(AsyncAction):
def __init__(self, manager: SoftwareManager, icon_cache: Cache, app: PackageView = None):
def __init__(self, manager: SoftwareManager, icon_cache: MemoryCache, app: PackageView = None):
super(UninstallApp, self).__init__()
self.app = app
self.manager = manager
@@ -223,7 +223,7 @@ class SearchApps(AsyncAction):
class InstallApp(AsyncAction):
def __init__(self, manager: SoftwareManager, disk_cache: bool, icon_cache: Cache, locale_keys: dict, pkg: PackageView = None):
def __init__(self, manager: SoftwareManager, disk_cache: bool, icon_cache: MemoryCache, locale_keys: dict, pkg: PackageView = None):
super(InstallApp, self).__init__()
self.pkg = pkg
self.manager = manager

View File

@@ -6,10 +6,10 @@ from PyQt5.QtCore import QEvent, Qt, QSize, pyqtSignal
from PyQt5.QtGui import QIcon, QWindowStateChangeEvent, QPixmap
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QApplication, QCheckBox, QHeaderView, QToolButton, QToolBar, \
QLabel, QPlainTextEdit, QLineEdit, QProgressBar, QPushButton, QComboBox
from bauh_api.abstract.cache import MemoryCache
from bauh_api.abstract.controller import SoftwareManager
from bauh_api.abstract.model import SoftwarePackage
from bauh_api.abstract.view import MessageType
from bauh_api.util.cache import Cache
from bauh.core import resource
from bauh.util import util
@@ -38,7 +38,7 @@ class ManageWindow(QWidget):
def _toolbar_button_style(self, bg: str):
return 'QPushButton { color: white; font-weight: bold; background: ' + bg + '}'
def __init__(self, locale_keys: dict, icon_cache: Cache, manager: SoftwareManager, disk_cache: bool, download_icons: bool, screen_size, suggestions: bool, tray_icon=None):
def __init__(self, locale_keys: dict, icon_cache: MemoryCache, manager: SoftwareManager, disk_cache: bool, download_icons: bool, screen_size, suggestions: bool, tray_icon=None):
super(ManageWindow, self).__init__()
self.locale_keys = locale_keys
self.manager = manager