프로젝트

일반

사용자정보

개정판 d4c5dd47

IDd4c5dd473ccfc49548cb58423d37a5aca897ac46
상위 0fc0c3e6
하위 5550ec23, d2856a0e

함의성이(가) 5년 이상 전에 추가함

issue #000: attrs ea item

Change-Id: I17c11672d8bf2e5ba2e266306445c66ca4d3d32e

차이점 보기:

DTI_PID/DTI_PID/AppDocData.py
1930 1930
            # Get a cursor object
1931 1931
            cursor = conn.cursor()
1932 1932

  
1933
            sql = 'select a.UID, a.Attribute, a.DisplayAttribute, a.AttributeType, a.[AttrAt], a.[Expression], a.[index] from SymbolAttribute a inner join SymbolType t on a.SymbolType_UID = t.UID and t.type = ? order by a.[index]'
1933
            sql = 'select a.UID, a.Attribute, a.DisplayAttribute, a.AttributeType, a.[AttrAt], a.[Expression], a.[index], a.[Target] from SymbolAttribute a inner join SymbolType t on a.SymbolType_UID = t.UID and t.type = ? order by a.[index]'
1934 1934
            param = (_type,)
1935 1935
            cursor.execute(sql, param)
1936 1936
            rows = cursor.fetchall()
......
1942 1942
                attr.AttributeType = row[3]
1943 1943
                attr.AttrAt = row[4]
1944 1944
                attr.Expression = row[5]
1945
                attr.Target = row[7]
1945 1946
                result.append(attr)
1946 1947
            # Catch the exception
1947 1948
        except Exception as ex:
......
1976 1977
            # Get a cursor object
1977 1978
            cursor = conn.cursor()
1978 1979

  
1979
            sql = 'select Attribute, DisplayAttribute, AttributeType, AttrAt, Expression from SymbolAttribute where uid = "{}"'.format(UID)
1980
            sql = 'select Attribute, DisplayAttribute, AttributeType, AttrAt, Expression, target from SymbolAttribute where uid = "{}"'.format(UID)
1980 1981
            cursor.execute(sql)
1981 1982
            rows = cursor.fetchall()
1982 1983
            if len(rows):
......
1987 1988
                res.AttributeType = rows[0][2]
1988 1989
                res.AttrAt = rows[0][3]
1989 1990
                res.Expression = rows[0][4]
1991
                res.Target = rows[0][5]
1990 1992
            # Catch the exception
1991 1993
        except Exception as ex:
1992 1994
            from App import App
......
2021 2023
            cursor.execute(sql, param)
2022 2024

  
2023 2025
            for attr in attrs:
2024
                sql = 'insert into SymbolAttribute(UID, SymbolType_UID, Attribute, DisplayAttribute, AttributeType, AttrAt, Expression, [index]) values(?, ?, ?, ?, ?, ?, ?, ?)'
2026
                sql = 'insert into SymbolAttribute(UID, SymbolType_UID, Attribute, DisplayAttribute, AttributeType, AttrAt, Expression, Target, [index]) values(?, ?, ?, ?, ?, ?, ?, ?, ?)'
2025 2027
                attr.insert(1, type)
2026 2028
                param = tuple(attr)
2027 2029
                cursor.execute(sql, param)
DTI_PID/DTI_PID/Shapes/QEngineeringOPCItem.py
98 98
                elif 4.71 == self.angle:
99 99
                    sorted(self._associations['Text Item'], key=lambda attr: attr.loc[1])                # sort by y coordinate
100 100
        except Exception as ex:
101
            from App import App 
101
            from App import App
102
            from AppDocData import MessageType
102 103

  
103 104
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
104 105
            App.mainWnd().addMessage.emit(MessageType.Error, message)
DTI_PID/DTI_PID/SpecBreakDialog.py
9 9
from PyQt5.QtGui import *
10 10
from PyQt5.QtWidgets import *
11 11
from AppDocData import AppDocData
12
import sqlite3
13 12

  
14 13
#sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)) + '\\Shapes')
15 14
import SpecBreak_UI
DTI_PID/DTI_PID/SymbolAttr.py
116 116
        self.AttributeType = None
117 117
        self.AttrAt = None
118 118
        self.Expression = None
