159 @type QUrl |
159 @type QUrl |
160 @return string representation of the URL |
160 @return string representation of the URL |
161 @rtype str |
161 @rtype str |
162 """ |
162 """ |
163 return url.toString(QUrl.PrettyDecoded | QUrl.RemoveUserInfo | |
163 return url.toString(QUrl.PrettyDecoded | QUrl.RemoveUserInfo | |
164 QUrl.RemoveFragment) |
164 QUrl.RemoveFragment| QUrl.RemovePath) |
165 |
165 |
166 def iconForUrl(self, url): |
166 def iconForUrl(self, url): |
167 """ |
167 """ |
168 Public method to get an icon for an URL. |
168 Public method to get an icon for an URL. |
169 |
169 |
185 return UI.PixmapCache.getIcon("network-server") |
185 return UI.PixmapCache.getIcon("network-server") |
186 |
186 |
187 self.load() |
187 self.load() |
188 |
188 |
189 urlStr = self.__urlToString(url) |
189 urlStr = self.__urlToString(url) |
190 for iconUrlStr in self.__iconsDB: |
190 if urlStr in self.__iconsDB: |
191 if iconUrlStr.startswith(urlStr): |
191 return self.__iconsDB[urlStr] |
192 return self.__iconsDB[iconUrlStr] |
192 else: |
|
193 for iconUrlStr in self.__iconsDB: |
|
194 if iconUrlStr.startswith(urlStr): |
|
195 return self.__iconsDB[iconUrlStr] |
193 |
196 |
194 # try replacing http scheme with https scheme |
197 # try replacing http scheme with https scheme |
195 url = QUrl(url) |
198 url = QUrl(url) |
196 if url.scheme() == "http": |
199 if url.scheme() == "http": |
197 url.setScheme("https") |
200 url.setScheme("https") |
198 urlStr = self.__urlToString(url) |
201 urlStr = self.__urlToString(url) |
199 for iconUrlStr in self.__iconsDB: |
202 if urlStr in self.__iconsDB: |
200 if iconUrlStr.startswith(urlStr): |
203 return self.__iconsDB[urlStr] |
201 return self.__iconsDB[iconUrlStr] |
204 else: |
|
205 for iconUrlStr in self.__iconsDB: |
|
206 if iconUrlStr.startswith(urlStr): |
|
207 return self.__iconsDB[iconUrlStr] |
202 |
208 |
203 if scheme == "https": |
209 if scheme == "https": |
204 return UI.PixmapCache.getIcon("securityHigh32") |
210 return UI.PixmapCache.getIcon("securityHigh32") |
205 else: |
211 else: |
206 return UI.PixmapCache.getIcon("defaultIcon") |
212 return UI.PixmapCache.getIcon("defaultIcon") |