개정판 7e5c0b5c
add regex
Change-Id: I189ec2dc39fa006c5e14596942fba77775b4c0bb
DTI_PID/DTI_PID/TextItemEditDialog.py | ||
---|---|---|
33 | 33 |
self.ui.checkBoxGlobal.stateChanged.connect(self.checkBoxGlobalChanged) |
34 | 34 |
self.ui.checkBoxMatch.stateChanged.connect(self.checkBoxMatchChanged) |
35 | 35 |
self.ui.checkBoxBroad.stateChanged.connect(self.checkBoxBroadChanged) |
36 |
self.ui.checkBoxExpression.stateChanged.connect(self.checkBoxExpressionChanged) |
|
36 | 37 |
self.ui.pushButtonSetAngle.clicked.connect(self.set_angle_zero) |
37 | 38 |
self.ui.pushButtonSetAngle.setHidden(True) # hide temp function |
38 | 39 |
self.ui.checkBoxBroad.setEnabled(False) |
... | ... | |
92 | 93 |
self.ui.checkBoxGlobal.stateChanged.disconnect(self.checkBoxGlobalChanged) |
93 | 94 |
self.ui.checkBoxMatch.stateChanged.disconnect(self.checkBoxMatchChanged) |
94 | 95 |
self.ui.checkBoxBroad.stateChanged.disconnect(self.checkBoxBroadChanged) |
96 |
self.ui.checkBoxExpression.stateChanged.disconnect(self.checkBoxExpressionChanged) |
|
95 | 97 |
|
96 | 98 |
if checkState is int(Qt.Checked): |
97 | 99 |
self.ui.pushButtonReplaceText.setEnabled(False) |
98 | 100 |
self.ui.lineEditReplaceText.setEnabled(False) |
101 |
self.ui.checkBoxExpression.setEnabled(False) |
|
99 | 102 |
|
100 | 103 |
self.ui.checkBoxSymbol.setCheckState(False) |
101 | 104 |
self.ui.checkBoxBroad.setCheckState(False) |
... | ... | |
105 | 108 |
self.ui.checkBoxMatch.setEnabled(True) |
106 | 109 |
self.ui.checkBoxBroad.setEnabled(False) |
107 | 110 |
else: |
108 |
if not self.ui.checkBoxSymbol.isChecked() and not self.ui.checkBoxGlobal.isChecked():
|
|
111 |
if not self.ui.checkBoxGlobal.isChecked(): |
|
109 | 112 |
self.ui.pushButtonReplaceText.setEnabled(True) |
110 | 113 |
self.ui.lineEditReplaceText.setEnabled(True) |
111 | 114 |
|
... | ... | |
113 | 116 |
self.ui.checkBoxSymbol.setEnabled(True) |
114 | 117 |
if self.ui.checkBoxGlobal.isChecked() and not self.ui.checkBoxMatch.isChecked(): |
115 | 118 |
self.ui.checkBoxBroad.setEnabled(True) |
119 |
if not self.ui.checkBoxGlobal.isChecked() and not self.ui.checkBoxMatch.isChecked(): |
|
120 |
self.ui.checkBoxExpression.setEnabled(True) |
|
116 | 121 |
|
117 | 122 |
self.ui.checkBoxSymbol.stateChanged.connect(self.checkBoxSymbolChanged) |
118 | 123 |
self.ui.checkBoxGlobal.stateChanged.connect(self.checkBoxGlobalChanged) |
119 | 124 |
self.ui.checkBoxMatch.stateChanged.connect(self.checkBoxMatchChanged) |
120 |
self.ui.checkBoxBroad.stateChanged.connect(self.checkBoxBroadChanged) |
|
125 |
self.ui.checkBoxBroad.stateChanged.connect(self.checkBoxBroadChanged) |
|
126 |
self.ui.checkBoxExpression.stateChanged.connect(self.checkBoxExpressionChanged) |
|
121 | 127 |
|
122 | 128 |
def checkBoxSymbolChanged(self, checkState): |
123 | 129 |
self.ui.checkBoxUID.stateChanged.disconnect(self.checkBoxUIDChanged) |
124 | 130 |
self.ui.checkBoxGlobal.stateChanged.disconnect(self.checkBoxGlobalChanged) |
125 | 131 |
self.ui.checkBoxMatch.stateChanged.disconnect(self.checkBoxMatchChanged) |
126 | 132 |
self.ui.checkBoxBroad.stateChanged.disconnect(self.checkBoxBroadChanged) |
133 |
self.ui.checkBoxExpression.stateChanged.disconnect(self.checkBoxExpressionChanged) |
|
127 | 134 |
|
128 | 135 |
if checkState is int(Qt.Checked): |
129 | 136 |
self.ui.pushButtonReplaceText.setEnabled(False) |
130 | 137 |
self.ui.lineEditReplaceText.setEnabled(False) |
138 |
self.ui.checkBoxExpression.setEnabled(False) |
|
131 | 139 |
self.ui.label_2.setText('Symbol : ') |
132 | 140 |
|
133 | 141 |
self.ui.checkBoxUID.setCheckState(False) |
... | ... | |
146 | 154 |
self.ui.checkBoxUID.setEnabled(True) |
147 | 155 |
if not self.ui.checkBoxMatch.isChecked(): |
148 | 156 |
self.ui.checkBoxBroad.setEnabled(True) |
157 |
|
|
158 |
if not self.ui.checkBoxGlobal.isChecked() and not self.ui.checkBoxMatch.isChecked(): |
|
159 |
self.ui.checkBoxExpression.setEnabled(True) |
|
149 | 160 |
|
150 | 161 |
self.ui.checkBoxUID.stateChanged.connect(self.checkBoxUIDChanged) |
151 | 162 |
self.ui.checkBoxGlobal.stateChanged.connect(self.checkBoxGlobalChanged) |
152 | 163 |
self.ui.checkBoxMatch.stateChanged.connect(self.checkBoxMatchChanged) |
153 | 164 |
self.ui.checkBoxBroad.stateChanged.connect(self.checkBoxBroadChanged) |
165 |
self.ui.checkBoxExpression.stateChanged.connect(self.checkBoxExpressionChanged) |
|
154 | 166 |
|
155 | 167 |
def checkBoxGlobalChanged(self, checkState): |
156 | 168 |
self.ui.checkBoxUID.stateChanged.disconnect(self.checkBoxUIDChanged) |
157 | 169 |
self.ui.checkBoxSymbol.stateChanged.disconnect(self.checkBoxSymbolChanged) |
158 | 170 |
self.ui.checkBoxMatch.stateChanged.disconnect(self.checkBoxMatchChanged) |
159 | 171 |
self.ui.checkBoxBroad.stateChanged.disconnect(self.checkBoxBroadChanged) |
172 |
self.ui.checkBoxExpression.stateChanged.disconnect(self.checkBoxExpressionChanged) |
|
160 | 173 |
|
161 | 174 |
if checkState is int(Qt.Checked): |
162 | 175 |
self.ui.pushButtonReplaceText.setEnabled(False) |
163 | 176 |
self.ui.lineEditReplaceText.setEnabled(False) |
177 |
self.ui.checkBoxExpression.setEnabled(False) |
|
164 | 178 |
|
165 | 179 |
if not self.ui.checkBoxSymbol.isChecked() and not self.ui.checkBoxBroad.isChecked(): |
166 | 180 |
self.ui.checkBoxUID.setEnabled(True) |
... | ... | |
178 | 192 |
if self.ui.checkBoxBroad.isChecked(): |
179 | 193 |
self.ui.checkBoxBroad.setCheckState(False) |
180 | 194 |
self.ui.checkBoxBroad.setEnabled(False) |
195 |
self.ui.checkBoxUID.setEnabled(True) |
|
196 |
self.ui.checkBoxSymbol.setEnabled(True) |
|
197 |
self.ui.checkBoxMatch.setEnabled(True) |
|
198 |
|
|
199 |
if not self.ui.checkBoxSymbol.isChecked() and not self.ui.checkBoxUID.isChecked() and not self.ui.checkBoxMatch.isChecked() and not self.ui.checkBoxBroad.isChecked(): |
|
200 |
self.ui.checkBoxExpression.setEnabled(True) |
|
181 | 201 |
|
182 | 202 |
self.ui.checkBoxUID.stateChanged.connect(self.checkBoxUIDChanged) |
183 | 203 |
self.ui.checkBoxSymbol.stateChanged.connect(self.checkBoxSymbolChanged) |
184 | 204 |
self.ui.checkBoxMatch.stateChanged.connect(self.checkBoxMatchChanged) |
185 | 205 |
self.ui.checkBoxBroad.stateChanged.connect(self.checkBoxBroadChanged) |
206 |
self.ui.checkBoxExpression.stateChanged.connect(self.checkBoxExpressionChanged) |
|
186 | 207 |
|
187 | 208 |
def checkBoxMatchChanged(self, checkState): |
188 | 209 |
self.ui.checkBoxUID.stateChanged.disconnect(self.checkBoxUIDChanged) |
189 | 210 |
self.ui.checkBoxSymbol.stateChanged.disconnect(self.checkBoxSymbolChanged) |
190 | 211 |
self.ui.checkBoxGlobal.stateChanged.disconnect(self.checkBoxGlobalChanged) |
191 | 212 |
self.ui.checkBoxBroad.stateChanged.disconnect(self.checkBoxBroadChanged) |
213 |
self.ui.checkBoxExpression.stateChanged.disconnect(self.checkBoxExpressionChanged) |
|
192 | 214 |
|
193 | 215 |
if checkState is int(Qt.Checked): |
194 | 216 |
self.ui.checkBoxBroad.setCheckState(False) |
195 | 217 |
self.ui.checkBoxBroad.setEnabled(False) |
196 |
elif not self.ui.checkBoxSymbol.isChecked() and not self.ui.checkBoxUID.isChecked() and self.ui.checkBoxGlobal.isChecked(): |
|
197 |
self.ui.checkBoxBroad.setEnabled(True) |
|
218 |
self.ui.checkBoxExpression.setEnabled(False) |
|
219 |
else: |
|
220 |
if not self.ui.checkBoxSymbol.isChecked() and not self.ui.checkBoxUID.isChecked() and self.ui.checkBoxGlobal.isChecked(): |
|
221 |
self.ui.checkBoxBroad.setEnabled(True) |
|
222 |
|
|
223 |
if not self.ui.checkBoxSymbol.isChecked() and not self.ui.checkBoxUID.isChecked() and not self.ui.checkBoxGlobal.isChecked(): |
|
224 |
self.ui.checkBoxExpression.setEnabled(True) |
|
198 | 225 |
|
199 | 226 |
self.ui.checkBoxUID.stateChanged.connect(self.checkBoxUIDChanged) |
200 | 227 |
self.ui.checkBoxSymbol.stateChanged.connect(self.checkBoxSymbolChanged) |
201 | 228 |
self.ui.checkBoxGlobal.stateChanged.connect(self.checkBoxGlobalChanged) |
202 | 229 |
self.ui.checkBoxBroad.stateChanged.connect(self.checkBoxBroadChanged) |
230 |
self.ui.checkBoxExpression.stateChanged.connect(self.checkBoxExpressionChanged) |
|
203 | 231 |
|
204 | 232 |
def checkBoxBroadChanged(self, checkState): |
205 | 233 |
self.ui.checkBoxUID.stateChanged.disconnect(self.checkBoxUIDChanged) |
206 | 234 |
self.ui.checkBoxSymbol.stateChanged.disconnect(self.checkBoxSymbolChanged) |
207 | 235 |
self.ui.checkBoxGlobal.stateChanged.disconnect(self.checkBoxGlobalChanged) |
208 | 236 |
self.ui.checkBoxMatch.stateChanged.disconnect(self.checkBoxMatchChanged) |
237 |
self.ui.checkBoxExpression.stateChanged.disconnect(self.checkBoxExpressionChanged) |
|
209 | 238 |
|
210 | 239 |
if checkState is int(Qt.Checked): |
211 | 240 |
self.ui.checkBoxUID.setCheckState(False) |
212 | 241 |
self.ui.checkBoxMatch.setCheckState(False) |
213 | 242 |
self.ui.checkBoxSymbol.setCheckState(False) |
243 |
self.ui.checkBoxExpression.setEnabled(False) |
|
214 | 244 |
|
215 | 245 |
self.ui.checkBoxUID.setEnabled(False) |
216 | 246 |
self.ui.checkBoxSymbol.setEnabled(False) |
... | ... | |
219 | 249 |
self.ui.checkBoxUID.setEnabled(True) |
220 | 250 |
self.ui.checkBoxSymbol.setEnabled(True) |
221 | 251 |
self.ui.checkBoxMatch.setEnabled(True) |
252 |
|
|
253 |
if not self.ui.checkBoxGlobal.isChecked(): |
|
254 |
self.ui.checkBoxExpression.setEnabled(True) |
|
255 |
|
|
256 |
self.ui.checkBoxUID.stateChanged.connect(self.checkBoxUIDChanged) |
|
257 |
self.ui.checkBoxSymbol.stateChanged.connect(self.checkBoxSymbolChanged) |
|
258 |
self.ui.checkBoxGlobal.stateChanged.connect(self.checkBoxGlobalChanged) |
|
259 |
self.ui.checkBoxMatch.stateChanged.connect(self.checkBoxMatchChanged) |
|
260 |
self.ui.checkBoxExpression.stateChanged.connect(self.checkBoxExpressionChanged) |
|
261 |
|
|
262 |
def checkBoxExpressionChanged(self, checkState): |
|
263 |
self.ui.checkBoxUID.stateChanged.disconnect(self.checkBoxUIDChanged) |
|
264 |
self.ui.checkBoxSymbol.stateChanged.disconnect(self.checkBoxSymbolChanged) |
|
265 |
self.ui.checkBoxGlobal.stateChanged.disconnect(self.checkBoxGlobalChanged) |
|
266 |
self.ui.checkBoxMatch.stateChanged.disconnect(self.checkBoxMatchChanged) |
|
267 |
self.ui.checkBoxBroad.stateChanged.disconnect(self.checkBoxBroadChanged) |
|
268 |
|
|
269 |
if checkState is int(Qt.Checked): |
|
270 |
self.ui.checkBoxUID.setEnabled(False) |
|
271 |
self.ui.checkBoxMatch.setEnabled(False) |
|
272 |
self.ui.checkBoxSymbol.setEnabled(False) |
|
273 |
self.ui.checkBoxGlobal.setEnabled(False) |
|
274 |
else: |
|
275 |
self.ui.checkBoxUID.setEnabled(True) |
|
276 |
self.ui.checkBoxMatch.setEnabled(True) |
|
277 |
self.ui.checkBoxSymbol.setEnabled(True) |
|
278 |
self.ui.checkBoxGlobal.setEnabled(True) |
|
222 | 279 |
|
223 | 280 |
self.ui.checkBoxUID.stateChanged.connect(self.checkBoxUIDChanged) |
224 | 281 |
self.ui.checkBoxSymbol.stateChanged.connect(self.checkBoxSymbolChanged) |
225 | 282 |
self.ui.checkBoxGlobal.stateChanged.connect(self.checkBoxGlobalChanged) |
226 | 283 |
self.ui.checkBoxMatch.stateChanged.connect(self.checkBoxMatchChanged) |
284 |
self.ui.checkBoxBroad.stateChanged.connect(self.checkBoxBroadChanged) |
|
227 | 285 |
|
228 | 286 |
def find_symbol_global(self): |
229 | 287 |
try: |
... | ... | |
320 | 378 |
def find_text(self): |
321 | 379 |
"""find user input text""" |
322 | 380 |
|
381 |
import re |
|
382 |
|
|
323 | 383 |
self.ui.tableViewResult.setModel(None) |
324 | 384 |
|
325 | 385 |
text = self.ui.lineEditFindText.text() |
... | ... | |
330 | 390 |
if self.ui.checkBoxUID.isChecked(): |
331 | 391 |
text_items = [item for item in self.mainWindow.graphicsView.scene().items() |
332 | 392 |
if hasattr(item, 'uid') and (str(item.uid).upper().count(text.upper()) if not self.ui.checkBoxMatch.isChecked() else str(item.uid).upper() == text.upper())] |
393 |
elif self.ui.checkBoxExpression.isChecked(): |
|
394 |
text_items = [item for item in self.mainWindow.graphicsView.scene().items() if issubclass(type(item), QEngineeringTextItem) and re.search(text, item.text(), re.DOTALL)] |
|
333 | 395 |
else: |
334 | 396 |
if not self.ui.checkBoxSymbol.isChecked(): |
335 | 397 |
if text.upper() == 'LINE NO': |
... | ... | |
393 | 455 |
for row in range(model.rowCount()): |
394 | 456 |
item = self.ui.tableViewResult.model().item(row, 0) |
395 | 457 |
data = item.data() |
396 |
if data and data.text() != replace: |
|
397 |
text = data.text() |
|
398 |
messages.append(f"replaced: {text} --> {text.replace(text_find, replace)}") |
|
399 |
data.setPlainText(text.replace(text_find, replace)) |
|
458 |
text = data.text() |
|
459 |
|
|
460 |
if type(data) is not QEngineeringTextItem: |
|
461 |
messages.append(f"{text} can not be replaced. {type(data)}") |
|
462 |
continue |
|
463 |
|
|
464 |
if data and text != replace: |
|
465 |
newText = '' |
|
466 |
if not self.ui.checkBoxExpression.isChecked(): |
|
467 |
newText = text.replace(text_find, replace) |
|
468 |
data.setPlainText(newText) |
|
469 |
else: |
|
470 |
newText = data.try_eval(data, replace) |
|
471 |
data.setPlainText(newText) |
|
472 |
messages.append(f"replaced: {text} --> {newText}") |
|
473 |
|
|
400 | 474 |
if not data.text(): |
401 | 475 |
data.transfer.onRemoved.emit(data) |
476 |
else: |
|
477 |
data.update_font() |
|
402 | 478 |
|
403 | 479 |
if messages: |
404 | 480 |
QMessageBox.information(self, self.tr('Information'), '\r\n'.join(messages)) |
DTI_PID/DTI_PID/TextItemEdit_UI.py | ||
---|---|---|
14 | 14 |
class Ui_TextItemEditDialog(object): |
15 | 15 |
def setupUi(self, TextItemEditDialog): |
16 | 16 |
TextItemEditDialog.setObjectName("TextItemEditDialog") |
17 |
TextItemEditDialog.resize(487, 223)
|
|
17 |
TextItemEditDialog.resize(580, 228)
|
|
18 | 18 |
TextItemEditDialog.setSizeGripEnabled(True) |
19 | 19 |
TextItemEditDialog.setModal(False) |
20 | 20 |
self.gridLayout = QtWidgets.QGridLayout(TextItemEditDialog) |
... | ... | |
67 | 67 |
self.checkBoxBroad = QtWidgets.QCheckBox(TextItemEditDialog) |
68 | 68 |
self.checkBoxBroad.setObjectName("checkBoxBroad") |
69 | 69 |
self.horizontalLayout.addWidget(self.checkBoxBroad) |
70 |
self.checkBoxExpression = QtWidgets.QCheckBox(TextItemEditDialog) |
|
71 |
self.checkBoxExpression.setObjectName("checkBoxExpression") |
|
72 |
self.horizontalLayout.addWidget(self.checkBoxExpression) |
|
70 | 73 |
self.buttonBox = QtWidgets.QDialogButtonBox(TextItemEditDialog) |
71 | 74 |
self.buttonBox.setOrientation(QtCore.Qt.Horizontal) |
72 | 75 |
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Close) |
... | ... | |
78 | 81 |
self.buttonBox.accepted.connect(TextItemEditDialog.accept) |
79 | 82 |
self.buttonBox.rejected.connect(TextItemEditDialog.reject) |
80 | 83 |
QtCore.QMetaObject.connectSlotsByName(TextItemEditDialog) |
84 |
TextItemEditDialog.setTabOrder(self.lineEditFindText, self.lineEditReplaceText) |
|
85 |
TextItemEditDialog.setTabOrder(self.lineEditReplaceText, self.pushButtonFindText) |
|
86 |
TextItemEditDialog.setTabOrder(self.pushButtonFindText, self.pushButtonReplaceText) |
|
87 |
TextItemEditDialog.setTabOrder(self.pushButtonReplaceText, self.tableViewResult) |
|
88 |
TextItemEditDialog.setTabOrder(self.tableViewResult, self.checkBoxSymbol) |
|
89 |
TextItemEditDialog.setTabOrder(self.checkBoxSymbol, self.checkBoxGlobal) |
|
90 |
TextItemEditDialog.setTabOrder(self.checkBoxGlobal, self.checkBoxMatch) |
|
91 |
TextItemEditDialog.setTabOrder(self.checkBoxMatch, self.checkBoxBroad) |
|
92 |
TextItemEditDialog.setTabOrder(self.checkBoxBroad, self.checkBoxExpression) |
|
93 |
TextItemEditDialog.setTabOrder(self.checkBoxExpression, self.pushButtonSetAngle) |
|
81 | 94 |
|
82 | 95 |
def retranslateUi(self, TextItemEditDialog): |
83 | 96 |
_translate = QtCore.QCoreApplication.translate |
... | ... | |
92 | 105 |
self.checkBoxGlobal.setText(_translate("TextItemEditDialog", "Global")) |
93 | 106 |
self.checkBoxMatch.setText(_translate("TextItemEditDialog", "Match")) |
94 | 107 |
self.checkBoxBroad.setText(_translate("TextItemEditDialog", "Broad")) |
108 |
self.checkBoxExpression.setText(_translate("TextItemEditDialog", "Expression")) |
|
95 | 109 |
import MainWindow_rc |
96 | 110 |
|
97 | 111 |
|
DTI_PID/DTI_PID/UI/TextItemEdit.ui | ||
---|---|---|
6 | 6 |
<rect> |
7 | 7 |
<x>0</x> |
8 | 8 |
<y>0</y> |
9 |
<width>487</width>
|
|
10 |
<height>223</height>
|
|
9 |
<width>580</width>
|
|
10 |
<height>228</height>
|
|
11 | 11 |
</rect> |
12 | 12 |
</property> |
13 | 13 |
<property name="windowTitle"> |
... | ... | |
119 | 119 |
</widget> |
120 | 120 |
</item> |
121 | 121 |
<item> |
122 |
<widget class="QCheckBox" name="checkBoxExpression"> |
|
123 |
<property name="text"> |
|
124 |
<string>Expression</string> |
|
125 |
</property> |
|
126 |
</widget> |
|
127 |
</item> |
|
128 |
<item> |
|
122 | 129 |
<widget class="QDialogButtonBox" name="buttonBox"> |
123 | 130 |
<property name="orientation"> |
124 | 131 |
<enum>Qt::Horizontal</enum> |
... | ... | |
132 | 139 |
</item> |
133 | 140 |
</layout> |
134 | 141 |
</widget> |
142 |
<tabstops> |
|
143 |
<tabstop>lineEditFindText</tabstop> |
|
144 |
<tabstop>lineEditReplaceText</tabstop> |
|
145 |
<tabstop>pushButtonFindText</tabstop> |
|
146 |
<tabstop>pushButtonReplaceText</tabstop> |
|
147 |
<tabstop>tableViewResult</tabstop> |
|
148 |
<tabstop>checkBoxSymbol</tabstop> |
|
149 |
<tabstop>checkBoxGlobal</tabstop> |
|
150 |
<tabstop>checkBoxMatch</tabstop> |
|
151 |
<tabstop>checkBoxBroad</tabstop> |
|
152 |
<tabstop>checkBoxExpression</tabstop> |
|
153 |
<tabstop>pushButtonSetAngle</tabstop> |
|
154 |
</tabstops> |
|
135 | 155 |
<resources> |
136 | 156 |
<include location="../res/MainWindow.qrc"/> |
137 | 157 |
</resources> |
내보내기 Unified diff