119
        self.Target = None
119 120
        self.Length = None
120 121
        self.AssocItem = None
121 122

  
DTI_PID/DTI_PID/SymbolAttrEditorDialog.py
35 35
            self.currentTypeId = 0
36 36
            ## insert QTableWidgetEx
37 37
            self.ui.tableWidgetAttr = QTableWidgetEx(self.ui.groupBox)
38
            self.ui.tableWidgetAttr.setColumnCount(6)
38
            self.ui.tableWidgetAttr.setColumnCount(7)
39 39
            self.ui.tableWidgetAttr.setObjectName("tableWidgetAttr")
40 40
            self.ui.tableWidgetAttr.setRowCount(0)
41 41
            self.ui.tableWidgetAttr.verticalHeader().setVisible(False)
......
47 47
            ## up to here
48 48
            self.ui.pushButtonAddAttr.clicked.connect(self.onAddAttr)
49 49
            self.ui.pushButtonDelAttr.clicked.connect(self.onDelAttr)
50
            self.ui.tableWidgetAttr.setHorizontalHeaderLabels(['UID', 'Name', 'Display Name', 'Type', 'Attr At', 'Expression'])
50
            self.ui.tableWidgetAttr.setHorizontalHeaderLabels(['UID', 'Name', 'Display Name', 'Type', 'Attr At', 'Expression', 'Target'])
51 51
            self.ui.tableWidgetAttr.horizontalHeaderItem(1).setSizeHint(QSize(25, 25))
52
            self.ui.tableWidgetAttr.setColumnWidth(3, 130)
52 53
            self.ui.tableWidgetAttr.hideColumn(0)
54

  
55
            self.ui.tableWidgetAttr.cellDoubleClicked.connect(self.cell_double_clicked)
53 56
        else:
54 57
            self.ui.comboBoxSymbolType.setVisible(False)
55 58
            ## insert QTableWidgetEx
......
68 71
            self.ui.pushButtonAddAttr.clicked.connect(self.onAddLineNoAttr)
69 72
            self.ui.pushButtonDelAttr.clicked.connect(self.onDelLineNoAttr)
70 73

  
74
    def cell_double_clicked(self, row, column):
75
        if self._symbolType is None or column is not 6: return
76
    
77
        from SymbolAttrTargetDialog import SymbolAttrTargetDialog
78

  
79
        try:
80
            symbolType = self.ui.comboBoxSymbolType.currentText()
81

  
82
            dialog = SymbolAttrTargetDialog(self, symbolType, self.ui.tableWidgetAttr.item(row, 6).tag)
83
            (isAccept, target) = dialog.showDialog()
84
  
85
            if isAccept:
86
                self.ui.tableWidgetAttr.item(row, 6).tag = target
87
                if target == 'ALL':
88
                    self.ui.tableWidgetAttr.item(row, 6).setText('ALL')
89
                else:
90
                    self.ui.tableWidgetAttr.item(row, 6).setText('...')
91

  
92
        except Exception as ex:
93
            from App import App
94
            from AppDocData import MessageType
95

  
96
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
97
            App.mainWnd().addMessage.emit(MessageType.Error, message)
