Kexi API Documentation (2.0 alpha)

KexiComboBoxBase Class Reference

#include <kexicomboboxbase.h>

Inheritance diagram for KexiComboBoxBase:

KexiComboBoxTableEdit KexiDBComboBox List of all members.

Detailed Description

A base class for handling data-aware combo boxes. This class is used by KexiComboBoxTableEdit and KexiDBComboBox.

Definition at line 37 of file kexicomboboxbase.h.

Public Member Functions

 KexiComboBoxBase ()
virtual ~KexiComboBoxBase ()
virtual KexiTableViewColumncolumn () const =0
virtual KexiDB::Fieldfield () const =0
virtual QVariant origValue () const =0
virtual QVariant value ()
 Note: Generally in current implementation this is integer > 0; may be null if no value is set.
virtual QVariant visibleValue ()
virtual void clear ()
 Reimplement this and call this impl.: used to clear internal editor.
virtual tristate valueChangedInternal ()
virtual bool valueIsNull ()
virtual bool valueIsEmpty ()
virtual void hide ()
void createPopup (bool show)
void showPopup ()
virtual void slotRowAccepted (KexiTableItem *item, int row)
 Call this from slot.
virtual void slotItemSelected (KexiTableItem *)
 Call this from slot.
void slotInternalEditorValueChanged (const QVariant &v)
 Call this from slot.
virtual QWidgetinternalEditor () const =0
 Implement this to return the internal editor.

Protected Member Functions

virtual void setValueInternal (const QVariant &add, bool removeOld)
KexiTableItemselectItemForEnteredValueInLookupTable (const QVariant &v)
 Used to select row item for an user-entered value v.
QString valueForString (const QString &str, int *row, uint lookInColumn, uint returnFromColumn, bool allowNulls=false)
void setValueOrTextInInternalEditor (const QVariant &value)
 sets value for the line edit without setting a flag (m_userEnteredValue) that indicates that the text has been entered by hand (by a user)
KexiDB::LookupFieldSchemalookupFieldSchema () const
int rowToHighlightForLookupTable () const
virtual void moveCursorToEndInInternalEditor ()=0
 Implement this to perform "move cursor to end" in the internal editor.
virtual void selectAllInInternalEditor ()=0
 Implement this to perform "select all" in the internal editor.
virtual void setValueInInternalEditor (const QVariant &value)=0
 Implement this to perform "set value" in the internal editor.
virtual QVariant valueFromInternalEditor ()=0
 Implement this to return value from the internal editor.
virtual void editRequested ()=0
 Implement this as signal.
virtual void acceptRequested ()=0
 Implement this as signal.
virtual QPoint mapFromParentToGlobal (const QPoint &pos) const =0
 Implement this to return a position pos mapped from parent (e.g.
virtual int popupWidthHint () const =0
 Implement this to return a hint for popup width.
virtual void updateButton ()
 Implement this to update button state.
virtual KexiComboBoxPopuppopup () const =0
virtual void setPopup (KexiComboBoxPopup *popup)=0
virtual QVariant visibleValueForLookupField ()
void updateTextForHighlightedRow ()
bool handleKeyPressForPopup (QKeyEvent *ke)
void acceptPopupSelection ()
void undoChanges ()
 Used by KexiDBComboBox.

Protected Attributes

QVariant m_visibleValue
QVariant m_userEnteredValue
 value (usually a text) entered by hand (by the user)
bool m_internalEditorValueChanged: 1
 true if user has text or other value inside editor
bool m_slotInternalEditorValueChanged_enabled: 1
 Used in slotInternalEditorValueChanged().
bool m_setValueOrTextInInternalEditor_enabled: 1
 Used in setValueOrTextInInternalEditor() and slotItemSelected().
bool m_mouseBtnPressedWhenPopupVisible: 1
 Used only by KexiComboBoxTableEdit.
bool m_insideCreatePopup: 1
 true if we're inside createPopup(); used in slotItemSelected()
bool m_updatePopupSelectionOnShow: 1
 Set to false as soon as the item corresponding with the current value is selected in the popup table.
bool m_moveCursorToEndInInternalEditor_enabled: 1
bool m_selectAllInInternalEditor_enabled: 1
bool m_setValueInInternalEditor_enabled: 1
bool m_setVisibleValueOnSetValueInternal: 1
 Used in setValueInternal() to control whether we want to set visible value on setValueInternal()
  • true for table view's combo box.


Constructor & Destructor Documentation

KexiComboBoxBase::KexiComboBoxBase  ) 
 

