SpreadsheetModel.h header
#include <ew/app/SpreadsheetModel.h>
Namespace ew::app
SpreadsheetModel class
class ew::app::SpreadsheetModel
Editable table model over one Spreadsheet content object. DisplayRole shows each cell's evaluated value formatted by the cell's number format (formulas computed via the spreadsheet evaluator); EditRole exposes the raw cell text so a formula can be edited; TextAlignmentRole gives the cell's alignment (numbers default to right-aligned). CellFormatRole exposes the whole ew::core::CellFormat so a UI-layer delegate can apply font and colour attributes (kept out of this UI-agnostic model). Setting a cell pushes an undoable SetSpreadsheetCellCommand and re-queries the whole grid (a change can affect dependent cells). Headers show A1-style column letters and 1-based row numbers.
Members
int ew::app::SpreadsheetModel::CellFormatRole = Qt::UserRole + 1
Item-data role returning the cell's ew::core::CellFormat (via QVariant::fromValue), for a presentation-layer delegate to render font and colours without this model depending on the Qt GUI module.
ew::app::SpreadsheetModel::SpreadsheetModel(QObject *parent=nullptr)
Constructs an empty model with parent parent; set a source with setSource.
void ew::app::SpreadsheetModel::setSource(Workspace *workspace, ew::core::ContentId spreadsheetId)
Points the model at workspace's spreadsheet spreadsheetId (not owned) and resets it.
void ew::app::SpreadsheetModel::refresh()
Re-reads the spreadsheet and resets the model.
int ew::app::SpreadsheetModel::rowCount(const QModelIndex &parent=QModelIndex()) const override
Returns the spreadsheet's row count under parent (QAbstractTableModel).
int ew::app::SpreadsheetModel::columnCount(const QModelIndex &parent=QModelIndex()) const override
Returns the spreadsheet's column count under parent (QAbstractTableModel).
QVariant ew::app::SpreadsheetModel::data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Returns the cell data for index and role (QAbstractTableModel; see class doc).
bool ew::app::SpreadsheetModel::setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
Sets cell index to value via an undoable command (QAbstractTableModel).
QVariant ew::app::SpreadsheetModel::headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Returns the A1 column letter or 1-based row number for section (QAbstractTableModel).
Qt::ItemFlags ew::app::SpreadsheetModel::flags(const QModelIndex &index) const override
Returns the item flags for index (editable cells; QAbstractTableModel).