Public Slots | Public Member Functions | Public Attributes | Friends

QxtCheckComboBoxPrivate Class Reference

#include <qxtcheckcombobox_p.h>

Inheritance diagram for QxtCheckComboBoxPrivate:
Inheritance graph
[legend]
Collaboration diagram for QxtCheckComboBoxPrivate:
Collaboration graph
[legend]

List of all members.

Public Slots

void updateCheckedItems ()
void toggleCheckState (int index)

Public Member Functions

 QxtCheckComboBoxPrivate ()
bool eventFilter (QObject *receiver, QEvent *event)

Public Attributes

QString separator
QString defaultText
bool containerMousePress

Friends

class QxtCheckComboBox

Detailed Description

Definition at line 48 of file qxtcheckcombobox_p.h.


Constructor & Destructor Documentation

QxtCheckComboBoxPrivate::QxtCheckComboBoxPrivate (  )

Definition at line 30 of file qxtcheckcombobox.cpp.

References separator.

                                                 : containerMousePress(false)
{
    separator = QLatin1String(",");
}

Member Function Documentation

bool QxtCheckComboBoxPrivate::eventFilter ( QObject *  receiver,
QEvent *  event 
)

Definition at line 35 of file qxtcheckcombobox.cpp.

References containerMousePress, mitk::Key_Down, mitk::Key_Enter, mitk::Key_Escape, mitk::Key_Return, mitk::Key_Up, and QxtPrivate< QxtCheckComboBox >::qxt_p().

{
    switch (event->type())
    {
    case QEvent::KeyPress:
    case QEvent::KeyRelease:
    {
        QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
        if (receiver == &qxt_p() && (keyEvent->key() == Qt::Key_Up || keyEvent->key() == Qt::Key_Down))
        {
            qxt_p().showPopup();
            return true;
        }
        else if (keyEvent->key() == Qt::Key_Enter ||
                 keyEvent->key() == Qt::Key_Return ||
                 keyEvent->key() == Qt::Key_Escape)
        {
            // it is important to call QComboBox implementation
            qxt_p().QComboBox::hidePopup();
            if (keyEvent->key() != Qt::Key_Escape)
                return true;
        }
    }
    case QEvent::MouseButtonPress:
        containerMousePress = (receiver == qxt_p().view()->window());
        break;
    case QEvent::MouseButtonRelease:
        containerMousePress = false;;
        break;
    default:
        break;
    }
    return false;
}
void QxtCheckComboBoxPrivate::toggleCheckState ( int  index ) [slot]

Definition at line 83 of file qxtcheckcombobox.cpp.

References QxtPrivate< QxtCheckComboBox >::qxt_p().

{
    QVariant value = qxt_p().itemData(index, Qt::CheckStateRole);
    if (value.isValid())
    {
        Qt::CheckState state = static_cast<Qt::CheckState>(value.toInt());
        qxt_p().setItemData(index, (state == Qt::Unchecked ? Qt::Checked : Qt::Unchecked), Qt::CheckStateRole);
    }
}
void QxtCheckComboBoxPrivate::updateCheckedItems (  ) [slot]

Definition at line 70 of file qxtcheckcombobox.cpp.

References QxtCheckComboBox::checkedItems, QxtCheckComboBox::checkedItemsChanged(), defaultText, QxtPrivate< QxtCheckComboBox >::qxt_p(), and separator.

{
    QStringList items = qxt_p().checkedItems();
    if (items.isEmpty())
        qxt_p().setEditText(defaultText);
    else
        qxt_p().setEditText(items.join(separator));

    // TODO: find a way to recalculate a meaningful size hint

    emit qxt_p().checkedItemsChanged(items);
}

Friends And Related Function Documentation

friend class QxtCheckComboBox [friend]

Definition at line 53 of file qxtcheckcombobox_p.h.


Member Data Documentation

Definition at line 58 of file qxtcheckcombobox_p.h.

Referenced by eventFilter().

Definition at line 57 of file qxtcheckcombobox_p.h.

Referenced by updateCheckedItems().

Definition at line 56 of file qxtcheckcombobox_p.h.

Referenced by QxtCheckComboBoxPrivate(), and updateCheckedItems().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines