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

Method handleTreeClick

src/plugins/SSHManager/sshmanagerpluginwidget.cpp:414–462  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

412}
413
414void SSHManagerTreeWidget::handleTreeClick(Qt::MouseButton btn, const QModelIndex idx)
415{
416 if (!d->controller) {
417 return;
418 }
419 auto sourceIdx = d->filterModel->mapToSource(idx);
420
421 ui->treeView->setCurrentIndex(idx);
422 ui->treeView->selectionModel()->setCurrentIndex(idx, QItemSelectionModel::SelectionFlag::Rows);
423
424 if (btn == Qt::LeftButton || btn == Qt::RightButton) {
425 const bool isParent = sourceIdx.parent() == d->model->invisibleRootItem()->index();
426
427 if (isParent) {
428 setEditComponentsEnabled(false);
429 if (sourceIdx.data(Qt::DisplayRole).toString() == i18n("SSH Config")) {
430 ui->btnDelete->setEnabled(false);
431 ui->btnDelete->setToolTip(i18n("Cannot delete this folder"));
432 } else {
433 ui->btnDelete->setEnabled(true);
434 ui->btnDelete->setToolTip(i18n("Delete folder and all of its contents"));
435 }
436 ui->btnEdit->setEnabled(false);
437 if (ui->sshInfoPane->isVisible()) {
438 ui->errorPanel->setText(i18n("Double click to change the folder name."));
439 }
440 } else {
441 const auto item = d->model->itemFromIndex(sourceIdx);
442 const auto data = item->data(SSHManagerModel::SSHRole).value<SSHConfigurationData>();
443 ui->btnEdit->setEnabled(true);
444 ui->btnDelete->setEnabled(!data.importedFromSshConfig);
445 ui->btnDelete->setToolTip(data.importedFromSshConfig ? i18n("You can't delete an automatically added entry.") : i18n("Delete selected entry"));
446 if (ui->sshInfoPane->isVisible()) {
447 handleImportedData(data.importedFromSshConfig);
448 editSshInfo();
449 }
450 }
451 return;
452 }
453
454 if (btn == Qt::MiddleButton) {
455 if (sourceIdx.parent() == d->model->invisibleRootItem()->index()) {
456 return;
457 }
458
459 Q_EMIT requestNewTab();
460 SSHManagerPlugin::requestConnection(d->filterModel, d->model, d->controller, sourceIdx);
461 }
462}
463
464void SSHManagerTreeWidget::showEvent(QShowEvent *)
465{

Callers

nothing calls this directly

Calls 6

toStringMethod · 0.80
setEnabledMethod · 0.80
setTextMethod · 0.80
parentMethod · 0.45
indexMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected