프로젝트

일반

사용자정보

통계
| 개정판:

hytos / DTI_PID / DTI_PID / SymbolAttrCodeTableDialog.py @ b4c3e73a

이력 | 보기 | 이력해설 | 다운로드 (2.84 KB)

1
# coding: utf-8
2
"""
3
    This is area configuration module
4
"""
5
import os
6
import sys
7
from PyQt5.QtCore import *
8
from PyQt5.QtGui import *
9
from PyQt5.QtWidgets import *
10
from AppDocData import AppDocData
11

    
12
from CodeTableDialog import QCodeTableDialog
13

    
14
import SymbolAttrCodeTable_UI
15

    
16
class SymbolAttrCodeTableDialog(QCodeTableDialog):
17
    def __init__(self, parent, symbol_attribute_uid, tableDatas=None):
18
        QCodeTableDialog.__init__(self, parent, 'SymbolAttributeCodeTable')
19

    
20
        self.ui = SymbolAttrCodeTable_UI.Ui_AttributeCodeTable()
21
        self.ui.setupUi(self)
22

    
23
        self.ui.spinBoxHeight.setValue(50)
24
        self.ui.tableWidgetSymbolAttributeCodeTable.setSortingEnabled(True)
25

    
26
        self.isAccepted = False
27
        self.code_data = None
28

    
29
        self.ui.pushButtonRead.clicked.connect(self.read_from_legend)
30
        self.ui.buttonBox.accepted.connect(self.accept)
31
        self.ui.buttonBox.rejected.connect(self.reject)
32

    
33
        self.settingTable('SymbolAttributeCodeTable', symbol_attribute_uid=symbol_attribute_uid, tableDatas=tableDatas)
34
    '''
35
        @brief  accept dialog
36
    '''
37
    def accept(self):
38
        import uuid
39

    
40
        try:
41
            self.code_data = []
42
            self.isAccepted = False
43

    
44
            tabText = self.getTabText()    
45
            table = self.findTableWidget(tabText)
46

    
47
            for row in range(table.rowCount()):
48
                if table.isRowHidden(row):
49
                    continue
50
                else:
51
                    uid = table.item(row, 0).text() if table.item(row, 0).text() else str(uuid.uuid4())
52
                    code = table.item(row, 1).text()
53
                    description = table.item(row, 2).text() if table.item(row, 2) is not None else ''
54
                    allowables = table.item(row, 3).text().split(',') if table.item(row, 3) is not None else []
55

    
56
                if code:
57
                    self.code_data.append((uid, code, description, allowables))
58

    
59
            self.isAccepted = True
60
            QDialog.accept(self)
61

    
62
        except Exception as ex:
63
            from App import App
64
            from AppDocData import MessageType
65

    
66
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
67
            App.mainWnd().addMessage.emit(MessageType.Error, message)
68
        
69
    def reject(self):
70
        try:
71
            self.isAccepted = False
72

    
73
            pass
74
            QDialog.reject(self)
75

    
76
        except Exception as ex:
77
            from App import App
78
            from AppDocData import MessageType
79

    
80
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
81
            App.mainWnd().addMessage.emit(MessageType.Error, message)
82

    
83
    def showDialog(self):
84
        self.show()
85
        self.exec_()
86
        return self.isAccepted, self.code_data
클립보드 이미지 추가 (최대 크기: 500 MB)