-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/conan-remote-tab-widget' into develop
- Loading branch information
Showing
16 changed files
with
1,279 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class ConanRemote: | ||
def __init__(self, name: str, url: str, ssl: bool): | ||
self.name = name | ||
self.url = url | ||
self.ssl = ssl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
conanguide/ui/controller/tab/remote/conan_remote_reference.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
from PySide2 import QtWidgets | ||
from PySide2.QtGui import QStandardItemModel, QStandardItem | ||
|
||
from conanguide.api.conan_api import ConanApi | ||
|
||
|
||
class ConanRemoteReferenceListController: | ||
""" | ||
Controller class to control view and model of the conan remote list | ||
""" | ||
|
||
def __init__(self, view: QtWidgets.QListView, conan_api: ConanApi): | ||
self.view = view | ||
self.conan_api = conan_api | ||
|
||
self.model = QStandardItemModel() | ||
self.view.setModel(self.model) | ||
|
||
def update(self, remote_name: str): | ||
""" | ||
This method provides list of recipes thats are referenced to the given remote name. | ||
The conan API method 'remote_list_ref' gives a dictionary with recipe name as key and remote name as value. In | ||
this method we will make a list of key based on the value of the dictionary. Basically this is a reverse search | ||
of an dictionary. | ||
:param remote_name: Remote name | ||
""" | ||
self.model.clear() | ||
|
||
# Get the reference list from the conan API | ||
remote_reference = self.conan_api.remote_list_ref() | ||
|
||
# Put the key and values into a list | ||
recipe_keys = list(remote_reference.keys()) | ||
remote_values = list(remote_reference.values()) | ||
|
||
# Get the index numbers into a list where the value is matched to the given remote name | ||
index_list = [i for i, j in enumerate(remote_values) if j == remote_name] | ||
|
||
# Finally based on the index list, we will get the keys from dictionary. This list will contain the recipes | ||
# that are referenced to the given remote name | ||
recipe_reference_list = [recipe_keys[i] for i in index_list] | ||
|
||
# Feed the list of recipe to the QlistView widget | ||
for recipe in recipe_reference_list: | ||
item = QStandardItem(recipe) | ||
item.setEditable(False) | ||
|
||
self.model.appendRow(item) | ||
|
||
def clear(self): | ||
self.model.clear() |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
from conanguide.ui.dialog.edit.remote.edit_remote_ui import Ui_DialogEditRemote | ||
|
||
from PySide2.QtCore import Slot | ||
|
||
from PySide2 import QtWidgets, QtCore | ||
|
||
|
||
class DialogEditRemote(QtWidgets.QDialog, Ui_DialogEditRemote): | ||
def __init__(self, title: str, list_name: list, name="", url="", ssl=True, edit_mode=False, *args, obj=None, | ||
**kwargs): | ||
super(DialogEditRemote, self).__init__(*args, **kwargs) | ||
self.setupUi(self) | ||
|
||
self.title = title | ||
self.list_name = list_name | ||
self.name = name | ||
self.url = url | ||
self.ssl = ssl | ||
self.edit_mode = edit_mode | ||
|
||
self.setWindowTitle(title) | ||
|
||
self.lineEditName.setText(self.name) | ||
self.lineEditName.textChanged.connect(self._on_edit_text_name) | ||
|
||
self.lineEditURL.setText(self.url) | ||
|
||
self.checkBoxVerifySSL.setChecked(self.ssl) | ||
|
||
if self.edit_mode: | ||
self.btnOK.setEnabled(True) | ||
else: | ||
self.btnOK.setEnabled(False) | ||
|
||
self.setWindowFlag(QtCore.Qt.WindowContextHelpButtonHint, False) | ||
|
||
@Slot() | ||
def on_btnOK_clicked(self): | ||
self.accept() | ||
self.close() | ||
|
||
@Slot() | ||
def on_btnCancel_clicked(self): | ||
self.close() | ||
|
||
@property | ||
def remote_name(self) -> str: | ||
return self.lineEditName.text() | ||
|
||
@property | ||
def remote_url(self) -> str: | ||
return self.lineEditURL.text() | ||
|
||
@property | ||
def remote_ssl(self) -> bool: | ||
return self.checkBoxVerifySSL.isChecked() | ||
|
||
def _on_edit_text_name(self): | ||
if self.lineEditName.text() == "": | ||
self.btnOK.setEnabled(False) | ||
elif self.lineEditName.text() == self.name and self.lineEditName.text() != "": | ||
self.btnOK.setEnabled(False) | ||
self.labelInfo.setText("Choose another name.") | ||
else: | ||
if self.lineEditName.text() in self.list_name: | ||
self.labelInfo.setText("Name already exists.") | ||
self.btnOK.setEnabled(False) | ||
else: | ||
self.labelInfo.setText("") | ||
self.btnOK.setEnabled(True) |
Oops, something went wrong.