eric7/HelpViewer/HelpViewerImpl.py

branch
eric7
changeset 8696
7e88f292b1b1
parent 8693
d51660d6f1b9
child 8705
327e596607f8
--- a/eric7/HelpViewer/HelpViewerImpl.py	Sun Oct 17 15:26:01 2021 +0200
+++ b/eric7/HelpViewer/HelpViewerImpl.py	Sun Oct 17 15:26:31 2021 +0200
@@ -7,23 +7,7 @@
 Module implementing the help viewer base class.
 """
 
-from PyQt6.QtCore import pyqtSignal, QCoreApplication
-
-AboutBlank = QCoreApplication.translate(
-    "HelpViewer",
-    "<html>"
-    "<head><title>about:blank</title></head>"
-    "<body></body>"
-    "</html>")
-
-PageNotFound = QCoreApplication.translate(
-    "HelpViewer",
-    """<html>"""
-    """<head><title>Error 404...</title></head>"""
-    """<body><div align="center"><br><br>"""
-    """<h1>The page could not be found</h1><br>"""
-    """<h3>'{0}'</h3></div></body>"""
-    """</html>""")
+from PyQt6.QtCore import pyqtSignal, QUrl
 
 
 class HelpViewerImpl:
@@ -32,6 +16,10 @@
     
     This is the base class of help viewer implementations and defines the
     interface. Als subclasses must implement the these methods.
+    
+    @signal titleChanged() emitted to indicate a change of the page title
+    @signal loadFinished(ok) emitted to indicate the completion of a page load
+    @signal zoomChanged() emitted to indicate a change of the zoom level
     """
     titleChanged = pyqtSignal()
     loadFinished = pyqtSignal(bool)
@@ -46,7 +34,7 @@
         """
         self._engine = engine
     
-    def setUrl(self, url):
+    def setLink(self, url):
         """
         Public method to set the URL of the document to be shown.
         
@@ -56,53 +44,18 @@
         """
         raise RuntimeError("Not implemented")
     
-    def url(self):
+    def link(self):
         """
         Public method to get the URL of the shown document.
         
-        @return url URL of the document
+        @return URL of the document
         @rtype QUrl
         @exception RuntimeError raised when not implemented
         """
         raise RuntimeError("Not implemented")
-        return None
+        return QUrl()
     
-    def getData(self, url):
-        """
-        Public method to get the data to be shown.
-        
-        @param url URL to be loaded
-        @type QUrl
-        @return data to be shown
-        @rtype str
-        """
-        scheme = url.scheme()
-        if scheme == "about":
-            if url.toString() == "about:blank":
-                return AboutBlank
-            else:
-                return PageNotFound.format(url.toString())
-        elif scheme in ("file", ""):
-            filePath = url.toLocalFile()
-            try:
-                with open(filePath, "r", encoding="utf-8") as f:
-                    htmlText = f.read()
-                return htmlText
-            except OSError:
-                return PageNotFound.format(url.toString())
-        elif scheme == "qthelp":
-            if self._engine.findFile(url).isValid():
-                data = bytes(self._engine.fileData(url)).decode("utf-8")
-                if not data:
-                    data = PageNotFound.format(url.toString())
-                return data
-            else:
-                return PageNotFound.format(url.toString())
-        else:
-            # None is an indicator that we cannot handle the request
-            return None
-    
-    def title(self):
+    def pageTitle(self):
         """
         Public method get the page title.
         
@@ -128,6 +81,8 @@
         Public method to check, if stepping backward through the history is
         available.
         
+        @return flag indicating backward stepping is available
+        @rtype bool
         @exception RuntimeError raised when not implemented
         """
         raise RuntimeError("Not implemented")
@@ -138,6 +93,8 @@
         Public method to check, if stepping forward through the history is
         available.
         
+        @return flag indicating forward stepping is available
+        @rtype bool
         @exception RuntimeError raised when not implemented
         """
         raise RuntimeError("Not implemented")

eric ide

mercurial