29 class CondaPackagesWidget(QWidget, Ui_CondaPackagesWidget): |
29 class CondaPackagesWidget(QWidget, Ui_CondaPackagesWidget): |
30 """ |
30 """ |
31 Class implementing the conda packages management widget. |
31 Class implementing the conda packages management widget. |
32 """ |
32 """ |
33 # Role definition of packages list |
33 # Role definition of packages list |
34 PackageVersionRole = Qt.UserRole + 1 |
34 PackageVersionRole = Qt.ItemDataRole.UserRole + 1 |
35 PackageBuildRole = Qt.UserRole + 2 |
35 PackageBuildRole = Qt.ItemDataRole.UserRole + 2 |
36 |
36 |
37 # Role definitions of search results list |
37 # Role definitions of search results list |
38 PackageDetailedDataRole = Qt.UserRole + 1 |
38 PackageDetailedDataRole = Qt.ItemDataRole.UserRole + 1 |
39 |
39 |
40 def __init__(self, conda, parent=None): |
40 def __init__(self, conda, parent=None): |
41 """ |
41 """ |
42 Constructor |
42 Constructor |
43 |
43 |
68 |
68 |
69 self.condaMenuButton.setObjectName( |
69 self.condaMenuButton.setObjectName( |
70 "conda_supermenu_button") |
70 "conda_supermenu_button") |
71 self.condaMenuButton.setIcon(UI.PixmapCache.getIcon("superMenu")) |
71 self.condaMenuButton.setIcon(UI.PixmapCache.getIcon("superMenu")) |
72 self.condaMenuButton.setToolTip(self.tr("Conda Menu")) |
72 self.condaMenuButton.setToolTip(self.tr("Conda Menu")) |
73 self.condaMenuButton.setPopupMode(QToolButton.InstantPopup) |
73 self.condaMenuButton.setPopupMode( |
74 self.condaMenuButton.setToolButtonStyle(Qt.ToolButtonIconOnly) |
74 QToolButton.ToolButtonPopupMode.InstantPopup) |
75 self.condaMenuButton.setFocusPolicy(Qt.NoFocus) |
75 self.condaMenuButton.setToolButtonStyle( |
|
76 Qt.ToolButtonStyle.ToolButtonIconOnly) |
|
77 self.condaMenuButton.setFocusPolicy(Qt.FocusPolicy.NoFocus) |
76 self.condaMenuButton.setAutoRaise(True) |
78 self.condaMenuButton.setAutoRaise(True) |
77 self.condaMenuButton.setShowMenuInside(True) |
79 self.condaMenuButton.setShowMenuInside(True) |
78 |
80 |
79 self.refreshButton.setIcon(UI.PixmapCache.getIcon("reload")) |
81 self.refreshButton.setIcon(UI.PixmapCache.getIcon("reload")) |
80 self.upgradeButton.setIcon(UI.PixmapCache.getIcon("1uparrow")) |
82 self.upgradeButton.setIcon(UI.PixmapCache.getIcon("1uparrow")) |
239 self.packagesList.setUpdatesEnabled(False) |
241 self.packagesList.setUpdatesEnabled(False) |
240 updateablePackages = self.__conda.getUpdateablePackages( |
242 updateablePackages = self.__conda.getUpdateablePackages( |
241 prefix=prefix) |
243 prefix=prefix) |
242 for package, version, build in updateablePackages: |
244 for package, version, build in updateablePackages: |
243 items = self.packagesList.findItems( |
245 items = self.packagesList.findItems( |
244 package, Qt.MatchExactly | Qt.MatchCaseSensitive) |
246 package, |
|
247 Qt.MatchFlag.MatchExactly | |
|
248 Qt.MatchFlag.MatchCaseSensitive) |
245 if items: |
249 if items: |
246 itm = items[0] |
250 itm = items[0] |
247 itm.setText(2, version) |
251 itm.setText(2, version) |
248 itm.setData(2, self.PackageVersionRole, version) |
252 itm.setData(2, self.PackageVersionRole, version) |
249 itm.setData(2, self.PackageBuildRole, build) |
253 itm.setData(2, self.PackageBuildRole, build) |
256 itm.setText(2, self.tr("{0} (Build: {1})").format( |
260 itm.setText(2, self.tr("{0} (Build: {1})").format( |
257 itm.data(2, self.PackageVersionRole), |
261 itm.data(2, self.PackageVersionRole), |
258 itm.data(2, self.PackageBuildRole), |
262 itm.data(2, self.PackageBuildRole), |
259 )) |
263 )) |
260 |
264 |
261 self.packagesList.sortItems(0, Qt.AscendingOrder) |
265 self.packagesList.sortItems(0, Qt.SortOrder.AscendingOrder) |
262 for col in range(self.packagesList.columnCount()): |
266 for col in range(self.packagesList.columnCount()): |
263 self.packagesList.resizeColumnToContents(col) |
267 self.packagesList.resizeColumnToContents(col) |
264 self.packagesList.setUpdatesEnabled(True) |
268 self.packagesList.setUpdatesEnabled(True) |
265 self.statusLabel.hide() |
269 self.statusLabel.hide() |
266 |
270 |
285 |
289 |
286 with E5OverrideCursor(): |
290 with E5OverrideCursor(): |
287 self.__populateEnvironments() |
291 self.__populateEnvironments() |
288 |
292 |
289 index = self.environmentsComboBox.findText( |
293 index = self.environmentsComboBox.findText( |
290 currentEnvironment, Qt.MatchExactly | Qt.MatchCaseSensitive) |
294 currentEnvironment, |
|
295 Qt.MatchFlag.MatchExactly | Qt.MatchFlag.MatchCaseSensitive) |
291 if index != -1: |
296 if index != -1: |
292 self.environmentsComboBox.setCurrentIndex(index) |
297 self.environmentsComboBox.setCurrentIndex(index) |
293 |
298 |
294 self.__updateActionButtons() |
299 self.__updateActionButtons() |
295 |
300 |
384 citm = QTreeWidgetItem( |
389 citm = QTreeWidgetItem( |
385 itm, ["", version, build, platform]) |
390 itm, ["", version, build, platform]) |
386 citm.setData(0, self.PackageDetailedDataRole, |
391 citm.setData(0, self.PackageDetailedDataRole, |
387 detail) |
392 detail) |
388 |
393 |
389 self.searchResultList.sortItems(0, Qt.AscendingOrder) |
394 self.searchResultList.sortItems( |
|
395 0, Qt.SortOrder.AscendingOrder) |
390 self.searchResultList.resizeColumnToContents(0) |
396 self.searchResultList.resizeColumnToContents(0) |
391 self.searchResultList.setUpdatesEnabled(True) |
397 self.searchResultList.setUpdatesEnabled(True) |
392 if not ok: |
398 if not ok: |
393 try: |
399 try: |
394 message = result["message"] |
400 message = result["message"] |
509 @type bool |
515 @type bool |
510 """ |
516 """ |
511 self.searchWidget.setVisible(checked) |
517 self.searchWidget.setVisible(checked) |
512 |
518 |
513 if checked: |
519 if checked: |
514 self.searchEdit.setFocus(Qt.OtherFocusReason) |
520 self.searchEdit.setFocus(Qt.FocusReason.OtherFocusReason) |
515 self.searchEdit.selectAll() |
521 self.searchEdit.selectAll() |
516 |
522 |
517 self.__updateSearchActionButtons() |
523 self.__updateSearchActionButtons() |
518 |
524 |
519 ####################################################################### |
525 ####################################################################### |
554 if prefix: |
560 if prefix: |
555 ok, packageSpecs = E5TextInputDialog.getText( |
561 ok, packageSpecs = E5TextInputDialog.getText( |
556 self, |
562 self, |
557 self.tr("Install Packages"), |
563 self.tr("Install Packages"), |
558 self.tr("Package Specifications (separated by whitespace):"), |
564 self.tr("Package Specifications (separated by whitespace):"), |
559 QLineEdit.Normal, |
565 QLineEdit.EchoMode.Normal, |
560 minimumWidth=600) |
566 minimumWidth=600) |
561 if ok and packageSpecs.strip(): |
567 if ok and packageSpecs.strip(): |
562 packages = [p.strip() for p in packageSpecs.split()] |
568 packages = [p.strip() for p in packageSpecs.split()] |
563 ok = self.__conda.installPackages(packages, prefix=prefix) |
569 ok = self.__conda.installPackages(packages, prefix=prefix) |
564 if ok: |
570 if ok: |
614 prefix = self.environmentsComboBox.itemData( |
620 prefix = self.environmentsComboBox.itemData( |
615 self.environmentsComboBox.currentIndex()) |
621 self.environmentsComboBox.currentIndex()) |
616 if prefix: |
622 if prefix: |
617 dlg = CondaNewEnvironmentDataDialog(self.tr("Clone Environment"), |
623 dlg = CondaNewEnvironmentDataDialog(self.tr("Clone Environment"), |
618 False, self) |
624 False, self) |
619 if dlg.exec() == QDialog.Accepted: |
625 if dlg.exec() == QDialog.DialogCode.Accepted: |
620 virtEnvName, envName, _ = dlg.getData() |
626 virtEnvName, envName, _ = dlg.getData() |
621 args = [ |
627 args = [ |
622 "--name", |
628 "--name", |
623 envName.strip(), |
629 envName.strip(), |
624 "--clone", |
630 "--clone", |
638 from .CondaNewEnvironmentDataDialog import ( |
644 from .CondaNewEnvironmentDataDialog import ( |
639 CondaNewEnvironmentDataDialog) |
645 CondaNewEnvironmentDataDialog) |
640 |
646 |
641 dlg = CondaNewEnvironmentDataDialog(self.tr("Create Environment"), |
647 dlg = CondaNewEnvironmentDataDialog(self.tr("Create Environment"), |
642 True, self) |
648 True, self) |
643 if dlg.exec() == QDialog.Accepted: |
649 if dlg.exec() == QDialog.DialogCode.Accepted: |
644 virtEnvName, envName, requirements = dlg.getData() |
650 virtEnvName, envName, requirements = dlg.getData() |
645 args = [ |
651 args = [ |
646 "--name", |
652 "--name", |
647 envName.strip(), |
653 envName.strip(), |
648 "--file", |
654 "--file", |