Commit f4d35d07 authored by Tomaz  Canabrava's avatar Tomaz Canabrava Committed by Kurt Hindenburg
Browse files

Method to retrieve the Profile for a specific SSH Host

parent 5c252472
......@@ -99,6 +99,28 @@ void SSHManagerModel::addChildItem(const SSHConfigurationData &config, const QSt
parentItem->sortChildren(0);
}
std::optional<QString> SSHManagerModel::profileForHost(const QString &host) const
{
auto *root = invisibleRootItem();
// iterate through folders:
for (int i = 0, end = root->rowCount(); i < end; ++i) {
// iterate throguh the items on folders;
auto folder = root->child(i);
for (int e = 0, inner_end = folder->rowCount(); e < inner_end; ++e) {
QStandardItem *ssh_item = folder->child(e);
auto data = ssh_item->data(SSHRole).value<SSHConfigurationData>();
// Return the profile name if the host matches.
if (data.host == host) {
return data.profileName;
}
}
}
return {};
}
bool SSHManagerModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
const bool ret = QStandardItemModel::setData(index, value, role);
......
......@@ -12,6 +12,7 @@
#include <QStandardItemModel>
#include <memory>
#include <optional>
namespace Konsole
{
......@@ -54,6 +55,7 @@ public:
void save();
bool hasHost(const QString &hostName) const;
std::optional<QString> profileForHost(const QString &host) const;
private:
QStandardItem *m_sshConfigTopLevelItem = nullptr;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment