-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp_view_model.py
More file actions
48 lines (38 loc) · 1.65 KB
/
app_view_model.py
File metadata and controls
48 lines (38 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Este módulo actúa como el "pegamento" entre la Vista y el Modelo.
# Maneja la lógica de la UI y los datos de la aplicación.
from PyQt6.QtCore import QObject, QStringListModel, pyqtSignal, Qt, QAbstractItemModel
import ipatool_helper
class AppsViewModel(QAbstractItemModel):
"""
El ViewModel de la aplicación.
Gestiona la lógica de la UI, los modelos de datos y se comunica con el ExcelProcessor.
"""
resumeCompleted = pyqtSignal()
def __init__(self):
super().__init__()
self._apps_dict = {}
self._header_labels = ["name", "version", "bundleID", "price", "id"]
def update_apps(self, apps_dict):
"""
Actualiza el diccionario de aplicaciones y notifica a la UI.
"""
self._apps_dict = apps_dict
self.resumeCompleted.emit()
def index(self, row, column, parent=None):
return self.createIndex(row, column)
def rowCount(self, parent=None):
return len(self._apps_dict)
def data(self, index, role):
if role == Qt.ItemDataRole.DisplayRole:
return self._apps_dict[index.row()][self._header_labels[index.column()]]
return None
def headerData(self, section, orientation, role):
if role == Qt.ItemDataRole.DisplayRole:
if orientation == Qt.Orientation.Horizontal:
return self._header_labels[section]
return None
def columnCount(self, parent=None):
return 5 # Por ejemplo, Nombre y Versión
def search_apps(self, name):
self._apps_dict=ipatool_helper.find_app_by_name(name)
self.layoutChanged.emit()