개정판 5b34bdef
issue #665: 리스트 양식 설정
Change-Id: Ibc68c12ffe4ccc44a00282233a39691c67fe48d9
DTI_PID/DTI_PID/AppDocData.py | ||
---|---|---|
923 | 923 |
|
924 | 924 |
# Creates or opens a file called mydb with a SQLite3 DB |
925 | 925 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), AppDocData.DATABASE) |
926 |
db = sqlite3.connect(dbPath) |
|
927 |
# Get a cursor object |
|
928 |
cursor = db.cursor() |
|
926 |
conn = sqlite3.connect(dbPath) |
|
927 |
with conn: |
|
928 |
# Get a cursor object |
|
929 |
cursor = conn.cursor() |
|
929 | 930 |
|
930 |
sql = "select UID, Name, DisplayName, Type, LimitNumber, [index] from LineProperties order by [index]" |
|
931 |
cursor.execute(sql) |
|
932 |
rows = cursor.fetchall() |
|
933 |
for row in rows: |
|
934 |
attr = SymbolAttr() |
|
935 |
attr.UID = row[0] |
|
936 |
attr.Attribute = row[1] |
|
937 |
attr.DisplayAttribute = row[2] |
|
938 |
attr.AttributeType = row[3] |
|
939 |
attr.Length = row[4] |
|
940 |
self._lineNoProperties.append(attr) |
|
931 |
sql = "select UID, Name, DisplayName, Type, LimitNumber, [index] from LineProperties order by [index]"
|
|
932 |
cursor.execute(sql)
|
|
933 |
rows = cursor.fetchall()
|
|
934 |
for row in rows:
|
|
935 |
attr = SymbolAttr()
|
|
936 |
attr.UID = row[0]
|
|
937 |
attr.Attribute = row[1]
|
|
938 |
attr.DisplayAttribute = row[2]
|
|
939 |
attr.AttributeType = row[3]
|
|
940 |
attr.Length = row[4]
|
|
941 |
self._lineNoProperties.append(attr)
|
|
941 | 942 |
|
942 | 943 |
res = self._lineNoProperties |
943 | 944 |
# Catch the exception |
944 | 945 |
except Exception as ex: |
945 | 946 |
# Roll back any change if something goes wrong |
946 |
db.rollback()
|
|
947 |
conn.rollback()
|
|
947 | 948 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
948 |
finally: |
|
949 |
# Close the db connection |
|
950 |
db.close() |
|
951 | 949 |
else: |
952 | 950 |
res = self._lineNoProperties |
953 | 951 |
|
... | ... | |
2077 | 2075 |
# Creates or opens a file called mydb with a SQLite3 DB |
2078 | 2076 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), AppDocData.DATABASE) |
2079 | 2077 |
conn = sqlite3.connect(dbPath) |
2080 |
# Get a cursor object |
|
2081 |
cursor = conn.cursor() |
|
2078 |
with conn: |
|
2079 |
# Get a cursor object |
|
2080 |
cursor = conn.cursor() |
|
2082 | 2081 |
|
2083 |
sql = 'delete from LineProperties' |
|
2084 |
cursor.execute(sql) |
|
2082 |
sql = 'delete from LineProperties'
|
|
2083 |
cursor.execute(sql)
|
|
2085 | 2084 |
|
2086 |
for attr in attrs: |
|
2087 |
sql = 'insert into LineProperties(UID, Name, DisplayName, Type, LimitNumber, [index]) values(?, ?, ?, ?, ?, ?)' |
|
2088 |
param = tuple(attr) |
|
2089 |
cursor.execute(sql, param) |
|
2085 |
for attr in attrs:
|
|
2086 |
sql = 'insert into LineProperties(UID, Name, DisplayName, Type, LimitNumber, [index]) values(?, ?, ?, ?, ?, ?)'
|
|
2087 |
param = tuple(attr)
|
|
2088 |
cursor.execute(sql, param)
|
|
2090 | 2089 |
|
2091 |
conn.commit() |
|
2090 |
conn.commit()
|
|
2092 | 2091 |
|
2093 |
self._lineNoProperties = None |
|
2092 |
self._lineNoProperties = None
|
|
2094 | 2093 |
# Catch the exception |
2095 | 2094 |
except Exception as ex: |
2096 | 2095 |
# Roll back any change if something goes wrong |
... | ... | |
2099 | 2098 |
from App import App |
2100 | 2099 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
2101 | 2100 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
2102 |
finally: |
|
2103 |
# Close the db connection |
|
2104 |
conn.close() |
|
2105 | 2101 |
|
2106 | 2102 |
''' |
2107 | 2103 |
@brief get symbol type id |
... | ... | |
2414 | 2410 |
# Creates or opens a file called mydb with a SQLite3 DB |
2415 | 2411 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), AppDocData.DATABASE) |
2416 | 2412 |
conn = sqlite3.connect(dbPath) |
2417 |
# Get a cursor object |
|
2418 |
cursor = conn.cursor() |
|
2413 |
with conn: |
|
2414 |
# Get a cursor object |
|
2415 |
cursor = conn.cursor() |
|
2419 | 2416 |
|
2420 |
sql = 'select UID, LINE_SIZE, LINE_SYMBOL, LINE_NO, LINE_CLASS, LINE_ROUTING_FROM, LINE_ROUTING_TO, SERVICE_FLUID, SERVICE_DENSITY, SERVICE_STATE, OPERATION_CONDITION_TEMP, OPERATION_CONDITION_PRESS, DESIGN_CONDITION_TEMP, DESIGN_CONDITION_PRESS, TEST_CONDITION_TEMP, TEST_CONDITION_PRESS, INSUL_CODE, PAINT_CODE, NDE_CODE, PWHT, PNID_NO from LINE_DATA_LIST' |
|
2421 |
if docName is not None: |
|
2422 |
sql += " where PNID_NO = '{}'".format(docName) |
|
2417 |
#sql = "delete from Ports where Components_UID in (select UID from Components where Drawings_UID = (select UID from Drawings where Name= '{}'))".format(pidNo) |
|
2423 | 2418 |
|
2424 |
cursor.execute(sql) |
|
2425 |
#columnName = list(map(lambda x: x[0].upper(), cursor.description)) |
|
2426 |
rows = cursor.fetchall() |
|
2427 |
for row in rows: |
|
2428 |
data = [] |
|
2429 |
for index in range(len(cursor.description)): |
|
2430 |
data.append(row[index]) |
|
2431 |
result.append(data) |
|
2432 |
# Catch the exception |
|
2419 |
sql = 'select A.UID,B.Name from Components A left join Drawings B on A.Drawings_UID=B.UID' |
|
2420 |
if docName is not None: |
|
2421 |
sql += " where Drawings_UID=(select UID from Drawings where Name='{}')".format(docName) |
|
2422 |
cursor.execute(sql) |
|
2423 |
comps = [(row[0],row[1]) for row in cursor.fetchall()] |
|
2424 |
for comp in comps: |
|
2425 |
sql = "select b.Name,a.Value from LineNoAttributes a left join LineProperties b on a.LineProperties_UID=b.UID where a.Components_UID='{}'".format(comp[0]) |
|
2426 |
cursor.execute(sql) |
|
2427 |
attrs = cursor.fetchall() |
|
2428 |
data = [] |
|
2429 |
for attr in attrs: |
|
2430 |
data.append([attr[0], attr[1]]) |
|
2431 |
if data: |
|
2432 |
data.insert(0, ['Drawing Name', comp[1]]) |
|
2433 |
data.insert(0, ['UID', comp[0]]) |
|
2434 |
result.append(data) |
|
2435 |
|
|
2436 |
# catch the exception |
|
2433 | 2437 |
except Exception as ex: |
2434 | 2438 |
# Roll back any change if something goes wrong |
2435 | 2439 |
conn.rollback() |
2436 | 2440 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
2437 |
finally: |
|
2438 |
# Close the db connection |
|
2439 |
conn.close() |
|
2440 | 2441 |
|
2441 | 2442 |
return result |
2442 | 2443 |
|
... | ... | |
2788 | 2789 |
# Creates or opens a file called mydb with a SQLite3 DB |
2789 | 2790 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), AppDocData.DATABASE) |
2790 | 2791 |
conn = sqlite3.connect(dbPath, isolation_level=None) |
2791 |
# Get a cursor object |
|
2792 |
cursor = conn.cursor() |
|
2792 |
with conn: |
|
2793 |
# Get a cursor object |
|
2794 |
cursor = conn.cursor() |
|
2793 | 2795 |
|
2794 |
# delete all datas of current drawing |
|
2795 |
pidNo = self.activeDrawing.name |
|
2796 |
sql = "delete from LINE_DATA_LIST where PNID_NO = '{}'".format(pidNo) |
|
2797 |
cursor.execute(sql) |
|
2798 |
sql = "delete from EQUIPMENT_DATA_LIST where PNID_NO = '{}'".format(pidNo) |
|
2799 |
cursor.execute(sql) |
|
2800 |
sql = "delete from VALVE_DATA_LIST where PNID_NO = '{}'".format(pidNo) |
|
2801 |
cursor.execute(sql) |
|
2802 |
sql = "delete from INSTRUMENT_DATA_LIST where PNID_NO = '{}'".format(pidNo) |
|
2803 |
cursor.execute(sql) |
|
2804 |
sql = "delete from NOTE_DATA_LIST where PNID_NO = '{}'".format(pidNo) |
|
2805 |
cursor.execute(sql) |
|
2806 |
sql = "delete from TitleBlockValues where Drawings_UID = '{}'".format(pidNo) |
|
2807 |
cursor.execute(sql) |
|
2796 |
# delete all datas of current drawing
|
|
2797 |
pidNo = self.activeDrawing.name
|
|
2798 |
sql = "delete from LINE_DATA_LIST where PNID_NO = '{}'".format(pidNo)
|
|
2799 |
cursor.execute(sql)
|
|
2800 |
sql = "delete from EQUIPMENT_DATA_LIST where PNID_NO = '{}'".format(pidNo)
|
|
2801 |
cursor.execute(sql)
|
|
2802 |
sql = "delete from VALVE_DATA_LIST where PNID_NO = '{}'".format(pidNo)
|
|
2803 |
cursor.execute(sql)
|
|
2804 |
sql = "delete from INSTRUMENT_DATA_LIST where PNID_NO = '{}'".format(pidNo)
|
|
2805 |
cursor.execute(sql)
|
|
2806 |
sql = "delete from NOTE_DATA_LIST where PNID_NO = '{}'".format(pidNo)
|
|
2807 |
cursor.execute(sql)
|
|
2808 |
sql = "delete from TitleBlockValues where Drawings_UID = '{}'".format(pidNo)
|
|
2809 |
cursor.execute(sql)
|
|
2808 | 2810 |
|
2809 |
# delete ports |
|
2810 |
sql = "delete from Ports where Components_UID in (select UID from Components where Drawings_UID = (select UID from Drawings where Name= '{}'))".format(pidNo) |
|
2811 |
cursor.execute(sql) |
|
2811 |
# delete ports
|
|
2812 |
sql = "delete from Ports where Components_UID in (select UID from Components where Drawings_UID = (select UID from Drawings where Name= '{}'))".format(pidNo)
|
|
2813 |
cursor.execute(sql)
|
|
2812 | 2814 |
|
2813 |
# delete Attributes |
|
2814 |
sql = "delete from Attributes where Components_UID in (select UID from Components where Drawings_UID = (select UID from Drawings where Name= '{}'))".format(pidNo) |
|
2815 |
cursor.execute(sql) |
|
2815 |
# delete Attributes
|
|
2816 |
sql = "delete from Attributes where Components_UID in (select UID from Components where Drawings_UID = (select UID from Drawings where Name= '{}'))".format(pidNo)
|
|
2817 |
cursor.execute(sql)
|
|
2816 | 2818 |
|
2817 |
# delete Components |
|
2818 |
sql = "delete from Components where Drawings_UID = (select UID from Drawings where Name= '{}')".format(pidNo) |
|
2819 |
cursor.execute(sql) |
|
2819 |
# delete Components
|
|
2820 |
sql = "delete from Components where Drawings_UID = (select UID from Drawings where Name= '{}')".format(pidNo)
|
|
2821 |
cursor.execute(sql)
|
|
2820 | 2822 |
|
2821 |
# delete Vendor Package |
|
2822 |
sql = "delete from VendorPackages where Drawings_UID = '{}'".format(pidNo) |
|
2823 |
cursor.execute(sql) |
|
2823 |
# delete Vendor Package
|
|
2824 |
sql = "delete from VendorPackages where Drawings_UID = '{}'".format(pidNo)
|
|
2825 |
cursor.execute(sql)
|
|
2824 | 2826 |
|
2825 |
for item in items: |
|
2826 |
sql = item.toSql() |
|
2827 |
if type(sql) is list: |
|
2828 |
for item in sql: |
|
2829 |
if item is not None and 2 == len(item): |
|
2830 |
cursor.execute(item[0], item[1]) |
|
2831 |
else: |
|
2832 |
if sql is not None and 2 == len(sql): |
|
2833 |
cursor.execute(sql[0], sql[1]) |
|
2827 |
for item in items:
|
|
2828 |
sql = item.toSql()
|
|
2829 |
if type(sql) is list:
|
|
2830 |
for item in sql:
|
|
2831 |
if item is not None and 2 == len(item):
|
|
2832 |
cursor.execute(item[0], item[1])
|
|
2833 |
else:
|
|
2834 |
if sql is not None and 2 == len(sql):
|
|
2835 |
cursor.execute(sql[0], sql[1])
|
|
2834 | 2836 |
|
2835 |
conn.commit() |
|
2837 |
conn.commit()
|
|
2836 | 2838 |
# Catch the exception |
2837 | 2839 |
except Exception as ex: |
2838 | 2840 |
from App import App |
... | ... | |
2842 | 2844 |
print(sql) |
2843 | 2845 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
2844 | 2846 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
2845 |
finally: |
|
2846 |
# Close the db connection |
|
2847 |
conn.close() |
|
2848 | 2847 |
|
2849 | 2848 |
''' |
2850 | 2849 |
@brief set equipment data list |
... | ... | |
3146 | 3145 |
self._activeDrawing = value |
3147 | 3146 |
|
3148 | 3147 |
def getColNames(self, table): |
3149 |
""" |
|
3150 |
return column names of given table and attribute names if tabe is VALVE_DATA_LIST or EQUIPMET_DATA_LIST |
|
3151 |
""" |
|
3148 |
""" return column names of given table and attribute names if tabe is VALVE_DATA_LIST or EQUIPMET_DATA_LIST """ |
|
3152 | 3149 |
res = None |
3153 | 3150 |
try: |
3154 | 3151 |
# Creates or opens a file called mydb with a SQLite3 DB |
DTI_PID/DTI_PID/ItemDataExportDialog.py | ||
---|---|---|
1 | 1 |
# coding: utf-8 |
2 |
""" |
|
3 |
This is ItemDataExportDialog module |
|
4 |
""" |
|
2 |
""" This is ItemDataExportDialog module """ |
|
5 | 3 |
|
6 | 4 |
import os |
7 | 5 |
import sys |
... | ... | |
18 | 16 |
dbListOrderName = ['LINE_DATA_LIST_EXPORT_ORDER', 'EQUIPMENT_DATA_LIST_EXPORT_ORDER', 'VALVE_DATA_LIST_EXPORT_ORDER', 'INSTRUMENT_DATA_LIST_EXPORT_ORDER', 'NOTE_DATA_LIST_EXPORT_ORDER'] |
19 | 17 |
|
20 | 18 |
class QItemDataExportDialog(QDialog): |
21 |
""" |
|
22 |
This is QItemDataExportDialog class |
|
23 |
""" |
|
19 |
""" This is QItemDataExportDialog class """ |
|
20 |
|
|
21 |
DATA_LIST = ['LINE_DATA_LIST', 'EQUIPMENT_DATA_LIST', 'VALVE_DATA_LIST', 'INSTRUMENT_DATA_LIST', 'NOTE_DATA_LIST'] |
|
22 |
|
|
24 | 23 |
def __init__(self, parent): |
25 | 24 |
QDialog.__init__(self, parent) |
26 | 25 |
self.setWindowFlag(Qt.WindowMinMaxButtonsHint) |
... | ... | |
28 | 27 |
try: |
29 | 28 |
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) |
30 | 29 |
|
31 |
self.columnListAll = [] |
|
32 |
self.columnOrder = [] |
|
33 |
self.viewTables = [] |
|
34 |
|
|
35 | 30 |
self.delimiter = '!-!' |
36 | 31 |
self.delimiterCombine = '!@!' |
37 | 32 |
self.emptyCol = 'Empty Column' |
... | ... | |
48 | 43 |
self.valveColumnListAll = [] |
49 | 44 |
self.instColumnListAll = [] |
50 | 45 |
self.noteColumnListAll = [] |
51 |
self.columnListAll.append(self.lineColumnListAll) |
|
52 |
self.columnListAll.append(self.equipColumnListAll) |
|
53 |
self.columnListAll.append(self.valveColumnListAll) |
|
54 |
self.columnListAll.append(self.instColumnListAll) |
|
55 |
self.columnListAll.append(self.noteColumnListAll) |
|
46 |
self.columnListAll = \ |
|
47 |
{ |
|
48 |
QItemDataExportDialog.DATA_LIST[0]:self.lineColumnListAll, |
|
49 |
QItemDataExportDialog.DATA_LIST[1]:self.equipColumnListAll, |
|
50 |
QItemDataExportDialog.DATA_LIST[2]:self.valveColumnListAll, |
|
51 |
QItemDataExportDialog.DATA_LIST[3]:self.instColumnListAll, |
|
52 |
QItemDataExportDialog.DATA_LIST[4]:self.noteColumnListAll |
|
53 |
} |
|
56 | 54 |
|
57 | 55 |
self.lineOrder = [] |
58 | 56 |
self.equipOrder = [] |
59 | 57 |
self.valveOrder = [] |
60 | 58 |
self.instOrder = [] |
61 | 59 |
self.noteOrder = [] |
62 |
self.columnOrder.append(self.lineOrder) |
|
63 |
self.columnOrder.append(self.equipOrder) |
|
64 |
self.columnOrder.append(self.valveOrder) |
|
65 |
self.columnOrder.append(self.instOrder) |
|
66 |
self.columnOrder.append(self.noteOrder) |
|
60 |
self.columnOrder = \ |
|
61 |
{ |
|
62 |
QItemDataExportDialog.DATA_LIST[0]:self.lineOrder, |
|
63 |
QItemDataExportDialog.DATA_LIST[1]:self.equipOrder, |
|
64 |
QItemDataExportDialog.DATA_LIST[2]:self.valveOrder, |
|
65 |
QItemDataExportDialog.DATA_LIST[3]:self.instOrder, |
|
66 |
QItemDataExportDialog.DATA_LIST[4]:self.noteOrder |
|
67 |
} |
|
67 | 68 |
|
68 | 69 |
self.removeUID = [[], [], [], [], []] |
69 | 70 |
|
... | ... | |
86 | 87 |
|
87 | 88 |
try: |
88 | 89 |
self.initComboBox() |
89 |
self.viewTables.append(self.ui.tableWidgetLineDataList) |
|
90 |
self.viewTables.append(self.ui.tableWidgetEquipmentDataList) |
|
91 |
self.viewTables.append(self.ui.tableWidgetValveDataList) |
|
92 |
self.viewTables.append(self.ui.tableWidgetInstrumentDataList) |
|
93 |
self.viewTables.append(self.ui.tableWidgetNoteDataList) |
|
90 |
self.viewTables = \ |
|
91 |
{ |
|
92 |
QItemDataExportDialog.DATA_LIST[0]:self.ui.tableWidgetLineDataList, |
|
93 |
QItemDataExportDialog.DATA_LIST[1]:self.ui.tableWidgetEquipmentDataList, |
|
94 |
QItemDataExportDialog.DATA_LIST[2]:self.ui.tableWidgetValveDataList, |
|
95 |
QItemDataExportDialog.DATA_LIST[3]:self.ui.tableWidgetInstrumentDataList, |
|
96 |
QItemDataExportDialog.DATA_LIST[4]:self.ui.tableWidgetNoteDataList |
|
97 |
} |
|
94 | 98 |
self.initTableWidget() |
95 | 99 |
except Exception as ex: |
96 | 100 |
from App import App |
... | ... | |
336 | 340 |
''' |
337 | 341 |
def initTableWidget(self): |
338 | 342 |
docData = AppDocData.instance() |
339 |
self.columnListAll = [] |
|
340 |
self.lineColumnListAll = docData.getColNames('LINE_DATA_LIST') |
|
341 |
self.equipColumnListAll = docData.getColNames('EQUIPMENT_DATA_LIST') |
|
342 |
self.valveColumnListAll = docData.getColNames('VALVE_DATA_LIST') |
|
343 |
self.instColumnListAll = docData.getColNames('INSTRUMENT_DATA_LIST') |
|
344 |
self.noteColumnListAll = docData.getColNames('NOTE_DATA_LIST') |
|
345 |
self.columnListAll.append(self.lineColumnListAll) |
|
346 |
self.columnListAll.append(self.equipColumnListAll) |
|
347 |
self.columnListAll.append(self.valveColumnListAll) |
|
348 |
self.columnListAll.append(self.instColumnListAll) |
|
349 |
self.columnListAll.append(self.noteColumnListAll) |
|
343 |
self.lineColumnListAll = ['UID', 'Drawing Name'] |
|
344 |
self.lineColumnListAll.extend([prop.Attribute for prop in docData.getLineProperties()]) |
|
345 |
self.equipColumnListAll = docData.getColNames(QItemDataExportDialog.DATA_LIST[1]) |
|
346 |
self.valveColumnListAll = docData.getColNames(QItemDataExportDialog.DATA_LIST[2]) |
|
347 |
self.instColumnListAll = docData.getColNames(QItemDataExportDialog.DATA_LIST[3]) |
|
348 |
self.noteColumnListAll = docData.getColNames(QItemDataExportDialog.DATA_LIST[4]) |
|
349 |
|
|
350 |
self.columnListAll.clear() |
|
351 |
self.columnListAll[QItemDataExportDialog.DATA_LIST[0]] = self.lineColumnListAll |
|
352 |
self.columnListAll[QItemDataExportDialog.DATA_LIST[1]] = self.equipColumnListAll |
|
353 |
self.columnListAll[QItemDataExportDialog.DATA_LIST[2]] = self.valveColumnListAll |
|
354 |
self.columnListAll[QItemDataExportDialog.DATA_LIST[3]] = self.instColumnListAll |
|
355 |
self.columnListAll[QItemDataExportDialog.DATA_LIST[4]] = self.noteColumnListAll |
|
350 | 356 |
# 엑셀 추출시 사용할 리스트 오더를 db에서 읽거나 없으면 db에 추가 |
351 | 357 |
try: |
352 | 358 |
configs = [] |
353 |
for orderIndex in range(len(self.columnOrder)): |
|
354 |
self.columnOrder[orderIndex] = docData.getConfigs(dbListOrderName[orderIndex], str(orderIndex)) |
|
355 |
if len(self.columnOrder[orderIndex]) is 0: |
|
356 |
value = '' |
|
357 |
for header in self.columnListAll[orderIndex]: |
|
358 |
value += (header + self.delimiterCombine + header + self.delimiter) |
|
359 |
value = value[:-len(self.delimiter)] |
|
360 |
configs.append(Config(dbListOrderName[orderIndex], str(orderIndex), value)) |
|
359 |
for data in QItemDataExportDialog.DATA_LIST: |
|
360 |
self.columnOrder[data] = docData.getConfigs('Order', data) |
|
361 |
if len(self.columnOrder[data]) is 0: ### use column name if setting does not exit |
|
362 |
if data == 'LINE_DATA_LIST': |
|
363 |
value = '' |
|
364 |
for prop in docData.getLineProperties(): |
|
365 |
value += (prop.Attribute + self.delimiterCombine + prop.Attribute + self.delimiter) |
|
366 |
value = value[:-len(self.delimiter)] |
|
367 |
configs.append(Config('Order', data, value)) |
|
368 |
else: |
|
369 |
value = '' |
|
370 |
for col in docData.getColNames(data): |
|
371 |
value += (col + self.delimiterCombine + col + self.delimiter) |
|
372 |
value = value[:-len(self.delimiter)] |
|
373 |
configs.append(Config('Order', data, value)) |
|
361 | 374 |
|
362 | 375 |
docData.saveConfigs(configs) |
363 | 376 |
|
... | ... | |
370 | 383 |
return None |
371 | 384 |
|
372 | 385 |
try: |
373 |
for tableIndex in range(len(self.viewTables)):
|
|
386 |
for key in self.viewTables.keys():
|
|
374 | 387 |
# set table column count |
375 |
self.viewTables[tableIndex].setColumnCount(len(self.columnListAll[tableIndex]))
|
|
388 |
self.viewTables[key].setColumnCount(len(self.columnListAll[key]))
|
|
376 | 389 |
# Table Header Label 설정 |
377 |
self.viewTables[tableIndex].setHorizontalHeaderLabels(self.columnListAll[tableIndex])
|
|
390 |
self.viewTables[key].setHorizontalHeaderLabels(self.columnListAll[key])
|
|
378 | 391 |
# Table Header 크기 설정 |
379 |
for listIndex in range(len(self.columnListAll[tableIndex])):
|
|
380 |
self.viewTables[tableIndex].horizontalHeaderItem(listIndex).setSizeHint(QSize(25, 25))
|
|
381 |
self.viewTables[tableIndex].setColumnWidth(listIndex, len(self.columnListAll[tableIndex][listIndex]) * 8 + 10)
|
|
392 |
for col in range(len(self.columnListAll[key])):
|
|
393 |
self.viewTables[key].horizontalHeaderItem(col).setSizeHint(QSize(25, 25))
|
|
394 |
self.viewTables[key].setColumnWidth(col, len(self.columnListAll[key][col]) * 8 + 10)
|
|
382 | 395 |
# UID column hide |
383 |
self.viewTables[tableIndex].hideColumn(0)
|
|
396 |
self.viewTables[key].hideColumn(0)
|
|
384 | 397 |
|
385 | 398 |
# talbe Data 설정 |
386 | 399 |
self.settingLineData() |
... | ... | |
389 | 402 |
self.settingInstrumentData() |
390 | 403 |
self.settingNoteData() |
391 | 404 |
|
392 |
#for table in self.viewTables: |
|
393 |
# self.initialTables.append(table.horizontalHeader().saveState()) |
|
394 |
|
|
395 | 405 |
self.sortListOrder() |
396 | 406 |
except Exception as ex: |
397 | 407 |
from App import App |
... | ... | |
401 | 411 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
402 | 412 |
|
403 | 413 |
''' |
404 |
@brief sort list view with db |
|
405 |
@author euisung |
|
406 |
@date 2018.10.24 |
|
407 |
@history 2018.10.29 euisung no more used |
|
408 |
2018.10.31 euisung use modified |
|
414 |
@brief sort columns |
|
415 |
@author humkyung |
|
409 | 416 |
''' |
410 | 417 |
def sortListOrder(self): |
411 | 418 |
try: |
412 | 419 |
docData = AppDocData.instance() |
413 | 420 |
|
414 |
for index in range(len(self.viewTables)): |
|
415 |
self.viewTables[index].setColumnCount(len(self.columnListAll[index])) |
|
416 |
self.viewTables[index].setHorizontalHeaderLabels(self.columnListAll[index]) |
|
417 |
#self.viewTables[index].horizontalHeader().restoreState(self.initialTables[index]) |
|
418 |
self.columnOrder[index] = docData.getConfigs(dbListOrderName[index], str(index))[0].value.split(self.delimiter) |
|
419 |
withoutEmpty = [] |
|
420 |
emptys = [] |
|
421 |
emptysUserHeader = [] |
|
422 |
for col in range(len(self.columnOrder[index])): |
|
423 |
if self.columnOrder[index][col].split(self.delimiterCombine)[0] == self.emptyCol: |
|
424 |
emptys.append(col) |
|
425 |
emptysUserHeader.append(self.columnOrder[index][col].split(self.delimiterCombine)[1]) |
|
426 |
else: |
|
427 |
withoutEmpty.append(self.columnOrder[index][col]) |
|
428 |
|
|
429 |
for reverse in range(len(withoutEmpty) - 1, 0, -1): |
|
430 |
targetCol = withoutEmpty[reverse].split(self.delimiterCombine)[0] |
|
431 |
targetUserHeader = withoutEmpty[reverse].split(self.delimiterCombine)[1] |
|
432 |
currentCol = [] |
|
433 |
for i in range(len(self.columnListAll[index])): |
|
434 |
currentCol.append(self.viewTables[index].horizontalHeader().visualIndex(i)) |
|
435 |
|
|
436 |
for columnNum in range(len(self.columnListAll[index])): |
|
437 |
if targetCol == self.columnListAll[index][columnNum]: |
|
438 |
self.viewTables[index].horizontalHeader().moveSection(currentCol[columnNum], 1) |
|
439 |
self.viewTables[index].horizontalHeaderItem(columnNum).setText(targetUserHeader) |
|
440 |
break |
|
441 |
|
|
442 |
for unvisibleCol in range(len(self.columnListAll[index])): |
|
443 |
self.viewTables[index].hideColumn(unvisibleCol) |
|
444 |
visibleCols = [] |
|
445 |
for visibleCol in range(1, len(withoutEmpty)): |
|
446 |
visibleCols.append(self.viewTables[index].horizontalHeader().logicalIndex(visibleCol)) |
|
447 |
for visibleCol in visibleCols: |
|
448 |
self.viewTables[index].showColumn(visibleCol) |
|
449 |
|
|
450 |
self.viewTables[index].setColumnCount(len(self.columnListAll[index]) + len(emptys)) |
|
451 |
for emp in range(len(emptys)): |
|
452 |
self.viewTables[index].horizontalHeader().moveSection(len(self.columnListAll[index]) + emp, emptys[emp]) |
|
453 |
self.viewTables[index].setHorizontalHeaderItem(len(self.columnListAll[index]) + emp, QTableWidgetItem(emptysUserHeader[emp])) |
|
421 |
for key in self.viewTables.keys(): |
|
422 |
headers = [] |
|
423 |
orders = docData.getConfigs('Order', key)[0].value.split(self.delimiter) |
|
424 |
for col in range(len(orders)): |
|
425 |
header = orders[col].split(self.delimiterCombine) |
|
426 |
headers.append(header) |
|
427 |
|
|
428 |
col = 0 |
|
429 |
for header in headers: |
|
430 |
matches = [index for index in range(self.viewTables[key].columnCount()) if header[0] == self.viewTables[key].horizontalHeaderItem(index).text()] |
|
431 |
if matches: |
|
432 |
_from = self.viewTables[key].horizontalHeader().visualIndex(matches[0]) |
|
433 |
self.viewTables[key].horizontalHeader().moveSection(_from, col) |
|
434 |
col = col + 1 |
|
454 | 435 |
except Exception as ex: |
455 | 436 |
from App import App |
456 | 437 |
from AppDocData import MessageType |
... | ... | |
468 | 449 |
docData = AppDocData.instance() |
469 | 450 |
# 기존 저장된 데이터 불러옴 |
470 | 451 |
index = self.ui.comboBoxDoc.currentIndex() |
471 |
text = self.ui.comboBoxDoc.itemText(index)
|
|
472 |
if self.ui.comboBoxDoc.currentIndex() == 0: |
|
473 |
text = None |
|
474 |
dataList = docData.getLineDataList(text)
|
|
452 |
drawing = self.ui.comboBoxDoc.itemText(index)
|
|
453 |
if self.ui.comboBoxDoc.currentIndex() == 0: drawing = None
|
|
454 |
|
|
455 |
dataList = docData.getLineDataList(drawing)
|
|
475 | 456 |
lineTable.setRowCount(len(dataList)) |
476 | 457 |
row = 0 |
477 | 458 |
for data in dataList: |
459 |
for col in range(self.ui.tableWidgetLineDataList.columnCount()): |
|
460 |
col_name = self.ui.tableWidgetLineDataList.horizontalHeaderItem(col).text() |
|
461 |
matches = [value for value in data if value[0] == col_name] |
|
462 |
if matches: |
|
463 |
item = QTableWidgetItem(matches[0][1] if matches[0][1] is not None else '') |
|
464 |
item.setFlags(Qt.ItemIsEnabled) |
|
465 |
lineTable.setItem(row, col, item) |
|
466 |
|
|
467 |
""" |
|
478 | 468 |
for dataIndex in range(len(data)): |
479 |
#self.lineNoTableComboBoxDic |
|
480 | 469 |
if dataIndex in self.lineNoTableComboBoxDic: |
481 | 470 |
tempList = self.lineNoTableComboBoxDic[dataIndex] |
482 | 471 |
comboBox = QComboBox() |
483 | 472 |
comboBox.setEnabled(False) |
484 | 473 |
for comboText in tempList: |
485 | 474 |
comboBox.addItem(comboText) |
486 |
tempIndex = comboBox.findText(data[dataIndex]) |
|
475 |
tempIndex = comboBox.findText(data[dataIndex][1])
|
|
487 | 476 |
comboBox.setCurrentIndex(tempIndex) |
488 | 477 |
lineTable.setCellWidget(row, dataIndex, comboBox) |
489 | 478 |
else: |
490 |
item = QTableWidgetItem(data[dataIndex] if data[dataIndex] is not None else '')
|
|
479 |
item = QTableWidgetItem(data[dataIndex][1] if data[dataIndex][1] is not None else '')
|
|
491 | 480 |
item.setFlags(Qt.ItemIsEnabled) |
492 | 481 |
lineTable.setItem(row, dataIndex, item) |
482 |
""" |
|
493 | 483 |
row += 1 |
494 |
''' |
|
495 |
# 현재 문서명이 같으면 중복 체크 (line 경우 lineNo로) |
|
496 |
if docData.imgName is not None and (docData.imgName == text or self.ui.comboBoxDoc.currentIndex() == 0): |
|
497 |
rowCount = lineTable.rowCount() |
|
498 |
lineNo = [] |
|
499 |
for row in range(rowCount): |
|
500 |
lineNo.append(lineTable.item(row, 3).text()) |
|
501 |
|
|
502 |
for line in self.sceneLineData.keys(): |
|
503 |
lineData = self.sceneLineData[line] |
|
504 |
# 중복 (어떻게 할지) |
|
505 |
if lineNo.count(line) >= 1: |
|
506 |
rowIndex = lineNo.index(line) |
|
507 |
|
|
508 |
for index in range(len(lineData)): |
|
509 |
if str(lineData[index]): |
|
510 |
if index in self.lineNoTableComboBoxDic: |
|
511 |
oldData = lineTable.cellWidget(rowIndex, index).currentText() |
|
512 |
if oldData != lineData[index]: |
|
513 |
tempIndex = lineTable.cellWidget(rowIndex, index).findText(lineData[index]) |
|
514 |
lineTable.cellWidget(rowIndex, index).setCurrentIndex(tempIndex) |
|
515 |
else: |
|
516 |
oldData = lineTable.item(rowIndex, index).text() |
|
517 |
if oldData != lineData[index]: |
|
518 |
lineTable.item(rowIndex, index).setText(lineData[index]) |
|
519 |
lineTable.item(rowIndex, index).setBackground(QColor(int(134), int(229), int(127))) |
|
520 |
# 신규 |
|
521 |
else: |
|
522 |
rowCount += 1 |
|
523 |
lineTable.setRowCount(rowCount) |
|
524 |
lineData[0] = '' |
|
525 |
|
|
526 |
for index in range(len(lineData)): |
|
527 |
if index in self.lineNoTableComboBoxDic: |
|
528 |
tempList = self.lineNoTableComboBoxDic[index] |
|
529 |
comboBox = QComboBox() |
|
530 |
comboBox.setEnabled(False) |
|
531 |
for comboText in tempList: |
|
532 |
comboBox.addItem(comboText) |
|
533 |
tempIndex = comboBox.findText(lineData[index]) |
|
534 |
comboBox.setCurrentIndex(tempIndex) |
|
535 |
lineTable.setCellWidget(rowCount - 1, index, comboBox) |
|
536 |
item = lineTable.item(rowCount - 1, index) |
|
537 |
if item is not None: |
|
538 |
lineTable.item(rowCount - 1, index).setFlags(Qt.ItemIsEnabled) |
|
539 |
else: |
|
540 |
item = QTableWidgetItem(lineData[index] if lineData[index] is not None else '') |
|
541 |
item.setFlags(Qt.ItemIsEnabled) |
|
542 |
if item.text() != '': |
|
543 |
item.setBackground(QColor(int(134), int(229), int(127))) |
|
544 |
lineTable.setItem(rowCount - 1, index, item) |
|
545 |
''' |
|
546 | 484 |
|
547 | 485 |
''' |
548 | 486 |
@brief setting equip data |
... | ... | |
631 | 569 |
valve_table.setRowCount(len(dataList)) |
632 | 570 |
row = 0 |
633 | 571 |
for data in dataList: |
634 |
col = 0 |
|
635 |
for key in data.keys(): |
|
636 |
item = QTableWidgetItem(data[key] if data[key] is not None else '') |
|
637 |
item.setFlags(Qt.ItemIsEnabled) |
|
638 |
valve_table.setItem(row, col, item) |
|
639 |
col += 1 |
|
572 |
for col in range(self.ui.tableWidgetValveDataList.columnCount()): |
|
573 |
col_name = self.ui.tableWidgetValveDataList.horizontalHeaderItem(col).text() |
|
574 |
matches = [key for key in data.keys() if key == col_name] |
|
575 |
if matches: |
|
576 |
item = QTableWidgetItem(data[matches[0]]) |
|
577 |
item.setFlags(Qt.ItemIsEnabled) |
|
578 |
valve_table.setItem(row, col, item) |
|
640 | 579 |
row += 1 |
641 | 580 |
|
642 | 581 |
# get column headers |
643 | 582 |
headers = [] |
644 | 583 |
for col in range(valve_table.columnCount()): |
645 | 584 |
headers.append(valve_table.horizontalHeaderItem(col).text()) |
646 |
''' |
|
647 |
# 현재 문서명이 같으면 중복 체크 |
|
648 |
if docData.imgName is not None and (docData.imgName == text or self.ui.comboBoxDoc.currentIndex() == 0): |
|
649 |
rowCount = valve_table.rowCount() |
|
650 |
uidList = [] |
|
651 |
for row in range(rowCount): |
|
652 |
uidList.append(valve_table.item(row, 0).text()) |
|
653 |
|
|
654 |
for uid in self.scene_valve_data.keys(): |
|
655 |
attrs = self.scene_valve_data[uid].getAttributes() |
|
656 |
# 중복 (어떻게 할지) |
|
657 |
if uidList.count(uid) >= 1: |
|
658 |
rowIndex = uidList.index(uid) |
|
659 |
|
|
660 |
for key in attrs.keys(): |
|
661 |
attr_info = docData.getSymbolAttributeByUID(key) |
|
662 |
attr_name = attr_info[0] if attr_info is not None else '' |
|
663 |
if attr_name in headers: |
|
664 |
oldData = valve_table.item(rowIndex, headers.index(attr_name)).text() |
|
665 |
if oldData != attrs[key]: |
|
666 |
valve_table.item(rowIndex, index).setText(attrs[key]) |
|
667 |
valve_table.item(rowIndex, index).setBackground(QColor(int(134), int(229), int(127))) |
|
668 |
# 신규 |
|
669 |
else: |
|
670 |
rowCount += 1 |
|
671 |
valve_table.setRowCount(rowCount) |
|
672 |
|
|
673 |
for key in attrs.keys(): |
|
674 |
attr_info = docData.getSymbolAttributeByUID(key) |
|
675 |
attr_name = attr_info[0] if attr_info is not None else '' |
|
676 |
if attr_name in headers: |
|
677 |
if attr_info[2] == 'Text Item': |
|
678 |
items = [item for item in self.parent.graphicsView.scene.items() if issubclass(type(item), QEngineeringTextItem) and item.uid == attrs[key]] |
|
679 |
item = QTableWidgetItem(items[0].text() if len(items) > 0 else '') |
|
680 |
else: |
|
681 |
item = QTableWidgetItem(str(attrs[key]) if attrs[key] is not None else '') |
|
682 |
|
|
683 |
item.setFlags(Qt.ItemIsEnabled) |
|
684 |
if item.text() != '': |
|
685 |
item.setBackground(QColor(int(134), int(229), int(127))) |
|
686 |
valve_table.setItem(rowCount - 1, headers.index(attr_name), item) |
|
687 |
|
|
688 |
for attr_name in ['UID', 'PNID_NO']: |
|
689 |
if attr_name in headers: |
|
690 |
if attr_name == 'UID': |
|
691 |
item = QTableWidgetItem(uid) |
|
692 |
elif attr_name == 'PNID_NO': |
|
693 |
item = QTableWidgetItem(docData.imgName) |
|
694 |
|
|
695 |
item.setFlags(Qt.ItemIsEnabled) |
|
696 |
if item.text() != '': |
|
697 |
item.setBackground(QColor(int(134), int(229), int(127))) |
|
698 |
valve_table.setItem(rowCount - 1, headers.index(attr_name), item) |
|
699 |
''' |
|
700 | 585 |
except Exception as ex: |
701 | 586 |
from App import App |
702 | 587 |
from AppDocData import MessageType |
... | ... | |
820 | 705 |
''' |
821 | 706 |
|
822 | 707 |
def show_item_data_format_dialog(self): |
823 |
""" |
|
824 |
show item data format dialog |
|
825 |
""" |
|
708 |
""" show item data format dialog """ |
|
709 |
|
|
826 | 710 |
from ItemDataFormatDialog import QItemDataFormatDialog |
827 | 711 |
|
828 | 712 |
item_data_format_dialog = QItemDataFormatDialog(self, self.columnListAll, self.columnOrder) |
DTI_PID/DTI_PID/ItemDataFormatDialog.py | ||
---|---|---|
1 | 1 |
# coding: utf-8 |
2 |
""" |
|
3 |
This is ItemDataFormatDialog module |
|
4 |
""" |
|
2 |
""" This is ItemDataFormatDialog module """ |
|
5 | 3 |
|
6 | 4 |
import os |
7 | 5 |
import sys |
... | ... | |
15 | 13 |
dbListName = ['LINE_DATA_LIST', 'EQUIPMENT_DATA_LIST', 'VALVE_DATA_LIST', 'INSTRUMENT_DATA_LIST', 'NOTE_DATA_LIST'] |
16 | 14 |
|
17 | 15 |
class QItemDataFormatDialog(QDialog): |
18 |
""" |
|
19 |
This is QItemDataFormatDialog class |
|
20 |
""" |
|
16 |
""" This is QItemDataFormatDialog class """ |
|
17 |
|
|
18 |
DATA_LIST = ['LINE_DATA_LIST', 'EQUIPMENT_DATA_LIST', 'VALVE_DATA_LIST', 'INSTRUMENT_DATA_LIST', 'NOTE_DATA_LIST'] |
|
19 |
|
|
21 | 20 |
def __init__(self, parent, columnListAll, columnOrder): |
22 | 21 |
QDialog.__init__(self, parent) |
23 | 22 |
self.setWindowFlag(Qt.WindowMinMaxButtonsHint) |
... | ... | |
34 | 33 |
self.emptyCol = 'Empty Column' |
35 | 34 |
self.selectedCol = None |
36 | 35 |
|
37 |
self.colHistory = [] |
|
38 |
|
|
39 | 36 |
self.lineHistory =[] |
40 | 37 |
self.equipmentHistory = [] |
41 | 38 |
self.valveHistory = [] |
42 | 39 |
self.instrumentHistory = [] |
43 | 40 |
self.noteHistory = [] |
44 |
self.colHistory.append(self.lineHistory) |
|
45 |
self.colHistory.append(self.equipmentHistory) |
|
46 |
self.colHistory.append(self.valveHistory) |
|
47 |
self.colHistory.append(self.instrumentHistory) |
|
48 |
self.colHistory.append(self.noteHistory) |
|
49 |
|
|
50 |
self.listWidgets = [] |
|
51 |
self.listWidgets.append(self.ui.listWidgetLine) |
|
52 |
self.listWidgets.append(self.ui.listWidgetEquipment) |
|
53 |
self.listWidgets.append(self.ui.listWidgetValve) |
|
54 |
self.listWidgets.append(self.ui.listWidgetInstrument) |
|
55 |
self.listWidgets.append(self.ui.listWidgetNote) |
|
56 |
|
|
57 |
self.tableWidgets = [] |
|
58 |
self.tableWidgets.append(self.ui.tableWidgetLine) |
|
59 |
self.tableWidgets.append(self.ui.tableWidgetEquipment) |
|
60 |
self.tableWidgets.append(self.ui.tableWidgetValve) |
|
61 |
self.tableWidgets.append(self.ui.tableWidgetInstrument) |
|
62 |
self.tableWidgets.append(self.ui.tableWidgetNote) |
|
63 |
|
|
64 |
self.sections = [] |
|
65 |
self.sections.append(self.lineSectionClicked) |
|
66 |
self.sections.append(self.equipmentSectionClicked) |
|
67 |
self.sections.append(self.valveSectionClicked) |
|
68 |
self.sections.append(self.instrumentSectionClicked) |
|
69 |
self.sections.append(self.noteSectionClicked) |
|
70 |
|
|
71 |
self.items = [] |
|
72 |
self.items.append(self.lineItemDoubleCliked) |
|
73 |
self.items.append(self.equipmentItemDoubleCliked) |
|
74 |
self.items.append(self.valveItemDoubleCliked) |
|
75 |
self.items.append(self.instrumentItemDoubleCliked) |
|
76 |
self.items.append(self.noteItemDoubleCliked) |
|
77 |
|
|
78 |
self.drops = [] |
|
79 |
self.drops.append(self.lineDropEvent) |
|
80 |
self.drops.append(self.equipmentDropEvent) |
|
81 |
self.drops.append(self.valveDropEvent) |
|
82 |
self.drops.append(self.instrumentDropEvent) |
|
83 |
self.drops.append(self.noteDropEvent) |
|
84 |
|
|
85 |
self.deleteButtons = [] |
|
86 |
self.deleteButtons.append(self.ui.pushButtonLineDelete) |
|
87 |
self.deleteButtons.append(self.ui.pushButtonEquipmentDelete) |
|
88 |
self.deleteButtons.append(self.ui.pushButtonValveDelete) |
|
89 |
self.deleteButtons.append(self.ui.pushButtonInstrumentDelete) |
|
90 |
self.deleteButtons.append(self.ui.pushButtonNoteDelete) |
|
91 |
|
|
92 |
self.deletes = [] |
|
93 |
self.deletes.append(self.lineDeleteClicked) |
|
94 |
self.deletes.append(self.equipmentDeleteClicked) |
|
95 |
self.deletes.append(self.valveDeleteClicked) |
|
96 |
self.deletes.append(self.instrumentDeleteClicked) |
|
97 |
self.deletes.append(self.noteDeleteClicked) |
|
98 |
|
|
99 |
self.addButtons = [] |
|
100 |
self.addButtons.append(self.ui.pushButtonLineAdd) |
|
101 |
self.addButtons.append(self.ui.pushButtonEquipmentAdd) |
|
102 |
self.addButtons.append(self.ui.pushButtonValveAdd) |
|
103 |
self.addButtons.append(self.ui.pushButtonInstrumentAdd) |
|
104 |
self.addButtons.append(self.ui.pushButtonNoteAdd) |
|
105 |
|
|
106 |
self.adds = [] |
|
107 |
self.adds.append(self.lineAddClicked) |
|
108 |
self.adds.append(self.equipmentAddClicked) |
|
109 |
self.adds.append(self.valveAddClicked) |
|
110 |
self.adds.append(self.instrumentAddClicked) |
|
111 |
self.adds.append(self.noteAddClicked) |
|
112 |
|
|
113 |
self.emptyButtons = [] |
|
114 |
self.emptyButtons.append(self.ui.pushButtonLineEmptyColumn) |
|
115 |
self.emptyButtons.append(self.ui.pushButtonEquipmentEmptyColumn) |
|
116 |
self.emptyButtons.append(self.ui.pushButtonValveEmptyColumn) |
|
117 |
self.emptyButtons.append(self.ui.pushButtonInstrumentEmptyColumn) |
|
118 |
self.emptyButtons.append(self.ui.pushButtonNoteEmptyColumn) |
|
119 |
|
|
120 |
self.emptys = [] |
|
121 |
self.emptys.append(self.lineEmptyClicked) |
|
122 |
self.emptys.append(self.equipmentEmptyClicked) |
|
123 |
self.emptys.append(self.valveEmptyClicked) |
|
124 |
self.emptys.append(self.instrumentEmptyClicked) |
|
125 |
self.emptys.append(self.noteEmptyClicked) |
|
126 |
|
|
127 |
self.colAddButtons = [] |
|
128 |
self.colAddButtons.append(self.ui.pushButtonLineColAdd) |
|
129 |
self.colAddButtons.append(self.ui.pushButtonEqpColAdd) |
|
130 |
self.colAddButtons.append(self.ui.pushButtonValveColAdd) |
|
131 |
self.colAddButtons.append(self.ui.pushButtonInstColAdd) |
|
132 |
self.colAddButtons.append(self.ui.pushButtonNoteColAdd) |
|
133 |
|
|
134 |
self.colAdds = [] |
|
135 |
self.colAdds.append(self.line_add_clicked) |
|
136 |
self.colAdds.append(self.equipment_add_clicked) |
|
137 |
self.colAdds.append(self.valve_add_clicked) |
|
138 |
self.colAdds.append(self.instrument_add_clicked) |
|
139 |
self.colAdds.append(self.note_add_clicked) |
|
140 |
|
|
141 |
self.colEditButtons = [] |
|
142 |
self.colEditButtons.append(self.ui.pushButtonLineColEdit) |
|
143 |
self.colEditButtons.append(self.ui.pushButtonEqpColEdit) |
|
144 |
self.colEditButtons.append(self.ui.pushButtonValveColEdit) |
|
145 |
self.colEditButtons.append(self.ui.pushButtonInstColEdit) |
|
146 |
self.colEditButtons.append(self.ui.pushButtonNoteColEdit) |
|
147 |
|
|
148 |
self.colEdits = [] |
|
149 |
self.colEdits.append(self.line_edit_clicked) |
|
150 |
self.colEdits.append(self.equipment_edit_clicked) |
|
151 |
self.colEdits.append(self.valve_edit_clicked) |
|
152 |
self.colEdits.append(self.instrument_edit_clicked) |
|
153 |
self.colEdits.append(self.note_edit_clicked) |
|
41 |
self.colHistory = \ |
|
42 |
{ |
|
43 |
QItemDataFormatDialog.DATA_LIST[0]:self.lineHistory, |
|
44 |
QItemDataFormatDialog.DATA_LIST[1]:self.equipmentHistory, |
|
45 |
QItemDataFormatDialog.DATA_LIST[2]:self.valveHistory, |
|
46 |
QItemDataFormatDialog.DATA_LIST[3]:self.instrumentHistory, |
|
47 |
QItemDataFormatDialog.DATA_LIST[4]:self.noteHistory |
|
48 |
} |
|
49 |
|
|
50 |
self.listWidgets = \ |
|
51 |
{ |
|
52 |
QItemDataFormatDialog.DATA_LIST[0]:self.ui.listWidgetLine, |
|
53 |
QItemDataFormatDialog.DATA_LIST[1]:self.ui.listWidgetEquipment, |
|
54 |
QItemDataFormatDialog.DATA_LIST[2]:self.ui.listWidgetValve, |
|
55 |
QItemDataFormatDialog.DATA_LIST[3]:self.ui.listWidgetInstrument, |
|
56 |
QItemDataFormatDialog.DATA_LIST[4]:self.ui.listWidgetNote |
|
57 |
} |
|
58 |
|
|
59 |
self.tableWidgets = \ |
|
60 |
{ |
|
61 |
QItemDataFormatDialog.DATA_LIST[0]:self.ui.tableWidgetLine, |
|
62 |
QItemDataFormatDialog.DATA_LIST[1]:self.ui.tableWidgetEquipment, |
|
63 |
QItemDataFormatDialog.DATA_LIST[2]:self.ui.tableWidgetValve, |
|
64 |
QItemDataFormatDialog.DATA_LIST[3]:self.ui.tableWidgetInstrument, |
|
65 |
QItemDataFormatDialog.DATA_LIST[4]:self.ui.tableWidgetNote |
|
66 |
} |
|
67 |
|
|
68 |
self.sections = \ |
|
69 |
{ |
|
70 |
QItemDataFormatDialog.DATA_LIST[0]:self.lineSectionClicked, |
|
71 |
QItemDataFormatDialog.DATA_LIST[1]:self.equipmentSectionClicked, |
|
72 |
QItemDataFormatDialog.DATA_LIST[2]:self.valveSectionClicked, |
|
73 |
QItemDataFormatDialog.DATA_LIST[3]:self.instrumentSectionClicked, |
|
74 |
QItemDataFormatDialog.DATA_LIST[4]:self.noteSectionClicked |
|
75 |
} |
|
76 |
|
|
77 |
self.items = \ |
|
78 |
{ |
|
79 |
QItemDataFormatDialog.DATA_LIST[0]:self.lineItemDoubleCliked, |
|
80 |
QItemDataFormatDialog.DATA_LIST[1]:self.equipmentItemDoubleCliked, |
|
81 |
QItemDataFormatDialog.DATA_LIST[2]:self.valveItemDoubleCliked, |
|
82 |
QItemDataFormatDialog.DATA_LIST[3]:self.instrumentItemDoubleCliked, |
|
83 |
QItemDataFormatDialog.DATA_LIST[4]:self.noteItemDoubleCliked |
|
84 |
} |
|
85 |
|
|
86 |
self.drops = \ |
|
87 |
{ |
|
88 |
QItemDataFormatDialog.DATA_LIST[0]:self.lineDropEvent, |
|
89 |
QItemDataFormatDialog.DATA_LIST[1]:self.equipmentDropEvent, |
|
90 |
QItemDataFormatDialog.DATA_LIST[2]:self.valveDropEvent, |
|
91 |
QItemDataFormatDialog.DATA_LIST[3]:self.instrumentDropEvent, |
|
92 |
QItemDataFormatDialog.DATA_LIST[4]:self.noteDropEvent |
|
93 |
} |
|
94 |
|
|
95 |
self.deleteButtons = \ |
|
96 |
{ |
|
97 |
QItemDataFormatDialog.DATA_LIST[0]:self.ui.pushButtonLineDelete, |
|
98 |
QItemDataFormatDialog.DATA_LIST[1]:self.ui.pushButtonEquipmentDelete, |
|
99 |
QItemDataFormatDialog.DATA_LIST[2]:self.ui.pushButtonValveDelete, |
|
100 |
QItemDataFormatDialog.DATA_LIST[3]:self.ui.pushButtonInstrumentDelete, |
|
101 |
QItemDataFormatDialog.DATA_LIST[4]:self.ui.pushButtonNoteDelete |
|
102 |
} |
|
103 |
|
|
104 |
self.deletes = \ |
|
105 |
{ |
|
106 |
QItemDataFormatDialog.DATA_LIST[0]:self.lineDeleteClicked, |
|
107 |
QItemDataFormatDialog.DATA_LIST[1]:self.equipmentDeleteClicked, |
|
108 |
QItemDataFormatDialog.DATA_LIST[2]:self.valveDeleteClicked, |
|
109 |
QItemDataFormatDialog.DATA_LIST[3]:self.instrumentDeleteClicked, |
|
110 |
QItemDataFormatDialog.DATA_LIST[4]:self.noteDeleteClicked |
|
111 |
} |
|
112 |
|
|
113 |
self.addButtons = \ |
|
114 |
{ |
|
115 |
QItemDataFormatDialog.DATA_LIST[0]:self.ui.pushButtonLineAdd, |
|
116 |
QItemDataFormatDialog.DATA_LIST[1]:self.ui.pushButtonEquipmentAdd, |
|
117 |
QItemDataFormatDialog.DATA_LIST[2]:self.ui.pushButtonValveAdd, |
|
118 |
QItemDataFormatDialog.DATA_LIST[3]:self.ui.pushButtonInstrumentAdd, |
|
119 |
QItemDataFormatDialog.DATA_LIST[4]:self.ui.pushButtonNoteAdd |
|
120 |
} |
|
121 |
|
|
122 |
self.adds = \ |
|
123 |
{ |
|
124 |
QItemDataFormatDialog.DATA_LIST[0]:self.lineAddClicked, |
|
125 |
QItemDataFormatDialog.DATA_LIST[1]:self.equipmentAddClicked, |
|
126 |
QItemDataFormatDialog.DATA_LIST[2]:self.valveAddClicked, |
|
127 |
QItemDataFormatDialog.DATA_LIST[3]:self.instrumentAddClicked, |
|
128 |
QItemDataFormatDialog.DATA_LIST[4]:self.noteAddClicked |
|
129 |
} |
|
130 |
|
|
131 |
self.emptyButtons = \ |
|
132 |
{ |
|
133 |
QItemDataFormatDialog.DATA_LIST[0]:self.ui.pushButtonLineEmptyColumn, |
|
134 |
QItemDataFormatDialog.DATA_LIST[1]:self.ui.pushButtonEquipmentEmptyColumn, |
|
135 |
QItemDataFormatDialog.DATA_LIST[2]:self.ui.pushButtonValveEmptyColumn, |
|
136 |
QItemDataFormatDialog.DATA_LIST[3]:self.ui.pushButtonInstrumentEmptyColumn, |
|
137 |
QItemDataFormatDialog.DATA_LIST[4]:self.ui.pushButtonNoteEmptyColumn |
|
138 |
} |
|
139 |
|
|
140 |
self.emptys = \ |
|
141 |
{ |
|
142 |
QItemDataFormatDialog.DATA_LIST[0]:self.lineEmptyClicked, |
|
143 |
QItemDataFormatDialog.DATA_LIST[1]:self.equipmentEmptyClicked, |
|
144 |
QItemDataFormatDialog.DATA_LIST[2]:self.valveEmptyClicked, |
|
145 |
QItemDataFormatDialog.DATA_LIST[3]:self.instrumentEmptyClicked, |
|
146 |
QItemDataFormatDialog.DATA_LIST[4]:self.noteEmptyClicked |
|
147 |
} |
|
148 |
|
|
149 |
self.colAddButtons = \ |
|
150 |
{ |
|
151 |
QItemDataFormatDialog.DATA_LIST[0]:self.ui.pushButtonLineColAdd, |
|
152 |
QItemDataFormatDialog.DATA_LIST[1]:self.ui.pushButtonEqpColAdd, |
|
153 |
QItemDataFormatDialog.DATA_LIST[2]:self.ui.pushButtonValveColAdd, |
|
154 |
QItemDataFormatDialog.DATA_LIST[3]:self.ui.pushButtonInstColAdd, |
|
155 |
QItemDataFormatDialog.DATA_LIST[4]:self.ui.pushButtonNoteColAdd |
|
156 |
} |
|
157 |
|
|
158 |
self.colAdds = \ |
|
159 |
{ |
|
160 |
QItemDataFormatDialog.DATA_LIST[0]:self.line_add_clicked, |
|
161 |
QItemDataFormatDialog.DATA_LIST[1]:self.equipment_add_clicked, |
|
162 |
QItemDataFormatDialog.DATA_LIST[2]:self.valve_add_clicked, |
|
163 |
QItemDataFormatDialog.DATA_LIST[3]:self.instrument_add_clicked, |
|
164 |
QItemDataFormatDialog.DATA_LIST[4]:self.note_add_clicked |
|
165 |
} |
|
166 |
|
|
167 |
self.colEditButtons = \ |
|
168 |
{ |
|
169 |
QItemDataFormatDialog.DATA_LIST[0]:self.ui.pushButtonLineColEdit, |
|
170 |
QItemDataFormatDialog.DATA_LIST[1]:self.ui.pushButtonEqpColEdit, |
|
171 |
QItemDataFormatDialog.DATA_LIST[2]:self.ui.pushButtonValveColEdit, |
|
172 |
QItemDataFormatDialog.DATA_LIST[3]:self.ui.pushButtonInstColEdit, |
|
173 |
QItemDataFormatDialog.DATA_LIST[4]:self.ui.pushButtonNoteColEdit |
|
174 |
} |
|
175 |
|
|
176 |
self.colEdits = \ |
|
177 |
{ |
|
178 |
QItemDataFormatDialog.DATA_LIST[0]:self.line_edit_clicked, |
|
179 |
QItemDataFormatDialog.DATA_LIST[1]:self.equipment_edit_clicked, |
|
180 |
QItemDataFormatDialog.DATA_LIST[2]:self.valve_edit_clicked, |
|
181 |
QItemDataFormatDialog.DATA_LIST[3]:self.instrument_edit_clicked, |
|
182 |
QItemDataFormatDialog.DATA_LIST[4]:self.note_edit_clicked |
|
183 |
} |
|
154 | 184 |
|
155 | 185 |
# button en/disable setting |
156 | 186 |
self.ui.pushButtonLineColAdd.setDisabled(True) |
... | ... | |
166 | 196 |
self.dragItem = None |
167 | 197 |
|
168 | 198 |
# tableWidget setting |
169 |
for index in range(len(self.tableWidgets)): |
|
170 |
self.tableWidgets[index].horizontalHeader().setSectionsMovable(True) |
|
171 |
self.tableWidgets[index].setSelectionMode(QAbstractItemView.SingleSelection) |
|
172 |
#self.tableWidgets[index].setEditTriggers(QAbstractItemView.NoEditTriggers) |
|
173 |
self.tableWidgets[index].horizontalHeader().setSectionsClickable(True) |
|
174 |
self.tableWidgets[index].horizontalHeader().setHighlightSections(True) |
|
175 |
self.tableWidgets[index].setColumnCount(len(self.columnOrder[index])) |
|
199 |
for key in self.tableWidgets.keys(): |
|
200 |
self.tableWidgets[key].horizontalHeader().setSectionsMovable(True) |
|
201 |
self.tableWidgets[key].setSelectionMode(QAbstractItemView.SingleSelection) |
|
202 |
self.tableWidgets[key].horizontalHeader().setSectionsClickable(True) |
|
203 |
self.tableWidgets[key].horizontalHeader().setHighlightSections(True) |
|
204 |
|
|
176 | 205 |
headers = [] |
177 |
userHeaders = [] |
|
178 |
for col in self.columnOrder[index]: |
|
179 |
headers.append(col.split(self.delimiterCombine)[0]) |
|
180 |
userHeaders.append(col.split(self.delimiterCombine)[1]) |
|
181 |
self.tableWidgets[index].setHorizontalHeaderLabels(headers) |
|
182 |
for ucol in range(len(self.columnOrder[index])): |
|
183 |
self.tableWidgets[index].setItem(0, ucol, QTableWidgetItem(userHeaders[ucol])) |
|
184 |
self.tableWidgets[index].horizontalHeader().sectionClicked.connect(self.sections[index]) |
|
185 |
self.tableWidgets[index].cellClicked.connect(self.sections[index]) |
|
186 |
self.deleteButtons[index].clicked.connect(self.deletes[index]) |
|
187 |
self.addButtons[index].clicked.connect(self.adds[index]) |
|
188 |
self.emptyButtons[index].clicked.connect(self.emptys[index]) |
|
189 |
for listIndex in range(len(self.columnOrder[index])): |
|
190 |
self.tableWidgets[index].horizontalHeaderItem(listIndex).setSizeHint(QSize(25, 25)) |
|
191 |
self.tableWidgets[index].setColumnWidth(listIndex, len(headers[listIndex]) * 8 + 10) |
|
192 |
self.tableWidgets[index].hideColumn(0) |
|
193 |
|
|
194 |
self.tableWidgets[index].setDragDropMode(QAbstractItemView.DropOnly) |
|
195 |
self.tableWidgets[index].setAcceptDrops(True) |
|
196 |
self.tableWidgets[index].dropEvent = self.drops[index] |
|
206 |
tokens = self.columnOrder[key][0].value.split(self.delimiter) |
|
207 |
for token in tokens: |
|
208 |
header = token.split(self.delimiterCombine) |
|
209 |
headers.append([header[0] if len(header) > 0 else '', header[-1] if len(header) > 1 else '']) |
|
210 |
|
|
211 |
self.tableWidgets[key].setColumnCount(len(headers)) |
|
212 |
self.tableWidgets[key].setHorizontalHeaderLabels([header[0] for header in headers]) |
|
213 |
for col in range(len(headers)): |
|
214 |
self.tableWidgets[key].setItem(0, col, QTableWidgetItem(headers[col][1])) |
|
215 |
self.tableWidgets[key].horizontalHeaderItem(col).setSizeHint(QSize(25, 25)) |
|
216 |
#self.tableWidgets[key].setColumnWidth(col, len(headers[col]) * 8 + 10) |
|
217 |
|
|
218 |
self.tableWidgets[key].horizontalHeader().sectionClicked.connect(self.sections[key]) |
|
219 |
self.tableWidgets[key].cellClicked.connect(self.sections[key]) |
|
220 |
self.deleteButtons[key].clicked.connect(self.deletes[key]) |
|
221 |
self.addButtons[key].clicked.connect(self.adds[key]) |
|
222 |
self.emptyButtons[key].clicked.connect(self.emptys[key]) |
|
223 |
|
|
224 |
self.tableWidgets[key].setDragDropMode(QAbstractItemView.DropOnly) |
|
225 |
self.tableWidgets[key].setAcceptDrops(True) |
|
226 |
self.tableWidgets[key].dropEvent = self.drops[key] |
|
197 | 227 |
|
198 | 228 |
# attribute list setting |
199 |
for index in range(len(self.listWidgets)):
|
|
200 |
self.listWidgets[index].itemDoubleClicked.connect(self.items[index])
|
|
201 |
self.colAddButtons[index].clicked.connect(self.colAdds[index])
|
|
202 |
self.colEditButtons[index].clicked.connect(self.colEdits[index])
|
|
203 |
for header in range(1, len(columnListAll[index])):
|
|
204 |
item = QListWidgetItem(columnListAll[index][header])
|
|
229 |
for key in self.listWidgets.keys():
|
|
230 |
self.listWidgets[key].itemDoubleClicked.connect(self.items[key])
|
|
231 |
self.colAddButtons[key].clicked.connect(self.colAdds[key])
|
|
232 |
self.colEditButtons[key].clicked.connect(self.colEdits[key])
|
|
233 |
for header in range(1, len(columnListAll[key])):
|
|
234 |
item = QListWidgetItem(columnListAll[key][header])
|
|
205 | 235 |
item.setSizeHint(QSize(25, 25)) |
206 |
self.listWidgets[index].addItem(item) |
|
207 |
#if savedBackground == False: |
|
208 |
# self.originBackground = item.background() |
|
209 |
# savedBackground = True |
|
210 |
for logical in range(self.tableWidgets[index].columnCount()): |
|
211 |
if item.text() == self.tableWidgets[index].horizontalHeaderItem(logical).text(): |
|
236 |
self.listWidgets[key].addItem(item) |
|
237 |
for logical in range(self.tableWidgets[key].columnCount()): |
|
238 |
if item.text() == self.tableWidgets[key].horizontalHeaderItem(logical).text(): |
|
212 | 239 |
#item.setBackground(self.selectionBackground) |
213 |
self.listWidgets[index].takeItem(self.listWidgets[index].count() - 1)
|
|
240 |
self.listWidgets[key].takeItem(self.listWidgets[key].count() - 1)
|
|
214 | 241 |
break |
215 | 242 |
|
216 |
self.listWidgets[index].setDragDropMode(QAbstractItemView.DragDrop)
|
|
217 |
self.listWidgets[index].dragEnterEvent = self.dragEnterEvent
|
|
243 |
self.listWidgets[key].setDragDropMode(QAbstractItemView.DragDrop)
|
|
244 |
self.listWidgets[key].dragEnterEvent = self.dragEnterEvent
|
|
218 | 245 |
|
219 | 246 |
self.ui.pushButtonApply.clicked.connect(self.pushButtonApplyClicked) |
220 | 247 |
self.ui.pushButtonClose.clicked.connect(self.pushButtonCloseClicked) |
... | ... | |
292 | 319 |
break |
293 | 320 |
|
294 | 321 |
def line_edit_clicked(self): |
295 |
self.edit_column_clicked(dbListName[0], self.listWidgets[0], self.columnListAll[0], self.colHistory[0]) |
|
322 |
data_list = QItemDataFormatDialog.DATA_LIST[0] |
|
323 |
self.edit_column_clicked(data_list, self.listWidgets[data_list], self.columnListAll[data_list], self.colHistory[data_list]) |
|
296 | 324 |
|
297 | 325 |
def equipment_edit_clicked(self): |
298 |
self.edit_column_clicked(dbListName[1], self.listWidgets[1], self.columnListAll[1], self.colHistory[1]) |
|
326 |
data_list = QItemDataFormatDialog.DATA_LIST[1] |
|
327 |
self.edit_column_clicked(data_list, self.listWidgets[data_list], self.columnListAll[data_list], self.colHistory[data_list]) |
|
299 | 328 |
|
300 | 329 |
def valve_edit_clicked(self): |
301 |
self.edit_column_clicked(dbListName[2], self.listWidgets[2], self.columnListAll[2], self.colHistory[2]) |
|
330 |
data_list = QItemDataFormatDialog.DATA_LIST[2] |
|
331 |
self.edit_column_clicked(data_list, self.listWidgets[data_list], self.columnListAll[data_list], self.colHistory[data_list]) |
|
302 | 332 |
|
303 | 333 |
def instrument_edit_clicked(self): |
304 |
self.edit_column_clicked(dbListName[3], self.listWidgets[3], self.columnListAll[3], self.colHistory[3]) |
|
334 |
data_list = QItemDataFormatDialog.DATA_LIST[3] |
|
335 |
self.edit_column_clicked(data_list, self.listWidgets[data_list], self.columnListAll[data_list], self.colHistory[data_list]) |
|
305 | 336 |
|
306 | 337 |
def note_edit_clicked(self): |
307 |
self.edit_column_clicked(dbListName[4], self.listWidgets[4], self.columnListAll[4], self.colHistory[4]) |
|
338 |
data_list = QItemDataFormatDialog.DATA_LIST[4] |
|
339 |
self.edit_column_clicked(data_list, self.listWidgets[data_list], self.columnListAll[data_list], self.colHistory[data_list]) |
|
308 | 340 |
|
309 | 341 |
def add_column_clicked(self, tableName, alist, colList, history): |
310 | 342 |
''' |
... | ... | |
324 | 356 |
alist.addItem(item) |
325 | 357 |
|
326 | 358 |
def line_add_clicked(self): |
327 |
self.add_column_clicked(dbListName[0], self.listWidgets[0], self.columnListAll[0], self.colHistory[0]) |
|
359 |
data_list = QItemDataFormatDialog.DATA_LIST[0] |
|
360 |
self.add_column_clicked(data_list, self.listWidgets[data_list], self.columnListAll[data_list], self.colHistory[data_list]) |
|
328 | 361 |
|
329 | 362 |
def equipment_add_clicked(self): |
330 |
self.add_column_clicked(dbListName[1], self.listWidgets[1], self.columnListAll[1], self.colHistory[1]) |
|
363 |
data_list = QItemDataFormatDialog.DATA_LIST[1] |
|
364 |
self.add_column_clicked(data_list, self.listWidgets[data_list], self.columnListAll[data_list], self.colHistory[data_list]) |
|
331 | 365 |
|
332 | 366 |
def valve_add_clicked(self): |
333 |
self.add_column_clicked(dbListName[2], self.listWidgets[2], self.columnListAll[2], self.colHistory[2]) |
|
367 |
data_list = QItemDataFormatDialog.DATA_LIST[2] |
|
368 |
self.add_column_clicked(data_list, self.listWidgets[data_list], self.columnListAll[data_list], self.colHistory[data_list]) |
|
334 | 369 |
|
335 | 370 |
def instrument_add_clicked(self): |
336 |
self.add_column_clicked(dbListName[3], self.listWidgets[3], self.columnListAll[3], self.colHistory[3]) |
|
371 |
data_list = QItemDataFormatDialog.DATA_LIST[3] |
|
372 |
self.add_column_clicked(data_list, self.listWidgets[data_list], self.columnListAll[data_list], self.colHistory[data_list]) |
|
337 | 373 |
|
338 | 374 |
def note_add_clicked(self): |
339 |
self.add_column_clicked(dbListName[4], self.listWidgets[4], self.columnListAll[4], self.colHistory[4]) |
|
375 |
data_list = QItemDataFormatDialog.DATA_LIST[4] |
|
376 |
self.add_column_clicked(data_list, self.listWidgets[data_list], self.columnListAll[data_list], self.colHistory[data_list]) |
|
340 | 377 |
|
341 | 378 |
''' |
342 | 379 |
@brief add empty column |
... | ... | |
355 | 392 |
self.selectedCol = [table, None, alist] |
356 | 393 |
|
357 | 394 |
def lineEmptyClicked(self): |
358 |
self.emptyColumnClicked(self.tableWidgets[0], self.listWidgets[0]) |
|
395 |
data_list = QItemDataFormatDialog.DATA_LIST[0] |
|
396 |
self.emptyColumnClicked(self.tableWidgets[data_list], self.listWidgets[data_list]) |
|
359 | 397 |
|
360 | 398 |
def equipmentEmptyClicked(self): |
361 |
self.emptyColumnClicked(self.tableWidgets[1], self.listWidgets[1]) |
|
399 |
data_list = QItemDataFormatDialog.DATA_LIST[1] |
|
400 |
self.emptyColumnClicked(self.tableWidgets[data_list], self.listWidgets[data_list]) |
|
362 | 401 |
|
363 | 402 |
def valveEmptyClicked(self): |
364 |
self.emptyColumnClicked(self.tableWidgets[2], self.listWidgets[2]) |
|
403 |
data_list = QItemDataFormatDialog.DATA_LIST[2] |
|
404 |
self.emptyColumnClicked(self.tableWidgets[data_list], self.listWidgets[data_list]) |
|
365 | 405 |
|
366 | 406 |
def instrumentEmptyClicked(self): |
367 |
self.emptyColumnClicked(self.tableWidgets[3], self.listWidgets[3]) |
|
407 |
data_list = QItemDataFormatDialog.DATA_LIST[3] |
|
408 |
self.emptyColumnClicked(self.tableWidgets[data_list], self.listWidgets[data_list]) |
|
368 | 409 |
|
369 | 410 |
def noteEmptyClicked(self): |
370 |
self.emptyColumnClicked(self.tableWidgets[4], self.listWidgets[4]) |
|
411 |
data_list = QItemDataFormatDialog.DATA_LIST[4] |
|
412 |
self.emptyColumnClicked(self.tableWidgets[data_list], self.listWidgets[data_list]) |
|
371 | 413 |
|
372 | 414 |
''' |
373 | 415 |
@brief save and apply all change |
... | ... | |
377 | 419 |
def pushButtonApplyClicked(self): |
378 | 420 |
docData = AppDocData.instance() |
379 | 421 |
configs = [] |
380 |
for index in range(len(self.tableWidgets)):
|
|
422 |
for key in self.tableWidgets.keys():
|
|
381 | 423 |
# table column apply |
382 | 424 |
addedCol = [] |
383 | 425 |
editedCol = [] |
384 |
for history in self.colHistory[index]:
|
|
426 |
for history in self.colHistory[key]:
|
|
385 | 427 |
if history[0] is not None: # edit |
386 | 428 |
isNewAddedCol = False |
387 | 429 |
for index in range(len(addedCol)): |
... | ... | |
398 | 440 |
for added in addedCol: |
399 | 441 |
docData.add_column_into_table(dbListName[index], added) |
400 | 442 |
|
401 |
# column order save |
|
402 |
headerCount = self.tableWidgets[index].columnCount() |
|
403 |
currentCol = [] |
|
404 |
logicalList = [] |
|
405 |
ueserList = [] |
|
406 |
for logicalCol in range(headerCount): |
|
407 |
logicalList.append(self.tableWidgets[index].horizontalHeaderItem(logicalCol).text()) |
|
408 |
ueserList.append(self.tableWidgets[index].item(0, logicalCol).text()) |
|
409 |
for i in range(headerCount): |
|
410 |
currentCol.append(self.tableWidgets[index].horizontalHeader().logicalIndex(i)) |
|
411 |
|
|
443 |
# save column order |
|
412 | 444 |
value = '' |
413 |
for header in currentCol: |
|
414 |
if header is -1: |
|
415 |
continue |
|
416 |
value += logicalList[header] + self.delimiterCombine + ueserList[header] + self.delimiter |
|
445 |
for col in range(self.tableWidgets[key].columnCount()): |
|
446 |
order = self.tableWidgets[key].horizontalHeader().logicalIndex(col) |
|
447 |
if order is -1: continue |
|
448 |
|
|
449 |
col_name = self.tableWidgets[key].horizontalHeaderItem(order).text() |
|
450 |
display_name = self.tableWidgets[key].item(0, order).text() |
|
451 |
value += col_name + self.delimiterCombine + display_name + self.delimiter |
|
452 |
|
|
417 | 453 |
value = value[:-len(self.delimiter)] |
418 |
configs.append(Config(dbListOrderName[index], str(index), value))
|
|
454 |
configs.append(Config('Order', key, value))
|
|
419 | 455 |
|
420 | 456 |
docData.saveConfigs(configs) |
421 | 457 |
docData.configTable = None |
422 | 458 |
|
423 |
reply = QMessageBox.information(self, self.tr('INFO'), self.tr('Save Success!'), QMessageBox.Ok, QMessageBox.Cancel)
|
|
459 |
reply = QMessageBox.information(self, self.tr('Information'), self.tr('Save Success!'), QMessageBox.Ok, QMessageBox.Cancel)
|
|
424 | 460 |
if reply == QMessageBox.Ok: |
425 | 461 |
QDialog.accept(self) |
426 | 462 |
|
... | ... | |
455 | 491 |
break |
456 | 492 |
|
457 | 493 |
def lineItemDoubleCliked(self, item): |
458 |
self.listItemDoubleClicked(self.tableWidgets[0], item, self.listWidgets[0]) |
|
494 |
data_list = QItemDataFormatDialog.DATA_LIST[0] |
|
495 |
self.listItemDoubleClicked(self.tableWidgets[data_list], item, self.listWidgets[data_list]) |
|
459 | 496 |
|
460 | 497 |
def equipmentItemDoubleCliked(self, item): |
461 |
self.listItemDoubleClicked(self.tableWidgets[1], item, self.listWidgets[1]) |
|
498 |
data_list = QItemDataFormatDialog.DATA_LIST[1] |
|
499 |
self.listItemDoubleClicked(self.tableWidgets[data_list], item, self.listWidgets[data_list]) |
|
462 | 500 |
|
463 | 501 |
def valveItemDoubleCliked(self, item): |
464 |
self.listItemDoubleClicked(self.tableWidgets[2], item, self.listWidgets[2]) |
|
502 |
data_list = QItemDataFormatDialog.DATA_LIST[2] |
|
503 |
self.listItemDoubleClicked(self.tableWidgets[data_list], item, self.listWidgets[data_list]) |
|
465 | 504 |
|
466 | 505 |
def instrumentItemDoubleCliked(self, item): |
467 |
self.listItemDoubleClicked(self.tableWidgets[3], item, self.listWidgets[3]) |
|
506 |
data_list = QItemDataFormatDialog.DATA_LIST[3] |
|
507 |
self.listItemDoubleClicked(self.tableWidgets[data_list], item, self.listWidgets[data_list]) |
|
468 | 508 |
|
469 | 509 |
def noteItemDoubleCliked(self, item): |
470 |
self.listItemDoubleClicked(self.tableWidgets[4], item, self.listWidgets[4]) |
|
510 |
data_list = QItemDataFormatDialog.DATA_LIST[4] |
|
511 |
self.listItemDoubleClicked(self.tableWidgets[data_list], item, self.listWidgets[data_list]) |
|
471 | 512 |
|
472 | 513 |
''' |
473 | 514 |
@brief close without save |
... | ... | |
526 | 567 |
self.listItemDoubleClicked(table, item, alist) |
527 | 568 |
|
528 | 569 |
def lineAddClicked(self): |
529 |
self.addClicked(self.tableWidgets[0], self.listWidgets[0]) |
|
570 |
data_list = QItemDataFormatDialog.DATA_LIST[0] |
|
571 |
self.addClicked(self.tableWidgets[data_list], self.listWidgets[data_list]) |
|
530 | 572 |
|
531 | 573 |
def equipmentAddClicked(self): |
532 |
self.addClicked(self.tableWidgets[1], self.listWidgets[1]) |
|
574 |
data_list = QItemDataFormatDialog.DATA_LIST[1] |
|
575 |
self.addClicked(self.tableWidgets[data_list], self.listWidgets[data_list]) |
|
533 | 576 |
|
534 | 577 |
def valveAddClicked(self): |
535 |
self.addClicked(self.tableWidgets[2], self.listWidgets[2]) |
|
578 |
data_list = QItemDataFormatDialog.DATA_LIST[2] |
|
579 |
self.addClicked(self.tableWidgets[data_list], self.listWidgets[data_list]) |
|
536 | 580 |
|
537 | 581 |
def instrumentAddClicked(self): |
538 |
self.addClicked(self.tableWidgets[3], self.listWidgets[3]) |
|
582 |
data_list = QItemDataFormatDialog.DATA_LIST[3] |
|
583 |
self.addClicked(self.tableWidgets[data_list], self.listWidgets[data_list]) |
|
539 | 584 |
|
540 | 585 |
def noteAddClicked(self): |
541 |
self.addClicked(self.tableWidgets[4], self.listWidgets[4]) |
|
586 |
data_list = QItemDataFormatDialog.DATA_LIST[4] |
|
587 |
self.addClicked(self.tableWidgets[data_list], self.listWidgets[data_list]) |
|
542 | 588 |
|
543 | 589 |
''' |
544 | 590 |
@brief delete column by button clicked |
... | ... | |
560 | 606 |
self.selectedCol = None |
561 | 607 |
|
562 | 608 |
def lineDeleteClicked(self): |
563 |
self.deleteClicked(self.tableWidgets[0], self.listWidgets[0]) |
|
609 |
data_list = QItemDataFormatDialog.DATA_LIST[0] |
|
610 |
self.deleteClicked(self.tableWidgets[data_list], self.listWidgets[data_list]) |
|
564 | 611 |
|
565 | 612 |
def equipmentDeleteClicked(self): |
566 |
self.deleteClicked(self.tableWidgets[1], self.listWidgets[1]) |
|
613 |
data_list = QItemDataFormatDialog.DATA_LIST[1] |
|
614 |
self.deleteClicked(self.tableWidgets[data_list], self.listWidgets[data_list]) |
|
567 | 615 |
|
568 | 616 |
def valveDeleteClicked(self): |
569 |
self.deleteClicked(self.tableWidgets[2], self.listWidgets[2]) |
|
617 |
data_list = QItemDataFormatDialog.DATA_LIST[2] |
|
618 |
self.deleteClicked(self.tableWidgets[data_list], self.listWidgets[data_list]) |
|
570 | 619 |
|
571 | 620 |
def instrumentDeleteClicked(self): |
572 |
self.deleteClicked(self.tableWidgets[3], self.listWidgets[3]) |
|
621 |
data_list = QItemDataFormatDialog.DATA_LIST[3] |
|
622 |
self.deleteClicked(self.tableWidgets[data_list], self.listWidgets[data_list]) |
|
573 | 623 |
|
574 | 624 |
def noteDeleteClicked(self): |
575 |
self.deleteClicked(self.tableWidgets[4], self.listWidgets[4]) |
|
625 |
data_list = QItemDataFormatDialog.DATA_LIST[4] |
|
626 |
self.deleteClicked(self.tableWidgets[data_list], self.listWidgets[data_list]) |
|
576 | 627 |
|
577 | 628 |
''' |
578 | 629 |
@brief table section clicked event, set selected column |
... | ... | |
586 | 637 |
self.selectedCol = [table, None, alist] |
587 | 638 |
|
588 | 639 |
def lineSectionClicked(self, logicalIndex): |
589 |
self.sectionClicked(self.tableWidgets[0], logicalIndex, self.listWidgets[0]) |
|
640 |
data_list = QItemDataFormatDialog.DATA_LIST[0] |
|
641 |
self.sectionClicked(self.tableWidgets[data_list], logicalIndex, self.listWidgets[data_list]) |
|
590 | 642 |
|
591 | 643 |
def equipmentSectionClicked(self, logicalIndex): |
592 |
self.sectionClicked(self.tableWidgets[1], logicalIndex, self.listWidgets[1]) |
|
644 |
data_list = QItemDataFormatDialog.DATA_LIST[1] |
|
645 |
self.sectionClicked(self.tableWidgets[data_list], logicalIndex, self.listWidgets[data_list]) |
|
593 | 646 |
|
594 | 647 |
def valveSectionClicked(self, logicalIndex): |
595 |
self.sectionClicked(self.tableWidgets[2], logicalIndex, self.listWidgets[2]) |
|
648 |
data_list = QItemDataFormatDialog.DATA_LIST[2] |
|
649 |
self.sectionClicked(self.tableWidgets[data_list], logicalIndex, self.listWidgets[data_list]) |
|
596 | 650 |
|
597 | 651 |
def instrumentSectionClicked(self, logicalIndex): |
598 |
self.sectionClicked(self.tableWidgets[3], logicalIndex, self.listWidgets[3]) |
|
652 |
data_list = QItemDataFormatDialog.DATA_LIST[3] |
|
653 |
self.sectionClicked(self.tableWidgets[data_list], logicalIndex, self.listWidgets[data_list]) |
|
599 | 654 |
|
600 | 655 |
def noteSectionClicked(self, logicalIndex): |
601 |
self.sectionClicked(self.tableWidgets[4], logicalIndex, self.listWidgets[4]) |
|
656 |
data_list = QItemDataFormatDialog.DATA_LIST[4] |
|
657 |
self.sectionClicked(self.tableWidgets[data_list], logicalIndex, self.listWidgets[data_list]) |
DTI_PID/DTI_PID/Shapes/EngineeringLineNoTextItem.py | ||
---|---|---|
289 | 289 |
_attrs[matches[0]] = self.attrs[matches[0]] |
290 | 290 |
else: |
291 | 291 |
_attrs[prop] = '' |
292 |
|
|
293 |
# attrs['CONN'] = self.conns[0].uid if self.conns else '' |
|
294 | 292 |
except Exception as ex: |
295 | 293 |
from App import App |
296 | 294 |
from AppDocData import MessageType |
... | ... | |
562 | 560 |
self.set_property('To', None) |
563 | 561 |
|
564 | 562 |
''' |
565 |
@brief save Line Data
|
|
566 |
@author kyouho
|
|
563 |
@brief generate sql phrase to save to database(Notice: Line No's symbol is is 1)
|
|
564 |
@author humkyung
|
|
567 | 565 |
@date 2018.08.14 |
568 | 566 |
''' |
569 | 567 |
def toSql(self): |
570 |
data = self.getLineDataList() |
|
571 |
sql = "insert or replace into LINE_DATA_LIST(UID, LINE_SIZE, LINE_SYMBOL, LINE_NO, LINE_CLASS, LINE_ROUTING_FROM, LINE_ROUTING_TO, SERVICE_FLUID, SERVICE_DENSITY, SERVICE_STATE, OPERATION_CONDITION_TEMP, OPERATION_CONDITION_PRESS, DESIGN_CONDITION_TEMP, DESIGN_CONDITION_PRESS, TEST_CONDITION_TEMP, TEST_CONDITION_PRESS, INSUL_CODE, PAINT_CODE, NDE_CODE, PWHT, PNID_NO) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" |
|
572 |
param = tuple(data) |
|
573 |
return (sql, tuple(param)) |
|
568 |
import uuid |
|
569 |
|
|
570 |
res = [] |
|
571 |
|
|
572 |
app_doc_data = AppDocData.instance() |
|
573 |
|
|
574 |
sql = "insert or replace into Components(UID, Drawings_UID, Symbol_UID, X, Y, Width, Height, Rotation) values(?, ?, ?, ?, ?, ?, ?, ?)" |
|
575 |
rect = self.sceneBoundingRect() |
|
576 |
data = [str(self.uid), str(app_doc_data.activeDrawing.UID), str(1), str(rect.x()), str(rect.y()), str(rect.width()), str(rect.height()), str(self.angle)] |
|
577 |
res.append((sql, tuple(data))) |
|
578 |
|
|
579 |
attrs = self.getAttributes() |
|
580 |
for key,value in attrs.items(): |
|
581 |
sql = "insert or replace into LineNoAttributes(UID, Components_UID, LineProperties_UID, Value) values(?, ?, ?, ?)" |
|
582 |
data = [str(uuid.uuid4()), str(self.uid), str(key.UID), str(value)] |
|
583 |
res.append((sql, tuple(data))) |
|
584 |
|
|
585 |
return res |
|
574 | 586 |
|
575 | 587 |
''' |
576 | 588 |
@brief return Line Data List |
... | ... | |
585 | 597 |
|
586 | 598 |
docData = AppDocData.instance() |
587 | 599 |
attrs = self.getAttributes() |
588 |
#attrs = attrs.items() |
|
589 | 600 |
for index in range(len(lineColumnList)): |
590 | 601 |
dataList.append('') |
591 | 602 |
|
DTI_PID/DTI_PID/SymbolAttrEditorDialog.py | ||
---|---|---|
65 | 65 |
## up to here |
66 | 66 |
self.ui.tableWidgetAttr.setHorizontalHeaderLabels(['UID', 'Name', 'Display Name', 'Type', 'Length']) |
67 | 67 |
self.ui.tableWidgetAttr.horizontalHeaderItem(1).setSizeHint(QSize(25, 25)) |
68 |
self.ui.tableWidgetAttr.hideColumn(0) |
|
68 | 69 |
|
69 | 70 |
self.settingLineNoAttributeTable() |
70 | 71 |
|
내보내기 Unified diff