8 """ |
8 """ |
9 |
9 |
10 from PyQt4.QtCore import pyqtSignal, QRect |
10 from PyQt4.QtCore import pyqtSignal, QRect |
11 from PyQt4.QtGui import QListWidget, QListWidgetItem |
11 from PyQt4.QtGui import QListWidget, QListWidgetItem |
12 |
12 |
13 from .GreaseMonkeyConfigurationListDelegate import GreaseMonkeyConfigurationListDelegate |
13 from .GreaseMonkeyConfigurationListDelegate import \ |
|
14 GreaseMonkeyConfigurationListDelegate |
14 |
15 |
15 |
16 |
16 class GreaseMonkeyConfigurationListWidget(QListWidget): |
17 class GreaseMonkeyConfigurationListWidget(QListWidget): |
17 """ |
18 """ |
18 Class implementing a special list widget for GreaseMonkey scripts. |
19 Class implementing a special list widget for GreaseMonkey scripts. |
30 self.__delegate = GreaseMonkeyConfigurationListDelegate(self) |
31 self.__delegate = GreaseMonkeyConfigurationListDelegate(self) |
31 self.setItemDelegate(self.__delegate) |
32 self.setItemDelegate(self.__delegate) |
32 |
33 |
33 def __containsRemoveIcon(self, pos): |
34 def __containsRemoveIcon(self, pos): |
34 """ |
35 """ |
35 Private method to check, if the given position is inside the remove icon. |
36 Private method to check, if the given position is inside the remove |
|
37 icon. |
36 |
38 |
37 @param pos position to check for (QPoint) |
39 @param pos position to check for (QPoint) |
38 @return flag indicating success (boolean) |
40 @return flag indicating success (boolean) |
39 """ |
41 """ |
40 itm = self.itemAt(pos) |
42 itm = self.itemAt(pos) |
45 iconSize = GreaseMonkeyConfigurationListDelegate.RemoveIconSize |
47 iconSize = GreaseMonkeyConfigurationListDelegate.RemoveIconSize |
46 removeIconXPos = rect.right() - self.__delegate.padding() - iconSize |
48 removeIconXPos = rect.right() - self.__delegate.padding() - iconSize |
47 center = rect.height() // 2 + rect.top() |
49 center = rect.height() // 2 + rect.top() |
48 removeIconYPos = center - iconSize // 2 |
50 removeIconYPos = center - iconSize // 2 |
49 |
51 |
50 removeIconRect = QRect(removeIconXPos, removeIconYPos, iconSize, iconSize) |
52 removeIconRect = QRect(removeIconXPos, removeIconYPos, |
|
53 iconSize, iconSize) |
51 return removeIconRect.contains(pos) |
54 return removeIconRect.contains(pos) |
52 |
55 |
53 def mousePressEvent(self, evt): |
56 def mousePressEvent(self, evt): |
54 """ |
57 """ |
55 Private method handling presses of mouse buttons. |
58 Private method handling presses of mouse buttons. |