개정판 c4e5da78
issue #627: 리스트 출력 - Special Item 리스트를 출력한다
Change-Id: I964467c5eef8bba75d01a35e9a08cdb496336531
DTI_PID/DTI_PID/AppDocData.py | ||
---|---|---|
2251 | 2251 |
conn.rollback() |
2252 | 2252 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
2253 | 2253 |
|
2254 |
def get_special_items(self, docName = None): |
|
2255 |
""" get special items from database """ |
|
2256 |
result = [] |
|
2257 |
|
|
2258 |
try: |
|
2259 |
# Creates or opens a file called mydb with a SQLite3 DB |
|
2260 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), AppDocData.DATABASE) |
|
2261 |
conn = sqlite3.connect(dbPath) |
|
2262 |
conn.row_factory = sqlite3.Row |
|
2263 |
with conn: |
|
2264 |
# Get a cursor object |
|
2265 |
cursor = conn.cursor() |
|
2266 |
|
|
2267 |
sql = 'select distinct (select Value from Components where UID=D.Owner) as "Line No",C.Code from Components A \ |
|
2268 |
left join Drawings B on A.Drawings_UID=B.UID \ |
|
2269 |
left join SpecialItemTypes C on A.SpecialItemTypes_UID=C.UID \ |
|
2270 |
left join Components D on A.Connected=D.UID \ |
|
2271 |
where A.SpecialItemTypes_UID not null group by "Line No"' |
|
2272 |
if docName is not None: |
|
2273 |
sql += " where Drawings_UID=(select UID from Drawings where Name='{}')".format(docName) |
|
2274 |
cursor.execute(sql) |
|
2275 |
|
|
2276 |
return cursor.fetchall() |
|
2277 |
# catch the exception |
|
2278 |
except Exception as ex: |
|
2279 |
# Roll back any change if something goes wrong |
|
2280 |
conn.rollback() |
|
2281 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
2282 |
|
|
2283 |
return None |
|
2284 |
|
|
2254 | 2285 |
''' |
2255 | 2286 |
@brief Set Common Code Data |
2256 | 2287 |
@author kyouho |
DTI_PID/DTI_PID/ItemDataExportDialog.py | ||
---|---|---|
18 | 18 |
class QItemDataExportDialog(QDialog): |
19 | 19 |
""" This is QItemDataExportDialog class """ |
20 | 20 |
|
21 |
DATA_LIST = ['LINE_DATA_LIST', 'EQUIPMENT_DATA_LIST', 'VALVE_DATA_LIST', 'INSTRUMENT_DATA_LIST', 'NOTE_DATA_LIST'] |
|
21 |
DATA_LIST = ['LINE_DATA_LIST', 'EQUIPMENT_DATA_LIST', 'VALVE_DATA_LIST', 'INSTRUMENT_DATA_LIST', 'NOTE_DATA_LIST', 'SPECIAL_ITEMS']
|
|
22 | 22 |
|
23 | 23 |
def __init__(self, parent): |
24 | 24 |
QDialog.__init__(self, parent) |
... | ... | |
49 | 49 |
QItemDataExportDialog.DATA_LIST[1]:self.equipColumnListAll, |
50 | 50 |
QItemDataExportDialog.DATA_LIST[2]:self.valveColumnListAll, |
51 | 51 |
QItemDataExportDialog.DATA_LIST[3]:self.instColumnListAll, |
52 |
QItemDataExportDialog.DATA_LIST[4]:self.noteColumnListAll |
|
52 |
QItemDataExportDialog.DATA_LIST[4]:self.noteColumnListAll, |
|
53 |
QItemDataExportDialog.DATA_LIST[5]:[] |
|
53 | 54 |
} |
54 | 55 |
|
55 | 56 |
self.lineOrder = [] |
... | ... | |
63 | 64 |
QItemDataExportDialog.DATA_LIST[1]:self.equipOrder, |
64 | 65 |
QItemDataExportDialog.DATA_LIST[2]:self.valveOrder, |
65 | 66 |
QItemDataExportDialog.DATA_LIST[3]:self.instOrder, |
66 |
QItemDataExportDialog.DATA_LIST[4]:self.noteOrder |
|
67 |
QItemDataExportDialog.DATA_LIST[4]:self.noteOrder, |
|
68 |
QItemDataExportDialog.DATA_LIST[5]:[] |
|
67 | 69 |
} |
68 | 70 |
|
69 |
self.removeUID = [[], [], [], [], []] |
|
70 |
|
|
71 | 71 |
self.parent = parent |
72 | 72 |
self.ui = ItemDataExport_UI.Ui_ItemDataExportDialog() |
73 | 73 |
self.ui.setupUi(self) |
... | ... | |
93 | 93 |
QItemDataExportDialog.DATA_LIST[1]:self.ui.tableWidgetEquipmentDataList, |
94 | 94 |
QItemDataExportDialog.DATA_LIST[2]:self.ui.tableWidgetValveDataList, |
95 | 95 |
QItemDataExportDialog.DATA_LIST[3]:self.ui.tableWidgetInstrumentDataList, |
96 |
QItemDataExportDialog.DATA_LIST[4]:self.ui.tableWidgetNoteDataList |
|
96 |
QItemDataExportDialog.DATA_LIST[4]:self.ui.tableWidgetNoteDataList, |
|
97 |
QItemDataExportDialog.DATA_LIST[5]:self.ui.tableWidgetSpecialItems |
|
97 | 98 |
} |
98 | 99 |
self.initTableWidget() |
99 | 100 |
except Exception as ex: |
... | ... | |
158 | 159 |
return |
159 | 160 |
|
160 | 161 |
wb = Workbook() |
161 |
wb.active.title = self.tr('Line List') |
|
162 |
wb.create_sheet(self.tr('Equipment List')) |
|
163 |
wb.create_sheet(self.tr('Valve List')) |
|
164 |
wb.create_sheet(self.tr('Instrument List')) |
|
165 |
wb.create_sheet(self.tr('Note List')) |
|
166 |
|
|
167 |
for index in range(5): |
|
168 |
self.qtable_to_sheet(self.viewTables[index], wb.worksheets[index], index) |
|
162 |
wb.active.title = self.tr(self.ui.tabWidget.tabText(0)) |
|
163 |
for i in range(1,self.ui.tabWidget.count()): |
|
164 |
wb.create_sheet(self.tr(self.ui.tabWidget.tabText(i))) |
|
165 |
|
|
166 |
for index in range(self.ui.tabWidget.count()): |
|
167 |
self.qtable_to_sheet(self.viewTables[QItemDataExportDialog.DATA_LIST[index]], wb.worksheets[index], index) |
|
169 | 168 |
|
170 | 169 |
fileName, ext = os.path.splitext(fileName[0]) |
171 | 170 |
wb.save(fileName + ext if ext == '.xlsx' else fileName + '.xlsx') |
172 | 171 |
|
173 |
QMessageBox.about(self, self.tr("INFO"), self.tr('Successfully saved.'))
|
|
172 |
QMessageBox.about(self, self.tr("Information"), self.tr('Successfully saved.'))
|
|
174 | 173 |
|
175 | 174 |
command = os.path.join(project.path, fileName + '.xlsx') |
176 | 175 |
subprocess.call(command, shell=True) |
... | ... | |
189 | 188 |
''' |
190 | 189 |
def qtable_to_sheet(self, table, sheet, index): |
191 | 190 |
try: |
192 |
self.set_sheet_header(table, sheet, index) |
|
193 |
self.set_sheet_data(table, sheet, index) |
|
191 |
key = QItemDataExportDialog.DATA_LIST[index] |
|
192 |
self.set_sheet_header(table, sheet, key) |
|
193 |
self.set_sheet_data(table, sheet, key) |
|
194 | 194 |
self.auto_resize_columns(sheet) |
195 | 195 |
except Exception as ex: |
196 | 196 |
from App import App |
... | ... | |
199 | 199 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
200 | 200 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
201 | 201 |
|
202 |
''' |
|
203 |
@brief save excel |
|
204 |
@author kyouho |
|
205 |
@date 2018.08.16 |
|
206 |
@history 2018.10.26 euisung export order apply |
|
207 |
''' |
|
208 | 202 |
def set_sheet_header(self, table, sheet, index): |
203 |
""" set list header """ |
|
209 | 204 |
try: |
210 | 205 |
thin = Side(border_style='thin', color='000000') |
211 | 206 |
border = Border(left=thin, right=thin, top=thin, bottom=thin) |
212 |
col = 1 |
|
213 |
for exportHeader in self.columnOrder[index]: |
|
214 |
if exportHeader.split(self.delimiterCombine)[0] == self.columnListAll[index][0]: |
|
215 |
continue |
|
216 |
sheet.cell(1, col, exportHeader.split(self.delimiterCombine)[1]) |
|
217 |
sheet.cell(row = 1, column = col).alignment = Alignment(horizontal='center', vertical='center', wrapText=True) |
|
218 |
sheet.cell(row = 1, column = col).fill = PatternFill(patternType='solid', fill_type='solid', fgColor=Color('8DB4E2')) |
|
219 |
sheet.cell(row = 1, column = col).border = border |
|
220 |
col += 1 |
|
207 |
_col = 1 |
|
208 |
for col in range(table.columnCount()): |
|
209 |
logical_index = table.horizontalHeader().logicalIndex(col) |
|
210 |
col_name = table.horizontalHeaderItem(logical_index).text() |
|
211 |
if table.isColumnHidden(logical_index): continue |
|
212 |
sheet.cell(1, _col, col_name) |
|
213 |
sheet.cell(row = 1, column = _col).alignment = Alignment(horizontal='center', vertical='center', wrapText=True) |
|
214 |
sheet.cell(row = 1, column = _col).fill = PatternFill(patternType='solid', fill_type='solid', fgColor=Color('8DB4E2')) |
|
215 |
sheet.cell(row = 1, column = _col).border = border |
|
216 |
_col += 1 |
|
221 | 217 |
except Exception as ex: |
222 | 218 |
from App import App |
223 | 219 |
from AppDocData import MessageType |
... | ... | |
226 | 222 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
227 | 223 |
|
228 | 224 |
def set_sheet_data(self, table, sheet, index): |
229 |
""" |
|
230 |
@brief save excel |
|
231 |
@author kyouho |
|
232 |
@date 2018.08.16 |
|
233 |
@history 2018.10.31 euisung export order apply |
|
234 |
""" |
|
225 |
""" write list data to sheet """ |
|
235 | 226 |
try: |
236 | 227 |
thin = Side(border_style='thin', color='000000') |
237 | 228 |
border = Border(left=thin, right=thin, top=thin, bottom=thin) |
238 |
logicalCol = [] |
|
239 |
withoutEmpty = [] |
|
240 |
emptys = [] |
|
241 |
for col in range(len(self.columnOrder[index])): |
|
242 |
if self.columnOrder[index][col].split(self.delimiterCombine)[0] == self.emptyCol: |
|
243 |
emptys.append(col) |
|
244 |
else: |
|
245 |
withoutEmpty.append(self.columnOrder[index][col]) |
|
246 |
|
|
247 |
for header in range(len(withoutEmpty)): |
|
248 |
target = withoutEmpty[header].split(self.delimiterCombine)[0] |
|
249 |
for col in range(len(self.columnListAll[index])): |
|
250 |
if target == self.columnListAll[index][col]: |
|
251 |
logicalCol.append(col) |
|
252 |
break |
|
253 |
|
|
254 |
exportCol = [0] |
|
255 |
position = 1 |
|
256 |
for col in range(1, len(self.columnOrder[index])): |
|
257 |
if self.columnOrder[index][col].split(self.delimiterCombine)[0] == self.emptyCol: |
|
258 |
position += 1 |
|
259 |
continue |
|
260 |
exportCol.append(position) |
|
261 |
position += 1 |
|
262 | 229 |
|
263 | 230 |
for rowIndex in range(table.rowCount()): |
264 |
for header in range(len(logicalCol)): |
|
265 |
if not logicalCol[header]: |
|
266 |
continue |
|
231 |
_col = 1 |
|
232 |
for col in range(table.columnCount()): |
|
233 |
logical_index = table.horizontalHeader().logicalIndex(col) |
|
234 |
if table.isColumnHidden(logical_index): continue |
|
267 | 235 |
|
268 |
widgetItem = table.cellWidget(rowIndex, logicalCol[header])
|
|
236 |
widgetItem = table.cellWidget(rowIndex, logical_index)
|
|
269 | 237 |
if widgetItem is None: |
270 |
data = table.item(rowIndex, logicalCol[header]).text() if table.item(rowIndex, logicalCol[header]) is not None else ''
|
|
238 |
data = table.item(rowIndex, logical_index).text() if table.item(rowIndex, logical_index) is not None else ''
|
|
271 | 239 |
else: |
272 |
if widgetItem.currentIndex() >= 0: |
|
273 |
data = widgetItem.currentText() |
|
274 |
else: |
|
275 |
data = '' |
|
276 |
|
|
277 |
sheet.cell(rowIndex + 2, exportCol[header], data) |
|
240 |
data = widgetItem.currentText() if widgetItem.currentIndex() >= 0 else '' |
|
278 | 241 |
|
279 |
for rowIndex in range(table.rowCount()):
|
|
280 |
for colIndex in range(1, len(self.columnOrder[index])):
|
|
281 |
sheet.cell(row = rowIndex+2, column = colIndex).border = border
|
|
242 |
sheet.cell(rowIndex + 2, _col, data)
|
|
243 |
sheet.cell(row = rowIndex+2, column=_col).border = border
|
|
244 |
_col += 1
|
|
282 | 245 |
except Exception as ex: |
283 | 246 |
from App import App |
284 | 247 |
from AppDocData import MessageType |
... | ... | |
317 | 280 |
documentNameList = [] |
318 | 281 |
documentNameData = docData.getDocumentNameList() |
319 | 282 |
documentNameList.extend(documentNameData) |
320 |
#documentNameData = docData.getEquipDocumentNameList() |
|
321 |
#documentNameList.extend(documentNameData) |
|
322 | 283 |
|
323 | 284 |
for name in documentNameData: |
324 | 285 |
self.ui.comboBoxDoc.addItem(name) |
325 | 286 |
|
326 |
|
|
327 | 287 |
if not self.parent.graphicsView.hasImage(): |
328 | 288 |
return |
329 | 289 |
result = self.ui.comboBoxDoc.findText(docData.imgName) |
... | ... | |
339 | 299 |
Euisung 2018.10.25 add initial list saving process |
340 | 300 |
''' |
341 | 301 |
def initTableWidget(self): |
302 |
from SpecialItemTypesDialog import SpecialItemTypes |
|
303 |
|
|
342 | 304 |
docData = AppDocData.instance() |
305 |
special_item_types = SpecialItemTypes.instance() |
|
343 | 306 |
self.lineColumnListAll = ['UID', 'Drawing Name'] |
344 | 307 |
self.lineColumnListAll.extend([prop.Attribute for prop in docData.getLineProperties()]) |
345 | 308 |
self.equipColumnListAll = docData.getColNames(QItemDataExportDialog.DATA_LIST[1]) |
... | ... | |
353 | 316 |
self.columnListAll[QItemDataExportDialog.DATA_LIST[2]] = self.valveColumnListAll |
354 | 317 |
self.columnListAll[QItemDataExportDialog.DATA_LIST[3]] = self.instColumnListAll |
355 | 318 |
self.columnListAll[QItemDataExportDialog.DATA_LIST[4]] = self.noteColumnListAll |
319 |
self.columnListAll[QItemDataExportDialog.DATA_LIST[5]] = ['UID', 'Line No'] + [code['Code'] for code in special_item_types.values] |
|
356 | 320 |
# 엑셀 추출시 사용할 리스트 오더를 db에서 읽거나 없으면 db에 추가 |
357 | 321 |
try: |
358 | 322 |
configs = [] |
... | ... | |
367 | 331 |
configs.append(Config('Order', data, value)) |
368 | 332 |
else: |
369 | 333 |
value = '' |
370 |
for col in docData.getColNames(data):
|
|
334 |
for col in self.columnListAll[data]:
|
|
371 | 335 |
value += (col + self.delimiterCombine + col + self.delimiter) |
372 | 336 |
value = value[:-len(self.delimiter)] |
373 | 337 |
configs.append(Config('Order', data, value)) |
... | ... | |
401 | 365 |
self.set_valve_data() |
402 | 366 |
self.settingInstrumentData() |
403 | 367 |
self.settingNoteData() |
368 |
self.fill_special_items() |
|
404 | 369 |
|
405 | 370 |
self.sortListOrder() |
406 | 371 |
except Exception as ex: |
... | ... | |
419 | 384 |
docData = AppDocData.instance() |
420 | 385 |
|
421 | 386 |
for key in self.viewTables.keys(): |
422 |
headers = [] |
|
387 |
config = docData.getConfigs('Order', key) |
|
388 |
if not config: continue |
|
389 |
|
|
423 | 390 |
orders = docData.getConfigs('Order', key)[0].value.split(self.delimiter) |
391 |
headers = [] |
|
424 | 392 |
for col in range(len(orders)): |
425 | 393 |
header = orders[col].split(self.delimiterCombine) |
426 | 394 |
headers.append(header) |
... | ... | |
429 | 397 |
for header in headers: |
430 | 398 |
matches = [index for index in range(self.viewTables[key].columnCount()) if header[0] == self.viewTables[key].horizontalHeaderItem(index).text()] |
431 | 399 |
if matches: |
400 |
self.viewTables[key].horizontalHeaderItem(matches[0]).setText(header[1]) # display user column name |
|
432 | 401 |
_from = self.viewTables[key].horizontalHeader().visualIndex(matches[0]) |
433 | 402 |
self.viewTables[key].horizontalHeader().moveSection(_from, col) |
434 | 403 |
col = col + 1 |
... | ... | |
464 | 433 |
item.setFlags(Qt.ItemIsEnabled) |
465 | 434 |
lineTable.setItem(row, col, item) |
466 | 435 |
|
467 |
""" |
|
468 |
for dataIndex in range(len(data)): |
|
469 |
if dataIndex in self.lineNoTableComboBoxDic: |
|
470 |
tempList = self.lineNoTableComboBoxDic[dataIndex] |
|
471 |
comboBox = QComboBox() |
|
472 |
comboBox.setEnabled(False) |
|
473 |
for comboText in tempList: |
|
474 |
comboBox.addItem(comboText) |
|
475 |
tempIndex = comboBox.findText(data[dataIndex][1]) |
|
476 |
comboBox.setCurrentIndex(tempIndex) |
|
477 |
lineTable.setCellWidget(row, dataIndex, comboBox) |
|
478 |
else: |
|
479 |
item = QTableWidgetItem(data[dataIndex][1] if data[dataIndex][1] is not None else '') |
|
480 |
item.setFlags(Qt.ItemIsEnabled) |
|
481 |
lineTable.setItem(row, dataIndex, item) |
|
482 |
""" |
|
483 | 436 |
row += 1 |
484 | 437 |
|
485 | 438 |
''' |
... | ... | |
509 | 462 |
col += 1 |
510 | 463 |
|
511 | 464 |
row += 1 |
512 |
''' |
|
513 |
# 현재 문서명이 같으면 중복 체크 (Equipment 경우 uid로) |
|
514 |
if docData.imgName is not None and (docData.imgName == text or self.ui.comboBoxDoc.currentIndex() == 0): |
|
515 |
rowCount = equipTable.rowCount() |
|
516 |
uidList = [] |
|
517 |
for row in range(rowCount): |
|
518 |
uidList.append(equipTable.item(row, 0).text()) |
|
519 |
|
|
520 |
for uid in self.sceneEquipData.keys(): |
|
521 |
equipData = self.sceneEquipData[uid] |
|
522 |
# 중복 (어떻게 할지) |
|
523 |
if uidList.count(uid) >= 1: |
|
524 |
rowIndex = uidList.index(uid) |
|
525 |
|
|
526 |
for index in range(len(equipData)): |
|
527 |
if str(equipData[index]): |
|
528 |
oldData = equipTable.item(rowIndex, index).text() |
|
529 |
if oldData != equipData[index]: |
|
530 |
equipTable.item(rowIndex, index).setText(equipData[index]) |
|
531 |
equipTable.item(rowIndex, index).setBackground(QColor(int(134), int(229), int(127))) |
|
532 |
# 신규 |
|
533 |
else: |
|
534 |
rowCount += 1 |
|
535 |
equipTable.setRowCount(rowCount) |
|
536 |
|
|
537 |
for index in range(len(equipData)): |
|
538 |
item = QTableWidgetItem(str(equipData[index]) if equipData[index] is not None else '') |
|
539 |
item.setFlags(Qt.ItemIsEnabled) |
|
540 |
if item.text() != '': |
|
541 |
item.setBackground(QColor(int(134), int(229), int(127))) |
|
542 |
equipTable.setItem(rowCount - 1, index, item) |
|
543 |
''' |
|
544 | 465 |
except Exception as ex: |
545 | 466 |
from App import App |
546 | 467 |
from AppDocData import MessageType |
... | ... | |
612 | 533 |
item.setFlags(Qt.ItemIsEnabled) |
613 | 534 |
instTable.setItem(row, dataIndex, item) |
614 | 535 |
row += 1 |
615 |
''' |
|
616 |
# 현재 문서명이 같으면 중복 체크 (Inst 경우 uid로) |
|
617 |
if docData.imgName is not None and (docData.imgName == text or self.ui.comboBoxDoc.currentIndex() == 0): |
|
618 |
rowCount = instTable.rowCount() |
|
619 |
uidList = [] |
|
620 |
for row in range(rowCount): |
|
621 |
uidList.append(instTable.item(row, 0).text()) |
|
622 |
|
|
623 |
for uid in self.sceneInstData.keys(): |
|
624 |
instData = self.sceneInstData[uid] |
|
625 |
# 중복 (어떻게 할지) |
|
626 |
if uidList.count(uid) >= 1: |
|
627 |
rowIndex = uidList.index(uid) |
|
628 |
|
|
629 |
for index in range(len(instData)): |
|
630 |
if str(instData[index]): |
|
631 |
oldData = instTable.item(rowIndex, index).text() |
|
632 |
if oldData != instData[index]: |
|
633 |
instTable.item(rowIndex, index).setText(instData[index]) |
|
634 |
instTable.item(rowIndex, index).setBackground(QColor(int(134), int(229), int(127))) |
|
635 |
|
|
636 |
# 신규 |
|
637 |
else: |
|
638 |
rowCount += 1 |
|
639 |
instTable.setRowCount(rowCount) |
|
640 |
|
|
641 |
for index in range(len(instData)): |
|
642 |
item = QTableWidgetItem(str(instData[index]) if instData[index] is not None else '') |
|
643 |
item.setFlags(Qt.ItemIsEnabled) |
|
644 |
if item.text() != '': |
|
645 |
item.setBackground(QColor(int(134), int(229), int(127))) |
|
646 |
instTable.setItem(rowCount - 1, index, item) |
|
647 |
''' |
|
648 | 536 |
|
649 | 537 |
''' |
650 | 538 |
@brief setting note data |
... | ... | |
670 | 558 |
item.setFlags(Qt.ItemIsEnabled) |
671 | 559 |
noteTable.setItem(row, dataIndex, item) |
672 | 560 |
row += 1 |
673 |
''' |
|
674 |
# 현재 문서명이 같으면 중복 체크 (Note 경우 uid로) |
|
675 |
if docData.imgName is not None and (docData.imgName == text or self.ui.comboBoxDoc.currentIndex() == 0): |
|
676 |
rowCount = noteTable.rowCount() |
|
677 |
uidList = [] |
|
678 |
for row in range(rowCount): |
|
679 |
uidList.append(noteTable.item(row, 0).text()) |
|
680 |
|
|
681 |
for uid in self.sceneNoteData.keys(): |
|
682 |
noteData = self.sceneNoteData[uid] |
|
683 |
# 중복 (어떻게 할지) |
|
684 |
if uidList.count(uid) >= 1: |
|
685 |
rowIndex = uidList.index(uid) |
|
686 |
|
|
687 |
for index in range(len(noteData)): |
|
688 |
if str(noteData[index]): |
|
689 |
oldData = noteTable.item(rowIndex, index).text() |
|
690 |
if oldData != noteData[index]: |
|
691 |
noteTable.item(rowIndex, index).setText(noteData[index]) |
|
692 |
noteTable.item(rowIndex, index).setBackground(QColor(int(134), int(229), int(127))) |
|
693 |
|
|
694 |
# 신규 |
|
695 |
else: |
|
696 |
rowCount += 1 |
|
697 |
noteTable.setRowCount(rowCount) |
|
698 | 561 |
|
699 |
for index in range(len(noteData)): |
|
700 |
item = QTableWidgetItem(str(noteData[index]) if noteData[index] is not None else '') |
|
701 |
item.setFlags(Qt.ItemIsEnabled) |
|
702 |
if item.text() != '': |
|
703 |
item.setBackground(QColor(int(134), int(229), int(127))) |
|
704 |
noteTable.setItem(rowCount - 1, index, item) |
|
705 |
''' |
|
562 |
def fill_special_items(self): |
|
563 |
""" fill table widget with special items """ |
|
564 |
|
|
565 |
app_doc_data = AppDocData.instance() |
|
566 |
special_items = app_doc_data.get_special_items() |
|
567 |
merged_special_items = [] |
|
568 |
for item in special_items: |
|
569 |
matches = [merged for merged in merged_special_items if merged['Line No'] == item[0]] |
|
570 |
if matches: |
|
571 |
matches[item[1]] = 'O' |
|
572 |
else: |
|
573 |
merged_special_items.append({'Line No':item[0], item[1]:'O'}) |
|
574 |
|
|
575 |
self.ui.tableWidgetSpecialItems.setRowCount(len(merged_special_items)) |
|
576 |
|
|
577 |
row = 0 |
|
578 |
for item in merged_special_items: |
|
579 |
for col in range(self.ui.tableWidgetSpecialItems.columnCount()): |
|
580 |
if self.ui.tableWidgetSpecialItems.isColumnHidden(col): continue |
|
581 |
col_name = self.ui.tableWidgetSpecialItems.horizontalHeaderItem(col).text() |
|
582 |
widget_item = QTableWidgetItem(item[col_name]) if col_name in item.keys() else QTableWidgetItem('X') |
|
583 |
widget_item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter) |
|
584 |
widget_item.setFlags(Qt.ItemIsEnabled) |
|
585 |
self.ui.tableWidgetSpecialItems.setItem(row, col, widget_item) |
|
586 |
row += 1 |
|
706 | 587 |
|
707 | 588 |
def show_item_data_format_dialog(self): |
708 | 589 |
""" show item data format dialog """ |
... | ... | |
765 | 646 |
self.sceneNoteData[str(item.uid) + "-" + str(loopIndex)] = note |
766 | 647 |
loopIndex += 1 |
767 | 648 |
|
768 |
''' self.equipmentDataList |
|
769 |
@brief save Datas |
|
770 |
@author kyouho |
|
771 |
@date 2018.08.13 |
|
772 |
''' |
|
773 |
def accept(self): |
|
774 |
docData = AppDocData.instance() |
|
775 |
self.saveLineDataList() |
|
776 |
docData.deleteLineDataList(self.removeUID[0]) |
|
777 |
self.saveEquipmentDataList() |
|
778 |
docData.deleteEquipDataList(self.removeUID[1]) |
|
779 |
# sung |
|
780 |
#self.saveValveDataList() |
|
781 |
#docData.deleteValveDataList(self.removeUID[1]) |
|
782 |
self.saveInstrumentDataList() |
|
783 |
docData.deleteInstDataList(self.removeUID[2]) |
|
784 |
self.saveNoteDataList() |
|
785 |
docData.deleteNoteDataList(self.removeUID[3]) |
|
786 |
|
|
787 |
QDialog.accept(self) |
|
788 |
|
|
789 | 649 |
''' |
790 | 650 |
@brief save Line Data |
791 | 651 |
@author kyouho |
... | ... | |
902 | 762 |
@author kyouho |
903 | 763 |
@date 2018.08.13 |
904 | 764 |
''' |
765 |
""" |
|
905 | 766 |
def keyPressEvent(self, e): |
906 | 767 |
if e.key() == Qt.Key_Delete: |
907 | 768 |
_tabWidget = self.ui.tabWidget |
... | ... | |
938 | 799 |
uid = table.item(row, 0).text() |
939 | 800 |
self.removeUID[currentTabIndex].append(uid) |
940 | 801 |
model.removeRow(row) |
802 |
""" |
DTI_PID/DTI_PID/Shapes/EngineeringLineNoTextItem.py | ||
---|---|---|
571 | 571 |
|
572 | 572 |
app_doc_data = AppDocData.instance() |
573 | 573 |
|
574 |
cols = ['UID', 'Drawings_UID', 'Symbol_UID', 'X', 'Y', 'Width', 'Height', 'Rotation', 'Connected'] |
|
574 |
cols = ['UID', 'Drawings_UID', 'Symbol_UID', 'X', 'Y', 'Width', 'Height', 'Rotation', 'Value', 'Connected']
|
|
575 | 575 |
rect = self.sceneBoundingRect() |
576 |
values = ['?', '?', "(select UID from Symbol where Name='Line NO' and SymbolType_UID='-1')", '?', '?', '?', '?', '?', '?'] |
|
576 |
values = ['?', '?', "(select UID from Symbol where Name='Line NO' and SymbolType_UID='-1')", '?', '?', '?', '?', '?', '?', '?']
|
|
577 | 577 |
params = [str(self.uid), str(app_doc_data.activeDrawing.UID), str(rect.x()), str(rect.y()), str(rect.width()), str(rect.height()), str(self.angle),\ |
578 |
self.text(),\ |
|
578 | 579 |
str(self.conns[0]) if self.conns else None] |
579 | 580 |
sql = 'insert or replace into Components({}) values({})'.format(','.join(cols), ','.join(values)) |
580 | 581 |
res.append((sql, tuple(params))) |
내보내기 Unified diff