mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
BC: Fix combobox delegate.
This commit is contained in:
1 parent
6b1a77b235
commit
dbcf0d6392
4 files changed
+19
-13
No files matched your search
@@ -31,7 +31,7 @@ class SetNodeCommand(QUndoCommand):
|
||||
|
||||
self._lst = lst
|
||||
self._index = index
|
||||
self._old = self.lst[index].node
|
||||
self._old = self._lst[index].node
|
||||
self._new = node
|
||||
|
||||
def undo(self):
|
||||
@@ -47,8 +47,8 @@ class SetTypeCommand(QUndoCommand):
|
||||
self._lst = lst
|
||||
self._index = index
|
||||
self._type = _type
|
||||
self._old = self.lst[index]
|
||||
self._new = self.lst[index].convert(self._type)
|
||||
self._old = self._lst[index]
|
||||
self._new = self._lst[index].convert(self._type)
|
||||
|
||||
def undo(self):
|
||||
self._lst[self._index] = self._old
|
||||
|
||||
@@ -12,6 +12,7 @@ from PyQt5.QtGui import (
|
||||
from PyQt5.QtCore import (
|
||||
Qt, QVariant, QAbstractTableModel,
|
||||
QCoreApplication, QModelIndex, pyqtSlot,
|
||||
QRect,
|
||||
)
|
||||
|
||||
from PyQt5.QtWidgets import (
|
||||
@@ -68,10 +69,10 @@ class ComboBoxDelegate(QItemDelegate):
|
||||
self.editor = QComboBox(parent)
|
||||
|
||||
if self._mode == "type":
|
||||
self.editor.addItems(BC_types.keys())
|
||||
self.editor.addItems([long_types[k] for k in BC_types.keys()])
|
||||
else:
|
||||
self.editor.addItems(
|
||||
["Not associate"] +
|
||||
[_translate("BoundaryCondition", "Not associate")] +
|
||||
self._data.nodes_names()
|
||||
)
|
||||
|
||||
@@ -134,7 +135,7 @@ class TableModel(QAbstractTableModel):
|
||||
elif self._headers[column] == "node":
|
||||
n = self._lst[row].node
|
||||
if n is None:
|
||||
return "-"
|
||||
return _translate("BoundaryCondition", "Not associate")
|
||||
return n.name
|
||||
|
||||
return QVariant()
|
||||
@@ -159,9 +160,10 @@ class TableModel(QAbstractTableModel):
|
||||
)
|
||||
)
|
||||
elif self._headers[column] == "type":
|
||||
key = next(k for k, v in long_types.items() if v == value)
|
||||
self._undo.push(
|
||||
SetTypeCommand(
|
||||
self._lst, row, BC_types[value]
|
||||
self._lst, row, BC_types[key]
|
||||
)
|
||||
)
|
||||
elif self._headers[column] == "node":
|
||||
|
||||
Reference in new issue
Block a user