프로젝트

일반

사용자정보

개정판 73698ad3

ID73698ad3377efc8c05ee1f29d841f24e6a538830
상위 edde144e
하위 0d987bb7

함의성이(가) 4년 이상 전에 추가함

issue #563: add tag no attribute on table, save remain or not necessary, fix csv

Change-Id: I1909ed60811c27930e95683fa8cc0eb58688d365

차이점 보기:

DTI_PID/DTI_PID/ItemPropertyTableWidget.py
23 23
from SymbolSvgItem import SymbolSvgItem
24 24
from EngineeringLineNoTextItem import QEngineeringLineNoTextItem
25 25
from QEngineeringTrimLineNoTextItem import QEngineeringTrimLineNoTextItem
26
from QEngineeringTagNoTextItem import QEngineeringTagNoTextItem
26 27
from EngineeringLineItem import QEngineeringLineItem
27 28
from EngineeringNoteItem import QEngineeringNoteItem
28 29
from EngineeringTextItem import QEngineeringTextItem
......
128 129
                self.onSymbolClicked(item)
129 130
            elif type(item) is QEngineeringLineNoTextItem or type(item) is QEngineeringRunItem:
130 131
                self.onLineNoClicked(item)
132
            elif type(item) is QEngineeringTagNoTextItem:
133
                self.onTagNoClicked(item)
131 134
            elif type(item) is QEngineeringNoteItem:
132 135
                noteContentsList = item.findNoteContents(item.text())
133 136
                self.onNoteClicked(item.text(), noteContentsList)
......
230 233

  
231 234
        try:
232 235
            self.blockSignals(True)
233
            self.initTitleCell(item)
236
            self.textChanged(item)
237
        finally:
238
            self.blockSignals(False)
234 239

  
235
            self.setItem(0, 3, QTableWidgetItem(str(self._item.uid)))
240
    def textChanged(self, item):
241
        self.initTitleCell(item)
236 242

  
237
            owner_item = QTableWidgetItem('{}'.format('None' if self._item.owner is None else str(self._item.owner)))
238
            owner_item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)
239
            self.setItem(1, 3, owner_item)
243
        self.setItem(0, 3, QTableWidgetItem(str(self._item.uid)))
240 244

  
241
            """ show icon item """
242
            attr = SymbolAttr()
243
            attr.AttributeType = "OWNER"
244
            self.show_icon_item(1, 2, attr)
245
            self.item(1, 1).setData(Qt.UserRole, attr)
245
        owner_item = QTableWidgetItem('{}'.format('None' if self._item.owner is None else str(self._item.owner)))
246
        owner_item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)
247
        self.setItem(1, 3, owner_item)
246 248

  
247
            self.setItem(2, 3, QTableWidgetItem(self._item.type))
248
            self.setItem(3, 3, QTableWidgetItem(self._item.text()))
249
            self.setItem(4, 3, QTableWidgetItem(self._item.area))
250
        finally:
251
            self.blockSignals(False)
249
        """ show icon item """
250
        attr = SymbolAttr()
251
        attr.AttributeType = "OWNER"
252
        self.show_icon_item(1, 2, attr)
253
        self.item(1, 1).setData(Qt.UserRole, attr)
254

  
255
        self.setItem(2, 3, QTableWidgetItem(self._item.type))
256
        self.setItem(3, 3, QTableWidgetItem(self._item.text()))
257
        self.setItem(4, 3, QTableWidgetItem(self._item.area))
252 258

  
253 259
    '''
254 260
        @brief      Slot to accept Note item click event
......
271 277
        @date       18.05.10
272 278
        @hisotry    humkyung 2018.07.08 change method name to onLineNoClicked
273 279
    '''
274

  
275 280
    @pyqtSlot(QEngineeringAbstractItem)
276 281
    def onLineNoClicked(self, item):
277 282
        try:
......
280 285
        finally:
281 286
            self.blockSignals(False)
