개정판 3d7ee12a
issue #563: line type update improve
Change-Id: Ibd6b5525fe822c36b745e329945d0e5e97993f69
DTI_PID/DTI_PID/LineTypeConditions.py | ||
---|---|---|
38 | 38 |
|
39 | 39 |
def eval(self, items): |
40 | 40 |
""" return the result of evaluate """ |
41 |
from EngineeringInstrumentItem import QEngineeringInstrumentItem
|
|
41 |
from SymbolSvgItem import SymbolSvgItem
|
|
42 | 42 |
from EngineeringLineItem import QEngineeringLineItem |
43 | 43 |
|
44 | 44 |
try: |
... | ... | |
48 | 48 |
for condition in self.conditions: |
49 | 49 |
if not condition[0]: continue |
50 | 50 |
matches = [] |
51 |
if condition[0] == 'Instrument':
|
|
51 |
if condition[0] == 'Symbol':
|
|
52 | 52 |
for index in range(len(items)): |
53 |
if type(items[index]) is QEngineeringInstrumentItem:
|
|
53 |
if issubclass(type(items[index]), SymbolSvgItem):
|
|
54 | 54 |
matches.append([items[index], index]) |
55 | 55 |
if not matches: return False |
56 | 56 |
elif condition[0] == 'Line': |
... | ... | |
60 | 60 |
if not matches: return False |
61 | 61 |
|
62 | 62 |
if condition[1]: |
63 |
res = False
|
|
63 |
ret = False
|
|
64 | 64 |
for item, index in matches: |
65 |
ret = eval(condition[1]) |
|
65 |
if issubclass(type(item), SymbolSvgItem): |
|
66 |
if item.type.upper() in condition[1].upper(): |
|
67 |
ret = True |
|
68 |
elif type(item) is QEngineeringLineItem: |
|
69 |
if item.lineType.upper() in condition[1].upper(): |
|
70 |
ret = True |
|
71 |
|
|
66 | 72 |
if ret == True: |
67 |
res = True |
|
68 | 73 |
break |
69 | 74 |
|
70 |
if res == False:
|
|
75 |
if ret == False:
|
|
71 | 76 |
return False |
72 | 77 |
else: |
73 | 78 |
items.pop(index) |
DTI_PID/DTI_PID/LineTypeConditionsDialog.py | ||
---|---|---|
19 | 19 |
self.ui = Ui_LineTypeConditions() |
20 | 20 |
self.ui.setupUi(self) |
21 | 21 |
|
22 |
self.ui.tableWidgetLineTypeConditions.setHorizontalHeaderLabels([self.tr('Type'), self.tr('Conditions')])
|
|
22 |
self.ui.tableWidgetLineTypeConditions.setHorizontalHeaderLabels([self.tr('Type'), self.tr('Item Type Names')])
|
|
23 | 23 |
self.ui.tableWidgetLineTypeConditions.horizontalHeader().setStretchLastSection(True) |
24 | 24 |
for row in range(self.ui.tableWidgetLineTypeConditions.rowCount()): |
25 | 25 |
""" Type """ |
26 | 26 |
combobox = QComboBox() |
27 |
combobox.addItems(['', 'Instrument', 'Line'])
|
|
27 |
combobox.addItems(['', 'Symbol', 'Line'])
|
|
28 | 28 |
combobox.setCurrentText(line_type_conditions._conditions[row][0] if line_type_conditions._conditions[row][0] else '') |
29 | 29 |
self.ui.tableWidgetLineTypeConditions.setCellWidget(row, 0, combobox) |
30 | 30 |
|
내보내기 Unified diff