Definition at line 35 of file kexicomboboxbase.cpp.

References m_insideCreatePopup, m_internalEditorValueChanged, m_mouseBtnPressedWhenPopupVisible, m_moveCursorToEndInInternalEditor_enabled, m_selectAllInInternalEditor_enabled, m_setValueInInternalEditor_enabled, m_setValueOrTextInInternalEditor_enabled, m_setVisibleValueOnSetValueInternal, m_slotInternalEditorValueChanged_enabled, and m_updatePopupSelectionOnShow.

KexiComboBoxBase::~KexiComboBoxBase  )  [virtual]
 

Definition at line 49 of file kexicomboboxbase.cpp.


Member Function Documentation

void KexiComboBoxBase::acceptPopupSelection  )  [protected]
 

Definition at line 433 of file kexicomboboxbase.cpp.

References popup(), and slotRowAccepted().

Referenced by KexiDBComboBox::handleKeyPressEvent().

virtual void KexiComboBoxBase::acceptRequested  )  [protected, pure virtual]
 

Implement this as signal.

Implemented in KexiDBComboBox, and KexiComboBoxTableEdit.

Referenced by slotRowAccepted().

void KexiComboBoxBase::clear  )  [virtual]
 

Reimplement this and call this impl.: used to clear internal editor.

Reimplemented in KexiComboBoxTableEdit.

Definition at line 290 of file kexicomboboxbase.cpp.

References popup(), and slotInternalEditorValueChanged().

Referenced by KexiComboBoxTableEdit::clear(), and slotItemSelected().

virtual KexiTableViewColumn* KexiComboBoxBase::column  )  const [pure virtual]
 

Returns:
column related to this combo; for KexiComboBoxTableEdit 0 is returned here

Implemented in KexiDBComboBox, and KexiComboBoxTableEdit.

Referenced by createPopup(), setValueInternal(), slotItemSelected(), value(), valueChangedInternal(), and valueForString().

void KexiComboBoxBase::createPopup bool  show  ) 
 

todo alter the position to fit the popup within screen boundaries

Definition at line 339 of file kexicomboboxbase.cpp.

References column(), editRequested(), field(), internalEditor(), lookupFieldSchema(), m_insideCreatePopup, m_moveCursorToEndInInternalEditor_enabled, m_selectAllInInternalEditor_enabled, m_setValueInInternalEditor_enabled, m_updatePopupSelectionOnShow, mapFromParentToGlobal(), moveCursorToEndInInternalEditor(), origValue(), popup(), popupWidthHint(), rowToHighlightForLookupTable(), selectAllInInternalEditor(), setPopup(), setValueInInternalEditor(), slotItemSelected(), slotRowAccepted(), and valueForString().

Referenced by KexiComboBoxTableEdit::handleKeyPress(), setValueInternal(), showPopup(), and value().

virtual void KexiComboBoxBase::editRequested  )  [protected, pure virtual]
 

Implement this as signal.

Implemented in KexiDBComboBox, and KexiComboBoxTableEdit.

Referenced by createPopup().

virtual KexiDB::Field* KexiComboBoxBase::field  )  const [pure virtual]
 

Returns:
database field related to this combo

Implemented in KexiDBComboBox, and KexiComboBoxTableEdit.

Referenced by createPopup(), lookupFieldSchema(), setValueInternal(), and slotItemSelected().

bool KexiComboBoxBase::handleKeyPressForPopup QKeyEvent *  ke  )  [protected]
 

Definition at line 510 of file kexicomboboxbase.cpp.

References popup(), and updateTextForHighlightedRow().

Referenced by KexiComboBoxTableEdit::handleKeyPress(), and KexiDBComboBox::handleKeyPressEvent().

void KexiComboBoxBase::hide  )  [virtual]
 

Reimplemented in KexiComboBoxTableEdit.

Definition at line 417 of file kexicomboboxbase.cpp.

References popup().

Referenced by KexiComboBoxTableEdit::hide().

virtual QWidget* KexiComboBoxBase::internalEditor  )  const [pure virtual]
 

Implement this to return the internal editor.

Implemented in KexiDBComboBox, and KexiComboBoxTableEdit.

Referenced by createPopup().

KexiDB::LookupFieldSchema * KexiComboBoxBase::lookupFieldSchema  )  const [protected]
 

Definition at line 53 of file kexicomboboxbase.cpp.

References field().

Referenced by createPopup(), rowToHighlightForLookupTable(), selectItemForEnteredValueInLookupTable(), KexiComboBoxTableEdit::setupContents(), setValueInternal(), slotItemSelected(), undoChanges(), value(), valueChangedInternal(), visibleValueForLookupField(), and KexiComboBoxTableEdit::widthForValue().

virtual QPoint KexiComboBoxBase::mapFromParentToGlobal const QPoint &  pos  )  const [protected, pure virtual]
 

Implement this to return a position pos mapped from parent (e.g.

viewport) to global coordinates. QPoint(-1, -1) should be returned if this cannot be computed.

Implemented in KexiDBComboBox, and KexiComboBoxTableEdit.

Referenced by createPopup().

virtual void KexiComboBoxBase::moveCursorToEndInInternalEditor  )  [protected, pure virtual]
 

Implement this to perform "move cursor to end" in the internal editor.

Implemented in KexiDBComboBox, and KexiComboBoxTableEdit.

Referenced by createPopup(), setValueInternal(), and slotItemSelected().

virtual QVariant KexiComboBoxBase::origValue  )  const [pure virtual]
 

Returns:
the original value

Implemented in KexiDBComboBox, and KexiComboBoxTableEdit.

Referenced by createPopup(), rowToHighlightForLookupTable(), setValueInternal(), and value().

virtual KexiComboBoxPopup* KexiComboBoxBase::popup  )  const [protected, pure virtual]
 

Implemented in KexiDBComboBox, and KexiComboBoxTableEdit.

Referenced by acceptPopupSelection(), clear(), createPopup(), handleKeyPressForPopup(), hide(), rowToHighlightForLookupTable(), selectItemForEnteredValueInLookupTable(), setValueInternal(), slotInternalEditorValueChanged(), slotItemSelected(), undoChanges(), updateTextForHighlightedRow(), value(), valueChangedInternal(), and visibleValueForLookupField().

virtual int KexiComboBoxBase::popupWidthHint  )  const [protected, pure virtual]
 

Implement this to return a hint for popup width.

Implemented in KexiDBComboBox, and KexiComboBoxTableEdit.

Referenced by createPopup().

int KexiComboBoxBase::rowToHighlightForLookupTable  )  const [protected]
 

Todo:
for now we're assuming the id is INTEGER

Definition at line 60 of file kexicomboboxbase.cpp.

References KexiDB::LookupFieldSchema::boundColumn(), KexiTableViewData::iterator(), lookupFieldSchema(), origValue(), and popup().

Referenced by createPopup(), and setValueInternal().

virtual void KexiComboBoxBase::selectAllInInternalEditor  )  [protected, pure virtual]
 

Implement this to perform "select all" in the internal editor.

Implemented in KexiDBComboBox, and KexiComboBoxTableEdit.

Referenced by createPopup(), setValueInternal(), and slotItemSelected().

KexiTableItem * KexiComboBoxBase::selectItemForEnteredValueInLookupTable const QVariant &  v  )  [protected]
 

Used to select row item for an user-entered value v.

Only for "lookup table" mode.

Definition at line 163 of file kexicomboboxbase.cpp.

References KexiTableViewData::iterator(), lookupFieldSchema(), m_setValueOrTextInInternalEditor_enabled, popup(), and KexiDB::LookupFieldSchema::visibleColumn().

Referenced by KexiComboBoxTableEdit::handleKeyPress(), and value().

