개정판 46d5088b
issue #000: hmb value editing test
Change-Id: Icf55d2912a87f88b9ea031a938e6e23600ddadd2
DTI_PID/DTI_PID/HMBDialog.py | ||
---|---|---|
20 | 20 |
class HMBDelegate(QStyledItemDelegate): |
21 | 21 |
def createEditor(self, parent, option, index): |
22 | 22 |
editor = super(HMBDelegate, self).createEditor(parent, option, index) |
23 |
if index.column() != 0: |
|
23 |
if index.column() != 0 and index.column() != 1:
|
|
24 | 24 |
return editor |
25 | 25 |
|
26 | 26 |
|
... | ... | |
28 | 28 |
def __init__(self, parent=None, *args): |
29 | 29 |
QStandardItemModel.__init__(self, parent, *args) |
30 | 30 |
|
31 |
''' |
|
31 | 32 |
def data(self, index, role): |
32 | 33 |
if not index.isValid(): |
33 | 34 |
return None |
... | ... | |
35 | 36 |
print('a') |
36 | 37 |
|
37 | 38 |
return super(HmbModel, self).data(index, role) |
39 |
''' |
|
38 | 40 |
|
39 | 41 |
class QHMBDialog(QDialog): |
40 | 42 |
def __init__(self, parent): |
... | ... | |
52 | 54 |
self.ui.buttonBox.button(QDialogButtonBox.Ok).setText(self.tr('Import')) |
53 | 55 |
self.ui.buttonBox.button(QDialogButtonBox.Close).setIcon(QIcon(':/newPrefix/Remove.svg')) |
54 | 56 |
|
55 |
self.tabs = [self.ui.tab] |
|
56 |
self.layouts = [self.ui.gridLayout_3] |
|
57 |
self.views = [self.ui.tableViewHMB] |
|
57 |
self.hmbs = None |
|
58 |
|
|
59 |
self.tabs = [] |
|
60 |
self.layouts = [] |
|
61 |
self.views = [] |
|
58 | 62 |
|
59 | 63 |
self.dataChanged_original = None |
60 | 64 |
|
... | ... | |
71 | 75 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
72 | 76 |
|
73 | 77 |
def dataChanged(self, *args): |
74 |
tab = self.ui.tabWidget.currentWidget() |
|
75 |
index = self.tabs.index(tab) |
|
76 |
view = self.views[index] |
|
78 |
""" when cell data change update hmb data""" |
|
79 |
try: |
|
80 |
if self.hmbs: |
|
81 |
#currentTabIndex = self.ui.tabWidget.currentIndex() |
|
82 |
#tabText = self.ui.tabWidget.tabText(currentTabIndex) |
|
83 |
tab = self.ui.tabWidget.currentWidget() |
|
84 |
tab_index = self.tabs.index(tab) |
|
85 |
|
|
86 |
view = self.views[tab_index] |
|
87 |
cell_index = args[0] |
|
88 |
row = cell_index.row() |
|
89 |
col = cell_index.column() |
|
90 |
|
|
91 |
value = view.model().itemFromIndex(cell_index).text() |
|
92 |
|
|
93 |
# change stream no |
|
94 |
if col == 1: |
|
95 |
pass |
|
96 |
# change list value |
|
97 |
else: |
|
98 |
stream_no = view.model().item(row, 1).text() |
|
99 |
for hmb in self.hmbs: |
|
100 |
if hmb.stream_no == stream_no: |
|
101 |
hmb.datas[tab_index][col - 2].value = value |
|
102 |
break |
|
103 |
|
|
104 |
except Exception as ex: |
|
105 |
from App import App |
|
106 |
from AppDocData import MessageType |
|
107 |
|
|
108 |
message = f"error occurred({repr(ex)}) in {sys.exc_info()[-1].tb_frame.f_code.co_filename}:" \ |
|
109 |
f"{sys.exc_info()[-1].tb_lineno}" |
|
110 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
77 | 111 |
|
78 | 112 |
self.dataChanged_original(args[0], args[1], args[2]) |
79 | 113 |
|
... | ... | |
83 | 117 |
|
84 | 118 |
try: |
85 | 119 |
hmbs = AppDocData.instance().get_hmb_data(None) |
120 |
|
|
121 |
count = self.ui.tabWidget.count() |
|
122 |
for i in range(count): |
|
123 |
self.ui.tabWidget.removeTab(0) |
|
124 |
self.tabs = [] |
|
125 |
self.layouts = [] |
|
126 |
self.views = [] |
|
127 |
|
|
86 | 128 |
if not hmbs: |
129 |
self.hmbs = None |
|
87 | 130 |
return False |
88 | 131 |
|
89 | 132 |
for index in range(len(hmbs[0].datas)): |
90 |
if index != 0: |
|
91 |
tab = QWidget() |
|
92 |
tab.setObjectName(self.tabs[0].objectName() + '_d' + str(index)) |
|
93 |
gridLayout = QGridLayout(tab) |
|
94 |
gridLayout.setObjectName(self.layouts[0].objectName() + '_d' + str(index)) |
|
95 |
tableViewHMB = QTableView(tab) |
|
96 |
tableViewHMB.setObjectName(self.views[0].objectName() + '_d' + str(index)) |
|
97 |
gridLayout.addWidget(tableViewHMB, 0, 0, 1, 1) |
|
98 |
self.ui.tabWidget.addTab(tab, "") |
|
99 |
|
|
100 |
self.tabs.append(tab) |
|
101 |
self.layouts.append(gridLayout) |
|
102 |
self.views.append(tableViewHMB) |
|
133 |
tab = QWidget() |
|
134 |
tab.setObjectName('tab' + '_d' + str(index)) |
|
135 |
gridLayout = QGridLayout(tab) |
|
136 |
gridLayout.setObjectName('gridLayout_3' + '_d' + str(index)) |
|
137 |
tableViewHMB = QTableView(tab) |
|
138 |
tableViewHMB.setObjectName('tableViewHMB' + '_d' + str(index)) |
|
139 |
gridLayout.addWidget(tableViewHMB, 0, 0, 1, 1) |
|
140 |
self.ui.tabWidget.addTab(tab, "") |
|
141 |
|
|
142 |
self.tabs.append(tab) |
|
143 |
self.layouts.append(gridLayout) |
|
144 |
self.views.append(tableViewHMB) |
|
103 | 145 |
|
104 | 146 |
model = HmbModel() |
105 | 147 |
header = ['UID', 'StreamNumber'] |
... | ... | |
132 | 174 |
self.views[index].setAlternatingRowColors(True) |
133 | 175 |
self.ui.tabWidget.setTabText(self.ui.tabWidget.indexOf(self.tabs[index]), hmbs[0].datas[index][0].case) |
134 | 176 |
|
177 |
self.hmbs = hmbs |
|
135 | 178 |
return True |
136 | 179 |
except Exception as ex: |
137 | 180 |
from App import App |
... | ... | |
232 | 275 |
|
233 | 276 |
def save_hmb(self): |
234 | 277 |
""" save hmb data """ |
235 |
pass |
|
278 |
if self.hmbs: |
|
279 |
app_doc_data = AppDocData.instance() |
|
280 |
app_doc_data.save_hmb_data(self.hmbs) |
|
236 | 281 |
|
237 | 282 |
def import_hmb(self): |
238 | 283 |
""" import hmb excel """ |
내보내기 Unified diff