diff options
author | Blaine | 2020-06-15 19:52:16 +0530 |
---|---|---|
committer | Blaine | 2020-06-15 19:52:16 +0530 |
commit | 6bb2fe8e1313b5f2fcd8e706f16d89546f51ba23 (patch) | |
tree | 43eccb67d64be5f62db326349b93f4662a6fbce9 /src/main/python | |
parent | f31b832f7807f1568e128d826ea45712714d125a (diff) | |
download | Chemical-PFD-6bb2fe8e1313b5f2fcd8e706f16d89546f51ba23.tar.gz Chemical-PFD-6bb2fe8e1313b5f2fcd8e706f16d89546f51ba23.tar.bz2 Chemical-PFD-6bb2fe8e1313b5f2fcd8e706f16d89546f51ba23.zip |
procedural table
Diffstat (limited to 'src/main/python')
-rw-r--r-- | src/main/python/utils/canvas.py | 2 | ||||
-rw-r--r-- | src/main/python/utils/streamTable.py | 19 |
2 files changed, 13 insertions, 8 deletions
diff --git a/src/main/python/utils/canvas.py b/src/main/python/utils/canvas.py index f8d71d6..285dd87 100644 --- a/src/main/python/utils/canvas.py +++ b/src/main/python/utils/canvas.py @@ -54,7 +54,7 @@ class canvas(customView): def updateStreamTable(self, item): if self.streamTable: - self.streamTable.model.insertRow(name=item.toPlainText()) + self.streamTable.model.insertRow(item = item) def sideViewContextMenu(self, pos): self.parentFileWindow.sideViewContextMenu(self.mapTo(self.parentFileWindow, pos)) diff --git a/src/main/python/utils/streamTable.py b/src/main/python/utils/streamTable.py index b7dffa9..a9fc5d8 100644 --- a/src/main/python/utils/streamTable.py +++ b/src/main/python/utils/streamTable.py @@ -16,21 +16,27 @@ class streamTableModel(QAbstractTableModel): return len(self.list) def columnCount(self, parent=None): - return len(self.list[0]) + return len(self.header) def data(self, index, role): if not index.isValid(): return None elif role != Qt.DisplayRole: return None - return self.list[index.row()][index.column()] + if index.column() == 0: + return self.list[index.row()][index.column()].toPlainText() + else: + return self.list[index.row()][index.column()] def setData(self, index, value, role): if not index.isValid(): return False elif role != Qt.EditRole: return False - self.list[index.row()][index.column()] = value + if index.column() == 0: + self.list[index.row()][index.column()].setPlainText(value) + else: + self.list[index.row()][index.column()] = value return True def insertColumn(self, int): @@ -41,10 +47,10 @@ class streamTableModel(QAbstractTableModel): self.endInsertColumns() self.updateEvent.emit() - def insertRow(self, int=None, name="Name"): + def insertRow(self, int=None, item=None): int = int if int else self.rowCount()+1 self.beginInsertRows(QModelIndex(), int, int) - self.list.insert(int, [name] + [0 for _ in range(self.columnCount()-1)]) + self.list.insert(int, [item] + [0 for _ in range(self.columnCount()-1)]) self.endInsertRows() self.updateEvent.emit() @@ -61,10 +67,9 @@ class streamTable(QTableView): def __init__(self, itemLabels=[], canvas=None, parent=None): super(streamTable, self).__init__(parent=parent) self.canvas = canvas - self.items = itemLabels list = [] for i, item in enumerate(itemLabels): - list.append([item.toPlainText()]+[0 for _ in range(5)]) + list.append([item] + [0 for _ in range(5)]) header = ["name", "val1", "val2", "val3", "val4", "val5"] self.model = streamTableModel(self, list, header) self.setShowGrid(False) |