21#include "ldapstructureproxymodel.h"
23#include "ldapmodelnode_p.h"
26#include <klocalizedstring.h>
30class LdapStructureProxyModel::LdapStructureProxyModelPrivate
33 LdapStructureProxyModelPrivate();
37LdapStructureProxyModel::LdapStructureProxyModelPrivate::LdapStructureProxyModelPrivate()
42LdapStructureProxyModel::LdapStructureProxyModel( QObject *parent )
43 : QSortFilterProxyModel( parent ),
44 m_d( new LdapStructureProxyModelPrivate() )
49LdapStructureProxyModel::~LdapStructureProxyModel()
54QVariant LdapStructureProxyModel::data(
const QModelIndex &index,
59 return sourceModel()->data( mapToSource( index ), role );
62bool LdapStructureProxyModel::setData(
const QModelIndex &index,
63 const QVariant &value,
72bool LdapStructureProxyModel::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::DN;
82QVariant LdapStructureProxyModel::headerData(
int section,
83 Qt::Orientation orientation,
87 if ( orientation == Qt::Horizontal && role == Qt::DisplayRole ) {
88 return i18n(
"Distinguished Name" );
94int LdapStructureProxyModel::columnCount(
const QModelIndex & )
const
100Qt::ItemFlags LdapStructureProxyModel::flags(
const QModelIndex &index )
const
103 return sourceModel()->flags( mapToSource( index ) );
106bool LdapStructureProxyModel::hasChildren(
const QModelIndex &parent )
const
111 return model->
hasChildrenOfType( mapToSource( parent ), LdapModel::DistinguishedName );
114QModelIndex LdapStructureProxyModel::mapFromSource(
const QModelIndex &sourceIndex )
const
116 return QSortFilterProxyModel::mapFromSource( sourceIndex );
119QModelIndex LdapStructureProxyModel::mapToSource(
const QModelIndex &proxyIndex )
const
121 return QSortFilterProxyModel::mapToSource( proxyIndex );
124bool LdapStructureProxyModel::insertRows(
int row,
int count,
125 const QModelIndex &parent )
133bool LdapStructureProxyModel::removeRows(
int row,
int count,
134 const QModelIndex &parent )
142void LdapStructureProxyModel::sort(
int column, Qt::SortOrder order )
148Qt::DropActions LdapStructureProxyModel::supportedDropActions()
const
150 return Qt::MoveAction;
153QMimeData *LdapStructureProxyModel::mimeData(
const QModelIndexList &indexes )
const
159bool LdapStructureProxyModel::dropMimeData(
const QMimeData *data, Qt::DropAction action,
160 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.