|
6 | 6 | # Import Qt modules first |
7 | 7 | from PySide6.QtWidgets import ( |
8 | 8 | QApplication, QMainWindow, QHeaderView, QLabel, |
9 | | - QVBoxLayout, QSizePolicy, QPushButton |
| 9 | + QVBoxLayout, QSizePolicy, QPushButton, QGridLayout, QWidget, QFrame |
10 | 10 | ) |
11 | 11 | from PySide6.QtGui import QIcon, QFont, QPixmap, QCursor |
12 | 12 | from PySide6.QtCore import Qt, QSize |
|
19 | 19 | from langchain_core.messages import HumanMessage, AIMessage |
20 | 20 | from OprFuncs import read_file |
21 | 21 | from modules.ui_main import Ui_MainWindow |
| 22 | +from uiEXT.ColDialog import ColDialog |
22 | 23 |
|
23 | 24 |
|
24 | 25 | def resizeEvent(self, event): |
@@ -47,7 +48,7 @@ def __init__(self, user_id): |
47 | 48 |
|
48 | 49 | # Initialize app functions after UI setup |
49 | 50 | self.app_functions = GuiFunctions(self, self.user_id) |
50 | | - self.load_reports() |
| 51 | + self.load_oldreports() |
51 | 52 |
|
52 | 53 | # Fix path separators for Windows - use forward slashes |
53 | 54 | self.report_logo = "images/icons/cil-report-colored-1.png" |
@@ -156,30 +157,107 @@ def openCloseRightBox(): |
156 | 157 | widgets.home_2.layout().addWidget(welcome_label) |
157 | 158 | widgets.btn_home.setStyleSheet(UIFunctions.selectMenu(widgets.btn_home.styleSheet())) |
158 | 159 |
|
159 | | - def load_reports(self): |
160 | | - #self.report_list.clear() |
161 | | - reports = self.app_functions.db.get_user_reports(self.user_id) |
162 | | - for report in reports: |
163 | | - report_btn = QPushButton(self.ui.topMenus) |
164 | | - report_btn.setObjectName(report['name']) |
165 | | - sizePolicy1 = QSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed) |
166 | | - sizePolicy1.setHeightForWidth(report_btn.sizePolicy().hasHeightForWidth()) |
167 | | - report_btn.setSizePolicy(sizePolicy1) |
168 | | - report_btn.setMinimumSize(QSize(0, 45)) |
169 | | - # report_btn.setFont(Qfont) |
170 | | - report_btn.setCursor(QCursor(Qt.CursorShape.PointingHandCursor)) |
171 | | - report_btn.setLayoutDirection(Qt.LayoutDirection.LeftToRight) |
172 | | - report_btn.setText(report['name']) |
173 | | - report_btn.setProperty("report_id", report['id']) |
174 | | - report_btn.setProperty("report_name", report['name']) |
175 | | - |
176 | | - report_logo = "images/icons/cil-report-colored-1.png" |
177 | | - pixmap_report_logo = QPixmap(report_logo) |
178 | | - logo_icon = QIcon(pixmap_report_logo) |
179 | | - report_btn.setIcon(logo_icon) |
180 | | - |
181 | | - report_btn.clicked.connect(self.report_button_clicked) |
182 | | - self.ui.verticalLayout_14.addWidget(report_btn) |
| 160 | + # Connect column header click event |
| 161 | + widgets.tableData.horizontalHeader().sectionClicked.connect(self.show_column_dialog) |
| 162 | + |
| 163 | + def load_oldreports(self): |
| 164 | + |
| 165 | + # Create a grid layout for the home page |
| 166 | + if hasattr(self.ui, 'home_2'): |
| 167 | + # Clear existing layout if any |
| 168 | + if self.ui.home_2.layout(): |
| 169 | + QWidget().setLayout(self.ui.home_2.layout()) |
| 170 | + |
| 171 | + # Create new grid layout |
| 172 | + grid_layout = QGridLayout(self.ui.home_2) |
| 173 | + grid_layout.setSpacing(10) |
| 174 | + grid_layout.setContentsMargins(20, 20, 20, 20) |
| 175 | + |
| 176 | + # Create welcome message widget for top left |
| 177 | + welcome_widget = QWidget() |
| 178 | + welcome_layout = QVBoxLayout(welcome_widget) |
| 179 | + welcome_layout.addStretch() |
| 180 | + |
| 181 | + # Add welcome widget to top left |
| 182 | + grid_layout.addWidget(welcome_widget, 0, 0) |
| 183 | + |
| 184 | + # Create reports container for top right |
| 185 | + reports_container = QWidget() |
| 186 | + reports_layout = QVBoxLayout(reports_container) |
| 187 | + reports_layout.setSpacing(5) |
| 188 | + reports_layout.setContentsMargins(0, 0, 0, 0) |
| 189 | + |
| 190 | + # Add title |
| 191 | + title_label = QLabel("Your Reports") |
| 192 | + title_label.setStyleSheet(""" |
| 193 | + QLabel { |
| 194 | + font-size: 16px; |
| 195 | + font-weight: bold; |
| 196 | + color: white; |
| 197 | + padding: 10px; |
| 198 | + background-color: rgb(196, 7, 105); |
| 199 | + border-radius: 4px; |
| 200 | + } |
| 201 | + """) |
| 202 | + title_label.setAlignment(Qt.AlignCenter) |
| 203 | + reports_layout.addWidget(title_label) |
| 204 | + reports_layout.addSpacing(10) |
| 205 | + |
| 206 | + reports = self.app_functions.db.get_user_reports(self.user_id) |
| 207 | + for report in reports: |
| 208 | + report_btn = QPushButton() |
| 209 | + report_btn.setObjectName(report['name']) |
| 210 | + report_btn.setMinimumHeight(40) |
| 211 | + report_btn.setCursor(QCursor(Qt.CursorShape.PointingHandCursor)) |
| 212 | + report_btn.setText(report['name']) |
| 213 | + report_btn.setProperty("report_id", report['id']) |
| 214 | + report_btn.setProperty("report_name", report['name']) |
| 215 | + |
| 216 | + # Set button style |
| 217 | + report_btn.setStyleSheet(""" |
| 218 | + QPushButton { |
| 219 | + background-color: rgb(24, 196, 199); |
| 220 | + border: 1px solid #ddd; |
| 221 | + border-radius: 4px; |
| 222 | + padding: 5px 10px; |
| 223 | + text-align: left; |
| 224 | + } |
| 225 | + QPushButton:hover { |
| 226 | + background-color: rgb(7, 60, 196); |
| 227 | + } |
| 228 | + """) |
| 229 | + |
| 230 | + # Add icon |
| 231 | + report_logo = "images/icons/cil-report-colored-1.png" |
| 232 | + pixmap_report_logo = QPixmap(report_logo) |
| 233 | + if not pixmap_report_logo.isNull(): |
| 234 | + scaled_pixmap = pixmap_report_logo.scaled(24, 24, Qt.KeepAspectRatio, Qt.SmoothTransformation) |
| 235 | + report_btn.setIcon(QIcon(scaled_pixmap)) |
| 236 | + report_btn.setIconSize(QSize(24, 24)) |
| 237 | + |
| 238 | + report_btn.clicked.connect(self.report_button_clicked) |
| 239 | + reports_layout.addWidget(report_btn) |
| 240 | + |
| 241 | + # Add reports container to top right |
| 242 | + grid_layout.addWidget(reports_container, 0, 1) |
| 243 | + |
| 244 | + # Add empty widgets for bottom left and right |
| 245 | + bottom_left = QWidget() |
| 246 | + bottom_right = QWidget() |
| 247 | + grid_layout.addWidget(bottom_left, 1, 0) |
| 248 | + grid_layout.addWidget(bottom_right, 1, 1) |
| 249 | + |
| 250 | + # Add horizontal line |
| 251 | + horizontal_line = QFrame() |
| 252 | + horizontal_line.setFrameShape(QFrame.Shape.HLine) |
| 253 | + horizontal_line.setStyleSheet("background-color: #ddd;") |
| 254 | + grid_layout.addWidget(horizontal_line, 1, 0, 1, 2) |
| 255 | + |
| 256 | + # Add vertical line |
| 257 | + vertical_line = QFrame() |
| 258 | + vertical_line.setFrameShape(QFrame.Shape.VLine) |
| 259 | + vertical_line.setStyleSheet("background-color: #ddd;") |
| 260 | + grid_layout.addWidget(vertical_line, 0, 1, 2, 1) |
183 | 261 |
|
184 | 262 | def report_button_clicked(self): |
185 | 263 | btn = self.sender() |
@@ -313,6 +391,12 @@ def mousePressEvent(self, event): |
313 | 391 | if event.buttons() == Qt.RightButton: |
314 | 392 | print('Mouse click: RIGHT CLICK') |
315 | 393 |
|
| 394 | + def show_column_dialog(self, column_index): |
| 395 | + """Show the column dialog when a column header is clicked""" |
| 396 | + column_name = widgets.tableData.horizontalHeaderItem(column_index).text() |
| 397 | + dialog = ColDialog(self, self.app_functions.df, column_name) |
| 398 | + dialog.setWindowTitle(f"Column Options - {column_name}") |
| 399 | + dialog.exec_() |
316 | 400 |
|
317 | 401 | if __name__ == "__main__": |
318 | 402 | # Create QApplication instance |
|
0 commit comments