Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Related Pages   Examples  

QdbtTableCell Class Reference
[Cell implementations]

The QdbtTableCell class represents a cell in a QdbtTabular object. More...

#include <qdbttabcell.h>

Inheritance diagram for QdbtTableCell:

Inheritance graph
[legend]
Collaboration diagram for QdbtTableCell:

Collaboration graph
[legend]
List of all members.

Public Types

enum  BorderType { LeftBorder = 0x0001, RightBorder = 0x0002, TopBorder = 0x0004, BottomBorder = 0x0008 }

Public Methods

 QdbtTableCell ()
 QdbtTableCell (const QdbtTableCell &)
 QdbtTableCell (QString text, const QPixmap *pixmap, const QColor &color=QColor(), int align=Qt::AlignLeft, bool edit=FALSE)
virtual ~QdbtTableCell ()
virtual void setText (QString text)
virtual QString text () const
void setPixmap (const QPixmap *pixmap)
const QPixmap & pixmap () const
virtual void setColor (const QColor &color)
virtual const QColor & color (QdbtBaseTabular *) const
virtual void setBackground (const QColor &color)
virtual const QColor & background (QdbtBaseTabular *) const
void setAlignment (int alignment)
int alignment () const
void setPixmapAlignment (int alignment)
int pixmapAlignment () const
virtual int widthHint (const QFontMetrics &fm) const
virtual int heightHint (const QFontMetrics &fm) const
int borderMode ()
void setBorderMode (int borderStyle)
virtual void setEditable (bool state)
bool isEditable () const
virtual void paintFocus (QPainter *p, QdbtBaseTabular *t, const QRect &r, bool selected, bool editing=FALSE)
void rightButtonClicked (QdbtBaseTabular *tab, int row, int col) const

Protected Methods

virtual QWidget * editor (QdbtBaseTabular *) const
virtual void paint (QPainter *p, QdbtBaseTabular *t, const QRect &r, bool selected, bool editing=FALSE)
virtual QRect getTextArea () const
virtual QRect getEditArea (int width) const
virtual QdbtBaseCell * clone (QdbtBaseTabular *) const
virtual bool beginEdit (QdbtBaseTabular *, int row, int col, const QRect cellGeometry) const
virtual bool acceptEdit (QdbtBaseTabular *, int row, int col)
virtual bool cancelEdit (QdbtBaseTabular *, int row, int col)
virtual bool mouseEvent (QdbtBaseTabular *, int row, int col, QMouseEvent *e, const QRect cellGeometry)
virtual bool keyEvent (QdbtBaseTabular *, int row, int col, QKeyEvent *e, const QRect cellGeometry)
virtual void setEditorEnabled (QdbtBaseTabular *, bool) const
virtual void moveEditor (QdbtBaseTabular *, const QRect cellGeometry) const
bool aboutToBeEdited (QdbtBaseTabular *) const
void notifyOnEditResult (QdbtBaseTabular *tab, int row, int col, int result, QString oldText)
QFont font (QdbtBaseTabular *) const
bool prepareEditor (QdbtBaseTabular *tab, const QRect &geom) const
bool cleanupEditor (QdbtBaseTabular *tab) const

Static Protected Attributes

int MASK_EDITABLE = 0x0001
int MASK_SELECTABLE = 0x0002
int MASK_SELECTED = 0x0004
int bw = 4

Detailed Description

The QdbtTableCell class represents a cell in a QdbtTabular object.

This class represents a cell of a QdbtTabular. A cell consists of a text (default the empty string) and a pixmap (default the null Pixmap).

The cell itself is not aware of its width and height, but can compute its preferred size given the font metrics that are used for the text.

The alignment of the pixmap with respect to the text can be controlled using setPixmapAlignment(). The alignment of the cell as a whole can be controlled using setAlignment().

Suppose you have QdbtTabular table widget called tabular. To change some properties of the cell at location (row,\e col) in this table use the following code:

  // create a local copy of the cell
  QdbtTableCell cell(*tabular->cell(row,col));

  // change some properties of the cell

  .
  .
  .

  // update the cell at (row,col) in the table
  tabular->changeCell(&cell,row,col);
Examples:

example1.cpp, example2.cpp, example3.cpp, example4.cpp, and example5.cpp.


Member Enumeration Documentation

enum QdbtTableCell::BorderType
 

Enum type for the possible border lines to be drawn

Enumeration values:
LeftBorder  A border line shall be drawn on the left side of the cell
RightBorder  A border line shall be drawn on the right side of the cell
TopBorder  A border line shall be drawn at the top of the cell
BottomBorder  A border line shall be drawn at the bottom of the cell


Constructor & Destructor Documentation

