Skip to content
Permalink
Browse files

also use 1-dimensional table in modeler dialog (follow up 4b35498)

  • Loading branch information
alexbruy authored and nyalldawson committed Jun 13, 2018
1 parent 262cee6 commit dcff720bb0810ec52db1d223c7a56d01444f3496
@@ -103,26 +103,28 @@ def changeHeader(self, index):
self.tblView.model().setHeaderData(index, Qt.Horizontal, txt)

def value(self):
cols = self.tblView.model().columnCount()
rows = self.tblView.model().rowCount()

items = []
model = self.tblView.model()
for i in range(model.rowCount()):
row = []
for j in range(model.columnCount()):
item = model.item(i, j)
row.append(item.text())
items.append(row)
for row in range(rows):
for col in range(cols):
items.append(str(self.tblView.model().item(row, col).text()))

return items

def setValue(self, table):
cols = len(table[0])
rows = len(table)
def setValue(self, headers, table):
model = self.tblView.model()
model.setHorizontalHeaderLabels(headers)

cols = len(headers)
rows = len(table) // cols
model = QStandardItemModel(rows, cols)

for i in range(rows):
for j in range(cols):
item = QStandardItem(str(table[i][j]))
model.setItem(i, j, item)
for row in range(rows):
for col in range(cols):
item = QStandardItem(str(table[row * cols + col]))
model.setItem(row, col, item)
self.tblView.setModel(model)

def headers(self):
@@ -133,10 +135,6 @@ def headers(self):

return headers

def setHeaders(self, headers):
model = self.tblView.model()
model.setHorizontalHeaderLabels(headers)

def fixedRows(self):
return self.chkFixedRows.isChecked()

@@ -294,8 +294,7 @@ def setupUi(self):
isinstance(self.param, QgsProcessingParameterMatrix):
self.widget = MatrixModelerWidget(self)
if self.param is not None:
self.widget.setValue(self.param.defaultValue())
self.widget.setHeaders(self.param.headers())
self.widget.setValue(self.param.headers(), self.param.defaultValue())
self.widget.setFixedRows(self.param.hasFixedNumberRows())
self.verticalLayout.addWidget(self.widget)

0 comments on commit dcff720

Please sign in to comment.
You can’t perform that action at this time.