|
43 | 43 | class FixedTableDialog(BASE, WIDGET):
|
44 | 44 |
|
45 | 45 | def __init__(self, param, table):
|
46 |
| - super(FixedTableDialog, self).__init__(None) |
| 46 | + """ |
| 47 | + Constructor for FixedTableDialog |
| 48 | + :param param: linked processing parameter |
| 49 | + :param table: initial table contents - squashed to 1-dimensional! |
| 50 | + """ |
| 51 | + super().__init__(None) |
| 52 | + |
47 | 53 | self.setupUi(self)
|
48 | 54 |
|
49 | 55 | self.tblView.setSelectionBehavior(QAbstractItemView.SelectRows)
|
@@ -76,27 +82,27 @@ def __init__(self, param, table):
|
76 | 82 |
|
77 | 83 | def populateTable(self, table):
|
78 | 84 | cols = len(self.param.headers())
|
79 |
| - rows = len(table) |
| 85 | + rows = len(table) // cols |
80 | 86 | model = QStandardItemModel(rows, cols)
|
81 | 87 |
|
82 | 88 | # Set headers
|
83 | 89 | model.setHorizontalHeaderLabels(self.param.headers())
|
84 | 90 |
|
85 | 91 | # Populate table
|
86 |
| - for i in range(rows): |
87 |
| - for j in range(cols): |
88 |
| - item = QStandardItem(str(table[i][j])) |
89 |
| - model.setItem(i, j, item) |
| 92 | + for row in range(rows): |
| 93 | + for col in range(cols): |
| 94 | + item = QStandardItem(str(table[row * cols + col])) |
| 95 | + model.setItem(row, col, item) |
90 | 96 | self.tblView.setModel(model)
|
91 | 97 |
|
92 | 98 | def accept(self):
|
93 | 99 | cols = self.tblView.model().columnCount()
|
94 | 100 | rows = self.tblView.model().rowCount()
|
| 101 | + # Table MUST BE 1-dimensional to match core QgsProcessingParameterMatrix expectations |
95 | 102 | self.rettable = []
|
96 |
| - for i in range(rows): |
97 |
| - self.rettable.append(list()) |
98 |
| - for j in range(cols): |
99 |
| - self.rettable[i].append(str(self.tblView.model().item(i, j).text())) |
| 103 | + for row in range(rows): |
| 104 | + for col in range(cols): |
| 105 | + self.rettable.append(str(self.tblView.model().item(row, col).text())) |
100 | 106 | QDialog.accept(self)
|
101 | 107 |
|
102 | 108 | def reject(self):
|
|
0 commit comments