53 |
53 |
54 def __populateEnvironments(self): |
54 def __populateEnvironments(self): |
55 """ |
55 """ |
56 Private method to get a list of environments and populate the selector. |
56 Private method to get a list of environments and populate the selector. |
57 """ |
57 """ |
58 # TODO: populate with name and prefix |
58 environments = [("", "")] + sorted( |
59 environmentNames = [""] + self.__conda.getCondaEnvironmentsList() |
59 self.__conda.getCondaEnvironmentsList()) |
60 self.environmentsComboBox.addItems(sorted(environmentNames)) |
60 for environment in environments: |
|
61 self.environmentsComboBox.addItem(environment[0], environment[1]) |
61 |
62 |
62 def __initCondaMenu(self): |
63 def __initCondaMenu(self): |
63 """ |
64 """ |
64 Private method to create the super menu and attach it to the super |
65 Private method to create the super menu and attach it to the super |
65 menu button. |
66 menu button. |
66 """ |
67 """ |
67 self.__condaMenu = QMenu(self) |
68 self.__condaMenu = QMenu(self) |
68 # TODO: implement Conda menu |
69 # TODO: implement Conda menu |
69 self.__condaMenu.addAction(self.tr("Test Entry"), self.on_refreshButton_clicked) |
70 self.__condaMenu.addAction(self.tr("Test Entry"), |
|
71 self.on_refreshButton_clicked) |
70 |
72 |
71 self.condaMenuButton.setMenu(self.__condaMenu) |
73 self.condaMenuButton.setMenu(self.__condaMenu) |
72 |
74 |
73 def __selectedUpdateableItems(self): |
75 def __selectedUpdateableItems(self): |
74 """ |
76 """ |
106 self.uninstallButton.setEnabled( |
108 self.uninstallButton.setEnabled( |
107 bool(self.packagesList.selectedItems())) |
109 bool(self.packagesList.selectedItems())) |
108 self.upgradeAllButton.setEnabled( |
110 self.upgradeAllButton.setEnabled( |
109 bool(self.__allUpdateableItems())) |
111 bool(self.__allUpdateableItems())) |
110 |
112 |
111 # TODO: change to int = index |
113 @pyqtSlot(int) |
112 @pyqtSlot(str) |
114 def on_environmentsComboBox_currentIndexChanged(self, index): |
113 def on_environmentsComboBox_currentIndexChanged(self, name): |
|
114 """ |
115 """ |
115 Private slot handling the selection of a conda environment. |
116 Private slot handling the selection of a conda environment. |
116 |
117 |
117 @param name name of the selected conda environment name |
118 @param index index of the selected conda environment |
118 @type str |
119 @type int |
119 """ |
120 """ |
120 self.packagesList.clear() |
121 self.packagesList.clear() |
121 if name: |
122 prefix = self.environmentsComboBox.itemData(index) |
|
123 if prefix: |
122 QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) |
124 QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) |
123 QApplication.processEvents() |
125 QApplication.processEvents() |
124 |
126 |
|
127 self.packagesList.setUpdatesEnabled(False) |
125 # 1. populate with installed packages |
128 # 1. populate with installed packages |
126 # TODO: use prefix |
129 installedPackages = \ |
127 installedPackages = self.__conda.getInstalledPackages(name=name) |
130 self.__conda.getInstalledPackages(prefix=prefix) |
128 for package, version, build_ in installedPackages: |
131 for package, version, build in installedPackages: |
129 QTreeWidgetItem(self.packagesList, [package, version]) |
132 itm = QTreeWidgetItem(self.packagesList, [package, version]) |
|
133 itm.setToolTip(1, self.tr("Build: {0}").format(build)) |
130 |
134 |
131 # 2. update with update information |
135 # 2. update with update information |
132 updateablePackages = self.__conda.getUpdateablePackages(name=name) |
136 updateablePackages = \ |
133 for package, version, build_ in updateablePackages: |
137 self.__conda.getUpdateablePackages(prefix=prefix) |
|
138 for package, version, build in updateablePackages: |
134 items = self.packagesList.findItems( |
139 items = self.packagesList.findItems( |
135 package, Qt.MatchExactly | Qt.MatchCaseSensitive) |
140 package, Qt.MatchExactly | Qt.MatchCaseSensitive) |
136 if items: |
141 if items: |
137 items[0].setText(2, version) |
142 items[0].setText(2, version) |
|
143 items[0].setToolTip(2, self.tr("Build: {0}").format(build)) |
138 |
144 |
|
145 self.packagesList.sortItems(0, Qt.AscendingOrder) |
|
146 self.packagesList.setUpdatesEnabled(True) |
139 QApplication.restoreOverrideCursor() |
147 QApplication.restoreOverrideCursor() |
140 |
148 |
141 self.__updateActionButtons() |
149 self.__updateActionButtons() |
142 |
150 |
143 @pyqtSlot() |
151 @pyqtSlot() |