Commit d2d2157f authored by Tomaz  Canabrava's avatar Tomaz Canabrava
Browse files

new method: Has Host. Important to check if we loaded something yet

parent 52076ab9
......@@ -115,6 +115,22 @@ QStringList SSHManagerModel::folders() const
return retList;
}
bool SSHManagerModel::hasHost(const QString &host) const
{
// runs in O(N), should be ok for the amount of data peophe have.
for (int i = 0, end = invisibleRootItem()->rowCount(); i < end; i++) {
QStandardItem *iChild = invisibleRootItem()->child(i);
for (int e = 0, end = iChild->rowCount(); i < end; e++) {
QStandardItem *eChild = iChild->child(e);
const auto data = eChild->data(SSHManagerModel::Roles::SSHRole).value<SSHConfigurationData>();
if (data.host == host) {
return true;
}
}
}
return false;
}
void SSHManagerModel::load()
{
auto config = KConfig(QStringLiteral("konsolesshconfig"), KConfig::OpenFlag::SimpleConfig);
......
......@@ -39,6 +39,8 @@ public:
void load();
void save();
bool hasHost(const QString &hostName) 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