KeyList.h
#ifndef __KEYLIST_H__
#define __KEYLIST_H__
#include <utility>
#include "core/GpgContext.h"
#include "ui/dialog/import_export/KeyImportDetailDialog.h"
class Ui_KeyList;
namespace GpgFrontend::UI {
struct KeyListRow {
using KeyType = unsigned int;
static const KeyType SECRET_OR_PUBLIC_KEY = 0;
static const KeyType ONLY_SECRET_KEY = 1;
};
struct KeyListColumn {
using InfoType = unsigned int;
static constexpr InfoType ALL = ~0;
static constexpr InfoType TYPE = 1 << 0;
static constexpr InfoType NAME = 1 << 1;
static constexpr InfoType EmailAddress = 1 << 2;
static constexpr InfoType Usage = 1 << 3;
static constexpr InfoType Validity = 1 << 4;
static constexpr InfoType FingerPrint = 1 << 5;
};
struct KeyMenuAbility {
using AbilityType = unsigned int;
static constexpr AbilityType ALL = ~0;
static constexpr AbilityType NONE = 0;
static constexpr AbilityType REFRESH = 1 << 0;
static constexpr AbilityType SYNC_PUBLIC_KEY = 1 << 1;
static constexpr AbilityType UNCHECK_ALL = 1 << 3;
static constexpr AbilityType CHECK_ALL = 1 << 5;
};
struct KeyTable {
QTableWidget* key_list_;
KeyListRow::KeyType select_type_;
KeyListColumn::InfoType info_type_;
std::vector<GpgKey> buffered_keys_;
std::function<bool(const GpgKey&)> filter_;
KeyIdArgsListPtr checked_key_ids_;
KeyTable(
QTableWidget* _key_list, KeyListRow::KeyType _select_type,
KeyListColumn::InfoType _info_type,
std::function<bool(const GpgKey&)> _filter = [](const GpgKey&) -> bool {
return true;
})
: key_list_(_key_list),
select_type_(_select_type),
info_type_(_info_type),
filter_(std::move(_filter)) {}
void Refresh(KeyLinkListPtr m_keys = nullptr);
KeyIdArgsListPtr& GetChecked();
void UncheckALL() const;
void CheckALL() const;
void SetChecked(KeyIdArgsListPtr key_ids);
};
class KeyList : public QWidget {
Q_OBJECT
public:
explicit KeyList(KeyMenuAbility::AbilityType menu_ability,
QWidget* parent = nullptr);
void AddListGroupTab(
const QString& name,
KeyListRow::KeyType selectType = KeyListRow::SECRET_OR_PUBLIC_KEY,
KeyListColumn::InfoType infoType = KeyListColumn::ALL,
const std::function<bool(const GpgKey&)>& filter =
[](const GpgKey&) -> bool { return true; });
void SetDoubleClickedAction(
std::function<void(const GpgKey&, QWidget*)> action);
void SetColumnWidth(int row, int size);
void AddMenuAction(QAction* act);
void AddSeparator();
KeyIdArgsListPtr GetChecked();
static KeyIdArgsListPtr GetChecked(const KeyTable& key_table);
KeyIdArgsListPtr GetPrivateChecked();
KeyIdArgsListPtr GetAllPrivateKeys();
void SetChecked(KeyIdArgsListPtr key_ids);
static void SetChecked(const KeyIdArgsListPtr& keyIds,
const KeyTable& key_table);
KeyIdArgsListPtr GetSelected();
std::string GetSelectedKey();
[[maybe_unused]] static void MarkKeys(QStringList* keyIds);
[[maybe_unused]] bool ContainsPrivateKeys();
signals:
void SignalRefreshStatusBar(const QString& message, int timeout);
void SignalRefreshDatabase();
public slots:
void SlotRefresh();
private:
void init();
void import_keys(const QByteArray& inBuffer);
void uncheck_all();
void check_all();
std::mutex buffered_key_list_mutex_;
std::shared_ptr<Ui_KeyList> ui_;
QTableWidget* m_key_list_{};
std::vector<KeyTable> m_key_tables_;
QMenu* popup_menu_{};
GpgFrontend::KeyLinkListPtr buffered_keys_list_;
std::function<void(const GpgKey&, QWidget*)> m_action_ = nullptr;
KeyMenuAbility::AbilityType menu_ability_ = KeyMenuAbility::ALL;
private slots:
void slot_double_clicked(const QModelIndex& index);
void slot_refresh_ui();
void slot_sync_with_key_server();
protected:
void contextMenuEvent(QContextMenuEvent* event) override;
void dragEnterEvent(QDragEnterEvent* event) override;
void dropEvent(QDropEvent* event) override;
};
} // namespace GpgFrontend::UI
#endif // __KEYLIST_H__
GpgFrontend::UI
Definition: FileReadTask.cpp:31
GpgFrontend::UI::KeyList::KeyList
KeyList(KeyMenuAbility::AbilityType menu_ability, QWidget *parent=nullptr)
Construct a new Key List object.
Definition: KeyList.cpp:44
GpgFrontend::UI::KeyTable::KeyTable
KeyTable(QTableWidget *_key_list, KeyListRow::KeyType _select_type, KeyListColumn::InfoType _info_type, std::function< bool(const GpgKey &)> _filter=[](const GpgKey &) -> bool { return true;})
Construct a new Key Table object.
Definition: KeyList.h:103
GpgFrontend::GlobalSettingStation::SyncSettings
void SyncSettings() noexcept
sync the settings to the file
Definition: GlobalSettingStation.cpp:33
GpgFrontend::UI::KeyList::dragEnterEvent
void dragEnterEvent(QDragEnterEvent *event) override
Definition: KeyList.cpp:374
GpgFrontend::UI::KeyList::SetColumnWidth
void SetColumnWidth(int row, int size)
Set the Column Width object.
Definition: KeyList.cpp:282
GpgFrontend::SingletonFunctionObject< GpgKeyGetter >::GetInstance
static GpgKeyGetter & GetInstance(int channel=GpgFrontend::GPGFRONTEND_DEFAULT_CHANNEL)
Get the Instance object.
Definition: GpgFunctionObject.h:170
GpgFrontend::UI::KeyList::GetSelectedKey
std::string GetSelectedKey()
Get the Selected Key object.
Definition: KeyList.cpp:408
GpgFrontend::UI::KeyTable
Definition: KeyList.h:87
GpgFrontend::UI::KeyList::dropEvent
void dropEvent(QDropEvent *event) override
Definition: KeyList.cpp:302
GpgFrontend::GlobalSettingStation::GetUISettings
libconfig::Setting & GetUISettings() noexcept
Definition: GlobalSettingStation.h:63
GpgFrontend::UI::KeyList::SetChecked
void SetChecked(KeyIdArgsListPtr key_ids)
Set the Checked object.
Definition: KeyList.cpp:239
GpgFrontend::UI::KeyList::AddListGroupTab
void AddListGroupTab(const QString &name, KeyListRow::KeyType selectType=KeyListRow::SECRET_OR_PUBLIC_KEY, KeyListColumn::InfoType infoType=KeyListColumn::ALL, const std::function< bool(const GpgKey &)> &filter=[](const GpgKey &) -> bool { return true;})
Definition: KeyList.cpp:99
GpgFrontend::UI::KeyTable::SetChecked
void SetChecked(KeyIdArgsListPtr key_ids)
Set the Checked object.
Definition: KeyList.cpp:514
GpgFrontend::UI::KeyList::slot_double_clicked
void slot_double_clicked(const QModelIndex &index)
Definition: KeyList.cpp:392
GpgFrontend::UI::KeyListRow
Definition: KeyList.h:45
GpgFrontend::UI::KeyList::GetAllPrivateKeys
KeyIdArgsListPtr GetAllPrivateKeys()
Get the All Private Keys object.
Definition: KeyList.cpp:195
GpgFrontend::UI::KeyList::GetChecked
KeyIdArgsListPtr GetChecked()
Get the Checked object.
Definition: KeyList.cpp:181
GpgFrontend::UI::KeyTable::Refresh
void Refresh(KeyLinkListPtr m_keys=nullptr)
Definition: KeyList.cpp:519
GpgFrontend::GpgKeyGetter::FetchKey
KeyLinkListPtr FetchKey()
Get all the keys by receiving a linked list.
Definition: GpgKeyGetter.cpp:82
GpgFrontend::UI::KeyList::AddMenuAction
void AddMenuAction(QAction *act)
Definition: KeyList.cpp:300
GpgFrontend::UI::KeyList::import_keys
void import_keys(const QByteArray &inBuffer)
Definition: KeyList.cpp:385
GpgFrontend::UI::KeyImportDetailDialog
Definition: KeyImportDetailDialog.h:43
GpgFrontend::UI::KeyTable::GetChecked
KeyIdArgsListPtr & GetChecked()
Get the Checked object.
Definition: KeyList.cpp:498
GpgFrontend::UI::KeyList::ContainsPrivateKeys
bool ContainsPrivateKeys()
Definition: KeyList.cpp:270
GpgFrontend::GpgKeyGetter::GetKey
GpgKey GetKey(const std::string &id, bool use_cache=true)
Get the Key object.
Definition: GpgKeyGetter.cpp:47
GpgFrontend::UI::KeyList::GetSelected
KeyIdArgsListPtr GetSelected()
Get the Selected object.
Definition: KeyList.cpp:253
GpgFrontend::UI::KeyList::GetPrivateChecked
KeyIdArgsListPtr GetPrivateChecked()
Get the Private Checked object.
Definition: KeyList.cpp:209
GpgFrontend::UI::KeyList::SetDoubleClickedAction
void SetDoubleClickedAction(std::function< void(const GpgKey &, QWidget *)> action)
Set the Double Clicked Action object.
Definition: KeyList.cpp:403
GpgFrontend::UI::CommonUtils::SlotImportKeyFromKeyServer
void SlotImportKeyFromKeyServer(QWidget *parent)
Definition: UserInterfaceUtils.cpp:204
GpgFrontend::UI::KeyList
Definition: KeyList.h:152
GpgFrontend::UI::SignalStation::GetInstance
static SignalStation * GetInstance()
Get the Instance object.
Definition: SignalStation.cpp:37
GpgFrontend::UI::KeyList::SignalRefreshStatusBar
void SignalRefreshStatusBar(const QString &message, int timeout)
GpgFrontend::GpgKeyImportExporter::ImportKey
GpgImportInformation ImportKey(StdBypeArrayPtr inBuffer)
Definition: GpgKeyImportExporter.cpp:42
GpgFrontend::UI::KeyList::MarkKeys
static void MarkKeys(QStringList *keyIds)
Definition: KeyList.cpp:381
GpgFrontend::UI::KeyListColumn
Definition: KeyList.h:56
GpgFrontend::GpgKey::GetUIDs
std::unique_ptr< std::vector< GpgUID > > GetUIDs() const
Definition: GpgKey.cpp:161
GpgFrontend::GpgImportInformation
Definition: GpgKeyImportExporter.h:57
GpgFrontend::UI::KeyList::contextMenuEvent
void contextMenuEvent(QContextMenuEvent *event) override
Definition: KeyList.cpp:289
GpgFrontend::GpgKey
Definition: GpgKey.h:41
GpgFrontend::UI::SignalStation::SignalRefreshStatusBar
void SignalRefreshStatusBar(const QString &message, int timeout)