#pragma once
#include <wx/dataview.h>
#include "LoggerLineData.h"

/**
* Column indices for the logger data-view control.
*
* @author Eddie O'Hagan
* @date 8/13/2026
*/
enum LoggerColumnID
{
	E_COL_ALERTICON = 0,		///< The alert-level icon column.
	E_COL_LOGTIME = 1,			///< The timestamp column.
	E_COL_ALERTLEVEL = 2,		///< The alert-level text column.
	E_COL_EVENTDESCRIPTION = 3	///< The event-description column.
};

/**
* A virtual list model backing the on-screen log's data-view control, holding the log lines and colouring rows by
* severity.
*
* @author Eddie O'Hagan
* @date 8/13/2026
*/
class LoggerListData : public wxDataViewVirtualListModel
{
protected:
	std::vector<LoggerLineData> myLoggerLineDatas;	///< The log lines backing the view, one per row.
	bool myHasWarnedAtCapacity;						///< Latches the one-time "log is now rolling off" warning (see AddToList).

public:
	/**
	* Builds an empty logger list model.
	*
	* @author Eddie O'Hagan
	* @date 8/13/2026
	*
	* @code
	*	LoggerListData model;
	* @endcode
	*/
	LoggerListData();

	/**
	* Defaulted destructor.
	*
	* @author Eddie O'Hagan
	* @date 8/13/2026
	*
	* @code
	*	LoggerListData* model = new LoggerListData();
	*	delete model;
	* @endcode
	*/
	virtual ~LoggerListData() = default;

	/**
	* Appends a log line to the model and notifies the view that a row was added.
	*
	* @author Eddie O'Hagan
	* @date 8/13/2026
	*
	* @code
	*	model.AddToList(logLine);
	* @endcode
	*
	* @param [in] dataToAdd The log line to append.
	*/
	virtual void AddToList(const LoggerLineData& dataToAdd);

	//Implementation of base class virtuals to define model
	/**
	* Supplies the value for a given row and column to the data-view control (icon, timestamp, level text, or
	* description).
	*
	* @author Eddie O'Hagan
	* @date 8/13/2026
	*
	* @code
	*	//Called by the wxDataViewCtrl as it renders each cell.
	* @endcode
	*
	* @param [out] variant The variant to fill with the cell's value.
	* @param [in]  row     The row index.
	* @param [in]  col     The column index (a LoggerColumnID).
	*/
	virtual void GetValueByRow(wxVariant& variant, unsigned int row, unsigned int col) const override;

	/**
	* Supplies a per-row display attribute, colouring alert rows red/bold and warning rows amber so the log is
	* scannable at a glance.
	*
	* @author Eddie O'Hagan
	* @date 8/13/2026
	*
	* @code
	*	//Called by the wxDataViewCtrl as it styles each row.
	* @endcode
	*
	* @param [in]  row  The row index.
	* @param [in]  col  The column index.
	* @param [out] attr The attribute to set for the row.
	*
	* @return True if a custom attribute was set (Alert/Warning), false to keep default styling (OK).
	*/
	virtual bool GetAttrByRow(unsigned int row, unsigned int col, wxDataViewItemAttr& attr) const override;

	/**
	* Rejects edits from the UI: the log is read-only from the view's perspective.
	*
	* @author Eddie O'Hagan
	* @date 8/13/2026
	*
	* @code
	*	//Called by the wxDataViewCtrl on an edit attempt; always refuses.
	* @endcode
	*
	* @param [in] variant The value the control tried to set.
	* @param [in] row     The row index.
	* @param [in] col     The column index.
	*
	* @return Always false (the log cannot be edited).
	*/
	virtual bool SetValueByRow(const wxVariant& variant, unsigned int row, unsigned int col) override;
};
