프로젝트

일반

사용자정보

개정판 01f38883

ID01f3888399d17ff5f9ad5fa1317d897e5f84f92d
상위 5588887a
하위 e8af48af

함의성이(가) 약 6년 전에 추가함

issue #665: debug delete

차이점 보기:

DTI_PID/DTI_PID/ItemDataExportDialog.py
31 31

  
32 32
        self.delimiter = '!-!'
33 33
        self.delimiterCombine = '!@!'
34
        self.emptyCol = 'Empty col'
34
        self.emptyCol = 'Empty Column'
35 35
        self.initialTables = []
36 36

  
37 37
        self.sceneLineData = {}
DTI_PID/DTI_PID/ItemDataFormatDialog.py
30 30

  
31 31
        self.delimiter = '!-!'
32 32
        self.delimiterCombine = '!@!'
33
        self.emptyCol = 'Empty col'
33
        self.emptyCol = 'Empty Column'
34 34
        self.selectedCol = None
35 35

  
36 36
        self.listWidgets = []
......
61 61
        self.items.append(self.instrumentItemDoubleCliked)
62 62
        self.items.append(self.noteItemDoubleCliked)
63 63

  
64
        self.drops = []
65
        self.drops.append(self.lineDropEvent)
66
        self.drops.append(self.equipmentDropEvent)
67
        self.drops.append(self.valveDropEvent)
68
        self.drops.append(self.instrumentDropEvent)
69
        self.drops.append(self.noteDropEvent)
70

  
64 71
        self.deleteButtons = []
65 72
        self.deleteButtons.append(self.ui.pushButtonLineDelete)
66 73
        self.deleteButtons.append(self.ui.pushButtonEquipmentDelete)
......
102 109
        self.emptys.append(self.valveEmptyClicked)
103 110
        self.emptys.append(self.instrumentEmptyClicked)
104 111
        self.emptys.append(self.noteEmptyClicked)
105

  
112
        '''test'''
113
        self.dragItem = ''
114
        '''test'''
106 115
        # tableWidget setting
107 116
        for index in range(len(self.tableWidgets)):
108 117
            self.tableWidgets[index].horizontalHeader().setSectionsMovable(True)
......
120 129
            for ucol in range(len(self.columnOrder[index])):
121 130
                self.tableWidgets[index].setItem(0, ucol, QTableWidgetItem(userHeaders[ucol]))
122 131
            self.tableWidgets[index].horizontalHeader().sectionClicked.connect(self.sections[index])
132
            self.tableWidgets[index].cellClicked.connect(self.sections[index])
123 133
            self.deleteButtons[index].clicked.connect(self.deletes[index])
124 134
            self.addButtons[index].clicked.connect(self.adds[index])
125 135
            self.emptyButtons[index].clicked.connect(self.emptys[index])
......
128 138
                self.tableWidgets[index].setColumnWidth(listIndex, len(headers[listIndex]) * 8 + 10)
129 139
            self.tableWidgets[index].hideColumn(0)
130 140

  
141
            self.tableWidgets[index].setDragDropMode(QAbstractItemView.DropOnly)
142
            self.tableWidgets[index].setAcceptDrops(True)
143
            self.tableWidgets[index].dropEvent = self.drops[index]
144

  
131 145
        savedBackground = False
132 146
        self.originBackground = None
133 147
        self.selectionBackground = QColor(255, 255, 255)
......
146 160
                        item.setBackground(self.selectionBackground)
147 161
                        break
148 162

  
163
            self.listWidgets[index].setDragDropMode(QAbstractItemView.DragDrop)
164
            self.listWidgets[index].dragEnterEvent = self.dragEnterEvent
165

  
149 166
        self.ui.pushButtonApply.clicked.connect(self.pushButtonApplyClicked)
150 167
        self.ui.pushButtonClose.clicked.connect(self.pushButtonCloseClicked)
151 168

  
152 169
    '''
170
        @brief      add column by drag and drop
171
        @author     euisung
172
        @date       2018.10.30
173
    '''
174
    def dragEnterEvent(self, event):
175
        self.dragItem = self.focusWidget().item(self.focusWidget().indexAt(event.pos()).row()).text()
