21 #include "ldapstructureproxymodel.h"
22 #include "ldapmodel.h"
23 #include "ldapmodelnode_p.h"
26 #include <klocalizedstring.h>
28 using namespace KLDAP;
30 class LdapStructureProxyModel::LdapStructureProxyModelPrivate
33 LdapStructureProxyModelPrivate();
37 LdapStructureProxyModel::LdapStructureProxyModelPrivate::LdapStructureProxyModelPrivate()
42 LdapStructureProxyModel::LdapStructureProxyModel(
QObject *parent )
44 m_d( new LdapStructureProxyModelPrivate() )
49 LdapStructureProxyModel::~LdapStructureProxyModel()
59 return sourceModel()->data( mapToSource( index ), role );
62 bool LdapStructureProxyModel::setData(
const QModelIndex &index,
72 bool LdapStructureProxyModel::filterAcceptsRow(
int sourceRow,
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;
82 QVariant LdapStructureProxyModel::headerData(
int section,
83 Qt::Orientation orientation,
87 if ( orientation == Qt::Horizontal && role == Qt::DisplayRole ) {
88 return i18n(
"Distinguished Name" );
94 int LdapStructureProxyModel::columnCount(
const QModelIndex & )
const
103 return sourceModel()->flags( mapToSource( index ) );
106 bool LdapStructureProxyModel::hasChildren(
const QModelIndex &parent )
const
111 return model->
hasChildrenOfType( mapToSource( parent ), LdapModel::DistinguishedName );
124 bool LdapStructureProxyModel::insertRows(
int row,
int count,
133 bool LdapStructureProxyModel::removeRows(
int row,
int count,
142 void LdapStructureProxyModel::sort(
int column, Qt::SortOrder order )
150 return Qt::MoveAction;
153 QMimeData *LdapStructureProxyModel::mimeData(
const QModelIndexList &indexes )
const
159 bool LdapStructureProxyModel::dropMimeData(
const QMimeData *data, Qt::DropAction action,
bool hasChildrenOfType(const QModelIndex &parent, LdapDataType type) const
Checks to see if the item referenced by parent has any children of the type type. ...
A ModelView interface to an LDAP tree.
virtual QModelIndex mapToSource(const QModelIndex &proxyIndex) const
virtual QModelIndex mapFromSource(const QModelIndex &sourceIndex) const