63 self.__updateButton = \ |
63 self.__updateButton = \ |
64 self.buttonBox.addButton(self.trUtf8("Update"), QDialogButtonBox.ActionRole) |
64 self.buttonBox.addButton(self.trUtf8("Update"), QDialogButtonBox.ActionRole) |
65 self.__downloadButton = \ |
65 self.__downloadButton = \ |
66 self.buttonBox.addButton(self.trUtf8("Download"), QDialogButtonBox.ActionRole) |
66 self.buttonBox.addButton(self.trUtf8("Download"), QDialogButtonBox.ActionRole) |
67 self.__downloadButton.setEnabled(False) |
67 self.__downloadButton.setEnabled(False) |
|
68 self.__downloadInstallButton = \ |
|
69 self.buttonBox.addButton(self.trUtf8("Download && Install"), |
|
70 QDialogButtonBox.ActionRole) |
|
71 self.__downloadInstallButton.setEnabled(False) |
68 self.__downloadCancelButton = \ |
72 self.__downloadCancelButton = \ |
69 self.buttonBox.addButton(self.trUtf8("Cancel"), QDialogButtonBox.ActionRole) |
73 self.buttonBox.addButton(self.trUtf8("Cancel"), QDialogButtonBox.ActionRole) |
70 self.__installButton = \ |
74 self.__installButton = \ |
71 self.buttonBox.addButton(self.trUtf8("Close && Install"), |
75 self.buttonBox.addButton(self.trUtf8("Close && Install"), |
72 QDialogButtonBox.ActionRole) |
76 QDialogButtonBox.ActionRole) |
89 |
93 |
90 self.__doneMethod = None |
94 self.__doneMethod = None |
91 self.__inDownload = False |
95 self.__inDownload = False |
92 self.__pluginsToDownload = [] |
96 self.__pluginsToDownload = [] |
93 self.__pluginsDownloaded = [] |
97 self.__pluginsDownloaded = [] |
|
98 self.__isDownloadInstall = False |
|
99 self.__allDownloadedOk = False |
94 |
100 |
95 self.__populateList() |
101 self.__populateList() |
96 |
102 |
97 @pyqtSlot(QAbstractButton) |
103 @pyqtSlot(QAbstractButton) |
98 def on_buttonBox_clicked(self, button): |
104 def on_buttonBox_clicked(self, button): |
100 Private slot to handle the click of a button of the button box. |
106 Private slot to handle the click of a button of the button box. |
101 """ |
107 """ |
102 if button == self.__updateButton: |
108 if button == self.__updateButton: |
103 self.__updateList() |
109 self.__updateList() |
104 elif button == self.__downloadButton: |
110 elif button == self.__downloadButton: |
|
111 self.__isDownloadInstall = False |
|
112 self.__downloadPlugins() |
|
113 elif button == self.__downloadInstallButton: |
|
114 self.__isDownloadInstall = True |
|
115 self.__allDownloadedOk = True |
105 self.__downloadPlugins() |
116 self.__downloadPlugins() |
106 elif button == self.__downloadCancelButton: |
117 elif button == self.__downloadCancelButton: |
107 self.__downloadCancel() |
118 self.__downloadCancel() |
108 elif button == self.__installButton: |
119 elif button == self.__installButton: |
109 self.closeAndInstall.emit() |
120 self.closeAndInstall.emit() |
165 def on_repositoryList_itemSelectionChanged(self): |
176 def on_repositoryList_itemSelectionChanged(self): |
166 """ |
177 """ |
167 Private slot to handle a change of the selection. |
178 Private slot to handle a change of the selection. |
168 """ |
179 """ |
169 self.__downloadButton.setEnabled(len(self.__selectedItems())) |
180 self.__downloadButton.setEnabled(len(self.__selectedItems())) |
|
181 self.__downloadInstallButton.setEnabled(len(self.__selectedItems())) |
170 |
182 |
171 def __updateList(self): |
183 def __updateList(self): |
172 """ |
184 """ |
173 Private slot to download a new list and display the contents. |
185 Private slot to download a new list and display the contents. |
174 """ |
186 """ |
188 |
200 |
189 def __downloadPluginDone(self, status, filename): |
201 def __downloadPluginDone(self, status, filename): |
190 """ |
202 """ |
191 Private method called, when the download of a plugin is finished. |
203 Private method called, when the download of a plugin is finished. |
192 |
204 |
193 @param status flaging indicating a successful download (boolean) |
205 @param status flag indicating a successful download (boolean) |
194 @param filename full path of the downloaded file (string) |
206 @param filename full path of the downloaded file (string) |
195 """ |
207 """ |
196 if status: |
208 if status: |
197 self.__pluginsDownloaded.append(filename) |
209 self.__pluginsDownloaded.append(filename) |
|
210 if self.__isDownloadInstall: |
|
211 self.__allDownloadedOk &= status |
198 |
212 |
199 del self.__pluginsToDownload[0] |
213 del self.__pluginsToDownload[0] |
200 if len(self.__pluginsToDownload): |
214 if len(self.__pluginsToDownload): |
201 self.__downloadPlugin() |
215 self.__downloadPlugin() |
202 else: |
216 else: |
215 Private slot to download the selected plugins. |
229 Private slot to download the selected plugins. |
216 """ |
230 """ |
217 self.__pluginsDownloaded = [] |
231 self.__pluginsDownloaded = [] |
218 self.__pluginsToDownload = [] |
232 self.__pluginsToDownload = [] |
219 self.__downloadButton.setEnabled(False) |
233 self.__downloadButton.setEnabled(False) |
|
234 self.__downloadInstallButton.setEnabled(False) |
220 self.__installButton.setEnabled(False) |
235 self.__installButton.setEnabled(False) |
221 for itm in self.repositoryList.selectedItems(): |
236 for itm in self.repositoryList.selectedItems(): |
222 if itm not in [self.__stableItem, self.__unstableItem, self.__unknownItem]: |
237 if itm not in [self.__stableItem, self.__unstableItem, self.__unknownItem]: |
223 url = itm.data(0, urlRole) |
238 url = itm.data(0, urlRole) |
224 filename = os.path.join( |
239 filename = os.path.join( |
230 def __downloadPluginsDone(self): |
245 def __downloadPluginsDone(self): |
231 """ |
246 """ |
232 Private method called, when the download of the plugins is finished. |
247 Private method called, when the download of the plugins is finished. |
233 """ |
248 """ |
234 self.__downloadButton.setEnabled(len(self.__selectedItems())) |
249 self.__downloadButton.setEnabled(len(self.__selectedItems())) |
|
250 self.__downloadInstallButton.setEnabled(len(self.__selectedItems())) |
235 self.__installButton.setEnabled(True) |
251 self.__installButton.setEnabled(True) |
236 self.__doneMethod = None |
252 self.__doneMethod = None |
237 E5MessageBox.information(self, |
253 if self.__isDownloadInstall: |
238 self.trUtf8("Download Plugin Files"), |
254 self.closeAndInstall.emit() |
239 self.trUtf8("""The requested plugins were downloaded.""")) |
255 else: |
240 self.downloadProgress.setValue(0) |
256 E5MessageBox.information(self, |
241 |
257 self.trUtf8("Download Plugin Files"), |
242 # repopulate the list to update the refresh icons |
258 self.trUtf8("""The requested plugins were downloaded.""")) |
243 self.__populateList() |
259 self.downloadProgress.setValue(0) |
|
260 |
|
261 # repopulate the list to update the refresh icons |
|
262 self.__populateList() |
244 |
263 |
245 def __resortRepositoryList(self): |
264 def __resortRepositoryList(self): |
246 """ |
265 """ |
247 Private method to resort the tree. |
266 Private method to resort the tree. |
248 """ |
267 """ |
293 @param filename local name of the file (string) |
312 @param filename local name of the file (string) |
294 @param doneMethod method to be called when done |
313 @param doneMethod method to be called when done |
295 """ |
314 """ |
296 self.__updateButton.setEnabled(False) |
315 self.__updateButton.setEnabled(False) |
297 self.__downloadButton.setEnabled(False) |
316 self.__downloadButton.setEnabled(False) |
|
317 self.__downloadInstallButton.setEnabled(False) |
298 self.__downloadCancelButton.setEnabled(True) |
318 self.__downloadCancelButton.setEnabled(True) |
299 |
319 |
300 self.statusLabel.setText(url) |
320 self.statusLabel.setText(url) |
301 |
321 |
302 self.__doneMethod = doneMethod |
322 self.__doneMethod = doneMethod |
341 if self.repositoryList.currentItem() is None: |
361 if self.repositoryList.currentItem() is None: |
342 self.repositoryList.setCurrentItem( |
362 self.repositoryList.setCurrentItem( |
343 self.repositoryList.topLevelItem(0)) |
363 self.repositoryList.topLevelItem(0)) |
344 else: |
364 else: |
345 self.__downloadButton.setEnabled(len(self.__selectedItems())) |
365 self.__downloadButton.setEnabled(len(self.__selectedItems())) |
|
366 self.__downloadInstallButton.setEnabled(len(self.__selectedItems())) |
346 return |
367 return |
347 |
368 |
348 self.__downloadIODevice.open(QIODevice.WriteOnly) |
369 self.__downloadIODevice.open(QIODevice.WriteOnly) |
349 self.__downloadIODevice.write(reply.readAll()) |
370 self.__downloadIODevice.write(reply.readAll()) |
350 self.__downloadIODevice.close() |
371 self.__downloadIODevice.close() |