# Path: lazylyst/CustomWidgets.py
# class MixListWidget(QtWidgets.QListWidget):       
#     # Return signal if key was pressed while in focus
#     keyPressedSignal=QtCore.pyqtSignal()  
#     leaveSignal=QtCore.pyqtSignal()
#     
#     def __init__(self, parent=None):
#         super(MixListWidget, self).__init__(parent)
#     
#     # Update this widgets last pressed key, and return a signal
#     def keyPressEvent(self, ev):
#         self.key=ev.key()
#         if self.key not in [Qt.Key_Insert,Qt.Key_Delete]:
#             return
#         self.keyPressedSignal.emit()
#         
#     # Deselect all items if in a blank space
#     def mousePressEvent(self, ev):
#         if self.itemAt(ev.pos()) is None:
#             self.clearSelection()
#         QtWidgets.QListWidget.mousePressEvent(self, ev)
#         
#     # Swapping a double click with the backspace button...
#     # ...wanted to transmit double click as a key
#     def mouseDoubleClickEvent(self,ev):
#         # Only allow left-double clicks
#         if ev.button()!=1:
#             return
#         self.key=Qt.Key_Backspace
#         self.keyPressedSignal.emit()
# 
#     # Ensure that key presses are sent to the widget which the mouse is hovering over
#     def enterEvent(self,ev):
#         super(MixListWidget, self).enterEvent(ev)
#         self.setFocus()
# 
#     # If ever the list if left by the mouse, emit (used to trigger ordering of passive functions)
#     def leaveEvent(self,ev):
#         self.leaveSignal.emit()
#         
#     # Return the lists entries in the order which it appears
#     def visualListOrder(self):
#         txt=np.array([self.item(i).text() for i in range(self.count())])
#         args=np.array([self.indexFromItem(self.item(i)).row() for i in range(self.count())])
#         return list(txt[np.argsort(args)])


from PyQt5 import QtCore, QtGui, QtWidgets
from lazylyst.CustomWidgets import MixListWidget
        self.confPassiveLabel.setAlignment(QtCore.Qt.AlignCenter)
        self.confPassiveLabel.setObjectName("confPassiveLabel")
        self.confPassiveTopLayout.addWidget(self.confPassiveLabel)
        spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.confPassiveTopLayout.addItem(spacerItem1)
        self.confPassiveAddButton = QtWidgets.QPushButton(ConfDialog)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.confPassiveAddButton.sizePolicy().hasHeightForWidth())
        self.confPassiveAddButton.setSizePolicy(sizePolicy)
        self.confPassiveAddButton.setMinimumSize(QtCore.QSize(25, 25))
        self.confPassiveAddButton.setMaximumSize(QtCore.QSize(25, 25))
        self.confPassiveAddButton.setAutoDefault(False)
        self.confPassiveAddButton.setDefault(False)
        self.confPassiveAddButton.setFlat(False)
        self.confPassiveAddButton.setObjectName("confPassiveAddButton")
        self.confPassiveTopLayout.addWidget(self.confPassiveAddButton)
        self.confPassiveDelButton = QtWidgets.QPushButton(ConfDialog)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.confPassiveDelButton.sizePolicy().hasHeightForWidth())
        self.confPassiveDelButton.setSizePolicy(sizePolicy)
        self.confPassiveDelButton.setMinimumSize(QtCore.QSize(25, 25))
        self.confPassiveDelButton.setMaximumSize(QtCore.QSize(25, 25))
        self.confPassiveDelButton.setAutoDefault(False)
        self.confPassiveDelButton.setObjectName("confPassiveDelButton")
        self.confPassiveTopLayout.addWidget(self.confPassiveDelButton)
        self.confPassiveLayout.addLayout(self.confPassiveTopLayout)

# Path: lazylyst/CustomWidgets.py
# class MixListWidget(QtWidgets.QListWidget):       
#     # Return signal if key was pressed while in focus
#     keyPressedSignal=QtCore.pyqtSignal()  
#     leaveSignal=QtCore.pyqtSignal()
#     
#     def __init__(self, parent=None):
#         super(MixListWidget, self).__init__(parent)
#     
#     # Update this widgets last pressed key, and return a signal
#     def keyPressEvent(self, ev):
#         self.key=ev.key()
#         if self.key not in [Qt.Key_Insert,Qt.Key_Delete]:
#             return
#         self.keyPressedSignal.emit()
#         
#     # Deselect all items if in a blank space
#     def mousePressEvent(self, ev):
#         if self.itemAt(ev.pos()) is None:
#             self.clearSelection()
#         QtWidgets.QListWidget.mousePressEvent(self, ev)
#         
#     # Swapping a double click with the backspace button...
#     # ...wanted to transmit double click as a key
#     def mouseDoubleClickEvent(self,ev):
#         # Only allow left-double clicks
#         if ev.button()!=1:
#             return
#         self.key=Qt.Key_Backspace
#         self.keyPressedSignal.emit()
# 
#     # Ensure that key presses are sent to the widget which the mouse is hovering over
#     def enterEvent(self,ev):
#         super(MixListWidget, self).enterEvent(ev)
#         self.setFocus()
# 
#     # If ever the list if left by the mouse, emit (used to trigger ordering of passive functions)
#     def leaveEvent(self,ev):
#         self.leaveSignal.emit()
#         
#     # Return the lists entries in the order which it appears
#     def visualListOrder(self):
#         txt=np.array([self.item(i).text() for i in range(self.count())])
#         args=np.array([self.indexFromItem(self.item(i)).row() for i in range(self.count())])
#         return list(txt[np.argsort(args)])


# Path: lazylyst/UI/Configuration.py
from PyQt5 import QtCore, QtGui, QtWidgets
from lazylyst.CustomWidgets import MixListWidget

        self.confPassiveLabel.setAlignment(QtCore.Qt.AlignCenter)
        self.confPassiveLabel.setObjectName("confPassiveLabel")
        self.confPassiveTopLayout.addWidget(self.confPassiveLabel)
        spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.confPassiveTopLayout.addItem(spacerItem1)
        self.confPassiveAddButton = QtWidgets.QPushButton(ConfDialog)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.confPassiveAddButton.sizePolicy().hasHeightForWidth())
        self.confPassiveAddButton.setSizePolicy(sizePolicy)
        self.confPassiveAddButton.setMinimumSize(QtCore.QSize(25, 25))
        self.confPassiveAddButton.setMaximumSize(QtCore.QSize(25, 25))
        self.confPassiveAddButton.setAutoDefault(False)
        self.confPassiveAddButton.setDefault(False)
        self.confPassiveAddButton.setFlat(False)
        self.confPassiveAddButton.setObjectName("confPassiveAddButton")
        self.confPassiveTopLayout.addWidget(self.confPassiveAddButton)
        self.confPassiveDelButton = QtWidgets.QPushButton(ConfDialog)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.confPassiveDelButton.sizePolicy().hasHeightForWidth())
        self.confPassiveDelButton.setSizePolicy(sizePolicy)
        self.confPassiveDelButton.setMinimumSize(QtCore.QSize(25, 25))
        self.confPassiveDelButton.setMaximumSize(QtCore.QSize(25, 25))
        self.confPassiveDelButton.setAutoDefault(False)
        self.confPassiveDelButton.setObjectName("confPassiveDelButton")
        self.confPassiveTopLayout.addWidget(self.confPassiveDelButton)
        self.confPassiveLayout.addLayout(self.confPassiveTopLayout)

        self.confPassiveList = MixListWidget(ConfDialog)