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)) |
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( |
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")) |
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 """ |