virtual void KexiComboBoxBase::setPopup KexiComboBoxPopup popup  )  [protected, pure virtual]
 

Implemented in KexiDBComboBox, and KexiComboBoxTableEdit.

Referenced by createPopup().

virtual void KexiComboBoxBase::setValueInInternalEditor const QVariant &  value  )  [protected, pure virtual]
 

Implement this to perform "set value" in the internal editor.

Implemented in KexiDBComboBox, and KexiComboBoxTableEdit.

Referenced by createPopup(), setValueInternal(), and setValueOrTextInInternalEditor().

void KexiComboBoxBase::setValueInternal const QVariant &  add_,
bool  removeOld
[protected, virtual]
 

Todo:
support more RowSourceType's, not only table
Todo:
errmsg
show

Reimplemented in KexiDBComboBox, and KexiComboBoxTableEdit.

Definition at line 86 of file kexicomboboxbase.cpp.

References KexiDB::LookupFieldSchema::boundColumn(), column(), createPopup(), field(), lookupFieldSchema(), m_mouseBtnPressedWhenPopupVisible, m_setVisibleValueOnSetValueInternal, m_updatePopupSelectionOnShow, moveCursorToEndInInternalEditor(), origValue(), popup(), rowToHighlightForLookupTable(), selectAllInInternalEditor(), setValueInInternalEditor(), setValueOrTextInInternalEditor(), valueForString(), and KexiDB::LookupFieldSchema::visibleColumn().

Referenced by KexiDBComboBox::setValueInternal(), and KexiComboBoxTableEdit::setValueInternal().

void KexiComboBoxBase::setValueOrTextInInternalEditor const QVariant &  value  )  [protected]
 

sets value for the line edit without setting a flag (m_userEnteredValue) that indicates that the text has been entered by hand (by a user)

Definition at line 500 of file kexicomboboxbase.cpp.

References m_internalEditorValueChanged, m_setValueOrTextInInternalEditor_enabled, m_userEnteredValue, and setValueInInternalEditor().

Referenced by setValueInternal(), slotItemSelected(), and undoChanges().

void KexiComboBoxBase::showPopup  ) 
 

Definition at line 334 of file kexicomboboxbase.cpp.

References createPopup().

Referenced by KexiDBComboBox::handleKeyPressEvent(), KexiDBComboBox::handleMousePressEvent(), and KexiComboBoxTableEdit::slotButtonClicked().

void KexiComboBoxBase::slotInternalEditorValueChanged const QVariant &  v  ) 
 

Call this from slot.

Reimplemented in KexiDBComboBox, and KexiComboBoxTableEdit.

Definition at line 486 of file kexicomboboxbase.cpp.

References m_internalEditorValueChanged, m_slotInternalEditorValueChanged_enabled, m_userEnteredValue, and popup().

Referenced by clear(), KexiDBComboBox::slotInternalEditorValueChanged(), and KexiComboBoxTableEdit::slotInternalEditorValueChanged().

void KexiComboBoxBase::slotItemSelected KexiTableItem  )  [virtual]
 

Call this from slot.

Reimplemented in KexiDBComboBox, and KexiComboBoxTableEdit.

Definition at line 445 of file kexicomboboxbase.cpp.

References clear(), column(), field(), kexidbg, lookupFieldSchema(), m_insideCreatePopup, m_setValueOrTextInInternalEditor_enabled, m_updatePopupSelectionOnShow, m_visibleValue, moveCursorToEndInInternalEditor(), popup(), selectAllInInternalEditor(), setValueOrTextInInternalEditor(), and visibleValueForLookupField().

Referenced by createPopup(), KexiDBComboBox::slotItemSelected(), KexiComboBoxTableEdit::slotItemSelected(), slotRowAccepted(), and updateTextForHighlightedRow().

void KexiComboBoxBase::slotRowAccepted KexiTableItem item,
int  row
[virtual]
 

Call this from slot.

Reimplemented in KexiDBComboBox, and KexiComboBoxTableEdit.

Definition at line 423 of file kexicomboboxbase.cpp.

References acceptRequested(), slotItemSelected(), and updateButton().

