Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
Konsole
Commits
f4d35d07
Commit
f4d35d07
authored
Nov 24, 2021
by
Tomaz Canabrava
Committed by
Kurt Hindenburg
Jan 26, 2022
Browse files
Method to retrieve the Profile for a specific SSH Host
parent
5c252472
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/plugins/SSHManager/sshmanagermodel.cpp
View file @
f4d35d07
...
...
@@ -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
);
...
...
src/plugins/SSHManager/sshmanagermodel.h
View file @
f4d35d07
...
...
@@ -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
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment