Extended some web browser manager objects to provide a method to get the name of their config file.

Wed, 15 Feb 2012 14:27:43 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 15 Feb 2012 14:27:43 +0100
changeset 1621
85653d5d3bf9
parent 1620
8172cc5d4dda
child 1622
e9e1b704af11

Extended some web browser manager objects to provide a method to get the name of their config file.

APIs/Python3/eric5.api file | annotate | diff | comparison | revisions
Documentation/Help/source.qch file | annotate | diff | comparison | revisions
Documentation/Help/source.qhp file | annotate | diff | comparison | revisions
Documentation/Source/eric5.Helpviewer.Bookmarks.BookmarksManager.html file | annotate | diff | comparison | revisions
Documentation/Source/eric5.Helpviewer.History.HistoryManager.html file | annotate | diff | comparison | revisions
Documentation/Source/eric5.Helpviewer.Passwords.PasswordManager.html file | annotate | diff | comparison | revisions
Documentation/Source/eric5.Helpviewer.UserAgent.UserAgentManager.html file | annotate | diff | comparison | revisions
Helpviewer/Bookmarks/BookmarksManager.py file | annotate | diff | comparison | revisions
Helpviewer/History/HistoryManager.py file | annotate | diff | comparison | revisions
Helpviewer/Passwords/PasswordManager.py file | annotate | diff | comparison | revisions
Helpviewer/UserAgent/UserAgentManager.py file | annotate | diff | comparison | revisions
--- a/APIs/Python3/eric5.api	Mon Feb 13 19:02:09 2012 +0100
+++ b/APIs/Python3/eric5.api	Wed Feb 15 14:27:43 2012 +0100
@@ -1793,6 +1793,7 @@
 eric5.Helpviewer.Bookmarks.BookmarksManager.BookmarksManager.entryChanged?7
 eric5.Helpviewer.Bookmarks.BookmarksManager.BookmarksManager.entryRemoved?7
 eric5.Helpviewer.Bookmarks.BookmarksManager.BookmarksManager.exportBookmarks?4()
+eric5.Helpviewer.Bookmarks.BookmarksManager.BookmarksManager.getFileName?4()
 eric5.Helpviewer.Bookmarks.BookmarksManager.BookmarksManager.iconChanged?4(url)
 eric5.Helpviewer.Bookmarks.BookmarksManager.BookmarksManager.importBookmarks?4()
 eric5.Helpviewer.Bookmarks.BookmarksManager.BookmarksManager.load?4()
@@ -2240,6 +2241,7 @@
 eric5.Helpviewer.History.HistoryManager.HistoryManager.entryAdded?7
 eric5.Helpviewer.History.HistoryManager.HistoryManager.entryRemoved?7
 eric5.Helpviewer.History.HistoryManager.HistoryManager.entryUpdated?7
+eric5.Helpviewer.History.HistoryManager.HistoryManager.getFileName?4()
 eric5.Helpviewer.History.HistoryManager.HistoryManager.history?4()
 eric5.Helpviewer.History.HistoryManager.HistoryManager.historyCleared?7
 eric5.Helpviewer.History.HistoryManager.HistoryManager.historyContains?4(url)
@@ -2441,6 +2443,7 @@
 eric5.Helpviewer.Passwords.PasswordManager.PasswordManager.clear?4()
 eric5.Helpviewer.Passwords.PasswordManager.PasswordManager.close?4()
 eric5.Helpviewer.Passwords.PasswordManager.PasswordManager.fill?4(page)
+eric5.Helpviewer.Passwords.PasswordManager.PasswordManager.getFileName?4()
 eric5.Helpviewer.Passwords.PasswordManager.PasswordManager.getLogin?4(url, realm)
 eric5.Helpviewer.Passwords.PasswordManager.PasswordManager.masterPasswordChanged?4(oldPassword, newPassword)
 eric5.Helpviewer.Passwords.PasswordManager.PasswordManager.post?4(request, data)
@@ -2537,6 +2540,7 @@
 eric5.Helpviewer.UserAgent.UserAgentManager.UserAgentManager.allHostNames?4()
 eric5.Helpviewer.UserAgent.UserAgentManager.UserAgentManager.changed?7
 eric5.Helpviewer.UserAgent.UserAgentManager.UserAgentManager.close?4()
+eric5.Helpviewer.UserAgent.UserAgentManager.UserAgentManager.getFileName?4()
 eric5.Helpviewer.UserAgent.UserAgentManager.UserAgentManager.hostsCount?4()
 eric5.Helpviewer.UserAgent.UserAgentManager.UserAgentManager.removeUserAgent?4(host)
 eric5.Helpviewer.UserAgent.UserAgentManager.UserAgentManager.save?4()
Binary file Documentation/Help/source.qch has changed
--- a/Documentation/Help/source.qhp	Mon Feb 13 19:02:09 2012 +0100
+++ b/Documentation/Help/source.qhp	Wed Feb 15 14:27:43 2012 +0100
@@ -1331,6 +1331,7 @@
       <keyword name="BookmarksManager.changeExpanded" id="BookmarksManager.changeExpanded" ref="eric5.Helpviewer.Bookmarks.BookmarksManager.html#BookmarksManager.changeExpanded" />
       <keyword name="BookmarksManager.close" id="BookmarksManager.close" ref="eric5.Helpviewer.Bookmarks.BookmarksManager.html#BookmarksManager.close" />
       <keyword name="BookmarksManager.exportBookmarks" id="BookmarksManager.exportBookmarks" ref="eric5.Helpviewer.Bookmarks.BookmarksManager.html#BookmarksManager.exportBookmarks" />
+      <keyword name="BookmarksManager.getFileName" id="BookmarksManager.getFileName" ref="eric5.Helpviewer.Bookmarks.BookmarksManager.html#BookmarksManager.getFileName" />
       <keyword name="BookmarksManager.iconChanged" id="BookmarksManager.iconChanged" ref="eric5.Helpviewer.Bookmarks.BookmarksManager.html#BookmarksManager.iconChanged" />
       <keyword name="BookmarksManager.importBookmarks" id="BookmarksManager.importBookmarks" ref="eric5.Helpviewer.Bookmarks.BookmarksManager.html#BookmarksManager.importBookmarks" />
       <keyword name="BookmarksManager.load" id="BookmarksManager.load" ref="eric5.Helpviewer.Bookmarks.BookmarksManager.html#BookmarksManager.load" />
@@ -5463,6 +5464,7 @@
       <keyword name="HistoryManager.clear" id="HistoryManager.clear" ref="eric5.Helpviewer.History.HistoryManager.html#HistoryManager.clear" />
       <keyword name="HistoryManager.close" id="HistoryManager.close" ref="eric5.Helpviewer.History.HistoryManager.html#HistoryManager.close" />
       <keyword name="HistoryManager.daysToExpire" id="HistoryManager.daysToExpire" ref="eric5.Helpviewer.History.HistoryManager.html#HistoryManager.daysToExpire" />
+      <keyword name="HistoryManager.getFileName" id="HistoryManager.getFileName" ref="eric5.Helpviewer.History.HistoryManager.html#HistoryManager.getFileName" />
       <keyword name="HistoryManager.history" id="HistoryManager.history" ref="eric5.Helpviewer.History.HistoryManager.html#HistoryManager.history" />
       <keyword name="HistoryManager.historyContains" id="HistoryManager.historyContains" ref="eric5.Helpviewer.History.HistoryManager.html#HistoryManager.historyContains" />
       <keyword name="HistoryManager.historyFilterModel" id="HistoryManager.historyFilterModel" ref="eric5.Helpviewer.History.HistoryManager.html#HistoryManager.historyFilterModel" />
@@ -6604,6 +6606,7 @@
       <keyword name="PasswordManager.clear" id="PasswordManager.clear" ref="eric5.Helpviewer.Passwords.PasswordManager.html#PasswordManager.clear" />
       <keyword name="PasswordManager.close" id="PasswordManager.close" ref="eric5.Helpviewer.Passwords.PasswordManager.html#PasswordManager.close" />
       <keyword name="PasswordManager.fill" id="PasswordManager.fill" ref="eric5.Helpviewer.Passwords.PasswordManager.html#PasswordManager.fill" />
+      <keyword name="PasswordManager.getFileName" id="PasswordManager.getFileName" ref="eric5.Helpviewer.Passwords.PasswordManager.html#PasswordManager.getFileName" />
       <keyword name="PasswordManager.getLogin" id="PasswordManager.getLogin" ref="eric5.Helpviewer.Passwords.PasswordManager.html#PasswordManager.getLogin" />
       <keyword name="PasswordManager.masterPasswordChanged" id="PasswordManager.masterPasswordChanged" ref="eric5.Helpviewer.Passwords.PasswordManager.html#PasswordManager.masterPasswordChanged" />
       <keyword name="PasswordManager.post" id="PasswordManager.post" ref="eric5.Helpviewer.Passwords.PasswordManager.html#PasswordManager.post" />
