#include <qdbtbasecell.h>
Inheritance diagram for QdbtBaseCell:
Public Methods | |
virtual | ~QdbtBaseCell () |
virtual QdbtBaseCell * | clone (QdbtBaseTabular *) const=0 |
virtual int | widthHint (const QFontMetrics &fm) const |
virtual int | heightHint (const QFontMetrics &fm) const |
virtual const QColor & | color (QdbtBaseTabular *) const |
virtual const QColor & | background (QdbtBaseTabular *) const |
virtual QString | text () const |
virtual void | setEditable (bool state) |
bool | isEditable () const |
virtual void | paint (QPainter *p, QdbtBaseTabular *t, const QRect &r, bool selected, bool editing=FALSE) |
virtual void | paintFocus (QPainter *p, QdbtBaseTabular *t, const QRect &r, bool selected, bool editing=FALSE) |
virtual QRect | getTextArea () const |
virtual QRect | getEditArea (int width) const |
void | rightButtonClicked (QdbtBaseTabular *tab, int row, int col) const |
Protected Methods | |
QdbtBaseCell () | |
virtual QWidget * | editor (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 |
Friends | |
class | QdbtTable |
class | QdbtEditorBase |
This class layouts the interface between the tabular widgets and its cells.
When interacting with a cell (e.g. modifying its properties), the clone()-method may be used. You might use code like to following to retreive a cell from a QdbtBaseTabular widget called tabular:
// create a local copy of the cell QdbtBaseCell *cell = tabular->cell( row, col )->clone(); // change some properties of the cell . . . QdbtIntCell *intCell = dynamic_cast<QdbtIntCell*>(cell); if ( intCell ) { intCell->setValue( intCell->value()+1 ); } . . . // update the cell at (row,col) in the table tabular->changeCell( cell, row, col ); delete cell;
For backward compatibility, the API of QdbtTabular/QdbtTableCell provide a different way to interact with cell. Please not, that due to subclassing no plain copy-contructor may be used to reproduce an object. This the clone()-method is used to leave reproduction of cells to the cells itself.
Since cloning resolves in allocating a new object of the cell's type, this object has to be deleted if it is not used any more.
|
The virtual destructur frees all data, the cell allocated. |
|
The constructor creates an empty cell. For handling the context (might be necessary for interacting with the singleton class that can store editor widget instances), the pointer of the tabualr widget is being passed. |
|
This function interacts with the table and clarifies, if a new editing session may be started. If this function returns
|
|
If a cell is currently being edited and for any reason, another cells is supposed to be transfered into editing mode, the table triggers this function to make a cell accept its changes. If, for any reason, the content of the cell is not acceptable and the cell returns
When acceptEdit() returns
Reimplemented in QdbtComboCell, QdbtIntCell, QdbtTableCell, QdbtTextCell, and QdbtValidatingCell. |
|
This function computes the background color for a table's cell. This color is generated from the table-component's forground color, if it is existing. If not (e.g. if the pointer to the tabular tab is not supplied correctly), a default color or white is supplied. Reimplemented in QdbtTableCell. |
|
This function is called by the table to put a single cell into editing mode. The cells is expected to return
When beginEdit() returns
Reimplemented in QdbtComboCell, QdbtIntCell, QdbtTableCell, QdbtTextCell, and QdbtValidatingCell. |
|
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
Reimplemented in QdbtComboCell, QdbtIntCell, QdbtTableCell, QdbtTextCell, and QdbtValidatingCell. |
|
This member cleans up a cell's editor and ensures that the editor is not visible any longer.
|
|
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.
Implemented in QdbtNoCell, QdbtComboCell, QdbtBorderlessComboCell, QdbtIntCell, QdbtTableCell, QdbtTextCell, and QdbtValidatingCell. |
|
This function computes the forground color for a table's cell. This color is generated from the table-component's forground color, if it is existing. If not (e.g. if the pointer to the tabular tab is not supplied correctly), a default color or black is supplied. Reimplemented in QdbtTableCell. |
|
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 in QdbtComboCell, QdbtIntCell, QdbtTableCell, QdbtTextCell, and QdbtValidatingCell. |
|
Read the font, that has been set for the QdbtTabular Widget. This font should be used for all text-editor facilities.
|
|
Returns the area inside the cell, where the edit focus may be placed. The coordinates of the rectangle are in pixels and relative to the cell. The top left of the cell has coordinates (0,0). Reimplemented in QdbtComboCell, QdbtIntCell, QdbtTableCell, QdbtTextCell, and QdbtValidatingCell. |
|
Returns the area inside the cell, where the text is being drawn. The coordinates of the rectangle are in pixels and relative to the cell. The top left of the cell has coordinates (0,0). Reimplemented in QdbtComboCell, QdbtIntCell, QdbtTableCell, QdbtTextCell, and QdbtValidatingCell. |
|
Compute the height for a cell, based on the assumption that the line contains just one textline. This function involved the static member QdbtBaseCell::bw . Reimplemented in QdbtComboCell, QdbtBorderlessComboCell, QdbtIntCell, QdbtTableCell, QdbtTextCell, and QdbtValidatingCell. |
|
Returns
|
|
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 Reimplemented in QdbtComboCell. |
|
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 Reimplemented in QdbtComboCell. |
|
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. |
|
This function interacts with the tabular components and may be used to communicate the result of an edit session to the remaining programm parts. |
|
This function is called whenever the cell 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. The boolean selected indicates if the cell is selected. The boolean editing indicates if the cell is currently being edited. Reimplemented in QdbtNoCell, QdbtComboCell, QdbtBorderlessComboCell, QdbtIntCell, QdbtTableCell, QdbtTextCell, and QdbtValidatingCell. |
|
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. |
|
Prepare the cell's editor for the about-to-be-started edit session.
|
|
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. |
|
Sets whether or not the cell may be edited by the application user.
If state is
If state is
|
|
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. |
|
Function to generate the text, which is being displayed within the cell. Reimplemented in QdbtNoCell, QdbtComboCell, QdbtIntCell, QdbtTableCell, QdbtTextCell, and QdbtValidatingCell. |
|
Compute a width for the cell, so that the text fits in. The texte is queried using the virtual function text(). This function involved the static member QdbtBaseCell::bw . Reimplemented in QdbtComboCell, QdbtIntCell, QdbtTableCell, QdbtTextCell, and QdbtValidatingCell. |
|
This friend declaration allows the table widget instance to interact with the cells through the protected API components. |
|
Default spacing value for tabular cells. |