def __showCookieDetails(self, index): """ Private slot to show a dialog with the cookie details. @param index index of the entry to show (QModelIndex) """ if not index.isValid(): return cookiesTable = self.sender() if cookiesTable is None: return model = cookiesTable.model() row = index.row() domain = model.data(model.index(row, 0)) name = model.data(model.index(row, 1)) path = model.data(model.index(row, 2)) secure = model.data(model.index(row, 3)) expires = model.data(model.index(row, 4)).toString("yyyy-MM-dd hh:mm") value = bytes( QByteArray.fromPercentEncoding( model.data(model.index(row, 5)))).decode() if self.__detailsDialog is None: from .CookieDetailsDialog import CookieDetailsDialog self.__detailsDialog = CookieDetailsDialog(self) self.__detailsDialog.setData(domain, name, path, secure, expires, value) self.__detailsDialog.show()
def on_cookiesTree_currentItemChanged(self, current, previous): """ Private slot to handle a change of the current item. @param current reference to the current item @type QTreeWidgetItem @param previous reference to the previous current item @type QTreeWidgetItem """ self.addButton.setEnabled(current is not None) self.removeButton.setEnabled(current is not None) if current is None: return if not current.text(1): # it is a cookie domain entry self.domain.setText(self.tr("<no cookie selected>")) self.name.setText(self.tr("<no cookie selected>")) self.path.setText(self.tr("<no cookie selected>")) self.secure.setText(self.tr("<no cookie selected>")) self.expiration.setText(self.tr("<no cookie selected>")) self.value.setText(self.tr("<no cookie selected>")) self.removeButton.setText(self.tr("Remove Cookies")) else: # it is a cookie entry cookie = current.data(0, self.CookieRole) self.domain.setText(cookie.domain()) self.name.setText(bytes(cookie.name()).decode()) self.path.setText(cookie.path()) if cookie.isSecure(): self.secure.setText(self.tr("Secure connections only")) else: self.secure.setText(self.tr("All connections")) if cookie.isSessionCookie(): self.expiration.setText(self.tr("Session Cookie")) else: self.expiration.setText( cookie.expirationDate().toString("yyyy-MM-dd HH:mm:ss")) self.value.setText( bytes(QByteArray.fromPercentEncoding(cookie.value())).decode()) self.removeButton.setText(self.tr("Remove Cookie"))