/** * Copyright (C) 2021-2024 Saturneric * * This file is part of GpgFrontend. * * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GpgFrontend is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GpgFrontend. If not, see . * * The initial version of the source code is inherited from * the gpg4usb project, which is under GPL-3.0-or-later. * * All the source code of GpgFrontend was modified and released by * Saturneric starting on May 12, 2021. * * SPDX-License-Identifier: GPL-3.0-or-later * */ #pragma once #include "core/model/GpgKey.h" #include "core/model/GpgKeyTableModel.h" #include "ui/model/GpgKeyTableProxyModel.h" namespace GpgFrontend::UI { /** * @brief * */ struct KeyTable : public QTableView { Q_OBJECT public: using KeyTableFilter = std::function; /** * @brief Construct a new Key Table object * * @param _key_list * @param _select_type * @param _info_type * @param _filter */ KeyTable( QWidget* parent, QSharedPointer model, GpgKeyTableDisplayMode _select_type, GpgKeyTableColumn _info_type, GpgKeyTableProxyModel::KeyFilter _filter = [](const GpgKey&) -> bool { return true; }); /** * @brief * * @param model */ void RefreshModel(QSharedPointer model); /** * @brief Get the Checked object * * @return KeyIdArgsListPtr& */ [[nodiscard]] auto GetChecked() const -> KeyIdArgsList; /** * @brief * */ void UncheckALL() const; /** * @brief * */ void CheckALL() const; /** * @brief * */ void SetFilterKeyword(const QString& keyword); /** * @brief * * @param row * @return true * @return false */ [[nodiscard]] auto IsRowChecked(int row) const -> bool; /** * @brief Set the Row Checked object * * @param row */ void SetRowChecked(int row) const; /** * @brief Set the Row Checked object * * @param row */ [[nodiscard]] auto GetRowSelected() const -> int; /** * @brief Get the Row Count object * * @return auto */ [[nodiscard]] auto GetRowCount() const -> int; /** * @brief Get the Key Id By Row object * * @param row * @return QString */ [[nodiscard]] auto GetKeyIdByRow(int row) const -> QString; /** * @brief * * @param row * @return true * @return false */ [[nodiscard]] auto IsPublicKeyByRow(int row) const -> bool; /** * @brief * * @param row * @return true * @return false */ [[nodiscard]] auto IsPrivateKeyByRow(int row) const -> bool; /** * @brief * */ void CheckAll(); /** * @brief * */ void UncheckAll(); signals: /** * @brief * */ void SignalColumnTypeChange(GpgKeyTableColumn); /** * @brief * */ void SignalGpgContextChannelChange(int); private: QSharedPointer model_; GpgKeyTableProxyModel proxy_model_; GpgKeyTableColumn column_filter_; }; } // namespace GpgFrontend::UI