A matrix data model.
More...
#include <Matrix.h++>
|
| | Matrix (int width=0, int height=0) |
| | Constructs a matrix with the given dimensions. More...
|
| |
| | ~Matrix () |
| | Destructor. More...
|
| |
| int | rows () const |
| | Returns the height of the matrix, in rows. More...
|
| |
| int | columns () const |
| | Returns the width of the matrix, in columns. More...
|
| |
| bool | isEmpty () const |
| | Tests if the matrix is empty. More...
|
| |
| void | setItemAt (int row, int column, T item) |
| | Sets the item at the given row and column. More...
|
| |
| T | getItemAt (int row, int column) const |
| | Returns the item at the given row and column. More...
|
| |
| void | insertRows (int rowIndex, int rowCount) |
| | Inserts new rows into the matrix. More...
|
| |
| void | deleteRows (int rowIndex, int rowCount) |
| | Deletes rows from the matrix. More...
|
| |
| void | insertColumns (int columnIndex, int columnCount) |
| | Inserts new columns into the matrix. More...
|
| |
| void | deleteColumns (int columnIndex, int columnCount) |
| | Deletes columns from the matrix. More...
|
| |
| bool | isRegionEmpty (int row, int column, int width, int height) const |
| | Tests if the given region in the matrix contains only "empty" items. More...
|
| |
| QPoint | findEmptyRegion (int width, int height) const |
| | Attempts to locate a rectangular region with the given dimensions in the matrix such that all cells in the region contain "empty" items. More...
|
| |
| bool | read (QDataStream &stream) |
| | Reads the matrix from a data stream. More...
|
| |
| void | write (QDataStream &stream) const |
| | Writes the matrix to a data stream. More...
|
| |
|
| virtual bool | isEmptyValue (const T &value) const |
| | Tests if a given item is to be considered "empty". More...
|
| |
template<typename T>
class quark::gui::Matrix< T >
A matrix data model.
A matrix is a two-dimensional grid of items, where some items can be considered "empty."
- Template Parameters
-
| T | The type of the objects contained in this model. |
- Author
- Mark Lindner
◆ Matrix()
| Matrix |
( |
int |
width = 0, |
|
|
int |
height = 0 |
|
) |
| |
Constructs a matrix with the given dimensions.
- Parameters
-
| width | The width of the matrix, in columns. |
| height | The height of the matrix, in rows. |
◆ ~Matrix()
◆ columns()
Returns the width of the matrix, in columns.
◆ deleteColumns()
| void deleteColumns |
( |
int |
columnIndex, |
|
|
int |
columnCount |
|
) |
| |
Deletes columns from the matrix.
- Parameters
-
| columnIndex | The column index at which to delete columns. |
| columnCount | The number of columns to delete. |
◆ deleteRows()
| void deleteRows |
( |
int |
rowIndex, |
|
|
int |
rowCount |
|
) |
| |
Deletes rows from the matrix.
- Parameters
-
| rowIndex | The row index at which to delete rows. |
| rowCount | The number of rows to delete. |
◆ findEmptyRegion()
| QPoint findEmptyRegion |
( |
int |
width, |
|
|
int |
height |
|
) |
| const |
Attempts to locate a rectangular region with the given dimensions in the matrix such that all cells in the region contain "empty" items.
- Parameters
-
| width | The width of the region, in columns. |
| height | The height of the region, in rows. |
| The | coordinates of the upper-left corner of the empty region, if found, or (-1, -1) if no such region could be found. |
◆ getItemAt()
| T getItemAt |
( |
int |
row, |
|
|
int |
column |
|
) |
| const |
Returns the item at the given row and column.
- Parameters
-
| row | The row. |
| column | The column. |
- Returns
- The item.
◆ insertColumns()
| void insertColumns |
( |
int |
columnIndex, |
|
|
int |
columnCount |
|
) |
| |
Inserts new columns into the matrix.
- Parameters
-
| columnIndex | The column index at which to insert the columns. |
| columnCount | The number of columns to insert. |
◆ insertRows()
| void insertRows |
( |
int |
rowIndex, |
|
|
int |
rowCount |
|
) |
| |
Inserts new rows into the matrix.
- Parameters
-
| rowIndex | The row index at which to insert the rows. |
| rowCount | The number of rows to insert. |
◆ isEmpty()
Tests if the matrix is empty.
◆ isEmptyValue()
| virtual bool isEmptyValue |
( |
const T & |
value | ) |
const |
|
protectedvirtual |
Tests if a given item is to be considered "empty".
◆ isRegionEmpty()
| bool isRegionEmpty |
( |
int |
row, |
|
|
int |
column, |
|
|
int |
width, |
|
|
int |
height |
|
) |
| const |
Tests if the given region in the matrix contains only "empty" items.
- Parameters
-
| row | The topmost row of the region. |
| column | The leftmost column of the region. |
| width | The width of the region, in columns. |
| height | The height of the region, in rows. |
- Returns
- true if the region contains only "empty" items, false otherwise.
◆ read()
| bool read |
( |
QDataStream & |
stream | ) |
|
Reads the matrix from a data stream.
Items are read using the left-shift operator of QDataStream.
- Parameters
-
| stream | The stream to read from. |
- Returns
- true on success, false on failure.
◆ rows()
Returns the height of the matrix, in rows.
◆ setItemAt()
| void setItemAt |
( |
int |
row, |
|
|
int |
column, |
|
|
T |
item |
|
) |
| |
Sets the item at the given row and column.
- Parameters
-
| row | The row. |
| column | The column. |
| item | The item. |
◆ write()
| void write |
( |
QDataStream & |
stream | ) |
const |
Writes the matrix to a data stream.
Items are written using the right-shift operator of QDataStream.
- Parameters
-
| stream | The stream to write to. |
The documentation for this class was generated from the following file: