FinceptTerminal is a modern finance application offering advanced market analytics, investment research, and economic data tools, designed for interactive exploration and data-driven decision-making in a user-friendly environment.
C++ ai-agentsalgorithmic-tradingbloomberg-terminalcppfinancefinancial-marketsfintechgood-first-issueinvestmentinvestment-researchmachine-learningopensourcepythonqtquantitative-financestock-markettrading
#pragma once
#include "core/report/ReportDocument.h"
#include <QScrollArea>
#include <QTextEdit>
#include <QVBoxLayout>
#include <QWidget>
namespace fincept::screens {
// Re-export the canonical types under the screens namespace so existing
// implementation code (which qualifies them as fincept::screens::Report*)
// keeps compiling unchanged.
using ReportComponent = ::fincept::report::ReportComponent;
using ReportMetadata = ::fincept::report::ReportMetadata;
using ReportTheme = ::fincept::report::ReportTheme;
/// Center panel — paginated A4 document canvas.
/// Each page is a separate QTextEdit with visible gap between pages,
/// matching Word/LibreOffice-style document layout.
/// Supports drag-and-drop of image files directly onto the canvas.
class DocumentCanvas : public QWidget {
Q_OBJECT
public:
explicit DocumentCanvas(QWidget* parent = nullptr);
void render(const QVector<ReportComponent>& components, const ReportMetadata& metadata, const ReportTheme& theme,
int selected_index);
/// Returns the last (current) page editor. NOT the whole report: every
/// page_break component starts a new editor, so this is only the content after
/// the last break. Use page_documents() for export/print.
QTextEdit* text_edit() const { return pages_.isEmpty() ? nullptr : pages_.last(); }
/// The documents of every page, in order — what PDF export and print preview
/// must paint to cover the whole report.
QVector<QTextDocument*> page_documents() const;
signals:
void image_dropped(const QString& file_path);
protected:
void dragEnterEvent(QDragEnterEvent* e) override;
void dragMoveEvent(QDragMoveEvent* e) override;
void dropEvent(QDropEvent* e) override;
private:
QScrollArea* scroll_ = nullptr;
QWidget* container_ = nullptr;
QVBoxLayout* pages_layout_ = nullptr;
QVector<QTextEdit*> pages_;
QTextEdit* new_page(const ReportTheme& theme);
void clear_pages();
};
} // namespace fincept::screens