@@ -9803,6 +9806,7 @@
       <keyword name="UserAgentManager.__load" id="UserAgentManager.__load" ref="eric5.Helpviewer.UserAgent.UserAgentManager.html#UserAgentManager.__load" />
       <keyword name="UserAgentManager.allHostNames" id="UserAgentManager.allHostNames" ref="eric5.Helpviewer.UserAgent.UserAgentManager.html#UserAgentManager.allHostNames" />
       <keyword name="UserAgentManager.close" id="UserAgentManager.close" ref="eric5.Helpviewer.UserAgent.UserAgentManager.html#UserAgentManager.close" />
+      <keyword name="UserAgentManager.getFileName" id="UserAgentManager.getFileName" ref="eric5.Helpviewer.UserAgent.UserAgentManager.html#UserAgentManager.getFileName" />
       <keyword name="UserAgentManager.hostsCount" id="UserAgentManager.hostsCount" ref="eric5.Helpviewer.UserAgent.UserAgentManager.html#UserAgentManager.hostsCount" />
       <keyword name="UserAgentManager.removeUserAgent" id="UserAgentManager.removeUserAgent" ref="eric5.Helpviewer.UserAgent.UserAgentManager.html#UserAgentManager.removeUserAgent" />
       <keyword name="UserAgentManager.save" id="UserAgentManager.save" ref="eric5.Helpviewer.UserAgent.UserAgentManager.html#UserAgentManager.save" />
--- a/Documentation/Source/eric5.Helpviewer.Bookmarks.BookmarksManager.html	Mon Feb 13 19:02:09 2012 +0100
+++ b/Documentation/Source/eric5.Helpviewer.Bookmarks.BookmarksManager.html	Wed Feb 15 14:27:43 2012 +0100
@@ -116,6 +116,9 @@
 <td><a href="#BookmarksManager.exportBookmarks">exportBookmarks</a></td>
 <td>Public method to export the bookmarks.</td>
 </tr><tr>
+<td><a href="#BookmarksManager.getFileName">getFileName</a></td>
+<td>Public method to get the file name of the bookmark file.</td>
+</tr><tr>
 <td><a href="#BookmarksManager.iconChanged">iconChanged</a></td>
 <td>Public slot to update the icon image for an URL.</td>
 </tr><tr>
@@ -291,7 +294,17 @@
 <b>exportBookmarks</b>(<i></i>)
 <p>
         Public method to export the bookmarks.
-</p><a NAME="BookmarksManager.iconChanged" ID="BookmarksManager.iconChanged"></a>
+</p><a NAME="BookmarksManager.getFileName" ID="BookmarksManager.getFileName"></a>
+<h4>BookmarksManager.getFileName</h4>
+<b>getFileName</b>(<i></i>)
+<p>
+        Public method to get the file name of the bookmark file.
+</p><dl>
+<dt>Returns:</dt>
+<dd>
+name of the bookmark file (string)
+</dd>
+</dl><a NAME="BookmarksManager.iconChanged" ID="BookmarksManager.iconChanged"></a>
 <h4>BookmarksManager.iconChanged</h4>
 <b>iconChanged</b>(<i>url</i>)
 <p>
--- a/Documentation/Source/eric5.Helpviewer.History.HistoryManager.html	Mon Feb 13 19:02:09 2012 +0100
+++ b/Documentation/Source/eric5.Helpviewer.History.HistoryManager.html	Wed Feb 15 14:27:43 2012 +0100
@@ -208,6 +208,9 @@
 <td><a href="#HistoryManager.daysToExpire">daysToExpire</a></td>
 <td>Public method to get the days for entry expiration.</td>
 </tr><tr>
+<td><a href="#HistoryManager.getFileName">getFileName</a></td>
+<td>Public method to get the file name of the history file.</td>
+</tr><tr>
 <td><a href="#HistoryManager.history">history</a></td>
 <td>Public method to return the history.</td>
 </tr><tr>
@@ -326,6 +329,16 @@
 <dd>
 days for entry expiration (integer)
 </dd>
+</dl><a NAME="HistoryManager.getFileName" ID="HistoryManager.getFileName"></a>
+<h4>HistoryManager.getFileName</h4>
+<b>getFileName</b>(<i></i>)
+<p>
+        Public method to get the file name of the history file.
+</p><dl>
+<dt>Returns:</dt>
+<dd>
+name of the history file (string)
+</dd>
 </dl><a NAME="HistoryManager.history" ID="HistoryManager.history"></a>
 <h4>HistoryManager.history</h4>
 <b>history</b>(<i></i>)
