개정판 74fc4c98
issue #49: add reserved words table and reservedword text item class
Change-Id: I76d05681de95fc4c299edcbb7e5d9e1d023d3cdf
DTI_PID/DTI_PID/CodeTableDialog.py | ||
---|---|---|
15 | 15 |
This code table dialog class |
16 | 16 |
""" |
17 | 17 |
|
18 |
CODE_TABLES = ('Nominal Diameter', 'Fluid Code', 'Insulation Purpose', 'PnID Number', 'Piping Materials Class', 'Unit Number', 'ValveOperCodes', 'EqpTagNames') |
|
18 |
CODE_TABLES = ('Nominal Diameter', 'Fluid Code', 'Insulation Purpose', 'PnID Number', 'Piping Materials Class', 'Unit Number', 'ValveOperCodes', 'EqpTagNames', 'ReservedWords')
|
|
19 | 19 |
|
20 | 20 |
def __init__(self, parent): |
21 | 21 |
QDialog.__init__(self, parent) |
... | ... | |
32 | 32 |
self.ui.tableWidgetPipingMaterialsClass.setSortingEnabled(True) |
33 | 33 |
self.ui.tableWidgetUnitNumber.setSortingEnabled(True) |
34 | 34 |
self.ui.tableWidgetValveOperCodes.setSortingEnabled(True) |
35 |
self.ui.tableWidgetEqpTagNames.setSortingEnabled(True) |
|
36 |
self.ui.tableWidgetReservedWords.setSortingEnabled(True) |
|
35 | 37 |
|
36 | 38 |
#DB Table명 기준으로 작성 |
37 | 39 |
for table in QCodeTableDialog.CODE_TABLES: |
DTI_PID/DTI_PID/CodeTable_UI.py | ||
---|---|---|
1 | 1 |
# -*- coding: utf-8 -*- |
2 | 2 |
|
3 |
# Form implementation generated from reading ui file '.\UI\CodeTable.ui'
|
|
3 |
# Form implementation generated from reading ui file './UI/CodeTable.ui'
|
|
4 | 4 |
# |
5 | 5 |
# Created by: PyQt5 UI code generator 5.11.3 |
6 | 6 |
# |
... | ... | |
18 | 18 |
CodeTableDialog.setModal(True) |
19 | 19 |
self.gridLayout = QtWidgets.QGridLayout(CodeTableDialog) |
20 | 20 |
self.gridLayout.setObjectName("gridLayout") |
21 |
self.buttonBox = QtWidgets.QDialogButtonBox(CodeTableDialog) |
|
22 |
self.buttonBox.setOrientation(QtCore.Qt.Horizontal) |
|
23 |
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok) |
|
24 |
self.buttonBox.setObjectName("buttonBox") |
|
25 |
self.gridLayout.addWidget(self.buttonBox, 4, 0, 1, 1) |
|
26 | 21 |
self.tabWidget = QtWidgets.QTabWidget(CodeTableDialog) |
22 |
self.tabWidget.setFocusPolicy(QtCore.Qt.NoFocus) |
|
27 | 23 |
self.tabWidget.setObjectName("tabWidget") |
28 | 24 |
self.tabNominalDiameter = QtWidgets.QWidget() |
29 | 25 |
self.tabNominalDiameter.setObjectName("tabNominalDiameter") |
... | ... | |
172 | 168 |
self.gridLayout_21.addWidget(self.tableWidgetEqpTagNames, 0, 0, 1, 1) |
173 | 169 |
self.gridLayout_22.addWidget(self.groupBox_8, 0, 0, 1, 1) |
174 | 170 |
self.tabWidget.addTab(self.tab_2, "") |
171 |
self.tab_3 = QtWidgets.QWidget() |
|
172 |
self.tab_3.setObjectName("tab_3") |
|
173 |
self.gridLayout_24 = QtWidgets.QGridLayout(self.tab_3) |
|
174 |
self.gridLayout_24.setObjectName("gridLayout_24") |
|
175 |
self.groupBox_9 = QtWidgets.QGroupBox(self.tab_3) |
|
176 |
self.groupBox_9.setObjectName("groupBox_9") |
|
177 |
self.gridLayout_23 = QtWidgets.QGridLayout(self.groupBox_9) |
|
178 |
self.gridLayout_23.setObjectName("gridLayout_23") |
|
179 |
self.tableWidgetReservedWords = QtWidgets.QTableWidget(self.groupBox_9) |
|
180 |
self.tableWidgetReservedWords.setColumnCount(4) |
|
181 |
self.tableWidgetReservedWords.setObjectName("tableWidgetReservedWords") |
|
182 |
self.tableWidgetReservedWords.setRowCount(0) |
|
183 |
self.tableWidgetReservedWords.horizontalHeader().setSortIndicatorShown(True) |
|
184 |
self.tableWidgetReservedWords.verticalHeader().setVisible(False) |
|
185 |
self.gridLayout_23.addWidget(self.tableWidgetReservedWords, 0, 0, 1, 1) |
|
186 |
self.gridLayout_24.addWidget(self.groupBox_9, 0, 0, 1, 1) |
|
187 |
self.tabWidget.addTab(self.tab_3, "") |
|
175 | 188 |
self.gridLayout.addWidget(self.tabWidget, 0, 0, 1, 1) |
189 |
self.buttonBox = QtWidgets.QDialogButtonBox(CodeTableDialog) |
|
190 |
self.buttonBox.setFocusPolicy(QtCore.Qt.TabFocus) |
|
191 |
self.buttonBox.setOrientation(QtCore.Qt.Horizontal) |
|
192 |
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok) |
|
193 |
self.buttonBox.setObjectName("buttonBox") |
|
194 |
self.gridLayout.addWidget(self.buttonBox, 1, 0, 1, 1) |
|
176 | 195 |
|
177 | 196 |
self.retranslateUi(CodeTableDialog) |
178 | 197 |
self.tabWidget.setCurrentIndex(0) |
... | ... | |
195 | 214 |
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tabPipingMaterialsClass), _translate("CodeTableDialog", "Piping Materials Class")) |
196 | 215 |
self.groupBox_6.setTitle(_translate("CodeTableDialog", "Unit Number")) |
197 | 216 |
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tabUnitNumber), _translate("CodeTableDialog", "Unit Number")) |
198 |
self.groupBox_7.setTitle(_translate("CodeTableDialog", "Codes"))
|
|
217 |
self.groupBox_7.setTitle(_translate("CodeTableDialog", "Valve Oper Code"))
|
|
199 | 218 |
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), _translate("CodeTableDialog", "Valve Oper Codes")) |
200 |
self.groupBox_8.setTitle(_translate("CodeTableDialog", "Tag Names"))
|
|
219 |
self.groupBox_8.setTitle(_translate("CodeTableDialog", "Tag Name")) |
|
201 | 220 |
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_2), _translate("CodeTableDialog", "Eqp Tag Names")) |
221 |
self.groupBox_9.setTitle(_translate("CodeTableDialog", "Reserved Word")) |
|
222 |
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_3), _translate("CodeTableDialog", "Reserved Words")) |
|
223 |
|
|
224 |
|
|
225 |
if __name__ == "__main__": |
|
226 |
import sys |
|
227 |
app = QtWidgets.QApplication(sys.argv) |
|
228 |
CodeTableDialog = QtWidgets.QDialog() |
|
229 |
ui = Ui_CodeTableDialog() |
|
230 |
ui.setupUi(CodeTableDialog) |
|
231 |
CodeTableDialog.show() |
|
232 |
sys.exit(app.exec_()) |
|
202 | 233 |
|
DTI_PID/DTI_PID/Shapes/EngineeringReservedWordTextItem.py | ||
---|---|---|
1 |
# coding: utf-8 |
|
2 |
""" This is engineering reserved word text item module """ |
|
3 |
|
|
4 |
import os.path |
|
5 |
import sys |
|
6 |
import copy |
|
7 |
try: |
|
8 |
from PyQt5.QtCore import Qt, QPointF, QRectF, pyqtSignal, QT_VERSION_STR, QRect |
|
9 |
from PyQt5.QtGui import QImage, QPixmap, QPainterPath, QBrush, QPen, QTransform, QFont |
|
10 |
from PyQt5.QtWidgets import QGraphicsView, QGraphicsScene, QFileDialog, QGraphicsItem, QAbstractGraphicsShapeItem, QGraphicsTextItem |
|
11 |
except ImportError: |
|
12 |
try: |
|
13 |
from PyQt4.QtCore import Qt, QRectF, pyqtSignal, QT_VERSION_STR, QRect |
|
14 |
from PyQt4.QtGui import QGraphicsView, QGraphicsScene, QImage, QPixmap, QPainterPath, QFileDialog, QFont |
|
15 |
except ImportError: |
|
16 |
raise ImportError("ImageViewerQt: Requires PyQt5 or PyQt4.") |
|
17 |
|
|
18 |
from AppDocData import AppDocData |
|
19 |
from EngineeringTextItem import QEngineeringTextItem |
|
20 |
|
|
21 |
class QEngineeringReservedWordTextItem(QEngineeringTextItem): |
|
22 |
|
|
23 |
def __init__(self, uid=None, parent=None): |
|
24 |
QEngineeringTextItem.__init__(self, uid, parent) |
|
25 |
self.type = 'Reserved Word' |
DTI_PID/DTI_PID/TextItemFactory.py | ||
---|---|---|
23 | 23 |
from QEngineeringSizeTextItem import QEngineeringSizeTextItem |
24 | 24 |
from QEngineeringTagNoTextItem import QEngineeringTagNoTextItem |
25 | 25 |
from EngineeringValveOperCodeTextItem import QEngineeringValveOperCodeTextItem |
26 |
from EngineeringReservedWordTextItem import QEngineeringReservedWordTextItem |
|
26 | 27 |
|
27 | 28 |
class TextItemFactory(SingletonInstane): |
28 | 29 |
""" This is TextItemFactor class """ |
... | ... | |
128 | 129 |
item = QEngineeringValveOperCodeTextItem() |
129 | 130 |
item.setToolTip('Valve Operation Code = {}'.format(text)) |
130 | 131 |
item.setPlainText(text) |
132 |
elif self.is_reserved_word(text): |
|
133 |
item = QEngineeringReservedWordTextItem() |
|
134 |
item.setToolTip('Reserved Word = {}'.format(text)) |
|
135 |
item.setPlainText(text) |
|
131 | 136 |
else: |
132 | 137 |
item = QEngineeringTextItem() |
133 | 138 |
item.setToolTip(text) |
... | ... | |
321 | 326 |
found = CodeTable.instance('ValveOperCodes').find_starts_with(text) |
322 | 327 |
|
323 | 328 |
return True if found else False |
329 |
|
|
330 |
def is_reserved_word(sefl, text): |
|
331 |
from CodeTables import CodeTable |
|
332 |
|
|
333 |
found = CodeTable.instance('ReservedWords').find_starts_with(text) |
|
334 |
|
|
335 |
return True if found else False |
DTI_PID/DTI_PID/UI/CodeTable.ui | ||
---|---|---|
22 | 22 |
<bool>true</bool> |
23 | 23 |
</property> |
24 | 24 |
<layout class="QGridLayout" name="gridLayout"> |
25 |
<item row="4" column="0"> |
|
26 |
<widget class="QDialogButtonBox" name="buttonBox"> |
|
27 |
<property name="orientation"> |
|
28 |
<enum>Qt::Horizontal</enum> |
|
29 |
</property> |
|
30 |
<property name="standardButtons"> |
|
31 |
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> |
|
32 |
</property> |
|
33 |
</widget> |
|
34 |
</item> |
|
35 | 25 |
<item row="0" column="0"> |
36 | 26 |
<widget class="QTabWidget" name="tabWidget"> |
27 |
<property name="focusPolicy"> |
|
28 |
<enum>Qt::NoFocus</enum> |
|
29 |
</property> |
|
37 | 30 |
<property name="currentIndex"> |
38 | 31 |
<number>0</number> |
39 | 32 |
</property> |
... | ... | |
247 | 240 |
<item row="0" column="0"> |
248 | 241 |
<widget class="QGroupBox" name="groupBox_7"> |
249 | 242 |
<property name="title"> |
250 |
<string>Codes</string>
|
|
243 |
<string>Valve Oper Code</string>
|
|
251 | 244 |
</property> |
252 | 245 |
<layout class="QGridLayout" name="gridLayout_20"> |
253 | 246 |
<item row="0" column="0"> |
... | ... | |
276 | 269 |
<item row="0" column="0"> |
277 | 270 |
<widget class="QGroupBox" name="groupBox_8"> |
278 | 271 |
<property name="title"> |
279 |
<string>Tag Names</string>
|
|
272 |
<string>Tag Name</string> |
|
280 | 273 |
</property> |
281 | 274 |
<layout class="QGridLayout" name="gridLayout_21"> |
282 | 275 |
<item row="0" column="0"> |
... | ... | |
297 | 290 |
</item> |
298 | 291 |
</layout> |
299 | 292 |
</widget> |
293 |
<widget class="QWidget" name="tab_3"> |
|
294 |
<attribute name="title"> |
|
295 |
<string>Reserved Words</string> |
|
296 |
</attribute> |
|
297 |
<layout class="QGridLayout" name="gridLayout_24"> |
|
298 |
<item row="0" column="0"> |
|
299 |
<widget class="QGroupBox" name="groupBox_9"> |
|
300 |
<property name="title"> |
|
301 |
<string>Reserved Word</string> |
|
302 |
</property> |
|
303 |
<layout class="QGridLayout" name="gridLayout_23"> |
|
304 |
<item row="0" column="0"> |
|
305 |
<widget class="QTableWidget" name="tableWidgetReservedWords"> |
|
306 |
<property name="columnCount"> |
|
307 |
<number>4</number> |
|
308 |
</property> |
|
309 |
<attribute name="horizontalHeaderShowSortIndicator" stdset="0"> |
|
310 |
<bool>true</bool> |
|
311 |
</attribute> |
|
312 |
<attribute name="verticalHeaderVisible"> |
|
313 |
<bool>false</bool> |
|
314 |
</attribute> |
|
315 |
<column/> |
|
316 |
<column/> |
|
317 |
<column/> |
|
318 |
<column/> |
|
319 |
</widget> |
|
320 |
</item> |
|
321 |
</layout> |
|
322 |
</widget> |
|
323 |
</item> |
|
324 |
</layout> |
|
325 |
</widget> |
|
326 |
</widget> |
|
327 |
</item> |
|
328 |
<item row="1" column="0"> |
|
329 |
<widget class="QDialogButtonBox" name="buttonBox"> |
|
330 |
<property name="focusPolicy"> |
|
331 |
<enum>Qt::TabFocus</enum> |
|
332 |
</property> |
|
333 |
<property name="orientation"> |
|
334 |
<enum>Qt::Horizontal</enum> |
|
335 |
</property> |
|
336 |
<property name="standardButtons"> |
|
337 |
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> |
|
338 |
</property> |
|
300 | 339 |
</widget> |
301 | 340 |
</item> |
302 | 341 |
</layout> |
내보내기 Unified diff