Spreadsheet.h header

#include <ew/core/Spreadsheet.h>

Namespace ew::core

Spreadsheet class

class ew::core::Spreadsheet

A spreadsheet content object: a titled grid of cells. Storage is sparse – only non-empty cells (and only non-default cell formats) are kept – while the visible grid size is given by the row and column counts. Cell text is stored verbatim (literals and formulas alike); formula evaluation lives elsewhere.

Members

ew::core::Spreadsheet::Spreadsheet(ContentId id, QString title)

Creates an empty spreadsheet with identity id and title (default grid size).

const QString & ew::core::Spreadsheet::title() const

The spreadsheet title.

void ew::core::Spreadsheet::setTitle(QString title)

Sets the spreadsheet title.

int ew::core::Spreadsheet::rowCount() const

The number of visible rows.

void ew::core::Spreadsheet::setRowCount(int rowCount)

Sets the number of visible rows.

int ew::core::Spreadsheet::columnCount() const

The number of visible columns.

void ew::core::Spreadsheet::setColumnCount(int columnCount)

Sets the number of visible columns.

QString ew::core::Spreadsheet::cell(int row, int column) const

The raw text of the cell at (row, column), or an empty string if unset.

void ew::core::Spreadsheet::setCell(int row, int column, QString text)

Sets the cell at (row, column) to text, replacing any existing content; an empty text clears (removes) the cell.

const std::vector< SpreadsheetCell > & ew::core::Spreadsheet::cells() const

The non-empty cells, in insertion order.

void ew::core::Spreadsheet::setCells(std::vector< SpreadsheetCell > cells)

Replaces the entire set of cells at once (used for bulk edits such as paste, CSV import, and refreshing a bound data table). Empty-text cells are dropped.

CellFormat ew::core::Spreadsheet::cellFormat(int row, int column) const

The formatting of the cell at (row, column), or a default (empty) CellFormat when the cell has no formatting.

void ew::core::Spreadsheet::setCellFormat(int row, int column, CellFormat format)

Sets the formatting of the cell at (row, column), replacing any existing format; a default (empty) format clears (removes) the cell's format entry.

const std::vector< SpreadsheetCellFormat > & ew::core::Spreadsheet::cellFormats() const

The non-default cell formats, in insertion order.

void ew::core::Spreadsheet::setCellFormats(std::vector< SpreadsheetCellFormat > formats)

Replaces the entire set of cell formats at once (used for bulk edits such as structural row/column inserts and deletes). Default-format entries are dropped.

int ew::core::Spreadsheet::columnWidth(int column) const

The custom pixel width of column, or 0 when it uses the view's default width.

void ew::core::Spreadsheet::setColumnWidth(int column, int width)

Sets the custom pixel width of column; a width of 0 or less clears it (default width).

int ew::core::Spreadsheet::rowHeight(int row) const

The custom pixel height of row, or 0 when it uses the view's default height.

void ew::core::Spreadsheet::setRowHeight(int row, int height)

Sets the custom pixel height of row; a height of 0 or less clears it (default height).

const std::map< int, int > & ew::core::Spreadsheet::columnWidths() const

The custom column widths, keyed by zero-based column index (only columns with a custom width appear).

void ew::core::Spreadsheet::setColumnWidths(std::map< int, int > widths)

Sets the custom column widths, keyed by zero-based column index.

const std::map< int, int > & ew::core::Spreadsheet::rowHeights() const

The custom row heights, keyed by zero-based row index (only rows with a custom height appear).

void ew::core::Spreadsheet::setRowHeights(std::map< int, int > heights)

Sets the custom row heights, keyed by zero-based row index.

CategoryId ew::core::Spreadsheet::linkedCategoryId() const

The taxonomy category this sheet is a data table for, or a null id when the sheet is freeform. When set, the sheet's first row is a header of the category's field names and each later row is one entity; this lets the sheet be refreshed from, and pushed back to, the codex.

void ew::core::Spreadsheet::setLinkedCategoryId(CategoryId linkedCategoryId)

Sets the taxonomy category this sheet is a data table for (a null id means freeform).

SpreadsheetCell struct

struct ew::core::SpreadsheetCell

One populated cell of a spreadsheet: its zero-based row and column and its raw text. The text is either a literal value ("42", "Hello") or a formula beginning with '=' ("=A1+B2"); evaluation happens in a higher layer, so the model stores exactly what the user typed.

Members

int ew::core::SpreadsheetCell::row = 0

The zero-based row.

int ew::core::SpreadsheetCell::column = 0

The zero-based column.

QString ew::core::SpreadsheetCell::text

The raw cell text.

SpreadsheetCellFormat struct

struct ew::core::SpreadsheetCellFormat

The visual formatting applied to one cell: its zero-based row and column and the format. Held sparsely and independently of cell text, so a formatted-but-empty cell and an unformatted cell with text both cost only what they use.

Members

int ew::core::SpreadsheetCellFormat::row = 0

The zero-based row.

int ew::core::SpreadsheetCellFormat::column = 0

The zero-based column.

CellFormat ew::core::SpreadsheetCellFormat::format

The cell's formatting.