프로젝트

일반

사용자정보

통계
| 개정판:

hytos / HYTOS / HYTOS / ItemPropertyTableWidget.py @ 2281dace

이력 | 보기 | 이력해설 | 다운로드 (42.6 KB)

1 d60b3b6e humkyung
# coding: utf-8
2
3 bddd799c 김정우
try:
4
    from PyQt5.QtCore import *
5
    from PyQt5.QtGui import *
6
    from PyQt5.QtWidgets import *
7
except ImportError:
8
    try:
9
        from PyQt4.QtCore import *
10
        from PyQt4.QtGui import *
11
    except ImportError:
12
        raise ImportError("ImageViewerQt: Requires PyQt5 or PyQt4.")
13 714bab5a humkyung
14 bddd799c 김정우
import os
15
import sys
16
import math
17 5953ddc1 gaqhf
import re
18 b2c42200 kim yeonjin
19 cac8d64c humkyung
from EngineeringAbstractItem import QEngineeringAbstractItem
20 bddd799c 김정우
from SymbolSvgItem import SymbolSvgItem
21 baf331db humkyung
from EngineeringLineNoTextItem import QEngineeringLineNoTextItem
22 afabd84e humkyung
from EngineeringNoteItem import QEngineeringNoteItem
23 5953ddc1 gaqhf
from EngineeringTextItem import QEngineeringTextItem
24 357646b0 gaqhf
from UserInputAttribute import UserInputAttribute
25 0cf624b6 gaqhf
from EngineeringSpecBreakItem import QEngineeringSpecBreakItem
26 4077103a esham21
from EngineeringErrorItem import QEngineeringErrorItem
27 c3a5995f esham21
from SymbolAttr import SymbolAttr
28 18e5ca81 humkyung
from AppDocData import *
29 714bab5a humkyung
from Drawing import Drawing
30 12fa11d3 김정우
from enum import Enum
31
32
'''
33
    @brief      ItemType
34
    @author     Jeongwoo
35
    @date       2018.04.27
36 360faad5 김정우
    @history    2018.05.10  Jeongwoo    Add LINE_NO
37 12fa11d3 김정우
'''
38
class ItemType(Enum):
39
    SYMBOL = 1
40
    NOTE = 2
41 360faad5 김정우
    LINE_NO = 3
42 bddd799c 김정우
43 d0172482 humkyung
class QCustomCheckBox(QCheckBox):
44
    def __init__(self, table, row, col):
45
        QCheckBox.__init__(self)
46
        self.table = table
47
        self.row = row
48
        self.col = col
49
50
    def state_changed(self, state):
51
        """ check box state is changed """
52
        if self.col == 0:
53 c3a5995f esham21
            '''
54
            for index in range(self.table.rowCount()):
55
                data = self.table.item(index, 1).data(Qt.UserRole) if self.table.item(index, 1) is not None else None
56
                if data and type(data) is SymbolAttr:
57
                    widget = self.table.cellWidget(index, 3)
58
                    if widget:
59
                        widget.setEnabled(False) if state else widget.setEnabled(True)
60
                    data.Freeze = self.isChecked()
61

62
                    item = self.table.item(index, 3)
63
                    if item:
64
                        item.setFlags(Qt.ItemIsEnabled) if state else item.setFlags(Qt.ItemIsEnabled|Qt.ItemIsEditable|Qt.ItemIsSelectable)
65
                        item.setBackground(Qt.lightGray) if state else item.setBackground(Qt.white)
66
            '''
67
68 d0172482 humkyung
            widget = self.table.cellWidget(self.row, 3)
69
            if widget:
70
                widget.setEnabled(False) if state else widget.setEnabled(True)
71
72 7552be56 humkyung
            data = self.table.item(self.row, 1).data(Qt.UserRole)
73
            if data: data.Freeze = self.isChecked()
74
75 d0172482 humkyung
            item = self.table.item(self.row, 3)
76
            if item:
77
                item.setFlags(Qt.ItemIsEnabled) if state else item.setFlags(Qt.ItemIsEnabled|Qt.ItemIsEditable|Qt.ItemIsSelectable)
78
                item.setBackground(Qt.lightGray) if state else item.setBackground(Qt.white)
79
        elif self.col == 3:
80
            cell = self.table.item(self.row, 1)
81
            if cell:
82
                data = cell.data(Qt.UserRole)
83
                if data is not None:
84
                    if self.table._item: self.table._item.set_property(data.Attribute, self.isChecked())
85
86 0a9e44a7 humkyung
class QItemPropertyTableWidget(QTableWidget):
87 7e9d9ecd gaqhf
    def __init__(self, mainWindow):
88 bddd799c 김정우
        QTableWidget.__init__(self)
89 a208ed03 humkyung
        self._item = None
90 7e9d9ecd gaqhf
        self.mainWindow = mainWindow
91 bddd799c 김정우
92 5953ddc1 gaqhf
        self.cellChanged.connect(self.cellChangedEvent)
93 a208ed03 humkyung
        self.cellDoubleClicked.connect(self.cellDoubleClickedEvent)
94 dd3553d3 humkyung
95 bddd799c 김정우
    '''
96 b2c42200 kim yeonjin
        @brief      Initialize TableWidget
97
        @author     Jeongwoo
98
        @date       18.04.13
99
        @history    humkyung 2018.07.08 show column header
100
    '''
101
    def initItemPropertyTableWidget(self, item=None):
102
103
        if item is None:
104
            self.horizontalHeader().hide()
105
            return
106
107
        self.horizontalHeader().show()
108
109
        category = item.category
110
111
        if category == 'Equipment - [ Pressure Drop ]':
112
            self.setColumnCount(2)
113
            self.setHorizontalHeaderLabels(['P. Drop', 'Elevation'])
114
            self.setColumnWidth(0, 80)
115
            self.setColumnWidth(1, 80)
116
        elif category == 'Equipment - [ Pressurized ]':
117
            self.setColumnCount(3)
118
            self.setHorizontalHeaderLabels(['Index', 'P. Drop', 'Elevation'])
119
            self.setColumnWidth(0, 70)
120
            self.setColumnWidth(1, 70)
121
            self.setColumnWidth(2, 10)
122
        elif category == 'Equipment - [ Rotating ]':
123
            self.setColumnCount(2)
124
            self.setHorizontalHeaderLabels(['P. Drop', 'Elevation'])
125
            self.setColumnWidth(0, 80)
126
            self.setColumnWidth(1, 80)
127
        elif category == 'Instrument':
128
            self.setColumnCount(2)
129
            self.setHorizontalHeaderLabels(['P. Drop', 'Elevation'])
130
            self.setColumnWidth(0, 80)
131
            self.setColumnWidth(1, 80)
132
133
        self.verticalHeader().hide()
134
        self.horizontalHeader().setStretchLastSection(True)
135
        #self.verticallHeader().setDefaultSectionSize(50)
