개정판 27f22398
issue #1351: add filter to symbol tree view
Change-Id: Ibc29af225eff0cc994499e0af820b7d17cc426de
DTI_PID/DTI_PID/LibraryItem.py | ||
---|---|---|
93 | 93 |
sys.exc_info()[-1].tb_lineno)) |
94 | 94 |
|
95 | 95 |
def dragEnterEvent(self, event: QDragEnterEvent) -> None: |
96 |
if issubclass(type(event.source()), QTreeWidget) and event.mimeData().hasFormat('text/plain'):
|
|
96 |
if issubclass(type(event.source()), QTreeView) and event.mimeData().hasFormat('text/plain'):
|
|
97 | 97 |
|
98 | 98 |
# check if symbol is already registered |
99 | 99 |
for idx in range(self.layout.count()): |
DTI_PID/DTI_PID/MainWindow.py | ||
---|---|---|
176 | 176 |
self.symbolTreeWidget = SymbolTreeWidget.QSymbolTreeWidget() |
177 | 177 |
self.symbolTreeWidget.header().hide() |
178 | 178 |
self.verticalLayoutSymbolTree.addWidget(self.symbolTreeWidget) |
179 |
self.lineEditFilter.textChanged.connect(self.on_search_text_changed) |
|
179 | 180 |
|
180 | 181 |
from LibraryItem import LibraryItemWidget |
181 | 182 |
self.libraryWidget = LibraryItemWidget(symbol_tree_widget=self.symbolTreeWidget) |
... | ... | |
1398 | 1399 |
def showImageSelectionMessageBox(self): |
1399 | 1400 |
QMessageBox.about(self.graphicsView, self.tr("Notice"), self.tr("First select image drawing")) |
1400 | 1401 |
|
1402 |
def on_search_text_changed(self): |
|
1403 |
"""filter symbol tree view""" |
|
1404 |
regexp = QRegExp(self.lineEditFilter.text(), Qt.CaseInsensitive, QRegExp.FixedString) |
|
1405 |
|
|
1406 |
proxy_model = self.symbolTreeWidget.model() |
|
1407 |
proxy_model.text = self.lineEditFilter.text().lower() |
|
1408 |
proxy_model.setFilterRegExp(regexp) |
|
1409 |
|
|
1410 |
self.symbolTreeWidget.expandAll() |
|
1411 |
|
|
1401 | 1412 |
''' |
1402 | 1413 |
@brief change selected lines' type by selected line type |
1403 | 1414 |
@author humkyung |
... | ... | |
1790 | 1801 |
symbolEditorDialog = SymbolEditorDialog.QSymbolEditorDialog(self, image.copy(x, y, width, height), |
1791 | 1802 |
AppDocData.instance().getCurrentProject()) |
1792 | 1803 |
(isAccepted, isImmediateInsert, offsetX, offsetY, newSym) = symbolEditorDialog.showDialog() |
1793 |
self.symbolTreeWidget.initDirTreeWidget() |
|
1804 |
# TODO: not initialize symbol tree view when user reject to create a new symbol |
|
1805 |
self.symbolTreeWidget.initSymbolTreeView() |
|
1794 | 1806 |
if isAccepted: |
1795 | 1807 |
if isImmediateInsert: |
1796 | 1808 |
svgPath = newSym.getSvgFileFullPath() |
DTI_PID/DTI_PID/MainWindow_UI.py | ||
---|---|---|
1 | 1 |
# -*- coding: utf-8 -*- |
2 | 2 |
|
3 |
# Form implementation generated from reading ui file './UI/MainWindow.ui'
|
|
3 |
# Form implementation generated from reading ui file '.\UI\MainWindow.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_MainWindow(object): |
12 | 14 |
def setupUi(self, MainWindow): |
13 | 15 |
MainWindow.setObjectName("MainWindow") |
... | ... | |
98 | 100 |
self.gridLayout_9.setObjectName("gridLayout_9") |
99 | 101 |
self.horizontalLayout = QtWidgets.QHBoxLayout() |
100 | 102 |
self.horizontalLayout.setObjectName("horizontalLayout") |
103 |
self.lineEditFilter = QtWidgets.QLineEdit(self.Symbol) |
|
104 |
self.lineEditFilter.setObjectName("lineEditFilter") |
|
105 |
self.horizontalLayout.addWidget(self.lineEditFilter) |
|
101 | 106 |
self.pushButtonCreateSymbol = QtWidgets.QPushButton(self.Symbol) |
102 | 107 |
self.pushButtonCreateSymbol.setMaximumSize(QtCore.QSize(32, 16777215)) |
103 | 108 |
self.pushButtonCreateSymbol.setLayoutDirection(QtCore.Qt.LeftToRight) |
104 | 109 |
self.pushButtonCreateSymbol.setObjectName("pushButtonCreateSymbol") |
105 | 110 |
self.horizontalLayout.addWidget(self.pushButtonCreateSymbol) |
106 |
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) |
|
107 |
self.horizontalLayout.addItem(spacerItem) |
|
108 | 111 |
self.pushButtonDetectSymbol = QtWidgets.QPushButton(self.Symbol) |
109 | 112 |
self.pushButtonDetectSymbol.setMaximumSize(QtCore.QSize(130, 16777215)) |
110 | 113 |
self.pushButtonDetectSymbol.setObjectName("pushButtonDetectSymbol") |
... | ... | |
134 | 137 |
self.scrollArea.setWidgetResizable(True) |
135 | 138 |
self.scrollArea.setObjectName("scrollArea") |
136 | 139 |
self.scrollAreaWidgetContents = QtWidgets.QWidget() |
137 |
self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 222, 195))
|
|
140 |
self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 284, 195))
|
|
138 | 141 |
self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents") |
139 | 142 |
self.gridLayout_14 = QtWidgets.QGridLayout(self.scrollAreaWidgetContents) |
140 | 143 |
self.gridLayout_14.setObjectName("gridLayout_14") |
... | ... | |
181 | 184 |
self.verticalLayoutDrawingList.setObjectName("verticalLayoutDrawingList") |
182 | 185 |
self.horizontalLayout_4 = QtWidgets.QHBoxLayout() |
183 | 186 |
self.horizontalLayout_4.setObjectName("horizontalLayout_4") |
184 |
spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
|
|
185 |
self.horizontalLayout_4.addItem(spacerItem1)
|
|
187 |
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) |
|
188 |
self.horizontalLayout_4.addItem(spacerItem) |
|
186 | 189 |
self.pushButtonRefreshDrawings = QtWidgets.QPushButton(self.tabDrawingList) |
187 | 190 |
self.pushButtonRefreshDrawings.setObjectName("pushButtonRefreshDrawings") |
188 | 191 |
self.horizontalLayout_4.addWidget(self.pushButtonRefreshDrawings) |
... | ... | |
231 | 234 |
self.verticalLayout_3.setObjectName("verticalLayout_3") |
232 | 235 |
self.horizontalLayout_5 = QtWidgets.QHBoxLayout() |
233 | 236 |
self.horizontalLayout_5.setObjectName("horizontalLayout_5") |
234 |
spacerItem2 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
|
|
235 |
self.horizontalLayout_5.addItem(spacerItem2)
|
|
237 |
spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
|
|
238 |
self.horizontalLayout_5.addItem(spacerItem1)
|
|
236 | 239 |
self.pushButtonClearLog = QtWidgets.QPushButton(self.tabTerminal) |
237 | 240 |
self.pushButtonClearLog.setEnabled(True) |
238 | 241 |
self.pushButtonClearLog.setMaximumSize(QtCore.QSize(32, 16777215)) |
... | ... | |
673 | 676 |
self.menuHelp.setTitle(_translate("MainWindow", "Help")) |
674 | 677 |
self.toolBar.setWindowTitle(_translate("MainWindow", "Main Toolbar")) |
675 | 678 |
self.dockWidget.setWindowTitle(_translate("MainWindow", "Symbol Explorer")) |
679 |
self.lineEditFilter.setPlaceholderText(_translate("MainWindow", "Search...")) |
|
676 | 680 |
self.pushButtonCreateSymbol.setText(_translate("MainWindow", "Create")) |
677 | 681 |
self.pushButtonDetectSymbol.setText(_translate("MainWindow", "Symbol Manager")) |
678 | 682 |
self.tabWidget.setTabText(self.tabWidget.indexOf(self.Symbol), _translate("MainWindow", "Symbol")) |
... | ... | |
777 | 781 |
self.actionRedo.setText(_translate("MainWindow", "Redo")) |
778 | 782 |
self.actionRedo.setToolTip(_translate("MainWindow", "Redo")) |
779 | 783 |
self.actionSymbol_Replace_Insert.setText(_translate("MainWindow", "Symbol Replace/Insert")) |
780 |
|
|
781 | 784 |
import MainWindow_rc |
782 |
|
|
783 |
if __name__ == "__main__": |
|
784 |
import sys |
|
785 |
app = QtWidgets.QApplication(sys.argv) |
|
786 |
MainWindow = QtWidgets.QMainWindow() |
|
787 |
ui = Ui_MainWindow() |
|
788 |
ui.setupUi(MainWindow) |
|
789 |
MainWindow.show() |
|
790 |
sys.exit(app.exec_()) |
|
791 |
|
DTI_PID/DTI_PID/SymbolPropertyTableWidget.py | ||
---|---|---|
164 | 164 |
''' |
165 | 165 |
def symbolChanged(self): |
166 | 166 |
if self.symData.baseSymbol is not None: |
167 |
#self.setItem(0, 1, QTableWidgetItem(str(self.symData.getId()))) |
|
168 |
#self.setItem(0, 1, QTableWidgetItem(self.symData.getName())) |
|
169 |
#self.setItem(1, 1, QTableWidgetItem(str(int(self.symData.getThreshold() * 100)))) |
|
170 |
#self.setItem(2, 1, QTableWidgetItem(str(self.symData.getMinMatchCount()))) |
|
171 |
|
|
172 | 167 |
Symboldata = QTableWidgetItem(self.symData.getName()) |
173 | 168 |
Symboldata.setFlags(Qt.ItemIsEnabled) |
174 | 169 |
self.setItem(0, 1, Symboldata) |
175 | 170 |
|
176 |
SymbolThreshold = QTableWidgetItem(str(self.symData.getThreshold() *100)) |
|
171 |
SymbolThreshold = QTableWidgetItem(str(self.symData.getThreshold() * 100))
|
|
177 | 172 |
SymbolThreshold.setFlags(Qt.ItemIsEnabled) |
178 | 173 |
self.setItem(1, 1, SymbolThreshold) |
179 | 174 |
|
... | ... | |
188 | 183 |
isContainChildCheckBox.setChecked(True if self.symData.getIsContainChild() == 1 else False) |
189 | 184 |
|
190 | 185 |
symbolTypeComboBox = self.cellWidget(5, 1) |
191 |
symbolTypeComboBox.setCurrentIndex(symbolTypeComboBox.findText(self.symData.getType())) ##### USED FIND TEXT
|
|
186 |
symbolTypeComboBox.setCurrentIndex(symbolTypeComboBox.findText(self.symData.getType())) |
|
192 | 187 |
|
193 | 188 |
baseSymbolComboBox = self.cellWidget(6, 1) |
194 | 189 |
baseSymbolComboBox.clear() |
195 | 190 |
for name in AppDocData.instance().getBaseSymbolComboBoxItems(self.symData.getType()): |
196 | 191 |
baseSymbolComboBox.addItem(name) |
197 |
baseSymbolComboBox.setCurrentIndex(baseSymbolComboBox.findText(self.symData.getBaseSymbol())) ##### USED FIND TEXT
|
|
192 |
baseSymbolComboBox.setCurrentIndex(baseSymbolComboBox.findText(self.symData.getBaseSymbol())) |
|
198 | 193 |
|
199 | 194 |
additionalSymbolItem = QTableWidgetItem(self.symData.getAdditionalSymbol()) |
200 | 195 |
additionalSymbolItem.setFlags(Qt.ItemIsEnabled) |
... | ... | |
215 | 210 |
hasInstrumentLabelCheckBox.setValue(self.symData.getHasInstrumentLabel()) |
216 | 211 |
|
217 | 212 |
else: |
218 |
#self.setItem(0, 1, QTableWidgetItem("")) |
|
219 |
#self.setItem(0, 1, QTableWidgetItem("")) |
|
220 |
#self.setItem(1, 1, QTableWidgetItem("")) |
|
221 |
#self.setItem(2, 1, QTableWidgetItem("")) |
|
222 |
|
|
223 | 213 |
item1 = QTableWidgetItem("") |
224 | 214 |
item1.setFlags(Qt.ItemIsEnabled) |
225 | 215 |
self.setItem(0, 1, item1) |
... | ... | |
232 | 222 |
item3.setFlags(Qt.ItemIsEnabled) |
233 | 223 |
self.setItem(2, 1, item3) |
234 | 224 |
|
235 |
|
|
236 | 225 |
rotationCountSpinBox = self.cellWidget(3, 1) |
237 | 226 |
rotationCountSpinBox.setValue(0) |
238 | 227 |
|
DTI_PID/DTI_PID/SymbolTreeWidget.py | ||
---|---|---|
20 | 20 |
import QSymbolDisplayDialog |
21 | 21 |
|
22 | 22 |
|
23 |
class QSymbolTreeWidget(QTreeWidget): |
|
23 |
class SearchProxyModel(QSortFilterProxyModel): |
|
24 |
def setFilterRegExp(self, pattern): |
|
25 |
if isinstance(pattern, str): |
|
26 |
pattern = QRegExp( pattern, Qt.CaseInsensitive, QRegExp.FixedString) |
|
27 |
super(SearchProxyModel, self).setFilterRegExp(pattern) |
|
28 |
|
|
29 |
def _accept_index(self, idx): |
|
30 |
if idx.isValid(): |
|
31 |
text = idx.data(Qt.DisplayRole) |
|
32 |
if self.filterRegExp().indexIn(text) >= 0: |
|
33 |
return True |
|
34 |
for row in range(idx.model().rowCount(idx)): |
|
35 |
if self._accept_index(idx.model().index(row, 0, idx)): |
|
36 |
return True |
|
37 |
return False |
|
38 |
|
|
39 |
def filterAcceptsRow(self, source_row, source_parent): |
|
40 |
idx = self.sourceModel().index(source_row, 0, source_parent) |
|
41 |
return self._accept_index(idx) |
|
42 |
|
|
43 |
|
|
44 |
class QSymbolTreeWidget(QTreeView): |
|
24 | 45 |
# Add signal |
25 | 46 |
singleClicked = pyqtSignal(SymbolBase.SymbolBase) |
26 | 47 |
symbols_loaded = pyqtSignal([SymbolBase.SymbolBase]) |
27 | 48 |
TREE_DATA_ROLE = Qt.UserRole |
28 | 49 |
|
29 | 50 |
def __init__(self): |
30 |
QTreeWidget.__init__(self)
|
|
51 |
QTreeView.__init__(self)
|
|
31 | 52 |
self.setIconSize(QSize(32, 32)) |
32 | 53 |
|
33 | 54 |
self.setDragEnabled(True) # enable drag |
34 |
self.initDirTreeWidget()
|
|
55 |
self.initSymbolTreeView()
|
|
35 | 56 |
self.isDoubleClicked = False |
36 |
self.itemDoubleClicked.connect(self.itemDoubleClickEvent)
|
|
57 |
self.doubleClicked.connect(self.itemDoubleClickEvent)
|
|
37 | 58 |
self.setContextMenuPolicy(Qt.CustomContextMenu) |
38 | 59 |
self.customContextMenuRequested.connect(self.openContextMenu) |
39 |
self.currentItemChanged.connect(self.onCurrentItemChanged) |
|
40 | 60 |
|
41 | 61 |
@property |
42 | 62 |
def symbols(self): |
... | ... | |
44 | 64 |
res = [] |
45 | 65 |
|
46 | 66 |
try: |
47 |
tree_item_stack = [self.invisibleRootItem()] |
|
67 |
tree_item_stack = [self.model().sourceModel().invisibleRootItem()]
|
|
48 | 68 |
while tree_item_stack: |
49 | 69 |
tree_item = tree_item_stack.pop(0) |
50 |
if tree_item and tree_item.childCount():
|
|
51 |
for idx in range(tree_item.childCount()):
|
|
70 |
if tree_item and tree_item.rowCount():
|
|
71 |
for idx in range(tree_item.rowCount()):
|
|
52 | 72 |
child = tree_item.child(idx) |
53 | 73 |
tree_item_stack.append(child) |
54 |
elif tree_item and tree_item.data(0, Qt.UserRole):
|
|
55 |
if type(tree_item.data(0, Qt.UserRole)) is SymbolBase.SymbolBase:
|
|
56 |
res.append(tree_item.data(0, Qt.UserRole))
|
|
74 |
elif tree_item and tree_item.data(Qt.UserRole): |
|
75 |
if type(tree_item.data(Qt.UserRole)) is SymbolBase.SymbolBase: |
|
76 |
res.append(tree_item.data(Qt.UserRole)) |
|
57 | 77 |
except Exception as ex: |
58 | 78 |
from App import App |
59 | 79 |
|
... | ... | |
63 | 83 |
|
64 | 84 |
return res |
65 | 85 |
|
66 |
''' |
|
67 |
@brief Show Context Menu |
|
68 |
@author Jeongwoo |
|
69 |
@date 18.04.?? |
|
70 |
@history Jeongwoo 2018.04.23 Symbol object Null Check when show context menu |
|
71 |
humkyung 2018.08.14 add menu for symbol type |
|
72 |
''' |
|
73 |
|
|
74 | 86 |
def openContextMenu(self, position): |
75 |
indexes = self.selectedIndexes() |
|
76 |
itemPosition = self.mapTo(self, position) |
|
77 |
item = self.itemAt(itemPosition) |
|
78 |
data = item.data(0, self.TREE_DATA_ROLE) |
|
87 |
"""show context menu""" |
|
88 |
item_position = self.mapTo(self, position) |
|
89 |
index = self.indexAt(item_position) |
|
90 |
item = self.model().sourceModel().itemFromIndex(self.model().mapToSource(index)) |
|
91 |
data = item.data(self.TREE_DATA_ROLE) |
|
79 | 92 |
|
80 | 93 |
advanced = False |
81 | 94 |
app_doc_data = AppDocData.instance() |
... | ... | |
83 | 96 |
if configs and 1 == len(configs) and 'advanced' == configs[0].value: |
84 | 97 |
advanced = True |
85 | 98 |
|
99 |
indexes = self.selectedIndexes() |
|
86 | 100 |
if data is not None and type(data) is symbol.SymbolBase: |
87 | 101 |
sym = self.getSymbolByItemName(item, 0) |
88 | 102 |
text = item.text(0) |
... | ... | |
123 | 137 |
def editDisplaySymbolActionClickEvent(self, item, columNo): |
124 | 138 |
self.showSymbolEditorDialog(item, columNo, True) |
125 | 139 |
|
126 |
''' |
|
127 |
@brief popup attribute editor dialog |
|
128 |
@author humkyung |
|
129 |
@date 2018.08.13 |
|
130 |
''' |
|
131 |
|
|
132 | 140 |
def onEditAttrClicked(self, item, columnNo): |
141 |
"""pop up attribute editor dialog""" |
|
133 | 142 |
from SymbolAttrEditorDialog import QSymbolAttrEditorDialog |
134 | 143 |
|
135 | 144 |
try: |
136 |
data = item.data(0, self.TREE_DATA_ROLE)
|
|
145 |
data = item.data(self.TREE_DATA_ROLE) |
|
137 | 146 |
|
138 | 147 |
dlg = QSymbolAttrEditorDialog(self, data) |
139 | 148 |
dlg.show() |
... | ... | |
141 | 150 |
except Exception as ex: |
142 | 151 |
from App import App |
143 | 152 |
|
144 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
|
|
145 |
sys.exc_info()[-1].tb_lineno)
|
|
153 |
message = f"error occurred({repr(ex)}) in {sys.exc_info()[-1].tb_frame.f_code.co_filename}:" \
|
|
154 |
f"{sys.exc_info()[-1].tb_lineno}"
|
|
146 | 155 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
147 | 156 |
|
148 | 157 |
def displaySymbolActionClickEvent(self, item, columnNo): |
... | ... | |
197 | 206 |
os.remove(svgPath) |
198 | 207 |
|
199 | 208 |
AppDocData.instance().deleteSymbol(itemName) |
200 |
self.initDirTreeWidget()
|
|
209 |
self.initSymbolTreeView()
|
|
201 | 210 |
else: |
202 | 211 |
pass |
203 | 212 |
|
204 |
''' |
|
205 |
@history 2018.05.02 Jeongwoo Change return value of QSymbolEditorDialog (Single variable → Tuple) |
|
206 |
''' |
|
207 |
|
|
208 |
def initDirTreeWidget(self): |
|
213 |
def initSymbolTreeView(self): |
|
214 |
"""initialize symbol tree view""" |
|
209 | 215 |
project = AppDocData.instance().getCurrentProject() |
210 | 216 |
if project is not None: |
211 |
self.clear() |
|
217 |
if self.model(): |
|
218 |
self.model().clear() |
|
212 | 219 |
projectPath = project.getPath().replace("\\", "/") |
213 | 220 |
self.load_symbol_info() |
214 | 221 |
self.expandAll() |
215 | 222 |
|
223 |
self.selectionModel().selectionChanged.connect(self.on_selection_changed) |
|
224 |
|
|
216 | 225 |
def load_symbol_info(self): |
217 |
"""Load Symbol Info and add TreeItem with DB"""
|
|
226 |
"""load symbol information and display it on tree view"""
|
|
218 | 227 |
try: |
219 | 228 |
app_doc_data = AppDocData.instance() |
220 | 229 |
|
230 |
model = QStandardItemModel() |
|
231 |
symbolTypeList = app_doc_data.getSymbolTypeList() |
|
232 |
for row, symbolType in enumerate(symbolTypeList): |
|
233 |
item = QStandardItem(symbolType[2]) |
|
234 |
item.setData(symbolType, self.TREE_DATA_ROLE) |
|
235 |
item.setEditable(False) |
|
236 |
item.setSelectable(False) |
|
237 |
|
|
238 |
symbolList = app_doc_data.getSymbolListByType('UID', symbolType[0]) |
|
239 |
for symbol in symbolList: |
|
240 |
child = QStandardItem(symbol.getName()) |
|
241 |
child.setData(symbol, self.TREE_DATA_ROLE) |
|
242 |
child.setEditable(False) |
|
243 |
|
|
244 |
_, svg = app_doc_data.read_symbol_shape(symbol.sName) |
|
245 |
if svg: |
|
246 |
symbol.pixmap = QPixmap() |
|
247 |
symbol.pixmap.loadFromData(svg if isinstance(svg, bytes) else svg.encode()) |
|
248 |
icon = QIcon(symbol.pixmap) |
|
249 |
child.setIcon(icon) |
|
250 |
child.svgFilePath = None # save svg file path |
|
251 |
else: |
|
252 |
svgPath = symbol.getSvgFileFullPath() |
|
253 |
symbol.pixmap = QPixmap(svgPath) |
|
254 |
icon = QIcon(symbol.pixmap) |
|
255 |
child.setIcon(icon) |
|
256 |
child.svgFilePath = svgPath # save svg file path |
|
257 |
|
|
258 |
item.appendRow(child) |
|
259 |
|
|
260 |
item.sortChildren(0, Qt.AscendingOrder) |
|
261 |
model.appendRow(item) |
|
262 |
|
|
263 |
proxy_model = SearchProxyModel() |
|
264 |
proxy_model.setSourceModel(model) |
|
265 |
proxy_model.setDynamicSortFilter(True) |
|
266 |
proxy_model.setFilterCaseSensitivity(Qt.CaseInsensitive) |
|
267 |
self.setModel(proxy_model) |
|
268 |
|
|
269 |
""" |
|
221 | 270 |
symbolTypeList = app_doc_data.getSymbolTypeList() |
222 | 271 |
for symbolType in symbolTypeList: |
223 | 272 |
if not symbolType[1]: continue # skip if category is empty |
... | ... | |
243 | 292 |
symbolItem.svgFilePath = svgPath # save svg file path |
244 | 293 |
|
245 | 294 |
parent.sortChildren(0, Qt.AscendingOrder) |
246 |
|
|
295 |
""" |
|
247 | 296 |
except Exception as ex: |
248 | 297 |
from App import App |
249 | 298 |
|
... | ... | |
269 | 318 |
AppDocData.instance().getCurrentProject(), |
270 | 319 |
sym, True) |
271 | 320 |
(isAccepted, isImmediateInsert, offsetX, offsetY, newSym) = symbolEditorDialog.showDialog() |
272 |
self.initDirTreeWidget()
|
|
321 |
self.initSymbolTreeView()
|
|
273 | 322 |
elif sym: |
274 | 323 |
# for symbol data and detection image |
275 | 324 |
path = sym.getPath() |
... | ... | |
278 | 327 |
AppDocData.instance().getCurrentProject(), |
279 | 328 |
sym, False) |
280 | 329 |
(isAccepted, isImmediateInsert, offsetX, offsetY, newSym) = symbolEditorDialog.showDialog() |
281 |
self.initDirTreeWidget()
|
|
330 |
self.initSymbolTreeView()
|
|
282 | 331 |
else: |
283 | 332 |
QMessageBox.about(self, self.tr('Error'), self.tr('Error occurs during loading symbol data.')) |
284 | 333 |
except Exception as ex: |
... | ... | |
296 | 345 |
if founds: |
297 | 346 |
self.setCurrentItem(founds[0]) |
298 | 347 |
|
299 |
def itemDoubleClickEvent(self, item, columnNo): |
|
300 |
self.isDoubleClicked = True |
|
301 |
sym = self.getSymbolByItemName(item, columnNo) |
|
302 |
itemName = item.text(columnNo) |
|
303 |
if sym is not None: |
|
304 |
self.showSymbolEditorDialog(item, columnNo) |
|
305 |
self.isDoubleClicked = False |
|
306 |
|
|
307 |
''' |
|
308 |
@brief Get Symbol data by symbol name |
|
309 |
@author Jeongwoo |
|
310 |
@date 18.04.20 |
|
311 |
''' |
|
348 |
def itemDoubleClickEvent(self, index): |
|
349 |
"""pop up symbol editor""" |
|
350 |
item = self.model().sourceModel().itemFromIndex(self.model().mapToSource(index)) |
|
351 |
if item: |
|
352 |
data = item.data(Qt.UserRole) |
|
353 |
if data and type(data) is SymbolBase.SymbolBase: |
|
354 |
sym = self.getSymbolByItemName(item, 0) |
|
355 |
itemName = item.text() |
|
356 |
if sym is not None: |
|
357 |
self.showSymbolEditorDialog(item, 0) |
|
312 | 358 |
|
313 | 359 |
def getSymbolByItemName(self, item, columnNo): |
314 |
itemName = item.text(columnNo) |
|
315 |
|
|
316 |
name = itemName |
|
360 |
"""Get Symbol data by symbol name""" |
|
361 |
name = item.text() |
|
317 | 362 |
sym = AppDocData.instance().getSymbolByQuery("name", name) |
363 |
|
|
318 | 364 |
return sym |
319 | 365 |
|
320 |
''' |
|
321 |
@breif show symbol's property when selection changed |
|
322 |
@author humkyung |
|
323 |
@date 2018.07.30 |
|
324 |
''' |
|
366 |
def on_selection_changed(self, new_selection, old_selection): |
|
367 |
"""show symbol's property when selection changed""" |
|
368 |
|
|
369 |
if new_selection.indexes(): |
|
370 |
proxy_model = self.model() |
|
371 |
item = proxy_model.sourceModel().itemFromIndex(proxy_model.mapToSource(new_selection.indexes()[0])) |
|
372 |
if item is not None: |
|
373 |
data = item.data(self.TREE_DATA_ROLE) |
|
374 |
if data is not None and type(data) is symbol.SymbolBase: |
|
375 |
self.singleClicked.emit(data) |
|
325 | 376 |
|
326 | 377 |
def onCurrentItemChanged(self, current, previous): |
378 |
"""show symbol's property when selection changed""" |
|
327 | 379 |
item = self.currentItem() |
328 | 380 |
if item is not None: |
329 | 381 |
data = item.data(0, self.TREE_DATA_ROLE) |
... | ... | |
333 | 385 |
def startDrag(self, dropAction): |
334 | 386 |
"""start drag""" |
335 | 387 |
try: |
336 |
items = self.selectedItems() |
|
388 |
index = self.currentIndex() |
|
389 |
proxy_model = self.model() |
|
390 |
items = [proxy_model.sourceModel().itemFromIndex(proxy_model.mapToSource(index))] |
|
337 | 391 |
if items and hasattr(items[0], 'svgFilePath'): |
338 |
symData = items[0].data(0, self.TREE_DATA_ROLE)
|
|
392 |
symData = items[0].data(self.TREE_DATA_ROLE) |
|
339 | 393 |
|
340 | 394 |
mime = QMimeData() |
341 | 395 |
mime.setText(symData.getName()) |
DTI_PID/DTI_PID/UI/MainWindow.ui | ||
---|---|---|
246 | 246 |
<item row="0" column="0"> |
247 | 247 |
<layout class="QHBoxLayout" name="horizontalLayout"> |
248 | 248 |
<item> |
249 |
<widget class="QLineEdit" name="lineEditFilter"> |
|
250 |
<property name="placeholderText"> |
|
251 |
<string>Search...</string> |
|
252 |
</property> |
|
253 |
</widget> |
|
254 |
</item> |
|
255 |
<item> |
|
249 | 256 |
<widget class="QPushButton" name="pushButtonCreateSymbol"> |
250 | 257 |
<property name="maximumSize"> |
251 | 258 |
<size> |
... | ... | |
262 | 269 |
</widget> |
263 | 270 |
</item> |
264 | 271 |
<item> |
265 |
<spacer name="horizontalSpacer"> |
|
266 |
<property name="orientation"> |
|
267 |
<enum>Qt::Horizontal</enum> |
|
268 |
</property> |
|
269 |
<property name="sizeHint" stdset="0"> |
|
270 |
<size> |
|
271 |
<width>40</width> |
|
272 |
<height>20</height> |
|
273 |
</size> |
|
274 |
</property> |
|
275 |
</spacer> |
|
276 |
</item> |
|
277 |
<item> |
|
278 | 272 |
<widget class="QPushButton" name="pushButtonDetectSymbol"> |
279 | 273 |
<property name="maximumSize"> |
280 | 274 |
<size> |
... | ... | |
344 | 338 |
<rect> |
345 | 339 |
<x>0</x> |
346 | 340 |
<y>0</y> |
347 |
<width>222</width>
|
|
341 |
<width>284</width>
|
|
348 | 342 |
<height>195</height> |
349 | 343 |
</rect> |
350 | 344 |
</property> |
... | ... | |
1246 | 1240 |
</action> |
1247 | 1241 |
<action name="actionExportAsSVG"> |
1248 | 1242 |
<property name="icon"> |
1249 |
<iconset> |
|
1243 |
<iconset resource="../res/MainWindow.qrc">
|
|
1250 | 1244 |
<normaloff>:/newPrefix/svg.png</normaloff>:/newPrefix/svg.png</iconset> |
1251 | 1245 |
</property> |
1252 | 1246 |
<property name="text"> |
... | ... | |
1273 | 1267 |
</action> |
1274 | 1268 |
<action name="actionRecognizeTable"> |
1275 | 1269 |
<property name="icon"> |
1276 |
<iconset> |
|
1270 |
<iconset resource="../res/MainWindow.qrc">
|
|
1277 | 1271 |
<normaloff>:/newPrefix/table_ocr.png</normaloff>:/newPrefix/table_ocr.png</iconset> |
1278 | 1272 |
</property> |
1279 | 1273 |
<property name="text"> |
내보내기 Unified diff