From 30447a801afdac80da948a6f0961ce7b08591f4f Mon Sep 17 00:00:00 2001 From: Maxim Slipenko Date: Sat, 3 Feb 2024 16:20:33 +0300 Subject: [PATCH] =?UTF-8?q?feat:=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D0=B2=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD?= =?UTF-8?q?=D0=BE=D1=81=D1=82=D1=8C=20=D1=83=D0=B4=D0=B0=D0=BB=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20=D1=84=D0=B0=D0=BA=D1=82=D0=BE=D1=80=D1=8B=20(#103)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #102 --- statapp/main_window.py | 25 +++++++++++++++++++++++-- statapp/models/input_values_model.py | 3 +++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/statapp/main_window.py b/statapp/main_window.py index 620a9df..a8ca582 100644 --- a/statapp/main_window.py +++ b/statapp/main_window.py @@ -19,8 +19,8 @@ # import numpy as np from PySide2 import QtCore -from PySide2.QtCore import Slot -from PySide2.QtWidgets import QMainWindow, QMessageBox +from PySide2.QtCore import Slot, Qt, QPoint +from PySide2.QtWidgets import QMainWindow, QMessageBox, QAction, QMenu from statapp.calculations import generateXValues, generateYValues from statapp.constants import NUMBERS_PRECISION @@ -79,6 +79,27 @@ class MainWindow(QMainWindow): # x1 = generateXValues(20, 2, 0, y) # x2 = generateXValues(10, 1, 0, y) # self.model.updateAllData(np.concatenate([y, x1, x2], axis=1)) + self.ui.tableView.horizontalHeader().setContextMenuPolicy(Qt.CustomContextMenu) + self.ui.tableView.horizontalHeader().customContextMenuRequested.connect(self.removeColumn) + + + def removeColumn(self, event: QPoint): + menu = QMenu(self) + + col = self.ui.tableView.columnAt(event.x()) + + if col == 0: + return + + def fun(): + self.model.removeCol(col) + self.isDataChanged = True + + selectAction = QAction("Удалить", self) + selectAction.triggered.connect(fun) + menu.addAction(selectAction) + menu.exec_(self.ui.tableView.mapToGlobal(event)) + def updateActionsEnabled(self): diff --git a/statapp/models/input_values_model.py b/statapp/models/input_values_model.py index 6360eb4..40f19c1 100644 --- a/statapp/models/input_values_model.py +++ b/statapp/models/input_values_model.py @@ -33,3 +33,6 @@ class InputValuesModel(EditableTableModel): def getY(self): return self._data[:, 0] + + def removeCol(self, index: int): + self.updateAllData(np.delete(self._data, index, axis=1))