136
137
    '''
138 d2c68320 humkyung
        @brief  show item's property
139
        @author humkyung
140
        @date   2018.07.03
141 b8cd70f9 esham21
        @history    euisung  2019.01.15     add icon image to line item
142 d2c68320 humkyung
    '''
143 a208ed03 humkyung
    def show_item_property(self, item):
144 dc05dcb9 humkyung
        try:
145 b081cb3e esham21
            from PyQt5 import QtGui
146 a208ed03 humkyung
            from SymbolAttr import SymbolAttr
147 b2c42200 kim yeonjin
            from EngineeringStreamlineItem import QEngineeringStreamlineItem
148 a208ed03 humkyung
149
            self._item = item
150
151
            self.blockSignals(True)
152
153 b2c42200 kim yeonjin
            if type(item) is QEngineeringStreamlineItem:
154
                self.initItemPropertyTableWidget()
155 dc05dcb9 humkyung
                self.initTitleCell(item)
156 62762fec humkyung
                self.initContentsCell()
157 b2c42200 kim yeonjin
            elif issubclass(type(item), SymbolSvgItem):                
158 dc05dcb9 humkyung
                self.onSymbolClicked(item)
159
            elif type(item) is QEngineeringLineNoTextItem:
160
                self.onLineNoClicked(item)
161
            elif type(item) is QEngineeringNoteItem:
162 b0034990 humkyung
                noteContentsList = item.findNoteContents(item.text())
163
                self.onNoteClicked(item.text(), noteContentsList)
164 d1f5aa1b esham21
            elif issubclass(type(item), QEngineeringTextItem):
165
                self.onTextClicked(item)
166 2decf39b esham21
            elif type(item) is QEngineeringVendorItem:
167
                self.onVendorClicked(item)
168 5a5c16e6 humkyung
            elif item is None:
169
                self.setRowCount(0)
170 dc05dcb9 humkyung
        except Exception as ex:
171
            from App import App 
172
173
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
174 e65b0bf8 humkyung
            App.mainWnd().addMessage.emit(MessageType.Error, message)
175 a208ed03 humkyung
        finally:
176
            self.blockSignals(False)
177 1430097d humkyung
178 b2c42200 kim yeonjin
    
179 bddd799c 김정우
        
180
    '''
181
        @brief      Slot to accept item click event
182
        @author     Jeongwoo
183
        @date       18.04.13
184 8c5431cc humkyung
        @history    humkyung 2018.04.17 check if given symbol type is SymbolSvgItem
185 bddd799c 김정우
    '''
186
    @pyqtSlot(SymbolSvgItem)
187 6d6ad72f humkyung
    def onSymbolClicked(self, symbol):
188 d0172482 humkyung
        try:
189
            self.blockSignals(True)
190
            if issubclass(type(symbol), SymbolSvgItem):
191
                self._item = symbol
192
                self.symbolChanged(symbol)
193
            elif type(symbol) is QEngineeringLineNoTextItem:
194
                self.lineNoChanged(symbol)
195
        finally:
196
            self.blockSignals(True)
197 12fa11d3 김정우
198
    '''
199 714bab5a humkyung
        @brief      show drawing' attributes
200
        @author     humkyung 
201
        @date       2018.07.07
202
    '''
203
    @pyqtSlot(Drawing)
204
    def onDrawingClicked(self, drawing):
205 d0172482 humkyung
        try:
206
            self.blockSignals(True)
207
            self.setRowCount(len(drawing.attrs))
208 714bab5a humkyung
209 d0172482 humkyung
            row = 0
210
            for attr in drawing.attrs:
211
                name = attr[0]
212
                item = QTableWidgetItem(name)
213
                item.setFlags(Qt.ItemIsEnabled)
214
                item.setBackground(Qt.lightGray)
215
                self.setItem(row, 0, item)
216
217
                value = attr[1]
218
                item = QTableWidgetItem(value)
219
                item.setFlags(Qt.ItemIsEnabled)
220
                self.setItem(row, 1, item)
221
222
                row = row + 1
223
        finally:
224
            self.blockSignals(False)
225 714bab5a humkyung
226 2decf39b esham21
    def onVendorClicked(self, item):
227
        from SymbolAttr import SymbolAttr
228
229
        try:
230
            self.blockSignals(True)
231
            self.initTitleCell(item)
232
233
            self.setItem(0, 3, QTableWidgetItem(str(self._item.uid)))
234
235
            self.show_item_properties(item)
236
        finally:
237
            self.blockSignals(False)
238
239 d1f5aa1b esham21
    def onTextClicked(self, item):
240
        from SymbolAttr import SymbolAttr
241
242
        try:
243
            self.blockSignals(True)
244
            self.initTitleCell(item)
245 ea4230ad esham21
246
            self.setItem(0, 3, QTableWidgetItem(str(self._item.uid)))
247
248 d1f5aa1b esham21
            owner_item = QTableWidgetItem('{}'.format('None' if self._item.owner is None else str(self._item.owner)))
249
            owner_item.setFlags(Qt.ItemIsEnabled|Qt.ItemIsSelectable)
250 ea4230ad esham21
            self.setItem(1, 3, owner_item)
251 d1f5aa1b esham21
252
            """ show icon item """
253
            attr = SymbolAttr()
254
            attr.AttributeType = "OWNER"
255 ea4230ad esham21
            self.show_icon_item(1, 2, attr)
256
            self.item(1, 1).setData(Qt.UserRole, attr)
257
258
            self.setItem(2, 3, QTableWidgetItem(self._item.type))
259
            self.setItem(3, 3, QTableWidgetItem(self._item.text()))
260 d1f5aa1b esham21
        finally:
261
            self.blockSignals(False)
262
263 714bab5a humkyung
    '''
264 12fa11d3 김정우
        @brief      Slot to accept Note item click event
265
        @author     Jeongwoo
266
        @date       18.04.27
267 6d6ad72f humkyung
        @history    humkyung 2018.07.08 change method name to onNoteClicked
268 12fa11d3 김정우
    '''
269 6ee64d77 humkyung
    @pyqtSlot(str, dict)
270 6d6ad72f humkyung
    def onNoteClicked(self, noteNoStr, noteContentsList):
271 d0172482 humkyung
        try:
272
            self.blockSignals(True)
273
            self.noteChanged(noteNoStr, noteContentsList)
274
        finally:
275
            self.blockSignals(False)
276 360faad5 김정우
277
    '''
278
        @brief      Slot to accept Line No Item Click event
279
        @author     Jeongwoo
280
        @date       18.05.10
281 6d6ad72f humkyung
        @hisotry    humkyung 2018.07.08 change method name to onLineNoClicked
282 360faad5 김정우
    '''
283 cac8d64c humkyung
    @pyqtSlot(QEngineeringAbstractItem)
284 6d6ad72f humkyung
    def onLineNoClicked(self, item):
285 d0172482 humkyung
        try:
286
            self.blockSignals(True)
287
            self.lineNoChanged(item)
288
        finally:
289
            self.blockSignals(False)
290 bddd799c 김정우
        
291
    '''
292
        @brief      Reset table with new SymbolSvgItem
293
        @author     Jeongwoo
294
        @date       18.04.13
295
        @history    .
296
    '''
297 d2c68320 humkyung
    def symbolChanged(self, item):
298 b2c42200 kim yeonjin
        self.initItemPropertyTableWidget(item)
299
        #self.initTitleCell(item)
300 bddd799c 김정우
        self.initContentsCell()
301 12fa11d3 김정우
302
    '''
303
        @brief      Reset table with note info
304
        @author     Jeongwoo
305
        @date       18.04.27
306
    '''
307
    def noteChanged(self, noteNoStr, noteContentsList):
308
        self.initNoteCell(noteNoStr, noteContentsList)
309 360faad5 김정우
310
    '''
311
        @brief      Reset table with line no item
312
        @author     Jeongwoo
313
        @date       18.05.10
314
    '''
315 233ca436 humkyung
    def lineNoChanged(self, item):
316 d0825b59 humkyung
        from EngineeringRunItem import QEngineeringRunItem
317 233ca436 humkyung
318
        if type(item) is QEngineeringLineNoTextItem:
319 d2c68320 humkyung
            self.initTitleCell(item)
320 233ca436 humkyung
            self.initLineNoCell(item)
321
        elif type(item) is QEngineeringRunItem:
322
            self.initLineRunCell(item)
323
324 9ff6820d humkyung
        """ show tooltip """
325
        for index in range(self.rowCount()):
326
            item = self.item(index, 1)
327
            if item is not None:
328
                item.setToolTip(item.text())
329
330 bddd799c 김정우
    '''
331
        @brief      Initialize Title Cell
332 ccb8b051 gaqhf
        @author     Jeongwoos
333 bddd799c 김정우
        @date       18.04.13
334 945eb2c6 humkyung
        @history    Jeongwoo 2018.04.27 Add if-statement by ItemType
335
                    Jeongwoo 2018.05.10 Add if-statement LINE_NO ItemType
336
                    humkyung 2018.08.15 add combobox for line type
337 bddd799c 김정우
    '''
338 d2c68320 humkyung
    def initTitleCell(self, item):
339 3a9d8155 humkyung
        from LineTypeConditions import LineTypeConditions
340 b2c42200 kim yeonjin
        from EngineeringStreamlineItem import QEngineeringStreamlineItem
341 3a9d8155 humkyung
342 d2c68320 humkyung
        try:
343 b2c42200 kim yeonjin
344
            #self.clear()
345
            #self.setHorizontalHeaderLabels(['', self.tr('Name'), '', self.tr('Value')])
346
            #self.setColumnWidth(0, 20)
347
            #self.setColumnWidth(1, 80)
348
            #self.setColumnWidth(2, 20)
349
            if type(item) is QEngineeringStreamlineItem:
350 8d4946fe esham21
                self.setRowCount(7)
351 ea4230ad esham21
                self.setItem(0, 1, QTableWidgetItem(self.tr("UID")))
352
                self.setItem(1, 1, QTableWidgetItem(self.tr("Name")))
353
                self.setItem(2, 1, QTableWidgetItem(self.tr("Type")))
354
                self.setItem(3, 1, QTableWidgetItem(self.tr("Angle")))
355
                self.setItem(4, 1, QTableWidgetItem(self.tr("Origin")))
356
                self.setItem(5, 1, QTableWidgetItem(self.tr("OWNER")))
357
                self.setItem(6, 1, QTableWidgetItem(self.tr("Set Specs")))
358 a208ed03 humkyung
            elif type(item) is QEngineeringErrorItem:
359 8d4946fe esham21
                self.setRowCount(7)
360 ea4230ad esham21
                self.setItem(0, 1, QTableWidgetItem(self.tr("UID")))
361
                self.setItem(1, 1, QTableWidgetItem(self.tr("Name")))
362
                self.setItem(2, 1, QTableWidgetItem(self.tr("Type")))
363
                self.setItem(3, 1, QTableWidgetItem(self.tr("Angle")))
364
                self.setItem(4, 1, QTableWidgetItem(self.tr("Origin")))
365
                self.setItem(5, 1, QTableWidgetItem(self.tr("OWNER")))
366
                self.setItem(6, 1, QTableWidgetItem(self.tr("Message")))
367 a208ed03 humkyung
            elif issubclass(type(item), SymbolSvgItem):
368
                self.setRowCount(6)
369 ea4230ad esham21
                self.setItem(0, 1, QTableWidgetItem(self.tr("UID")))
370
                self.setItem(1, 1, QTableWidgetItem(self.tr("Name")))
371
                self.setItem(2, 1, QTableWidgetItem(self.tr("Type")))
372
                self.setItem(3, 1, QTableWidgetItem(self.tr("Angle")))
373
                self.setItem(4, 1, QTableWidgetItem(self.tr("Origin")))
374
                self.setItem(5, 1, QTableWidgetItem(self.tr("OWNER")))
375 d2c68320 humkyung
            elif type(item) is QEngineeringNoteItem:
376 8d4946fe esham21
                self.setRowCount(2)
377 ea4230ad esham21
                self.setItem(0, 1, QTableWidgetItem(self.tr("Note No")))
378
                self.setItem(1, 1, QTableWidgetItem(self.tr("Desc.")))
379 d2c68320 humkyung
            elif type(item) is QEngineeringLineNoTextItem:
380 afabd84e humkyung
                self.setRowCount(1)
381 ea4230ad esham21
                self.setItem(0, 1, QTableWidgetItem(self.tr("UID")))
382 d2c68320 humkyung
            elif type(item) is QEngineeringLineItem:
383 a208ed03 humkyung
                self.setRowCount(5)
384 ea4230ad esham21
                self.setItem(0, 1, QTableWidgetItem(self.tr('UID')))
385
                self.setItem(1, 1, QTableWidgetItem(self.tr('OWNER')))
386
                widgetItem = QTableWidgetItem(self.tr("Type"))
387 945eb2c6 humkyung
                widgetItem.setData(Qt.UserRole, item)
388 d0172482 humkyung
                self.setItem(2, 1, widgetItem)
389 945eb2c6 humkyung
                self._lineTypeComboBox = QComboBox(self)
390
                self._lineTypeComboBox.tag = widgetItem
391 3a9d8155 humkyung
                for lineType in LineTypeConditions.items():
392
                    self._lineTypeComboBox.addItem(lineType.name)
393 d0172482 humkyung
                self.setCellWidget(2, 3, self._lineTypeComboBox)
394 945eb2c6 humkyung
                self._lineTypeComboBox.setCurrentText(item.lineType)
395
                self._lineTypeComboBox.currentIndexChanged.connect(self.onLineTypeChanged)
396 2decf39b esham21
            elif type(item) is QEngineeringVendorItem:
397
                self.setRowCount(1)
398
                self.setItem(0, 1, QTableWidgetItem(self.tr("UID")))
399 b2c42200 kim yeonjin
            #else:
400
            #    self.setRowCount(4)