98

  
71 99
    '''
72 100
        @brief      setting combobox symbolType
73 101
        @author     kyouho
......
134 162
            item = QTableWidgetItem(attr.Expression)    # Expression
135 163
            self.ui.tableWidgetAttr.setItem(row, 5, item)
136 164

  
165
            item = QTableWidgetItem('ALL') if attr.Target == 'ALL' or attr.Target is None else QTableWidgetItem('...')
166
            item.tag = attr.Target
167
            item.setTextAlignment(Qt.AlignHCenter)
168
            item.setFlags(Qt.ItemIsEnabled)
169
            self.ui.tableWidgetAttr.setItem(row, 6, item)
170

  
137 171
            row = row + 1
138 172

  
139 173
    def saveData(self):
......
155 189
            attr.append(table.item(index, 1).text() if table.item(index, 1) is not None else '')
156 190
            attr.append(table.item(index, 2).text() if table.item(index, 2) is not None else '')
157 191
            attr.append(table.cellWidget(index, 3).currentText())
158
            attr.append(table.item(index, 4).text() if table.item(index, 4) is not None else '')    # Attribute At
159
            attr.append(table.item(index, 5).text() if table.item(index, 5) is not None else '')    # Expression
192
            attr.append(table.item(index, 4).text() if table.item(index, 4) is not None else '')     # Attribute At
193
            attr.append(table.item(index, 5).text() if table.item(index, 5) is not None else '')     # Expression
194
            attr.append(table.item(index, 6).tag if table.item(index, 6).tag is not None else 'ALL') # Target
160 195
            attr.append(index)
161 196
            attrs.append(attr)
162 197

  
DTI_PID/DTI_PID/SymbolAttrTargetDialog.py
1
# coding: utf-8
2
"""
3
    This is area configuration module
4
"""
5
import os
6
import sys
7
#sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)) + '\\Commands')
8
from PyQt5.QtCore import *
9
from PyQt5.QtGui import *
10
from PyQt5.QtWidgets import *
11
from AppDocData import AppDocData
12

  
13
#sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)) + '\\Shapes')
14
import SymbolAttrTarget_UI
15

  
16
class SymbolAttrTargetDialog(QDialog):
17
    def __init__(self, parent, symbolType, target):
18
        QDialog.__init__(self, parent)
19

  
20
        self.ui = SymbolAttrTarget_UI.Ui_AttributeTarget()
21
        self.ui.setupUi(self)
22

  
23
        self.symbolType = symbolType
24
        self.target = target if target is not None else 'ALL'
25
        if self.target == 'ALL':
26
            self.ui.checkBox.setChecked(Qt.Checked)
27

  
28
        self.ui.tableWidget.setColumnCount(2)
29
        self.ui.tableWidget.setHorizontalHeaderLabels(['Symbol', 'Target'])
30
        for index in range(self.ui.tableWidget.columnCount()):
31
            self.ui.tableWidget.horizontalHeaderItem(0).setSizeHint(QSize(25, 25))
32
            self.ui.tableWidget.horizontalHeader().setSectionResizeMode(index, QHeaderView.Stretch)
33

  
34
        self.symbolList = AppDocData.instance().getSymbolListByType('type', self.symbolType)
35
        self.ui.tableWidget.setRowCount(len(self.symbolList))
36
        index = 0
37
        for symbol in self.symbolList:
38
            item = QTableWidgetItem(symbol.sName)
39
            item.setFlags(Qt.ItemIsEnabled)
40
            self.ui.tableWidget.setItem(index, 0, item)
41

  
42
            item = QTableWidgetItem()
43
            item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
44
            item.tag = symbol.uid
45
            item.setCheckState(Qt.Unchecked)
46
            if self.target != 'ALL':
47
                for tar in self.target.split(','):
48
                    if tar == str(symbol.uid):
49
                        item.setCheckState(Qt.Checked)
50
                        break
51
            self.ui.tableWidget.setItem(index, 1, item)
52

  
53
            index += 1
54
        
55
        self.isAccepted = False
56

  
57
        self.ui.tableWidget.resizeColumnsToContents()
58
 
59
    '''
60
        @brief  accept dialog
