개정판 d938b798
bm on going
Change-Id: I9432e1b5b81d1dd81135eb629dfce77601cc7644
DTI_PID/DTI_PID/BMSettingDialog.py | ||
---|---|---|
12 | 12 |
|
13 | 13 |
import BMSetting_UI |
14 | 14 |
|
15 |
class AttributeListModel(QStandardItemModel): |
|
16 |
def __init__(self, columListAll, parent=None, *args): |
|
17 |
QStandardItemModel.__init__(self, parent, *args) |
|
18 |
|
|
19 |
self.columListAll = columListAll |
|
20 |
|
|
21 |
for symbol in self.columListAll: |
|
22 |
items = [QStandardItem(symbol)] |
|
23 |
items[0].setEditable(False) |
|
24 |
self.appendRow(items) |
|
25 |
|
|
26 |
headers = [QStandardItem("Name"), QStandardItem("State")] |
|
27 |
for idx, header in enumerate(headers): |
|
28 |
header.setTextAlignment(Qt.AlignCenter) |
|
29 |
self.setHorizontalHeaderItem(idx, header) |
|
30 |
|
|
15 | 31 |
class SymbolListModel(QStandardItemModel): |
16 | 32 |
def __init__(self, parent=None, *args): |
17 | 33 |
QStandardItemModel.__init__(self, parent, *args) |
18 | 34 |
|
19 | 35 |
self.SymbolList = [ "DRAIN CUP", "EOL", "FLANGE", "FLANGE BLIND", "ORIFICE", "SCREW CAP", \ |
20 |
"3WAY", "4WAY", "BALL", "BUTTERFLY", "CHECK", "GATE", "GLOBE", \ |
|
36 |
"3WAY", "4WAY", "BALL", "BUTTERFLY", "CHECK", "GATE", "GLOBE", "NEEDLE", \
|
|
21 | 37 |
"CONTROL(BALL)", "CONTROL(BUTTERFLY)", "CONTROL(CHECK)", "CONTROL(GATE)", "CONTROL(GLOBE)", \ |
22 | 38 |
"MOV(BALL)", "MOV(BUTTERFLY)", "MOV(CHECK)", "MOV(GATE)", "MOV(GLOBE)", "MAGNETIC FLOW METER", "MASS FLOW METER", "ULTRASONIC FLOW METER", "VORTEX FLOW METER", "OPC", \ |
23 | 39 |
"GOOSE NECK VENT", "IP", "PG", "PP", "PSV", "RE", "SAMPLE CONNECTION", "SB", "SPACER", "STRAINER", "TG", "HOSE CONNECTION", "OD" ] |
... | ... | |
100 | 116 |
|
101 | 117 |
|
102 | 118 |
class BMSettingDialog(QDialog): |
103 |
def __init__(self, parent): |
|
119 |
def __init__(self, parent, columListAll, columnOrder):
|
|
104 | 120 |
QDialog.__init__(self, parent) |
105 | 121 |
|
106 | 122 |
self.ui = BMSetting_UI.Ui_BMSettingDialog() |
... | ... | |
108 | 124 |
|
109 | 125 |
self.isAccepted = False |
110 | 126 |
self.symbol_mapping = {} |
127 |
self.columListAll = columListAll |
|
128 |
self.columnOrder = columnOrder |
|
111 | 129 |
|
112 | 130 |
self.symbolListModel = SymbolListModel() |
113 | 131 |
self.ui.tableViewSymbolList.setModel(self.symbolListModel) |
... | ... | |
115 | 133 |
self.symbolMappingModel = SymbolMappingModel() |
116 | 134 |
self.symbolMappingModel.invisibleRootItem() |
117 | 135 |
self.ui.treeViewSymbolMapping.setModel(self.symbolMappingModel) |
136 |
self.ui.treeViewSymbolMapping.expandAll() |
|
118 | 137 |
self.add_check_box() |
119 | 138 |
self.load_symbol_mapping() |
120 |
self.ui.tableViewSymbolList.setCurrentIndex(self.symbolListModel.index(0, 0)) |
|
139 |
|
|
140 |
self.attributeListModel = AttributeListModel(self.columListAll) |
|
141 |
self.ui.tableViewAttributeList.setModel(self.attributeListModel) |
|
121 | 142 |
|
122 | 143 |
self.ui.tableViewSymbolList.horizontalHeader().setStretchLastSection(True) |
123 | 144 |
self.ui.treeViewSymbolMapping.header().setStretchLastSection(True) |
... | ... | |
128 | 149 |
self.ui.treeViewSymbolMapping.resizeColumnToContents(0) |
129 | 150 |
self.ui.treeViewSymbolMapping.setColumnWidth(1, 50) |
130 | 151 |
self.ui.tableViewSymbolList.resizeColumnsToContents() |
131 |
#self.ui.tableViewAttributeList.resizeColumnsToContents() |
|
152 |
self.ui.tableViewAttributeList.resizeColumnsToContents() |
|
153 |
self.ui.tableViewAttributeList.setColumnWidth(1, 50) |
|
132 | 154 |
|
133 | 155 |
self.ui.tableViewSymbolList.clicked.connect(self.on_symbol_changed) |
134 | 156 |
self.ui.buttonBox.accepted.connect(self.accept) |
135 | 157 |
self.ui.buttonBox.rejected.connect(self.reject) |
136 | 158 |
|
159 |
self.on_symbol_changed(self.symbolListModel.index(0, 0)) |
|
160 |
|
|
137 | 161 |
def load_symbol_mapping(self): |
138 | 162 |
app_doc_data = AppDocData.instance() |
139 | 163 |
|
... | ... | |
175 | 199 |
for child_row in range(child_count): |
176 | 200 |
child_index = self.symbolMappingModel.index(child_row, 0, category_index) |
177 | 201 |
id2_symbol_item = self.symbolMappingModel.itemFromIndex(child_index) |
178 |
id2_symbol_uid = id2_symbol_item.data(Qt.UserRole)
|
|
202 |
id2_symbol_uid = str(id2_symbol_item.data(Qt.UserRole))
|
|
179 | 203 |
checkBox_index = self.symbolMappingModel.index(child_row, 1, category_index) |
180 | 204 |
checkBox = self.ui.treeViewSymbolMapping.indexWidget(checkBox_index) |
181 |
if str(id2_symbol_uid) in self.symbol_mapping[selected_symbol.text()]: |
|
205 |
checkBox.setEnabled(True) |
|
206 |
if id2_symbol_uid in self.symbol_mapping[selected_symbol.text()]: |
|
182 | 207 |
checkBox.setCheckState(Qt.Checked) |
183 | 208 |
else: |
184 | 209 |
checkBox.setCheckState(Qt.Unchecked) |
185 |
|
|
210 |
|
|
211 |
matches = [key for key, value in self.symbol_mapping.items() if key != id2_symbol_item.text() and id2_symbol_uid in value] |
|
212 |
if matches: |
|
213 |
checkBox.setEnabled(False) |
|
186 | 214 |
|
187 | 215 |
def reject(self): |
188 | 216 |
QDialog.reject(self) |
내보내기 Unified diff