Archetype: cpp_qt_detail_dialog.hpp.mustache
Detail 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_detail_dialog.hpp.mustache.
{{! GENERATED FILE — tangled from projects/ores.codegen/library/templates/cpp_qt.org. Edit the org source. }}
{{! Template to generate Qt detail dialog header for domain entities }}
{{{cpp_license}}}
#ifndef ORES_QT_{{domain_entity.entity_upper}}_DETAIL_DIALOG_HPP
#define ORES_QT_{{domain_entity.entity_upper}}_DETAIL_DIALOG_HPP
#include <vector>
#include "ores.qt/ClientManager.hpp"
#include "ores.qt/DetailDialogBase.hpp"
#include "ores.logging/make_logger.hpp"
#include "{{domain_entity.qt.domain_include}}"
{{#domain_entity.qt.detail_fields}}{{#is_dynamic_combo}}
#include "{{combo_include}}"
{{/is_dynamic_combo}}{{/domain_entity.qt.detail_fields}}
namespace Ui {
class {{domain_entity.entity_pascal}}DetailDialog;
}
namespace ores::qt {
/**
* @brief Detail dialog for viewing and editing {{domain_entity.entity_singular_words}} records.
*
* This dialog allows viewing, creating, and editing {{domain_entity.entity_plural_words}}.
* It supports both create mode (for new records) and edit mode (for
* existing records).
*/
class {{domain_entity.entity_pascal}}DetailDialog final : public DetailDialogBase {
Q_OBJECT
private:
inline static std::string_view logger_name =
"ores.qt.{{domain_entity.entity_snake}}_detail_dialog";
[[nodiscard]] static auto& lg() {
using namespace ores::logging;
static auto instance = make_logger(logger_name);
return instance;
}
public:
explicit {{domain_entity.entity_pascal}}DetailDialog(QWidget* parent = nullptr);
~{{domain_entity.entity_pascal}}DetailDialog() override;
void setClientManager(ClientManager* clientManager);
void setUsername(const std::string& username);
void set{{domain_entity.entity_pascal_short}}(const {{domain_entity.qt.domain_class}}& {{domain_entity.qt.item_var}});
void setCreateMode(bool createMode);
void setReadOnly(bool readOnly);
{{#domain_entity.qt.detail_fields}}{{#is_dynamic_combo}}
void {{combo_setter}}(const std::vector<{{combo_type}}>& items);
{{/is_dynamic_combo}}{{/domain_entity.qt.detail_fields}}
signals:
void {{domain_entity.qt.item_var}}Saved(const QString& code);
void {{domain_entity.qt.item_var}}Deleted(const QString& code);
private slots:
void onSaveClicked();
void onDeleteClicked();
void onCodeChanged(const QString& text);
void onFieldChanged();
protected:
QTabWidget* tabWidget() const override;
QWidget* provenanceTab() const override;
ProvenanceWidget* provenanceWidget() const override;
bool hasUnsavedChanges() const override { return hasChanges_; }
private:
void setupUi();
void setupConnections();
{{#domain_entity.qt.has_combo_fields}}
void setupCombos();
{{/domain_entity.qt.has_combo_fields}}
void updateUiFrom{{domain_entity.entity_pascal_short}}();
void update{{domain_entity.entity_pascal_short}}FromUi();
void updateSaveButtonState();
bool validateInput();
{{#domain_entity.qt.detail_fields}}{{#is_dynamic_combo}}
void populate{{combo_setter_pascal}}();
{{/is_dynamic_combo}}{{/domain_entity.qt.detail_fields}}
Ui::{{domain_entity.entity_pascal}}DetailDialog* ui_;
ClientManager* clientManager_;
std::string username_;
{{domain_entity.qt.domain_class}} {{domain_entity.qt.item_var}}_;
bool createMode_{true};
bool readOnly_{false};
bool hasChanges_{false};
{{#domain_entity.qt.detail_fields}}{{#is_dynamic_combo}}
std::vector<{{combo_type}}> {{combo_items_member}}_;
{{/is_dynamic_combo}}{{/domain_entity.qt.detail_fields}}
};
}
#endif
See also
- Parent facet: C++ Qt templates
- Template variable reference