-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtrashdelegate.py
More file actions
35 lines (27 loc) · 1.23 KB
/
Copy pathtrashdelegate.py
File metadata and controls
35 lines (27 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# This Python file uses the following encoding: utf-8
from PySide2 import QtWidgets
from PySide2.QtWidgets import QStyledItemDelegate
from PySide2.QtCore import *
from PySide2.QtGui import *
from PySide2.QtWidgets import *
from resources_rc import *
import usetablemodel
class TrashDelegate(QItemDelegate):
pressed = Signal(str, QModelIndex, QModelIndex)
def __init__(self, parent=None):
QItemDelegate.__init__(self, parent)
def createEditor(self, parent, option, index):
sourceModelIndex = (index.model().mapToSource(index))
realSourceModelIndex = sourceModelIndex.model().mapToSource(sourceModelIndex)
#The index goes from the Proxy Model to the Table Model to look into the masterlist.
self.pressed.emit(index.model().sourceModel().sourceModel().metadataList[realSourceModelIndex.row()]["Source"],realSourceModelIndex, sourceModelIndex,)
def paint(self, painter, option, index):
icon = QIcon(QPixmap(':/resources/close-pushed@2x.png'))
painter.save()
line_1x = icon.pixmap(16,16)
painter.drawPixmap(option.rect.x()+option.rect.width()/2 - 8 ,
option.rect.y()+option.rect.height()/2 - 8,
16,
16,
line_1x)
painter.restore()