7#include "resourceitem.h"
9#include <KLDAPCore/LdapServer>
11using namespace IncidenceEditorNG;
17 , mLdapClient(0, this)
20 KLDAPCore::LdapServer server = ldapClient.server();
22 server.setScope(KLDAPCore::LdapUrl::Base);
24 mLdapClient.setServer(server);
26 connect(&mLdapClient, &KLDAPCore::LdapClient::result, this, &ResourceItem::slotLDAPResult);
28 mAttrs << QStringLiteral(
"uniqueMember");
29 mLdapClient.setAttributes(attrs);
31 itemData.reserve(mAttrs.count());
32 for (const QString &header : std::as_const(mAttrs)) {
38ResourceItem::~ResourceItem() =
default;
40ResourceItem::Ptr ResourceItem::child(
int number)
42 return childItems.value(number);
45int ResourceItem::childCount()
const
47 return childItems.count();
50int ResourceItem::childNumber()
const
54 for (
const ResourceItem::Ptr &child : std::as_const(parentItem->childItems)) {
65int ResourceItem::columnCount()
const
67 return itemData.count();
70QVariant ResourceItem::data(
int column)
const
72 return itemData.value(column);
75QVariant ResourceItem::data(
const QString &column)
const
77 if (!mLdapObject.attributes()[column].isEmpty()) {
83bool ResourceItem::insertChild(
int position,
const ResourceItem::Ptr &item)
85 if (position < 0 || position > childItems.size()) {
89 childItems.insert(position, item);
94ResourceItem::Ptr ResourceItem::parent()
99bool ResourceItem::removeChildren(
int position,
int count)
101 if (position < 0 || position + count > childItems.size()) {
105 for (
int row = 0; row < count; ++row) {
106 childItems.removeAt(position);
112const QStringList &ResourceItem::attributes()
const
117const KLDAPCore::LdapObject &ResourceItem::ldapObject()
const
122void ResourceItem::startSearch()
124 mLdapClient.startQuery(QStringLiteral(
"objectclass=*"));
127void ResourceItem::setLdapObject(
const KLDAPCore::LdapObject &obj)
129 slotLDAPResult(mLdapClient, obj);
132const KLDAPCore::LdapClient &ResourceItem::ldapClient()
const
137void ResourceItem::slotLDAPResult(
const KLDAPCore::LdapClient &client,
const KLDAPCore::LdapObject &obj)
141 for (
const QString &header : std::as_const(mAttrs)) {
145 itemData << QString();
151#include "moc_resourceitem.cpp"
const LdapAttrMap & attributes() const
QString fromUtf8(QByteArrayView str)