MCPcopy Create free account
hub / github.com/KDE/konsole / SSHManagerTreeWidget

Method SSHManagerTreeWidget

src/plugins/SSHManager/sshmanagerpluginwidget.cpp:48–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46};
47
48SSHManagerTreeWidget::SSHManagerTreeWidget(QWidget *parent)
49 : QWidget(parent)
50 , ui(std::make_unique<Ui::SSHTreeWidget>())
51 , d(std::make_unique<SSHManagerTreeWidget::Private>())
52{
53 ui->setupUi(this);
54 ui->errorPanel->hide();
55
56 d->filterModel = new SSHManagerFilterModel(this);
57
58 // full port range, users can setup ssh on any port they want
59 const auto *portValidator = new QIntValidator(0, 65535, this);
60 ui->port->setValidator(portValidator);
61
62 connect(ui->newSSHConfig, &QPushButton::clicked, this, &SSHManagerTreeWidget::showInfoPane);
63 connect(ui->btnCancel, &QPushButton::clicked, this, &SSHManagerTreeWidget::clearSshInfo);
64 connect(ui->btnEdit, &QPushButton::clicked, this, &SSHManagerTreeWidget::editSshInfo);
65 connect(ui->btnDelete, &QPushButton::clicked, this, &SSHManagerTreeWidget::triggerDelete);
66 connect(ui->btnInvertFilter, &QPushButton::clicked, d->filterModel, &SSHManagerFilterModel::setInvertFilter);
67
68 connect(ui->btnFindSshKey, &QPushButton::clicked, this, [this] {
69 const QString homeFolder = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
70 const QString sshFile = QFileDialog::getOpenFileName(this, i18n("SSH Key"), homeFolder + QStringLiteral("/.ssh"));
71 if (sshFile.isEmpty()) {
72 return;
73 }
74 ui->sshkey->setText(sshFile);
75 });
76
77 connect(ui->filterText, &QLineEdit::textChanged, this, [this] {
78 d->filterModel->setFilterRegularExpression(ui->filterText->text());
79 d->filterModel->invalidate();
80 });
81
82 connect(Konsole::ProfileModel::instance(), &Konsole::ProfileModel::rowsRemoved, this, &SSHManagerTreeWidget::updateProfileList);
83 connect(Konsole::ProfileModel::instance(), &Konsole::ProfileModel::rowsInserted, this, &SSHManagerTreeWidget::updateProfileList);
84 updateProfileList();
85
86 ui->treeView->setContextMenuPolicy(Qt::CustomContextMenu);
87
88 connect(ui->treeView, &QTreeView::customContextMenuRequested, [this](const QPoint &pos) {
89 QModelIndex idx = ui->treeView->indexAt(pos);
90 if (!idx.isValid()) {
91 return;
92 }
93
94 if (idx.data(Qt::DisplayRole) == i18n("SSH Config")) {
95 return;
96 }
97
98 auto sourceIdx = d->filterModel->mapToSource(idx);
99 const bool isParent = sourceIdx.parent() == d->model->invisibleRootItem()->index();
100 if (!isParent) {
101 const auto item = d->model->itemFromIndex(sourceIdx);
102 const auto data = item->data(SSHManagerModel::SSHRole).value<SSHConfigurationData>();
103 if (data.importedFromSshConfig) {
104 return;
105 }

Callers

nothing calls this directly

Calls 10

isEmptyMethod · 0.80
setTextMethod · 0.80
setEnabledMethod · 0.80
toStringMethod · 0.80
textMethod · 0.45
isValidMethod · 0.45
dataMethod · 0.45
parentMethod · 0.45
indexMethod · 0.45
setModelMethod · 0.45

Tested by

no test coverage detected