21#include "ldapattributeproxymodel.h"
23#include "ldapmodelnode_p.h"
26#include <klocalizedstring.h>
30class LdapAttributeProxyModel::LdapAttributeProxyModelPrivate
33 LdapAttributeProxyModelPrivate();
37LdapAttributeProxyModel::LdapAttributeProxyModelPrivate::LdapAttributeProxyModelPrivate()
42LdapAttributeProxyModel::LdapAttributeProxyModel( QObject *parent )
43 : QSortFilterProxyModel( parent ),
44 m_d( new LdapAttributeProxyModelPrivate() )
49LdapAttributeProxyModel::~LdapAttributeProxyModel()
54QVariant LdapAttributeProxyModel::data(
const QModelIndex &index,
59 return sourceModel()->data( mapToSource( index ), role );
62bool LdapAttributeProxyModel::setData(
const QModelIndex &index,
63 const QVariant &value,
72bool LdapAttributeProxyModel::filterAcceptsRow(
int sourceRow,
73 const QModelIndex &sourceParent )
const
75 QModelIndex idx = sourceModel()->index( sourceRow, 0, sourceParent );
76 LdapModelNode::NodeType nodeType =
77 static_cast<LdapModelNode::NodeType
>(
78 sourceModel()->data( idx, LdapModel::NodeTypeRole ).toUInt() );
79 return nodeType == LdapModelNode::Attr;
82QVariant LdapAttributeProxyModel::headerData(
int section,
83 Qt::Orientation orientation,
86 if ( orientation == Qt::Horizontal && role == Qt::DisplayRole ) {
88 return QVariant( i18n(
"Attribute" ) );
89 }
else if ( section == 1 ) {
90 return QVariant( i18n(
"Value" ) );
97int LdapAttributeProxyModel::columnCount(
const QModelIndex & )
const
102Qt::ItemFlags LdapAttributeProxyModel::flags(
const QModelIndex &index )
const
105 return sourceModel()->flags( mapToSource( index ) );
108bool LdapAttributeProxyModel::hasChildren(
const QModelIndex &parent )
const
116QModelIndex LdapAttributeProxyModel::mapFromSource(
const QModelIndex &sourceIndex )
const
118 return QSortFilterProxyModel::mapFromSource( sourceIndex );
121QModelIndex LdapAttributeProxyModel::mapToSource(
const QModelIndex &proxyIndex )
const
123 return QSortFilterProxyModel::mapToSource( proxyIndex );
126bool LdapAttributeProxyModel::insertRows(
int row,
int count,
127 const QModelIndex &parent )
135bool LdapAttributeProxyModel::removeRows(
int row,
int count,
136 const QModelIndex &parent )
144void LdapAttributeProxyModel::sort(
int column, Qt::SortOrder order )
150Qt::DropActions LdapAttributeProxyModel::supportedDropActions()
const
152 return Qt::MoveAction;
155QMimeData *LdapAttributeProxyModel::mimeData(
const QModelIndexList &indexes )
const
161bool LdapAttributeProxyModel::dropMimeData(
const QMimeData *data, Qt::DropAction action,
162 int row,
int column,
const QModelIndex &parent )
A ModelView interface to an LDAP tree.
bool hasChildrenOfType(const QModelIndex &parent, LdapDataType type) const
Checks to see if the item referenced by parent has any children of the type type.