20#ifndef ORES_QT_PORTFOLIO_EXPLORER_TREE_MODEL_HPP
21#define ORES_QT_PORTFOLIO_EXPLORER_TREE_MODEL_HPP
26#include <unordered_map>
28#include <QAbstractItemModel>
29#include <boost/uuid/uuid.hpp>
30#include "ores.logging/make_logger.hpp"
31#include "ores.refdata.api/domain/portfolio.hpp"
32#include "ores.refdata.api/domain/book.hpp"
43 enum class Kind { Party, Portfolio, Book };
50 std::vector<std::unique_ptr<PortfolioTreeNode>> children;
51 int row_in_parent = 0;
58 std::optional<boost::uuids::uuid> book_id;
59 std::optional<boost::uuids::uuid> portfolio_id;
73 inline static std::string_view logger_name =
74 "ores.qt.portfolio_explorer_tree_model";
76 [[nodiscard]]
static auto& lg() {
78 static auto instance = make_logger(logger_name);
93 void load(
const QString& party_name,
94 std::vector<refdata::domain::portfolio> portfolios,
95 std::vector<refdata::domain::book> books);
113 void set_trade_count(
const boost::uuids::uuid& book_id, std::uint32_t count);
116 QModelIndex index(
int row,
int col,
117 const QModelIndex& parent = QModelIndex())
const override;
118 QModelIndex parent(
const QModelIndex& index)
const override;
119 int rowCount(
const QModelIndex& parent = QModelIndex())
const override;
120 int columnCount(
const QModelIndex& parent = QModelIndex())
const override;
121 QVariant data(
const QModelIndex& index,
int role = Qt::DisplayRole)
const override;
130 const std::vector<refdata::domain::portfolio>& portfolios,
131 const std::vector<refdata::domain::book>& books,
132 const std::optional<boost::uuids::uuid>& parent_id);
134 QModelIndex find_book_index(
const boost::uuids::uuid&
id)
const;
137 std::unique_ptr<PortfolioTreeNode> root_;
138 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
A single node in the portfolio/book tree.
Definition PortfolioExplorerTreeModel.hpp:42
Filter result from a tree node selection.
Definition PortfolioExplorerTreeModel.hpp:57
Tree model for the portfolio/book hierarchy.
Definition PortfolioExplorerTreeModel.hpp:69
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 PortfolioExplorerTreeModel.cpp:136
void load(const QString &party_name, std::vector< refdata::domain::portfolio > portfolios, std::vector< refdata::domain::book > books)
Rebuild the tree from raw portfolio and book data.
Definition PortfolioExplorerTreeModel.cpp:33
PortfolioTreeNode * node_from_index(const QModelIndex &index) const
Returns the node for a given index, or nullptr if invalid.
Definition PortfolioExplorerTreeModel.cpp:171
TreeNodeFilter selected_filter(const QModelIndex &index) const
Returns the filter for the selected index.
Definition PortfolioExplorerTreeModel.cpp:107
Operational ledger leaf that holds trades.
Definition book.hpp:37
Logical aggregation node for risk and reporting.
Definition portfolio.hpp:37