7 Module implementing the download model. |
7 Module implementing the download model. |
8 """ |
8 """ |
9 |
9 |
10 from PyQt4.QtCore import Qt, QAbstractListModel, QModelIndex, QMimeData, QUrl |
10 from PyQt4.QtCore import Qt, QAbstractListModel, QModelIndex, QMimeData, QUrl |
11 |
11 |
|
12 |
12 class DownloadModel(QAbstractListModel): |
13 class DownloadModel(QAbstractListModel): |
13 """ |
14 """ |
14 Class implementing the download model. |
15 Class implementing the download model. |
15 """ |
16 """ |
16 def __init__(self, manager, parent = None): |
17 def __init__(self, manager, parent=None): |
17 """ |
18 """ |
18 Constructor |
19 Constructor |
19 |
20 |
20 @param manager reference to the download manager (DownloadManager) |
21 @param manager reference to the download manager (DownloadManager) |
21 @param parent reference to the parent object (QObject) |
22 @param parent reference to the parent object (QObject) |
39 if self.__manager.downloads()[index.row()].downloadedSuccessfully(): |
40 if self.__manager.downloads()[index.row()].downloadedSuccessfully(): |
40 return self.__manager.downloads()[index.row()].getInfoData() |
41 return self.__manager.downloads()[index.row()].getInfoData() |
41 |
42 |
42 return None |
43 return None |
43 |
44 |
44 def rowCount(self, parent = QModelIndex()): |
45 def rowCount(self, parent=QModelIndex()): |
45 """ |
46 """ |
46 Public method to get the number of rows of the model. |
47 Public method to get the number of rows of the model. |
47 |
48 |
48 @param parent parent index (QModelIndex) |
49 @param parent parent index (QModelIndex) |
49 @return number of rows (integer) |
50 @return number of rows (integer) |
51 if parent.isValid(): |
52 if parent.isValid(): |
52 return 0 |
53 return 0 |
53 else: |
54 else: |
54 return self.__manager.count() |
55 return self.__manager.count() |
55 |
56 |
56 def removeRows(self, row, count, parent = QModelIndex()): |
57 def removeRows(self, row, count, parent=QModelIndex()): |
57 """ |
58 """ |
58 Public method to remove bookmarks from the model. |
59 Public method to remove bookmarks from the model. |
59 |
60 |
60 @param row row of the first bookmark to remove (integer) |
61 @param row row of the first bookmark to remove (integer) |
61 @param count number of bookmarks to remove (integer) |
62 @param count number of bookmarks to remove (integer) |