KLDAP Library
ldapmodelnode_p.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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
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
00087 bool populated = isPopulated();
00088
00089 const LdapAttrMap &attrs = object.attributes();
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
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
00112 setPopulated( populated );
00113 }
00114
00115
00116
00117
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 }