6 """ |
6 """ |
7 Module implementing a dialog for the configuration of cookie exceptions. |
7 Module implementing a dialog for the configuration of cookie exceptions. |
8 """ |
8 """ |
9 |
9 |
10 from PyQt4.QtCore import pyqtSlot |
10 from PyQt4.QtCore import pyqtSlot |
11 from PyQt4.QtGui import QDialog, QSortFilterProxyModel, QCompleter, QFont, QFontMetrics |
11 from PyQt4.QtGui import QDialog, QSortFilterProxyModel, QCompleter, QFont, \ |
|
12 QFontMetrics |
12 |
13 |
13 from .CookieExceptionsModel import CookieExceptionsModel |
14 from .CookieExceptionsModel import CookieExceptionsModel |
14 from .CookieModel import CookieModel |
15 from .CookieModel import CookieModel |
15 |
16 |
16 from .Ui_CookiesExceptionsDialog import Ui_CookiesExceptionsDialog |
17 from .Ui_CookiesExceptionsDialog import Ui_CookiesExceptionsDialog |
30 super().__init__(parent) |
31 super().__init__(parent) |
31 self.setupUi(self) |
32 self.setupUi(self) |
32 |
33 |
33 self.__cookieJar = cookieJar |
34 self.__cookieJar = cookieJar |
34 |
35 |
35 self.removeButton.clicked[()].connect(self.exceptionsTable.removeSelected) |
36 self.removeButton.clicked[()].connect( |
36 self.removeAllButton.clicked[()].connect(self.exceptionsTable.removeAll) |
37 self.exceptionsTable.removeSelected) |
|
38 self.removeAllButton.clicked[()].connect( |
|
39 self.exceptionsTable.removeAll) |
37 |
40 |
38 self.exceptionsTable.verticalHeader().hide() |
41 self.exceptionsTable.verticalHeader().hide() |
39 self.__exceptionsModel = CookieExceptionsModel(cookieJar) |
42 self.__exceptionsModel = CookieExceptionsModel(cookieJar) |
40 self.__proxyModel = QSortFilterProxyModel(self) |
43 self.__proxyModel = QSortFilterProxyModel(self) |
41 self.__proxyModel.setSourceModel(self.__exceptionsModel) |
44 self.__proxyModel.setSourceModel(self.__exceptionsModel) |
42 self.searchEdit.textChanged.connect(self.__proxyModel.setFilterFixedString) |
45 self.searchEdit.textChanged.connect( |
|
46 self.__proxyModel.setFilterFixedString) |
43 self.exceptionsTable.setModel(self.__proxyModel) |
47 self.exceptionsTable.setModel(self.__proxyModel) |
44 |
48 |
45 cookieModel = CookieModel(cookieJar, self) |
49 cookieModel = CookieModel(cookieJar, self) |
46 self.domainEdit.setCompleter(QCompleter(cookieModel, self.domainEdit)) |
50 self.domainEdit.setCompleter(QCompleter(cookieModel, self.domainEdit)) |
47 |
51 |
50 fm = QFontMetrics(f) |
54 fm = QFontMetrics(f) |
51 height = fm.height() + fm.height() // 3 |
55 height = fm.height() + fm.height() // 3 |
52 self.exceptionsTable.verticalHeader().setDefaultSectionSize(height) |
56 self.exceptionsTable.verticalHeader().setDefaultSectionSize(height) |
53 self.exceptionsTable.verticalHeader().setMinimumSectionSize(-1) |
57 self.exceptionsTable.verticalHeader().setMinimumSectionSize(-1) |
54 for section in range(self.__exceptionsModel.columnCount()): |
58 for section in range(self.__exceptionsModel.columnCount()): |
55 header = self.exceptionsTable.horizontalHeader().sectionSizeHint(section) |
59 header = self.exceptionsTable.horizontalHeader()\ |
|
60 .sectionSizeHint(section) |
56 if section == 0: |
61 if section == 0: |
57 header = fm.width("averagebiglonghost.averagedomain.info") |
62 header = fm.width("averagebiglonghost.averagedomain.info") |
58 elif section == 1: |
63 elif section == 1: |
59 header = fm.width(self.trUtf8("Allow For Session")) |
64 header = fm.width(self.trUtf8("Allow For Session")) |
60 buffer = fm.width("mm") |
65 buffer = fm.width("mm") |
61 header += buffer |
66 header += buffer |
62 self.exceptionsTable.horizontalHeader().resizeSection(section, header) |
67 self.exceptionsTable.horizontalHeader()\ |
|
68 .resizeSection(section, header) |
63 |
69 |
64 def setDomainName(self, domain): |
70 def setDomainName(self, domain): |
65 """ |
71 """ |
66 Public method to set the domain to be displayed. |
72 Public method to set the domain to be displayed. |
67 |
73 |
93 def on_allowForSessionButton_clicked(self): |
99 def on_allowForSessionButton_clicked(self): |
94 """ |
100 """ |
95 Private slot to allow cookies of a domain for the current session only. |
101 Private slot to allow cookies of a domain for the current session only. |
96 """ |
102 """ |
97 from .CookieJar import CookieJar |
103 from .CookieJar import CookieJar |
98 self.__exceptionsModel.addRule(self.domainEdit.text(), CookieJar.AllowForSession) |
104 self.__exceptionsModel.addRule(self.domainEdit.text(), |
|
105 CookieJar.AllowForSession) |
99 |
106 |
100 @pyqtSlot() |
107 @pyqtSlot() |
101 def on_allowButton_clicked(self): |
108 def on_allowButton_clicked(self): |
102 """ |
109 """ |
103 Private slot to allow cookies of a domain. |
110 Private slot to allow cookies of a domain. |