QdbtTableCell::QdbtTableCell (    ) 
 

Constructs a cell with the following properties:

  • The cell has an empty text string.
  • The cell has a null pixmap.
  • The color of the text is not set (thus using the Foreground-Color or HilightedText of the Tabular's palette)
  • The background of the cell is not set (thus unding the Base-Color or Hilight of the Tabular's palette)
  • The cell's text is not editable.
  • The cell is not selected.
  • The cell is selectable.
  • The pixmap is aligned to the left of the text.
  • The pixmap-text pair is aligned to the left.

QdbtTableCell::QdbtTableCell (  const QdbtTableCell &    orig ) 
 

This constructor copy the supplied cell

QdbtTableCell::QdbtTableCell (  QString    t,
const QPixmap *    p,
const QColor &    c = QColor(),
int    a = Qt::AlignLeft,
bool    e = FALSE
) 
 

Constructs a cell with the following properties:

  • The cell has a text string t. Use a null pointer to define no text.
  • The cell's pixmap is set to p. Use a null pointer to define no pixmap.
  • The color is set to c.
  • The background of the cell has the same color as the background of the table.
  • The ability to edit a cell is set to e.
  • The cell is not selected.
  • The cell is selectable.
  • The pixmap is aligned to the left of the text.
  • The pixmap-text pair is aligned according to the value of a. Possible values are AlignLeft, AlignRight and AlignCenter.

QdbtTableCell::~QdbtTableCell (    )  [virtual]
 

Destroys the cell


Member Function Documentation

bool QdbtBaseCell::aboutToBeEdited (  QdbtBaseTabular *    tab )  const [protected, inherited]
 

This function interacts with the table and clarifies, if a new editing session may be started. If this function returns FALSE, no edit session may be started currently.

See also:
beginEdit()

bool QdbtTableCell::acceptEdit (  QdbtBaseTabular *    tab,
int    row,
int    col
)  [protected, virtual]
 

After editing has been done (and e.g. Return/Enter has been pressed), this function evaluates if the modified cell content is acceptable (when a pattern for the cell's column has been set, this pattern is being matched) and notifies the user on the edit's outcome.

This function retreives the current value from the editor and stores it within the table's cell (if accepted)

Reimplemented from QdbtBaseCell.

int QdbtTableCell::alignment (    )  const [inline]
 

Returns the alignment of the text-pixmap pair.

See also:
alignment().

const QColor & QdbtTableCell::background (  QdbtBaseTabular *    tab )  const [virtual]
 

Returns the background color of the cell.

See also:
setBackground().

Reimplemented from QdbtBaseCell.

bool QdbtTableCell::beginEdit (  QdbtBaseTabular *    tab,
int    row,
int    col,
const QRect    cellGeometry
)  const [protected, virtual]
 

Begin a new edit session. For this purpose a line editor is being initialized and show at the place, that is being occupied by the table's cells at row, col with the geometry cellGeometry

Reimplemented from QdbtBaseCell.

int QdbtTableCell::borderMode (    ) 
 

Function orthogonal to setBorderMode(). The mode of the cureent cell's border is or'ed together from the base border modes.

bool QdbtTableCell::cancelEdit (  QdbtBaseTabular *    tab,
int    row,
int    col
)  [protected, virtual]
 

If an edit-session has to be canceled for any reason, the table will use this function to ask for cancellation of an edit-session. The edit-session should then be canceled if possible.

When cancelEdit() returns TRUE, the tabular expects that the cell editor has been reset and made invisible again before this function returns.

See also:
acceptEdit()

Reimplemented from QdbtBaseCell.

bool QdbtBaseCell::cleanupEditor (  QdbtBaseTabular *    tab )  const [protected, inherited]
 

This member cleans up a cell's editor and ensures that the editor is not visible any longer.

Parameters:
tab  The tabular, to which the cell belongs
Returns:
TRUE if the editor has been cleaned up correctly, FALSE otherwise. If this function returns FALSE, it has not take any actions.
Attention:
This function relies on the editor()-function to answer the correct cell editor widget.
See also:
prepareEditor()

QdbtBaseCell * QdbtTableCell::clone (  QdbtBaseTabular *    )  const [protected, virtual]
 

This abstract method is being used to produce a new instance with exactly the same internal state as the original object was. If is being used whenever a copy of a cell has to be produced, e.g. when changing cells within the tabular widget's table matrix.

For initializing the new cell properly, the context of the cell (the tabular widget, that it is located in) is being transfered to the clone() function.

Warning:
This function is virtually used as a virtual constructor. Please refer to the Prototype paragraph from Erich Gamma et. al, 'Design Patterns, Elements of Reusable Object-Oriented Software', Addison-Wesley, 1995 (a book definitely worth its price)

Implements QdbtBaseCell.

const QColor & QdbtTableCell::color (  QdbtBaseTabular *    tab )  const [virtual]
 

Returns the color of the cell's text.

See also:
setColor().

Reimplemented from QdbtBaseCell.

QWidget * QdbtTableCell::editor (  QdbtBaseTabular *    tab )  const [protected, virtual]
 

This functions serves to determine the editor widget associated to a table cell. This function should be provided within a derived class, since the function determining if a tabular contains the keyboard focus relies on it. However it is safe to return 0, if no editor may be returned or even is only produced on demand.

Reimplemented from QdbtBaseCell.

QFont QdbtBaseCell::font (  QdbtBaseTabular *    tab )  const [protected, inherited]
 

Read the font, that has been set for the QdbtTabular Widget. This font should be used for all text-editor facilities.

Parameters:
tab  The context (tabular), with which the cell is used

QRect QdbtTableCell::getEditArea (  int    width )  const [protected, virtual]
 

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QdbtBaseCell.

QRect QdbtTableCell::getTextArea (    )  const [protected, virtual]
 

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QdbtBaseCell.

int QdbtTableCell::heightHint (  const QFontMetrics &    fm )  const [virtual]
 

Returns the preferred height of the cell. This is not the actual cell height, but the height that is required to fit both text and pixmap in the cell.

See also:
widthHint().

Reimplemented from QdbtBaseCell.

bool QdbtBaseCell::isEditable (    )  const [inherited]
 

Returns TRUE if the cell may be edited by the user.

See also:
setEditable().

bool QdbtBaseCell::keyEvent (  QdbtBaseTabular *   ,
int    row,
int    col,
QKeyEvent *    e,
const QRect    cellGeometry
)  [protected, virtual, inherited]
 

This method is used to inform a table cell about a key press event. The cell receives its coordinates with the table's matrix as row, col, all information on the key pressed e as well as its current geometry cellGeometry in the coordinate system of the table's cell matrix.

If this method returns FALSE, the table will apply the normal 'keyboard' rules (cursor keys traverse the focus, etc). If the method returns TRUE, the table components assume, that anything necessary has already been taken care of.

Reimplemented in QdbtComboCell.

bool QdbtBaseCell::mouseEvent (  QdbtBaseTabular *   ,
int    row,
int    col,
QMouseEvent *    e,
const QRect    cellGeometry
)  [protected, virtual, inherited]
 

This method is used to inform a table cell about a mouse press event. The cell receives its coordinates with the table's matrix as row, col, the coordinates of the mouse click relative to the table's cell matrix as e as well as its current geometry cellGeometry in the coordinate system of the table's cell matrix.

If this method returns FALSE, the table will apply the normal 'editing' rules (center mousebutton will edit the cell). If the method returns TRUE, the table components assume, that anything necessary has already been taken care of.

Reimplemented in QdbtComboCell.

void QdbtBaseCell::moveEditor (  QdbtBaseTabular *    tab,
const QRect    geom
)  const [protected, virtual, inherited]
 

This method is called whenever a table cell is being edited and the table is repainted. The method should check if the geometry of handed over is the same as the geometry applied to the editor widget and - if not - should resize or move the editor widget to the correct position.

The default implementation determines the editor widget by calling editor() and moves it to the correct location.

void QdbtBaseCell::notifyOnEditResult (  QdbtBaseTabular *    tab,
int    row,
int    col,
int    result,
QString    oldText
)  [protected, inherited]
 

This function interacts with the tabular components and may be used to communicate the result of an edit session to the remaining programm parts.

void QdbtTableCell::paint (  QPainter *    p,
QdbtBaseTabular *    t,
const QRect &    r,
bool    selected,
bool    editing = FALSE
)  [protected, virtual]
 

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QdbtBaseCell.

void QdbtBaseCell::paintFocus (  QPainter *    p,
QdbtBaseTabular *    t,
const QRect &    r,
bool    selected,
bool    editing = FALSE
)  [virtual, inherited]
 

This function is called whenever the cell's focus needs to be repainted. The width of the cell is w and the height is h is passed. To be able to interact with the tabular widget (e.g. for style support) that paints this cell, a pointer to it is passed to this function. The painter p automatically clips against the area of the cell.

Reimplemented in QdbtComboCell, and QdbtBorderlessComboCell.

const QPixmap & QdbtTableCell::pixmap (    )  const [inline]
 

Returns the pixmap of the cell.

See also:
setPixmap().

int QdbtTableCell::pixmapAlignment (    )  const [inline]
 

Returns the align of the pixmap with respect to the text. Possible values are: AlignLeft, AlignRight, AlignTop, AlignBottom.

See also:
setPixmapAlignment().

bool QdbtBaseCell::prepareEditor (  QdbtBaseTabular *    tab,
const QRect &    geom
)  const [protected, inherited]
 

Prepare the cell's editor for the about-to-be-started edit session.

Parameters:
tab  The tabular, to which this cell belongs
geom  The cell (and thus the editor's) geometry
Returns:
TRUE, if the editor has been configured appropriately, FALSE otherwise. If this function returns FALSE, it has not take any actions.
Attention:
This function relies on the editor()-function to anser the correct cell editor widget.
See also:
cleanupEditor()

void QdbtBaseCell::rightButtonClicked (  QdbtBaseTabular *    tab,
int    row,
int    col
)  const [inherited]
 

This functions informs the user, that the right mouse buttons has been pressed on top of the cell in row row and col col. This method should be used within each of the editor widgets mapped on top of the table components, for the 'normal' cells this signal is begin generated automatically.

void QdbtTableCell::setAlignment (  int    alignment )  [inline]
 

Set the alignment of the text-pixmap pair. Possible values are:

  • AlignLeft: The pixmap and text are aligned to the left.
  • AlignCenter: The pixmap and text are centered.
  • AlignRight: The pixmap and text are aligned to the right.
See also:
alignment().
Examples:
example1.cpp, example2.cpp, example4.cpp, and example5.cpp.

void QdbtTableCell::setBackground (  const QColor &    color )  [inline, virtual]
 

Sets the color of the background of the cell.

If an invalid color is supplied (the default), then the background color of the table will be used.

See also:
background().
Examples:
example2.cpp, and example4.cpp.

void QdbtTableCell::setBorderMode (  int    borderStyle ) 
 

Sets the mode, in which cell borders are drawn. They may be composed (or'ed) out of the following components:

  • LeftBorder: Draw a vertical line on the left side of the cell
  • RightBorder: Draw a vertical line on the right side of the cell
  • TopBorder: Draw a horizontal line on the top side of the cell
  • BottomBorder: Draw a horizontal line on the bottom side of the cell
Examples:
example5.cpp.

void QdbtTableCell::setColor (  const QColor &    color )  [inline, virtual]
 

Sets the color of the text to color.

See also:
color().
Examples:
example1.cpp, and example2.cpp.

void QdbtBaseCell::setEditable (  bool    state )  [virtual, inherited]
 

Sets whether or not the cell may be edited by the application user.

If state is TRUE the cell may be edited.

If state is FALSE the cell may not be edited.

See also:
isEditable().
Examples:
example1.cpp, example3.cpp, example4.cpp, and example5.cpp.

void QdbtBaseCell::setEditorEnabled (  QdbtBaseTabular *    tab,
bool    enable
)  const [protected, virtual, inherited]
 

This function serves to temporaryly disable/enable the editor widget, if there is any.

The default implementation determines the editor widget by calling editor() and disables or enables it according to enable.

void QdbtTableCell::setPixmap (  const QPixmap *    pixmap )  [inline]
 

Set the pixmap of the cell to pixmap.

See also:
pixmap().
Examples:
example1.cpp, and example4.cpp.

void QdbtTableCell::setPixmapAlignment (  int    alignment )  [inline]
 

Sets the alignment of the pixmap with respect to the text. Possible values are:

  • AlignLeft: The pixmap is displayed to the left of the text.
  • AlignRight: The pixmap is displayed to the right of the text.
  • AlignTop: The pixmap is displayed above the text.
  • AlignBottom: The pixmap is displayed below the text.
See also:
pixmapAlignment().
Examples:
example1.cpp, and example4.cpp.

void QdbtTableCell::setText (  QString    text )  [inline, virtual]
 

Set the text of the cell to text.

See also:
text().
Examples:
example1.cpp, example2.cpp, example3.cpp, example4.cpp, and example5.cpp.

QString QdbtTableCell::text (    )  const [inline, virtual]
 

Returns the text string of the cell.

See also:
setText().

Reimplemented from QdbtBaseCell.

int QdbtTableCell::widthHint (  const QFontMetrics &    fm )  const [virtual]
 

Returns the preferred width of the cell. This is not the actual cell width, but the width that is required to fit both text and pixmap in the cell.

See also:
heightHint().

Reimplemented from QdbtBaseCell.


Member Data Documentation

QdbtBaseCell::bw = 4 [static, protected, inherited]
 

Default spacing value for tabular cells.


The documentation for this class was generated from the following files:
Generated on Mon Apr 22 12:22:02 2002 for QdbtTabular by doxygen1.2.15-20020421