--- a/Documentation/Source/eric5.Helpviewer.Passwords.PasswordManager.html	Mon Feb 13 19:02:09 2012 +0100
+++ b/Documentation/Source/eric5.Helpviewer.Passwords.PasswordManager.html	Wed Feb 15 14:27:43 2012 +0100
@@ -180,6 +180,9 @@
 <td><a href="#PasswordManager.fill">fill</a></td>
 <td>Public slot to fill login forms with saved data.</td>
 </tr><tr>
+<td><a href="#PasswordManager.getFileName">getFileName</a></td>
+<td>Public method to get the file name of the passwords file.</td>
+</tr><tr>
 <td><a href="#PasswordManager.getLogin">getLogin</a></td>
 <td>Public method to get the login credentials.</td>
 </tr><tr>
@@ -327,6 +330,16 @@
 <dd>
 reference to the web page (QWebPage)
 </dd>
+</dl><a NAME="PasswordManager.getFileName" ID="PasswordManager.getFileName"></a>
+<h4>PasswordManager.getFileName</h4>
+<b>getFileName</b>(<i></i>)
+<p>
+        Public method to get the file name of the passwords file.
+</p><dl>
+<dt>Returns:</dt>
+<dd>
+name of the passwords file (string)
+</dd>
 </dl><a NAME="PasswordManager.getLogin" ID="PasswordManager.getLogin"></a>
 <h4>PasswordManager.getLogin</h4>
 <b>getLogin</b>(<i>url, realm</i>)
--- a/Documentation/Source/eric5.Helpviewer.UserAgent.UserAgentManager.html	Mon Feb 13 19:02:09 2012 +0100
+++ b/Documentation/Source/eric5.Helpviewer.UserAgent.UserAgentManager.html	Wed Feb 15 14:27:43 2012 +0100
@@ -76,6 +76,9 @@
 <td><a href="#UserAgentManager.close">close</a></td>
 <td>Public method to close the user agents manager.</td>
 </tr><tr>
+<td><a href="#UserAgentManager.getFileName">getFileName</a></td>
+<td>Public method to get the file name of the user agents file.</td>
+</tr><tr>
 <td><a href="#UserAgentManager.hostsCount">hostsCount</a></td>
 <td>Public method to get the number of available user agent settings.</td>
 </tr><tr>
@@ -132,7 +135,17 @@
 <b>close</b>(<i></i>)
 <p>
         Public method to close the user agents manager.
-</p><a NAME="UserAgentManager.hostsCount" ID="UserAgentManager.hostsCount"></a>
+</p><a NAME="UserAgentManager.getFileName" ID="UserAgentManager.getFileName"></a>
+<h4>UserAgentManager.getFileName</h4>
+<b>getFileName</b>(<i></i>)
+<p>
+        Public method to get the file name of the user agents file.
+</p><dl>
+<dt>Returns:</dt>
+<dd>
+name of the user agents file (string)
+</dd>
+</dl><a NAME="UserAgentManager.hostsCount" ID="UserAgentManager.hostsCount"></a>
 <h4>UserAgentManager.hostsCount</h4>
 <b>hostsCount</b>(<i></i>)
 <p>
--- a/Helpviewer/Bookmarks/BookmarksManager.py	Mon Feb 13 19:02:09 2012 +0100
+++ b/Helpviewer/Bookmarks/BookmarksManager.py	Wed Feb 15 14:27:43 2012 +0100
@@ -122,6 +122,14 @@
         self.entryRemoved.connect(self.__saveTimer.changeOccurred)
         self.entryChanged.connect(self.__saveTimer.changeOccurred)
     
+    def getFileName(self):
+        """
+        Public method to get the file name of the bookmark file.
+        
+        @return name of the bookmark file (string)
+        """
+        return os.path.join(Utilities.getConfigDir(), "browser", "bookmarks.xbel")
+    
     def close(self):
         """
         Public method to close the bookmark manager.
@@ -151,7 +159,7 @@
         
         self.__loaded = True
         
-        bookmarkFile = os.path.join(Utilities.getConfigDir(), "browser", "bookmarks.xbel")
+        bookmarkFile = self.getFileName()
         if not QFile.exists(bookmarkFile):
             ba = QByteArray(DefaultBookmarks)
             bookmarkFile = QBuffer(ba)
@@ -215,7 +223,7 @@
             return
         
         writer = XbelWriter()
-        bookmarkFile = os.path.join(Utilities.getConfigDir(), "browser", "bookmarks.xbel")
+        bookmarkFile = self.getFileName()
         
         # save root folder titles in English (i.e. not localized)
         self.__menu.title = BOOKMARKMENU
--- a/Helpviewer/History/HistoryManager.py	Mon Feb 13 19:02:09 2012 +0100
+++ b/Helpviewer/History/HistoryManager.py	Wed Feb 15 14:27:43 2012 +0100
@@ -7,6 +7,8 @@
 Module implementing the history manager.
 """
 
