mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
Refactoring: Use ui file in Geometry profile edit window.
This commit is contained in:
1 parent
44ccf99d48
commit
11a7486a9c
8 files changed
+198
-419
No files matched your search
@@ -46,7 +46,7 @@ logger = logging.getLogger()
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
|
||||
class TableEditableModel(PamhyrTableModel):
|
||||
class GeometryReachTableModel(PamhyrTableModel):
|
||||
def data(self, index, role=Qt.DisplayRole):
|
||||
if not index.isValid():
|
||||
return QVariant()
|
||||
@@ -223,62 +223,3 @@ class TableEditableModel(PamhyrTableModel):
|
||||
|
||||
self.layoutAboutToBeChanged.emit()
|
||||
self.layoutChanged.emit()
|
||||
|
||||
# TODO: Delete useless delegate
|
||||
class Delegate(QStyledItemDelegate):
|
||||
def __init__(self, parent=None, setModelDataEvent=None):
|
||||
super(Delegate, self).__init__(parent)
|
||||
self.setModelDataEvent = setModelDataEvent
|
||||
|
||||
def createEditor(self, parent, option, index):
|
||||
index.model().data(index, Qt.DisplayRole)
|
||||
return QLineEdit(parent)
|
||||
|
||||
def setEditorData(self, editor, index):
|
||||
value = index.model().data(index, Qt.DisplayRole)
|
||||
editor.setText(str(value))
|
||||
|
||||
def setModelData(self, editor, model, index):
|
||||
model.setData(index, editor.text())
|
||||
|
||||
if not self.setModelDataEvent is None:
|
||||
self.setModelDataEvent()
|
||||
|
||||
def updateEditorGeometry(self, editor, option, index):
|
||||
editor.setGeometry(option.rect)
|
||||
|
||||
class Delegate1(QStyledItemDelegate):
|
||||
def __init__(self, owner, choices):
|
||||
super().__init__(owner)
|
||||
self.items = choices
|
||||
|
||||
def paint(self, painter, option, index):
|
||||
if isinstance(self.parent(), QAbstractItemView):
|
||||
self.parent().openPersistentEditor(index)
|
||||
super(Delegate1, self).paint(painter, option, index)
|
||||
|
||||
def createEditor(self, parent, option, index):
|
||||
editor = QComboBox(parent)
|
||||
# editor.currentIndexChanged.connect(self.commit_editor)
|
||||
editor.addItems(self.items)
|
||||
return editor
|
||||
|
||||
def setEditorData(self, editor, index):
|
||||
editor.blockSignals(True)
|
||||
text = index.model().data(index, Qt.DisplayRole)
|
||||
try:
|
||||
i = self.items.index(text)
|
||||
except ValueError:
|
||||
i = 0
|
||||
editor.setCurrentIndex(i)
|
||||
editor.blockSignals(False)
|
||||
|
||||
def setModelData(self, editor, model, index):
|
||||
model.setData(index, editor.currentText(), Qt.DisplayRole)
|
||||
|
||||
def updateEditorGeometry(self, editor, option, index):
|
||||
editor.setGeometry(option.rect)
|
||||
|
||||
@pyqtSlot()
|
||||
def currentIndexChanged(self):
|
||||
self.commitData.emit(self.sender())
|
||||
Reference in new issue
Block a user