260 |
260 |
261 def __saveFileName(self, directory): |
261 def __saveFileName(self, directory): |
262 """ |
262 """ |
263 Private method to calculate a name for the file to download. |
263 Private method to calculate a name for the file to download. |
264 |
264 |
265 @param directory name of the directory to store the file into (string) |
265 @param directory name of the directory to store the file into |
266 @return proposed filename and original filename (string, string) |
266 @type str |
|
267 @return proposed filename and original filename |
|
268 @rtype tuple of (str, str) |
267 """ |
269 """ |
268 fpath = pathlib.Path(self.__downloadRequest.downloadFileName()) |
270 fpath = pathlib.Path(self.__downloadRequest.downloadFileName()) |
269 origName = fpath.name |
271 origName = fpath.name |
270 name = os.path.join(directory, origName) |
272 name = os.path.join(directory, origName) |
271 return name, origName |
273 return name, origName |
357 |
359 |
358 def bytesTotal(self): |
360 def bytesTotal(self): |
359 """ |
361 """ |
360 Public method to get the total number of bytes of the download. |
362 Public method to get the total number of bytes of the download. |
361 |
363 |
362 @return total number of bytes (integer) |
364 @return total number of bytes |
|
365 @rtype int |
363 """ |
366 """ |
364 if self.__bytesTotal == -1: |
367 if self.__bytesTotal == -1: |
365 self.__bytesTotal = self.__downloadRequest.totalBytes() |
368 self.__bytesTotal = self.__downloadRequest.totalBytes() |
366 return self.__bytesTotal |
369 return self.__bytesTotal |
367 |
370 |
368 def bytesReceived(self): |
371 def bytesReceived(self): |
369 """ |
372 """ |
370 Public method to get the number of bytes received. |
373 Public method to get the number of bytes received. |
371 |
374 |
372 @return number of bytes received (integer) |
375 @return number of bytes received |
|
376 @rtype int |
373 """ |
377 """ |
374 return self.__bytesReceived |
378 return self.__bytesReceived |
375 |
379 |
376 def remainingTime(self): |
380 def remainingTime(self): |
377 """ |
381 """ |
378 Public method to get an estimation for the remaining time. |
382 Public method to get an estimation for the remaining time. |
379 |
383 |
380 @return estimation for the remaining time (float) |
384 @return estimation for the remaining time |
|
385 @rtype float |
381 """ |
386 """ |
382 if not self.downloading(): |
387 if not self.downloading(): |
383 return -1.0 |
388 return -1.0 |
384 |
389 |
385 if self.bytesTotal() == -1: |
390 if self.bytesTotal() == -1: |
447 |
453 |
448 def downloading(self): |
454 def downloading(self): |
449 """ |
455 """ |
450 Public method to determine, if a download is in progress. |
456 Public method to determine, if a download is in progress. |
451 |
457 |
452 @return flag indicating a download is in progress (boolean) |
458 @return flag indicating a download is in progress |
|
459 @rtype bool |
453 """ |
460 """ |
454 return self.__state == DownloadState.Downloading |
461 return self.__state == DownloadState.Downloading |
455 |
462 |
456 def downloadedSuccessfully(self): |
463 def downloadedSuccessfully(self): |
457 """ |
464 """ |
458 Public method to check for a successful download. |
465 Public method to check for a successful download. |
459 |
466 |
460 @return flag indicating a successful download (boolean) |
467 @return flag indicating a successful download |
|
468 @rtype bool |
461 """ |
469 """ |
462 return self.__state == DownloadState.Successful |
470 return self.__state == DownloadState.Successful |
463 |
471 |
464 def downloadCanceled(self): |
472 def downloadCanceled(self): |
465 """ |
473 """ |
466 Public method to check, if the download was cancelled. |
474 Public method to check, if the download was cancelled. |
467 |
475 |
468 @return flag indicating a canceled download (boolean) |
476 @return flag indicating a canceled download |
|
477 @rtype bool |
469 """ |
478 """ |
470 return self.__state == DownloadState.Cancelled |
479 return self.__state == DownloadState.Cancelled |
471 |
480 |
472 def __finished(self): |
481 def __finished(self): |
473 """ |
482 """ |
501 |
510 |
502 def canceledFileSelect(self): |
511 def canceledFileSelect(self): |
503 """ |
512 """ |
504 Public method to check, if the user canceled the file selection. |
513 Public method to check, if the user canceled the file selection. |
505 |
514 |
506 @return flag indicating cancellation (boolean) |
515 @return flag indicating cancellation |
|
516 @rtype bool |
507 """ |
517 """ |
508 return self.__canceledFileSelect |
518 return self.__canceledFileSelect |
509 |
519 |
510 def setIcon(self, icon): |
520 def setIcon(self, icon): |
511 """ |
521 """ |
512 Public method to set the download icon. |
522 Public method to set the download icon. |
513 |
523 |
514 @param icon reference to the icon to be set (QIcon) |
524 @param icon reference to the icon to be set |
|
525 @type QIcon |
515 """ |
526 """ |
516 self.fileIcon.setPixmap(icon.pixmap(48, 48)) |
527 self.fileIcon.setPixmap(icon.pixmap(48, 48)) |
517 |
528 |
518 def fileName(self): |
529 def fileName(self): |
519 """ |
530 """ |
520 Public method to get the name of the output file. |
531 Public method to get the name of the output file. |
521 |
532 |
522 @return name of the output file (string) |
533 @return name of the output file |
|
534 @rtype str |
523 """ |
535 """ |
524 return self.__fileName |
536 return self.__fileName |
525 |
537 |
526 def absoluteFilePath(self): |
538 def absoluteFilePath(self): |
527 """ |
539 """ |
528 Public method to get the absolute path of the output file. |
540 Public method to get the absolute path of the output file. |
529 |
541 |
530 @return absolute path of the output file (string) |
542 @return absolute path of the output file |
|
543 @rtype str |
531 """ |
544 """ |
532 return str(pathlib.Path(self.__fileName).resolve()) |
545 return str(pathlib.Path(self.__fileName).resolve()) |
533 |
546 |
534 def getData(self): |
547 def getData(self): |
535 """ |
548 """ |
605 |
618 |
606 def getInfoData(self): |
619 def getInfoData(self): |
607 """ |
620 """ |
608 Public method to get the text of the info label. |
621 Public method to get the text of the info label. |
609 |
622 |
610 @return text of the info label (string) |
623 @return text of the info label |
|
624 @rtype str |
611 """ |
625 """ |
612 return self.infoLabel.text() |
626 return self.infoLabel.text() |
613 |
627 |
614 def getPageUrl(self): |
628 def getPageUrl(self): |
615 """ |
629 """ |
616 Public method to get the URL of the download page. |
630 Public method to get the URL of the download page. |
617 |
631 |
618 @return URL of the download page (QUrl) |
632 @return URL of the download page |
|
633 @rtype QUrl |
619 """ |
634 """ |
620 return self.__pageUrl |
635 return self.__pageUrl |
621 |
636 |
622 def __adjustSize(self): |
637 def __adjustSize(self): |
623 """ |
638 """ |