#include <q3combobox.h>
Inheritance diagram for Q3ComboBox:


Comboboxes provide a means of showing the user's current choice out of a list of options in a way that takes up the minimum amount of screen space.
Q3ComboBox supports three different display styles: Aqua/Motif 1.x, Motif 2.0 and Windows. In Motif 1.x, a combobox was called XmOptionMenu. In Motif 2.0, OSF introduced an improved combobox and named that XmComboBox. Q3ComboBox provides both.
Q3ComboBox provides two different constructors. The simplest constructor creates an "old-style" combobox in Motif (or Aqua) style:
Q3ComboBox *c = new Q3ComboBox(this, tr("read-only combobox"));
The other constructor creates a new-style combobox in Motif style, and can create both read-only and editable comboboxes:
Q3ComboBox *c1 = new Q3ComboBox(false, this, tr("read-only combobox")); Q3ComboBox *c2 = new Q3ComboBox(true, this, tr("editable combobox"));
New-style comboboxes use a list box in both Motif and Windows styles, and both the content size and the on-screen size of the list box can be limited with sizeLimit() and setMaxCount() respectively. Old-style comboboxes use a popup in Aqua and Motif style, and that popup will happily grow larger than the desktop if you put enough data into it.
The two constructors create identical-looking comboboxes in Windows style.
Comboboxes can contain pixmaps as well as strings; the insertItem() and changeItem() functions are suitably overloaded. For editable comboboxes, the function clearEdit() is provided, to clear the displayed string without changing the combobox's contents.
A combobox emits two signals, activated() and highlighted(), when a new item has been activated (selected) or highlighted (made current). Both signals exist in two versions, one with a QString argument and one with an int argument. If the user highlights or activates a pixmap, only the int signals are emitted. Whenever the text of an editable combobox is changed the textChanged() signal is emitted.
When the user enters a new string in an editable combobox, the widget may or may not insert it, and it can insert it in several locations. The default policy is is AtBottom but you can change this using setInsertionPolicy().
It is possible to constrain the input to an editable combobox using QValidator; see setValidator(). By default, any input is accepted.
If the combobox is not editable then it has a default focusPolicy() of TabFocus, i.e. it will not grab focus if clicked. This differs from both Windows and Motif. If the combobox is editable then it has a default focusPolicy() of StrongFocus, i.e. it will grab focus if clicked.
A combobox can be populated using the insert functions, insertStringList() and insertItem() for example. Items can be changed with changeItem(). An item can be removed with removeItem() and all items can be removed with clear(). The text of the current item is returned by currentText(), and the text of a numbered item is returned with text(). The current item can be set with setCurrentItem() or setCurrentText(). The number of items in the combobox is returned by count(); the maximum number of items can be set with setMaxCount(). You can allow editing using setEditable(). For editable comboboxes you can set auto-completion using setAutoCompletion() and whether or not the user can add duplicates is set with setDuplicatesEnabled().
Depending on the style, Q3ComboBox will use a list box or a popup menu to display the list of items. See setListBox() for more information.
Definition at line 43 of file q3combobox.h.
Public Types | |
| enum | Policy |
Public Slots | |
| void | clear () |
| void | clearValidator () |
| void | clearEdit () |
| virtual void | setEditText (const QString &) |
Signals | |
| void | activated (int index) |
| void | highlighted (int index) |
| void | activated (const QString &) |
| void | highlighted (const QString &) |
| void | textChanged (const QString &) |
Public Member Functions | |
| Q3ComboBox (QWidget *parent=0, const char *name=0) | |
| Q3ComboBox (bool rw, QWidget *parent=0, const char *name=0) | |
| ~Q3ComboBox () | |
| int | count () const |
| void | insertStringList (const QStringList &, int index=-1) |
| void | insertStrList (const Q3StrList &, int index=-1) |
| void | insertStrList (const Q3StrList *, int index=-1) |
| void | insertStrList (const char **, int numStrings=-1, int index=-1) |
| void | insertItem (const QString &text, int index=-1) |
| void | insertItem (const QPixmap &pixmap, int index=-1) |
| void | insertItem (const QPixmap &pixmap, const QString &text, int index=-1) |
| void | removeItem (int index) |
| int | currentItem () const |
| virtual void | setCurrentItem (int index) |
| QString | currentText () const |
| virtual void | setCurrentText (const QString &) |
| QString | text (int index) const |
| const QPixmap * | pixmap (int index) const |
| void | changeItem (const QString &text, int index) |
| void | changeItem (const QPixmap &pixmap, int index) |
| void | changeItem (const QPixmap &pixmap, const QString &text, int index) |
| bool | autoResize () const |
| virtual void | setAutoResize (bool) |
| QSize | sizeHint () const |
| void | setPalette (const QPalette &) |
| void | setFont (const QFont &) |
| void | setEnabled (bool) |
| virtual void | setSizeLimit (int) |
| int | sizeLimit () const |
| virtual void | setMaxCount (int) |
| int | maxCount () const |
| virtual void | setInsertionPolicy (Policy policy) |
| Policy | insertionPolicy () const |
| virtual void | setValidator (const QValidator *) |
| const QValidator * | validator () const |
| virtual void | setListBox (Q3ListBox *) |
| Q3ListBox * | listBox () const |
| virtual void | setLineEdit (QLineEdit *edit) |
| QLineEdit * | lineEdit () const |
| virtual void | setAutoCompletion (bool) |
| bool | autoCompletion () const |
| bool | eventFilter (QObject *object, QEvent *event) |
| void | setDuplicatesEnabled (bool enable) |
| bool | duplicatesEnabled () const |
| bool | editable () const |
| void | setEditable (bool) |
| virtual void | popup () |
| void | hide () |
Protected Member Functions | |
| void | paintEvent (QPaintEvent *) |
| void | resizeEvent (QResizeEvent *) |
| void | mousePressEvent (QMouseEvent *) |
| void | mouseMoveEvent (QMouseEvent *) |
| void | mouseReleaseEvent (QMouseEvent *) |
| void | mouseDoubleClickEvent (QMouseEvent *) |
| void | keyPressEvent (QKeyEvent *e) |
| void | focusInEvent (QFocusEvent *e) |
| void | focusOutEvent (QFocusEvent *e) |
| void | wheelEvent (QWheelEvent *e) |
| void | styleChange (QStyle &) |
| void | updateMask () |
Private Slots | |
| void | internalActivate (int) |
| void | internalHighlight (int) |
| void | internalClickTimeout () |
| void | returnPressed () |
Private Member Functions | |
| void | setUpListBox () |
| void | setUpLineEdit () |
| void | popDownListBox () |
| void | reIndex () |
| void | currentChanged () |
| int | completionIndex (const QString &, int) const |
Private Attributes | |
| Q3ComboBoxData * | d |
| enum Q3ComboBox::Policy |
This enum specifies what the Q3ComboBox should do when a new string is entered by the user.
NoInsertion the string will not be inserted into the combobox.
AtTop insert the string as the first item in the combobox.
AtCurrent replace the previously selected item with the string the user has entered.
AtBottom insert the string as the last item in the combobox.
AfterCurrent insert the string after the previously selected item.
BeforeCurrent insert the string before the previously selected item.
activated() is always emitted when the string is entered.
If inserting the new string would cause the combobox to breach its content size limit, the item at the other end of the list is deleted. The definition of "other end" is implementation-dependent.
NoInsert InsertAtTop InsertAtCurrent InsertAtBottom InsertAfterCurrent InsertBeforeCurrent
Definition at line 103 of file q3combobox.h.
00103 { NoInsertion, 00104 AtTop, 00105 AtCurrent, 00106 AtBottom, 00107 AfterCurrent, 00108 BeforeCurrent, 00109 NoInsert = NoInsertion, 00110 InsertAtTop = AtTop, 00111 InsertAtCurrent = AtCurrent, 00112 InsertAtBottom = AtBottom, 00113 InsertAfterCurrent = AfterCurrent, 00114 InsertBeforeCurrent = BeforeCurrent 00115 };
| Q3ComboBox::Q3ComboBox | ( | QWidget * | parent = 0, |
|
| const char * | name = 0 | |||
| ) |
Constructs a combobox widget with parent parent called name.
This constructor creates a popup list if the program uses Motif (or Aqua) look and feel; this is compatible with Motif 1.x and Aqua.
Note: If you use this constructor to create your Q3ComboBox, then the pixmap() function will always return 0. To workaround this, use the other constructor.
Definition at line 509 of file q3combobox.cpp.
References activated(), Q3ComboBoxData::arrowDown, Q3ComboBoxData::arrowPressed, AtBottom, Q3ComboBoxData::autoresize, Q3ComboBoxData::completeAt, Q3ComboBoxData::completeNow, Q3ComboBoxData::completionTimer, QObject::connect(), Q3ComboBoxData::current, d, Q3ComboBoxData::discardNextMousePress, Q3ComboBoxData::ed, QWidget::font(), highlighted(), QStyleOption::init(), internalActivate(), internalHighlight(), Q3ComboBoxData::maxCount, Q3ComboBoxData::p, Q3ComboBoxData::poppedUp, Q3ComboBoxData::popup(), QWidget::setFocusPolicy(), QWidget::setFont(), Q3ComboBoxData::setPopupMenu(), setUpListBox(), QStyle::SH_ComboBox_Popup, Q3ComboBoxData::shortClick, SIGNAL, Q3ComboBoxData::sizeLimit, SLOT, QWidget::style(), styleHint(), Qt::TabFocus, and Q3ComboBoxData::useCompletion.
00510 : QWidget( parent, name, Qt::WNoAutoErase ) 00511 { 00512 d = new Q3ComboBoxData( this ); 00513 QStyleOptionComboBox opt; 00514 opt.init(this); 00515 if ( style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, this) || 00516 style()->styleHint(QStyle::SH_GUIStyle, &opt, this) == Qt::MotifStyle ) { 00517 d->setPopupMenu( new Q3ComboBoxPopup( this, "in-combo" ) ); 00518 d->popup()->setFont( font() ); 00519 connect( d->popup(), SIGNAL(activated(int)), 00520 SLOT(internalActivate(int)) ); 00521 connect( d->popup(), SIGNAL(highlighted(int)), 00522 SLOT(internalHighlight(int)) ); 00523 } else { 00524 setUpListBox(); 00525 } 00526 d->ed = 0; 00527 d->current = 0; 00528 d->maxCount = INT_MAX; 00529 d->sizeLimit = 10; 00530 d->p = AtBottom; 00531 d->autoresize = false; 00532 d->poppedUp = false; 00533 d->arrowDown = false; 00534 d->arrowPressed = false; 00535 d->discardNextMousePress = false; 00536 d->shortClick = false; 00537 d->useCompletion = false; 00538 d->completeAt = 0; 00539 d->completeNow = false; 00540 d->completionTimer = new QTimer( this ); 00541 00542 setFocusPolicy( Qt::TabFocus ); 00543 setBackgroundMode( Qt::PaletteButton ); 00544 }
Here is the call graph for this function:

