/ proxyroles / singlerole.cpp
singlerole.cpp
1 #include "singlerole.h" 2 #include <QVariant> 3 4 namespace qqsfpm { 5 6 /*! 7 \qmltype SingleRole 8 \qmlabstract 9 \inherits ProxyRole 10 \inqmlmodule SortFilterProxyModel 11 \ingroup ProxyRoles 12 \brief Base type for the \l SortFilterProxyModel proxy roles defining a single role. 13 14 SingleRole is a convenience base class for proxy roles who define a single role. 15 It cannot be used directly in a QML file. 16 It exists to provide a set of common properties and methods, 17 available across all the other proxy role types that inherit from it. 18 Attempting to use the SingleRole type directly will result in an error. 19 */ 20 /*! 21 \qmlproperty string SingleRole::name 22 23 This property holds the role name of the proxy role. 24 */ 25 QString SingleRole::name() const 26 { 27 return m_name; 28 } 29 30 void SingleRole::setName(const QString& name) 31 { 32 if (m_name == name) 33 return; 34 35 Q_EMIT namesAboutToBeChanged(); 36 m_name = name; 37 Q_EMIT nameChanged(); 38 Q_EMIT namesChanged(); 39 } 40 41 QStringList SingleRole::names() 42 { 43 return QStringList { m_name }; 44 } 45 46 QVariant SingleRole::data(const QModelIndex &sourceIndex, const QQmlSortFilterProxyModel &proxyModel, const QString &name) 47 { 48 Q_UNUSED(name); 49 return data(sourceIndex, proxyModel); 50 } 51 52 }