프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

hytos / HYTOS / HYTOS / QEquipmentDataListDialog.py @ 5f7d5696

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

1
# coding: utf-8
2
import os
3
import sys
4
from PyQt5.QtCore import *
5
from PyQt5.QtGui import *
6
from PyQt5.QtWidgets import *
7
import sqlite3
8
from AppDocData import AppDocData
9
from AppDocData import Config
10
import Equipment_Data_List_UI
11
from AppDocData import AppDocData
12

    
13
class QEquipmentDataListDialog(QDialog):
14
    def __init__(self, parent):
15
        QDialog.__init__(self, parent)
16

    
17
        self.ui = Equipment_Data_List_UI.Ui_Dialog()
18
        self.ui.setupUi(self)
19

    
20
        self.ui.tableWidgetEqpDataList.setSelectionMode(QAbstractItemView.SingleSelection) 
21
        self.ui.tableWidgetEqpDataList.setColumnCount(1)
22
        # column header 명 설정.
23
        self.ui.tableWidgetEqpDataList.setHorizontalHeaderLabels(['Tag No'])
24
        self.ui.tableWidgetEqpDataList.horizontalHeaderItem(0).setToolTip('장치 이름') # header tooltip
25
        self.ui.tableWidgetEqpDataList.horizontalHeaderItem(0).setSizeHint(QSize(30, 30))
26

    
27
        docData = AppDocData.instance()
28
        dataList = docData.getEquipmentDataList()
29
        self.ui.tableWidgetEqpDataList.setRowCount(len(dataList))
30

    
31
        row = 0
32
        for data in dataList:
33
            self.ui.tableWidgetEqpDataList.setItem(row, 0, QTableWidgetItem(data.tagNo))
34
            row += 1
35

    
36
        # connect signals and slots
37
        self.ui.pushButtonAdd.clicked.connect(self.addRow)
38
        self.ui.pushButtonDel.clicked.connect(self.deleteRow)
39

    
40
    '''
41
        @brief  add a row
42
        @author humkyung
43
        @date   2018.05.03
44
    '''
45
    def addRow(self):
46
        self.ui.tableWidgetEqpDataList.setRowCount(self.ui.tableWidgetEqpDataList.rowCount() + 1)
47

    
48
    '''
49
        @brief  delete a selected row
50
        @author humkyung
51
        @date   2018.05.03
52
    '''
53
    def deleteRow(self):
54
        for index in self.ui.tableWidgetEqpDataList.selectedIndexes():
55
            self.ui.tableWidgetEqpDataList.removeRow(index.row())
56

    
57
    '''
58
        @brief      insert or update equipment data list modified by user
59
        @author     humkyung
60
        @date       2018.05.03
61
    '''
62
    def accept(self):
63
        from EquipmentData import EquipmentData
64

    
65
        try:
66
            docData = AppDocData.instance()
67

    
68
            dataList = []
69
            for row in range(self.ui.tableWidgetEqpDataList.rowCount()):
70
                item = self.ui.tableWidgetEqpDataList.item(row, 0)
71
                dataList.append(EquipmentData(item.text()))
72

    
73
            docData.setEquipmentDataList(dataList)
74
        except Exception as ex:
75
            from App import App
76
            from AppDocData import MessageType
77
            
78
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
79
            App.mainWnd().addMessage.emit(MessageType.Error, message)
80

    
81
        QDialog.accept(self)
클립보드 이미지 추가 (최대 크기: 500 MB)