개정판 ed2b4ab0
QDirTreeWidget에 출력되는 심볼을 디렉터리 기준에서 DB 기준으로 변경/드래그 시 각 심볼이 적용되게끔 수정
DTI_PID/DTI_PID/AppDocData.py | ||
---|---|---|
609 | 609 |
finally: |
610 | 610 |
conn.close() |
611 | 611 |
return (ret, fileName) |
612 |
|
|
612 |
|
|
613 | 613 |
''' |
614 |
@brief get symbol name list
|
|
614 |
@brief get symbol name |
|
615 | 615 |
''' |
616 | 616 |
def getSymbolByQuery(self, fieldName, param): |
617 | 617 |
ret = None |
... | ... | |
640 | 640 |
return ret |
641 | 641 |
|
642 | 642 |
''' |
643 |
@brief get symbol name list |
|
644 |
''' |
|
645 |
def getSymbolListByQuery(self, fieldName=None, param=None): |
|
646 |
ret = [] |
|
647 |
|
|
648 |
try: |
|
649 |
dbPath = self.getCurrentProject().getPath() + "/db/ITI_PID.db" |
|
650 |
conn = sqlite3.connect(dbPath) |
|
651 |
cursor = conn.cursor() |
|
652 |
if fieldName is not None and param is not None: |
|
653 |
sql = 'SELECT * FROM Symbol WHERE ' + fieldName + ' = "' + param + '"' |
|
654 |
else: |
|
655 |
sql = 'SELECT * FROM Symbol' |
|
656 |
try: |
|
657 |
cursor.execute(sql) |
|
658 |
rows = cursor.fetchall() |
|
659 |
if rows is not None and len(rows) > 0: |
|
660 |
for symbolTuple in rows: |
|
661 |
sym = symbol.SymbolBase(symbolTuple[1], symbolTuple[2], symbolTuple[3], symbolTuple[4] |
|
662 |
, symbolTuple[5], symbolTuple[6], symbolTuple[7], symbolTuple[8], symbolTuple[9] |
|
663 |
, symbolTuple[10], symbolTuple[11], symbolTuple[12], symbolTuple[13], symbolTuple[0]) ## uid is last item |
|
664 |
ret.append(sym) |
|
665 |
except Exception as ex: |
|
666 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
667 |
finally: |
|
668 |
conn.close() |
|
669 |
|
|
670 |
return ret |
|
671 |
|
|
672 |
''' |
|
643 | 673 |
@brief get nominal pipe size |
644 | 674 |
@author humkyung |
645 | 675 |
@date 2018.04.20 |
... | ... | |
680 | 710 |
''' |
681 | 711 |
def getOcrOptionComboBoxItems(self): |
682 | 712 |
return [("OCR 미적용", 0), ("일반 심볼", 1), ("Instrument 계통", 2)] |
683 |
|
|
713 |
|
|
684 | 714 |
''' |
685 | 715 |
@brief Return Symbol Type Items |
686 | 716 |
@author Jeongwoo |
687 |
@date 18.04.06
|
|
717 |
@date 18.04.20
|
|
688 | 718 |
@history . |
689 | 719 |
''' |
690 |
def getSymbolTypeComboBoxItems(self):
|
|
720 |
def getSymbolTypeList(self):
|
|
691 | 721 |
symbolTypeList = [] |
692 | 722 |
|
693 | 723 |
try: |
... | ... | |
705 | 735 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
706 | 736 |
finally: |
707 | 737 |
conn.close() |
708 |
symbolTypeList.insert(0, "None") |
|
738 |
|
|
739 |
return symbolTypeList |
|
740 |
|
|
741 |
''' |
|
742 |
@brief Return Symbol Type Items with "None" |
|
743 |
@author Jeongwoo |
|
744 |
@date 18.04.06 |
|
745 |
@history Seperate SymbolTypeList and "None" |
|
746 |
''' |
|
747 |
def getSymbolTypeComboBoxItems(self): |
|
748 |
symbolTypeList = self.getSymbolTypeList() |
|
749 |
symbolTypeList.insert(0, "None") |
|
709 | 750 |
|
710 | 751 |
return symbolTypeList |
711 | 752 |
|
DTI_PID/DTI_PID/QDirTreeWidget.py | ||
---|---|---|
18 | 18 |
class QDirTreeWidget(QTreeWidget): |
19 | 19 |
#Add signal |
20 | 20 |
singleClicked = pyqtSignal(SymbolBase.SymbolBase) |
21 |
TREE_DATA_ROLE = Qt.ToolTipRole |
|
21 | 22 |
|
22 | 23 |
def __init__(self): |
23 | 24 |
QTreeWidget.__init__(self) |
... | ... | |
101 | 102 |
#self.loadDirectoryInfo(project.getImageFilePath(), self) |
102 | 103 |
self.expandAll() |
103 | 104 |
|
105 |
''' |
|
106 |
@brief Load Symbol Info and add TreeItem with DB |
|
107 |
@author Jeongwoo |
|
108 |
@date 18.04.20 |
|
109 |
''' |
|
104 | 110 |
def loadSymbolInfo(self): |
105 | 111 |
'''ss''' |
112 |
SVG_PATH_ROOT = AppDocData.instance().getCurrentProject().getSvgFilePath() |
|
113 |
symbolTypeList = AppDocData.instance().getSymbolTypeList() |
|
114 |
for symbolType in symbolTypeList: |
|
115 |
parent = QTreeWidgetItem(self, [symbolType]) |
|
116 |
symbolList = AppDocData.instance().getSymbolListByQuery('type', symbolType) |
|
117 |
#symbolNameList = AppDocData.instance().getSymbolNameListByType(symbolType) |
|
118 |
for symbol in symbolList: |
|
119 |
symbolItem = QTreeWidgetItem(parent, [symbol.getName()]) |
|
120 |
symbolItem.setData(0, self.TREE_DATA_ROLE, symbol) ## ADD DATA |
|
121 |
svgPath = SVG_PATH_ROOT + "/" + symbolType + "/" + symbol.getName() + ".svg" |
|
122 |
icon = QIcon(svgPath) |
|
123 |
symbolItem.setIcon(0, icon) |
|
124 |
symbolItem.svgFilePath = svgPath # save svg file path |
|
125 |
|
|
106 | 126 |
|
107 | 127 |
''' |
108 | 128 |
@brief Make Directory |
... | ... | |
128 | 148 |
if not os.path.exists(tempDir): |
129 | 149 |
os.makedirs(tempDir) |
130 | 150 |
|
131 |
def loadDirectoryInfo(self, startPath, tree): |
|
132 |
for element in os.listdir(startPath): |
|
133 |
pathInfo = os.path.join(startPath, element) |
|
134 |
parentItem = QTreeWidgetItem(tree, [os.path.basename(element)]) |
|
135 |
if pathInfo.endswith(".png"): |
|
136 |
icon = QIcon(pathInfo) |
|
137 |
parentItem.setIcon(0, icon) |
|
138 |
parentItem.svgFilePath = pathInfo # save svg file path |
|
139 |
if os.path.isdir(pathInfo): |
|
140 |
self.loadDirectoryInfo(pathInfo, parentItem) |
|
151 |
#def loadDirectoryInfo(self, startPath, tree):
|
|
152 |
# for element in os.listdir(startPath):
|
|
153 |
# pathInfo = os.path.join(startPath, element)
|
|
154 |
# parentItem = QTreeWidgetItem(tree, [os.path.basename(element)])
|
|
155 |
# if pathInfo.endswith(".png"):
|
|
156 |
# icon = QIcon(pathInfo)
|
|
157 |
# parentItem.setIcon(0, icon)
|
|
158 |
# parentItem.svgFilePath = pathInfo # save svg file path
|
|
159 |
# if os.path.isdir(pathInfo):
|
|
160 |
# self.loadDirectoryInfo(pathInfo, parentItem)
|
|
141 | 161 |
|
142 | 162 |
def showSymbolEditorDialog(self, item, columnNo): |
143 | 163 |
sym = self.getSymbolByItemName(item, columnNo) |
... | ... | |
168 | 188 |
else: |
169 | 189 |
QMessageBox.about(self, "알림", "심볼 데이터를 불러오는 중 에러가 발생했습니다.") |
170 | 190 |
|
191 |
''' |
|
192 |
@brief Get Symbol data by symbol name |
|
193 |
@author Jeongwoo |
|
194 |
@date 18.04.20 |
|
195 |
''' |
|
171 | 196 |
def getSymbolByItemName(self, item, columnNo): |
172 | 197 |
tmpItem = item |
173 | 198 |
itemName = item.text(columnNo) |
174 |
if itemName.lower().endswith(".png"): |
|
175 |
path = itemName |
|
176 |
while tmpItem.parent() is not None: |
|
177 |
path = tmpItem.parent().text(columnNo) + "/" + path |
|
178 |
tmpItem = tmpItem.parent() |
|
179 |
fullPath = AppDocData.instance().getCurrentProject().getImageFilePath() + "/" + path # path includes ".png" |
|
180 |
|
|
181 |
name = itemName.replace(".png", "") |
|
182 |
sym = AppDocData.instance().getSymbolByQuery("name", name) |
|
183 |
return sym |
|
184 |
else: |
|
185 |
return None |
|
199 |
#if itemName.lower().endswith(".png"): |
|
200 |
#path = itemName |
|
201 |
#while tmpItem.parent() is not None: |
|
202 |
# path = tmpItem.parent().text(columnNo) + "/" + path |
|
203 |
# tmpItem = tmpItem.parent() |
|
204 |
#fullPath = AppDocData.instance().getCurrentProject().getImageFilePath() + "/" + path # path includes ".png" |
|
205 |
|
|
206 |
#name = itemName.replace(".png", "") |
|
207 |
name = itemName |
|
208 |
sym = AppDocData.instance().getSymbolByQuery("name", name) |
|
209 |
return sym |
|
210 |
#else: |
|
211 |
# return None |
|
186 | 212 |
|
187 | 213 |
''' |
188 | 214 |
@brief start drag |
189 | 215 |
@author humkyung |
190 | 216 |
@date 2018.04.17 |
217 |
@history 18.04.20 Jeongwoo Change Path in QPixmap |
|
191 | 218 |
''' |
192 | 219 |
def startDrag(self, dropAction): |
193 | 220 |
items = self.selectedItems() |
194 | 221 |
if items: |
195 |
pixmap = QPixmap(AppDocData.instance().getCurrentProject().getSvgFilePath() + '/Valves/' + 'GATE VALVE.svg') |
|
222 |
symData = items[0].data(0, self.TREE_DATA_ROLE) |
|
223 |
pixmap = QPixmap(AppDocData.instance().getCurrentProject().getSvgFilePath() + '/'+symData.getType()+'/' +symData.getName()+ '.svg') |
|
196 | 224 |
|
197 | 225 |
mime = QMimeData() |
198 | 226 |
mime.setText('BALL VALVE WITH PLUG') |
내보내기 Unified diff