282 287

  
288
    @pyqtSlot(QEngineeringAbstractItem)
289
    def onTagNoClicked(self, item):
290
        try:
291
            self.blockSignals(True)
292
            self.textChanged(item)
293
            self.initTagNoCell(item)
294

  
295
            """ show tooltip """
296
            for index in range(self.rowCount()):
297
                item = self.item(index, 1)
298
                if item is not None:
299
                    item.setToolTip(item.text())
300
        finally:
301
            self.blockSignals(False)
302

  
283 303
    def symbolChanged(self, item):
284 304
        """fill symbol properties"""
285 305
        self.initTitleCell(item)
......
808 828
        @date       18.05.10
809 829
        @history    humkyung 2018.07.20 display combobox when key is 'Stream No'
810 830
    '''
811

  
812 831
    def initLineNoCell(self, lineNoItem):
813 832
        appDocData = AppDocData.instance()
814 833
        configs = appDocData.getConfigs('Line No', 'Configuration')
......
861 880

  
862 881
                row = row + 1
863 882

  
883
    def initTagNoCell(self, tagNoItem):
884
        appDocData = AppDocData.instance()
885
        configs = appDocData.getConfigs('Tag No', 'Configuration')
886
        configs = configs[0].value.split('"-"')
887

  
888
        row = self.rowCount()
889
        attrs = tagNoItem.getAttributes()
890
        self.setRowCount(row + len(attrs))
891
        if attrs is not None:
892
            for key in attrs.keys():
893
                item = QTableWidgetItem(key.DisplayAttribute if key.DisplayAttribute else key.Attribute)
894
                item.setFlags(Qt.ItemIsEnabled)
895
                # item.setBackground(Qt.lightGray)
896
                item.setData(Qt.UserRole, key)
897
                self.setItem(row, 1, item)
898

  
899
                """ show icon item """
900
                self.show_icon_item(row, 2, key)
901

  
902
                """ show freeze state """
903
                if key.IsProp != 5:
904
                    checkbox = QCustomCheckBox(self, row, 0)
905
                    checkbox.setChecked(key.Freeze)
906
                    checkbox.stateChanged.connect(checkbox.state_changed)
907
                    self.setCellWidget(row, 0, checkbox)
908

  
909
                # value cell
910
                value = attrs[key]
911
                valueCell = QTableWidgetItem(value)
912

  
913
                # UID로 확인
914
                keyStr = appDocData.getLinePropertiesByUID(key.UID)
915
                if keyStr:
916
                    # editable value cell
917
                    if keyStr[0].AttributeType == 'String':
918
                        pass
919
                        # self.attrValueList.append((valueCell, key.Attribute))
920
                        # self.stringCell.append(valueCell)
921
                    if keyStr[0].UID in configs: valueCell.setFlags(Qt.ItemIsEnabled)
922
                else:
923
                    valueCell.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)
924
                
925
                self.setItem(row, 3, valueCell)
926

  
927
                row = row + 1
928

  
864 929
    def on_stream_no_changed(self, item, combobox, index):
865 930
        """change connected lines' stream no by selected stream no"""
866 931
        try:
DTI_PID/DTI_PID/Shapes/EngineeringAbstractItem.py
355 355
            from EngineeringVendorItem import QEngineeringVendorItem
356 356
            from EngineeringLineNoTextItem import QEngineeringLineNoTextItem
357 357
            from EngineeringSpecBreakItem import QEngineeringSpecBreakItem
358
            from QEngineeringTagNoTextItem import QEngineeringTagNoTextItem
358 359

  
359 360
            """ get attributes of item from database """
360 361
            app_doc_data = AppDocData.instance()
......
365 366
            elif type(self) is QEngineeringLineNoTextItem:
366 367
                symbolAttrs = app_doc_data.getSymbolAttribute('Line No')
367 368
                self.getLineNoAttributes(_attrs)
369
            elif type(self) is QEngineeringTagNoTextItem:
370
                self.getTagNoAttributes(_attrs)
371
                self.attrs = _attrs
372
                return self.attrs
368 373
            else:
369 374
                symbolAttrs = app_doc_data.getSymbolAttribute(self.type)
370 375

  
371 376
            targetAttrs = []
372 377
            if not (type(self) is QEngineeringLineItem or type(self) is QEngineeringVendorItem or
373
                    type(self) is QEngineeringLineNoTextItem):
378
                    type(self) is QEngineeringLineNoTextItem or type(self) is QEngineeringTagNoTextItem):
374 379
                for attr in symbolAttrs:
375 380
                    if not attr.Target and not type(self) is QEngineeringSpecBreakItem:
376 381
                        continue
DTI_PID/DTI_PID/Shapes/EngineeringLineNoTextItem.py
244 244
        @author     kyouho
245 245
        @date       2018.09.06
246 246
    '''
