kexi
KexiTableEdit Class Reference
#include <kexitableedit.h>
Inheritance diagram for KexiTableEdit:

Detailed Description
Abstract class for a cell editor. Handles cell painting and displaying the editor widget.
Definition at line 39 of file kexitableedit.h.
Signals | |
void | editRequested () |
void | cancelRequested () |
void | acceptRequested () |
Public Member Functions | |
KexiTableEdit (KexiTableViewColumn &column, QWidget *parent=0) | |
virtual | ~KexiTableEdit () |
virtual KexiDB::Field * | field () const |
virtual KexiDB::QueryColumnInfo * | columnInfo () const |
virtual void | setColumnInfo (KexiDB::QueryColumnInfo *) |
KexiTableViewColumn * | column () const |
KexiDB::Field * | displayedField () const |
virtual void | resize (int w, int h) |
virtual QWidget * | widget () |
virtual void | hideWidget () |
virtual void | showWidget () |
virtual void | paintFocusBorders (QPainter *p, QVariant &cal, int x, int y, int w, int h) |
virtual void | setupContents (QPainter *p, bool focused, const QVariant &val, QString &txt, int &align, int &x, int &y_offset, int &w, int &h) |
bool | usesSelectedTextColor () const |
virtual void | paintSelectionBackground (QPainter *p, bool focused, const QString &txt, int align, int x, int y_offset, int w, int h, const QColor &fillColor, const QFontMetrics &fm, bool readOnly, bool fullRowSelection) |
int | leftMargin () const |
int | rightMargin (bool focused) const |
virtual bool | handleKeyPress (QKeyEvent *ke, bool editorActive) |
virtual bool | handleDoubleClick () |
virtual void | handleCopyAction (const QVariant &value, const QVariant &visibleValue)=0 |
virtual int | widthForValue (QVariant &val, const QFontMetrics &fm) |
virtual QSize | totalSize () |
virtual bool | showToolTipIfNeeded (const QVariant &value, const QRect &rect, const QFontMetrics &fm, bool focused) |
virtual void | createInternalEditor (KexiDB::QuerySchema &schema) |
Protected Member Functions | |
virtual bool | eventFilter (QObject *watched, QEvent *e) |
void | setViewWidget (QWidget *v) |
void | moveChild (QWidget *child, int x, int y) |
void | repaintRelatedCell () |
Protected Attributes | |
KexiTableViewColumn * | m_column |
int | m_leftMargin |
int | m_rightMargin |
int | m_rightMarginWhenFocused |
QScrollView * | m_scrollView |
bool | m_usesSelectedTextColor: 1 |
Member Function Documentation
virtual KexiDB::Field* KexiTableEdit::field | ( | ) | const [inline, virtual] |
Implemented for KexiDataItemInterface.
- Returns:
- field information for this item
Implements KexiDataItemInterface.
Reimplemented in KexiComboBoxTableEdit.
Definition at line 50 of file kexitableedit.h.
virtual KexiDB::QueryColumnInfo* KexiTableEdit::columnInfo | ( | ) | const [inline, virtual] |
A rich field information for db-aware data. For not-db-aware data it is always 0 (use field() instead.
Implements KexiDataItemInterface.
Definition at line 54 of file kexitableedit.h.
virtual void KexiTableEdit::setColumnInfo | ( | KexiDB::QueryColumnInfo * | ) | [inline, virtual] |
Implemented for KexiDataItemInterface.
Does nothing because instead KexiTableViewColumn is used to get field's schema.
Implements KexiDataItemInterface.
Definition at line 58 of file kexitableedit.h.
KexiTableViewColumn* KexiTableEdit::column | ( | ) | const [inline] |
- Returns:
- column information for this item (extended information, comparing to field()).
Reimplemented in KexiComboBoxTableEdit.
Definition at line 62 of file kexitableedit.h.
KexiDB::Field * KexiTableEdit::displayedField | ( | ) | const |
- Returns:
- displayed field. This is equal field() in typical case but can return a different field definition if the column contains a lookup field. This distiction is especially used for displaying dependent on the type and specifics of the field definition (e.g. text type versus integer type). Note that we're computing the editor's value, we still use field().
Definition at line 78 of file kexitableedit.cpp.
void KexiTableEdit::resize | ( | int | w, | |
int | h | |||
) | [virtual] |
Reimplemented: resizes a view().
Reimplemented in KexiBlobTableEdit, and KexiComboBoxTableEdit.
Definition at line 100 of file kexitableedit.cpp.
virtual QWidget* KexiTableEdit::widget | ( | ) | [inline, virtual] |
- Returns:
- the view widget of this editor, e.g. line edit widget.
Implements KexiDataItemInterface.
Definition at line 75 of file kexitableedit.h.
virtual void KexiTableEdit::hideWidget | ( | ) | [inline, virtual] |
Hides item's widget, if available.
Reimplemented from KexiDataItemInterface.
Definition at line 78 of file kexitableedit.h.
virtual void KexiTableEdit::showWidget | ( | ) | [inline, virtual] |
Shows item's widget, if available.
Reimplemented from KexiDataItemInterface.
Definition at line 81 of file kexitableedit.h.
void KexiTableEdit::paintFocusBorders | ( | QPainter * | p, | |
QVariant & | cal, | |||
int | x, | |||
int | y, | |||
int | w, | |||
int | h | |||
) | [virtual] |
Paints a border for the cell described by x, y, w, h on p painter. The cell's value is val (may be useful if you want to reimplement this method).
Reimplemented in KexiBlobTableEdit, and KexiComboBoxTableEdit.
Definition at line 143 of file kexitableedit.cpp.
void KexiTableEdit::setupContents | ( | QPainter * | p, | |
bool | focused, | |||
const QVariant & | val, | |||
QString & | txt, | |||
int & | align, | |||
int & | x, | |||
int & | y_offset, | |||
int & | w, | |||
int & | h | |||
) | [virtual] |
For reimplementation. Sets up and paints cell's contents using context of val value. focused is true if the cell is focused. align is set using Qt::AlignmentFlags. Some additional things may be painted using p, but it is not needed to paint the text (this is done automatically outside of this method).
Before calling, x, y_offset, w, h parameters are initialized, but you can tune these values depending on the context. You should set txt to a text representation of val, otherwise no text will be painted.
p can be 0 - in this case no painting should be performed, becasue caller only expects that x, y_offset, w, h, txt paramaters are tuned, if needed. p painter's pen is set to foreground color (usually black) that should be used to paint foreground information, if needed. For example boolean editor widget paints a rectangle using this color.
- Todo:
- ADD OPTION to displaying NULL VALUES as e.g. "(null)"
Reimplemented in KexiBlobTableEdit, KexiKIconTableEdit, KexiBoolTableEdit, KexiComboBoxTableEdit, KexiDateTableEdit, KexiDateTimeTableEdit, and KexiTimeTableEdit.
Definition at line 148 of file kexitableedit.cpp.
bool KexiTableEdit::usesSelectedTextColor | ( | ) | const [inline] |
- Returns:
- true if "selected text" color should be used to paint contents of the editor. True by default. It's false e.g. in boolean editor, where no selection is painted using paintSelectionBackground(). This flag is set in editor's constructor and checked in KexiTableView::paintCell(). Depending on it, appropriate ("text" or "selected text" color is set for painter) before setupContents() is called.
Definition at line 113 of file kexitableedit.h.
void KexiTableEdit::paintSelectionBackground | ( | QPainter * | p, | |
bool | focused, | |||
const QString & | txt, | |||
int | align, | |||
int | x, | |||
int | y_offset, | |||
int | w, | |||
int | h, | |||
const QColor & | fillColor, | |||
const QFontMetrics & | fm, | |||
bool | readOnly, | |||
bool | fullRowSelection | |||
) | [virtual] |
For reimplementation. Paints selection's background using p. Most parameters are similar to these from setupContents().
Definition at line 188 of file kexitableedit.cpp.
int KexiTableEdit::leftMargin | ( | ) | const [inline] |
Sometimes, editor can contain non-standard margin, for example combobox editor contains dropdown button at the right side.
- Returns:
- left margin's size; 0 by default. For reimplementation.
Definition at line 125 of file kexitableedit.h.
int KexiTableEdit::rightMargin | ( | bool | focused | ) | const |
Sometimes, editor can contain non-standard margin, for example combobox editor contains dropdown button at the right side. THe dropdown button's width is counted only if focused is true.
- Returns:
- right margin's size; 0 by default. For reimplementation.
Definition at line 232 of file kexitableedit.cpp.
virtual bool KexiTableEdit::handleKeyPress | ( | QKeyEvent * | ke, | |
bool | editorActive | |||
) | [inline, virtual] |
Handles ke key event that came over the column that is bound to this editor. For implementation: true should be returned if ke should be accepted. If editorActive is true, this editor is currently active, i.e. the table view is in edit mode. By default false is returned.
Reimplemented in KexiBlobTableEdit, and KexiComboBoxTableEdit.
Definition at line 136 of file kexitableedit.h.
virtual bool KexiTableEdit::handleDoubleClick | ( | ) | [inline, virtual] |
Handles double click request coming from the table view.
- Returns:
- true if it has been consumed. Reimplemented in KexiBlobTableEdit (to execute "insert file" action.
Reimplemented in KexiBlobTableEdit.
Definition at line 142 of file kexitableedit.h.
virtual void KexiTableEdit::handleCopyAction | ( | const QVariant & | value, | |
const QVariant & | visibleValue | |||
) | [pure virtual] |
Handles copy action for value. The value is copied to clipboard in format appropriate for the editor's impementation, e.g. for image cell it can be a pixmap. For a special case (combo box), visibleValue can be provided, so it can be copied to the clipboard instead of unreadable value. For reimplementation.
Implemented in KexiBlobTableEdit, KexiKIconTableEdit, KexiBoolTableEdit, KexiComboBoxTableEdit, KexiDateTableEdit, KexiDateTimeTableEdit, KexiInputTableEdit, and KexiTimeTableEdit.
int KexiTableEdit::widthForValue | ( | QVariant & | val, | |
const QFontMetrics & | fm | |||
) | [virtual] |
- Returns:
- width of value. For the default implementation val is converted to a string and width of this string is returned.
Reimplemented in KexiBoolTableEdit, and KexiComboBoxTableEdit.
Definition at line 211 of file kexitableedit.cpp.
virtual QSize KexiTableEdit::totalSize | ( | ) | [inline, virtual] |
- Returns:
- total size of this editor, including any buttons, etc. (if present). Reimpelment this if you want to return more appropriate size. This impelmentation just returns QWidget::size().
Reimplemented in KexiInputTableEdit.
Definition at line 158 of file kexitableedit.h.
bool KexiTableEdit::showToolTipIfNeeded | ( | const QVariant & | value, | |
const QRect & | rect, | |||
const QFontMetrics & | fm, | |||
bool | focused | |||
) | [virtual] |
Shows a special tooltip for value if needed, i.e. if the value could not fit inside rect for a given font metrics fm.
- Returns:
- true a normal tooltip should be displayed (using QToolTip,) and false if no tooltip should be displayed or a custom tooltip was displayed internally (not yet supported). Default implementation does nothing and returns false. If the cell is currentl focused (selected), focused is true.
Reimplemented in KexiInputTableEdit.
Definition at line 222 of file kexitableedit.cpp.
virtual void KexiTableEdit::createInternalEditor | ( | KexiDB::QuerySchema & | schema | ) | [inline, virtual] |
Created internal editor for this editor is needed. This method is only implemented in KexiComboBoxTableEdit since it's visible value differs from internal value, so a different KexiTableEdit object is used to displaying the data.
Reimplemented in KexiComboBoxTableEdit.
Definition at line 172 of file kexitableedit.h.
void KexiTableEdit::setViewWidget | ( | QWidget * | v | ) | [protected] |
Sets v as view widget for this editor. The view will be assigned as focus proxy for the editor, its events will be filtered, it will be resized when neede, and so on.
Definition at line 86 of file kexitableedit.cpp.
void KexiTableEdit::moveChild | ( | QWidget * | child, | |
int | x, | |||
int | y | |||
) | [protected] |
Moves child widget within the viewport if the parent is scrollview (otherwise does nothing). Use this for child widgets that are outside of this editor widget, instead of calling QWidget::move().
Definition at line 94 of file kexitableedit.cpp.
void KexiTableEdit::repaintRelatedCell | ( | ) | [protected] |
Allows to force redrawing the related cell by the editor itself. Usable when the editor is not displayed by a QWidget but rather by table view cell itself, for example KexiBlobTableEdit.
Definition at line 216 of file kexitableedit.cpp.
Member Data Documentation
QScrollView* KexiTableEdit::m_scrollView [protected] |
bool KexiTableEdit::m_usesSelectedTextColor [protected] |
The documentation for this class was generated from the following files: