Skip to content

Commit

Permalink
[processing] resurrects matrix parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
slarosa committed Jan 25, 2018
1 parent dc564fb commit f4f89bb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
8 changes: 4 additions & 4 deletions python/plugins/processing/gui/FixedTableDialog.py
Expand Up @@ -63,20 +63,20 @@ def __init__(self, param, table):
self.btnRemove.clicked.connect(lambda: self.removeRows())
self.btnRemoveAll.clicked.connect(lambda: self.removeRows(True))

if self.param.fixedNumOfRows:
if self.param.hasFixedNumberRows():
self.btnAdd.setEnabled(False)
self.btnRemove.setEnabled(False)
self.btnRemoveAll.setEnabled(False)

self.populateTable(table)

def populateTable(self, table):
cols = len(self.param.cols)
cols = len(self.param.headers())
rows = len(table)
model = QStandardItemModel(rows, cols)

# Set headers
model.setHorizontalHeaderLabels(self.param.cols)
model.setHorizontalHeaderLabels(self.param.headers())

# Populate table
for i in range(rows):
Expand All @@ -101,7 +101,7 @@ def reject(self):
def removeRows(self, removeAll=False):
if removeAll:
self.tblView.model().clear()
self.tblView.model().setHorizontalHeaderLabels(self.param.cols)
self.tblView.model().setHorizontalHeaderLabels(self.param.headers())
else:
indexes = sorted(self.tblView.selectionModel().selectedRows())
self.tblView.setUpdatesEnabled(False)
Expand Down
8 changes: 4 additions & 4 deletions python/plugins/processing/gui/FixedTablePanel.py
Expand Up @@ -46,13 +46,13 @@ def __init__(self, param, parent=None):

self.param = param
self.table = []
for i in range(param.numRows):
for i in range(param.numberRows()):
self.table.append(list())
for j in range(len(param.cols)):
for j in range(len(param.headers())):
self.table[i].append('0')

self.leText.setText(
self.tr('Fixed table {0}x{1}').format(param.numRows, len(param.cols)))
self.tr('Fixed table {0}x{1}').format(param.numberRows(), len(param.headers())))

self.btnSelect.clicked.connect(self.showFixedTableDialog)

Expand All @@ -63,4 +63,4 @@ def showFixedTableDialog(self):
self.table = dlg.rettable

self.leText.setText(self.tr('Fixed table {0}x{1}').format(
len(self.table), len(self.param.cols)))
len(self.table), len(self.param.headers())))
2 changes: 2 additions & 0 deletions python/plugins/processing/gui/wrappers.py
Expand Up @@ -1607,6 +1607,8 @@ def create_wrapper_from_class(param, dialog, row=0, col=0):
wrapper = MapLayerWidgetWrapper
elif param.type() == 'range':
wrapper = RangeWidgetWrapper
elif param.type() == 'matrix':
wrapper = FixedTableWidgetWrapper
else:
assert False, param.type()
return wrapper(param, dialog, row, col)

0 comments on commit f4f89bb

Please sign in to comment.