61
    '''
62
    def accept(self):
63
        try:
64
            self.isAccepted = False
65

  
66
            if self.ui.checkBox.isChecked():
67
                self.target = 'ALL'
68
                self.isAccepted = True
69
                QDialog.accept(self)
70
            else:
71
                self.target = ''
72
                checked = False
73
                for row in range(self.ui.tableWidget.rowCount()):
74
                    if int(self.ui.tableWidget.item(row, 1).checkState()) is int(Qt.Checked):
75
                        self.target += str(self.ui.tableWidget.item(row, 1).tag) + ','
76
                        checked = True
77
                if checked:
78
                    self.target = self.target[:-1]
79
                    self.isAccepted = True
80
                    QDialog.accept(self)
81
                else:
82
                    return
83

  
84
        except Exception as ex:
85
            from App import App
86
            from AppDocData import MessageType
87

  
88
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
89
            App.mainWnd().addMessage.emit(MessageType.Error, message)
90

  
91
    def showDialog(self):
92
        self.setWindowFlags(self.windowFlags() & ~Qt.WindowCloseButtonHint & ~Qt.WindowContextHelpButtonHint)
93
        self.exec_()
94
        return self.isAccepted, self.target
DTI_PID/DTI_PID/SymbolAttrTarget_UI.py
1
# -*- coding: utf-8 -*-
2

  
3
# Form implementation generated from reading ui file './UI/SymbolAttrTarget.ui'
4
#
5
# Created by: PyQt5 UI code generator 5.11.3
6
#
7
# WARNING! All changes made in this file will be lost!
8

  
9
from PyQt5 import QtCore, QtGui, QtWidgets
10

  
11
class Ui_AttributeTarget(object):
12
    def setupUi(self, AttributeTarget):
13
        AttributeTarget.setObjectName("AttributeTarget")
14
        AttributeTarget.resize(496, 341)
15
        font = QtGui.QFont()
16
        font.setFamily("맑은 고딕")
17
        AttributeTarget.setFont(font)
18
        icon = QtGui.QIcon()
19
        icon.addPixmap(QtGui.QPixmap(":/newPrefix/setting.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
20
        AttributeTarget.setWindowIcon(icon)
21
        self.gridLayout = QtWidgets.QGridLayout(AttributeTarget)
22
        self.gridLayout.setObjectName("gridLayout")
23
        self.buttonBox = QtWidgets.QDialogButtonBox(AttributeTarget)
24
        self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
25
        self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
26
        self.buttonBox.setObjectName("buttonBox")
27
        self.gridLayout.addWidget(self.buttonBox, 2, 0, 1, 1)
28
        self.groupBoxTitleBlock = QtWidgets.QGroupBox(AttributeTarget)
29
        self.groupBoxTitleBlock.setObjectName("groupBoxTitleBlock")
30
        self.gridLayout_4 = QtWidgets.QGridLayout(self.groupBoxTitleBlock)
31
        self.gridLayout_4.setObjectName("gridLayout_4")
32
        self.verticalLayout_3 = QtWidgets.QVBoxLayout()
33
        self.verticalLayout_3.setObjectName("verticalLayout_3")
34
        self.horizontalLayout_4 = QtWidgets.QHBoxLayout()
35
        self.horizontalLayout_4.setObjectName("horizontalLayout_4")
36
        self.tableWidget = QtWidgets.QTableWidget(self.groupBoxTitleBlock)
37
        self.tableWidget.setColumnCount(2)
38
        self.tableWidget.setObjectName("tableWidget")
39
        self.tableWidget.setRowCount(0)
40
        self.horizontalLayout_4.addWidget(self.tableWidget)
41
        self.verticalLayout_3.addLayout(self.horizontalLayout_4)
42
        self.gridLayout_4.addLayout(self.verticalLayout_3, 1, 0, 1, 1)
43
        self.horizontalLayout = QtWidgets.QHBoxLayout()
44
        self.horizontalLayout.setObjectName("horizontalLayout")
45
        self.checkBox = QtWidgets.QCheckBox(self.groupBoxTitleBlock)
46
        self.checkBox.setObjectName("checkBox")
47
        self.horizontalLayout.addWidget(self.checkBox)
48
        spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
49
        self.horizontalLayout.addItem(spacerItem)
50
        self.gridLayout_4.addLayout(self.horizontalLayout, 0, 0, 1, 1)
51
        self.gridLayout.addWidget(self.groupBoxTitleBlock, 1, 0, 1, 1)
52

  
53
        self.retranslateUi(AttributeTarget)
54
        self.buttonBox.accepted.connect(AttributeTarget.accept)
55
        self.buttonBox.rejected.connect(AttributeTarget.reject)
56
        QtCore.QMetaObject.connectSlotsByName(AttributeTarget)
57

  
58
    def retranslateUi(self, AttributeTarget):
59
        _translate = QtCore.QCoreApplication.translate
60
        AttributeTarget.setWindowTitle(_translate("AttributeTarget", "Attribute Target"))
61
        self.groupBoxTitleBlock.setTitle(_translate("AttributeTarget", "Symbols"))
62
        self.checkBox.setText(_translate("AttributeTarget", "Select All"))
63

  
64
import MainWindow_rc
65

  
66
if __name__ == "__main__":
67
    import sys
68
    app = QtWidgets.QApplication(sys.argv)
69
    AttributeTarget = QtWidgets.QDialog()
70
    ui = Ui_AttributeTarget()
71
    ui.setupUi(AttributeTarget)
72
    AttributeTarget.show()
73
    sys.exit(app.exec_())
74

  
DTI_PID/DTI_PID/UI/SymbolAttrTarget.ui
1
<?xml version="1.0" encoding="UTF-8"?>
2
<ui version="4.0">
3
 <class>AttributeTarget</class>
4
 <widget class="QDialog" name="AttributeTarget">
5
  <property name="geometry">
6
   <rect>
7
    <x>0</x>
8
    <y>0</y>
9
    <width>496</width>
10
    <height>341</height>
11
   </rect>
12
  </property>
13
  <property name="font">
14
   <font>
15
    <family>맑은 고딕</family>
16
   </font>
17
  </property>
18
  <property name="windowTitle">
19
   <string>Attribute Target</string>
20
  </property>
21
  <property name="windowIcon">
22
   <iconset resource="../res/MainWindow.qrc">
23
    <normaloff>:/newPrefix/setting.png</normaloff>:/newPrefix/setting.png</iconset>
24
  </property>
25
  <layout class="QGridLayout" name="gridLayout">
26
   <item row="2" column="0">
27
    <widget class="QDialogButtonBox" name="buttonBox">
28
     <property name="orientation">
29
      <enum>Qt::Horizontal</enum>
30
     </property>
31
     <property name="standardButtons">
32
      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
33
     </property>
34
    </widget>
35
   </item>
36
   <item row="1" column="0">
37
    <widget class="QGroupBox" name="groupBoxTitleBlock">
38
     <property name="title">
39
      <string>Symbols</string>
40
     </property>
41
     <layout class="QGridLayout" name="gridLayout_4">
42
      <item row="1" column="0">
43
       <layout class="QVBoxLayout" name="verticalLayout_3">
44
        <item>
45
         <layout class="QHBoxLayout" name="horizontalLayout_4">
46
          <item>
47
           <widget class="QTableWidget" name="tableWidget">
48
            <property name="columnCount">
49
             <number>2</number>
50
            </property>
51
            <column/>
52
            <column/>
53
           </widget>
54
          </item>
55
         </layout>
56
        </item>
57
       </layout>
58
      </item>
59
      <item row="0" column="0">
60
       <layout class="QHBoxLayout" name="horizontalLayout">
61
        <item>
62
         <widget class="QCheckBox" name="checkBox">
63
          <property name="text">
64
           <string>Select All</string>
65
          </property>
66
         </widget>
67
        </item>
68
        <item>
69
         <spacer name="horizontalSpacer">
70
          <property name="orientation">
71
           <enum>Qt::Horizontal</enum>
72
          </property>
73
          <property name="sizeHint" stdset="0">
74
           <size>
75
            <width>40</width>
76
            <height>20</height>
77
           </size>
78
          </property>
79
         </spacer>
80
        </item>
81
       </layout>
82
      </item>
83
     </layout>
84
    </widget>
85
   </item>
86
  </layout>
87
 </widget>
88
 <resources>
89
  <include location="../res/MainWindow.qrc"/>
90
 </resources>
91
 <connections>
92
  <connection>
93
   <sender>buttonBox</sender>
94
   <signal>accepted()</signal>
95
   <receiver>AttributeTarget</receiver>
96
   <slot>accept()</slot>
97
   <hints>
98
    <hint type="sourcelabel">
99
     <x>248</x>
100
     <y>254</y>
101
    </hint>
102
    <hint type="destinationlabel">
103
     <x>157</x>
104
     <y>274</y>
105
    </hint>
106
   </hints>
107
  </connection>
108
  <connection>
109
   <sender>buttonBox</sender>
110
   <signal>rejected()</signal>
111
   <receiver>AttributeTarget</receiver>
112
   <slot>reject()</slot>
113
   <hints>
114
    <hint type="sourcelabel">
115
     <x>316</x>
116
     <y>260</y>
117
    </hint>
118
    <hint type="destinationlabel">
119
     <x>286</x>
120
     <y>274</y>
121
    </hint>
122
   </hints>
123
  </connection>
124
 </connections>
125
</ui>

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)