401
            #    self.setItem(0, 1, QTableWidgetItem(self.tr("UID")))
402
            #    self.setItem(1, 1, QTableWidgetItem(self.tr("OWNER")))
403
            #    self.setItem(2, 1, QTableWidgetItem(self.tr("Type")))
404
            #    self.setItem(3, 1, QTableWidgetItem(self.tr("Text")))
405 945eb2c6 humkyung
406 d2c68320 humkyung
            for index in range(self.rowCount()):
407 d0172482 humkyung
                item = self.item(index, 1)
408 d2c68320 humkyung
                if item is not None:
409 1430097d humkyung
                    item.setFlags(Qt.ItemIsEnabled)
410 a208ed03 humkyung
                    item.setBackground(Qt.lightGray)
411 d2c68320 humkyung
        except Exception as ex:
412 835465ff humkyung
            from App import App 
413
414
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
415
            App.mainWnd().addMessage.emit(MessageType.Error, message)
416
417 945eb2c6 humkyung
    '''
418
        @brief  change selected lines' type by selected line type
419
        @author humkyung
420
        @date   2018.08.15
421
    '''
422
    def onLineTypeChanged(self, param):
423
        lineType = self._lineTypeComboBox.itemText(param)
424
        data = self._lineTypeComboBox.tag.data(Qt.UserRole)
425
        if type(data) is QEngineeringLineItem:
426 c3fff180 esham21
            self.changeConnectedLineType(data, lineType)
427
428
    def changeConnectedLineType(self, line, lineType):
429
        line.lineType = lineType
430 ccd0db87 esham21
        if type(line.connectors[0].connectedItem) is QEngineeringLineItem and \
431
                (line.connectors[0].connectedItem.connectors[0].connectedItem is line or line.connectors[0].connectedItem.connectors[1].connectedItem is line) and \
432
                line.connectors[0].connectedItem.lineType is not lineType:
433 c3fff180 esham21
            self.changeConnectedLineType(line.connectors[0].connectedItem, lineType)
434 ccd0db87 esham21
        if type(line.connectors[1].connectedItem) is QEngineeringLineItem and \
435
                (line.connectors[1].connectedItem.connectors[0].connectedItem is line or line.connectors[1].connectedItem.connectors[1].connectedItem is line) and \
436
                line.connectors[1].connectedItem.lineType is not lineType:
437 c3fff180 esham21
            self.changeConnectedLineType(line.connectors[1].connectedItem, lineType)
438 a208ed03 humkyung
439 d0172482 humkyung
    def show_icon_item(self, row, col, prop):
440
        """ show icon item on grid """
441
        from PyQt5 import QtGui
442
443
        if prop.is_selectable or prop.AttributeType == 'OWNER' or prop.AttributeType == 'CONN':
444
            icon = QtGui.QIcon()
