Skip to content

Commit

Permalink
Fix for dynamic library filtering and editing
Browse files Browse the repository at this point in the history
  • Loading branch information
MaurizioB committed Mar 23, 2017
1 parent 7568e50 commit 25c43f5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
16 changes: 8 additions & 8 deletions bigglesworth/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,28 +195,28 @@ def _addSound(self, sound):
index_item.setData(bank*128+prog, IndexRole)
index_item.setEditable(False)
bank_item = QtGui.QStandardItem(uppercase[bank])
bank_item.setData(bank, UserRole)
# bank_item.setData(bank, UserRole)
bank_item.setData(bank, BankRole)
bank_item.setTextAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignCenter)
bank_item.setEditable(False)
prog_item = QtGui.QStandardItem('{:03}'.format(prog+1))
prog_item.setData(prog, UserRole)
# prog_item.setData(prog, UserRole)
prog_item.setData(prog, ProgRole)
prog_item.setEditable(False)
name_item = QtGui.QStandardItem(sound.name)
# name_item.setData(sound.Osc_1_Shape, QtCore.Qt.ToolTipRole)
# name_item.setData(sound.name, QtCore.Qt.ToolTipRole)
cat_item = QtGui.QStandardItem(categories[sound.cat])
cat_item.setData(sound.cat, UserRole)
# cat_item.setData(sound.cat, UserRole)
cat_item.setData(sound.cat, CatRole)
# status_item = QtGui.QStandardItem('Dumped' if sound.state == DUMPED else 'Stored')
status_item = QtGui.QStandardItem(status_dict[sound.state])
status_item.setData(sound.state, EditedRole)
status_item.setEditable(False)
sound_item = QtGui.QStandardItem()
sound_item.setData(sound, SoundRole)
# sound.bankChanged.connect(lambda bank, item=bank_item: item.setData(bank, BankRole))
# sound.progChanged.connect(lambda prog, item=prog_item: item.setData(prog, ProgRole))
sound.bankChanged.connect(lambda bank, item=bank_item: item.setData(bank, BankRole))
sound.progChanged.connect(lambda prog, item=prog_item: item.setData(prog, ProgRole))
sound.indexChanged.connect(lambda index, item=index_item: item.setData(index, IndexRole))
sound.nameChanged.connect(lambda name, item=name_item: item.setText(name))
sound.catChanged.connect(lambda cat, bank=bank, item=cat_item: self.soundSetCategory(item, bank, cat))
Expand Down Expand Up @@ -343,13 +343,13 @@ def clear(self):
self.cleared.emit()

def sound(self, index):
return self.item(index.row(), 6).data(SoundRole).toPyObject()
return self.item(index.row(), SOUND).data(SoundRole).toPyObject()


class LibraryProxy(QtGui.QSortFilterProxyModel):
def __init__(self, parent=None):
QtGui.QSortFilterProxyModel.__init__(self, parent)
# self.setDynamicSortFilter(True)
self.setDynamicSortFilter(True)
self.filter_columns = {}
self.text_filter = None

Expand All @@ -374,7 +374,7 @@ def filterAcceptsRow(self, row, parent):
if not len(self.filter_columns) and not self.text_filter:
return True
model = self.sourceModel()
if len(self.filter_columns) and any([True for column, index in self.filter_columns.items() if model.item(row, column).data(UserRole) != index]):
if len(self.filter_columns) and any([True for column, index in self.filter_columns.items() if model.item(row, column).data(roles_dict[column]) != index]):
return False
if not self.text_filter:
return True
Expand Down
7 changes: 7 additions & 0 deletions bigglesworth/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,13 @@ def __getitem__(self, index):
PortRole = EditedRole + 1
ClientRole = PortRole + 1

roles_dict = {
INDEX: IndexRole,
BANK: BankRole,
PROG: ProgRole,
CATEGORY: CatRole,
}

note_scancodes = [
52, 39, 53, 40, 54, 55, 42, 56, 43, 57, 44, 58,
59, 46, 60, 47, 61, 24, 11, 25, 12, 26, 13, 27,
Expand Down

0 comments on commit 25c43f5

Please sign in to comment.