개정판 0b0f46a6
issue #643: text move faster
Change-Id: I6cbb0172a6f8d6e1cf0b0d49c6b05b21df8fbec9
DTI_PID/DTI_PID/Shapes/EngineeringTextItem.py | ||
---|---|---|
209 | 209 |
|
210 | 210 |
self.rotate() |
211 | 211 |
elif event.key() == Qt.Key_Up: # translate up/down/left/right symbol |
212 |
self.loc[1] = self.loc[1] - 1 |
|
212 |
modifiers = QApplication.keyboardModifiers() |
|
213 |
delta = 10 if modifiers == Qt.ControlModifier else 1 |
|
214 |
|
|
215 |
self.loc[1] = self.loc[1] - delta |
|
213 | 216 |
self.rotate() |
214 | 217 |
elif event.key() == Qt.Key_Down: |
215 |
self.loc[1] = self.loc[1] + 1 |
|
218 |
modifiers = QApplication.keyboardModifiers() |
|
219 |
delta = 10 if modifiers == Qt.ControlModifier else 1 |
|
220 |
|
|
221 |
self.loc[1] = self.loc[1] + delta |
|
216 | 222 |
self.rotate() |
217 | 223 |
elif event.key() == Qt.Key_Left: |
218 |
self.loc[0] = self.loc[0] - 1 |
|
224 |
modifiers = QApplication.keyboardModifiers() |
|
225 |
delta = 10 if modifiers == Qt.ControlModifier else 1 |
|
226 |
|
|
227 |
self.loc[0] = self.loc[0] - delta |
|
219 | 228 |
self.rotate() |
220 | 229 |
elif event.key() == Qt.Key_Right: |
221 |
self.loc[0] = self.loc[0] + 1 |
|
230 |
modifiers = QApplication.keyboardModifiers() |
|
231 |
delta = 10 if modifiers == Qt.ControlModifier else 1 |
|
232 |
|
|
233 |
self.loc[0] = self.loc[0] + delta |
|
222 | 234 |
self.rotate() |
223 | 235 |
|
224 | 236 |
# QGraphicsTextItem.keyPressEvent(self, event) |
DTI_PID/DTI_PID/TextItemEditDialog.py | ||
---|---|---|
82 | 82 |
|
83 | 83 |
def replaceTextClicked(self): |
84 | 84 |
"""replace text""" |
85 |
self.find_text() |
|
86 |
|
|
87 |
text_find = self.ui.lineEditFindText.text() |
|
88 |
replace = self.ui.lineEditReplaceText.text() |
|
89 |
model = self.ui.tableViewResult.model() |
|
90 |
if model and model.rowCount(): |
|
91 |
messages = [] |
|
92 |
for row in range(model.rowCount()): |
|
93 |
item = self.ui.tableViewResult.model().item(row, 0) |
|
94 |
data = item.data() |
|
95 |
if data and data.text() != replace: |
|
96 |
text = data.text() |
|
97 |
messages.append(f"replaced: {text} --> {text.replace(text_find, replace)}") |
|
98 |
data.setPlainText(text.replace(text_find, replace)) |
|
99 |
if not data.text(): |
|
100 |
data.transfer.onRemoved.emit(data) |
|
101 |
|
|
102 |
if messages: |
|
103 |
QMessageBox.information(self, self.tr('Information'), '\r\n'.join(messages)) |
|
85 |
|
|
86 |
try: |
|
87 |
self.find_text() |
|
88 |
|
|
89 |
text_find = self.ui.lineEditFindText.text() |
|
90 |
replace = self.ui.lineEditReplaceText.text() |
|
91 |
model = self.ui.tableViewResult.model() |
|
92 |
if model and model.rowCount(): |
|
93 |
messages = [] |
|
94 |
for row in range(model.rowCount()): |
|
95 |
item = self.ui.tableViewResult.model().item(row, 0) |
|
96 |
data = item.data() |
|
97 |
if data and data.text() != replace: |
|
98 |
text = data.text() |
|
99 |
messages.append(f"replaced: {text} --> {text.replace(text_find, replace)}") |
|
100 |
data.setPlainText(text.replace(text_find, replace)) |
|
101 |
if not data.text(): |
|
102 |
data.transfer.onRemoved.emit(data) |
|
103 |
|
|
104 |
if messages: |
|
105 |
QMessageBox.information(self, self.tr('Information'), '\r\n'.join(messages)) |
|
106 |
except Exception as ex: |
|
107 |
from App import App |
|
108 |
from AppDocData import MessageType |
|
109 |
|
|
110 |
message = 'error occurred({}) in {}:{}'.format(repr(ex), sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
111 |
sys.exc_info()[-1].tb_lineno) |
|
112 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
104 | 113 |
|
105 | 114 |
''' |
106 | 115 |
@brief key press event |
내보내기 Unified diff