feat: добавлена возможность удалить факторы (#103)

Closes #102
This commit is contained in:
Maxim Slipenko 2024-02-03 16:20:33 +03:00 committed by GitHub
parent 240a517dd6
commit 30447a801a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 26 additions and 2 deletions

View File

@ -19,8 +19,8 @@
# #
import numpy as np import numpy as np
from PySide2 import QtCore from PySide2 import QtCore
from PySide2.QtCore import Slot from PySide2.QtCore import Slot, Qt, QPoint
from PySide2.QtWidgets import QMainWindow, QMessageBox from PySide2.QtWidgets import QMainWindow, QMessageBox, QAction, QMenu
from statapp.calculations import generateXValues, generateYValues from statapp.calculations import generateXValues, generateYValues
from statapp.constants import NUMBERS_PRECISION from statapp.constants import NUMBERS_PRECISION
@ -79,6 +79,27 @@ class MainWindow(QMainWindow):
# x1 = generateXValues(20, 2, 0, y) # x1 = generateXValues(20, 2, 0, y)
# x2 = generateXValues(10, 1, 0, y) # x2 = generateXValues(10, 1, 0, y)
# self.model.updateAllData(np.concatenate([y, x1, x2], axis=1)) # 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): def updateActionsEnabled(self):

View File

@ -33,3 +33,6 @@ class InputValuesModel(EditableTableModel):
def getY(self): def getY(self):
return self._data[:, 0] return self._data[:, 0]
def removeCol(self, index: int):
self.updateAllData(np.delete(self._data, index, axis=1))