Helpviewer/CookieJar/CookiesExceptionsDialog.py

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

eric ide

mercurial