94 for itm in self.venvList.selectedItems(): |
94 for itm in self.venvList.selectedItems(): |
95 if ( |
95 if ( |
96 itm.text(0) != "<default>" |
96 itm.text(0) != "<default>" |
97 and bool(itm.text(1)) |
97 and bool(itm.text(1)) |
98 and not itm.data(0, VirtualenvManagerWidget.MetadataRole).is_global |
98 and not itm.data(0, VirtualenvManagerWidget.MetadataRole).is_global |
99 and not itm.data(0, VirtualenvManagerWidget.MetadataRole).is_remote |
99 and itm.data(0, VirtualenvManagerWidget.MetadataRole).environment_type |
|
100 != "remote" |
100 ): |
101 ): |
101 deletableSelectedItemCount += 1 |
102 deletableSelectedItemCount += 1 |
102 |
103 |
103 deletableItemCount = 0 |
104 deletableItemCount = 0 |
104 for index in range(topLevelItemCount): |
105 for index in range(topLevelItemCount): |
105 itm = self.venvList.topLevelItem(index) |
106 itm = self.venvList.topLevelItem(index) |
106 if ( |
107 if ( |
107 itm.text(0) != "<default>" |
108 itm.text(0) != "<default>" |
108 and bool(itm.text(1)) |
109 and bool(itm.text(1)) |
109 and not itm.data(0, VirtualenvManagerWidget.MetadataRole).is_remote |
110 and itm.data(0, VirtualenvManagerWidget.MetadataRole).environment_type |
|
111 != "remote" |
110 ): |
112 ): |
111 deletableItemCount += 1 |
113 deletableItemCount += 1 |
112 |
114 |
113 canBeRemoved = ( |
115 canBeRemoved = ( |
114 selectedItemsCount == 1 |
116 selectedItemsCount == 1 |
322 """ |
324 """ |
323 self.__updateButtons() |
325 self.__updateButtons() |
324 |
326 |
325 selectedItems = self.venvList.selectedItems() |
327 selectedItems = self.venvList.selectedItems() |
326 if len(selectedItems) == 1: |
328 if len(selectedItems) == 1: |
327 self.descriptionEdit.setPlainText( |
329 envMetaData = selectedItems[0].data(0, VirtualenvManagerWidget.MetadataRole) |
328 selectedItems[0] |
330 self.descriptionEdit.setPlainText(envMetaData.description) |
329 .data(0, VirtualenvManagerWidget.MetadataRole) |
331 self.interpreterEdit.setText(envMetaData.interpreter) |
330 .description |
|
331 ) |
|
332 else: |
332 else: |
333 self.descriptionEdit.clear() |
333 self.descriptionEdit.clear() |
|
334 self.interpreterEdit.clear() |
334 |
335 |
335 @pyqtSlot() |
336 @pyqtSlot() |
336 def __refresh(self): |
337 def __refresh(self): |
337 """ |
338 """ |
338 Private slot to refresh the list of shown items. |
339 Private slot to refresh the list of shown items. |
356 |
357 |
357 def __populateVenvList(self): |
358 def __populateVenvList(self): |
358 """ |
359 """ |
359 Private method to populate the list of virtual environments. |
360 Private method to populate the list of virtual environments. |
360 """ |
361 """ |
|
362 typeNamesMapping = { |
|
363 n[0]: n[1] for n in self.__manager.getEnvironmentTypeNames() |
|
364 } |
|
365 |
361 for environment in self.__manager.getEnvironmentEntries(): |
366 for environment in self.__manager.getEnvironmentEntries(): |
362 itm = QTreeWidgetItem( |
367 itm = QTreeWidgetItem( |
363 self.venvList, |
368 self.venvList, |
364 [ |
369 [ |
365 environment.name, |
370 environment.name, |
|
371 typeNamesMapping[environment.environment_type], |
366 environment.path, |
372 environment.path, |
367 environment.interpreter, |
|
368 ], |
373 ], |
369 ) |
374 ) |
370 itm.setData(0, VirtualenvManagerWidget.MetadataRole, environment) |
375 itm.setData(0, VirtualenvManagerWidget.MetadataRole, environment) |
371 |
|
372 # show remote environments with underlined font |
|
373 if environment.is_remote: |
|
374 font = itm.font(0) |
|
375 font.setUnderline(True) |
|
376 for column in range(itm.columnCount()): |
|
377 itm.setFont(column, font) |
|
378 |
|
379 # show global environments with bold font |
|
380 elif environment.is_global: |
|
381 font = itm.font(0) |
|
382 font.setBold(True) |
|
383 for column in range(itm.columnCount()): |
|
384 itm.setFont(column, font) |
|
385 |
|
386 # show Anaconda environments with italic font |
|
387 elif environment.is_conda: |
|
388 font = itm.font(0) |
|
389 font.setItalic(True) |
|
390 for column in range(itm.columnCount()): |
|
391 itm.setFont(column, font) |
|
392 |
|
393 # show eric-ide server environments with underlined italic font |
|
394 elif environment.is_eric_server: |
|
395 font = itm.font(0) |
|
396 font.setItalic(True) |
|
397 font.setUnderline(True) |
|
398 for column in range(itm.columnCount()): |
|
399 itm.setFont(column, font) |
|
400 |
376 |
401 self.__resizeSections() |
377 self.__resizeSections() |
402 |
378 |
403 def __resizeSections(self): |
379 def __resizeSections(self): |
404 """ |
380 """ |
462 Constructor |
438 Constructor |
463 |
439 |
464 @param parent reference to the parent widget |
440 @param parent reference to the parent widget |
465 @type QWidget |
441 @type QWidget |
466 """ |
442 """ |
|
443 from eric7.EricWidgets.EricApplication import ericApp |
|
444 from eric7.PluginManager.PluginManager import PluginManager |
467 from eric7.VirtualEnv.VirtualenvManager import VirtualenvManager |
445 from eric7.VirtualEnv.VirtualenvManager import VirtualenvManager |
468 |
446 |
469 super().__init__(parent) |
447 super().__init__(parent) |
470 |
448 |
471 self.__virtualenvManager = VirtualenvManager(self) |
449 self.__virtualenvManager = VirtualenvManager(self) |
|
450 ericApp().registerObject("VirtualEnvManager", self.__virtualenvManager) |
|
451 |
|
452 self.__pluginManager = PluginManager(self) |
|
453 ericApp().registerObject("PluginManager", self.__pluginManager) |
|
454 self.__pluginManager.activateTypedPlugins("virtualenv") |
472 |
455 |
473 self.__centralWidget = QWidget(self) |
456 self.__centralWidget = QWidget(self) |
474 self.__layout = QVBoxLayout(self.__centralWidget) |
457 self.__layout = QVBoxLayout(self.__centralWidget) |
475 self.__centralWidget.setLayout(self.__layout) |
458 self.__centralWidget.setLayout(self.__layout) |
476 |
459 |
483 QDialogButtonBox.StandardButton.Close, Qt.Orientation.Horizontal, self |
466 QDialogButtonBox.StandardButton.Close, Qt.Orientation.Horizontal, self |
484 ) |
467 ) |
485 self.__layout.addWidget(self.__buttonBox) |
468 self.__layout.addWidget(self.__buttonBox) |
486 |
469 |
487 self.setCentralWidget(self.__centralWidget) |
470 self.setCentralWidget(self.__centralWidget) |
488 self.resize(700, 500) |
471 self.resize(700, 600) |
489 self.setWindowTitle(self.tr("Manage Virtual Environments")) |
472 self.setWindowTitle(self.tr("Manage Virtual Environments")) |
490 |
473 |
491 self.__buttonBox.accepted.connect(self.close) |
474 self.__buttonBox.accepted.connect(self.close) |
492 self.__buttonBox.rejected.connect(self.close) |
475 self.__buttonBox.rejected.connect(self.close) |