445
            icon.addPixmap(QtGui.QPixmap(":/newPrefix/doubleclick.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
446
            icon_item = QTableWidgetItem('')
447
            icon_item.setFlags(Qt.ItemIsEnabled)
448
            icon_item.setIcon(icon)
449
            self.setItem(row, col, icon_item)
450
        elif prop.AttributeType == "String":
451
            icon = QtGui.QIcon()
452
            icon.addPixmap(QtGui.QPixmap(":/newPrefix/type.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
453
            icon_item = QTableWidgetItem()
454
            icon_item.setIcon(icon)
455
            self.setItem(row, col, icon_item)
456
        else:
457
            item = QTableWidgetItem()
458
            item.setFlags(Qt.ItemIsEditable)
459
            self.setItem(row, col, item)
460
461 a208ed03 humkyung
    def show_item_properties(self, item):
462
        """ show item properties on grid """
463
        from PyQt5 import QtGui
464
465
        row = self.rowCount()
466
        if hasattr(item, '_properties'):
467
            self.setRowCount(row + len(item.properties))
468
469
            for prop,value in item.properties.items():
470 16cf1212 humkyung
                try:
471
                    """ show freeze state """
472
                    checkbox = QCustomCheckBox(self, row, 0)
473
                    checkbox.setChecked(prop.Freeze)
474
                    checkbox.stateChanged.connect(checkbox.state_changed)
475
                    self.setCellWidget(row, 0, checkbox)
476
477
                    """ show property name """
478
                    key_item = QTableWidgetItem(prop.DisplayAttribute if prop.DisplayAttribute else prop.Attribute)
479
                    key_item.setFlags(Qt.ItemIsEnabled)
480
                    key_item.setBackground(Qt.lightGray)
481
                    key_item.setData(Qt.UserRole, prop)
482
                    self.setItem(row, 1, key_item)
483
484
                    """ show icon item """
485
                    self.show_icon_item(row, 2, prop)
486
487
                    """ show property value """
488
                    if prop.is_selectable:
489
                        value_item = QTableWidgetItem(str(value.uid) if hasattr(value, 'uid') else value)
490
                        value_item.setFlags(Qt.ItemIsEnabled|Qt.ItemIsSelectable)
491 d0172482 humkyung
                        self.setItem(row, 3, value_item)
492 16cf1212 humkyung
                    else:
493
                        if prop.AttributeType == 'Boolean':
494
                            self.checkbox_cell = QCustomCheckBox(self, row, 3)
495
                            self.checkbox_cell.setChecked(True if value and str(value) == 'True' else False)
496
                            self.checkbox_cell.stateChanged.connect(self.checkbox_cell.state_changed)
497 7b02722f esham21
                            #if prop.Attribute == 'Freeze': self.checkbox_cell.stateChanged.connect(item.freeze_item.update_freeze)
498 16cf1212 humkyung
                            self.setCellWidget(row, 3, self.checkbox_cell)
499
                        else:
500
                            value_item = QTableWidgetItem(value if value else '')
501
                            value_item.setFlags(Qt.ItemIsEnabled|Qt.ItemIsSelectable|Qt.ItemIsEditable)
502
                            self.setItem(row, 3, value_item)
503
504
                    checkbox.state_changed(checkbox.isChecked())
505
                    
506
                    row = row + 1
507
                except Exception as ex:
508
                    from App import App 
509
510
                    message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
511
                    App.mainWnd().addMessage.emit(MessageType.Error, message)
512 7552be56 humkyung
513 a208ed03 humkyung
    def show_item_attributes(self, item):
514
        """ show item's attributes on grid """
515
        from PyQt5 import QtGui
516
517
        row = self.rowCount()
518
        attrs = item.getAttributes()
519
520
        # display attributes of symbol
521
        if attrs is not None:
522
            self.setRowCount(row + len(attrs))
523
524
            for key,value in attrs.items():
525 16cf1212 humkyung
                try:
526
                    """ show freeze state """
527
                    checkbox = QCustomCheckBox(self, row, 0)
528
                    checkbox.setChecked(key.Freeze)
529
                    checkbox.stateChanged.connect(checkbox.state_changed)
530
                    self.setCellWidget(row, 0, checkbox)
531
532
                    """ show property name """
533
                    key_item = QTableWidgetItem(key.DisplayAttribute if key.DisplayAttribute else key.Attribute)
534
                    key_item.setBackground(Qt.lightGray)
535
                    key_item.setData(Qt.UserRole, key)
536
                    self.setItem(row, 1, key_item)
537
538
                    """ show icon item """
539
                    self.show_icon_item(row, 2, key)
540
541
                    value_item = QTableWidgetItem(str(value))
542
                    value_item.setFlags(Qt.ItemIsEnabled|Qt.ItemIsSelectable|Qt.ItemIsEditable)
543
544
                    if type(item) is QEngineeringSpecBreakItem:
545
                        if key.Attribute == 'UpStream' or key.Attribute == 'DownStream':
546
                            UpDownItem = QTableWidgetItem('{}'.format('None' if value is None else value))
547
                            self.setItem(row, 3, UpDownItem)
548
                        elif key.AttributeType == 'Spec':
549
                            self.setItem(row, 3, QTableWidgetItem(key.Attribute))
550
                    else:
551
                        self.setItem(row, 3, value_item)
552 7552be56 humkyung
553 16cf1212 humkyung
                    checkbox.state_changed(checkbox.isChecked())
554
555
                    row = row + 1
556
                except Exception as ex:
557
                        from App import App 
558
559
                        message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
560
                        App.mainWnd().addMessage.emit(MessageType.Error, message)
561 a208ed03 humkyung
562
    def show_item_connectors(self, item):
563
        """ show items' connectors on grid """
564
        from PyQt5 import QtGui
565
        from SymbolAttr import SymbolAttr
566
567 b2c42200 kim yeonjin
        row = 0 #self.rowCount()
568 a208ed03 humkyung
        self.setRowCount(row + len(item.connectors))
569 b2c42200 kim yeonjin
        
570 a208ed03 humkyung
        count = 1
571
        for connector in item.connectors:
572 b2c42200 kim yeonjin
            connector_item = QTableWidgetItem('{}'.format(count))
573 a208ed03 humkyung
            connector_item.setFlags(Qt.ItemIsEnabled)
574
            connector_item.setBackground(Qt.lightGray)
575 b2c42200 kim yeonjin
            connector_item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
576
            self.setItem(row, 0, connector_item)
577 a208ed03 humkyung
578 b2c42200 kim yeonjin
            #attr = SymbolAttr()
579
            #attr.AttributeType = "CONN"
580
            #attr.AttrAt = count
581
            #connector_item.setData(Qt.UserRole, attr)
582 a208ed03 humkyung
583 d0172482 humkyung
            """ show icon item """
584 b2c42200 kim yeonjin
            #self.show_icon_item(row, 2, attr)
585 d0172482 humkyung
586 b2c42200 kim yeonjin
            #connector_item = QTableWidgetItem('{}'.format('None' if connector.connectedItem is None else str(connector.connectedItem)))
587
            #connector_item.setFlags(Qt.ItemIsEnabled|Qt.ItemIsSelectable)
588
            #self.setItem(row, 3, connector_item)
589 945eb2c6 humkyung
            
590 a208ed03 humkyung
            row = row + 1
591
            count = count + 1
592
593 bddd799c 김정우
    '''
594
        @brief      Initialize Contents Cell
595
        @author     Jeongwoo
596
        @date       18.04.13
597 18f21a9a humkyung
        @history    humkyung 2018.06.14 display symbol attributes 
598 1430097d humkyung
                    humkyung 2018.07.05 display connectivity
599 b8cd70f9 esham21
                    euisung  2019.01.15 edit specbreak
600 bddd799c 김정우
    '''
601
    def initContentsCell(self):
602 b081cb3e esham21
        from PyQt5 import QtGui
603 a208ed03 humkyung
        from SymbolAttr import SymbolAttr
604 95bd7003 gaqhf
605 dd3553d3 humkyung
        try:
606 62762fec humkyung
            if self._item is not None and issubclass(type(self._item), SymbolSvgItem):
607 dd3553d3 humkyung
                docData = AppDocData.instance()
608
609 b2c42200 kim yeonjin
                '''
610 d0172482 humkyung
                self.setItem(0, 3, QTableWidgetItem(str(self._item.uid)))
611
                self.setItem(1, 3, QTableWidgetItem(self._item.name))
612
                self.setItem(2, 3, QTableWidgetItem(self._item.type))
613
                self.setItem(3, 3, QTableWidgetItem(str(round(math.degrees(self._item.angle)))))
614
                self.setItem(4, 3, QTableWidgetItem(str(self._item.origin)))
615 5a4d5665 humkyung
                owner_item = QTableWidgetItem('{}'.format('None' if self._item.owner is None else str(self._item.owner)))
616 d0172482 humkyung
                self.setItem(5, 3, owner_item)
617

618 d4373bc6 esham21
                for index in range(self.rowCount()):
619
                    item = self.item(index, 3)
620
                    if item is not None:
621
                        item.setFlags(Qt.ItemIsEnabled|Qt.ItemIsSelectable)
622

623 d0172482 humkyung
                """ show icon item """
624 a208ed03 humkyung
                attr = SymbolAttr()
625
                attr.AttributeType = "OWNER"
626 d0172482 humkyung
                self.show_icon_item(5, 2, attr)
627
                self.item(5, 1).setData(Qt.UserRole, attr)
628

629 b2c42200 kim yeonjin
                #if type(self._item) is not QEngineeringSpecBreakItem and type(self._item) is not QEngineeringErrorItem:
630
                    #self.show_item_properties(self._item)
631 835465ff humkyung

632 a208ed03 humkyung
                if type(self._item) is QEngineeringSpecBreakItem:
633 8d4946fe esham21
                    row = self.rowCount()
634 75060f7c esham21
                    setSpecsItem = QTableWidgetItem('Open')
635
                    icon = QtGui.QIcon()
636
                    icon.addPixmap(QtGui.QPixmap(":/newPrefix/doubleclick.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
637
                    setSpecsItem.setIcon(icon)
638 1f78dfb4 esham21
                    self.setItem(row - 1, 2, setSpecsItem)
639 dd3553d3 humkyung

640 a208ed03 humkyung
                if type(self._item) is QEngineeringErrorItem:
641 4077103a esham21
                    errType = 'None'
642 a208ed03 humkyung
                    if type(self._item.parent) is QEngineeringLineItem:
643 4077103a esham21
                        errType = 'line'
644 a208ed03 humkyung
                    elif issubclass(type(self._item.parent), SymbolSvgItem):
645 4077103a esham21
                        errType = 'symbol'
646 d0172482 humkyung
                    self.setItem(2, 3, QTableWidgetItem(errType))
647
                    self.setItem(5, 3, QTableWidgetItem(str(self._item.parent.uid)))
648
                    self.setItem(6, 3, QTableWidgetItem(self._item.msg))
649 9ff6820d humkyung

650 a208ed03 humkyung
                self.show_item_attributes(self._item)
651 b2c42200 kim yeonjin
                '''
652 a208ed03 humkyung
                self.show_item_connectors(self._item)
653
                
654 ff096d3a esham21
                for index in range(self.rowCount()):
655 d0172482 humkyung
                    item = self.item(index, 3)
656 a208ed03 humkyung
                    if item is not None: item.setToolTip(item.text())
657 62762fec humkyung
            elif self._item is not None and type(self._item) is QEngineeringLineItem:
658
                self.setItem(0, 3, QTableWidgetItem(str(self._item.uid)))
659
660
                """ show icon item """
661
                attr = SymbolAttr()
662
                attr.AttributeType = "OWNER"
663
                self.show_icon_item(1, 2, attr)
664
                self.item(1, 1).setData(Qt.UserRole, attr)
665
666
                owner_item = QTableWidgetItem('{}'.format('None' if self._item.owner is None else str(self._item.owner)))
667
                self.setItem(1, 3, owner_item)
668
669
                self.show_item_properties(self._item)
670
671
                pt = self._item.startPoint()
672 ea4230ad esham21
                key_item = QTableWidgetItem(self.tr("Start"))
673 62762fec humkyung
                key_item.setFlags(Qt.ItemIsEnabled)
674
                key_item.setBackground(Qt.lightGray)
675
                self.setItem(3, 1, key_item)
676
                self.setItem(3, 3, QTableWidgetItem('({},{})'.format(pt[0], pt[1])))
677
                pt = self._item.endPoint()
678 ea4230ad esham21
                key_item = QTableWidgetItem(self.tr("End"))
679 62762fec humkyung
                key_item.setFlags(Qt.ItemIsEnabled)
680
                key_item.setBackground(Qt.lightGray)
681
                self.setItem(4, 1, key_item)
682
                self.setItem(4, 3, QTableWidgetItem('({},{})'.format(pt[0], pt[1])))
683
684 289417f5 esham21
                self.show_item_attributes(self._item)
685 62762fec humkyung
                self.show_item_connectors(self._item)
686 dd3553d3 humkyung
            else:
687
                self.setRowCount(0)
688 d4373bc6 esham21
            
689 dd3553d3 humkyung
        except Exception as ex:
690
            from App import App 
691 1430097d humkyung
692 dd3553d3 humkyung
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
693
            App.mainWnd().addMessage.emit(MessageType.Error, message)
694 12fa11d3 김정우
695 6a187649 gaqhf
    '''
696
        @brief      combobox change event
697
        @author     kyouho
698
        @date       2018.08.28
699
    '''
700
    def upStreamChanged(self, text):
701 a208ed03 humkyung
        if self._item is not None:
702 6a187649 gaqhf
            find = False
703 a208ed03 humkyung
            for index in range(len(self._item.attrs)):
704
                if type(self._item.attrs[index]) is tuple and self._item.attrs[index][0] == 'Up Stream':
705
                    self._item.attrs[index] = (self._item.attrs[index][0], text)
706 6a187649 gaqhf
                    find = True
707
                    break
708
            
709
            if not find:
710 a208ed03 humkyung
                self._item.attrs.append(('Up Stream', text))
711 6a187649 gaqhf
712
    '''
713
        @brief      combobox change event
714
        @author     kyouho
715
        @date       2018.08.28
716
    '''
717
    def downStreamChanged(self, text):
718 a208ed03 humkyung
        if self._item is not None:
719 6a187649 gaqhf
            find = False
720 a208ed03 humkyung
            for index in range(len(self._item.attrs)):
721
                if type(self._item.attrs[index]) is tuple and self._item.attrs[index][0] == 'Down Stream':
722
                    self._item.attrs[index] = (self._item.attrs[index][0], text)
723 6a187649 gaqhf
                    find = True
724
                    break
725
            
726
            if not find:
727 a208ed03 humkyung
                self._item.attrs.append(('Down Stream', text))
728 f457910a gaqhf
729
    '''
730 12fa11d3 김정우
        @brief      Initialize Note Contents Cell
731
        @author     Jeongwoo
732
        @date       18.04.27
733
    '''
734
    def initNoteCell(self, noteNoStr, noteContentsList):
735 6ee64d77 humkyung
        self.setRowCount(0)
736
737 366e4ab3 humkyung
        for key in noteContentsList:
738 6ee64d77 humkyung
            row = self.rowCount()
739
            self.setRowCount(row + len(noteContentsList[key]))
740
            item = QTableWidgetItem(key)
741 d0172482 humkyung
            self.setItem(row, 1, item)
742 6ee64d77 humkyung
743 366e4ab3 humkyung
            for index in range(len(noteContentsList[key])):
744 d0172482 humkyung
                self.setItem(row, 3, QTableWidgetItem(noteContentsList[key][index]))
745 6ee64d77 humkyung
                row = row + 1
746
747
        for index in range(self.rowCount()):
748 d0172482 humkyung
            item = self.item(index, 1)
749 6ee64d77 humkyung
            if item is not None:
750
                item.setFlags(Qt.ItemIsEnabled)
751 a208ed03 humkyung
                item.setBackground(Qt.lightGray)
752 360faad5 김정우
753
    '''
754
        @brief      Initialize Line No Contents Cell
755
        @author     Jeongwoo
756
        @date       18.05.10
757 2029fb03 humkyung
        @history    humkyung 2018.07.20 display combobox when key is 'Stream No'
758 360faad5 김정우
    '''
759
    def initLineNoCell(self, lineNoItem):
760 269a15c8 gaqhf
        appDocData = AppDocData.instance()
761 afabd84e humkyung
        configs = appDocData.getConfigs('Line No', 'Configuration')
762
        configs = configs[0].value.split('"-"')
763 269a15c8 gaqhf
764 afabd84e humkyung
        item = QTableWidgetItem(str(lineNoItem.uid))
765 1b0802fb humkyung
        item.setFlags(Qt.ItemIsEnabled|Qt.ItemIsSelectable)
766 d0172482 humkyung
        self.setItem(0, 3, item)
767 1430097d humkyung
768 a208ed03 humkyung
        self.show_item_properties(lineNoItem)
769
        
770 afabd84e humkyung
        row = self.rowCount()
771
        attrs = lineNoItem.getAttributes()
772
        self.setRowCount(row + len(attrs))
773
        if attrs is not None:
774
            for key in attrs.keys():
775
                item = QTableWidgetItem(key.DisplayAttribute if key.DisplayAttribute else key.Attribute)
776
                item.setFlags(Qt.ItemIsEnabled)
777 a208ed03 humkyung
                item.setBackground(Qt.lightGray)
778 afabd84e humkyung
                item.tag = key
779 d0172482 humkyung
                self.setItem(row, 1, item)
780
781
                """ show icon item """
782
                self.show_icon_item(row, 2, key)
783 dcb4b5a7 gaqhf
784
                # value cell
785 afabd84e humkyung
                value = attrs[key]
786 dcb4b5a7 gaqhf
                valueCell = QTableWidgetItem(value)
787
788
                # UID로 확인
789 afabd84e humkyung
                keyStr = appDocData.getLinePropertiesByUID(key.UID)
790 dcb4b5a7 gaqhf
                if keyStr:
791
                    # editable value cell
792 dd3553d3 humkyung
                    if keyStr[0].AttributeType == 'String':
793 a208ed03 humkyung
                        pass
794
                        #self.attrValueList.append((valueCell, key.Attribute))
795
                        #self.stringCell.append(valueCell)
796 afabd84e humkyung
                    if keyStr[0].UID in configs: valueCell.setFlags(Qt.ItemIsEnabled)
797
                else:
798 1b0802fb humkyung
                    valueCell.setFlags(Qt.ItemIsEnabled|Qt.ItemIsSelectable)
799 b209ec12 gaqhf
                 
800 1bfc5892 humkyung
                if key.Attribute.upper() == 'STREAM_NO':
801 2029fb03 humkyung
                    self.streamNoComboBox = QComboBox()
802 1bfc5892 humkyung
                    self.streamNoComboBox.tag = key
803 2029fb03 humkyung
                    self.streamNoComboBox.currentIndexChanged.connect(self.onStreamNoChanged)
804 269a15c8 gaqhf
                    
805 2029fb03 humkyung
                    streamNos = sorted(list(appDocData.hmbTable.streamNos()))
806
                    for streamNo in streamNos:
807
                        self.streamNoComboBox.addItem(streamNo)
808 d0172482 humkyung
                    self.setCellWidget(row, 3, self.streamNoComboBox)
809 2029fb03 humkyung
                    self.streamNoComboBox.setCurrentText(value)
810 d0172482 humkyung
                    
811
                self.setItem(row, 3, valueCell)
812 afabd84e humkyung
813
                row = row + 1
814 2029fb03 humkyung
815
    '''
816 945eb2c6 humkyung
        @brief  change selected lines' stream no by selected stream no
817 2029fb03 humkyung
        @author humkyung
818
        @date   2018.07.20
819
    '''
820
    def onStreamNoChanged(self, param):
821 1bfc5892 humkyung
        items = self.mainWindow.graphicsView.scene.selectedItems()
822
        if items is not None and len(items) == 1:
823
            if type(items[0]) is QEngineeringLineNoTextItem:
824
                stream_no = self.streamNoComboBox.itemText(param)
825 7552be56 humkyung
                items[0].set_attrib(self.streamNoComboBox.tag, stream_no)
826 1bfc5892 humkyung
                return
827 2029fb03 humkyung
828 233ca436 humkyung
    '''
829
        @brief      Initialize Run Contents Cell
830
        @author     humkyung 
831
        @date       2018.05.27
832
    '''
833
    def initLineRunCell(self, item):
834 1430097d humkyung
        self.setRowCount(1)
835
836 ea4230ad esham21
        lineTypeItem = QTableWidgetItem(self.tr("Line Type"))
837 a208ed03 humkyung
        lineTypeItem.setBackground(Qt.lightGray)
838 1430097d humkyung
        lineTypeItem.setFlags(Qt.ItemIsEnabled)
839 d0172482 humkyung
        self.setItem(0, 1, lineTypeItem)
840 7e9d9ecd gaqhf
841
    '''
842
        @brief      Key Press Event
843
        @author     kyouho
844
        @date       2018.07.19
845
    '''
846
    def keyPressEvent(self, event):
847 bc42255c esham21
        from SymbolAttr import SymbolAttr
848
849 7e9d9ecd gaqhf
        if event.key() == Qt.Key_Delete:
850
            items = self.mainWindow.graphicsView.scene.selectedItems()
851
            selectedIndexes = self.selectedIndexes()
852 0c8812bd esham21
            if selectedIndexes[0].column() == 3 and self.item(selectedIndexes[0].row(), 1).text() == 'OWNER':
853 c7a0bb20 humkyung
                items[0].owner = None
854
                self.show_item_property(items[0])
855 bc42255c esham21
            #elif len(items) == 1 and len(selectedIndexes) == 1 and type(items[0]) is not QEngineeringLineItem and type(items[0]) is not QEngineeringSpecBreakItem and self.item(selectedIndexes[0].row(), 1).text().find('CONN') is not 0:
856
            #    if selectedIndexes[0].column() == 3:
857
            #        attributeStr = self.item(selectedIndexes[0].row(), 1).text()
858
            #        items[0].removeSelfAttr(attributeStr)
859
            #        self.mainWindow.refreshResultPropertyTableWidget()
860 6d715a6e esham21
            elif len(items) == 1 and len(selectedIndexes) == 1 and (type(items[0]) is QEngineeringLineItem or issubclass(type(items[0]), SymbolSvgItem)):
861 9689cb6b esham21
                key_cell = self.item(selectedIndexes[0].row(), 1)
862 bc42255c esham21
                data = key_cell.data(Qt.UserRole)
863 d0172482 humkyung
                if selectedIndexes[0].column() == 3 and key_cell.text().find('CONN') is 0:
864 6d715a6e esham21
                    selectedUID = self.item(selectedIndexes[0].row(), 1).text()
865 e44ea38a humkyung
                    connNum = int(key_cell.text().replace('CONN', ''))
866 69645d91 esham21
                    items[0].connectors[connNum - 1].connectedItem = None
867 a208ed03 humkyung
                    self.show_item_property(items[0])
868 95bd7003 gaqhf
869 8958cadd esham21
                    for sceneItem in self.mainWindow.graphicsView.scene.items():
870 6d715a6e esham21
                        if hasattr(sceneItem, 'uid') and str(sceneItem.uid) == selectedUID and hasattr(sceneItem, 'connectors'):
871 8958cadd esham21
                            for sceneConnector in sceneItem.connectors:
872
                                if sceneConnector.connectedItem is not None and items[0].uid == sceneConnector.connectedItem.uid:
873
                                    sceneConnector.connectedItem = None
874 bc42255c esham21
                elif selectedIndexes[0].column() == 3 and data and type(data) is SymbolAttr:
875
                    for _attr,_value in items[0].attrs.items():
876
                        if str(_attr.UID) == str(data.UID):
877
                            items[0].remove_assoc_item(_attr.AssocItem)
878
                            if type(_attr.AssocItem) is QEngineeringTextItem:
879
                                _attr.AssocItem.owner = None
880
                            _attr.AssocItem = None
881
                            items[0].attrs[_attr] = ''
882
                            self.show_item_property(items[0])
883
                            break
884 aebfc172 esham21
            elif len(items) == 1 and len(selectedIndexes) == 1 and type(items[0]) is QEngineeringSpecBreakItem:
885 0c8812bd esham21
                keyCell = self.item(selectedIndexes[0].row(), 1)
886 d0172482 humkyung
                if selectedIndexes[0].column() == 3 and (keyCell.text() == 'UpStream' or keyCell.text() == 'DownStream'):
887 aebfc172 esham21
                    for attr in items[0].attrs.keys():
888
                        if attr.Attribute == keyCell.text():
889
                            items[0].attrs[attr] = None
890 a208ed03 humkyung
                    self.show_item_property(items[0])
891 c82b5644 humkyung
        elif (event.key() == Qt.Key_C) and (event.modifiers() & Qt.ControlModifier):
892
            self.copy_cells_to_clipboard()
893
            event.accept()
894
895
    def copy_cells_to_clipboard(self):
896
        """ copy selected text to clipboard """
897
898
        selection = self.selectedIndexes()
899
        if selection:
900
            rows = sorted(index.row() for index in selection)
901
            columns = sorted(index.column() for index in selection)
902
            text = self.item(rows[-1], columns[-1]).text()
903
            QApplication.clipboard().setText(text)
904 a208ed03 humkyung
905 95bd7003 gaqhf
    '''
906 5953ddc1 gaqhf
        @brief      int cell check
907
        @author     kyouho
908
        @date       2018.08.20
909 95bd7003 gaqhf
    '''
910
    def cellChangedEvent(self, row, column):
911 d0172482 humkyung
        from SymbolAttr import SymbolProp
912
        from SymbolAttr import SymbolAttr
913
914 2b1f447d esham21
        try:
915 d0172482 humkyung
            if column == 3:
916
                item = self.item(row, 1)
917
                data = item.data(Qt.UserRole) if item is not None else None
918
                if data is not None:
919 98db97f5 humkyung
                    if self._item:
920 d0172482 humkyung
                        if type(data) is SymbolProp:
921
                            if data.AttributeType != 'Boolean':
922
                                self._item.set_property(data.Attribute, self.item(row, column).text())
923
                            else:
924
                                self._item.set_property(data.Attribute, self.cellWidget(row, column).isChecked())
925
                        elif type(data) is SymbolAttr:
926
                            if data.AttributeType != 'Boolean':
927 7552be56 humkyung
                                self._item.set_attrib(data, self.item(row, column).text())
928 d0172482 humkyung
                            else:
929 7552be56 humkyung
                                self._item.set_attrib(data, self.cellWidget(row, column).isChecked())
930 2b1f447d esham21
        except Exception as ex:
931
            from App import App
932
            from AppDocData import MessageType
933
934
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
935
            App.mainWnd().addMessage.emit(MessageType.Error, message)
936 afabd84e humkyung
937 5953ddc1 gaqhf
    '''
938 318bf424 gaqhf
        @brief      resultPropertyTableWidget Cell Double Click Event
939
        @author     kyouho
940
        @date       2018.07.19
941 b8cd70f9 esham21
        @history    euisung  2019.01.15  edit specbreak
942 318bf424 gaqhf
    '''
943
    def cellDoubleClickedEvent(self, row, column):
944 a208ed03 humkyung
        from SymbolAttr import SymbolProp
945 76fb1c20 esham21
946 d0172482 humkyung
        if column == 2:
947 318bf424 gaqhf
            items = self.mainWindow.graphicsView.scene.selectedItems()
948 d0172482 humkyung
            keyCell = self.item(row, 1)
949 a208ed03 humkyung
            attr = keyCell.data(Qt.UserRole)
950 12c077d1 esham21
            if hasattr(keyCell, 'tag') and type(items[0]) is not QEngineeringSpecBreakItem:
951 318bf424 gaqhf
                attr = keyCell.tag
952 e46783af humkyung
                if attr.is_selectable:
953 318bf424 gaqhf
                    cmd = SelectAttributeCommand.SelectAttributeCommand(items[0], attr, self.mainWindow.graphicsView)
954
                    cmd.onSuccess.connect(self.onSuccessSelectAttribute)
955
                    self.mainWindow.graphicsView.command = cmd
956 96df8663 humkyung
                elif self.item(row, column).flags() != Qt.ItemIsEnabled: 
957 d77477f8 humkyung
                    self.editItem(self.item(row, column))
958 318bf424 gaqhf
            elif keyCell.text() == 'CONN' and type(items[0]) is QEngineeringLineNoTextItem:
959
                from SymbolAttr import SymbolAttr
960
                attr = SymbolAttr()
961 0b2e4877 esham21
                attr.AttributeType = "Line Item"
962
                cmd = SelectAttributeCommand.SelectAttributeCommand(items[0], attr, self.mainWindow.graphicsView)
963
                cmd.onSuccess.connect(self.onSuccessSelectAttribute)
964
                self.mainWindow.graphicsView.command = cmd
965 d1f5aa1b esham21
            elif keyCell.text() == 'OWNER' and ((type(items[0]) is QEngineeringLineItem) or (issubclass(type(items[0]), SymbolSvgItem)) or (issubclass(type(items[0]), QEngineeringTextItem))):
966 a208ed03 humkyung
                attr = keyCell.data(Qt.UserRole)
967 835465ff humkyung
                cmd = SelectAttributeCommand.SelectAttributeCommand(items[0], attr, self.mainWindow.graphicsView)
968
                cmd.onSuccess.connect(self.onSuccessSelectAttribute)
969
                self.mainWindow.graphicsView.command = cmd
970 12c077d1 esham21
            elif type(items[0]) is QEngineeringSpecBreakItem:
971
                if keyCell.text() == 'UpStream' or keyCell.text() == 'DownStream':
972 a208ed03 humkyung
                    attr = keyCell.data(Qt.UserRole)
973 12c077d1 esham21
                    cmd = SelectAttributeCommand.SelectAttributeCommand(items[0], attr, self.mainWindow.graphicsView)
974
                    cmd.onSuccess.connect(self.onSuccessSelectAttribute)
975 76fb1c20 esham21
                    self.mainWindow.graphicsView.command = cmd
976 12c077d1 esham21
977 75060f7c esham21
                elif keyCell.text() == 'Set Specs':
978 94cc331f esham21
                    from SpecBreakDialog import QSpecBreakDialog
979 76fb1c20 esham21
980
                    try:
981 0fd2a543 esham21
                        dialog = QSpecBreakDialog(self, items[0])
982 76fb1c20 esham21
                        dialog.exec_()
983 a208ed03 humkyung
                        self.show_item_property(items[0])
984 76fb1c20 esham21
                    except Exception as ex:
985
                        print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
986 a208ed03 humkyung
            elif issubclass(type(attr), SymbolProp):
987
                attr = keyCell.data(Qt.UserRole)
988
                cmd = SelectAttributeCommand.SelectAttributeCommand(items[0], attr, self.mainWindow.graphicsView)
989
                cmd.onSuccess.connect(self.onSuccessSelectAttribute)
990
                self.mainWindow.graphicsView.command = cmd
991 318bf424 gaqhf
992
    '''
993
        @brief      success select attribute 
994
        @author     kyouho
995
        @date       2018.10.23
996
    '''
997 19ef241f esham21
    def onSuccessSelectAttribute(self, connItem = None):
998 a208ed03 humkyung
        """ update item's properties after selecting """
999
        self.show_item_property(self._item)
클립보드 이미지 추가 (최대 크기: 500 MB)