haeppycomplements 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. haeppycomplements-1.0.0/LICENSE +21 -0
  2. haeppycomplements-1.0.0/PKG-INFO +164 -0
  3. haeppycomplements-1.0.0/README.md +130 -0
  4. haeppycomplements-1.0.0/pyproject.toml +55 -0
  5. haeppycomplements-1.0.0/setup.cfg +4 -0
  6. haeppycomplements-1.0.0/src/haeppycomplements/__init__.py +12 -0
  7. haeppycomplements-1.0.0/src/haeppycomplements/powergrid/__init__.py +135 -0
  8. haeppycomplements-1.0.0/src/haeppycomplements/powergrid/core/column_def.py +86 -0
  9. haeppycomplements-1.0.0/src/haeppycomplements/powergrid/core/delegates.py +66 -0
  10. haeppycomplements-1.0.0/src/haeppycomplements/powergrid/core/model.py +197 -0
  11. haeppycomplements-1.0.0/src/haeppycomplements/powergrid/core/proxy.py +274 -0
  12. haeppycomplements-1.0.0/src/haeppycomplements/powergrid/features/__init__.py +1 -0
  13. haeppycomplements-1.0.0/src/haeppycomplements/powergrid/features/excel_export.py +340 -0
  14. haeppycomplements-1.0.0/src/haeppycomplements/powergrid/features/summaries.py +98 -0
  15. haeppycomplements-1.0.0/src/haeppycomplements/powergrid/resources/check.svg +1 -0
  16. haeppycomplements-1.0.0/src/haeppycomplements/powergrid/resources/check_white.svg +1 -0
  17. haeppycomplements-1.0.0/src/haeppycomplements/powergrid/resources/clipboard.svg +1 -0
  18. haeppycomplements-1.0.0/src/haeppycomplements/powergrid/resources/excel.svg +2 -0
  19. haeppycomplements-1.0.0/src/haeppycomplements/powergrid/resources/filter_funnel.svg +1 -0
  20. haeppycomplements-1.0.0/src/haeppycomplements/powergrid/resources/not_filter_funnel.svg +4 -0
  21. haeppycomplements-1.0.0/src/haeppycomplements/powergrid/resources/row_down_white.svg +1 -0
  22. haeppycomplements-1.0.0/src/haeppycomplements/powergrid/resources/scroll_left_white.svg +1 -0
  23. haeppycomplements-1.0.0/src/haeppycomplements/powergrid/resources/scroll_right_white.svg +1 -0
  24. haeppycomplements-1.0.0/src/haeppycomplements/powergrid/resources/scroll_up_white.svg +1 -0
  25. haeppycomplements-1.0.0/src/haeppycomplements/powergrid/resources/sort_clear.svg +1 -0
  26. haeppycomplements-1.0.0/src/haeppycomplements/powergrid/resources/sort_down.svg +2 -0
  27. haeppycomplements-1.0.0/src/haeppycomplements/powergrid/resources/sort_down_active.svg +2 -0
  28. haeppycomplements-1.0.0/src/haeppycomplements/powergrid/resources/sort_up.svg +2 -0
  29. haeppycomplements-1.0.0/src/haeppycomplements/powergrid/resources/sort_up_active.svg +2 -0
  30. haeppycomplements-1.0.0/src/haeppycomplements/powergrid/styles/dark_blue.qss +953 -0
  31. haeppycomplements-1.0.0/src/haeppycomplements/powergrid/styles/default_style.qss +955 -0
  32. haeppycomplements-1.0.0/src/haeppycomplements/powergrid/styles/modern_blue.qss +953 -0
  33. haeppycomplements-1.0.0/src/haeppycomplements/powergrid/styles/modern_teal.qss +748 -0
  34. haeppycomplements-1.0.0/src/haeppycomplements/powergrid/styles/violaceo_blue.qss +829 -0
  35. haeppycomplements-1.0.0/src/haeppycomplements/powergrid/ui/__init__.py +1 -0
  36. haeppycomplements-1.0.0/src/haeppycomplements/powergrid/ui/filter_menu.py +639 -0
  37. haeppycomplements-1.0.0/src/haeppycomplements/powergrid/ui/filter_row.py +214 -0
  38. haeppycomplements-1.0.0/src/haeppycomplements/powergrid/ui/summary_bar.py +54 -0
  39. haeppycomplements-1.0.0/src/haeppycomplements/powergrid/ui/table_view.py +1576 -0
  40. haeppycomplements-1.0.0/src/haeppycomplements.egg-info/PKG-INFO +164 -0
  41. haeppycomplements-1.0.0/src/haeppycomplements.egg-info/SOURCES.txt +49 -0
  42. haeppycomplements-1.0.0/src/haeppycomplements.egg-info/dependency_links.txt +1 -0
  43. haeppycomplements-1.0.0/src/haeppycomplements.egg-info/requires.txt +9 -0
  44. haeppycomplements-1.0.0/src/haeppycomplements.egg-info/top_level.txt +1 -0
  45. haeppycomplements-1.0.0/tests/test_powergrid_basics.py +245 -0
  46. haeppycomplements-1.0.0/tests/test_powergrid_date_tree.py +107 -0
  47. haeppycomplements-1.0.0/tests/test_powergrid_excel.py +127 -0
  48. haeppycomplements-1.0.0/tests/test_powergrid_filters.py +171 -0
  49. haeppycomplements-1.0.0/tests/test_powergrid_icons.py +144 -0
  50. haeppycomplements-1.0.0/tests/test_powergrid_selchecked.py +93 -0
  51. haeppycomplements-1.0.0/tests/test_powergrid_styles.py +83 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Haeppy28
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,164 @@
1
+ Metadata-Version: 2.4
2
+ Name: haeppycomplements
3
+ Version: 1.0.0
4
+ Summary: Suite de componentes PySide6 reutilizables. Primer componente: PowerGrid.
5
+ Author: Haeppy28
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/Haeppy28/HaeppyComplements
8
+ Project-URL: Repository, https://github.com/Haeppy28/HaeppyComplements
9
+ Keywords: pyside6,qt,table,datagrid,gui,components,haeppycomplements
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3 :: Only
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Classifier: Topic :: Software Development :: User Interfaces
23
+ Requires-Python: >=3.9
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: PySide6>=6.5
27
+ Provides-Extra: excel
28
+ Requires-Dist: openpyxl>=3.0; extra == "excel"
29
+ Provides-Extra: dev
30
+ Requires-Dist: pytest>=7.0; extra == "dev"
31
+ Requires-Dist: pytest-qt; extra == "dev"
32
+ Requires-Dist: build>=1.0; extra == "dev"
33
+ Dynamic: license-file
34
+
35
+ # HaeppyComplements
36
+
37
+ Suite de **componentes PySide6 reutilizables** para construir aplicaciones de
38
+ escritorio de forma rapida, consistente y escalable.
39
+
40
+ El primer componente es **PowerGrid**, una tabla avanzada con filtros estilo
41
+ Excel, resumenes, subtablas con *lazy loading*, exportacion a Excel y estilos
42
+ intercambiables en caliente.
43
+
44
+ ```
45
+ HaeppyComplements
46
+ ├── powergrid (ya disponible)
47
+ ├── componente2 (futuro)
48
+ ├── componente3 (futuro)
49
+ └── ...
50
+ ```
51
+
52
+ Cada componente vive en un subpaquete propio de `haeppycomplements`, totalmente
53
+ independiente de los demas: agregar un componente nuevo no toca nada existente.
54
+
55
+ ---
56
+
57
+ ## Instalacion
58
+
59
+ ```bash
60
+ pip install haeppycomplements # base (PySide6 incluido)
61
+ pip install "haeppycomplements[excel]" # + exportacion a Excel (openpyxl)
62
+ ```
63
+
64
+ Desde GitHub (pre-publicacion):
65
+
66
+ ```bash
67
+ pip install git+https://github.com/Haeppy28/HaeppyComplements.git
68
+ ```
69
+
70
+ Desarrollo local (clonado del repositorio):
71
+
72
+ ```bash
73
+ pip install -e .[dev] # instalacion editable + pytest
74
+ ```
75
+
76
+ **Requisitos:** Python >= 3.9.
77
+
78
+ ---
79
+
80
+ ## Uso basico (PowerGrid)
81
+
82
+ ```python
83
+ from haeppycomplements.powergrid import PowerGrid, ColumnDef
84
+
85
+ columns = [
86
+ ColumnDef("Codigo", type="text", width=100),
87
+ ColumnDef("Debito", type="number", width=110, format="#,##0.00", summary="sum"),
88
+ ColumnDef("Fecha", type="date", width=100, format="dd/MM/yyyy"),
89
+ ColumnDef("Estado", type="combo", width=120, items=["Activo", "Inactivo"]),
90
+ ColumnDef("Sel", type="checkbox", width=60),
91
+ ]
92
+
93
+ grid = PowerGrid(columns=columns, data=[...])
94
+ ```
95
+
96
+ Tambien estan disponibles `setup_table` (equivalente a `PowerGrid`),
97
+ `PowerTableView` (la clase) y `ColumnDef`.
98
+
99
+ ### Lo que trae PowerGrid
100
+
101
+ | Area | Funcionalidades |
102
+ |---|---|
103
+ | **Filtros** | Cajas por columna con operadores (`contains`, `>=`, `between`, ...) y menu contextual estilo Excel; valores encadenados entre columnas |
104
+ | **Fechas** | Arbol **Ano -> Mes -> Fecha contraido** con seleccion jerarquica y busqueda |
105
+ | **Resumenes** | `sum`, `count`, `avg`, `min`, `max` en una barra configurable |
106
+ | **Subtablas** | Detalle por fila, anidables en varios niveles, con *lazy loading* sincrono y asincrono |
107
+ | **Columnas** | `text`, `number`, `date`, `combo`, `checkbox` con formatos, colores y alineacion |
108
+ | **Exportar/Copiar** | Excel (`.xlsx`) con estilo y columnas ocultas; portapapeles TSV |
109
+ | **Estilos** | 5 temas intercambiables en caliente, definidos por **tokens de color** |
110
+ | **Iconos** | Menu del encabezado parametrizable por accion y estado |
111
+
112
+ Documentacion detallada del componente: [docs/powergrid_manual.md](docs/powergrid_manual.md).
113
+
114
+ ---
115
+
116
+ ## Estructura del repositorio
117
+
118
+ ```
119
+ HaeppyComplements/
120
+ ├── src/haeppycomplements/
121
+ │ ├── __init__.py # version + registro de componentes
122
+ │ └── powergrid/ # componente PowerGrid
123
+ │ ├── ui/ core/ features/
124
+ │ ├── styles/*.qss # temas por tokens
125
+ │ └── resources/*.svg # iconos
126
+ ├── examples/ # demos (requieren Python + PySide6)
127
+ ├── tests/ # pytest (Qt offscreen)
128
+ └── docs/ # manuales por componente
129
+ ```
130
+
131
+ ## Ejemplos
132
+
133
+ Las demos viven en `examples/` y se ejecutan desde la raiz del proyecto
134
+ (recomendado con `pip install -e .`):
135
+
136
+ ```bash
137
+ python examples/demo_full_powergrid.py # demo completa (requiere nomina.db)
138
+ python examples/demo_contable.py
139
+ python examples/demo_style_contable.py
140
+ python examples/demo_lazy_subtables.py
141
+ python examples/demo_nomina_db.py # requiere: python examples/example_db_sql/build_db.py
142
+ ```
143
+
144
+ ## Tests
145
+
146
+ ```bash
147
+ pip install -e .[dev]
148
+ pytest
149
+ ```
150
+
151
+ La suite corre con Qt en modo `offscreen` (sin pantalla), apta para CI local
152
+ y GitHub Actions.
153
+
154
+ ## Publicacion
155
+
156
+ - **Version:** se toma de `haeppycomplements/__init__.py::__version__` (un solo
157
+ origen). Actual semantica: `MAYOR.MENOR.PATCH`.
158
+ - **Releases:** cada release publica se marca con un tag `vX.Y.Z` en GitHub;
159
+ el workflow de GitHub Actions construye el wheel/sdist y lo publica en PyPI.
160
+ - **Historial:** ver [CHANGELOG.md](CHANGELOG.md).
161
+
162
+ ## Licencia
163
+
164
+ [MIT](LICENSE) - Copyright (c) 2026 Haeppy28
@@ -0,0 +1,130 @@
1
+ # HaeppyComplements
2
+
3
+ Suite de **componentes PySide6 reutilizables** para construir aplicaciones de
4
+ escritorio de forma rapida, consistente y escalable.
5
+
6
+ El primer componente es **PowerGrid**, una tabla avanzada con filtros estilo
7
+ Excel, resumenes, subtablas con *lazy loading*, exportacion a Excel y estilos
8
+ intercambiables en caliente.
9
+
10
+ ```
11
+ HaeppyComplements
12
+ ├── powergrid (ya disponible)
13
+ ├── componente2 (futuro)
14
+ ├── componente3 (futuro)
15
+ └── ...
16
+ ```
17
+
18
+ Cada componente vive en un subpaquete propio de `haeppycomplements`, totalmente
19
+ independiente de los demas: agregar un componente nuevo no toca nada existente.
20
+
21
+ ---
22
+
23
+ ## Instalacion
24
+
25
+ ```bash
26
+ pip install haeppycomplements # base (PySide6 incluido)
27
+ pip install "haeppycomplements[excel]" # + exportacion a Excel (openpyxl)
28
+ ```
29
+
30
+ Desde GitHub (pre-publicacion):
31
+
32
+ ```bash
33
+ pip install git+https://github.com/Haeppy28/HaeppyComplements.git
34
+ ```
35
+
36
+ Desarrollo local (clonado del repositorio):
37
+
38
+ ```bash
39
+ pip install -e .[dev] # instalacion editable + pytest
40
+ ```
41
+
42
+ **Requisitos:** Python >= 3.9.
43
+
44
+ ---
45
+
46
+ ## Uso basico (PowerGrid)
47
+
48
+ ```python
49
+ from haeppycomplements.powergrid import PowerGrid, ColumnDef
50
+
51
+ columns = [
52
+ ColumnDef("Codigo", type="text", width=100),
53
+ ColumnDef("Debito", type="number", width=110, format="#,##0.00", summary="sum"),
54
+ ColumnDef("Fecha", type="date", width=100, format="dd/MM/yyyy"),
55
+ ColumnDef("Estado", type="combo", width=120, items=["Activo", "Inactivo"]),
56
+ ColumnDef("Sel", type="checkbox", width=60),
57
+ ]
58
+
59
+ grid = PowerGrid(columns=columns, data=[...])
60
+ ```
61
+
62
+ Tambien estan disponibles `setup_table` (equivalente a `PowerGrid`),
63
+ `PowerTableView` (la clase) y `ColumnDef`.
64
+
65
+ ### Lo que trae PowerGrid
66
+
67
+ | Area | Funcionalidades |
68
+ |---|---|
69
+ | **Filtros** | Cajas por columna con operadores (`contains`, `>=`, `between`, ...) y menu contextual estilo Excel; valores encadenados entre columnas |
70
+ | **Fechas** | Arbol **Ano -> Mes -> Fecha contraido** con seleccion jerarquica y busqueda |
71
+ | **Resumenes** | `sum`, `count`, `avg`, `min`, `max` en una barra configurable |
72
+ | **Subtablas** | Detalle por fila, anidables en varios niveles, con *lazy loading* sincrono y asincrono |
73
+ | **Columnas** | `text`, `number`, `date`, `combo`, `checkbox` con formatos, colores y alineacion |
74
+ | **Exportar/Copiar** | Excel (`.xlsx`) con estilo y columnas ocultas; portapapeles TSV |
75
+ | **Estilos** | 5 temas intercambiables en caliente, definidos por **tokens de color** |
76
+ | **Iconos** | Menu del encabezado parametrizable por accion y estado |
77
+
78
+ Documentacion detallada del componente: [docs/powergrid_manual.md](docs/powergrid_manual.md).
79
+
80
+ ---
81
+
82
+ ## Estructura del repositorio
83
+
84
+ ```
85
+ HaeppyComplements/
86
+ ├── src/haeppycomplements/
87
+ │ ├── __init__.py # version + registro de componentes
88
+ │ └── powergrid/ # componente PowerGrid
89
+ │ ├── ui/ core/ features/
90
+ │ ├── styles/*.qss # temas por tokens
91
+ │ └── resources/*.svg # iconos
92
+ ├── examples/ # demos (requieren Python + PySide6)
93
+ ├── tests/ # pytest (Qt offscreen)
94
+ └── docs/ # manuales por componente
95
+ ```
96
+
97
+ ## Ejemplos
98
+
99
+ Las demos viven en `examples/` y se ejecutan desde la raiz del proyecto
100
+ (recomendado con `pip install -e .`):
101
+
102
+ ```bash
103
+ python examples/demo_full_powergrid.py # demo completa (requiere nomina.db)
104
+ python examples/demo_contable.py
105
+ python examples/demo_style_contable.py
106
+ python examples/demo_lazy_subtables.py
107
+ python examples/demo_nomina_db.py # requiere: python examples/example_db_sql/build_db.py
108
+ ```
109
+
110
+ ## Tests
111
+
112
+ ```bash
113
+ pip install -e .[dev]
114
+ pytest
115
+ ```
116
+
117
+ La suite corre con Qt en modo `offscreen` (sin pantalla), apta para CI local
118
+ y GitHub Actions.
119
+
120
+ ## Publicacion
121
+
122
+ - **Version:** se toma de `haeppycomplements/__init__.py::__version__` (un solo
123
+ origen). Actual semantica: `MAYOR.MENOR.PATCH`.
124
+ - **Releases:** cada release publica se marca con un tag `vX.Y.Z` en GitHub;
125
+ el workflow de GitHub Actions construye el wheel/sdist y lo publica en PyPI.
126
+ - **Historial:** ver [CHANGELOG.md](CHANGELOG.md).
127
+
128
+ ## Licencia
129
+
130
+ [MIT](LICENSE) - Copyright (c) 2026 Haeppy28
@@ -0,0 +1,55 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "haeppycomplements"
7
+ dynamic = ["version"]
8
+ description = "Suite de componentes PySide6 reutilizables. Primer componente: PowerGrid."
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = {text = "MIT"}
12
+ authors = [{name = "Haeppy28"}]
13
+ keywords = ["pyside6", "qt", "table", "datagrid", "gui", "components", "haeppycomplements"]
14
+ classifiers = [
15
+ "Development Status :: 5 - Production/Stable",
16
+ "Intended Audience :: Developers",
17
+ "License :: OSI Approved :: MIT License",
18
+ "Operating System :: OS Independent",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3 :: Only",
21
+ "Programming Language :: Python :: 3.9",
22
+ "Programming Language :: Python :: 3.10",
23
+ "Programming Language :: Python :: 3.11",
24
+ "Programming Language :: Python :: 3.12",
25
+ "Programming Language :: Python :: 3.13",
26
+ "Topic :: Software Development :: Libraries :: Python Modules",
27
+ "Topic :: Software Development :: User Interfaces",
28
+ ]
29
+ dependencies = [
30
+ "PySide6>=6.5",
31
+ ]
32
+
33
+ [project.optional-dependencies]
34
+ excel = ["openpyxl>=3.0"]
35
+ dev = ["pytest>=7.0", "pytest-qt", "build>=1.0"]
36
+
37
+ [project.urls]
38
+ Homepage = "https://github.com/Haeppy28/HaeppyComplements"
39
+ Repository = "https://github.com/Haeppy28/HaeppyComplements"
40
+
41
+ [tool.setuptools]
42
+ include-package-data = true
43
+
44
+ [tool.setuptools.dynamic]
45
+ version = {attr = "haeppycomplements.__version__"}
46
+
47
+ [tool.setuptools.packages.find]
48
+ where = ["src"]
49
+
50
+ [tool.setuptools.package-data]
51
+ "haeppycomplements.powergrid" = ["styles/*.qss", "resources/*.svg"]
52
+
53
+ [tool.pytest.ini_options]
54
+ testpaths = ["tests"]
55
+ pythonpath = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,12 @@
1
+ """HaeppyComplements - Suite de componentes PySide6 reutilizables.
2
+
3
+ El primer componente es PowerGrid (tabla avanzada con filtros, resumenes,
4
+ subtablas con lazy loading, exportacion a Excel y estilos parametrizables).
5
+ Cada componente vive en un subpaquete propio (``haeppycomplements.powergrid``
6
+ y futuros ``haeppycomplements.*``) totalmente independiente de los demas.
7
+ """
8
+
9
+ __version__ = "1.0.0"
10
+
11
+ # Registro de componentes disponibles (para descubrimiento y utilidades futuras).
12
+ COMPONENTS = ("powergrid",)
@@ -0,0 +1,135 @@
1
+ """PowerGrid - Tabla avanzada con filtros, resumenes y edicion inline.
2
+
3
+ Componente de HaeppyComplements. Uso recomendado:
4
+
5
+ from haeppycomplements.powergrid import PowerGrid, ColumnDef
6
+
7
+ grid = PowerGrid(columns=[...], data=[...])
8
+ """
9
+
10
+ from .core.column_def import ColumnDef
11
+ from .ui.table_view import PowerTableView
12
+
13
+ __version__ = "1.0.0"
14
+
15
+
16
+ def setup_table(
17
+ columns=None,
18
+ headers=None,
19
+ data=None,
20
+ parent=None,
21
+ pos=(0, 0),
22
+ anchor="parent",
23
+ margins=(0, 0, 0, 0),
24
+ # Filtros
25
+ filters=True,
26
+ filters_position="top",
27
+ filter_type="both",
28
+ filter_visible=True,
29
+ filter_style=None,
30
+ filter_modes=None,
31
+ multi_filter_separator=";",
32
+ # Resumenes
33
+ summaries=None,
34
+ summaries_position="bottom",
35
+ summary_style=None,
36
+ # Columnas
37
+ stretch_last_section=True,
38
+ # Personalizacion
39
+ colors=None,
40
+ font=None,
41
+ header_font=None,
42
+ row_height=6,
43
+ header_height=6,
44
+ zebra=True,
45
+ grid_lines=False,
46
+ editable=True,
47
+ sortable=True,
48
+ resizable=True,
49
+ grouping=False,
50
+ context_menu=True,
51
+ fixed_width=None,
52
+ fixed_height=None,
53
+ style: str = None,
54
+ filter_row_height: int = 26,
55
+ edit_triggers=None,
56
+ menu_icons=None,
57
+ style_preset=None,
58
+ ):
59
+ """Crea y configura una PowerTableView completa.
60
+
61
+ Args:
62
+ columns: Lista de ColumnDef.
63
+ headers: Lista de strings (solo si columns=None).
64
+ data: Lista de listas con los datos.
65
+ parent: Widget padre.
66
+ pos: (x, y) posicion dentro del padre.
67
+ anchor: Comportamiento de redimensionamiento.
68
+ margins: (left, top, right, bottom) margenes.
69
+ filters: True/False o dict con configuracion.
70
+ filters_position: "top" o "bottom".
71
+ filter_type: "boxes" (solo cajas), "menu" (solo contextual), "both", "none".
72
+ filter_visible: True para mostrar filtros, False para ocultar.
73
+ filter_style: Hoja de estilos CSS para la fila de filtros.
74
+ multi_filter_separator: Separador para multiples criterios OR (default: ";").
75
+ summaries: Lista de operaciones: ["sum","count","avg","min","max"].
76
+ summaries_position: "top" o "bottom".
77
+ summary_style: Hoja de estilos CSS para la barra de resumenes.
78
+ colors: Dict con colores personalizados.
79
+ style: Hoja de estilo CSS personalizada para toda la tabla.
80
+ Si se proporciona, anula los parámetros colors, summary_style y filter_style.
81
+ El CSS debe usar selectores descendientes que comiencen con "PowerTableView"
82
+ para afectar solo a los subcomponentes de la tabla.
83
+ filter_row_height: Alto de la fila de filtros en pixeles (default: 26).
84
+ edit_triggers: Triggers de edicion (QAbstractItemView.EditTrigger).
85
+ None usa el default de Qt (doble clic y F2).
86
+ menu_icons: Dict {accion: {estado: icono}} para personalizar los iconos
87
+ del menu del encabezado. Ver PowerGrid.ui.filter_menu para
88
+ el formato (str | (str, color) | None).
89
+ style_preset: Clave del estilo default de PowerGrid: "modern_gray",
90
+ "modern_blue", "modern_teal", "dark_blue" o
91
+ "violaceo_blue" (o ruta a un .qss propio). Se puede
92
+ cambiar en caliente con grid.set_style_preset(...).
93
+ row_height: Alto de fila en pixeles.
94
+ header_height: Alto del header en pixeles.
95
+ zebra: Colores alternados.
96
+ grid_lines: Mostrar lineas de grid.
97
+ editable: Permitir edicion inline.
98
+ sortable: Permitir ordenamiento por clic.
99
+ resizable: Permitir redimensionar columnas.
100
+ grouping: Habilitar agrupaciones.
101
+ context_menu: Menu contextual en datos.
102
+
103
+ Returns:
104
+ PowerTableView configurado.
105
+ """
106
+ return PowerTableView(
107
+ columns=columns, headers=headers, data=data, parent=parent,
108
+ pos=pos, anchor=anchor, margins=margins,
109
+ filters=filters, filters_position=filters_position,
110
+ filter_type=filter_type, filter_visible=filter_visible,
111
+ filter_style=filter_style,
112
+ filter_modes=filter_modes, multi_filter_separator=multi_filter_separator,
113
+ summaries=summaries, summaries_position=summaries_position,
114
+ summary_style=summary_style,
115
+ stretch_last_section=stretch_last_section,
116
+ colors=colors, font=font, header_font=header_font,
117
+ row_height=row_height, header_height=header_height,
118
+ zebra=zebra, grid_lines=grid_lines,
119
+ editable=editable, sortable=sortable, resizable=resizable,
120
+ grouping=grouping, context_menu=context_menu,
121
+ fixed_width=fixed_width, fixed_height=fixed_height,
122
+ style=style,
123
+ filter_row_height=filter_row_height,
124
+ edit_triggers=edit_triggers,
125
+ menu_icons=menu_icons,
126
+ style_preset=style_preset,
127
+ )
128
+
129
+
130
+ # Alias ergonomico: PowerGrid es la fabrica que crea una PowerTableView.
131
+ # Habilita el import documentado:
132
+ # from haeppycomplements.powergrid import PowerGrid
133
+ PowerGrid = setup_table
134
+
135
+ __all__ = ["setup_table", "PowerGrid", "PowerTableView", "ColumnDef"]
@@ -0,0 +1,86 @@
1
+ """Definicion de columnas para PowerGrid."""
2
+
3
+
4
+ class ColumnDef:
5
+ """Define una columna de la tabla.
6
+
7
+ Args:
8
+ name: Nombre visible de la columna.
9
+ key: Key interna (si no se especifica, = name).
10
+ type: Tipo de dato: "text", "number", "date", "combo", "checkbox", "button".
11
+ width: Ancho inicial en pixeles.
12
+ min_width: Ancho minimo.
13
+ editable: Si la celda es editable.
14
+ checkable: Si una columna type="checkbox" puede marcarse/desmarcarse.
15
+ Con False, las celdas muestran el estado pero no se pueden alternar
16
+ (ni por clic ni con la tecla Espacio) y el header no muestra el
17
+ checkbox de "marcar/desmarcar todo". Default: True.
18
+ visible: Si la columna es visible.
19
+ format: Formato de visualizacion (ej: "#,##0.00", "dd/MM/yyyy").
20
+ summary: Operacion de resumen: "sum", "count", "avg", "min", "max".
21
+ summary_label: Etiqueta personalizada en el resumen.
22
+ filter: True/False o lista de modos de filtro.
23
+ filter_operator: Operador de filtro por defecto para la columna.
24
+ "contains", "not_contains", "=", "!=", ">", "<", ">=", "<=", "between".
25
+ Si no se especifica, se deduce del tipo: texto->"contains", numero->">=", fecha->">=".
26
+ items: Para type="combo": valores del desplegable.
27
+ alignment: "left", "center", "right".
28
+ background: Color fijo o funcion(row) -> color.
29
+ foreground: Color fijo o funcion(row) -> color.
30
+ groupable: Si se puede agrupar por esta columna.
31
+ is_key: True si esta columna es la clave identificadora del registro
32
+ (ej: codigo de un documento). Se usa con el lazy loading de
33
+ subtablas: al expandir una fila, PowerGrid devuelve el valor de
34
+ esta columna (subtableKeyRequested / set_subtable_loader).
35
+ Si ninguna columna tiene is_key=True, se usa el indice de fila.
36
+ """
37
+
38
+ def __init__(
39
+ self,
40
+ name,
41
+ key=None,
42
+ type="text",
43
+ width=100,
44
+ min_width=40,
45
+ editable=False,
46
+ checkable=True,
47
+ visible=True,
48
+ format=None,
49
+ summary=None,
50
+ summary_label=None,
51
+ filter=True,
52
+ filter_operator=None,
53
+ items=None,
54
+ alignment="left",
55
+ background=None,
56
+ foreground=None,
57
+ groupable=True,
58
+ is_key=False,
59
+ ):
60
+ self.name = name
61
+ self.key = key if key else name
62
+ self.type = type
63
+ self.width = width
64
+ self.min_width = min_width
65
+ self.editable = editable
66
+ self.checkable = checkable
67
+ self.visible = visible
68
+ self.format = format
69
+ self.summary = summary
70
+ self.summary_label = summary_label if summary_label else name
71
+ self.filter = filter
72
+ self.items = items if items else []
73
+ self.alignment = alignment
74
+ self.background = background
75
+ self.foreground = foreground
76
+ self.groupable = groupable
77
+ self.is_key = is_key
78
+ # Operador por defecto segun tipo
79
+ if filter_operator:
80
+ self.filter_operator = filter_operator
81
+ elif type == "number":
82
+ self.filter_operator = ">="
83
+ elif type == "date":
84
+ self.filter_operator = ">="
85
+ else:
86
+ self.filter_operator = "contains"
@@ -0,0 +1,66 @@
1
+ """Delegados personalizados para edición por tipo de columna."""
2
+
3
+ from PySide6.QtWidgets import QStyledItemDelegate, QDateEdit, QLineEdit, QComboBox
4
+ from PySide6.QtCore import Qt, QDate
5
+
6
+
7
+ class DateDelegate(QStyledItemDelegate):
8
+ def createEditor(self, parent, option, index):
9
+ editor = QDateEdit(parent)
10
+ editor.setCalendarPopup(True)
11
+ editor.setDisplayFormat("dd/MM/yyyy")
12
+ return editor
13
+
14
+ def setEditorData(self, editor, index):
15
+ value = index.data(Qt.ItemDataRole.DisplayRole)
16
+ try:
17
+ parts = str(value).split("/")
18
+ d = QDate(int(parts[2]), int(parts[1]), int(parts[0]))
19
+ editor.setDate(d)
20
+ except Exception:
21
+ editor.setDate(QDate.currentDate())
22
+
23
+ def setModelData(self, editor, model, index):
24
+ model.setData(index, editor.date().toString("dd/MM/yyyy"))
25
+
26
+
27
+ class NumberDelegate(QStyledItemDelegate):
28
+ def createEditor(self, parent, option, index):
29
+ editor = QLineEdit(parent)
30
+ editor.setAlignment(Qt.AlignmentFlag.AlignRight)
31
+ return editor
32
+
33
+ def setEditorData(self, editor, index):
34
+ value = index.data(Qt.ItemDataRole.EditRole)
35
+ editor.setText(str(value))
36
+
37
+ def setModelData(self, editor, model, index):
38
+ text = editor.text().strip()
39
+ try:
40
+ value = float(text.replace(",", ""))
41
+ model.setData(index, value)
42
+ except ValueError:
43
+ pass
44
+
45
+
46
+ class ComboDelegate(QStyledItemDelegate):
47
+ def __init__(self, items, parent=None):
48
+ super().__init__(parent)
49
+ self._items = items
50
+
51
+ def createEditor(self, parent, option, index):
52
+ editor = QComboBox(parent)
53
+ editor.addItems(self._items)
54
+ editor.setEditable(True)
55
+ return editor
56
+
57
+ def setEditorData(self, editor, index):
58
+ value = index.data(Qt.ItemDataRole.DisplayRole)
59
+ idx = editor.findText(str(value))
60
+ if idx >= 0:
61
+ editor.setCurrentIndex(idx)
62
+ else:
63
+ editor.setCurrentText(str(value))
64
+
65
+ def setModelData(self, editor, model, index):
66
+ model.setData(index, editor.currentText())