20#ifndef ORES_QT_ORG_EXPLORER_TREE_MODEL_HPP
21#define ORES_QT_ORG_EXPLORER_TREE_MODEL_HPP
27#include <unordered_map>
29#include <QAbstractItemModel>
30#include <boost/uuid/uuid.hpp>
31#include "ores.logging/make_logger.hpp"
32#include "ores.refdata.api/domain/business_unit.hpp"
33#include "ores.refdata.api/domain/book.hpp"
44 std::optional<boost::uuids::uuid> book_id;
45 std::optional<boost::uuids::uuid> business_unit_id;
57 enum class Kind { Party, BusinessUnit, Book };
64 std::vector<std::unique_ptr<OrgTreeNode>> children;
65 int row_in_parent = 0;
81 inline static std::string_view logger_name =
82 "ores.qt.org_explorer_tree_model";
84 [[nodiscard]]
static auto& lg() {
86 static auto instance = make_logger(logger_name);
101 void load(
const QString& party_name,
102 std::vector<refdata::domain::business_unit> units,
103 std::vector<refdata::domain::book> books);
120 void set_trade_count(
const boost::uuids::uuid& book_id, std::uint32_t count);
128 QModelIndex index(
int row,
int col,
129 const QModelIndex& parent = QModelIndex())
const override;
130 QModelIndex parent(
const QModelIndex& index)
const override;
131 int rowCount(
const QModelIndex& parent = QModelIndex())
const override;
132 int columnCount(
const QModelIndex& parent = QModelIndex())
const override;
133 QVariant data(
const QModelIndex& index,
int role = Qt::DisplayRole)
const override;
137 const std::vector<refdata::domain::business_unit>& units,
138 const std::vector<refdata::domain::book>& books,
139 const std::optional<boost::uuids::uuid>& parent_unit_id);
141 QModelIndex find_book_index(
const boost::uuids::uuid&
id)
const;
142 std::uint32_t subtree_count(
const OrgTreeNode* node)
const;
144 std::unique_ptr<OrgTreeNode> root_;
145 std::unordered_map<std::string, std::uint32_t> trade_counts_;
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:29
Filter result from a tree node selection.
Definition OrgExplorerTreeModel.hpp:43
A single node in the organisational hierarchy tree.
Definition OrgExplorerTreeModel.hpp:56
Tree model for the organisational hierarchy.
Definition OrgExplorerTreeModel.hpp:77
void set_trade_count(const boost::uuids::uuid &book_id, std::uint32_t count)
Update the trade count for a book and refresh its display.
Definition OrgExplorerTreeModel.cpp:172
OrgTreeNodeFilter selected_filter(const QModelIndex &index) const
Returns the filter for the selected index.
Definition OrgExplorerTreeModel.cpp:134
OrgTreeNode * node_from_index(const QModelIndex &index) const
Returns the node for a given index, or nullptr if invalid.
Definition OrgExplorerTreeModel.cpp:206
void load(const QString &party_name, std::vector< refdata::domain::business_unit > units, std::vector< refdata::domain::book > books)
Rebuild the tree from raw business unit and book data.
Definition OrgExplorerTreeModel.cpp:33
Operational ledger leaf that holds trades.
Definition book.hpp:37
Internal organizational unit within a party.
Definition business_unit.hpp:37