An extended QComboBox with checkable items. More...
#include <qxtcheckcombobox.h>
Public Slots | |
void | setCheckedItems (const QStringList &items) |
Signals | |
void | checkedItemsChanged (const QStringList &items) |
Public Member Functions | |
QxtCheckComboBox (QWidget *parent=0) | |
virtual | ~QxtCheckComboBox () |
virtual void | hidePopup () |
QString | defaultText () const |
void | setDefaultText (const QString &text) |
Qt::CheckState | itemCheckState (int index) const |
void | setItemCheckState (int index, Qt::CheckState state) |
QString | separator () const |
void | setSeparator (const QString &separator) |
QStringList | checkedItems () const |
Properties | |
QString | separator |
This property holds the default separator. | |
QString | defaultText |
This property holds the default text. | |
QStringList | checkedItems |
This property holds the checked items. | |
Friends | |
class | QxtCheckComboBoxPrivate |
An extended QComboBox with checkable items.
QxtComboBox is a specialized combo box with checkable items. Checked items are collected together in the line edit.
QxtCheckComboBox in Plastique style.
Definition at line 35 of file qxtcheckcombobox.h.
QxtCheckComboBox::QxtCheckComboBox | ( | QWidget * | parent = 0 ) |
[explicit] |
Constructs a new QxtCheckComboBox with parent.
Definition at line 162 of file qxtcheckcombobox.cpp.
References QXT_INIT_PRIVATE.
: QComboBox(parent) { QXT_INIT_PRIVATE(QxtCheckComboBox); setModel(new QxtCheckComboModel(this)); connect(this, SIGNAL(activated(int)), &qxt_d(), SLOT(toggleCheckState(int))); connect(model(), SIGNAL(checkStateChanged()), &qxt_d(), SLOT(updateCheckedItems())); connect(model(), SIGNAL(rowsInserted(const QModelIndex &, int, int)), &qxt_d(), SLOT(updateCheckedItems())); connect(model(), SIGNAL(rowsRemoved(const QModelIndex &, int, int)), &qxt_d(), SLOT(updateCheckedItems())); // read-only contents QLineEdit* lineEdit = new QLineEdit(this); lineEdit->setReadOnly(true); setLineEdit(lineEdit); setInsertPolicy(QComboBox::NoInsert); view()->installEventFilter(&qxt_d()); view()->window()->installEventFilter(&qxt_d()); view()->viewport()->installEventFilter(&qxt_d()); this->installEventFilter(&qxt_d()); }
QxtCheckComboBox::~QxtCheckComboBox | ( | ) | [virtual] |
QStringList QxtCheckComboBox::checkedItems | ( | ) | const |
QxtCheckComboBox::checkedItemsChanged | ( | const QStringList & | items ) | [signal] |
This signal is emitted whenever the checked items have been changed.
Referenced by QxtCheckComboBoxPrivate::updateCheckedItems().
QString QxtCheckComboBox::defaultText | ( | ) | const |
Referenced by setDefaultText().
void QxtCheckComboBox::hidePopup | ( | ) | [virtual] |
Definition at line 193 of file qxtcheckcombobox.cpp.
{ if (qxt_d().containerMousePress) QComboBox::hidePopup(); }
Qt::CheckState QxtCheckComboBox::itemCheckState | ( | int | index ) | const |
Returns the check state of the item at index.
Definition at line 202 of file qxtcheckcombobox.cpp.
{ return static_cast<Qt::CheckState>(itemData(index, Qt::CheckStateRole).toInt()); }
QString QxtCheckComboBox::separator | ( | ) | const |
Referenced by setSeparator().
void QxtCheckComboBox::setCheckedItems | ( | const QStringList & | items ) | [slot] |
Definition at line 232 of file qxtcheckcombobox.cpp.
References setItemCheckState().
{ // not the most efficient solution but most likely nobody // will put too many items into a combo box anyway so... foreach(const QString& text, items) { const int index = findText(text); setItemCheckState(index, index != -1 ? Qt::Checked : Qt::Unchecked); } }
void QxtCheckComboBox::setDefaultText | ( | const QString & | text ) |
Definition at line 255 of file qxtcheckcombobox.cpp.
References defaultText().
{ if (qxt_d().defaultText != text) { qxt_d().defaultText = text; qxt_d().updateCheckedItems(); } }
void QxtCheckComboBox::setItemCheckState | ( | int | index, |
Qt::CheckState | state | ||
) |
Sets the check state of the item at index to state.
Definition at line 210 of file qxtcheckcombobox.cpp.
Referenced by setCheckedItems().
{ setItemData(index, state, Qt::CheckStateRole); }
void QxtCheckComboBox::setSeparator | ( | const QString & | separator ) |
Definition at line 276 of file qxtcheckcombobox.cpp.
References separator().
friend class QxtCheckComboBoxPrivate [friend] |
Definition at line 38 of file qxtcheckcombobox.h.
QStringList QxtCheckComboBox::checkedItems [read, write] |
This property holds the checked items.
Definition at line 41 of file qxtcheckcombobox.h.
Referenced by QxtCheckComboBoxPrivate::updateCheckedItems().
QString QxtCheckComboBox::defaultText [read, write] |
This property holds the default text.
The default text is shown when there are no checked items. The default value is an empty string.
Definition at line 40 of file qxtcheckcombobox.h.
QString QxtCheckComboBox::separator [read, write] |
This property holds the default separator.
The checked items are joined together with the separator string. The default value is a comma (",").
Definition at line 38 of file qxtcheckcombobox.h.