| Q3ComboBox::Q3ComboBox | ( | bool | rw, | |
| QWidget * | parent = 0, |
|||
| const char * | name = 0 | |||
| ) |
Constructs a combobox with a maximum size and either Motif 2.0 or Windows look and feel.
The input field can be edited if rw is true, otherwise the user may only choose one of the items in the combobox.
The parent and name arguments are passed on to the QWidget constructor.
Definition at line 559 of file q3combobox.cpp.
References Q3ComboBoxData::arrowDown, AtBottom, Q3ComboBoxData::autoresize, Q3ComboBoxData::completeAt, Q3ComboBoxData::completeNow, Q3ComboBoxData::completionTimer, Q3ComboBoxData::current, d, Q3ComboBoxData::discardNextMousePress, Q3ComboBoxData::ed, Q3ComboBoxData::getStyleOption(), Q3ComboBoxData::maxCount, Q3ComboBoxData::p, Q3ComboBoxData::poppedUp, Q3ComboBoxData::popup(), QWidget::setFocusPolicy(), setSizeLimit(), setUpLineEdit(), setUpListBox(), QStyle::SH_ComboBox_Popup, Q3ComboBoxData::shortClick, Qt::StrongFocus, QWidget::style(), QStyle::styleHint(), and Q3ComboBoxData::useCompletion.
00560 : QWidget( parent, name, Qt::WNoAutoErase ) 00561 { 00562 d = new Q3ComboBoxData( this ); 00563 setUpListBox(); 00564 00565 QStyleOptionComboBox opt = d->getStyleOption(); 00566 if(d->popup() && style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, this)) 00567 d->popup()->setItemChecked(d->current, false); 00568 d->maxCount = INT_MAX; 00569 setSizeLimit(10); 00570 d->p = AtBottom; 00571 d->autoresize = false; 00572 d->poppedUp = false; 00573 d->arrowDown = false; 00574 d->discardNextMousePress = false; 00575 d->shortClick = false; 00576 d->useCompletion = false; 00577 d->completeAt = 0; 00578 d->completeNow = false; 00579 d->completionTimer = new QTimer( this ); 00580 00581 setFocusPolicy( Qt::StrongFocus ); 00582 00583 d->ed = 0; 00584 if ( rw ) 00585 setUpLineEdit(); 00586 setBackgroundMode( Qt::PaletteButton, Qt::PaletteBase ); 00587 }
Here is the call graph for this function:

| Q3ComboBox::~Q3ComboBox | ( | ) |
Destroys the combobox.
Definition at line 595 of file q3combobox.cpp.
References d.
00596 { 00597 delete d; 00598 }
| int Q3ComboBox::count | ( | ) | const |
Definition at line 610 of file q3combobox.cpp.
References Q3ListBox::count(), d, Q3ComboBoxData::listBox(), Q3ComboBoxData::popup(), and Q3ComboBoxData::usingListBox().
Referenced by changeItem(), completionIndex(), Q3ComboTableItem::count(), currentText(), insertItem(), insertStringList(), insertStrList(), keyPressEvent(), mousePressEvent(), pixmap(), popup(), reIndex(), removeItem(), returnPressed(), Q3ComboTableItem::setContentFromEditor(), setCurrentItem(), setCurrentText(), setMaxCount(), sizeHint(), Q3ComboTableItem::sizeHint(), text(), Q3ComboBoxData::updateLinedGeometry(), Q3FileDialog::urlStart(), and wheelEvent().
00611 { 00612 if ( d->usingListBox() ) 00613 return d->listBox()->count(); 00614 else if (d->popup()) 00615 return d->popup()->count(); 00616 else 00617 return 0; 00618 }
Here is the call graph for this function:

| void Q3ComboBox::insertStringList | ( | const QStringList & | list, | |
| int | index = -1 | |||
| ) |
Inserts the list of strings at position index in the combobox.
Definition at line 682 of file q3combobox.cpp.
References QList< T >::begin(), count(), Q3ComboBoxData::current, currentChanged(), d, Q3ComboBoxData::ed, QList< T >::end(), escapedComboString(), Q3ListBox::insertItem(), Q3ComboBoxData::listBox(), Q3ComboBoxData::popup(), reIndex(), QLineEdit::setText(), text(), QWidget::update(), Q3ComboBoxData::updateLinedGeometry(), and Q3ComboBoxData::usingListBox().
Referenced by Q3ComboTableItem::createEditor(), and Q3ComboTableItem::setStringList().
00683 { 00684 QStringList::ConstIterator it = list.begin(); 00685 if ( index < 0 ) 00686 index = count(); 00687 while ( it != list.end() ) { 00688 if ( d->usingListBox() ) 00689 d->listBox()->insertItem( *it, index ); 00690 else 00691 d->popup()->insertItem( escapedComboString(*it), index, index ); 00692 if ( index++ == d->current && d->current < count() ) { 00693 if ( d->ed ) { 00694 d->ed->setText( text( d->current ) ); 00695 d->updateLinedGeometry(); 00696 } else 00697 update(); 00698 currentChanged(); 00699 } 00700 ++it; 00701 } 00702 if ( index != count() ) 00703 reIndex(); 00704 }
Here is the call graph for this function:

| void Q3ComboBox::insertStrList | ( | const Q3StrList & | list, | |
| int | index = -1 | |||
| ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Inserts the list of strings at position index in the combobox.
This is only for compatibility since it does not support Unicode strings. See insertStringList().
Definition at line 631 of file q3combobox.cpp.
00632 { 00633 insertStrList( &list, index ); 00634 }
| void Q3ComboBox::insertStrList | ( | const Q3StrList * | list, | |
| int | index = -1 | |||
| ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Inserts the list of strings at position index in the combobox.
This is only for compatibility since it does not support Unicode strings. See insertStringList().
Definition at line 646 of file q3combobox.cpp.
References count(), Q3ComboBoxData::current, currentChanged(), d, Q3ComboBoxData::ed, escapedComboString(), QString::fromLatin1(), Q3ListBox::insertItem(), Q3ComboBoxData::listBox(), Q3ComboBoxData::popup(), Q3StrListIterator, reIndex(), QLineEdit::setText(), text(), QWidget::update(), Q3ComboBoxData::updateLinedGeometry(), and Q3ComboBoxData::usingListBox().
00647 { 00648 if ( !list ) { 00649 #if defined(QT_CHECK_NULL) 00650 Q_ASSERT( list != 0 ); 00651 #endif 00652 return; 00653 } 00654 Q3StrListIterator it( *list ); 00655 const char* tmp; 00656 if ( index < 0 ) 00657 index = count(); 00658 while ( (tmp=it.current()) ) { 00659 ++it; 00660 if ( d->usingListBox() ) 00661 d->listBox()->insertItem( QString::fromLatin1(tmp), index ); 00662 else 00663 d->popup()->insertItem( escapedComboString(QString::fromLatin1(tmp)), index, index ); 00664 if ( index++ == d->current && d->current < count() ) { 00665 if ( d->ed ) { 00666 d->ed->setText( text( d->current ) ); 00667 d->updateLinedGeometry(); 00668 } else 00669 update(); 00670 currentChanged(); 00671 } 00672 } 00673 if ( index != count() ) 00674 reIndex(); 00675 }
Here is the call graph for this function:

| void Q3ComboBox::insertStrList | ( | const char ** | strings, | |
| int | numStrings = -1, |
|||
| int | index = -1 | |||
| ) |
Inserts the array of char * strings at position index in the combobox.
The numStrings argument is the number of strings. If numStrings is -1 (default), the strings array must be terminated with 0.
Example:
static const char* items[] = { "red", "green", "blue", 0 }; combo->insertStrList( items );
Definition at line 723 of file q3combobox.cpp.
References count(), Q3ComboBoxData::current, currentChanged(), d, Q3ComboBoxData::ed, escapedComboString(), QString::fromLatin1(), i, Q3ListBox::insertItem(), Q3ComboBoxData::listBox(), Q3ComboBoxData::popup(), reIndex(), QLineEdit::setText(), text(), QWidget::update(), Q3ComboBoxData::updateLinedGeometry(), and Q3ComboBoxData::usingListBox().
00724 { 00725 if ( !strings ) { 00726 #if defined(QT_CHECK_NULL) 00727 Q_ASSERT( strings != 0 ); 00728 #endif 00729 return; 00730 } 00731 if ( index < 0 ) 00732 index = count(); 00733 int i = 0; 00734 while ( (numStrings<0 && strings[i]!=0) || i<numStrings ) { 00735 if ( d->usingListBox() ) 00736 d->listBox()->insertItem( QString::fromLatin1(strings[i]), index ); 00737 else 00738 d->popup()->insertItem( escapedComboString(QString::fromLatin1(strings[i])), index, index ); 00739 i++; 00740 if ( index++ == d->current && d->current < count() ) { 00741 if ( d->ed ) { 00742 d->ed->setText( text( d->current ) ); 00743 d->updateLinedGeometry(); 00744 } else 00745 update(); 00746 currentChanged(); 00747 } 00748 } 00749 if ( index != count() ) 00750 reIndex(); 00751 }
Here is the call graph for this function:

| void Q3ComboBox::insertItem | ( | const QString & | t, | |
| int | index = -1 | |||
| ) |
Inserts a text item with text t, at position index. The item will be appended if index is negative.
Definition at line 759 of file q3combobox.cpp.
References checkInsertIndex(), count(), Q3ComboBoxData::current, currentChanged(), d, Q3ComboBoxData::ed, escapedComboString(), Q3ListBox::insertItem(), Q3ComboBoxData::listBox(), name, Q3ComboBoxData::popup(), reIndex(), QLineEdit::setText(), t, text(), QWidget::update(), Q3ComboBoxData::updateLinedGeometry(), and Q3ComboBoxData::usingListBox().
Referenced by Q3FileDialog::init(), returnPressed(), Q3ComboTableItem::sizeHint(), and Q3FileDialog::urlStart().
00760 { 00761 int cnt = count(); 00762 if ( !checkInsertIndex( "insertItem", name(), cnt, &index ) ) 00763 return; 00764 if ( d->usingListBox() ) 00765 d->listBox()->insertItem( t, index ); 00766 else 00767 d->popup()->insertItem( escapedComboString(t), index, index ); 00768 if ( index != cnt ) 00769 reIndex(); 00770 if ( index == d->current && d->current < count() ) { 00771 if ( d->ed ) { 00772 d->ed->setText( text( d->current ) ); 00773 d->updateLinedGeometry(); 00774 } else 00775 update(); 00776 } 00777 if ( index == d->current ) 00778 currentChanged(); 00779 }
Here is the call graph for this function:

| void Q3ComboBox::insertItem | ( | const QPixmap & | pixmap, | |
| int | index = -1 | |||
| ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Inserts a pixmap item at position index. The item will be appended if index is negative.
Definition at line 788 of file q3combobox.cpp.
References checkInsertIndex(), count(), Q3ComboBoxData::current, currentChanged(), d, Q3ComboBoxData::ed, Q3ListBox::insertItem(), Q3ComboBoxData::listBox(), name, pixmap(), Q3ComboBoxData::popup(), reIndex(), QLineEdit::setText(), text(), QWidget::update(), Q3ComboBoxData::updateLinedGeometry(), and Q3ComboBoxData::usingListBox().
00789 { 00790 int cnt = count(); 00791 if ( !checkInsertIndex( "insertItem", name(), cnt, &index ) ) 00792 return; 00793 if ( d->usingListBox() ) 00794 d->listBox()->insertItem( pixmap, index ); 00795 else 00796 d->popup()->insertItem( pixmap, index, index ); 00797 if ( index != cnt ) 00798 reIndex(); 00799 if ( index == d->current && d->current < count() ) { 00800 if ( d->ed ) { 00801 d->ed->setText( text( d->current ) ); 00802 d->updateLinedGeometry(); 00803 } else 00804 update(); 00805 } 00806 if ( index == d->current ) 00807 currentChanged(); 00808 }
Here is the call graph for this function:

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Inserts a pixmap item with additional text text at position index. The item will be appended if index is negative.
Definition at line 817 of file q3combobox.cpp.
References checkInsertIndex(), count(), Q3ComboBoxData::current, currentChanged(), d, Q3ComboBoxData::ed, escapedComboString(), Q3ListBox::insertItem(), Q3ComboBoxData::listBox(), name, pixmap(), Q3ComboBoxData::popup(), reIndex(), QLineEdit::setText(), text(), QWidget::update(), Q3ComboBoxData::updateLinedGeometry(), and Q3ComboBoxData::usingListBox().
00818 { 00819 int cnt = count(); 00820 if ( !checkInsertIndex( "insertItem", name(), cnt, &index ) ) 00821 return; 00822 if ( d->usingListBox() ) 00823 d->listBox()->insertItem( pixmap, text, index ); 00824 else 00825 d->popup()->insertItem( pixmap, escapedComboString(text), index, index ); 00826 if ( index != cnt ) 00827 reIndex(); 00828 if ( index == d->current && d->current < count() ) { 00829 if ( d->ed ) { 00830 d->ed->setText( this->text( d->current ) ); 00831 d->updateLinedGeometry(); 00832 } else 00833 update(); 00834 } 00835 if ( index == d->current ) 00836 currentChanged(); 00837 }
Here is the call graph for this function:

| void Q3ComboBox::removeItem | ( | int | index | ) |
Removes the item at position index.
Definition at line 844 of file q3combobox.cpp.
References checkIndex(), count(), Q3ComboBoxData::current, currentChanged(), Q3ListBox::currentItem(), d, Q3ComboBoxData::ed, QString::fromLatin1(), Q3ComboBoxData::getStyleOption(), Q3ComboBoxData::listBox(), name, Q3ComboBoxData::popup(), reIndex(), Q3ListBox::removeItem(), s, setCurrentItem(), QLineEdit::setText(), QStyle::SH_ComboBox_Popup, QWidget::style(), styleHint(), text(), QWidget::update(), Q3ComboBoxData::updateLinedGeometry(), and Q3ComboBoxData::usingListBox().
Referenced by returnPressed(), setMaxCount(), and Q3ComboTableItem::sizeHint().
00845 { 00846 int cnt = count(); 00847 if ( !checkIndex( "removeItem", name(), cnt, index ) ) 00848 return; 00849 if ( d->usingListBox() ) { 00850 QStyleOptionComboBox opt = d->getStyleOption(); 00851 if ( style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, this) && d->popup() ) 00852 d->popup()->removeItemAt( index ); 00853 d->listBox()->removeItem( index ); 00854 } else { 00855 d->popup()->removeItemAt( index ); 00856 } 00857 if ( index != cnt-1 ) 00858 reIndex(); 00859 if ( index == d->current ) { 00860 if ( d->ed ) { 00861 QString s = QString::fromLatin1(""); 00862 if (d->current < cnt - 1) 00863 s = text( d->current ); 00864 d->ed->setText( s ); 00865 d->updateLinedGeometry(); 00866 } 00867 else { 00868 if ( d->usingListBox() ) { 00869 d->current = d->listBox()->currentItem(); 00870 } else { 00871 if (d->current > count()-1 && d->current > 0) 00872 d->current--; 00873 } 00874 update(); 00875 } 00876 currentChanged(); 00877 } 00878 else { 00879 if ( !d->ed ) { 00880 if (d->current < cnt - 1) 00881 setCurrentItem( d->current ); 00882 else 00883 setCurrentItem( d->current - 1 ); 00884 } 00885 } 00886 00887 }
Here is the call graph for this function:

| int Q3ComboBox::currentItem | ( | ) | const |
Definition at line 1044 of file q3combobox.cpp.
References Q3ComboBoxData::current, and d.
Referenced by Q3ComboTableItem::currentItem(), currentText(), eventFilter(), keyPressEvent(), popup(), returnPressed(), Q3ComboTableItem::setContentFromEditor(), Q3ComboTableItem::setCurrentItem(), setCurrentText(), setEditable(), and wheelEvent().
| void Q3ComboBox::setCurrentItem | ( | int | index | ) | [virtual] |
Definition at line 1049 of file q3combobox.cpp.
References checkIndex(), Q3ComboBoxData::completeAt, count(), Q3ComboBoxData::current, currentChanged(), d, Q3ComboBoxData::ed, Q3ComboBoxData::getStyleOption(), internalHighlight(), Q3ListBoxItem::isSelectable(), Q3ListBox::item(), Q3ComboBoxData::listBox(), listBox(), name, Q3ComboBoxData::popup(), Q3ListBox::setCurrentItem(), QLineEdit::setText(), QStyle::SH_ComboBox_Popup, QWidget::style(), QStyle::styleHint(), text(), Q3ComboBoxData::updateLinedGeometry(), and Q3ComboBoxData::usingListBox().
Referenced by Q3ComboTableItem::createEditor(), keyPressEvent(), removeItem(), returnPressed(), Q3ComboTableItem::setCurrentItem(), setCurrentText(), Q3ComboTableItem::sizeHint(), Q3FileDialog::urlStart(), and wheelEvent().
01050 { 01051 if ( index == d->current && !d->ed ) { 01052 return; 01053 } 01054 if ( !checkIndex( "setCurrentItem", name(), count(), index ) ) { 01055 return; 01056 } 01057 01058 if ( d->usingListBox() && !( listBox()->item(index) && listBox()->item(index)->isSelectable() ) ) 01059 return; 01060 01061 QStyleOptionComboBox opt = d->getStyleOption(); 01062 if(d->popup() && style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, this)) 01063 d->popup()->setItemChecked(d->current, false); 01064 d->current = index; 01065 d->completeAt = 0; 01066 if ( d->ed ) { 01067 d->ed->setText( text( index ) ); 01068 d->updateLinedGeometry(); 01069 } 01070 // ### We want to keep ListBox's currentItem in sync, even if NOT popuped... 01071 if ( d->usingListBox() && d->listBox() ) { 01072 d->listBox()->setCurrentItem( index ); 01073 } else { 01074 internalHighlight( index ); 01075 // internalActivate( index ); ### this leads to weird behavior, as in 3.0.1 01076 } 01077 01078 currentChanged(); 01079 }
Here is the call graph for this function:

| QString Q3ComboBox::currentText | ( | ) | const |
Definition at line 917 of file q3combobox.cpp.
References count(), Q3ComboBoxData::current, currentItem(), d, Q3ComboBoxData::ed, QString::null, QLineEdit::text(), and text().
Referenced by Q3ComboTableItem::currentText(), Q3FileDialog::keyPressEvent(), keyPressEvent(), popup(), Q3ComboTableItem::setContentFromEditor(), Q3ComboTableItem::setCurrentItem(), setEditable(), setLineEdit(), and wheelEvent().
00918 { 00919 if ( d->ed ) 00920 return d->ed->text(); 00921 else if ( d->current < count() ) 00922 return text( currentItem() ); 00923 else 00924 return QString::null; 00925 }
Here is the call graph for this function:

| void Q3ComboBox::setCurrentText | ( | const QString & | ) | [virtual] |
Definition at line 927 of file q3combobox.cpp.
References changeItem(), count(), currentItem(), d, Q3ComboBoxData::ed, i, setCurrentItem(), QLineEdit::setText(), and text().
00928 { 00929 int i; 00930 for ( i = 0; i < count(); i++) 00931 if ( text( i ) == txt ) 00932 break; 00933 if ( i < count() ) 00934 setCurrentItem( i ); 00935 else if ( d->ed ) 00936 d->ed->setText( txt ); 00937 else 00938 changeItem( txt, currentItem() ); 00939 }
Here is the call graph for this function:

| QString Q3ComboBox::text | ( | int | index | ) | const |
Returns the text item at position index, or QString::null if the item is not a string.
Definition at line 949 of file q3combobox.cpp.
References checkIndex(), count(), d, Q3ComboBoxData::listBox(), name, QString::null, Q3ComboBoxData::popup(), QString::replace(), Q3ListBox::text(), and Q3ComboBoxData::usingListBox().
Referenced by changeItem(), completionIndex(), currentText(), eventFilter(), Q3ComboBoxData::getStyleOption(), insertItem(), insertStringList(), insertStrList(), internalActivate(), internalHighlight(), keyPressEvent(), popup(), removeItem(), returnPressed(), Q3ComboTableItem::setContentFromEditor(), setCurrentItem(), setCurrentText(), Q3ComboTableItem::text(), and Q3FileDialog::urlStart().
00950 { 00951 if ( !checkIndex( "text", name(), count(), index ) ) 00952 return QString::null; 00953 if ( d->usingListBox() ) { 00954 return d->listBox()->text( index ); 00955 } else { 00956 QString retText = d->popup()->text(index); 00957 retText.replace("&&", "&"); 00958 return retText; 00959 } 00960 }
Here is the call graph for this function:

| const QPixmap * Q3ComboBox::pixmap | ( | int | index | ) | const |
Returns the pixmap item at position index, or 0 if the item is not a pixmap.
Definition at line 967 of file q3combobox.cpp.
References checkIndex(), count(), d, Q3ComboBoxData::listBox(), name, Q3ListBox::pixmap(), Q3ComboBoxData::popup(), Q3ComboBoxData::popupPixmaps, and Q3ComboBoxData::usingListBox().
Referenced by Q3ComboBoxData::getStyleOption(), insertItem(), and Q3ComboBoxData::updateLinedGeometry().
00968 { 00969 if ( !checkIndex( "pixmap", name(), count(), index ) ) 00970 return 0; 00971 00972 if (d->usingListBox()) { 00973 return d->listBox()->pixmap( index ); 00974 } else { 00975 d->popupPixmaps[index] = d->popup()->pixmap(index); 00976 return d->popupPixmaps[index].isNull() ? 0 : &d->popupPixmaps[index]; 00977 } 00978 }
Here is the call graph for this function:

| void Q3ComboBox::changeItem | ( | const QString & | t, | |
| int | index | |||
| ) |
Replaces the item at position index with the text t.
Definition at line 984 of file q3combobox.cpp.
References Q3ListBox::changeItem(), checkIndex(), count(), Q3ComboBoxData::current, d, Q3ComboBoxData::ed, Q3ComboBoxData::listBox(), name, Q3ComboBoxData::popup(), QLineEdit::setText(), t, text(), QWidget::update(), Q3ComboBoxData::updateLinedGeometry(), and Q3ComboBoxData::usingListBox().
Referenced by returnPressed(), and setCurrentText().
00985 { 00986 if ( !checkIndex( "changeItem", name(), count(), index ) ) 00987 return; 00988 if ( d->usingListBox() ) 00989 d->listBox()->changeItem( t, index ); 00990 else 00991 d->popup()->changeItem(index, t); 00992 if ( index == d->current ) { 00993 if ( d->ed ) { 00994 d->ed->setText( text( d->current ) ); 00995 d->updateLinedGeometry(); 00996 } else 00997 update(); 00998 } 00999 }
Here is the call graph for this function:

| void Q3ComboBox::changeItem | ( | const QPixmap & | im, | |
| int | index | |||
| ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Replaces the item at position index with the pixmap im, unless the combobox is editable.
Definition at line 1010 of file q3combobox.cpp.
References Q3ListBox::changeItem(), checkIndex(), count(), Q3ComboBoxData::current, d, Q3ComboBoxData::listBox(), name, Q3ComboBoxData::popup(), QWidget::update(), and Q3ComboBoxData::usingListBox().
01011 { 01012 if ( !checkIndex( "changeItem", name(), count(), index ) ) 01013 return; 01014 if ( d->usingListBox() ) 01015 d->listBox()->changeItem( im, index ); 01016 else 01017 d->popup()->changeItem(index, im); 01018 if ( index == d->current ) 01019 update(); 01020 }
Here is the call graph for this function:

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Replaces the item at position index with the pixmap im and the text t.
Definition at line 1031 of file q3combobox.cpp.
References Q3ListBox::changeItem(), checkIndex(), count(), Q3ComboBoxData::current, d, Q3ComboBoxData::listBox(), name, Q3ComboBoxData::popup(), t, QWidget::update(), and Q3ComboBoxData::usingListBox().
01032 { 01033 if ( !checkIndex( "changeItem", name(), count(), index ) ) 01034 return; 01035 if ( d->usingListBox() ) 01036 d->listBox()->changeItem( im, t, index ); 01037 else 01038 d->popup()->changeItem(index, im, t); 01039 if ( index == d->current ) 01040 update(); 01041 }
Here is the call graph for this function:

| bool Q3ComboBox::autoResize | ( | ) | const |
Returns true if auto-resize is enabled; otherwise returns false.
Definition at line 1087 of file q3combobox.cpp.
References Q3ComboBoxData::autoresize, and d.
01088 { 01089 return d->autoresize; 01090 }
| void Q3ComboBox::setAutoResize | ( | bool | enable | ) | [virtual] |
If enable is true, enable auto-resize; disable it otherwise.
Definition at line 1098 of file q3combobox.cpp.
References QWidget::adjustSize(), Q3ComboBoxData::autoresize, and d.
01099 { 01100 if ( (bool)d->autoresize != enable ) { 01101 d->autoresize = enable; 01102 if ( enable ) 01103 adjustSize(); 01104 } 01105 }
Here is the call graph for this function:

| QSize Q3ComboBox::sizeHint | ( | ) | const [virtual] |
This implementation caches the size hint to avoid resizing when the contents change dynamically. To invalidate the cached value call setFont().
Reimplemented from QWidget.
Definition at line 1115 of file q3combobox.cpp.
References count(), QStyle::CT_ComboBox, d, QWidget::fontMetrics(), Q3PopupMenu::frameWidth(), Q3ComboBoxData::getStyleOption(), QApplication::globalStrut(), i, QSize::isValid(), QWidget::isVisible(), Q3ListBox::item(), QFontMetrics::lineSpacing(), Q3ComboBoxData::listBox(), Q3ComboBoxData::popup(), QStyle::sizeFromContents(), Q3ComboBoxData::sizeHint, QMenu::sizeHint(), QWidget::style(), Q3ComboBoxData::usingListBox(), w, Q3ListBoxItem::width(), QSize::width(), and QFontMetrics::width().
Referenced by Q3ComboTableItem::sizeHint(), and Q3FileDialog::updateGeometries().
01116 { 01117 if ( isVisible() && d->sizeHint.isValid() ) 01118 return d->sizeHint; 01119 01120 constPolish(); 01121 int i, w; 01122 QFontMetrics fm = fontMetrics(); 01123 01124 int maxW = count() ? 18 : 7 * fm.width(QChar('x')) + 18; 01125 int maxH = QMAX( fm.lineSpacing(), 14 ) + 2; 01126 01127 if ( !d->usingListBox() ) { 01128 w = d->popup()->sizeHint().width() - 2* d->popup()->frameWidth(); 01129 if ( w > maxW ) 01130 maxW = w; 01131 } else { 01132 for( i = 0; i < count(); i++ ) { 01133 w = d->listBox()->item( i )->width( d->listBox() ); 01134 if ( w > maxW ) 01135 maxW = w; 01136 } 01137 } 01138 01139 QStyleOptionComboBox opt = d->getStyleOption(); 01140 d->sizeHint = (style()->sizeFromContents(QStyle::CT_ComboBox, &opt, QSize(maxW, maxH), this). 01141 expandedTo(QApplication::globalStrut())); 01142 01143 return d->sizeHint; 01144 }
Here is the call graph for this function:

| void Q3ComboBox::setPalette | ( | const QPalette & | palette | ) |
Sets the palette for both the combobox button and the combobox popup list to palette.
Reimplemented from QWidget.
Definition at line 1208 of file q3combobox.cpp.
References d, Q3ComboBoxData::listBox(), QWidget::palette(), Q3ComboBoxData::popup(), and QWidget::setPalette().
01209 { 01210 QWidget::setPalette( palette ); 01211 if ( d->listBox() ) 01212 d->listBox()->setPalette( palette ); 01213 if ( d->popup() ) 01214 d->popup()->setPalette( palette ); 01215 }
Here is the call graph for this function:

| void Q3ComboBox::setFont | ( | const QFont & | font | ) |
Sets the font for both the combobox button and the combobox popup list to font.
Reimplemented from QWidget.
Definition at line 1222 of file q3combobox.cpp.
References QWidget::adjustSize(), Q3ComboBoxData::autoresize, d, Q3ComboBoxData::ed, QWidget::font(), Q3ComboBoxData::listBox(), Q3ComboBoxData::popup(), QWidget::setFont(), Q3ComboBoxData::sizeHint, and Q3ComboBoxData::usingListBox().
01223 { 01224 d->sizeHint = QSize(); // invalidate size hint 01225 QWidget::setFont( font ); 01226 if ( d->usingListBox() ) 01227 d->listBox()->setFont( font ); 01228 else 01229 d->popup()->setFont( font ); 01230 if (d->ed) 01231 d->ed->setFont( font ); 01232 if ( d->autoresize ) 01233 adjustSize(); 01234 }
Here is the call graph for this function:

| void Q3ComboBox::setEnabled | ( | bool | enable | ) |
Enables the combobox if enable is true; otherwise disables it.
Reimplemented from QWidget.
Definition at line 2054 of file q3combobox.cpp.
References QWidget::close(), d, popDownListBox(), Q3ComboBoxData::poppedUp, Q3ComboBoxData::popup(), QObject::removeEventFilter(), QWidget::setEnabled(), and Q3ComboBoxData::usingListBox().
02055 { 02056 if ( !enable ) { 02057 if ( d->usingListBox() ) { 02058 popDownListBox(); 02059 } else { 02060 d->popup()->removeEventFilter( this ); 02061 d->popup()->close(); 02062 d->poppedUp = false; 02063 } 02064 } 02065 QWidget::setEnabled( enable ); 02066 }
Here is the call graph for this function:

| void Q3ComboBox::setSizeLimit | ( | int | ) | [virtual] |
Definition at line 1952 of file q3combobox.cpp.
References d, and Q3ComboBoxData::sizeLimit.
Referenced by Q3ComboBox().
| int Q3ComboBox::sizeLimit | ( | ) | const |
| void Q3ComboBox::setMaxCount | ( | int | ) | [virtual] |
Definition at line 1963 of file q3combobox.cpp.
References count(), d, l, Q3ComboBoxData::maxCount, and removeItem().
01964 { 01965 int l = this->count(); 01966 while( --l > count ) 01967 removeItem( l ); 01968 d->maxCount = count; 01969 }
Here is the call graph for this function:

| int Q3ComboBox::maxCount | ( | ) | const |
| void Q3ComboBox::setInsertionPolicy | ( | Policy | policy | ) | [virtual] |
Definition at line 1976 of file q3combobox.cpp.
References d, and Q3ComboBoxData::p.
Referenced by Q3FileDialog::init().
| Q3ComboBox::Policy Q3ComboBox::insertionPolicy | ( | ) | const |
Definition at line 1971 of file q3combobox.cpp.
References d, and Q3ComboBoxData::p.
Referenced by returnPressed().
| void Q3ComboBox::setValidator | ( | const QValidator * | v | ) | [virtual] |
Applies the validator v to the combobox so that only text which is valid according to v is accepted.
This function does nothing if the combobox is not editable.
Definition at line 2079 of file q3combobox.cpp.
References d, Q3ComboBoxData::ed, and QLineEdit::setValidator().
Here is the call graph for this function:

| const QValidator * Q3ComboBox::validator | ( | ) | const |
Returns the validator which constrains editing for this combobox if there is one; otherwise returns 0.
Definition at line 2093 of file q3combobox.cpp.
References d, Q3ComboBoxData::ed, and QLineEdit::validator().
Here is the call graph for this function:

| void Q3ComboBox::setListBox | ( | Q3ListBox * | newListBox | ) | [virtual] |
Sets the combobox to use newListBox instead of the current list box or popup. As a side effect, it clears the combobox of its current contents.
Definition at line 2120 of file q3combobox.cpp.
References Q3ScrollView::AlwaysOff, QFrame::Box, clear(), QObject::connect(), d, QWidget::font(), highlighted(), internalActivate(), internalHighlight(), Q3ComboBoxData::listBox(), QWidget::palette(), QFrame::Plain, Q3ComboBoxData::popup(), Q3ScrollView::resize(), QWidget::setFont(), QFrame::setFrameStyle(), Q3ScrollView::setHScrollBarMode(), QFrame::setLineWidth(), Q3ComboBoxData::setListBox(), QWidget::setPalette(), Q3ComboBoxData::setPopupMenu(), Q3ScrollView::setVScrollBarMode(), SIGNAL, SLOT, and Q3ComboBoxData::usingListBox().
02121 { 02122 clear(); 02123 02124 if ( d->usingListBox() ) { 02125 delete d->listBox(); 02126 } else { 02127 delete d->popup(); 02128 d->setPopupMenu(0, false); 02129 } 02130 02131 newListBox->reparent( this, Qt::WType_Popup, QPoint(0,0), false ); 02132 d->setListBox( newListBox ); 02133 d->listBox()->setFont( font() ); 02134 d->listBox()->setPalette( palette() ); 02135 d->listBox()->setVScrollBarMode(Q3ScrollView::AlwaysOff); 02136 d->listBox()->setHScrollBarMode(Q3ScrollView::AlwaysOff); 02137 d->listBox()->setFrameStyle( Q3Frame::Box | Q3Frame::Plain ); 02138 d->listBox()->setLineWidth( 1 ); 02139 d->listBox()->resize( 100, 10 ); 02140 02141 connect( d->listBox(), SIGNAL(selected(int)), 02142 SLOT(internalActivate(int)) ); 02143 connect( d->listBox(), SIGNAL(highlighted(int)), 02144 SLOT(internalHighlight(int))); 02145 }
Here is the call graph for this function:

| Q3ListBox * Q3ComboBox::listBox | ( | ) | const |
Returns the current list box, or 0 if there is no list box. (Q3ComboBox can use QPopupMenu instead of QListBox.) Provided to match setListBox().
Definition at line 2156 of file q3combobox.cpp.
References d, Q3ComboBoxData::listBox(), and Q3ComboBoxData::usingListBox().
Referenced by hide(), Q3FileDialog::init(), internalActivate(), mousePressEvent(), and setCurrentItem().
02157 { 02158 return d && d->usingListBox() ? d->listBox() : 0; 02159 }
Here is the call graph for this function:

| void Q3ComboBox::setLineEdit | ( | QLineEdit * | edit | ) | [virtual] |
Sets the line edit to use edit instead of the current line edit.
Definition at line 2288 of file q3combobox.cpp.
References QObject::connect(), currentText(), d, Q3ComboBoxData::ed, QObject::installEventFilter(), QWidget::isVisible(), QObject::parent(), returnPressed(), QWidget::setFocusPolicy(), QWidget::setFocusProxy(), QLineEdit::setFrame(), QLineEdit::setText(), setUpListBox(), QWidget::show(), SIGNAL, SLOT, Qt::StrongFocus, textChanged(), QWidget::update(), QWidget::updateGeometry(), Q3ComboBoxData::updateLinedGeometry(), and Q3ComboBoxData::usingListBox().
Referenced by setUpLineEdit().
02289 { 02290 if ( !edit ) { 02291 #if defined(QT_CHECK_NULL) 02292 Q_ASSERT( edit != 0 ); 02293 #endif 02294 return; 02295 } 02296 02297 edit->setText( currentText() ); 02298 delete d->ed; 02299 d->ed = edit; 02300 02301 if ( edit->parent() != this ) 02302 edit->reparent( this, QPoint(0,0), false ); 02303 02304 connect (edit, SIGNAL(textChanged(QString)), 02305 this, SIGNAL(textChanged(QString)) ); 02306 connect( edit, SIGNAL(returnPressed()), SLOT(returnPressed()) ); 02307 02308 edit->setFrame( false ); 02309 d->updateLinedGeometry(); 02310 edit->installEventFilter( this ); 02311 setFocusProxy( edit ); 02312 setFocusPolicy(Qt::StrongFocus); 02313 setInputMethodEnabled( true ); 02314 02315 if ( !d->usingListBox() ) 02316 setUpListBox(); 02317 02318 if ( isVisible() ) 02319 edit->show(); 02320 02321 updateGeometry(); 02322 update(); 02323 }
Here is the call graph for this function:

| QLineEdit * Q3ComboBox::lineEdit | ( | ) | const |
Returns the line edit, or 0 if there is no line edit.
Only editable listboxes have a line editor.
Definition at line 2166 of file q3combobox.cpp.
References d, and Q3ComboBoxData::ed.
| void Q3ComboBox::setAutoCompletion | ( | bool | ) | [virtual] |
Definition at line 2211 of file q3combobox.cpp.
References Q3ComboBoxData::completeNow, d, and Q3ComboBoxData::useCompletion.
02212 { 02213 d->useCompletion = enable; 02214 d->completeNow = false; 02215 }
| bool Q3ComboBox::autoCompletion | ( | ) | const |
Definition at line 2218 of file q3combobox.cpp.
References d, and Q3ComboBoxData::useCompletion.
02219 { 02220 return d->useCompletion; 02221 }
Reimplemented from QObject.
Definition at line 1735 of file q3combobox.cpp.
References Qt::AltModifier, Q3ComboBoxData::arrowDown, Q3ComboBoxData::arrowPressed, QMouseEvent::button(), QStyle::CC_ComboBox, Q3ComboBoxData::completeAt, Q3ComboBoxData::completeNow, completionIndex(), QRect::contains(), Q3ComboBoxData::current, currentItem(), QLineEdit::cursorPosition(), d, Q3ComboBoxData::discardNextMousePress, Q3ComboBoxData::ed, QWidget::event(), QObject::eventFilter(), QEvent::FocusIn, focusInEvent(), QEvent::FocusOut, focusOutEvent(), Q3ComboBoxData::getStyleOption(), QMouseEvent::globalPos(), QEvent::Hide, i, int, internalHighlight(), QString::isNull(), key, Qt::Key_Down, Qt::Key_End, Qt::Key_Enter, Qt::Key_Escape, Qt::Key_F4, Qt::Key_Return, Qt::Key_Up, QEvent::KeyPress, keyPressEvent(), QEvent::KeyRelease, QWidget::keyReleaseEvent(), Qt::LeftButton, QString::length(), Q3ComboBoxData::listBox(), m, QWidget::mapFromGlobal(), QWidget::mapToGlobal(), Qt::MidButton, QEvent::MouseButtonDblClick, QEvent::MouseButtonPress, QEvent::MouseButtonRelease, QEvent::MouseMove, Q3ComboBoxData::mouseWasInsidePopup, Qt::NoButton, object, popDownListBox(), Q3ComboBoxData::poppedUp, Q3ComboBoxData::popup(), QMouseEvent::pos(), QWidget::pos(), QWidget::rect(), QObject::removeEventFilter(), QWidget::repaint(), Qt::RightButton, QStyle::SC_ComboBoxArrow, QCoreApplication::sendEvent(), QStyle::SH_ComboBox_ListMouseTracking, QStyle::SH_ComboBox_Popup, Q3ComboBoxData::shortClick, QWidget::style(), QStyle::styleHint(), QStyle::subControlRect(), QLineEdit::text(), text(), Q3ComboBoxData::useCompletion, Q3ComboBoxData::usingListBox(), Q3ScrollView::viewport(), and QApplication::widgetAt().
01736 { 01737 QStyleOptionComboBox opt = d->getStyleOption(); 01738 if ( !event ) 01739 return true; 01740 else if ( object == d->ed ) { 01741 if ( event->type() == QEvent::KeyPress ) { 01742 bool isAccepted = ( (QKeyEvent*)event )->isAccepted(); 01743 keyPressEvent( (QKeyEvent *)event ); 01744 if ( ((QKeyEvent *)event)->isAccepted() ) { 01745 d->completeNow = false; 01746 return true; 01747 } else if ( ((QKeyEvent *)event)->key() != Qt::Key_End ) { 01748 d->completeNow = true; 01749 d->completeAt = d->ed->cursorPosition(); 01750 } 01751 if ( isAccepted ) 01752 ( (QKeyEvent*)event )->accept(); 01753 else 01754 ( (QKeyEvent*)event )->ignore(); 01755 } else if ( event->type() == QEvent::KeyRelease ) { 01756 keyReleaseEvent( (QKeyEvent *)event ); 01757 return ((QKeyEvent *)event)->isAccepted(); 01758 } else if ( event->type() == QEvent::FocusIn ) { 01759 focusInEvent( (QFocusEvent *)event ); 01760 } else if ( event->type() == QEvent::FocusOut ) { 01761 focusOutEvent( (QFocusEvent *)event ); 01762 } else if ( d->useCompletion && d->completeNow ) { 01763 d->completeNow = false; 01764 if ( !d->ed->text().isNull() && 01765 d->ed->cursorPosition() > d->completeAt && 01766 d->ed->cursorPosition() == (int)d->ed->text().length() ) { 01767 QString ct( d->ed->text() ); 01768 int i = completionIndex( ct, currentItem() ); 01769 if ( i > -1 ) { 01770 QString it = text( i ); 01771 d->ed->validateAndSet( it, ct.length(), 01772 ct.length(), it.length() ); 01773 d->current = i; 01774 // ### sets current item without emitting signals. This is to 01775 // make sure the right item is current if you change current with 01776 // wheel/up/down. While typing current is not valid anyway. Fix properly 01777 // in 4.0. 01778 } 01779 } 01780 } 01781 } else if ( d->usingListBox() && ( object == d->listBox() || 01782 object == d->listBox()->viewport() )) { 01783 QMouseEvent *e = (QMouseEvent*)event; 01784 switch( event->type() ) { 01785 case QEvent::MouseMove: 01786 if ( !d->mouseWasInsidePopup ) { 01787 QPoint pos = e->pos(); 01788 if ( d->listBox()->rect().contains( pos ) ) 01789 d->mouseWasInsidePopup = true; 01790 // Check if arrow button should toggle 01791 if ( d->arrowPressed ) { 01792 QPoint comboPos; 01793 comboPos = mapFromGlobal( d->listBox()->mapToGlobal(pos) ); 01794 QRect arrowRect = style()->subControlRect(QStyle::CC_ComboBox, &opt, 01795 QStyle::SC_ComboBoxArrow, this); 01796 if ( arrowRect.contains( comboPos ) ) { 01797 if ( !d->arrowDown ) { 01798 d->arrowDown = true; 01799 repaint( false ); 01800 } 01801 } else { 01802 if ( d->arrowDown ) { 01803 d->arrowDown = false; 01804 repaint( false ); 01805 } 01806 } 01807 } 01808 } else if ((e->state() & ( Qt::RightButton | Qt::LeftButton | Qt::MidButton ) ) == 0 && 01809 style()->styleHint(QStyle::SH_ComboBox_ListMouseTracking, &opt, this)) { 01810 QWidget *mouseW = QApplication::widgetAt( e->globalPos(), true ); 01811 if ( mouseW == d->listBox()->viewport() ) { //### 01812 QMouseEvent m( QEvent::MouseMove, e->pos(), e->globalPos(), 01813 Qt::NoButton, Qt::LeftButton ); 01814 QApplication::sendEvent( object, &m ); //### Evil 01815 return true; 01816 } 01817 } 01818 01819 break; 01820 case QEvent::MouseButtonRelease: 01821 if ( d->listBox()->rect().contains( e->pos() ) ) { 01822 QMouseEvent tmp( QEvent::MouseButtonDblClick, 01823 e->pos(), e->button(), e->state() ) ; 01824 // will hide popup 01825 QApplication::sendEvent( object, &tmp ); 01826 return true; 01827 } else { 01828 if ( d->mouseWasInsidePopup ) { 01829 popDownListBox(); 01830 } else { 01831 d->arrowPressed = false; 01832 if ( d->arrowDown ) { 01833 d->arrowDown = false; 01834 repaint( false ); 01835 } 01836 } 01837 } 01838 break; 01839 case QEvent::MouseButtonDblClick: 01840 case QEvent::MouseButtonPress: 01841 if ( !d->listBox()->rect().contains( e->pos() ) ) { 01842 QPoint globalPos = d->listBox()->mapToGlobal(e->pos()); 01843 if ( QApplication::widgetAt( globalPos, true ) == this ) { 01844 d->discardNextMousePress = true; 01845 // avoid popping up again 01846 } 01847 popDownListBox(); 01848 return true; 01849 } 01850 break; 01851 case QEvent::KeyPress: 01852 switch( ((QKeyEvent *)event)->key() ) { 01853 case Qt::Key_Up: 01854 case Qt::Key_Down: 01855 if ( !(((QKeyEvent *)event)->state() & Qt::AltModifier) ) 01856 break; 01857 case Qt::Key_F4: 01858 case Qt::Key_Escape: 01859 if ( d->poppedUp ) { 01860 popDownListBox(); 01861 return true; 01862 } 01863 break; 01864 case Qt::Key_Enter: 01865 case Qt::Key_Return: 01866 // work around QDialog's enter handling 01867 return false; 01868 default: 01869 break; 01870 } 01871 break; 01872 case QEvent::Hide: 01873 popDownListBox(); 01874 break; 01875 default: 01876 break; 01877 } 01878 } else if ( (!d->usingListBox() || style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, this)) && 01879 object == d->popup() ) { 01880 QMouseEvent *e = (QMouseEvent*)event; 01881 switch ( event->type() ) { 01882 case QEvent::MouseButtonRelease: 01883 if ( d->shortClick ) { 01884 QMouseEvent tmp( QEvent::MouseMove, 01885 e->pos(), e->button(), e->state() ) ; 01886 // highlight item, but don't pop down: 01887 QApplication::sendEvent( object, &tmp ); 01888 return true; 01889 } 01890 break; 01891 case QEvent::MouseButtonDblClick: 01892 case QEvent::MouseButtonPress: 01893 if ( !d->popup()->rect().contains( e->pos() ) ) { 01894 d->poppedUp = false; 01895 d->arrowDown = false; 01896 // remove filter, event will take down popup: 01897 d->popup()->removeEventFilter( this ); 01898 // ### uglehack! 01899 // call internalHighlight so the highlighed signal 01900 // will be emitted at least as often as necessary. 01901 // it may be called more often than necessary 01902 internalHighlight( d->current ); 01903 } 01904 break; 01905 case QEvent::Hide: 01906 d->poppedUp = false; 01907 break; 01908 default: 01909 break; 01910 } 01911 } 01912 return QWidget::eventFilter( object, event ); 01913 }
Here is the call graph for this function:

| void Q3ComboBox::setDuplicatesEnabled | ( | bool | enable | ) |
Definition at line 600 of file q3combobox.cpp.
References d, and Q3ComboBoxData::duplicatesEnabled.
Referenced by Q3FileDialog::init().
00601 { 00602 d->duplicatesEnabled = enable; 00603 }
| bool Q3ComboBox::duplicatesEnabled | ( | ) | const |
Definition at line 605 of file q3combobox.cpp.
References d, and Q3ComboBoxData::duplicatesEnabled.
00606 { 00607 return d->duplicatesEnabled; 00608 }
| bool Q3ComboBox::editable | ( | ) | const |
Definition at line 2233 of file q3combobox.cpp.
References d, and Q3ComboBoxData::ed.
Referenced by Q3ComboBoxData::getStyleOption(), mousePressEvent(), Q3ComboTableItem::paint(), popup(), and setEditable().
| void Q3ComboBox::setEditable | ( | bool | ) |
Definition at line 2238 of file q3combobox.cpp.
References currentItem(), currentText(), d, Q3ComboBoxData::ed, editable(), setEditText(), QWidget::setFocusPolicy(), setUpLineEdit(), setUpListBox(), QWidget::show(), Qt::StrongFocus, QWidget::update(), QWidget::updateGeometry(), and Q3ComboBoxData::usingListBox().
02239 { 02240 if ( y == editable() ) 02241 return; 02242 if ( y ) { 02243 if ( !d->usingListBox() ) 02244 setUpListBox(); 02245 setUpLineEdit(); 02246 d->ed->show(); 02247 if ( currentItem() ) 02248 setEditText( currentText() ); 02249 } else { 02250 delete d->ed; 02251 d->ed = 0; 02252 } 02253 02254 setFocusPolicy(Qt::StrongFocus); 02255 updateGeometry(); 02256 update(); 02257 }
Here is the call graph for this function:

| void Q3ComboBox::popup | ( | ) | [virtual] |
Pops up the combobox popup list.
If the list is empty, no items appear.
Definition at line 1550 of file q3combobox.cpp.
References activated(), Q3ScrollView::Auto, QDesktopWidget::availableGeometry(), QObject::blockSignals(), QStyle::CC_ComboBox, QMenu::clear(), QObject::connect(), Q3ScrollView::contentsX(), Q3ListBox::count(), count(), Q3ComboBoxData::current, currentItem(), currentText(), d, QApplication::desktop(), editable(), escapedComboString(), Q3ListBox::findItem(), QWidget::font(), Q3ComboBoxData::getStyleOption(), h, QWidget::height(), QRect::height(), highlighted(), i, QObject::installEventFilter(), internalActivate(), internalHighlight(), QApplication::isEffectEnabled(), QRect::isNull(), Q3ListBoxItem::isSelectable(), Q3ListBoxItem::isSelected(), Q3ListBox::item(), Q3ListBox::itemRect(), Q3ComboBoxData::listBox(), listHeight(), QWidget::mapToGlobal(), Q3ComboBoxData::mouseWasInsidePopup, p, Q3ComboBoxData::poppedUp, QMenu::popup(), Q3ComboBoxData::popup(), QWidget::pos(), qScrollEffect(), QWidget::raise(), QStyleOption::rect, QWidget::rect(), Q3ListBoxText::RTTI, Q3ListBoxPixmap::RTTI, QStyle::SC_ComboBoxListBoxPopup, Q3ScrollView::setContentsPos(), Q3ListBox::setCurrentItem(), QWidget::setGeometry(), Q3ComboBoxData::setPopupMenu(), QRect::setRect(), Q3ListBox::setSelected(), Q3ScrollView::setVScrollBarMode(), QStyle::SH_ComboBox_Popup, QWidget::show(), SIGNAL, QObject::signalsBlocked(), Q3ListBox::sizeHint(), Q3ComboBoxData::sizeLimit, SLOT, QWidget::style(), QStyle::styleHint(), QStyle::subControlRect(), text(), QRect::topLeft(), Q3ListBox::triggerUpdate(), Qt::UI_AnimateCombo, QWidget::update(), QEffects::UpScroll, Q3ComboBoxData::usingListBox(), Q3ListBox::variableWidth(), Q3ScrollView::viewportToContents(), w, QRect::width(), QSize::width(), QWidget::width(), QRect::x(), QPoint::x(), QWidget::x(), QRect::y(), QPoint::y(), and QWidget::y().
Referenced by keyPressEvent(), and mousePressEvent().
01551 { 01552 if ( !count() || d->poppedUp ) 01553 return; 01554 01555 QStyleOptionComboBox opt = d->getStyleOption(); 01556 if( !d->usingListBox() || style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, this) ) { 01557 if(d->usingListBox()) { 01558 if(!d->popup()) { 01559 Q3ComboBoxPopup *p = new Q3ComboBoxPopup( this, "in-combo" ); 01560 d->setPopupMenu( p, false ); 01561 p->setFont( font() ); 01562 connect( p, SIGNAL(activated(int)), SLOT(internalActivate(int)) ); 01563 connect( p, SIGNAL(highlighted(int)), SLOT(internalHighlight(int)) ); 01564 } 01565 d->popup()->clear(); 01566 for(unsigned int i = 0; i < d->listBox()->count(); i++) { 01567 Q3ListBoxItem *item = d->listBox()->item(i); 01568 if(item->rtti() == Q3ListBoxText::RTTI) { 01569 d->popup()->insertItem(escapedComboString(item->text()), i, i); 01570 } else if(item->rtti() == Q3ListBoxPixmap::RTTI) { 01571 if(item->pixmap()) 01572 d->popup()->insertItem(QIcon(*item->pixmap()), escapedComboString(item->text()), i, i); 01573 else 01574 d->popup()->insertItem(escapedComboString(item->text()), i, i); 01575 } else { 01576 d->popup()->insertItem(new Q3ComboBoxPopupItem(item), i, i); 01577 } 01578 } 01579 } 01580 d->popup()->installEventFilter( this ); 01581 if(d->popup() && style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, this)) 01582 d->popup()->setItemChecked(this->d->current, true); 01583 d->popup()->popup( mapToGlobal( QPoint(0,0) ), this->d->current ); 01584 update(); 01585 } else { 01586 // Send all listbox events to eventFilter(): 01587 Q3ListBox* lb = d->listBox(); 01588 lb->triggerUpdate( true ); 01589 lb->installEventFilter( this ); 01590 d->mouseWasInsidePopup = false; 01591 int w = lb->variableWidth() ? lb->sizeHint().width() : width(); 01592 int h = listHeight( lb, d->sizeLimit ) + 2; 01593 QRect screen = QApplication::desktop()->availableGeometry( this ); 01594 01595 int sx = screen.x(); // screen pos 01596 int sy = screen.y(); 01597 int sw = screen.width(); // screen width 01598 int sh = screen.height(); // screen height 01599 QPoint pos = mapToGlobal( QPoint(0,height()) ); 01600 // ## Similar code is in QPopupMenu 01601 int x = pos.x(); 01602 int y = pos.y(); 01603 01604 // the complete widget must be visible 01605 if ( x + w > sx + sw ) 01606 x = sx+sw - w; 01607 if ( x < sx ) 01608 x = sx; 01609 if (y + h > sy+sh && y - h - height() >= 0 ) 01610 y = y - h - height(); 01611 01612 opt.rect = QRect(x, y, w, h); 01613 QRect rect = style()->subControlRect(QStyle::CC_ComboBox, &opt, 01614 QStyle::SC_ComboBoxListBoxPopup, this); 01615 01616 // work around older styles that don't implement the combobox 01617 // listbox popup subcontrol 01618 if ( rect.isNull() ) 01619 rect.setRect( x, y, w, h ); 01620 lb->setGeometry( rect ); 01621 01622 lb->raise(); 01623 bool block = lb->signalsBlocked(); 01624 lb->blockSignals( true ); 01625 Q3ListBoxItem* currentLBItem = 0; 01626 if ( editable() && currentText() != text( currentItem() ) ) 01627 currentLBItem = lb->findItem( currentText() ); 01628 01629 currentLBItem = currentLBItem ? currentLBItem : lb->item( d->current ); 01630 01631 lb->setCurrentItem( currentLBItem ); 01632 lb->setContentsPos( lb->contentsX(), 01633 lb->viewportToContents( lb->itemRect( currentLBItem ).topLeft() ).y() ); 01634 01635 // set the current item to also be the selected item if it isn't already 01636 if ( currentLBItem && currentLBItem->isSelectable() && !currentLBItem->isSelected() ) 01637 lb->setSelected( currentLBItem, true ); 01638 lb->blockSignals( block ); 01639 lb->setVScrollBarMode(Q3ScrollView::Auto); 01640 01641 #ifndef QT_NO_EFFECTS 01642 if ( QApplication::isEffectEnabled( Qt::UI_AnimateCombo ) ) { 01643 if ( lb->y() < mapToGlobal(QPoint(0,0)).y() ) 01644 qScrollEffect( lb, QEffects::UpScroll ); 01645 else 01646 qScrollEffect( lb ); 01647 } else 01648 #endif 01649 lb->show(); 01650 } 01651 d->poppedUp = true; 01652 }
Here is the call graph for this function:

| void Q3ComboBox::hide | ( | ) |
Hides the combobox.
Reimplemented from QWidget.
Definition at line 2330 of file q3combobox.cpp.
References d, QWidget::hide(), listBox(), and Q3ComboBoxData::popup().
Referenced by Q3ComboTableItem::Q3ComboTableItem().
02331 { 02332 QWidget::hide(); 02333 02334 if (listBox()) 02335 listBox()->hide(); 02336 else if (d->popup()) 02337 d->popup()->hide(); 02338 }
Here is the call graph for this function:

| void Q3ComboBox::clear | ( | ) | [slot] |
Removes all combobox items.
Definition at line 894 of file q3combobox.cpp.
References QMenu::clear(), Q3ListBox::clear(), Q3ComboBoxData::current, currentChanged(), d, Q3ComboBoxData::ed, QString::fromLatin1(), Q3ComboBoxData::getStyleOption(), Q3ComboBoxData::listBox(), Q3ComboBoxData::popup(), Q3ScrollView::resize(), QLineEdit::setText(), QStyle::SH_ComboBox_Popup, QWidget::style(), QStyle::styleHint(), styleHint(), Q3ComboBoxData::updateLinedGeometry(), and Q3ComboBoxData::usingListBox().
Referenced by setListBox(), and Q3ComboTableItem::setStringList().
00895 { 00896 QStyleOptionComboBox opt = d->getStyleOption(); 00897 if ( d->usingListBox() ) { 00898 if ( style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, this) && d->popup() ) 00899 d->popup()->clear(); 00900 d->listBox()->resize( 0, 0 ); 00901 d->listBox()->clear(); 00902 } else { 00903 d->popup()->clear(); 00904 } 00905 00906 if(d->popup() && style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, this)) 00907 d->popup()->setItemChecked(d->current, false); 00908 d->current = 0; 00909 if ( d->ed ) { 00910 d->ed->setText( QString::fromLatin1("") ); 00911 d->updateLinedGeometry(); 00912 } 00913 currentChanged(); 00914 }
| void Q3ComboBox::clearValidator | ( | ) | [slot] |
This slot is equivalent to setValidator( 0 ).
Definition at line 2103 of file q3combobox.cpp.
References d, Q3ComboBoxData::ed, and QLineEdit::setValidator().
| void Q3ComboBox::clearEdit | ( | ) | [slot] |
Clears the line edit without changing the combobox's contents. Does nothing if the combobox isn't editable.
This is particularly useful when using a combobox as a line edit with history. For example you can connect the combobox's activated() signal to clearEdit() in order to present the user with a new, empty line as soon as Enter is pressed.
Definition at line 2185 of file q3combobox.cpp.
References QLineEdit::clear(), d, and Q3ComboBoxData::ed.
| void Q3ComboBox::setEditText | ( | const QString & | newText | ) | [virtual, slot] |
Sets the text in the line edit to newText without changing the combobox's contents. Does nothing if the combobox isn't editable.
This is useful e.g. for providing a good starting point for the user's editing and entering the change in the combobox only when the user presses Enter.
Definition at line 2203 of file q3combobox.cpp.
References d, Q3ComboBoxData::ed, QLineEdit::setText(), and Q3ComboBoxData::updateLinedGeometry().
Referenced by setEditable().
02204 { 02205 if ( d && d->ed ) { 02206 d->updateLinedGeometry(); 02207 d->ed->setText( newText ); 02208 } 02209 }
| void Q3ComboBox::activated | ( | int | index | ) | [signal] |
This signal is emitted when a new item has been activated (selected). The index is the position of the item in the combobox.
This signal is not emitted if the item is changed programmatically, e.g. using setCurrentItem().
Referenced by internalActivate(), keyPressEvent(), popup(), Q3ComboBox(), returnPressed(), and wheelEvent().
| void Q3ComboBox::highlighted | ( | int | index | ) | [signal] |
This signal is emitted when a new item has been set to be the current item. The index is the position of the item in the combobox.
This signal is not emitted if the item is changed programmatically, e.g. using setCurrentItem().
Referenced by internalHighlight(), popup(), Q3ComboBox(), setListBox(), and setUpListBox().
| void Q3ComboBox::activated | ( | const QString & | string | ) | [signal] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This signal is emitted when a new item has been activated (selected). string is the selected string.
You can also use the activated(int) signal, but be aware that its argument is meaningful only for selected strings, not for user entered strings.
| void Q3ComboBox::highlighted | ( | const QString & | string | ) | [signal] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This signal is emitted when a new item has been set to be the current item. string is the item's text.
You can also use the highlighted(int) signal.
| void Q3ComboBox::textChanged | ( | const QString & | string | ) | [signal] |
This signal is used for editable comboboxes. It is emitted whenever the contents of the text entry field changes. string contains the new text.
Referenced by setLineEdit().
| void Q3ComboBox::internalActivate | ( | int | ) | [private, slot] |
Definition at line 1153 of file q3combobox.cpp.
References activated(), Q3ComboBoxData::current, currentChanged(), d, Q3ComboBoxData::ed, emit, Q3ComboBoxData::getStyleOption(), Q3ListBoxItem::isSelectable(), Q3ListBox::item(), listBox(), popDownListBox(), Q3ComboBoxData::poppedUp, Q3ComboBoxData::popup(), QObject::removeEventFilter(), QLineEdit::setText(), QStyle::SH_ComboBox_Popup, QWidget::style(), QStyle::styleHint(), t, text(), Q3ComboBoxData::updateLinedGeometry(), and Q3ComboBoxData::usingListBox().
Referenced by popup(), Q3ComboBox(), setListBox(), and setUpListBox().
01154 { 01155 QStyleOptionComboBox opt = d->getStyleOption(); 01156 if ( d->current != index ) { 01157 if ( !d->usingListBox() || listBox()->item( index )->isSelectable() ) { 01158 if (d->popup() && style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, this)) 01159 d->popup()->setItemChecked(d->current, false); 01160 d->current = index; 01161 currentChanged(); 01162 } 01163 } 01164 if ( d->usingListBox() ) 01165 popDownListBox(); 01166 else 01167 d->popup()->removeEventFilter( this ); 01168 d->poppedUp = false; 01169 01170 QString t( text( index ) ); 01171 if ( d->ed ) { 01172 d->ed->setText( t ); 01173 d->updateLinedGeometry(); 01174 } 01175 emit activated( index ); 01176 emit activated( t ); 01177 }
| void Q3ComboBox::internalHighlight | ( | int | ) | [private, slot] |
Definition at line 1185 of file q3combobox.cpp.
References emit, highlighted(), t, and text().
Referenced by eventFilter(), popup(), Q3ComboBox(), setCurrentItem(), setListBox(), and setUpListBox().
01186 { 01187 emit highlighted( index ); 01188 QString t = text( index ); 01189 if ( !t.isNull() ) 01190 emit highlighted( t ); 01191 }
| void Q3ComboBox::internalClickTimeout | ( | ) | [private, slot] |
Definition at line 1198 of file q3combobox.cpp.
References d, and Q3ComboBoxData::shortClick.
Referenced by mousePressEvent().
01199 { 01200 d->shortClick = false; 01201 }
| void Q3ComboBox::returnPressed | ( | ) | [private, slot] |
Internal slot to keep the line editor up to date.
Definition at line 1987 of file q3combobox.cpp.
References activated(), c, changeItem(), count(), currentItem(), d, Q3ComboBoxData::duplicatesEnabled, Q3ComboBoxData::ed, emit, i, InsertAfterCurrent, InsertAtBottom, InsertAtCurrent, InsertAtTop, InsertBeforeCurrent, insertionPolicy(), insertItem(), Q3ComboBoxData::maxCount, NoInsert, removeItem(), s, setCurrentItem(), QLineEdit::text(), and text().
Referenced by setLineEdit().
01988 { 01989 QString s( d->ed->text() ); 01990 01991 if ( s.isEmpty() ) 01992 return; 01993 01994 int c = 0; 01995 bool doInsert = true; 01996 if ( !d->duplicatesEnabled ) { 01997 for ( int i = 0; i < count(); ++i ) { 01998 if ( s == text( i ) ) { 01999 doInsert = false; 02000 c = i; 02001 break; 02002 } 02003 } 02004 } 02005 02006 if ( doInsert ) { 02007 if ( insertionPolicy() != NoInsert ) { 02008 int cnt = count(); 02009 while ( cnt >= d->maxCount ) { 02010 removeItem( --cnt ); 02011 } 02012 } 02013 02014 switch ( insertionPolicy() ) { 02015 case InsertAtCurrent: 02016 if (count() == 0) 02017 insertItem(s); 02018 else if ( s != text( currentItem() ) ) 02019 changeItem( s, currentItem() ); 02020 emit activated( currentItem() ); 02021 emit activated( s ); 02022 return; 02023 case NoInsert: 02024 emit activated( s ); 02025 return; 02026 case InsertAtTop: 02027 c = 0; 02028 break; 02029 case InsertAtBottom: 02030 c = count(); 02031 break; 02032 case InsertBeforeCurrent: 02033 c = currentItem(); 02034 break; 02035 case InsertAfterCurrent: 02036 c = count() == 0 ? 0 : currentItem() + 1; 02037 break; 02038 } 02039 insertItem( s, c ); 02040 } 02041 02042 setCurrentItem( c ); 02043 emit activated( c ); 02044 emit activated( s ); 02045 }
| void Q3ComboBox::paintEvent | ( | QPaintEvent * | ) | [protected, virtual] |
Reimplemented from QWidget.
Definition at line 1252 of file q3combobox.cpp.
References Qt::AlignCenter, QFontMetrics::ascent(), Base, QStyle::CC_ComboBox, Q3ComboBoxData::current, d, QStyle::drawComplexControl(), Q3ComboBoxData::ed, QWidget::font(), g, Q3ComboBoxData::getStyleOption(), QWidget::hasFocus(), Q3ListBoxItem::height(), QWidget::height(), QPixmap::height(), QRect::height(), QIcon::isNull(), QPixmap::isNull(), QString::isNull(), Q3ListBox::item(), Q3ComboBoxData::listBox(), p, Q3ListBoxItem::paint(), QIcon::pixmap(), Q3ListBoxItem::pixmap(), QStyle::PM_DefaultFrameWidth, Q3ComboBoxData::popup(), qDrawShadePanel(), QWidget::rect(), reverse(), QStyle::SC_ComboBoxEditField, QWidget::style(), QStyle::styleHint(), QStyle::subControlRect(), Qt::TextSingleLine, Q3ComboBoxData::usingListBox(), w, QPixmap::width(), QWidget::width(), QRect::x(), QWidget::x(), QRect::y(), and QWidget::y().
01253 { 01254 QPainter p( this ); 01255 const QColorGroup & g = colorGroup(); 01256 p.setPen(g.text()); 01257 01258 if ( width() < 5 || height() < 5 ) { 01259 qDrawShadePanel( &p, rect(), g, false, 2, 01260 &g.brush( QColorGroup::Button ) ); 01261 return; 01262 } 01263 01264 QStyleOptionComboBox opt = d->getStyleOption(); 01265 bool reverse = QApplication::reverseLayout(); 01266 if ( !d->usingListBox() && 01267 style()->styleHint(QStyle::SH_GUIStyle) == Qt::MotifStyle) { // motif 1.x style 01268 int dist, buttonH, buttonW; 01269 dist = 8; 01270 buttonH = 7; 01271 buttonW = 11; 01272 int xPos; 01273 int x0; 01274 int w = width() - dist - buttonW - 1; 01275 if ( reverse ) { 01276 xPos = dist + 1; 01277 x0 = xPos + 4; 01278 } else { 01279 xPos = w; 01280 x0 = 4; 01281 } 01282 qDrawShadePanel( &p, rect(), g, false, 01283 style()->pixelMetric(QStyle::PM_DefaultFrameWidth, &opt, this), 01284 &g.brush( QColorGroup::Button ) ); 01285 qDrawShadePanel( &p, xPos, (height() - buttonH)/2, 01286 buttonW, buttonH, g, false, 01287 style()->pixelMetric(QStyle::PM_DefaultFrameWidth, &opt, this) ); 01288 QRect clip( x0, 2, w - 2 - 4 - 5, height() - 4 ); 01289 QString str = d->popup()->text( this->d->current ); 01290 if ( !str.isNull() ) { 01291 p.drawText( clip, Qt::AlignCenter | Qt::TextSingleLine, str ); 01292 } 01293 01294 QPixmap pix = d->popup()->pixmap( this->d->current ); 01295 QIcon iconSet = d->popup()->iconSet( this->d->current ); 01296 if (!pix.isNull() || !iconSet.isNull()) { 01297 QPixmap pm = ( !pix.isNull() ? pix : iconSet.pixmap() ); 01298 p.setClipRect( clip ); 01299 p.drawPixmap( 4, (height()-pm.height())/2, pm ); 01300 p.setClipping( false ); 01301 } 01302 01303 if ( hasFocus() ) 01304 p.drawRect( xPos - 5, 4, width() - xPos + 1 , height() - 8 ); 01305 } else if(!d->usingListBox()) { 01306 style()->drawComplexControl(QStyle::CC_ComboBox, &opt, &p, this); 01307 QRect re = style()->subControlRect(QStyle::CC_ComboBox, &opt, 01308 QStyle::SC_ComboBoxEditField, this); 01309 p.setClipRect( re ); 01310 01311 QString str = d->popup()->text( this->d->current ); 01312 QPixmap pix = d->popup()->pixmap( this->d->current ); 01313 if ( !str.isNull() ) { 01314 p.save(); 01315 p.setFont(font()); 01316 QFontMetrics fm(font()); 01317 int x = re.x(), y = re.y() + fm.ascent(); 01318 x += pix.width() + 5; 01319 p.drawText( x, y, str ); 01320 p.restore(); 01321 } 01322 if (!pix.isNull()) { 01323 p.fillRect(re.x(), re.y(), pix.width() + 4, re.height(), 01324 colorGroup().brush(QColorGroup::Base)); 01325 p.drawPixmap(re.x() + 2, re.y() + (re.height() - pix.height()) / 2, pix); 01326 } 01327 } else { 01328 style()->drawComplexControl(QStyle::CC_ComboBox, &opt, &p, this); 01329 QRect re = style()->subControlRect(QStyle::CC_ComboBox, &opt, 01330 QStyle::SC_ComboBoxEditField, this); 01331 p.setClipRect(re); 01332 01333 if ( !d->ed ) { 01334 Q3ListBoxItem * item = d->listBox()->item( d->current ); 01335 if ( item ) { 01336 int itemh = item->height( d->listBox() ); 01337 p.translate( re.x(), re.y() + (re.height() - itemh)/2 ); 01338 item->paint( &p ); 01339 } 01340 } else if ( d->listBox() && d->listBox()->item( d->current ) ) { 01341 Q3ListBoxItem * item = d->listBox()->item( d->current ); 01342 const QPixmap *pix = item->pixmap(); 01343 if ( pix ) { 01344 p.fillRect( re.x(), re.y(), pix->width() + 4, re.height(), 01345 colorGroup().brush( QColorGroup::Base ) ); 01346 p.drawPixmap( re.x() + 2, re.y() + 01347 ( re.height() - pix->height() ) / 2, *pix ); 01348 } 01349 } 01350 p.setClipping( false ); 01351 } 01352 }
Here is the call graph for this function:

| void Q3ComboBox::resizeEvent | ( | QResizeEvent * | e | ) | [protected, virtual] |
Reimplemented from QWidget.
Definition at line 1240 of file q3combobox.cpp.
References d, Q3ComboBoxData::ed, QWidget::height(), Q3ComboBoxData::listBox(), Q3ScrollView::resize(), QWidget::resizeEvent(), Q3ComboBoxData::updateLinedGeometry(), and QWidget::width().
01241 { 01242 if ( d->ed ) 01243 d->updateLinedGeometry(); 01244 if ( d->listBox() ) 01245 d->listBox()->resize( width(), d->listBox()->height() ); 01246 QWidget::resizeEvent( e ); 01247 }
Here is the call graph for this function:

| void Q3ComboBox::mousePressEvent | ( | QMouseEvent * | e | ) | [protected, virtual] |
Reimplemented from QWidget.
Definition at line 1358 of file q3combobox.cpp.
References Q3ComboBoxData::arrowDown, Q3ComboBoxData::arrowPressed, QObject::blockSignals(), QMouseEvent::button(), QStyle::CC_ComboBox, QRect::contains(), count(), Q3ComboBoxData::current, d, Q3ComboBoxData::discardNextMousePress, editable(), Q3ComboBoxData::getStyleOption(), QWidget::height(), QRect::height(), internalClickTimeout(), Qt::LeftButton, listBox(), popup(), QMouseEvent::pos(), qApp, QWidget::repaint(), QStyle::SC_ComboBoxArrow, Q3ListBox::setCurrentItem(), QRect::setHeight(), Q3ComboBoxData::shortClick, QTimer::singleShot(), SLOT, QWidget::style(), QStyle::subControlRect(), Q3ComboBoxData::usingListBox(), and QRect::y().
Referenced by mouseDoubleClickEvent().
01359 { 01360 if ( e->button() != Qt::LeftButton ) 01361 return; 01362 if ( d->discardNextMousePress ) { 01363 d->discardNextMousePress = false; 01364 return; 01365 } 01366 01367 QStyleOptionComboBox opt = d->getStyleOption(); 01368 QRect arrowRect = style()->subControlRect(QStyle::CC_ComboBox, &opt, QStyle::SC_ComboBoxArrow 01369 , this); 01370 01371 // Correction for motif style, where arrow is smaller 01372 // and thus has a rect that doesn't fit the button. 01373 arrowRect.setHeight( QMAX( height() - (2 * arrowRect.y()), arrowRect.height() ) ); 01374 01375 if ( count() && ( !editable() || arrowRect.contain