• Skip to content
  • Skip to link menu
KDE 4.0 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • Sitemap
  • Contact Us
 

KLDAP Library

ldapmodelnode_p.cpp

00001 /*
00002   This file is part of libkldap.
00003   Copyright (c) 2006 Sean Harmer <sh@theharmers.co.uk>
00004 
00005   This library is free software; you can redistribute it and/or
00006   modify it under the terms of the GNU Library General  Public
00007   License as published by the Free Software Foundation; either
00008   version 2 of the License, or (at your option) any later version.
00009 
00010   This library is distributed in the hope that it will be useful,
00011   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013   Library General Public License for more details.
00014 
00015   You should have received a copy of the GNU Library General Public License
00016   along with this library; see the file COPYING.LIB.  If not, write to
00017   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018   Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #include "ldapmodelnode_p.h"
00022 
00023 #include <kdebug.h>
00024 
00025 using namespace KLDAP;
00026 
00027 LdapModelNode::LdapModelNode( LdapModelDNNode *parent )
00028   : m_parent( parent ),
00029     m_isPopulated( false )
00030 {
00031   if ( m_parent ) {
00032     m_parent->appendChild( this );
00033   }
00034 }
00035 
00036 LdapModelNode::~LdapModelNode()
00037 {
00038 
00039 }
00040 
00041 LdapModelDNNode *LdapModelNode::parent()
00042 {
00043   return m_parent;
00044 }
00045 
00046 int LdapModelNode::row() const
00047 {
00048   if ( m_parent ) {
00049     return m_parent->children().indexOf( const_cast<LdapModelNode*>( this ) );
00050   }
00051   return 0;
00052 }
00053 
00054 
00055 //
00056 // LdapModelDNNode imlpementation
00057 //
00058 
00059 LdapModelDNNode::LdapModelDNNode( LdapModelDNNode *parent,
00060                                   const LdapDN &dn )
00061   : LdapModelNode( parent ),
00062     m_childItems(),
00063     m_dn( dn )
00064 {
00065   kDebug(5322) << "Creating LdapModelDNNode: DN =" << m_dn.toString();
00066 }
00067 
00068 LdapModelDNNode::~LdapModelDNNode()
00069 {
00070   qDeleteAll( m_childItems );
00071 }
00072 
00073 void LdapModelDNNode::appendChild( LdapModelNode *pItem )
00074 {
00075   m_childItems.append( pItem );
00076   setPopulated( true );
00077 }
00078 
00079 LdapModelNode *LdapModelDNNode::child( int row )
00080 {
00081   return m_childItems.value( row );
00082 }
00083 
00084 void LdapModelDNNode::setLdapObject( const LdapObject &object )
00085 {
00086   // Remember whether this item is populated or not
00087   bool populated = isPopulated();
00088 
00089   const LdapAttrMap &attrs = object.attributes();
00090   /*
00091   int attributeCount = 0;
00092   for ( LdapAttrMap::ConstIterator it = attrs.begin(); it != attrs.end(); ++it ) {
00093     attributeCount += (*it).size();
00094   }
00095 
00096   for ( int i = 0; i < attributeCount; i++ )
00097   {
00098     LdapModelNode* node = new LdapModelAttrNode( this, QString::number( i ) );
00099     Q_UNUSED( node );
00100   }
00101   */
00102 
00103   for ( LdapAttrMap::ConstIterator it = attrs.begin(); it != attrs.end(); ++it ) {
00104     QString attr = it.key();
00105     for ( LdapAttrValue::ConstIterator it2 = (*it).begin(); it2 != (*it).end(); ++it2 ) {
00106       LdapModelNode* node = new LdapModelAttrNode( this, attr, *it2 );
00107       Q_UNUSED( node );
00108     }
00109   }
00110 
00111   // Reset the populated flag so that we don't stop the model querying for children
00112   setPopulated( populated );
00113 }
00114 
00115 
00116 //
00117 // LdapModelAttrNode imlpementation
00118 //
00119 
00120 LdapModelAttrNode::LdapModelAttrNode( LdapModelDNNode *parent,
00121                                       const QString &attrName,
00122                                       const QByteArray &attrData )
00123   : LdapModelNode( parent ),
00124     m_attrName( attrName ),
00125     m_attrData( attrData )
00126 {
00127   kDebug(5322) << "Creating LdapModelAttrNode: Name =" << m_attrName
00128                << " Data =" << m_attrData;
00129 }
00130 
00131 LdapModelAttrNode::~LdapModelAttrNode()
00132 {
00133 
00134 }

KLDAP Library

Skip menu "KLDAP Library"
  • Main Page
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • kabc
  • kblog
  • kcal
  • kimap
  • kioslave
  •   imap4
  •   mbox
  • kldap
  • kmime
  • kpimidentities
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.5.5
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal