개정판 7a88517f
issue #477: 심볼 카테고리 필터 기능을 지원한다
Change-Id: I2be3846a11d6f74537e8f9762c20aa3906acf418
DTI_PID/DTI_PID/SymbolEditorDialog.py | ||
---|---|---|
25 | 25 |
from Area import Area |
26 | 26 |
|
27 | 27 |
|
28 |
class SearchProxyModel(QSortFilterProxyModel): |
|
29 |
def setFilterRegExp(self, pattern): |
|
30 |
if isinstance(pattern, str): |
|
31 |
pattern = QtCore.QRegExp( pattern, QtCore.Qt.CaseInsensitive, QtCore.QRegExp.FixedString) |
|
32 |
super(SearchProxyModel, self).setFilterRegExp(pattern) |
|
33 |
|
|
34 |
def _accept_index(self, idx): |
|
35 |
if idx.isValid(): |
|
36 |
text = idx.data(QtCore.Qt.DisplayRole) |
|
37 |
if self.filterRegExp().indexIn(text) >= 0: |
|
38 |
return True |
|
39 |
for row in range(idx.model().rowCount(idx)): |
|
40 |
if self._accept_index(idx.model().index(row, 0, idx)): |
|
41 |
return True |
|
42 |
return False |
|
43 |
|
|
44 |
def filterAcceptsRow(self, source_row, source_parent): |
|
45 |
idx = self.sourceModel().index(source_row, 0, source_parent) |
|
46 |
return self._accept_index(idx) |
|
47 |
|
|
48 |
|
|
28 | 49 |
class QSymbolEditorDialog(QDialog): |
29 | 50 |
""" This is symbol editor dialog """ |
30 | 51 |
|
... | ... | |
49 | 70 |
self.project = project |
50 | 71 |
self.ui = SymbolEditor_UI.Ui_Dialog() |
51 | 72 |
self.ui.setupUi(self) |
73 |
self.ui.lineEditFilter.textChanged.connect(self.on_search_text_changed) |
|
52 | 74 |
self.ui.tableWidgetConnList.setColumnCount(6) |
53 | 75 |
self.ui.tableWidgetConnList.setHorizontalHeaderLabels( |
54 | 76 |
[self.tr('Position'), self.tr('Direction'), self.tr('Symbol'), self.tr('In_out'), self.tr('Break'), |
... | ... | |
227 | 249 |
symbol.parentSymbol = newBase |
228 | 250 |
symbol.childSymbol = newAddition |
229 | 251 |
|
252 |
def on_search_text_changed(self): |
|
253 |
"""filter category tree view""" |
|
254 |
regexp = QRegExp(self.ui.lineEditFilter.text(), Qt.CaseInsensitive, QRegExp.FixedString) |
|
255 |
|
|
256 |
proxy_model = self.ui.treeViewSymbolCategory.model() |
|
257 |
proxy_model.text = self.ui.lineEditFilter.text().lower() |
|
258 |
proxy_model.setFilterRegExp(regexp) |
|
259 |
|
|
260 |
if len(self.ui.lineEditFilter.text()) >= 1 and proxy_model.rowCount() > 0: |
|
261 |
self.ui.treeViewSymbolCategory.expandAll() |
|
262 |
else: |
|
263 |
self.ui.treeViewSymbolCategory.collapseAll() |
|
264 |
|
|
230 | 265 |
''' |
231 | 266 |
@brief hilight pressed connector item |
232 | 267 |
@author humkyung |
... | ... | |
321 | 356 |
''' |
322 | 357 |
@brief Init Forms with type and default values |
323 | 358 |
''' |
359 |
|
|
324 | 360 |
def initForms(self): |
325 | 361 |
self.ui.minMatchPointLineEdit.setValidator(QRegExpValidator(QtCore.QRegExp("^[0-9]\d+$"))) |
326 | 362 |
self.initDefaultSymbolDirectionComboBoxItems() |
... | ... | |
346 | 382 |
if hoberIndex is not -1: |
347 | 383 |
self.ui.comboBoxHoverColor.setCurrentIndex(hoberIndex) |
348 | 384 |
|
349 |
# old color setting not used |
|
350 |
self.ui.comboBoxNormalColor.setHidden(True) |
|
351 |
self.ui.comboBoxHoverColor.setHidden(True) |
|
352 |
self.ui.label.setHidden(True) |
|
353 |
self.ui.label_2.setHidden(True) |
|
354 |
|
|
355 |
''' |
|
356 |
@brief Init Symbol Type ComboBox Items |
|
357 |
@author Jeongwoo |
|
358 |
@date 2018.04.06 |
|
359 |
''' |
|
360 | 385 |
def initSymbolTypeComboBoxItems(self): |
386 |
"""init symbol type comobox items""" |
|
361 | 387 |
app_doc_data = AppDocData.instance() |
362 | 388 |
|
363 | 389 |
model = QStandardItemModel() |
... | ... | |
375 | 401 |
|
376 | 402 |
model.setHeaderData(0, Qt.Horizontal, 'Category', Qt.DisplayRole) |
377 | 403 |
|
378 |
""" |
|
379 |
view = QTreeView(self) |
|
380 |
view.setEditTriggers(view.NoEditTriggers) |
|
381 |
view.setAlternatingRowColors(True) |
|
382 |
view.setSelectionBehavior(view.SelectRows) |
|
383 |
view.setWordWrap(True) |
|
384 |
view.setAllColumnsShowFocus(True) |
|
385 |
self.ui.typeComboBox.setModel(model) |
|
386 |
self.ui.typeComboBox.setView(view) |
|
387 |
view.expandAll() |
|
388 |
""" |
|
389 |
|
|
390 |
self.ui.treeViewSymbolCategory.setModel(model) |
|
391 |
|
|
392 |
""" |
|
393 |
for row in range(model.rowCount()): |
|
394 |
for col in range(model.columnCount()): |
|
395 |
item = model.item(row, col) |
|
396 |
item.child(0, 0) |
|
397 |
if item.text() == 'BL Line': |
|
398 |
index = model.indexFromItem(item) |
|
399 |
self.ui.treeViewSymbolCategory.expand(index) |
|
400 |
self.ui.treeViewSymbolCategory.selectionModel().select(index, QItemSelectionModel.Rows | QItemSelectionModel.Select) |
|
401 |
""" |
|
402 |
|
|
403 |
""" |
|
404 |
for item in AppDocData.instance().getSymbolTypeComboBoxItems(): |
|
405 |
self.ui.typeComboBox.addItem(item[2]) |
|
406 |
self.ui.typeComboBox.currentTextChanged.connect(self.symbolTypeTextChagedEvent) |
|
407 |
""" |
|
404 |
proxy_model = SearchProxyModel() |
|
405 |
proxy_model.setSourceModel(model) |
|
406 |
proxy_model.setDynamicSortFilter(True) |
|
407 |
proxy_model.setFilterCaseSensitivity(Qt.CaseInsensitive) |
|
408 |
self.ui.treeViewSymbolCategory.setModel(proxy_model) |
|
408 | 409 |
|
409 | 410 |
''' |
410 | 411 |
@brief Set data on forms, For modifying symbol |
... | ... | |
423 | 424 |
self.ui.rotationCountSpinBox.setValue(self.selectedSymbol.getRotationCount() * 90) |
424 | 425 |
self.ui.isContainChildCheckBox.setChecked(True if self.selectedSymbol.getIsContainChild() else False) |
425 | 426 |
|
426 |
category = self.ui.treeViewSymbolCategory.model().findItems(self.selectedSymbol.getType(), |
|
427 |
Qt.MatchExactly) |
|
427 |
category = self.ui.treeViewSymbolCategory.model().sourceModel().findItems(self.selectedSymbol.getType(),
|
|
428 |
Qt.MatchExactly)
|
|
428 | 429 |
if category: |
429 |
index = self.ui.treeViewSymbolCategory.model().indexFromItem(category[0]) |
|
430 |
self.ui.treeViewSymbolCategory.expand(index) |
|
430 |
proxy_model = self.ui.treeViewSymbolCategory.model() |
|
431 |
index = proxy_model.sourceModel().indexFromItem(category[0]) |
|
432 |
self.ui.treeViewSymbolCategory.expand(proxy_model.mapFromSource(index)) |
|
431 | 433 |
for row in range(category[0].rowCount()): |
432 | 434 |
child = category[0].child(row) |
433 | 435 |
if child.text() == self.selectedSymbol.getBaseSymbol(): |
434 |
index = self.ui.treeViewSymbolCategory.model().indexFromItem(child) |
|
435 |
self.ui.treeViewSymbolCategory.setCurrentIndex(index) |
|
436 |
|
|
437 |
""" |
|
438 |
self.ui.typeComboBox.setCurrentIndex(self.ui.typeComboBox.findText(self.selectedSymbol.getType())) |
|
439 |
self.ui.baseSymbolComboBox.setCurrentIndex( |
|
440 |
self.ui.baseSymbolComboBox.findText(self.selectedSymbol.getBaseSymbol())) |
|
441 |
""" |
|
436 |
index = self.ui.treeViewSymbolCategory.model().sourceModel().indexFromItem(child) |
|
437 |
self.ui.treeViewSymbolCategory.setCurrentIndex(proxy_model.mapFromSource(index)) |
|
442 | 438 |
|
443 | 439 |
self.ui.isExceptDetectCheckBox.setChecked(True if self.selectedSymbol.getIsExceptDetect() else False) |
444 | 440 |
self.ui.makeFlipCheckBox.setChecked(True if self.selectedSymbol.getDetectFlip() else False) |
... | ... | |
638 | 634 |
# symId = self.ui.idLineEdit.text() |
639 | 635 |
name = self.ui.nameLineEdit.text() |
640 | 636 |
|
637 |
proxy_model = self.ui.treeViewSymbolCategory.model() |
|
641 | 638 |
index = self.ui.treeViewSymbolCategory.currentIndex() |
642 |
item = self.ui.treeViewSymbolCategory.model().itemFromIndex(index)
|
|
639 |
item = proxy_model.sourceModel().itemFromIndex(proxy_model.mapToSource(index))
|
|
643 | 640 |
if item: |
644 | 641 |
category = item.parent().text() |
645 | 642 |
self.FILE_NUMBER = 0 |
DTI_PID/DTI_PID/SymbolEditor_UI.py | ||
---|---|---|
1 | 1 |
# -*- coding: utf-8 -*- |
2 | 2 |
|
3 |
# Form implementation generated from reading ui file './UI/SymbolEditor.ui'
|
|
3 |
# Form implementation generated from reading ui file '.\UI\SymbolEditor.ui'
|
|
4 | 4 |
# |
5 |
# Created by: PyQt5 UI code generator 5.11.3
|
|
5 |
# Created by: PyQt5 UI code generator 5.14.2
|
|
6 | 6 |
# |
7 | 7 |
# WARNING! All changes made in this file will be lost! |
8 | 8 |
|
9 |
|
|
9 | 10 |
from PyQt5 import QtCore, QtGui, QtWidgets |
10 | 11 |
|
12 |
|
|
11 | 13 |
class Ui_Dialog(object): |
12 | 14 |
def setupUi(self, Dialog): |
13 | 15 |
Dialog.setObjectName("Dialog") |
... | ... | |
348 | 350 |
self.groupBox.setObjectName("groupBox") |
349 | 351 |
self.gridLayout_8 = QtWidgets.QGridLayout(self.groupBox) |
350 | 352 |
self.gridLayout_8.setObjectName("gridLayout_8") |
351 |
self.horizontalLayout_2 = QtWidgets.QHBoxLayout() |
|
352 |
self.horizontalLayout_2.setObjectName("horizontalLayout_2") |
|
353 |
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) |
|
354 |
self.horizontalLayout_2.addItem(spacerItem) |
|
355 |
self.lineEditSearch = QtWidgets.QLineEdit(self.groupBox) |
|
356 |
self.lineEditSearch.setObjectName("lineEditSearch") |
|
357 |
self.horizontalLayout_2.addWidget(self.lineEditSearch) |
|
358 |
self.pushButtonSearch = QtWidgets.QPushButton(self.groupBox) |
|
359 |
self.pushButtonSearch.setObjectName("pushButtonSearch") |
|
360 |
self.horizontalLayout_2.addWidget(self.pushButtonSearch) |
|
361 |
self.gridLayout_8.addLayout(self.horizontalLayout_2, 0, 0, 1, 1) |
|
362 | 353 |
self.treeViewSymbolCategory = QtWidgets.QTreeView(self.groupBox) |
363 | 354 |
self.treeViewSymbolCategory.setObjectName("treeViewSymbolCategory") |
364 |
self.gridLayout_8.addWidget(self.treeViewSymbolCategory, 4, 0, 1, 1) |
|
355 |
self.gridLayout_8.addWidget(self.treeViewSymbolCategory, 1, 0, 1, 1) |
|
356 |
self.lineEditFilter = QtWidgets.QLineEdit(self.groupBox) |
|
357 |
self.lineEditFilter.setObjectName("lineEditFilter") |
|
358 |
self.gridLayout_8.addWidget(self.lineEditFilter, 0, 0, 1, 1) |
|
365 | 359 |
self.gridLayout_7.addWidget(self.groupBox, 5, 0, 1, 4) |
366 | 360 |
self.immediateInsertLabel = QtWidgets.QLabel(self.scrollAreaWidgetContents) |
367 | 361 |
font = QtGui.QFont() |
... | ... | |
637 | 631 |
self.label.setText(_translate("Dialog", "Normal Color :")) |
638 | 632 |
self.label_2.setText(_translate("Dialog", "Highlight Color :")) |
639 | 633 |
self.groupBox.setTitle(_translate("Dialog", "Base Symbol")) |
640 |
self.pushButtonSearch.setText(_translate("Dialog", "Search"))
|
|
634 |
self.lineEditFilter.setPlaceholderText(_translate("Dialog", "Search..."))
|
|
641 | 635 |
self.immediateInsertLabel.setText(_translate("Dialog", "Insert Symbol When Create")) |
642 | 636 |
self.additionalSymbolLabel.setText(_translate("Dialog", "Addition Symbol")) |
643 | 637 |
self.hasInstrumentLabel.setText(_translate("Dialog", "Include Text")) |
... | ... | |
660 | 654 |
self.isExceptDetectLabel.setText(_translate("Dialog", "Exclude")) |
661 | 655 |
self.addAdditionalSymbolButton.setText(_translate("Dialog", "Add")) |
662 | 656 |
self.label_5.setText(_translate("Dialog", "Text Area")) |
663 |
|
|
664 | 657 |
import MainWindow_rc |
665 |
|
|
666 |
if __name__ == "__main__": |
|
667 |
import sys |
|
668 |
app = QtWidgets.QApplication(sys.argv) |
|
669 |
Dialog = QtWidgets.QDialog() |
|
670 |
ui = Ui_Dialog() |
|
671 |
ui.setupUi(Dialog) |
|
672 |
Dialog.show() |
|
673 |
sys.exit(app.exec_()) |
|
674 |
|
DTI_PID/DTI_PID/UI/SymbolEditor.ui | ||
---|---|---|
757 | 757 |
<string>Base Symbol</string> |
758 | 758 |
</property> |
759 | 759 |
<layout class="QGridLayout" name="gridLayout_8"> |
760 |
<item row="0" column="0"> |
|
761 |
<layout class="QHBoxLayout" name="horizontalLayout_2"> |
|
762 |
<item> |
|
763 |
<spacer name="horizontalSpacer"> |
|
764 |
<property name="orientation"> |
|
765 |
<enum>Qt::Horizontal</enum> |
|
766 |
</property> |
|
767 |
<property name="sizeHint" stdset="0"> |
|
768 |
<size> |
|
769 |
<width>40</width> |
|
770 |
<height>20</height> |
|
771 |
</size> |
|
772 |
</property> |
|
773 |
</spacer> |
|
774 |
</item> |
|
775 |
<item> |
|
776 |
<widget class="QLineEdit" name="lineEditSearch"/> |
|
777 |
</item> |
|
778 |
<item> |
|
779 |
<widget class="QPushButton" name="pushButtonSearch"> |
|
780 |
<property name="text"> |
|
781 |
<string>Search</string> |
|
782 |
</property> |
|
783 |
</widget> |
|
784 |
</item> |
|
785 |
</layout> |
|
786 |
</item> |
|
787 |
<item row="4" column="0"> |
|
760 |
<item row="1" column="0"> |
|
788 | 761 |
<widget class="QTreeView" name="treeViewSymbolCategory"/> |
789 | 762 |
</item> |
763 |
<item row="0" column="0"> |
|
764 |
<widget class="QLineEdit" name="lineEditFilter"> |
|
765 |
<property name="placeholderText"> |
|
766 |
<string>Search...</string> |
|
767 |
</property> |
|
768 |
</widget> |
|
769 |
</item> |
|
790 | 770 |
</layout> |
791 | 771 |
</widget> |
792 | 772 |
</item> |
내보내기 Unified diff