Skip to content

Commit

Permalink
Refactor RARC tab to use model/view architecture, add file filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
LagoLunatic committed Jun 22, 2024
1 parent 047302c commit c83fbe1
Show file tree
Hide file tree
Showing 5 changed files with 385 additions and 316 deletions.
33 changes: 33 additions & 0 deletions gcft_ui/custom_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,36 @@ def fixup(self, input):
def setRange(self, minimum, maximum):
self._minimum = minimum
self._maximum = maximum


class ComboBoxDelegate(QItemDelegate):
def __init__(self, parent=None):
super().__init__(parent)
self.items: list[str] = []

def set_items(self, items: list[str]):
self.items = items

def createEditor(self, parent, option, index):
combobox = QComboBox(parent)
combobox.setMaximumWidth(80)
for item in self.items:
combobox.addItem(item)
return combobox

def setEditorData(self, editor: QComboBox, index):
value = index.model().data(index, Qt.ItemDataRole.EditRole)
if value:
editor.setCurrentIndex(self.items.index(value))
else:
editor.setCurrentIndex(-1)

def setModelData(self, editor: QComboBox, model, index):
model.setData(index, editor.currentText(), Qt.ItemDataRole.EditRole)

class ReadOnlyDelegate(QItemDelegate):
def editorEvent(self, event, model, option, index):
return False

def createEditor(self, parent, option, index):
return None
Loading

0 comments on commit c83fbe1

Please sign in to comment.