64 inline static std::string_view logger_name =
65 "ores.qt.portfolio_explorer_mdi_window";
67 [[nodiscard]]
static auto& lg() {
69 static auto instance = make_logger(logger_name);
74 static constexpr const char* book_event =
"ores.refdata.book_changed";
75 static constexpr const char* portfolio_event =
"ores.refdata.portfolio_changed";
76 static constexpr const char* trade_event =
"ores.trading.trade_changed";
85 const QString& username,
86 QWidget* parent =
nullptr);
98 void statusChanged(
const QString& msg);
102 return tr(
"Refresh portfolio/book tree");
106 void onTreeSelectionChanged(
const QItemSelection& selected,
107 const QItemSelection& deselected);
108 void onNotificationReceived(
const QString& eventType,
109 const QDateTime& timestamp,
110 const QStringList& entityIds,
111 const QString& tenantId);
112 void onPortfoliosLoaded();
113 void onBooksLoaded();
114 void onCounterpartiesLoaded();
115 void onAddRequested();
116 void onEditSelected();
117 void onDeleteSelected();
118 void onHistorySelected();
119 void onShowContextMenu(
const QPoint& pos);
120 void onTradeDoubleClicked(
const QModelIndex& index);
121 void updateActionStates();
124 bool eventFilter(QObject* obj, QEvent* event)
override;
128 void setupTradePanel();
129 void setupConnections();
130 void setupEventSubscriptions();
133 void collectBookUuids(
const QModelIndex& parent,
134 QList<boost::uuids::uuid>& uuids);
136 const boost::uuids::uuid& newParentId);
139 struct PortfolioFetchResult {
141 std::vector<refdata::domain::portfolio> portfolios;
142 QString error_message;
143 QString error_details;
146 struct BookFetchResult {
148 std::vector<refdata::domain::book> books;
149 QString error_message;
150 QString error_details;
153 struct CounterpartyFetchResult {
155 std::unordered_map<std::string, CounterpartyInfo> cpty_map;
156 QString error_message;
157 QString error_details;
161 boost::uuids::uuid book_id;
162 std::uint32_t count{0};
164 QString error_message;
165 QString error_details;
168 ClientManager* clientManager_;
172 BookController* bookController_{
nullptr};
173 OreImportController* oreImportController_{
nullptr};
174 PortfolioController* portfolioController_{
nullptr};
175 TradeController* tradeController_{
nullptr};
178 QToolBar* toolbar_{
nullptr};
179 QAction* reloadAction_{
nullptr};
182 QAction* addAction_{
nullptr};
183 QAction* editAction_{
nullptr};
184 QAction* deleteAction_{
nullptr};
185 QAction* historyAction_{
nullptr};
186 QAction* importAction_{
nullptr};
188 QSplitter* splitter_{
nullptr};
191 QTreeView* treeView_{
nullptr};
192 PortfolioExplorerTreeModel* treeModel_{
nullptr};
195 QWidget* breadcrumbBar_{
nullptr};
196 QTableView* tradeTableView_{
nullptr};
197 PortfolioExplorerTradeModel* tradeModel_{
nullptr};
198 QSortFilterProxyModel* tradeProxyModel_{
nullptr};
199 PaginationWidget* paginationWidget_{
nullptr};
202 QFutureWatcher<PortfolioFetchResult>* portfolioWatcher_{
nullptr};
203 QFutureWatcher<BookFetchResult>* bookWatcher_{
nullptr};
204 QFutureWatcher<CounterpartyFetchResult>* counterpartyWatcher_{
nullptr};
205 QList<QFutureWatcher<CountResult>*> countWatchers_;
208 std::vector<refdata::domain::portfolio> portfolios_;
209 std::vector<refdata::domain::book> books_;
210 bool portfolios_loaded_{
false};
211 bool books_loaded_{
false};
214 QPoint dragStartPos_;
215 QModelIndex dragSourceIndex_;