개정판 9a5aef6e
issue #481: set owner of text
Change-Id: Ifaa45decc57c53f05d14c5c8f2f47586852190ef
DTI_PID/DTI_PID/Commands/SelectAttributeCommand.py | ||
---|---|---|
82 | 82 | |
83 | 83 |
while len(self._item._associations[self._attr.AttributeType]) <= self._attr.AttrAt: |
84 | 84 |
self._item._associations[self._attr.AttributeType].append(None) |
85 |
self._item._associations[self._attr.AttributeType][self._attr.AttrAt] = item
|
|
85 |
self._item.add_assoc_item(item, self._attr.AttrAt)
|
|
86 | 86 |
|
87 | 87 |
self.onSuccess.emit() |
88 | 88 |
except Exception as ex: |
DTI_PID/DTI_PID/Shapes/EngineeringAbstractItem.py | ||
---|---|---|
148 | 148 | |
149 | 149 |
return _type |
150 | 150 | |
151 |
def add_assoc_item(self, item): |
|
152 |
""" |
|
153 |
add given item to association |
|
154 |
""" |
|
151 |
def add_assoc_item(self, item, at=None): |
|
152 |
""" add given item to association """ |
|
155 | 153 | |
156 | 154 |
from EngineeringTextItem import QEngineeringTextItem |
157 | 155 |
from SymbolSvgItem import SymbolSvgItem |
... | ... | |
163 | 161 |
if not _type in self._associations: |
164 | 162 |
self._associations[_type] = [] |
165 | 163 | |
166 |
self._associations[_type].append(item) |
|
164 |
if at is None: |
|
165 |
self._associations[_type].append(item) |
|
166 |
else: |
|
167 |
self._associations[_type][at] = item |
|
168 |
item.owner = self |
DTI_PID/DTI_PID/Shapes/EngineeringTextItem.py | ||
---|---|---|
64 | 64 | |
65 | 65 |
# find owner with uid |
66 | 66 |
if self._owner is not None and type(self._owner) is uuid.UUID: |
67 |
matches = [x for x in self.scene().items() if hasattr(x, 'uid') and x.uid == self._owner] |
|
67 |
matches = [x for x in self.scene().items() if hasattr(x, 'uid') and str(x.uid) == str(self._owner)] |
|
68 |
if matches: self._owner = matches[0] |
|
68 | 69 |
return matches[0] if matches else None |
69 | 70 |
# up to here |
70 | 71 | |
... | ... | |
201 | 202 |
rect = QRectF(0, 0, self.size[1], self.size[0]) |
202 | 203 |
else: |
203 | 204 |
rect = QRectF(0, 0, self.size[0], self.size[1]) |
204 |
""" |
|
205 |
rect = self.sceneBoundingRect() |
|
206 |
rect.moveTo(0,0) |
|
207 |
""" |
|
208 | 205 | |
209 | 206 |
painter.setFont(self.font()) |
210 | 207 |
color = self.defaultTextColor() |
... | ... | |
530 | 527 | |
531 | 528 |
try: |
532 | 529 |
node = Element('ATTRIBUTE') |
533 |
#if owner is not None: |
|
534 | 530 |
uidNode = Element('UID') |
535 | 531 |
uidNode.text = str(self.uid) |
536 | 532 |
node.append(uidNode) |
... | ... | |
591 | 587 |
@history humkyung 2018.05.13 update after change color |
592 | 588 |
''' |
593 | 589 |
def setColor(self, color): |
594 |
c = QColor() |
|
595 |
c.setNamedColor(color) |
|
596 |
self.setDefaultTextColor(c) |
|
597 |
self.update() |
|
590 |
if QColor.isValidColor(color): |
|
591 |
c = QColor() |
|
592 |
c.setNamedColor(color) |
|
593 |
self.setDefaultTextColor(c) |
|
594 |
self.update() |
|
598 | 595 | |
599 | 596 |
def toSql(self): |
600 | 597 |
""" |
DTI_PID/DTI_PID/Shapes/SymbolSvgItem.py | ||
---|---|---|
459 | 459 |
self.hover = True |
460 | 460 |
self.update() |
461 | 461 | |
462 |
""" |
|
463 |
from EngineeringTextItem import QEngineeringTextItem |
|
464 |
self.setHightlight() |
|
465 |
self.currentCursor = int(Qt.OpenHandCursor) |
|
466 |
cursor = QCursor(Qt.OpenHandCursor) |
|
467 |
QApplication.instance().setOverrideCursor(cursor) |
|
468 |
self.update() |
|
469 | ||
470 |
for attr in self.attrs: |
|
471 |
if issubclass(type(attr), QEngineeringTextItem): |
|
472 |
attr.setDefaultTextColor(Qt.red) |
|
473 |
attr.update() |
|
474 |
elif issubclass(type(attr), SymbolSvgItem): |
|
475 |
attr.setColor('url(#hover)') |
|
476 |
attr.update() |
|
477 |
""" |
|
462 |
for assoc in self.associations(): |
|
463 |
assoc.hoverEnterEvent(event) |
|
478 | 464 |
except Exception as ex: |
479 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
465 |
from App import App |
|
466 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
467 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
480 | 468 | |
481 | 469 |
''' |
482 | 470 |
@brief unhighlight connector and attribute |
... | ... | |
488 | 476 |
self.hover = False |
489 | 477 |
self.update() |
490 | 478 | |
491 |
""" |
|
492 |
from EngineeringTextItem import QEngineeringTextItem |
|
493 |
self.unsetHightlight() |
|
494 |
self.currentCursor = int(Qt.ArrowCursor) |
|
495 |
cursor = QCursor(Qt.ArrowCursor) |
|
496 |
QApplication.instance().setOverrideCursor(cursor) |
|
497 |
self.update() |
|
498 | ||
499 |
for attr in self.attrs: |
|
500 |
if issubclass(type(attr), QEngineeringTextItem): |
|
501 |
attr.setDefaultTextColor(Qt.blue) |
|
502 |
attr.update() |
|
503 |
elif issubclass(type(attr), SymbolSvgItem): |
|
504 |
attr.setColor('url(#normal)') |
|
505 |
attr.update() |
|
506 |
""" |
|
479 |
for assoc in self.associations(): |
|
480 |
assoc.hoverLeaveEvent(event) |
|
507 | 481 | |
508 | 482 |
''' |
509 | 483 |
@brief set highlight |
내보내기 Unified diff