ores.cpp.qt.mdi_window_header
MDI window 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_mdi_window.hpp.mustache.
{{! GENERATED FILE — tangled from projects/ores.codegen/library/templates/cpp_qt.org. Edit the org source. }}
{{! Template to generate Qt MDI window header for domain entities }}
{{{cpp_license}}}
#ifndef ORES_QT_{{domain_entity.entity_upper}}_MDI_WINDOW_HPP
#define ORES_QT_{{domain_entity.entity_upper}}_MDI_WINDOW_HPP
#include <QToolBar>
#include <QTableView>
#include <QSortFilterProxyModel>
#include "ores.qt/EntityListMdiWindow.hpp"
#include "ores.qt/ClientManager.hpp"
#include "ores.qt/Client{{domain_entity.entity_pascal}}Model.hpp"
#include "ores.qt/PaginationWidget.hpp"
#include "ores.logging/make_logger.hpp"
#include "{{domain_entity.qt.domain_include}}"
{{#domain_entity.qt.has_setting_gated_actions}}
#include "ores.qt/SettingGatedActionController.hpp"
{{/domain_entity.qt.has_setting_gated_actions}}
{{#domain_entity.qt.has_csv_xml_io}}
#include "{{domain_entity.qt.csv_export_include}}"
#include "{{domain_entity.qt.xml_export_include}}"
#include "{{domain_entity.qt.xml_import_include}}"
{{/domain_entity.qt.has_csv_xml_io}}
namespace ores::qt {
{{#domain_entity.qt.has_badge_columns}}
class BadgeCache;
{{/domain_entity.qt.has_badge_columns}}
{{#domain_entity.qt.needs_image_cache}}
class ImageCache;
{{/domain_entity.qt.needs_image_cache}}
/**
* @brief MDI window for displaying and managing {{domain_entity.entity_plural_words}}.
*
* Provides a table view of {{domain_entity.entity_plural_words}} with toolbar actions
* for reload, add, edit, delete, and viewing history.
*/
class {{domain_entity.entity_pascal}}MdiWindow final : public EntityListMdiWindow {
Q_OBJECT
private:
inline static std::string_view logger_name =
"ores.qt.{{domain_entity.entity_snake}}_mdi_window";
[[nodiscard]] static auto& lg() {
using namespace ores::logging;
static auto instance = make_logger(logger_name);
return instance;
}
public:
explicit {{domain_entity.entity_pascal}}MdiWindow(
ClientManager* clientManager,
const QString& username,
{{#domain_entity.qt.has_badge_columns}}
BadgeCache* badgeCache,
{{/domain_entity.qt.has_badge_columns}}
{{#domain_entity.qt.needs_image_cache}}
ImageCache* imageCache,
{{/domain_entity.qt.needs_image_cache}}
{{#domain_entity.qt.has_parent_scoped_list}}
const QString& {{domain_entity.qt.parent_key_param}},
{{/domain_entity.qt.has_parent_scoped_list}}
QWidget* parent = nullptr);
~{{domain_entity.entity_pascal}}MdiWindow() override = default;
signals:
void statusChanged(const QString& message);
void errorOccurred(const QString& error_message);
{{^domain_entity.qt.has_readonly_paginated_list}}
void show{{domain_entity.entity_pascal_short}}Details(const {{domain_entity.qt.domain_class}}& {{domain_entity.qt.item_var}});
void addNewRequested();
void {{domain_entity.qt.item_var}}Deleted(const QString& code);
void show{{domain_entity.entity_pascal_short}}History(const {{domain_entity.qt.domain_class}}& {{domain_entity.qt.item_var}});
{{/domain_entity.qt.has_readonly_paginated_list}}
{{#domain_entity.qt.has_related_entity_shortcuts}}
/**
* @brief Emitted to request opening a related entity's own list window
* (e.g. a lookup entity backing one of this entity's combo fields).
* Relayed by the controller and wired to the target's controller in the
* plugin's composition root.
*/
{{#domain_entity.qt.related_entity_shortcuts}}
void show{{signal}}Requested();
{{/domain_entity.qt.related_entity_shortcuts}}
{{/domain_entity.qt.has_related_entity_shortcuts}}
// Extra signal declarations seam: a future
// :implements 67D24D2F-2D98-49EB-9A1D-32F1D8BFA76A block is expected
// to declare any entity-specific signals (e.g. a cross-navigation
// request to a related entity's list window) — see
// paste_blocks_in_codegen.org. Left empty when no entity implements
// this kind.
<<paste:67D24D2F-2D98-49EB-9A1D-32F1D8BFA76A>>
public slots:
{{^domain_entity.qt.has_readonly_paginated_list}}
void addNew();
void editSelected();
void deleteSelected();
void viewHistorySelected();
{{/domain_entity.qt.has_readonly_paginated_list}}
{{#domain_entity.qt.has_csv_xml_io}}
void exportToCSV();
void exportToXML();
void importFromXML();
{{/domain_entity.qt.has_csv_xml_io}}
protected:
void doReload() override;
private slots:
void onDataLoaded();
void onLoadError(const QString& error_message, const QString& details = {});
void onSelectionChanged();
void onDoubleClicked(const QModelIndex& index);
protected:
QString normalRefreshTooltip() const override {
return tr("Refresh {{domain_entity.entity_plural_words}}");
}
private:
void setupUi();
void setupToolbar();
void setupTable();
void setupConnections();
{{^domain_entity.qt.has_readonly_paginated_list}}
void updateActionStates();
{{/domain_entity.qt.has_readonly_paginated_list}}
ClientManager* clientManager_;
QString username_;
{{#domain_entity.qt.has_parent_scoped_list}}
QString {{domain_entity.qt.parent_key_param}}_;
{{/domain_entity.qt.has_parent_scoped_list}}
{{#domain_entity.qt.has_badge_columns}}
BadgeCache* badgeCache_;
{{/domain_entity.qt.has_badge_columns}}
{{#domain_entity.qt.needs_image_cache}}
ImageCache* imageCache_;
{{/domain_entity.qt.needs_image_cache}}
QToolBar* toolbar_;
QTableView* tableView_;
Client{{domain_entity.entity_pascal}}Model* model_;
QSortFilterProxyModel* proxyModel_;
PaginationWidget* paginationWidget_;
// Toolbar actions
QAction* reloadAction_;
{{^domain_entity.qt.has_readonly_paginated_list}}
QAction* addAction_;
QAction* editAction_;
QAction* deleteAction_;
{{/domain_entity.qt.has_readonly_paginated_list}}
{{#domain_entity.qt.has_csv_xml_io}}
QAction* importXMLAction_;
QAction* exportCSVAction_;
QAction* exportXMLAction_;
{{/domain_entity.qt.has_csv_xml_io}}
{{^domain_entity.qt.has_readonly_paginated_list}}
QAction* historyAction_;
{{/domain_entity.qt.has_readonly_paginated_list}}
{{#domain_entity.qt.has_setting_gated_actions}}
{{#domain_entity.qt.setting_gated_actions}}
QAction* {{action}}_;
{{/domain_entity.qt.setting_gated_actions}}
SettingGatedActionController* settingGatedActions_;
{{/domain_entity.qt.has_setting_gated_actions}}
};
}
#endif
See also
- Parent facet: ores.cpp.qt
- Template variable reference