Referenced by acceptPopupSelection(), createPopup(), KexiDBComboBox::slotRowAccepted(), and KexiComboBoxTableEdit::slotRowAccepted().

void KexiComboBoxBase::undoChanges  )  [protected]
 

Used by KexiDBComboBox.

Reimplemented in KexiDBComboBox.

Definition at line 574 of file kexicomboboxbase.cpp.

References lookupFieldSchema(), m_visibleValue, popup(), setValueOrTextInInternalEditor(), and visibleValueForLookupField().

Referenced by KexiDBComboBox::undoChanges().

virtual void KexiComboBoxBase::updateButton  )  [inline, protected, virtual]
 

Implement this to update button state.

Table view just updates on/off state for the button depending on visibility of the popup

Reimplemented in KexiComboBoxTableEdit.

Definition at line 133 of file kexicomboboxbase.h.

Referenced by slotRowAccepted().

void KexiComboBoxBase::updateTextForHighlightedRow  )  [protected]
 

Definition at line 567 of file kexicomboboxbase.cpp.

References popup(), and slotItemSelected().

Referenced by handleKeyPressForPopup().

QVariant KexiComboBoxBase::value  )  [virtual]
 

Note: Generally in current implementation this is integer > 0; may be null if no value is set.

it &&

Todo:
don't return just 1st row, but use autocompletion feature and: show message box if entered text does not match!

Reimplemented in KexiDBComboBox, and KexiComboBoxTableEdit.

Definition at line 232 of file kexicomboboxbase.cpp.

References KexiDB::LookupFieldSchema::boundColumn(), column(), createPopup(), lookupFieldSchema(), m_internalEditorValueChanged, m_userEnteredValue, origValue(), popup(), selectItemForEnteredValueInLookupTable(), valueForString(), and valueFromInternalEditor().

Referenced by KexiDBComboBox::value(), KexiComboBoxTableEdit::value(), and valueIsNull().

tristate KexiComboBoxBase::valueChangedInternal  )  [virtual]
 

Definition at line 297 of file kexicomboboxbase.cpp.

References cancelled, column(), lookupFieldSchema(), m_internalEditorValueChanged, and popup().

Referenced by KexiComboBoxTableEdit::valueChanged().

QString KexiComboBoxBase::valueForString const QString str,
int *  row,
uint  lookInColumn,
uint  returnFromColumn,
bool  allowNulls = false
[protected]
 

Returns:
value from returnFromColumn related to str value from column lookInColumn. If allowNulls is true, NULL is returend if no matched column found, else: str is returned. Example: lookInColumn=0, returnFromColumn=1 --returns user-visible string for column #1 for id-column #0

Definition at line 202 of file kexicomboboxbase.cpp.

References column(), KexiTableViewData::iterator(), and kexiwarn.

Referenced by createPopup(), KexiComboBoxTableEdit::setupContents(), setValueInternal(), and value().

virtual QVariant KexiComboBoxBase::valueFromInternalEditor  )  [protected, pure virtual]
 

Implement this to return value from the internal editor.

Implemented in KexiDBComboBox, and KexiComboBoxTableEdit.

Referenced by value().

bool KexiComboBoxBase::valueIsEmpty  )  [virtual]
 

Definition at line 329 of file kexicomboboxbase.cpp.

References valueIsNull().

bool KexiComboBoxBase::valueIsNull  )  [virtual]
 

Definition at line 321 of file kexicomboboxbase.cpp.

References value().

Referenced by valueIsEmpty().

QVariant KexiComboBoxBase::visibleValue  )  [virtual]
 

Reimplemented in KexiDBComboBox, and KexiComboBoxTableEdit.

Definition at line 285 of file kexicomboboxbase.cpp.

References m_visibleValue.

Referenced by KexiDBComboBox::visibleValue(), and KexiComboBoxTableEdit::visibleValue().

QVariant KexiComboBoxBase::visibleValueForLookupField  )  [protected, virtual]
 

Definition at line 276 of file kexicomboboxbase.cpp.

References lookupFieldSchema(), popup(), and KexiDB::LookupFieldSchema::visibleColumn().

