개정판 21bf5f0c
dev issue #581: edit UI and editable NominalPipeSize
DTI_PID/DTI_PID/AppDocData.py | ||
---|---|---|
1138 | 1138 |
@date 2018.04.20 |
1139 | 1139 |
@history humkyung 2018.04.24 read MetricStr column and set size unit |
1140 | 1140 |
kyouho 2018.07.04 forCheckLineNumber get only inch or metric |
1141 |
kyouho 2018.07.16 edit query order by code |
|
1141 | 1142 |
''' |
1142 | 1143 |
def getNomialPipeSizeData(self, forCheckLineNumber = False): |
1143 | 1144 |
res = [] |
... | ... | |
1151 | 1152 |
# Get a cursor object |
1152 | 1153 |
cursor = conn.cursor() |
1153 | 1154 | |
1154 |
sql = "select Code,Metric,Inch,InchStr,MetricStr from 'NOMINAL PIPE SIZE' ORDER BY METRIC ASC"
|
|
1155 |
sql = "select Code,Metric,Inch,InchStr,MetricStr from 'NOMINAL PIPE SIZE' ORDER BY CODE ASC"
|
|
1155 | 1156 |
cursor.execute(sql) |
1156 | 1157 |
rows = cursor.fetchall() |
1157 | 1158 |
for row in rows: |
1158 |
pipeSize = NominalPipeSize(row[0], float(row[1]) if row[1] is not None else -1, float(row[2]) if row[2] is not None else -1, row[3], row[4])
|
|
1159 |
pipeSize = NominalPipeSize(row[0], float(row[1]) if row[1] is not None else None, float(row[2]) if row[2] is not None else None, row[3], row[4])
|
|
1159 | 1160 |
pipeSize.sizeUnit = sizeUnit |
1160 | 1161 |
if forCheckLineNumber: |
1161 | 1162 |
if sizeUnit == 'Inch' and pipeSize.inchStr: |
... | ... | |
1175 | 1176 |
conn.close() |
1176 | 1177 | |
1177 | 1178 |
return res |
1179 | ||
1180 |
''' |
|
1181 |
@brief insert nominal pipe size table |
|
1182 |
@author kyouho |
|
1183 |
@date 2018.07.16 |
|
1184 |
''' |
|
1185 |
def insertNomialPipeSize(self, pipeSizes): |
|
1186 |
try: |
|
1187 |
# Creates or opens a file called mydb with a SQLite3 DB |
|
1188 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db') |
|
1189 |
conn = sqlite3.connect(dbPath) |
|
1190 |
# Get a cursor object |
|
1191 |
cursor = conn.cursor() |
|
1192 |
sql = "INSERT INTO 'NOMINAL PIPE SIZE'(Code, Metric, Inch, InchStr, MetricStr) VALUES(?,?,?,?,?)" |
|
1193 |
for pipeSize in pipeSizes: |
|
1194 |
param = (pipeSize.code, pipeSize.metric, pipeSize.inch, pipeSize.inchStr, pipeSize.metricStr) |
|
1195 |
cursor.execute(sql, param) |
|
1196 |
conn.commit() |
|
1197 |
# Catch the exception |
|
1198 |
except Exception as ex: |
|
1199 |
# Roll back any change if something goes wrong |
|
1200 |
conn.rollback() |
|
1201 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
1202 |
finally: |
|
1203 |
# Close the db connection |
|
1204 |
conn.close() |
|
1205 | ||
1206 | ||
1207 |
''' |
|
1208 |
@brief delete nominal pipe size table |
|
1209 |
@author kyouho |
|
1210 |
@date 2018.07.16 |
|
1211 |
''' |
|
1212 |
def deleteNomialPipeSize(self): |
|
1213 |
try: |
|
1214 |
dbPath = self.getCurrentProject().getPath() + "/db/ITI_PID.db" |
|
1215 |
conn = sqlite3.connect(dbPath) |
|
1216 |
cursor = conn.cursor() |
|
1217 |
sql = "DELETE FROM 'NOMINAL PIPE SIZE'" |
|
1218 |
try: |
|
1219 |
cursor.execute(sql) |
|
1220 |
conn.commit() |
|
1221 |
except Exception as ex: |
|
1222 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
1223 |
finally: |
|
1224 |
conn.close() |
|
1178 | 1225 |
|
1179 | 1226 | |
1227 | ||
1228 | ||
1180 | 1229 |
''' |
1181 | 1230 |
@brief convert inch to metric |
1182 | 1231 |
@author kyouho |
DTI_PID/DTI_PID/CodeTableDialog.py | ||
---|---|---|
77 | 77 |
row = 0 |
78 | 78 |
for pipeSize in pipeSizes: |
79 | 79 |
self.ui.tableWidgetNominalDiameter.setItem(row, 0, QTableWidgetItem(pipeSize.code)) |
80 |
self.ui.tableWidgetNominalDiameter.setItem(row, 1, QTableWidgetItem(str(pipeSize.metric))) |
|
81 |
self.ui.tableWidgetNominalDiameter.setItem(row, 2, QTableWidgetItem(str(pipeSize.inch))) |
|
80 |
self.ui.tableWidgetNominalDiameter.setItem(row, 1, QTableWidgetItem('' if pipeSize.metric is None else str(pipeSize.metric)))
|
|
81 |
self.ui.tableWidgetNominalDiameter.setItem(row, 2, QTableWidgetItem('' if pipeSize.inch is None else str(pipeSize.inch)))
|
|
82 | 82 |
self.ui.tableWidgetNominalDiameter.setItem(row, 3, QTableWidgetItem('' if pipeSize.inchStr is None else pipeSize.inchStr)) |
83 | 83 |
self.ui.tableWidgetNominalDiameter.setItem(row, 4, QTableWidgetItem('' if pipeSize.metricStr is None else pipeSize.metricStr)) |
84 | 84 |
row += 1 |
... | ... | |
107 | 107 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
108 | 108 | |
109 | 109 | |
110 | ||
111 | ||
112 | 110 |
''' |
113 | 111 |
@brief Find TableWidget with Name |
114 | 112 |
@author kyouhokyouho |
... | ... | |
295 | 293 |
self.saveCommonCodeData("PnID Number") |
296 | 294 |
self.saveCommonCodeData("Piping Materials Class") |
297 | 295 |
self.saveCommonCodeData("Unit Number") |
298 | ||
299 | 296 |
self.deleteCommonCodeData() |
300 | 297 | |
298 |
self.saveNomialPipeSize() |
|
299 | ||
301 | 300 |
QDialog.accept(self) |
302 | 301 | |
303 | 302 |
''' |
... | ... | |
338 | 337 |
except Exception as ex: |
339 | 338 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
340 | 339 | |
340 |
''' |
|
341 |
@brief save common code data |
|
342 |
@author kyouho |
|
343 |
@date 2018.07.16 |
|
344 |
''' |
|
345 |
def saveNomialPipeSize(self): |
|
346 |
pipeSizes = [] |
|
347 |
try: |
|
348 |
docData = AppDocData.instance() |
|
349 |
self.deleteNomialPipeSize() |
|
350 | ||
351 |
from AppDocData import NominalPipeSize |
|
352 |
|
|
353 |
table = self.ui.tableWidgetNominalDiameter |
|
354 |
rowCount = table.rowCount() |
|
355 |
for row in range(rowCount): |
|
356 |
code = table.item(row, 0).text() |
|
357 |
metric = table.item(row, 1).text() |
|
358 |
inch = table.item(row, 2).text() |
|
359 |
inchStr = table.item(row, 3).text() |
|
360 |
metricStr = table.item(row, 4).text() |
|
361 | ||
362 |
pipeSize = NominalPipeSize(code, float(metric) if metric != '' else None, float(inch) if inch != '' else None, inchStr, metricStr) |
|
363 |
pipeSizes.append(pipeSize) |
|
364 | ||
365 |
docData.insertNomialPipeSize(pipeSizes) |
|
366 | ||
367 |
except Exception as ex: |
|
368 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
369 | ||
370 | ||
371 | ||
372 | ||
373 | ||
374 | ||
375 | ||
376 | ||
377 | ||
378 | ||
379 |
''' |
|
380 |
@brief save common code data |
|
381 |
@author kyouho |
|
382 |
@date 2018.07.16 |
|
383 |
''' |
|
384 |
def deleteNomialPipeSize(self): |
|
385 |
docData = AppDocData.instance() |
|
386 |
docData.deleteNomialPipeSize() |
|
387 | ||
388 | ||
389 | ||
390 | ||
341 | 391 |
|
342 | 392 | |
343 | 393 |
DTI_PID/DTI_PID/CodeTable_UI.py | ||
---|---|---|
150 | 150 |
def retranslateUi(self, CodeTableDialog): |
151 | 151 |
_translate = QtCore.QCoreApplication.translate |
152 | 152 |
CodeTableDialog.setWindowTitle(_translate("CodeTableDialog", "Code Table")) |
153 |
self.groupBox.setTitle(_translate("CodeTableDialog", "Nominal DIameter"))
|
|
153 |
self.groupBox.setTitle(_translate("CodeTableDialog", "Nominal Diameter"))
|
|
154 | 154 |
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tabNominalDiameter), _translate("CodeTableDialog", "Nominal Diameter")) |
155 | 155 |
self.groupBox_2.setTitle(_translate("CodeTableDialog", "Fluid Code")) |
156 | 156 |
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tabFluidCode), _translate("CodeTableDialog", "Fluid Code")) |
DTI_PID/DTI_PID/UI/CodeTable.ui | ||
---|---|---|
47 | 47 |
<item> |
48 | 48 |
<widget class="QGroupBox" name="groupBox"> |
49 | 49 |
<property name="title"> |
50 |
<string>Nominal DIameter</string>
|
|
50 |
<string>Nominal Diameter</string>
|
|
51 | 51 |
</property> |
52 | 52 |
<layout class="QGridLayout" name="gridLayout_13"> |
53 | 53 |
<item row="0" column="0"> |
내보내기 Unified diff