247

  
248 247
    def getLineNoAttributes(self, _attrs=None):
249 248
        from SymbolAttr import SymbolAttr
250 249
        from Configs import LineNoConfig
250
        import csv
251 251

  
252 252
        if _attrs is None:
253 253
            _attrs = {}
......
266 266
            else:
267 267
                item = (False,)
268 268

  
269
            # Line No 부분
270 269
            if item[0]:
270
                # Line No 부분
271 271
                attr = SymbolAttr()
272 272
                attr.Attribute = 'LINE NO'
273 273
                attr.DisplayAttribute = 'Line No'
......
276 276
                _attrs[attr] = self.text()
277 277

  
278 278
                result = item[1]
279
                configs = config.value.split(self.delimiter)
279
                configs = list(csv.reader([config.value], delimiter=self.delimiter, escapechar='^'))[0]
280 280
                props = docData.getLineProperties()
281 281
                for prop in props:
282 282
                    if prop.UID in configs:
DTI_PID/DTI_PID/Shapes/QEngineeringTagNoTextItem.py
68 68
        except Exception as ex:
69 69
            from App import App 
70 70
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
71
            App.mainWnd().addMessage.emit(MessageType.Error, message)
71
            App.mainWnd().addMessage.emit(MessageType.Error, message)
72

  
73
    def getTagNoAttributes(self, _attrs=None):
74
        from SymbolAttr import SymbolAttr
75
        from Configs import TagNoConfig
76
        import csv
77

  
78
        if _attrs is None:
79
            _attrs = {}
80

  
81
        try:
82
            docData = AppDocData.instance()
83

  
84
            tag_no_configs = TagNoConfig.instance(tag=True)
85
            config = None
86
            if tag_no_configs:
87
                for tag_no_config in tag_no_configs:
88
                    item = tag_no_config.parse(self.text())
89
                    if item[0]:
90
                        config = tag_no_config
91
                        break
92
            else:
93
                item = (False,)
94

  
95
            if item[0]:
96
                result = item[1]
97
                configs = list(csv.reader([config.value], delimiter=self.delimiter, escapechar='^'))[0]
98
                props = docData.getLineProperties()
99
                for prop in props:
100
                    if prop.UID in configs:
101
                        for i in range(len(configs)):
102
                            if prop.UID == configs[i]:
103
                                _attrs[prop] = result[i]
104
                                break
105
                    else:
106
                        matches = [attr for attr in self.attrs if attr.UID == prop.UID]
107
                        if len(matches) == 1:
108
                            _attrs[matches[0]] = self.attrs[matches[0]]
109
                        # else:
110
                        #    _attrs[prop] = ''
111
        except Exception as ex:
112
            from App import App
113
            from AppDocData import MessageType
114

  
115
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
116
                                                           sys.exc_info()[-1].tb_lineno)
117
            App.mainWnd().addMessage.emit(MessageType.Error, message)
118

  
119
        return _attrs

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)