Skip to content
Permalink
Browse files

[processing] resurrects matrix parameter

  • Loading branch information
slarosa committed Jan 25, 2018
1 parent dc564fb commit f4f89bbcbe456f87ce51ab0ab72c6f32df6943d3
@@ -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):
@@ -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)
@@ -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)

@@ -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())))
@@ -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.
You can’t perform that action at this time.