+import os
+
 from PyQt4.QtCore import pyqtSignal, QFileInfo, QDateTime, QDate, QTime, QUrl, QTimer, \
     QFile, QIODevice, QByteArray, QDataStream, QTemporaryFile
 from PyQt4.QtWebKit import QWebHistoryInterface, QWebSettings
@@ -332,11 +334,19 @@
         self.historyReset.emit()
         self.historyCleared.emit()
     
+    def getFileName(self):
+        """
+        Public method to get the file name of the history file.
+        
+        @return name of the history file (string)
+        """
+        return os.path.join(Utilities.getConfigDir(), "browser", "history")
+    
     def __load(self):
         """
         Private method to load the saved history entries from disk.
         """
-        historyFile = QFile(Utilities.getConfigDir() + "/browser/history")
+        historyFile = QFile(self.getFileName())
         if not historyFile.exists():
             return
         if not historyFile.open(QIODevice.ReadOnly):
@@ -392,7 +402,7 @@
         """
         Public slot to save the history entries to disk.
         """
-        historyFile = QFile(Utilities.getConfigDir() + "/browser/history")
+        historyFile = QFile(self.getFileName())
         if not historyFile.exists():
             self.__lastSavedUrl = ""
         
--- a/Helpviewer/Passwords/PasswordManager.py	Mon Feb 13 19:02:09 2012 +0100
+++ b/Helpviewer/Passwords/PasswordManager.py	Wed Feb 15 14:27:43 2012 +0100
@@ -166,6 +166,14 @@
             key = "{0}://{1}".format(url.scheme(), url.authority())
         return key
     
+    def getFileName(self):
+        """
+        Public method to get the file name of the passwords file.
+        
+        @return name of the passwords file (string)
+        """
+        return os.path.join(Utilities.getConfigDir(), "browser", "logins")
+    
     def save(self):
         """
         Public slot to save the login entries to disk.
@@ -173,7 +181,7 @@
         if not self.__loaded:
             return
         
-        loginFile = os.path.join(Utilities.getConfigDir(), "browser", "logins")
+        loginFile = self.getFileName()
         try:
             f = open(loginFile, "w", encoding="utf-8")
             for key, login in list(self.__logins.items()):
@@ -203,7 +211,7 @@
         """
         Private method to load the saved login credentials.
         """
-        loginFile = os.path.join(Utilities.getConfigDir(), "browser", "logins")
+        loginFile = self.getFileName()
         if os.path.exists(loginFile):
             try:
                 f = open(loginFile, "r", encoding="utf-8")
--- a/Helpviewer/UserAgent/UserAgentManager.py	Mon Feb 13 19:02:09 2012 +0100
+++ b/Helpviewer/UserAgent/UserAgentManager.py	Wed Feb 15 14:27:43 2012 +0100
@@ -39,6 +39,14 @@
         
         self.changed.connect(self.__saveTimer.changeOccurred)
     
+    def getFileName(self):
+        """
+        Public method to get the file name of the user agents file.
+        
+        @return name of the user agents file (string)
+        """
+        return os.path.join(Utilities.getConfigDir(), "browser", "userAgentSettings")
+    
     def save(self):
         """
         Public slot to save the user agent entries to disk.
@@ -46,7 +54,7 @@
         if not self.__loaded:
             return
         
-        agentFile = os.path.join(Utilities.getConfigDir(), "browser", "userAgentSettings")
+        agentFile = self.getFileName()
         try:
             f = open(agentFile, "w", encoding="utf-8")
             for host, agent in self.__agents.items():
@@ -63,7 +71,7 @@
         """
         Private method to load the saved user agent settings.
         """
-        agentFile = os.path.join(Utilities.getConfigDir(), "browser", "userAgentSettings")
+        agentFile = self.getFileName()
         if os.path.exists(agentFile):
             try:
                 f = open(agentFile, "r", encoding="utf-8")

eric ide

mercurial