Quark  0.1
Matrix< T > Class Template Reference

A matrix data model. More...

#include <Matrix.h++>

Public Member Functions

 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...
 
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...
 

Protected Member Functions

virtual bool isEmptyValue (const T &value) const
 Tests if a given item is to be considered "empty". More...
 

Detailed Description

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
TThe type of the objects contained in this model.
Author
Mark Lindner

Constructor & Destructor Documentation

◆ Matrix()

Matrix ( int  width = 0,
int  height = 0 
)

Constructs a matrix with the given dimensions.

Parameters
widthThe width of the matrix, in columns.
heightThe height of the matrix, in rows.

◆ ~Matrix()

~Matrix ( )

Destructor.

Member Function Documentation

◆ columns()

int columns ( ) const

Returns the width of the matrix, in columns.

◆ deleteColumns()

void deleteColumns ( int  columnIndex,
int  columnCount 
)

Deletes columns from the matrix.

Parameters
columnIndexThe column index at which to delete columns.
columnCountThe number of columns to delete.

◆ deleteRows()

void deleteRows ( int  rowIndex,
int  rowCount 
)

Deletes rows from the matrix.

Parameters
rowIndexThe row index at which to delete rows.
rowCountThe 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
widthThe width of the region, in columns.
heightThe height of the region, in rows.
Thecoordinates 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
rowThe row.
columnThe column.
Returns
The item.

◆ insertColumns()

void insertColumns ( int  columnIndex,
int  columnCount 
)

Inserts new columns into the matrix.

Parameters
columnIndexThe column index at which to insert the columns.
columnCountThe number of columns to insert.

◆ insertRows()

void insertRows ( int  rowIndex,
int  rowCount 
)

Inserts new rows into the matrix.

Parameters
rowIndexThe row index at which to insert the rows.
rowCountThe number of rows to insert.

◆ isEmpty()

bool isEmpty ( ) const
inline

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
rowThe topmost row of the region.
columnThe leftmost column of the region.
widthThe width of the region, in columns.
heightThe 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
streamThe stream to read from.
Returns
true on success, false on failure.

◆ rows()

int rows ( ) const

Returns the height of the matrix, in rows.

◆ setItemAt()

void setItemAt ( int  row,
int  column,
item 
)

Sets the item at the given row and column.

Parameters
rowThe row.
columnThe column.
itemThe 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
streamThe stream to write to.

The documentation for this class was generated from the following file: