Public Member Functions | Public Attributes

QxtModelFilterPrivate Class Reference

List of all members.

Public Member Functions

 QxtModelFilterPrivate (const QVariant &value=QVariant(), const int role=Qt::DisplayRole, const Qt::MatchFlags flags=Qt::MatchContains)
bool acceptsValue (const QVariant &value)

Public Attributes

QVariant m_value
int m_role
Qt::MatchFlags m_flags

Detailed Description

Definition at line 45 of file qxtsortfilterproxymodel.cpp.


Constructor & Destructor Documentation

QxtModelFilterPrivate::QxtModelFilterPrivate ( const QVariant &  value = QVariant(),
const int  role = Qt::DisplayRole,
const Qt::MatchFlags  flags = Qt::MatchContains 
)

Definition at line 62 of file qxtsortfilterproxymodel.cpp.

    :m_value(value),m_role(role),m_flags(flags)
{

}

Member Function Documentation

bool QxtModelFilterPrivate::acceptsValue ( const QVariant &  value )

Definition at line 68 of file qxtsortfilterproxymodel.cpp.

References m_flags, and m_value.

Referenced by QxtSortFilterProxyModel::filterAcceptsRow().

{
    uint matchType = m_flags & 0x0F;
    //if we have no value we accept everything
    if(!m_value.isValid() || !value.isValid())
        return true;

    // QVariant based matching
    if (matchType == Qt::MatchExactly ){
        if(m_value == value) 
            return true;
    }
    // QString based matching
    else { 
        Qt::CaseSensitivity cs = m_flags & Qt::MatchCaseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive;
        QString filterText = m_value.toString();
        QString modelText  = value.toString();
        switch (matchType){
            case Qt::MatchRegExp:
                if (QRegExp(filterText, cs).exactMatch(modelText))
                    return true;
                break;
            case Qt::MatchWildcard:
                if (QRegExp(filterText, cs, QRegExp::Wildcard).exactMatch(modelText))
                    return true;
                break;
            case Qt::MatchStartsWith:
                if (modelText.startsWith(filterText, cs))
                    return true;
                break;
            case Qt::MatchEndsWith:
                if (modelText.endsWith(filterText, cs))
                    return true;
                break;
            case Qt::MatchFixedString:
                if (modelText.compare(filterText, cs) == 0)
                    return true;
                break;
            default:
            case Qt::MatchContains:
                if (modelText.contains(filterText, cs))
                    return true;
        }
    }
    return false;
}

Member Data Documentation

Definition at line 52 of file qxtsortfilterproxymodel.cpp.

Referenced by acceptsValue().

Definition at line 50 of file qxtsortfilterproxymodel.cpp.

Referenced by acceptsValue().


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