Archetype: cpp_qt_history_dialog.hpp.mustache

Table of Contents

History dialog declarations. Qt UI component: model/view class or dialog wired to the service layer via request/response messages.

See the Template variable reference for the complete list of available variables and their semantics.

Template

The full template source. Edit here and re-tangle with compass build --direct tangle_codegen_templates to regenerate library/templates/cpp_qt_history_dialog.hpp.mustache.

{{! GENERATED FILE — tangled from projects/ores.codegen/library/templates/cpp_qt.org. Edit the org source. }}
{{! Template to generate Qt history dialog header for domain entities }}
{{{cpp_license}}}
#ifndef ORES_QT_{{domain_entity.entity_upper}}_HISTORY_DIALOG_HPP
#define ORES_QT_{{domain_entity.entity_upper}}_HISTORY_DIALOG_HPP

#include "ores.qt/HistoryDialogBase.hpp"
{{#domain_entity.qt.has_uuid_primary_key}}
#include <boost/uuid/uuid.hpp>
{{/domain_entity.qt.has_uuid_primary_key}}
#include "ores.qt/ClientManager.hpp"
#include "ores.logging/make_logger.hpp"
#include "{{domain_entity.qt.domain_include}}"

namespace Ui {
class {{domain_entity.entity_pascal}}HistoryDialog;
}

namespace ores::qt {

/**
 * @brief Dialog for viewing the version history of a {{domain_entity.entity_singular_words}}.
 *
 * Shows all historical versions of a {{domain_entity.entity_singular_words}} with ability
 * to view details or revert to a previous version.
 */
class {{domain_entity.entity_pascal}}HistoryDialog final : public HistoryDialogBase {
    Q_OBJECT

private:
    inline static std::string_view logger_name =
        "ores.qt.{{domain_entity.entity_snake}}_history_dialog";

    [[nodiscard]] static auto& lg() {
        using namespace ores::logging;
        static auto instance = make_logger(logger_name);
        return instance;
    }

public:
{{#domain_entity.qt.has_uuid_primary_key}}
    explicit {{domain_entity.entity_pascal}}HistoryDialog(
        const boost::uuids::uuid& id,
        const QString& code,
        ClientManager* clientManager,
        QWidget* parent = nullptr);
{{/domain_entity.qt.has_uuid_primary_key}}
{{^domain_entity.qt.has_uuid_primary_key}}
    explicit {{domain_entity.entity_pascal}}HistoryDialog(
        const QString& code,
        ClientManager* clientManager,
        QWidget* parent = nullptr);
{{/domain_entity.qt.has_uuid_primary_key}}
    ~{{domain_entity.entity_pascal}}HistoryDialog() override;

    void loadHistory() override;
    [[nodiscard]] QString code() const override;

signals:
    void openVersionRequested(const {{domain_entity.qt.domain_class}}& {{domain_entity.qt.item_var}},
                              int versionNumber);
    void revertVersionRequested(const {{domain_entity.qt.domain_class}}& {{domain_entity.qt.item_var}});

protected:
    [[nodiscard]] int historySize() const override;
    [[nodiscard]] VersionRow versionRow(int index) const override;
    [[nodiscard]] QString historyTitle() const override;
    [[nodiscard]] DiffResult calculateDiffAt(int ci, int pi) const override;
    void displayFullDetails(int index) override;
    void openVersionAt(int index) override;
    void revertToVersionAt(int index) override;

private:
    Ui::{{domain_entity.entity_pascal}}HistoryDialog* ui_;
{{#domain_entity.qt.has_uuid_primary_key}}
    boost::uuids::uuid id_;
{{/domain_entity.qt.has_uuid_primary_key}}
    QString code_;
    ClientManager* clientManager_;
    std::vector<{{domain_entity.qt.domain_class}}> versions_;
};

}

#endif

See also

Emacs 29.1 (Org mode 9.6.6)