개정판 3ba088c3
add contextmenu
Change-Id: Icdb2ca61b5f8f7d9cc8893b59e801233ae22f78a
DTI_PID/DTI_PID/ItemTreeWidget.py | ||
---|---|---|
145 | 145 |
explode_action = QAction(self.tr("Explode")) |
146 | 146 |
explode_action.triggered.connect(lambda: self.explode_all_line_nos(item)) |
147 | 147 |
menu.addAction(explode_action) |
148 |
explodeKeepFromTo_action = QAction(self.tr("Explode (keep from, to)"))
|
|
148 |
explodeKeepFromTo_action = QAction(self.tr("Explode(keep from, to)")) |
|
149 | 149 |
explodeKeepFromTo_action.triggered.connect(lambda: self.explode_all_line_nos(item, True)) |
150 | 150 |
menu.addAction(explodeKeepFromTo_action) |
151 | 151 |
menu.exec_(self.viewport().mapToGlobal(position)) |
... | ... | |
162 | 162 |
explode_action.triggered.connect(lambda: self.explode_line_no(item)) |
163 | 163 |
menu.addAction(explode_action) |
164 | 164 |
if type(data) is QEngineeringLineNoTextItem: |
165 |
explodeKeepFromTo_action = QAction(self.tr("Explode (keep from, to)"))
|
|
165 |
explodeKeepFromTo_action = QAction(self.tr("Explode(keep from, to)")) |
|
166 | 166 |
explodeKeepFromTo_action.setEnabled(not freeze) |
167 | 167 |
explodeKeepFromTo_action.triggered.connect(lambda: self.explode_line_no(item, True)) |
168 | 168 |
menu.addAction(explodeKeepFromTo_action) |
DTI_PID/DTI_PID/OPCRelationDialog.py | ||
---|---|---|
501 | 501 |
for row in range(table.rowCount()): |
502 | 502 |
try: |
503 | 503 |
text = str(table.item(row, col).text()) |
504 |
color = table.item(row, col).background().color() |
|
505 |
if color == Qt.cyan or color == Qt.magenta or color == Qt.red or color == Qt.yellow: |
|
506 |
sheet.cell(row + 2, col + 1).fill = PatternFill(patternType='solid', fill_type='solid', |
|
507 |
fgColor=Color(color.name().replace('#', ''))) |
|
504 | 508 |
sheet.cell(row + 2, col + 1, text) |
505 | 509 |
sheet.cell(row=row + 2, column=col + 1).border = border |
506 | 510 |
except AttributeError: |
DTI_PID/DTI_PID/QtImageViewerScene.py | ||
---|---|---|
68 | 68 |
def keyPressEvent(self, event: QKeyEvent): |
69 | 69 |
from SymbolSvgItem import SymbolSvgItem |
70 | 70 |
from EngineeringTextItem import QEngineeringTextItem |
71 |
from EngineeringLineItem import QEngineeringLineItem |
|
71 | 72 |
from DeleteCommand import DeleteCommand |
72 | 73 |
from RotateCommand import RotateCommand |
73 | 74 |
from FlipCommand import FlipCommand |
... | ... | |
80 | 81 |
elif event.key() in [Qt.Key_Up, Qt.Key_Down, Qt.Key_Left, Qt.Key_Right]: |
81 | 82 |
if self.selectedItems(): |
82 | 83 |
items = [text for text in self.selectedItems() if |
83 |
issubclass(type(text), QEngineeringTextItem) or issubclass(type(text), SymbolSvgItem)] |
|
84 |
issubclass(type(text), QEngineeringTextItem) or issubclass(type(text), SymbolSvgItem) or type(text) == QEngineeringLineItem]
|
|
84 | 85 |
self._pressed_keys.add(event.key()) |
85 | 86 |
if items: |
86 | 87 |
for item in items: |
DTI_PID/DTI_PID/Shapes/EngineeringLineItem.py | ||
---|---|---|
1415 | 1415 |
def keyPressEvent(self, event): |
1416 | 1416 |
from EngineeringLineNoTextItem import QEngineeringLineNoTextItem |
1417 | 1417 |
|
1418 |
if self.isSelected() and event.key() == Qt.Key_Delete: |
|
1419 |
self.scene().removeItem(self) |
|
1420 |
elif event.key() == Qt.Key_C:# and self.is_piping(True):
|
|
1418 |
#if self.isSelected() and event.key() == Qt.Key_Delete:
|
|
1419 |
# self.scene().removeItem(self)
|
|
1420 |
if event.key() == Qt.Key_C:# and self.is_piping(True): |
|
1421 | 1421 |
if self.owner and issubclass(type(self.owner), QEngineeringLineNoTextItem): |
1422 | 1422 |
index = 1 |
1423 | 1423 |
for run in self.owner.runs: |
... | ... | |
2058 | 2058 |
QGraphicsLineItem.mouseReleaseEvent(self, event) |
2059 | 2059 |
|
2060 | 2060 |
def contextMenuEvent(self, event): |
2061 |
menu = QMenu() |
|
2062 |
testAction = QAction('Test', None) |
|
2063 |
testAction.triggered.connect(self.print_out) |
|
2064 |
menu.addAction(testAction) |
|
2065 |
menu.exec_(event.screenPos()) |
|
2066 |
|
|
2067 |
def print_out(self): |
|
2068 |
print('Triggered') |
|
2061 |
items = self.scene().selectedItems() |
|
2062 |
if len(items) > 0 and self in items: |
|
2063 |
menu = QMenu() |
|
2064 |
|
|
2065 |
mergeAction = QAction('Merge(M)', None) |
|
2066 |
mergeAction.triggered.connect(self.contextMerge) |
|
2067 |
menu.addAction(mergeAction) |
|
2068 |
|
|
2069 |
reverseAction = QAction('Reverse(C)', None) |
|
2070 |
reverseAction.triggered.connect(self.contextReverse) |
|
2071 |
menu.addAction(reverseAction) |
|
2072 |
|
|
2073 |
arrowAction = QAction('Arrow(A)', None) |
|
2074 |
arrowAction.triggered.connect(self.contextArrow) |
|
2075 |
menu.addAction(arrowAction) |
|
2076 |
|
|
2077 |
deleteAction = QAction('Delete(E)', None) |
|
2078 |
deleteAction.triggered.connect(self.contextDelete) |
|
2079 |
menu.addAction(deleteAction) |
|
2080 |
|
|
2081 |
menu.exec_(event.screenPos()) |
|
2082 |
|
|
2083 |
def contextDelete(self): |
|
2084 |
event = QKeyEvent(QEvent.KeyPress, Qt.Key_Delete, Qt.NoModifier) |
|
2085 |
self.scene().keyPressEvent(event) |
|
2086 |
|
|
2087 |
def contextArrow(self): |
|
2088 |
event = QKeyEvent(QEvent.KeyPress, Qt.Key_A, Qt.NoModifier) |
|
2089 |
self.keyPressEvent(event) |
|
2090 |
|
|
2091 |
def contextReverse(self): |
|
2092 |
event = QKeyEvent(QEvent.KeyPress, Qt.Key_C, Qt.NoModifier) |
|
2093 |
self.keyPressEvent(event) |
|
2094 |
|
|
2095 |
def contextMerge(self): |
|
2096 |
event = QKeyEvent(QEvent.KeyPress, Qt.Key_M, Qt.NoModifier) |
|
2097 |
self.keyPressEvent(event) |
|
2069 | 2098 |
|
2070 | 2099 |
''' |
2071 | 2100 |
@brief The class transfer pyqtSignal Event. Cause Subclass of QGraphicsRectItem can't use pyqtSignal |
DTI_PID/DTI_PID/Shapes/EngineeringLineNoTextItem.py | ||
---|---|---|
7 | 7 |
|
8 | 8 |
try: |
9 | 9 |
from PyQt5.QtCore import * |
10 |
from PyQt5.QtGui import QImage, QPixmap, QPainterPath, QBrush, QPen, QTransform, QFont |
|
11 |
from PyQt5.QtWidgets import QGraphicsView, QGraphicsScene, QFileDialog, QGraphicsItem, QAbstractGraphicsShapeItem, \ |
|
12 |
QGraphicsTextItem |
|
10 |
from PyQt5.QtGui import * |
|
11 |
from PyQt5.QtWidgets import * |
|
13 | 12 |
except ImportError: |
14 | 13 |
try: |
15 | 14 |
from PyQt4.QtCore import Qt, QRectF, pyqtSignal, QT_VERSION_STR, QRect |
... | ... | |
146 | 145 |
sys.exc_info()[-1].tb_lineno) |
147 | 146 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
148 | 147 |
|
148 |
def contextMenuEvent(self, event): |
|
149 |
items = self.scene().selectedItems() |
|
150 |
if len(items) == 1 and self in items: |
|
151 |
menu = QMenu() |
|
152 |
|
|
153 |
''' |
|
154 |
explodeAction = QAction('Explode', None) |
|
155 |
explodeAction.triggered.connect(self.contextExplode) |
|
156 |
menu.addAction(explodeAction) |
|
157 |
|
|
158 |
explodeKeepAction = QAction('Explode(keep from, to)', None) |
|
159 |
explodeKeepAction.triggered.connect(self.contextExplodeKeep) |
|
160 |
menu.addAction(explodeKeepAction) |
|
161 |
''' |
|
162 |
|
|
163 |
reverseAction = QAction('Reverse Flow', None) |
|
164 |
reverseAction.triggered.connect(self.contextReverse) |
|
165 |
menu.addAction(reverseAction) |
|
166 |
|
|
167 |
editAction = QAction('Edit(Return)', None) |
|
168 |
editAction.triggered.connect(self.contextEdit) |
|
169 |
menu.addAction(editAction) |
|
170 |
|
|
171 |
rotateAction = QAction('Rotate(R)', None) |
|
172 |
rotateAction.triggered.connect(self.contextRotate) |
|
173 |
menu.addAction(rotateAction) |
|
174 |
|
|
175 |
deleteAction = QAction('Delete(E)', None) |
|
176 |
deleteAction.triggered.connect(self.contextDelete) |
|
177 |
menu.addAction(deleteAction) |
|
178 |
|
|
179 |
menu.exec_(event.screenPos()) |
|
180 |
|
|
181 |
def contextExplode(self): |
|
182 |
from App import App |
|
183 |
App.mainWnd().itemTreeWidget.explode_line_no(self) |
|
184 |
|
|
185 |
def contextExplodeKeep(self): |
|
186 |
from App import App |
|
187 |
App.mainWnd().itemTreeWidget.explode_line_no(self, True) |
|
188 |
|
|
189 |
def contextReverse(self): |
|
190 |
self.reverse() |
|
191 |
|
|
192 |
def contextDelete(self): |
|
193 |
event = QKeyEvent(QEvent.KeyPress, Qt.Key_Delete, Qt.NoModifier) |
|
194 |
self.scene().keyPressEvent(event) |
|
195 |
|
|
196 |
def contextEdit(self): |
|
197 |
event = QKeyEvent(QEvent.KeyPress, Qt.Key_Return, Qt.NoModifier) |
|
198 |
self.keyPressEvent(event) |
|
199 |
|
|
200 |
def contextRotate(self): |
|
201 |
event = QKeyEvent(QEvent.KeyPress, Qt.Key_R, Qt.NoModifier) |
|
202 |
self.keyPressEvent(event) |
|
149 | 203 |
|
150 | 204 |
def hoverLeaveEvent(self, event): |
151 | 205 |
""" unhighlight line no text and run's item """ |
DTI_PID/DTI_PID/Shapes/EngineeringTextItem.py | ||
---|---|---|
4 | 4 |
import sys |
5 | 5 |
|
6 | 6 |
try: |
7 |
from PyQt5.QtCore import Qt, QPointF, QRectF, pyqtSignal, QObject, QT_VERSION_STR, QRect |
|
8 |
from PyQt5.QtGui import QImage, QPixmap, QPainterPath, QBrush, QPen, QTransform, QFont, QColor, QFontMetricsF |
|
9 |
from PyQt5.QtWidgets import QGraphicsView, QGraphicsScene, QFileDialog, QGraphicsItem, QAbstractGraphicsShapeItem, \ |
|
10 |
QGraphicsTextItem, QDialog, QApplication |
|
7 |
from PyQt5.QtCore import * |
|
8 |
from PyQt5.QtGui import * |
|
9 |
from PyQt5.QtWidgets import * |
|
11 | 10 |
except ImportError: |
12 | 11 |
try: |
13 | 12 |
from PyQt4.QtCore import Qt, QRectF, pyqtSignal, QRect, QObject, QT_VERSION_STR |
... | ... | |
197 | 196 |
humkyung 2018.08.18 rotate text when user press 'R' |
198 | 197 |
''' |
199 | 198 |
|
199 |
def contextMenuEvent(self, event): |
|
200 |
items = self.scene().selectedItems() |
|
201 |
if len(items) > 0 and self in items: |
|
202 |
menu = QMenu() |
|
203 |
|
|
204 |
editAction = QAction('Edit(Return)', None) |
|
205 |
editAction.triggered.connect(self.contextEdit) |
|
206 |
menu.addAction(editAction) |
|
207 |
|
|
208 |
mergeAction = QAction('Merge(M)', None) |
|
209 |
mergeAction.triggered.connect(self.contextMerge) |
|
210 |
menu.addAction(mergeAction) |
|
211 |
|
|
212 |
rotateAction = QAction('Rotate(R)', None) |
|
213 |
rotateAction.triggered.connect(self.contextRotate) |
|
214 |
menu.addAction(rotateAction) |
|
215 |
|
|
216 |
deleteAction = QAction('Delete(E)', None) |
|
217 |
deleteAction.triggered.connect(self.contextDelete) |
|
218 |
menu.addAction(deleteAction) |
|
219 |
|
|
220 |
menu.exec_(event.screenPos()) |
|
221 |
|
|
222 |
def contextMerge(self): |
|
223 |
event = QKeyEvent(QEvent.KeyPress, Qt.Key_M, Qt.NoModifier) |
|
224 |
self.keyPressEvent(event) |
|
225 |
|
|
226 |
def contextDelete(self): |
|
227 |
event = QKeyEvent(QEvent.KeyPress, Qt.Key_Delete, Qt.NoModifier) |
|
228 |
self.scene().keyPressEvent(event) |
|
229 |
|
|
230 |
def contextEdit(self): |
|
231 |
event = QKeyEvent(QEvent.KeyPress, Qt.Key_Return, Qt.NoModifier) |
|
232 |
self.keyPressEvent(event) |
|
233 |
|
|
234 |
def contextRotate(self): |
|
235 |
event = QKeyEvent(QEvent.KeyPress, Qt.Key_R, Qt.NoModifier) |
|
236 |
self.keyPressEvent(event) |
|
237 |
|
|
200 | 238 |
def keyPressEvent(self, event): |
201 | 239 |
#print('item :' + str(event.key())) |
202 | 240 |
if Qt.Key_Return == event.key(): |
DTI_PID/DTI_PID/Shapes/SymbolSvgItem.py | ||
---|---|---|
8 | 8 |
from PyQt5.QtGui import * |
9 | 9 |
from PyQt5.QtCore import * |
10 | 10 |
from PyQt5.QtSvg import * |
11 |
from PyQt5.QtWidgets import (QApplication, QGraphicsItem, QDialog)
|
|
11 |
from PyQt5.QtWidgets import *
|
|
12 | 12 |
from PyQt5.QtXml import * |
13 | 13 |
|
14 | 14 |
from AppDocData import * |
... | ... | |
1136 | 1136 |
from App import App |
1137 | 1137 |
App.mainWnd().keyPressEvent(event) |
1138 | 1138 |
|
1139 |
def contextMenuEvent(self, event): |
|
1140 |
items = self.scene().selectedItems() |
|
1141 |
if len(items) == 0 and self in items: |
|
1142 |
menu = QMenu() |
|
1143 |
|
|
1144 |
bindAction = QAction('Bind(B)', None) |
|
1145 |
bindAction.triggered.connect(self.contextBind) |
|
1146 |
menu.addAction(bindAction) |
|
1147 |
|
|
1148 |
rotateAction = QAction('Rotate(R)', None) |
|
1149 |
rotateAction.triggered.connect(self.contextRotate) |
|
1150 |
menu.addAction(rotateAction) |
|
1151 |
|
|
1152 |
flipAction = QAction('Flip(F)', None) |
|
1153 |
flipAction.triggered.connect(self.contextFlip) |
|
1154 |
menu.addAction(flipAction) |
|
1155 |
|
|
1156 |
deleteAction = QAction('Delete(E)', None) |
|
1157 |
deleteAction.triggered.connect(self.contextDelete) |
|
1158 |
menu.addAction(deleteAction) |
|
1159 |
|
|
1160 |
menu.exec_(event.screenPos()) |
|
1161 |
|
|
1162 |
def contextDelete(self): |
|
1163 |
event = QKeyEvent(QEvent.KeyPress, Qt.Key_Delete, Qt.NoModifier) |
|
1164 |
self.scene().keyPressEvent(event) |
|
1165 |
|
|
1166 |
def contextBind(self): |
|
1167 |
event = QKeyEvent(QEvent.KeyPress, Qt.Key_B, Qt.NoModifier) |
|
1168 |
self.keyPressEvent(event) |
|
1169 |
|
|
1170 |
def contextRotate(self): |
|
1171 |
event = QKeyEvent(QEvent.KeyPress, Qt.Key_R, Qt.NoModifier) |
|
1172 |
self.scene().keyPressEvent(event) |
|
1173 |
|
|
1174 |
def contextFlip(self): |
|
1175 |
event = QKeyEvent(QEvent.KeyPress, Qt.Key_F, Qt.NoModifier) |
|
1176 |
self.scene().keyPressEvent(event) |
|
1177 |
|
|
1139 | 1178 |
def bind_close_items(self): |
1140 | 1179 |
""" connect close item by pressing B """ |
1141 | 1180 |
from EngineeringLineItem import QEngineeringLineItem |
내보내기 Unified diff