src/eric7/WebBrowser/Download/DownloadManager.py

branch
eric7
changeset 10436
f6881d10e995
parent 10069
435cc5875135
child 10439
21c28b0f9e41
equal deleted inserted replaced
10435:c712d09cc839 10436:f6881d10e995
51 51
52 def __init__(self, parent=None): 52 def __init__(self, parent=None):
53 """ 53 """
54 Constructor 54 Constructor
55 55
56 @param parent reference to the parent widget (QWidget) 56 @param parent reference to the parent widget
57 @type QWidget
57 """ 58 """
58 super().__init__(parent) 59 super().__init__(parent)
59 self.setupUi(self) 60 self.setupUi(self)
60 self.setWindowFlags(Qt.WindowType.Window) 61 self.setWindowFlags(Qt.WindowType.Window)
61 62
96 @pyqtSlot(QPoint) 97 @pyqtSlot(QPoint)
97 def __customContextMenuRequested(self, pos): 98 def __customContextMenuRequested(self, pos):
98 """ 99 """
99 Private slot to handle the context menu request for the bookmarks tree. 100 Private slot to handle the context menu request for the bookmarks tree.
100 101
101 @param pos position the context menu was requested (QPoint) 102 @param pos position the context menu was requested
103 @type QPoint
102 """ 104 """
103 menu = QMenu() 105 menu = QMenu()
104 106
105 selectedRowsCount = len(self.downloadsView.selectionModel().selectedRows()) 107 selectedRowsCount = len(self.downloadsView.selectionModel().selectedRows())
106 108
150 152
151 def activeDownloadsCount(self): 153 def activeDownloadsCount(self):
152 """ 154 """
153 Public method to get the number of active downloads. 155 Public method to get the number of active downloads.
154 156
155 @return number of active downloads (integer) 157 @return number of active downloads
158 @rtype int
156 """ 159 """
157 count = 0 160 count = 0
158 161
159 for download in self.__downloads: 162 for download in self.__downloads:
160 if download.downloading(): 163 if download.downloading():
163 166
164 def allowQuit(self): 167 def allowQuit(self):
165 """ 168 """
166 Public method to check, if it is ok to quit. 169 Public method to check, if it is ok to quit.
167 170
168 @return flag indicating allowance to quit (boolean) 171 @return flag indicating allowance to quit
172 @rtype bool
169 """ 173 """
170 if self.activeDownloadsCount() > 0: 174 if self.activeDownloadsCount() > 0:
171 res = EricMessageBox.yesNo( 175 res = EricMessageBox.yesNo(
172 self, 176 self,
173 self.tr(""), 177 self.tr(""),
377 381
378 def removePolicy(self): 382 def removePolicy(self):
379 """ 383 """
380 Public method to get the remove policy. 384 Public method to get the remove policy.
381 385
382 @return remove policy (integer) 386 @return remove policy
387 @rtype int
383 """ 388 """
384 return Preferences.getWebBrowser("DownloadManagerRemovePolicy") 389 return Preferences.getWebBrowser("DownloadManagerRemovePolicy")
385 390
386 def setRemovePolicy(self, policy): 391 def setRemovePolicy(self, policy):
387 """ 392 """
388 Public method to set the remove policy. 393 Public method to set the remove policy.
389 394
390 @param policy policy to be set 395 @param policy policy to be set
391 (DownloadManager.RemoveExit, DownloadManager.RemoveNever, 396 (DownloadManager.RemoveExit, DownloadManager.RemoveNever,
392 DownloadManager.RemoveSuccessFullDownload) 397 DownloadManager.RemoveSuccessFullDownload)
398 @type int
393 """ 399 """
394 if policy in ( 400 if policy in (
395 DownloadManager.RemoveExit, 401 DownloadManager.RemoveExit,
396 DownloadManager.RemoveNever, 402 DownloadManager.RemoveNever,
397 DownloadManager.RemoveSuccessFullDownload, 403 DownloadManager.RemoveSuccessFullDownload,
517 523
518 def setDownloadDirectory(self, directory): 524 def setDownloadDirectory(self, directory):
519 """ 525 """
520 Public method to set the current download directory. 526 Public method to set the current download directory.
521 527
522 @param directory current download directory (string) 528 @param directory current download directory
529 @type str
523 """ 530 """
524 self.__downloadDirectory = directory 531 self.__downloadDirectory = directory
525 if self.__downloadDirectory != "": 532 if self.__downloadDirectory != "":
526 self.__downloadDirectory += "/" 533 self.__downloadDirectory += "/"
527 534
528 def downloadDirectory(self): 535 def downloadDirectory(self):
529 """ 536 """
530 Public method to get the current download directory. 537 Public method to get the current download directory.
531 538
532 @return current download directory (string) 539 @return current download directory
540 @rtype str
533 """ 541 """
534 return self.__downloadDirectory 542 return self.__downloadDirectory
535 543
536 def downloadsCount(self): 544 def downloadsCount(self):
537 """ 545 """
544 552
545 def downloads(self): 553 def downloads(self):
546 """ 554 """
547 Public method to get a reference to the downloads. 555 Public method to get a reference to the downloads.
548 556
549 @return reference to the downloads (list of DownloadItem) 557 @return reference to the downloads
558 @rtype list of DownloadItem
550 """ 559 """
551 return self.__downloads 560 return self.__downloads
552 561
553 def changeOccurred(self): 562 def changeOccurred(self):
554 """ 563 """
653 662
654 def __currentItem(self): 663 def __currentItem(self):
655 """ 664 """
656 Private method to get a reference to the current item. 665 Private method to get a reference to the current item.
657 666
658 @return reference to the current item (DownloadItem) 667 @return reference to the current item
668 @rtype DownloadItem
659 """ 669 """
660 index = self.downloadsView.currentIndex() 670 index = self.downloadsView.currentIndex()
661 if index and index.isValid(): 671 if index and index.isValid():
662 row = index.row() 672 row = index.row()
663 return self.__downloads[row] 673 return self.__downloads[row]

eric ide

mercurial