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

Forbid deletions from imported data

parent 89ec496d
Pipeline #103790 passed with stage
in 2 minutes and 3 seconds
......@@ -89,11 +89,27 @@ SSHManagerTreeWidget::SSHManagerTreeWidget(QWidget *parent)
ui->profile->setModelColumn(Konsole::ProfileModel::PROFILE);
ui->treeView->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->treeView, &QTreeView::customContextMenuRequested, [this](const QPoint &pos) {
if (!ui->treeView->indexAt(pos).isValid()) {
QModelIndex idx = ui->treeView->indexAt(pos);
if (!idx.isValid()) {
return;
}
if (idx.data(Qt::DisplayRole) == i18n("SSH Config")) {
return;
}
auto sourceIdx = d->filterModel->mapToSource(idx);
const bool isParent = sourceIdx.parent() == d->model->invisibleRootItem()->index();
if (!isParent) {
const auto item = d->model->itemFromIndex(sourceIdx);
const auto data = item->data(SSHManagerModel::SSHRole).value<SSHConfigurationData>();
if (data.importedFromSshConfig) {
return;
}
}
QMenu *menu = new QMenu(this);
auto action = new QAction(QStringLiteral("Remove"), ui->treeView);
menu->addAction(action);
......@@ -374,6 +390,13 @@ void SSHManagerTreeWidget::handleTreeClick(Qt::MouseButton btn, const QModelInde
if (isParent) {
setEditComponentsEnabled(false);
if (sourceIdx.data(Qt::DisplayRole).toString() == i18n("SSH Config")) {
ui->btnRemove->setEnabled(false);
ui->btnRemove->setToolTip(i18n("Cannot remove this folder"));
} else {
ui->btnRemove->setEnabled(true);
ui->btnRemove->setToolTip(i18n("Remove folder and all of it's contents"));
}
ui->btnEdit->setEnabled(false);
if (ui->sshInfoPane->isVisible()) {
ui->errorPanel->setText(i18n("Double click to change the folder name."));
......
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