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