src/eric7/WebBrowser/SpeedDial/SpeedDial.py

branch
eric7
changeset 10436
f6881d10e995
parent 9684
8ddb4ddb72f2
child 10439
21c28b0f9e41
equal deleted inserted replaced
10435:c712d09cc839 10436:f6881d10e995
44 44
45 def __init__(self, parent=None): 45 def __init__(self, parent=None):
46 """ 46 """
47 Constructor 47 Constructor
48 48
49 @param parent reference to the parent object (QObject) 49 @param parent reference to the parent object
50 @type QObject
50 """ 51 """
51 super().__init__(parent) 52 super().__init__(parent)
52 53
53 self.__regenerateScript = True 54 self.__regenerateScript = True
54 55
66 67
67 def addPage(self, url, title): 68 def addPage(self, url, title):
68 """ 69 """
69 Public method to add a page for the given data. 70 Public method to add a page for the given data.
70 71
71 @param url URL of the page (QUrl) 72 @param url URL of the page
72 @param title title of the page (string) 73 @type QUrl
74 @param title title of the page
75 @type str
73 """ 76 """
74 if url.isEmpty(): 77 if url.isEmpty():
75 return 78 return
76 79
77 page = Page(self.__escapeUrl(url.toString()), self.__escapeTitle(title)) 80 page = Page(self.__escapeUrl(url.toString()), self.__escapeTitle(title))
82 85
83 def removePage(self, url): 86 def removePage(self, url):
84 """ 87 """
85 Public method to remove a page. 88 Public method to remove a page.
86 89
87 @param url URL of the page (QUrl) 90 @param url URL of the page
91 @type QUrl
88 """ 92 """
89 page = self.pageForUrl(url) 93 page = self.pageForUrl(url)
90 if not page.isValid(): 94 if not page.isValid():
91 return 95 return
92 96
98 102
99 def __imageFileName(self, url): 103 def __imageFileName(self, url):
100 """ 104 """
101 Private method to generate the image file name for a URL. 105 Private method to generate the image file name for a URL.
102 106
103 @param url URL to generate the file name from (string) 107 @param url URL to generate the file name from
104 @return name of the image file (string) 108 @type str
109 @return name of the image file
110 @rtype str
105 """ 111 """
106 return os.path.join( 112 return os.path.join(
107 self.__thumbnailsDirectory, 113 self.__thumbnailsDirectory,
108 str( 114 str(
109 QCryptographicHash.hash( 115 QCryptographicHash.hash(
116 122
117 def initialScript(self): 123 def initialScript(self):
118 """ 124 """
119 Public method to get the 'initial' JavaScript script. 125 Public method to get the 'initial' JavaScript script.
120 126
121 @return initial JavaScript script (string) 127 @return initial JavaScript script
128 @rtype str
122 """ 129 """
123 if self.__regenerateScript: 130 if self.__regenerateScript:
124 self.__regenerateScript = False 131 self.__regenerateScript = False
125 self.__initialScript = "" 132 self.__initialScript = ""
126 133
146 153
147 def getFileName(self): 154 def getFileName(self):
148 """ 155 """
149 Public method to get the file name of the user agents file. 156 Public method to get the file name of the user agents file.
150 157
151 @return name of the user agents file (string) 158 @return name of the user agents file
159 @rtype str
152 """ 160 """
153 return os.path.join(Globals.getConfigDir(), "web_browser", "speedDial.xml") 161 return os.path.join(Globals.getConfigDir(), "web_browser", "speedDial.xml")
154 162
155 def __initialize(self): 163 def __initialize(self):
156 """ 164 """
253 261
254 def pageForUrl(self, url): 262 def pageForUrl(self, url):
255 """ 263 """
256 Public method to get the page for the given URL. 264 Public method to get the page for the given URL.
257 265
258 @param url URL to be searched for (QUrl) 266 @param url URL to be searched for
259 @return page for the URL (Page) 267 @type QUrl
268 @return page for the URL
269 @rtype Page
260 """ 270 """
261 urlString = url.toString() 271 urlString = url.toString()
262 if urlString.endswith("/"): 272 if urlString.endswith("/"):
263 urlString = urlString[:-1] 273 urlString = urlString[:-1]
264 274
270 280
271 def urlForShortcut(self, key): 281 def urlForShortcut(self, key):
272 """ 282 """
273 Public method to get the URL for the given shortcut key. 283 Public method to get the URL for the given shortcut key.
274 284
275 @param key shortcut key (integer) 285 @param key shortcut key
276 @return URL for the key (QUrl) 286 @type int
287 @return URL for the key
288 @rtype QUrl
277 """ 289 """
278 if key < 0 or len(self.__webPages) <= key: 290 if key < 0 or len(self.__webPages) <= key:
279 return QUrl() 291 return QUrl()
280 292
281 return QUrl.fromEncoded(self.__webPages[key].url.encode("utf-8")) 293 return QUrl.fromEncoded(self.__webPages[key].url.encode("utf-8"))
283 @pyqtSlot(str) 295 @pyqtSlot(str)
284 def changed(self, allPages): 296 def changed(self, allPages):
285 """ 297 """
286 Public slot to react on changed pages. 298 Public slot to react on changed pages.
287 299
288 @param allPages string giving all pages (string) 300 @param allPages string giving all pages
301 @type str
289 """ 302 """
290 if not allPages: 303 if not allPages:
291 return 304 return
292 305
293 entries = allPages.split('";') 306 entries = allPages.split('";')
348 @pyqtSlot(str) 361 @pyqtSlot(str)
349 def removeImageForUrl(self, url): 362 def removeImageForUrl(self, url):
350 """ 363 """
351 Public slot to remove the image for a URL. 364 Public slot to remove the image for a URL.
352 365
353 @param url URL to remove the image for (string) 366 @param url URL to remove the image for
367 @type str
354 """ 368 """
355 fileName = self.__imageFileName(url) 369 fileName = self.__imageFileName(url)
356 if os.path.exists(fileName): 370 if os.path.exists(fileName):
357 os.remove(fileName) 371 os.remove(fileName)
358 372
359 @pyqtSlot(str, result=str) 373 @pyqtSlot(str, result=str)
360 def urlFromUserInput(self, url): 374 def urlFromUserInput(self, url):
361 """ 375 """
362 Public slot to get the URL from user input. 376 Public slot to get the URL from user input.
363 377
364 @param url URL entered by the user (string) 378 @param url URL entered by the user
365 @return sanitized URL (string) 379 @type str
380 @return sanitized URL
381 @rtype str
366 """ 382 """
367 return QUrl.fromUserInput(url).toString() 383 return QUrl.fromUserInput(url).toString()
368 384
369 @pyqtSlot(int) 385 @pyqtSlot(int)
370 def setPagesInRow(self, count): 386 def setPagesInRow(self, count):
371 """ 387 """
372 Public slot to set the number of pages per row. 388 Public slot to set the number of pages per row.
373 389
374 @param count number of pages per row (integer) 390 @param count number of pages per row
391 @type int
375 """ 392 """
376 self.__pagesPerRow = count 393 self.__pagesPerRow = count
377 self.__saveTimer.changeOccurred() 394 self.__saveTimer.changeOccurred()
378 395
379 def pagesInRow(self): 396 def pagesInRow(self):
380 """ 397 """
381 Public method to get the number of dials per row. 398 Public method to get the number of dials per row.
382 399
383 @return number of dials per row (integer) 400 @return number of dials per row
401 @rtype int
384 """ 402 """
385 return self.__pagesPerRow 403 return self.__pagesPerRow
386 404
387 @pyqtSlot(int) 405 @pyqtSlot(int)
388 def setSdSize(self, size): 406 def setSdSize(self, size):
389 """ 407 """
390 Public slot to set the size of the speed dial. 408 Public slot to set the size of the speed dial.
391 409
392 @param size size of the speed dial (integer) 410 @param size size of the speed dial
411 @type int
393 """ 412 """
394 self.__speedDialSize = size 413 self.__speedDialSize = size
395 self.__saveTimer.changeOccurred() 414 self.__saveTimer.changeOccurred()
396 415
397 def sdSize(self): 416 def sdSize(self):
398 """ 417 """
399 Public method to get the speed dial size. 418 Public method to get the speed dial size.
400 419
401 @return speed dial size (integer) 420 @return speed dial size
421 @rtype int
402 """ 422 """
403 return self.__speedDialSize 423 return self.__speedDialSize
404 424
405 def __thumbnailCreated(self, image, thumbnailer): 425 def __thumbnailCreated(self, image, thumbnailer):
406 """ 426 """

eric ide

mercurial