From 73a0f7ddf8a8db0057201374f1518d2063ad9a06 Mon Sep 17 00:00:00 2001 From: saturneric Date: Wed, 16 Apr 2025 01:19:53 +0200 Subject: feat: support key groups --- src/ui/widgets/KeyTreeView.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'src/ui/widgets/KeyTreeView.cpp') diff --git a/src/ui/widgets/KeyTreeView.cpp b/src/ui/widgets/KeyTreeView.cpp index c0a00c4e..46cfa2db 100644 --- a/src/ui/widgets/KeyTreeView.cpp +++ b/src/ui/widgets/KeyTreeView.cpp @@ -31,9 +31,8 @@ #include #include "core/function/gpg/GpgKeyGetter.h" -#include "core/utils/GpgUtils.h" #include "ui/UISignalStation.h" -#include "ui/dialog/keypair_details/KeyDetailsDialog.h" +#include "ui/UserInterfaceUtils.h" #include "ui/model/GpgKeyTreeProxyModel.h" namespace GpgFrontend::UI { @@ -109,18 +108,13 @@ void KeyTreeView::init() { connect(this, &QTableView::doubleClicked, this, [this](const QModelIndex& index) { - if (!index.isValid() || index.column() == 0) return; + if (!index.isValid()) return; - QModelIndex source_index = proxy_model_.mapToSource(index); - auto key = - GetGpgKeyByGpgAbstractKey(model_->GetKeyByIndex(source_index)); + auto key = GetKeyByIndex(index); + if (key == nullptr) return; - if (!key.IsGood()) { - QMessageBox::critical(this, tr("Error"), tr("Key Not Found.")); - return; - } - - new KeyDetailsDialog(model_->GetGpgContextChannel(), key, this); + CommonUtils::OpenDetailsDialogByKey( + this, model_->GetGpgContextChannel(), key); }); connect(UISignalStation::GetInstance(), @@ -150,4 +144,12 @@ void KeyTreeView::SetChannel(int channel) { proxy_model_.invalidate(); } +auto KeyTreeView::GetKeyByIndex(QModelIndex index) -> GpgAbstractKeyPtr { + auto* i = index.isValid() + ? static_cast(index.internalPointer()) + : nullptr; + assert(i != nullptr); + + return i->SharedKey(); +} } // namespace GpgFrontend::UI -- cgit v1.2.3