Made the second set of Qt5 compatibility changes.

Sun, 30 Sep 2012 17:04:23 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 30 Sep 2012 17:04:23 +0200
changeset 2078
9f4a45741622
parent 2077
68a34718a0ce
child 2079
febae63bb821

Made the second set of Qt5 compatibility changes.

Documentation/Help/source.qch file | annotate | diff | comparison | revisions
Helpviewer/HelpBrowserWV.py file | annotate | diff | comparison | revisions
Helpviewer/Network/NetworkAccessManager.py file | annotate | diff | comparison | revisions
Helpviewer/SiteInfo/SiteInfoDialog.py file | annotate | diff | comparison | revisions
Helpviewer/SslCertificatesDialog.py file | annotate | diff | comparison | revisions
Helpviewer/SslInfoWidget.py file | annotate | diff | comparison | revisions
Helpviewer/UrlBar/UrlBar.py file | annotate | diff | comparison | revisions
Binary file Documentation/Help/source.qch has changed
--- a/Helpviewer/HelpBrowserWV.py	Sun Sep 30 13:27:28 2012 +0200
+++ b/Helpviewer/HelpBrowserWV.py	Sun Sep 30 17:04:23 2012 +0200
@@ -10,7 +10,7 @@
 
 from PyQt4.QtCore import pyqtSlot, pyqtSignal, QObject, QT_TRANSLATE_NOOP, QUrl, \
     QBuffer, QIODevice, QFileInfo, Qt, QTimer, QEvent, QRect, QFile, QPoint, \
-    QByteArray
+    QByteArray, qVersion
 from PyQt4.QtGui import qApp, QDesktopServices, QStyle, QMenu, QApplication, \
     QInputDialog, QLineEdit, QClipboard, QMouseEvent, QLabel, QToolTip, QColor, \
     QPalette, QFrame, QPrinter, QPrintDialog, QDialog
@@ -519,9 +519,14 @@
                 if cert in localCAList:
                     return True
         
-        for cert in certList:
-            if not cert.isValid():
-                return False
+        if qVersion() >= "5.0.0":
+            for cert in certList:
+                if cert.isBlacklisted():
+                    return False
+        else:
+            for cert in certList:
+                if not cert.isValid():
+                    return False
         
         return True
     
--- a/Helpviewer/Network/NetworkAccessManager.py	Sun Sep 30 13:27:28 2012 +0200
+++ b/Helpviewer/Network/NetworkAccessManager.py	Sun Sep 30 17:04:23 2012 +0200
@@ -9,7 +9,7 @@
 
 import os
 
-from PyQt4.QtCore import pyqtSignal, QByteArray, Qt
+from PyQt4.QtCore import pyqtSignal, QByteArray, Qt, qVersion
 from PyQt4.QtGui import QDialog
 from PyQt4.QtNetwork import QNetworkAccessManager, QNetworkRequest, QNetworkReply
 try:
@@ -316,17 +316,30 @@
         """
         result = "<p>"
         
-        result += self.trUtf8("Name: {0}")\
-            .format(Qt.escape(Utilities.decodeString(
-                cert.subjectInfo(QSslCertificate.CommonName))))
-        
-        result += self.trUtf8("<br/>Organization: {0}")\
-            .format(Qt.escape(Utilities.decodeString(
-                cert.subjectInfo(QSslCertificate.Organization))))
-        
-        result += self.trUtf8("<br/>Issuer: {0}")\
-            .format(Qt.escape(Utilities.decodeString(
-                cert.issuerInfo(QSslCertificate.CommonName))))
+        if qVersion() >= "5.0.0":
+            result += self.trUtf8("Name: {0}")\
+                .format(Qt.escape(Utilities.decodeString(
+                    ", ".join(cert.subjectInfo(QSslCertificate.CommonName)))))
+            
+            result += self.trUtf8("<br/>Organization: {0}")\
+                .format(Qt.escape(Utilities.decodeString(
+                    ", ".join(cert.subjectInfo(QSslCertificate.Organization)))))
+            
+            result += self.trUtf8("<br/>Issuer: {0}")\
+                .format(Qt.escape(Utilities.decodeString(
+                    ", ".join(cert.issuerInfo(QSslCertificate.CommonName)))))
+        else:
+            result += self.trUtf8("Name: {0}")\
+                .format(Qt.escape(Utilities.decodeString(
+                    cert.subjectInfo(QSslCertificate.CommonName))))
+            
+            result += self.trUtf8("<br/>Organization: {0}")\
+                .format(Qt.escape(Utilities.decodeString(
+                    cert.subjectInfo(QSslCertificate.Organization))))
+            
+            result += self.trUtf8("<br/>Issuer: {0}")\
+                .format(Qt.escape(Utilities.decodeString(
+                    cert.issuerInfo(QSslCertificate.CommonName))))
         
         result += self.trUtf8("<br/>Not valid before: {0}<br/>Valid Until: {1}")\
             .format(Qt.escape(cert.effectiveDate().toString("yyyy-MM-dd")),
--- a/Helpviewer/SiteInfo/SiteInfoDialog.py	Sun Sep 30 13:27:28 2012 +0200
+++ b/Helpviewer/SiteInfo/SiteInfoDialog.py	Sun Sep 30 17:04:23 2012 +0200
@@ -9,7 +9,7 @@
 
 import os
 
-from PyQt4.QtCore import pyqtSlot, QUrl, Qt, QFile
+from PyQt4.QtCore import pyqtSlot, QUrl, Qt, QFile, qVersion
 from PyQt4.QtGui import QDialog, QTreeWidgetItem, QPixmap, QGraphicsScene, QMenu, \
     QCursor, QApplication, QListWidgetItem
 from PyQt4.QtWebKit import QWebSettings
@@ -88,7 +88,9 @@
         self.encodingLabel.setText(encoding)
         
         # populate the Security info and the Security tab
-        if sslInfo is not None and sslInfo.isValid():
+        if sslInfo is not None and \
+           ((qVersion() >= "5.0.0" and not sslInfo.isBlacklisted()) or \
+            (qVersion() < "5.0.0" and sslInfo.isValid())):
             self.securityLabel.setStyleSheet(SiteInfoDialog.okStyle)
             self.securityLabel.setText('<b>Connection is encrypted.</b>')
             if SSL:
--- a/Helpviewer/SslCertificatesDialog.py	Sun Sep 30 13:27:28 2012 +0200
+++ b/Helpviewer/SslCertificatesDialog.py	Sun Sep 30 17:04:23 2012 +0200
@@ -7,7 +7,8 @@
 Module implementing a dialog to show and edit all certificates.
 """
 
-from PyQt4.QtCore import pyqtSlot, Qt, QByteArray, QFile, QFileInfo, QIODevice
+from PyQt4.QtCore import pyqtSlot, Qt, QByteArray, QFile, QFileInfo, QIODevice, \
+    qVersion
 from PyQt4.QtGui import QDialog, QTreeWidgetItem
 try:
     from PyQt4.QtNetwork import QSslCertificate, QSslSocket, QSslConfiguration, QSsl
@@ -67,12 +68,18 @@
         @param cert certificate to insert (QSslCertificate)
         """
         # step 1: extract the info to be shown
-        organisation = Qt.escape(Utilities.decodeString(
-            cert.subjectInfo(QSslCertificate.Organization)))
+        if qVersion() >= "5.0.0":
+            organisation = Qt.escape(Utilities.decodeString(
+                ", ".join(cert.subjectInfo(QSslCertificate.Organization))))
+            commonName = Qt.escape(Utilities.decodeString(
+                ", ".join(cert.subjectInfo(QSslCertificate.CommonName))))
+        else:
+            organisation = Qt.escape(Utilities.decodeString(
+                cert.subjectInfo(QSslCertificate.Organization)))
+            commonName = Qt.escape(Utilities.decodeString(
+                cert.subjectInfo(QSslCertificate.CommonName)))
         if organisation is None or organisation == "":
             organisation = self.trUtf8("(Unknown)")
-        commonName = Qt.escape(Utilities.decodeString(
-            cert.subjectInfo(QSslCertificate.CommonName)))
         if commonName is None or commonName == "":
             commonName = self.trUtf8("(Unknown common name)")
         expiryDate = Qt.escape(cert.expiryDate().toString("yyyy-MM-dd"))
@@ -174,12 +181,16 @@
             pems = QByteArray()
             for cert in certs:
                 if cert in sCerts:
+                    if qVersion() >= "5.0.0":
+                        commonStr = ", ".join(
+                            cert.subjectInfo(QSslCertificate.CommonName))
+                    else:
+                        commonStr = cert.subjectInfo(QSslCertificate.CommonName)
                     E5MessageBox.warning(self,
                         self.trUtf8("Import Certificate"),
                         self.trUtf8("""<p>The certificate <b>{0}</b> already exists."""
                                     """ Skipping.</p>""")
-                            .format(Utilities.decodeString(
-                                cert.subjectInfo(QSslCertificate.CommonName))))
+                            .format(Utilities.decodeString(commonStr)))
                 else:
                     pems.append(cert.toPem() + '\n')
             if server not in certificateDict:
@@ -249,12 +260,18 @@
         @param cert certificate to insert (QSslCertificate)
         """
         # step 1: extract the info to be shown
-        organisation = Qt.escape(Utilities.decodeString(
-            cert.subjectInfo(QSslCertificate.Organization)))
+        if qVersion() >= "5.0.0":
+            organisation = Qt.escape(Utilities.decodeString(
+                ", ".join(cert.subjectInfo(QSslCertificate.Organization))))
+            commonName = Qt.escape(Utilities.decodeString(
+                ", ".join(cert.subjectInfo(QSslCertificate.CommonName))))
+        else:
+            organisation = Qt.escape(Utilities.decodeString(
+                cert.subjectInfo(QSslCertificate.Organization)))
+            commonName = Qt.escape(Utilities.decodeString(
+                cert.subjectInfo(QSslCertificate.CommonName)))
         if organisation is None or organisation == "":
             organisation = self.trUtf8("(Unknown)")
-        commonName = Qt.escape(Utilities.decodeString(
-            cert.subjectInfo(QSslCertificate.CommonName)))
         if commonName is None or commonName == "":
             commonName = self.trUtf8("(Unknown common name)")
         expiryDate = Qt.escape(cert.expiryDate().toString("yyyy-MM-dd"))
@@ -338,12 +355,16 @@
             caCerts = self.__getSystemCaCertificates()
             for cert in certs:
                 if cert in caCerts:
+                    if qVersion() >= "5.0.0":
+                        commonStr = ", ".join(
+                            cert.subjectInfo(QSslCertificate.CommonName))
+                    else:
+                        commonStr = cert.subjectInfo(QSslCertificate.CommonName)
                     E5MessageBox.warning(self,
                         self.trUtf8("Import Certificate"),
                         self.trUtf8("""<p>The certificate <b>{0}</b> already exists."""
                                     """ Skipping.</p>""")
-                            .format(Utilities.decodeString(
-                                cert.subjectInfo(QSslCertificate.CommonName))))
+                            .format(Utilities.decodeString(commonStr)))
                 else:
                     caCerts.append(cert)
             
--- a/Helpviewer/SslInfoWidget.py	Sun Sep 30 13:27:28 2012 +0200
+++ b/Helpviewer/SslInfoWidget.py	Sun Sep 30 17:04:23 2012 +0200
@@ -7,7 +7,7 @@
 Module implementing a widget to show SSL certificate infos.
 """
 
-from PyQt4.QtCore import QCryptographicHash, QDateTime, Qt
+from PyQt4.QtCore import QCryptographicHash, QDateTime, Qt, qVersion
 from PyQt4.QtGui import QWidget
 from PyQt4.QtNetwork import QSslCertificate
 
@@ -42,19 +42,34 @@
         self.expiredLabel.setStyleSheet(
             "QLabel { color : white; background-color : red; }")
         
-        self.subjectCommonNameLabel.setText(self.__certificateString(
-            certificate.subjectInfo(QSslCertificate.CommonName)))
-        self.subjectOrganizationLabel.setText(self.__certificateString(
-            certificate.subjectInfo(QSslCertificate.Organization)))
-        self.subjectOrganizationalUnitLabel.setText(self.__certificateString(
-            certificate.subjectInfo(QSslCertificate.OrganizationalUnitName)))
+        if qVersion() >= "5.0.0":
+            self.subjectCommonNameLabel.setText(self.__certificateString(
+                ", ".join(certificate.subjectInfo(QSslCertificate.CommonName))))
+            self.subjectOrganizationLabel.setText(self.__certificateString(
+                ", ".join(certificate.subjectInfo(QSslCertificate.Organization))))
+            self.subjectOrganizationalUnitLabel.setText(self.__certificateString(
+                ", ".join(
+                    certificate.subjectInfo(QSslCertificate.OrganizationalUnitName))))
+            self.issuerCommonNameLabel.setText(self.__certificateString(
+                ", ".join(certificate.issuerInfo(QSslCertificate.CommonName))))
+            self.issuerOrganizationLabel.setText(self.__certificateString(
+                ", ".join(certificate.issuerInfo(QSslCertificate.Organization))))
+            self.issuerOrganizationalUnitLabel.setText(self.__certificateString(
+                ", ".join(certificate.issuerInfo(QSslCertificate.OrganizationalUnitName))))
+        else:
+            self.subjectCommonNameLabel.setText(self.__certificateString(
+                certificate.subjectInfo(QSslCertificate.CommonName)))
+            self.subjectOrganizationLabel.setText(self.__certificateString(
+                certificate.subjectInfo(QSslCertificate.Organization)))
+            self.subjectOrganizationalUnitLabel.setText(self.__certificateString(
+                certificate.subjectInfo(QSslCertificate.OrganizationalUnitName)))
+            self.issuerCommonNameLabel.setText(self.__certificateString(
+                certificate.issuerInfo(QSslCertificate.CommonName)))
+            self.issuerOrganizationLabel.setText(self.__certificateString(
+                certificate.issuerInfo(QSslCertificate.Organization)))
+            self.issuerOrganizationalUnitLabel.setText(self.__certificateString(
+                certificate.issuerInfo(QSslCertificate.OrganizationalUnitName)))
         self.serialNumberLabel.setText(self.__serialNumber(certificate))
-        self.issuerCommonNameLabel.setText(self.__certificateString(
-            certificate.issuerInfo(QSslCertificate.CommonName)))
-        self.issuerOrganizationLabel.setText(self.__certificateString(
-            certificate.issuerInfo(QSslCertificate.Organization)))
-        self.issuerOrganizationalUnitLabel.setText(self.__certificateString(
-            certificate.issuerInfo(QSslCertificate.OrganizationalUnitName)))
         self.effectiveLabel.setText(Qt.escape(
             certificate.effectiveDate().toString("yyyy-MM-dd")))
         self.expiresLabel.setText(Qt.escape(
@@ -64,7 +79,8 @@
         self.md5Label.setText(self.__formatHexString(
             str(certificate.digest(QCryptographicHash.Md5).toHex(), encoding="ascii")))
         
-        if not certificate.isValid():
+        if (qVersion() >= "5.0.0" and certificate.isBlacklisted()) or \
+           (qVersion() < "5.0.0" and not certificate.isValid()):
             # something is wrong; indicate it to the user
             if self.__hasExpired(certificate.effectiveDate(), certificate.expiryDate()):
                 self.expiredLabel.setVisible(True)
--- a/Helpviewer/UrlBar/UrlBar.py	Sun Sep 30 13:27:28 2012 +0200
+++ b/Helpviewer/UrlBar/UrlBar.py	Sun Sep 30 17:04:23 2012 +0200
@@ -7,7 +7,7 @@
 Module implementing the URL bar widget.
 """
 
-from PyQt4.QtCore import pyqtSlot, Qt, QPointF, QUrl, QDateTime
+from PyQt4.QtCore import pyqtSlot, Qt, QPointF, QUrl, QDateTime, qVersion
 from PyQt4.QtGui import QColor, QPalette, QLinearGradient, QIcon, QDialog
 try:
     from PyQt4.QtNetwork import QSslCertificate     # __IGNORE_EXCEPTION__
@@ -180,18 +180,31 @@
                QSslCertificate is not None:
                 sslInfo = self.__browser.page().getSslInfo()
                 if sslInfo is not None:
-                    org = Qt.escape(Utilities.decodeString(
-                        sslInfo.subjectInfo(QSslCertificate.Organization)))
+                    if qVersion() >= "5.0.0":
+                        org = Qt.escape(Utilities.decodeString(
+                            ", ".join(sslInfo.subjectInfo(QSslCertificate.Organization))))
+                    else:
+                        org = Qt.escape(Utilities.decodeString(
+                            sslInfo.subjectInfo(QSslCertificate.Organization)))
                     if org == "":
-                        cn = Qt.escape(Utilities.decodeString(
-                            sslInfo.subjectInfo(QSslCertificate.CommonName)))
+                        if qVersion() >= "5.0.0":
+                            cn = Qt.escape(Utilities.decodeString(
+                                ", ".join(
+                                    sslInfo.subjectInfo(QSslCertificate.CommonName))))
+                        else:
+                            cn = Qt.escape(Utilities.decodeString(
+                                sslInfo.subjectInfo(QSslCertificate.CommonName)))
                         if cn != "":
                             org = cn.split(".", 1)[1]
                         if org == "":
                             org = self.trUtf8("Unknown")
                     self.__sslLabel.setText(" {0} ".format(org))
                     self.__sslLabel.setVisible(True)
-                    self.__sslLabel.setValidity(sslInfo.isValid())
+                    if qVersion() >= "5.0.0":
+                        valid = not sslInfo.isBlacklisted()
+                    else:
+                        valid = sslInfo.isValid()
+                    self.__sslLabel.setValidity(valid)
                     return
             
             self.__sslLabel.setVisible(False)

eric ide

mercurial