diff options
Diffstat (limited to '')
-rw-r--r-- | src/ui/widgets/KeyList.cpp | 71 |
1 files changed, 42 insertions, 29 deletions
diff --git a/src/ui/widgets/KeyList.cpp b/src/ui/widgets/KeyList.cpp index 58e53ae0..48c99269 100644 --- a/src/ui/widgets/KeyList.cpp +++ b/src/ui/widgets/KeyList.cpp @@ -115,7 +115,7 @@ void KeyList::AddListGroupTab(const QString& name, const QString& id, KeyListRow::KeyType selectType, KeyListColumn::InfoType infoType, const KeyTable::KeyTableFilter filter) { - GF_UI_LOG_DEBUG("add tab: {}", name.toStdString()); + GF_UI_LOG_DEBUG("add list group tab: {}", name); auto* key_list = new QTableWidget(this); if (m_key_list_ == nullptr) { @@ -126,7 +126,7 @@ void KeyList::AddListGroupTab(const QString& name, const QString& id, m_key_tables_.emplace_back(key_list, selectType, infoType, filter); m_key_tables_.back().SetMenuAbility(menu_ability_); - key_list->setColumnCount(7); + key_list->setColumnCount(8); key_list->horizontalHeader()->setSectionResizeMode( QHeaderView::ResizeToContents); key_list->verticalHeader()->hide(); @@ -159,13 +159,16 @@ void KeyList::AddListGroupTab(const QString& name, const QString& id, if ((infoType & KeyListColumn::Validity) == 0U) { key_list->setColumnHidden(5, true); } - if ((infoType & KeyListColumn::FingerPrint) == 0U) { + if ((infoType & KeyListColumn::KeyID) == 0U) { key_list->setColumnHidden(6, true); } + if ((infoType & KeyListColumn::FingerPrint) == 0U) { + key_list->setColumnHidden(7, true); + } QStringList labels; labels << tr("Select") << tr("Type") << tr("Name") << tr("Email Address") - << tr("Usage") << tr("Trust") << tr("Finger Print"); + << tr("Usage") << tr("Trust") << tr("Key ID") << tr("Finger Print"); key_list->setHorizontalHeaderLabels(labels); key_list->horizontalHeader()->setStretchLastSection(false); @@ -190,7 +193,7 @@ void KeyList::SlotRefreshUI() { this->slot_refresh_ui(); } -KeyIdArgsListPtr KeyList::GetChecked(const KeyTable& key_table) { +auto KeyList::GetChecked(const KeyTable& key_table) -> KeyIdArgsListPtr { auto ret = std::make_unique<KeyIdArgsList>(); for (int i = 0; i < key_table.key_list_->rowCount(); i++) { if (key_table.key_list_->item(i, 0)->checkState() == Qt::Checked) { @@ -200,7 +203,7 @@ KeyIdArgsListPtr KeyList::GetChecked(const KeyTable& key_table) { return ret; } -KeyIdArgsListPtr KeyList::GetChecked() { +auto KeyList::GetChecked() -> KeyIdArgsListPtr { auto* key_list = qobject_cast<QTableWidget*>(ui_->keyGroupTab->currentWidget()); const auto& buffered_keys = @@ -214,7 +217,7 @@ KeyIdArgsListPtr KeyList::GetChecked() { return ret; } -KeyIdArgsListPtr KeyList::GetAllPrivateKeys() { +auto KeyList::GetAllPrivateKeys() -> KeyIdArgsListPtr { auto* key_list = qobject_cast<QTableWidget*>(ui_->keyGroupTab->currentWidget()); const auto& buffered_keys = @@ -228,7 +231,7 @@ KeyIdArgsListPtr KeyList::GetAllPrivateKeys() { return ret; } -KeyIdArgsListPtr KeyList::GetPrivateChecked() { +auto KeyList::GetPrivateChecked() -> KeyIdArgsListPtr { auto ret = std::make_unique<KeyIdArgsList>(); if (ui_->keyGroupTab->size().isEmpty()) return ret; @@ -289,7 +292,7 @@ KeyIdArgsListPtr KeyList::GetSelected() { return ret; } -[[maybe_unused]] bool KeyList::ContainsPrivateKeys() { +[[maybe_unused]] auto KeyList::ContainsPrivateKeys() -> bool { if (ui_->keyGroupTab->size().isEmpty()) return false; m_key_list_ = qobject_cast<QTableWidget*>(ui_->keyGroupTab->currentWidget()); @@ -315,7 +318,7 @@ void KeyList::contextMenuEvent(QContextMenuEvent* event) { QString current_tab_widget_obj_name = ui_->keyGroupTab->widget(ui_->keyGroupTab->currentIndex())->objectName(); GF_UI_LOG_DEBUG("current tab widget object name: {}", - current_tab_widget_obj_name.toStdString()); + current_tab_widget_obj_name); if (current_tab_widget_obj_name == "favourite") { QList<QAction*> actions = popup_menu_->actions(); for (QAction* action : actions) { @@ -388,7 +391,7 @@ void KeyList::dropEvent(QDropEvent* event) { QFile file; file.setFileName(tmp.toLocalFile()); if (!file.open(QIODevice::ReadOnly)) { - GF_UI_LOG_ERROR("couldn't open file: {}", tmp.toString().toStdString()); + GF_UI_LOG_ERROR("couldn't open file: {}", tmp.toString()); } QByteArray in_buffer = file.readAll(); this->import_keys(in_buffer); @@ -426,7 +429,7 @@ void KeyList::SetDoubleClickedAction( this->m_action_ = std::move(action); } -QString KeyList::GetSelectedKey() { +auto KeyList::GetSelectedKey() -> QString { if (ui_->keyGroupTab->size().isEmpty()) return {}; const auto& buffered_keys = m_key_tables_[ui_->keyGroupTab->currentIndex()].buffered_keys_; @@ -576,12 +579,16 @@ void KeyTable::Refresh(KeyLinkListPtr m_keys) { while (it != keys->end()) { // filter by search bar's keyword if (ability_ & KeyMenuAbility::SEARCH_BAR && !keyword_.isEmpty()) { - auto name = it->GetName().toLower(); - auto email = it->GetEmail().toLower(); - auto comment = it->GetComment().toLower(); + QStringList infos; + infos << it->GetName().toLower() << it->GetEmail().toLower() + << it->GetComment().toLower() << it->GetFingerprint().toLower(); + + auto subkeys = it->GetSubKeys(); + for (const auto& subkey : *subkeys) { + infos << subkey.GetFingerprint().toLower() << subkey.GetID().toLower(); + } - if (!name.contains(keyword_) && !email.contains(keyword_) && - !comment.contains(keyword_)) { + if (infos.filter(keyword_.toLower()).isEmpty()) { it = keys->erase(it); continue; } @@ -657,22 +664,28 @@ void KeyTable::Refresh(KeyLinkListPtr m_keys) { temp_validity->setTextAlignment(Qt::AlignCenter); key_list_->setItem(row_index, 5, temp_validity); + auto* temp_id = new QTableWidgetItem(it->GetId()); + temp_id->setTextAlignment(Qt::AlignCenter); + key_list_->setItem(row_index, 6, temp_id); + auto* temp_fpr = new QTableWidgetItem(it->GetFingerprint()); temp_fpr->setTextAlignment(Qt::AlignCenter); - key_list_->setItem(row_index, 6, temp_fpr); + key_list_->setItem(row_index, 7, temp_fpr); + + QFont font = tmp2->font(); // strike out expired keys - if (it->IsExpired() || it->IsRevoked()) { - QFont strike = tmp2->font(); - strike.setStrikeOut(true); - tmp0->setFont(strike); - temp_usage->setFont(strike); - temp_fpr->setFont(strike); - temp_validity->setFont(strike); - tmp1->setFont(strike); - tmp2->setFont(strike); - tmp3->setFont(strike); - } + if (it->IsExpired() || it->IsRevoked()) font.setStrikeOut(true); + if (it->IsPrivateKey()) font.setBold(true); + + tmp0->setFont(font); + temp_usage->setFont(font); + temp_fpr->setFont(font); + temp_validity->setFont(font); + tmp1->setFont(font); + tmp2->setFont(font); + tmp3->setFont(font); + temp_id->setFont(font); // move to buffered keys buffered_keys_.emplace_back(std::move(*it)); |