Plugins/UiExtensionPlugins/PipInterface/PipSearchDialog.py

changeset 6331
758b1cb7a2e6
parent 6301
f488d2cc5841
child 6334
ca90aee56d20
equal deleted inserted replaced
6330:f2674335cf69 6331:758b1cb7a2e6
24 from .Ui_PipSearchDialog import Ui_PipSearchDialog 24 from .Ui_PipSearchDialog import Ui_PipSearchDialog
25 25
26 from . import DefaultIndexUrlXml 26 from . import DefaultIndexUrlXml
27 27
28 28
29 # TODO: add support for --user; additional button
30 class PipSearchDialog(QDialog, Ui_PipSearchDialog): 29 class PipSearchDialog(QDialog, Ui_PipSearchDialog):
31 """ 30 """
32 Class implementing a dialog to search PyPI. 31 Class implementing a dialog to search PyPI.
33 """ 32 """
34 VersionRole = Qt.UserRole + 1 33 VersionRole = Qt.UserRole + 1
57 56
58 self.__installButton = self.buttonBox.addButton( 57 self.__installButton = self.buttonBox.addButton(
59 self.tr("&Install"), QDialogButtonBox.ActionRole) 58 self.tr("&Install"), QDialogButtonBox.ActionRole)
60 self.__installButton.setEnabled(False) 59 self.__installButton.setEnabled(False)
61 60
61 self.__installUserButton = self.buttonBox.addButton(
62 self.tr("Install to &User-Site"), QDialogButtonBox.ActionRole)
63 self.__installUserButton.setEnabled(False)
64
62 self.__showDetailsButton = self.buttonBox.addButton( 65 self.__showDetailsButton = self.buttonBox.addButton(
63 self.tr("&Show Details..."), QDialogButtonBox.ActionRole) 66 self.tr("&Show Details..."), QDialogButtonBox.ActionRole)
64 self.__showDetailsButton.setEnabled(False) 67 self.__showDetailsButton.setEnabled(False)
65 68
66 self.__pip = pip 69 self.__pip = pip
116 def on_resultList_itemSelectionChanged(self): 119 def on_resultList_itemSelectionChanged(self):
117 """ 120 """
118 Private slot handling changes of the selection. 121 Private slot handling changes of the selection.
119 """ 122 """
120 self.__installButton.setEnabled( 123 self.__installButton.setEnabled(
124 len(self.resultList.selectedItems()) > 0)
125 self.__installUserButton.setEnabled(
121 len(self.resultList.selectedItems()) > 0) 126 len(self.resultList.selectedItems()) > 0)
122 self.__showDetailsButton.setEnabled( 127 self.__showDetailsButton.setEnabled(
123 len(self.resultList.selectedItems()) == 1) 128 len(self.resultList.selectedItems()) == 1)
124 129
125 @pyqtSlot(QAbstractButton) 130 @pyqtSlot(QAbstractButton)
134 elif button == self.buttonBox.button(QDialogButtonBox.Cancel): 139 elif button == self.buttonBox.button(QDialogButtonBox.Cancel):
135 self.__client.abort() 140 self.__client.abort()
136 self.__canceled = True 141 self.__canceled = True
137 elif button == self.__installButton: 142 elif button == self.__installButton:
138 self.__install() 143 self.__install()
144 elif button == self.__installUserButton:
145 self.__install(userSite=True)
139 elif button == self.__showDetailsButton: 146 elif button == self.__showDetailsButton:
140 self.__showDetails() 147 self.__showDetails()
141 148
142 def __search(self): 149 def __search(self):
143 """ 150 """
319 else: 326 else:
320 score += 1 327 score += 1
321 328
322 return score 329 return score
323 330
324 # TODO: add support for --user 331 def __install(self, userSite=False):
325 def __install(self):
326 """ 332 """
327 Private slot to install the selected packages. 333 Private slot to install the selected packages.
334
335 @param userSite flag indicating to install to the user directory
336 @type bool
328 """ 337 """
329 command = self.pipComboBox.currentText() 338 command = self.pipComboBox.currentText()
330 if command == self.__default: 339 if command == self.__default:
331 command = "" 340 command = ""
332 341
333 packages = [] 342 packages = []
334 for itm in self.resultList.selectedItems(): 343 for itm in self.resultList.selectedItems():
335 packages.append(itm.text(0).strip()) 344 packages.append(itm.text(0).strip())
336 if packages: 345 if packages:
337 self.__pip.installPackages(packages, cmd=command) 346 self.__pip.installPackages(packages, cmd=command,
347 userSite=userSite)
338 348
339 def __showDetails(self): 349 def __showDetails(self):
340 """ 350 """
341 Private slot to show details about the selected package. 351 Private slot to show details about the selected package.
342 """ 352 """

eric ide

mercurial