176

  
177
    def dropEvent(self, event, table, alist):
178
        loc = self.tableWidgets[0].indexAt(event.pos()).column()
179
        item = QTableWidgetItem(self.dragItem)
180
        self.listItemDoubleClicked(table, item, alist, loc)
181
        
182
    def lineDropEvent(self, event):
183
        self.dropEvent(event, self.tableWidgets[0], self.listWidgets[0])
184
    
185
    def equipmentDropEvent(self, event):
186
        self.dropEvent(event, self.tableWidgets[1], self.listWidgets[1])
187
    
188
    def valveDropEvent(self, event):
189
        self.dropEvent(event, self.tableWidgets[2], self.listWidgets[2])
190
        
191
    def instrumentDropEvent(self, event):
192
        self.dropEvent(event, self.tableWidgets[3], self.listWidgets[3])
193
    
194
    def noteDropEvent(self, event):
195
        self.dropEvent(event, self.tableWidgets[4], self.listWidgets[4])
196

  
197
    '''
153 198
        @brief      add empty column
154 199
        @author     euisung
155 200
        @date       2018.10.29
......
209 254
        @author     euisung
210 255
        @date       2018.10.25
211 256
    '''
212
    def listItemDoubleClicked(self, table, item, alist):
257
    def listItemDoubleClicked(self, table, item, alist, loc = 0):
213 258
        if item == None:
214 259
            return
215 260
        for index in range(table.columnCount()):
......
221 266
        table.setItem(0, table.columnCount() - 1, QTableWidgetItem(item.text()))
222 267
        table.horizontalHeaderItem(table.columnCount() - 1).setSizeHint(QSize(25, 25))
223 268
        table.setColumnWidth(table.columnCount() - 1, len(item.text()) * 8 + 10)
224
        table.horizontalHeader().moveSection(table.columnCount() - 1, 1)
269
        table.horizontalHeader().moveSection(table.columnCount() - 1, loc)
225 270
        for logical in range(alist.count()):
226 271
            if item.text() == alist.item(logical).text():
227 272
                alist.item(logical).setBackground(self.selectionBackground)
......
258 303
    '''
259 304
    def keyPressEvent(self, event):
260 305
        try:
261
            if event.key() == Qt.Key_Delete and self.selectedCol is not None:
306
            if event.key() == Qt.Key_Delete and self.selectedCol is not None and self.selectedCol[0].columnCount() is not 1 and self.selectedCol[0].currentColumn() is not 0:
262 307
                for logical in range(self.selectedCol[2].count()):
263 308
                    if self.selectedCol[0].horizontalHeaderItem(self.selectedCol[1]).text() == self.selectedCol[2].item(logical).text():
264 309
                        self.selectedCol[2].item(logical).setBackground(self.originBackground)
265 310
                        break
266 311
                self.selectedCol[0].removeColumn(self.selectedCol[1])
267
                self.selectedCol[0].setCurrentCell(0, self.selectedCol[1])
312
                if self.selectedCol[1] is self.selectedCol[0].columnCount():
313
                    self.selectedCol[0].setCurrentCell(0, self.selectedCol[1] - 1)
314
                    self.selectedCol[1] = self.selectedCol[1] -1
315
                    if self.selectedCol[0].colorCount() is 1:
316
                        self.selectedCol = []
317
                else:
318
                    self.selectedCol[0].setCurrentCell(0, self.selectedCol[1])
268 319
                
269 320
            QDialog.keyPressEvent(self, event)
270 321
        except Exception as ex:
......
336 387
        @date       2018.10.25
337 388
    '''
338 389
    def sectionClicked(self, table, logicalIndex, alist):
339
        table.setCurrentCell(0, logicalIndex)
340
        self.selectedCol = [table, logicalIndex, alist]
390
        if logicalIndex is not 0:
391
            table.setCurrentCell(0, logicalIndex)
392
            self.selectedCol = [table, logicalIndex, alist]
393
        else:
394
            self.selectedCol = [table, table.currentColumn(), alist]
395

  
341 396

  
342 397
    def lineSectionClicked(self, logicalIndex):
343 398
        self.sectionClicked(self.tableWidgets[0], logicalIndex, self.listWidgets[0])

내보내기 Unified diff

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