Referenced by slotItemSelected(), and undoChanges().


Member Data Documentation

bool KexiComboBoxBase::m_insideCreatePopup [protected]
 

true if we're inside createPopup(); used in slotItemSelected()

Definition at line 157 of file kexicomboboxbase.h.

Referenced by createPopup(), KexiComboBoxBase(), and slotItemSelected().

bool KexiComboBoxBase::m_internalEditorValueChanged [protected]
 

true if user has text or other value inside editor

Definition at line 153 of file kexicomboboxbase.h.

Referenced by KexiComboBoxTableEdit::handleKeyPress(), KexiComboBoxBase(), setValueOrTextInInternalEditor(), slotInternalEditorValueChanged(), value(), and valueChangedInternal().

bool KexiComboBoxBase::m_mouseBtnPressedWhenPopupVisible [protected]
 

Used only by KexiComboBoxTableEdit.

Definition at line 156 of file kexicomboboxbase.h.

Referenced by KexiComboBoxTableEdit::eventFilter(), KexiComboBoxBase(), setValueInternal(), and KexiComboBoxTableEdit::slotButtonClicked().

bool KexiComboBoxBase::m_moveCursorToEndInInternalEditor_enabled [protected]
 

Definition at line 161 of file kexicomboboxbase.h.

Referenced by createPopup(), KexiComboBoxBase(), and KexiDBComboBox::moveCursorToEndInInternalEditor().

bool KexiComboBoxBase::m_selectAllInInternalEditor_enabled [protected]
 

Definition at line 162 of file kexicomboboxbase.h.

Referenced by createPopup(), KexiComboBoxBase(), and KexiDBComboBox::selectAllInInternalEditor().

bool KexiComboBoxBase::m_setValueInInternalEditor_enabled [protected]
 

Definition at line 163 of file kexicomboboxbase.h.

Referenced by createPopup(), KexiComboBoxBase(), and KexiDBComboBox::setValueInInternalEditor().

bool KexiComboBoxBase::m_setValueOrTextInInternalEditor_enabled [protected]
 

Used in setValueOrTextInInternalEditor() and slotItemSelected().

Definition at line 155 of file kexicomboboxbase.h.

Referenced by KexiComboBoxBase(), selectItemForEnteredValueInLookupTable(), setValueOrTextInInternalEditor(), and slotItemSelected().

bool KexiComboBoxBase::m_setVisibleValueOnSetValueInternal [protected]
 

Used in setValueInternal() to control whether we want to set visible value on setValueInternal()

  • true for table view's combo box.

Definition at line 164 of file kexicomboboxbase.h.

Referenced by KexiComboBoxBase(), KexiComboBoxTableEdit::KexiComboBoxTableEdit(), and setValueInternal().

bool KexiComboBoxBase::m_slotInternalEditorValueChanged_enabled [protected]
 

Used in slotInternalEditorValueChanged().

Definition at line 154 of file kexicomboboxbase.h.

Referenced by KexiComboBoxBase(), and slotInternalEditorValueChanged().

bool KexiComboBoxBase::m_updatePopupSelectionOnShow [protected]
 

Set to false as soon as the item corresponding with the current value is selected in the popup table.

This avoids selecting item for origValue() and thus loosing the recent choice.

Definition at line 158 of file kexicomboboxbase.h.

Referenced by createPopup(), KexiComboBoxBase(), setValueInternal(), and slotItemSelected().

QVariant KexiComboBoxBase::m_userEnteredValue [protected]
 

value (usually a text) entered by hand (by the user)

Definition at line 151 of file kexicomboboxbase.h.

Referenced by KexiComboBoxTableEdit::handleKeyPress(), setValueOrTextInInternalEditor(), slotInternalEditorValueChanged(), and value().

QVariant KexiComboBoxBase::m_visibleValue [protected]
 

Definition at line 149 of file kexicomboboxbase.h.

Referenced by slotItemSelected(), undoChanges(), and visibleValue().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for Kexi 2.0 alpha.
Documentation copyright © 2002-2007 the Kexi Team.
Generated on Tue Apr 1 20:49:49 2008 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003