21 #include "ldapattributeproxymodel.h"
22 #include "ldapmodel.h"
23 #include "ldapmodelnode_p.h"
26 #include <klocalizedstring.h>
28 using namespace KLDAP;
30 class LdapAttributeProxyModel::LdapAttributeProxyModelPrivate
33 LdapAttributeProxyModelPrivate();
37 LdapAttributeProxyModel::LdapAttributeProxyModelPrivate::LdapAttributeProxyModelPrivate()
42 LdapAttributeProxyModel::LdapAttributeProxyModel( QObject *parent )
43 : QSortFilterProxyModel( parent ),
44 m_d( new LdapAttributeProxyModelPrivate() )
49 LdapAttributeProxyModel::~LdapAttributeProxyModel()
54 QVariant LdapAttributeProxyModel::data(
const QModelIndex &index,
59 return sourceModel()->data( mapToSource( index ), role );
62 bool LdapAttributeProxyModel::setData(
const QModelIndex &index,
63 const QVariant &value,
72 bool 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;
82 QVariant 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" ) );
97 int LdapAttributeProxyModel::columnCount(
const QModelIndex & )
const
102 Qt::ItemFlags LdapAttributeProxyModel::flags(
const QModelIndex &index )
const
105 return sourceModel()->flags( mapToSource( index ) );
108 bool LdapAttributeProxyModel::hasChildren(
const QModelIndex &parent )
const
116 QModelIndex LdapAttributeProxyModel::mapFromSource(
const QModelIndex &sourceIndex )
const
118 return QSortFilterProxyModel::mapFromSource( sourceIndex );
121 QModelIndex LdapAttributeProxyModel::mapToSource(
const QModelIndex &proxyIndex )
const
123 return QSortFilterProxyModel::mapToSource( proxyIndex );
126 bool LdapAttributeProxyModel::insertRows(
int row,
int count,
127 const QModelIndex &parent )
135 bool LdapAttributeProxyModel::removeRows(
int row,
int count,
136 const QModelIndex &parent )
144 void LdapAttributeProxyModel::sort(
int column, Qt::SortOrder order )
150 Qt::DropActions LdapAttributeProxyModel::supportedDropActions()
const
152 return Qt::MoveAction;
155 QMimeData *LdapAttributeProxyModel::mimeData(
const QModelIndexList &indexes )
const
161 bool LdapAttributeProxyModel::dropMimeData(
const QMimeData *data, Qt::DropAction action,
162 int row,
int column,
const QModelIndex &parent )
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.