File: ldapmodelnode_p.h

package info (click to toggle)
kdepimlibs 4%3A4.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 22,300 kB
  • ctags: 16,353
  • sloc: cpp: 118,725; ansic: 17,101; xml: 2,722; perl: 1,791; yacc: 954; sh: 168; ruby: 60; makefile: 44
file content (123 lines) | stat: -rw-r--r-- 3,126 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
  This file is part of libkldap.
  Copyright (c) 2006 Sean Harmer <sh@theharmers.co.uk>

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Library General  Public
  License as published by the Free Software Foundation; either
  version 2 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Library General Public License for more details.

  You should have received a copy of the GNU Library General Public License
  along with this library; see the file COPYING.LIB.  If not, write to
  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  Boston, MA 02110-1301, USA.
*/

#ifndef KLDAP_LDAPMODELNODE_P_H
#define KLDAP_LDAPMODELNODE_P_H

#include <QByteArray>
#include <QString>
#include <QtCore/QList>
#include <QtCore/QVariant>

#include "ldapdn.h"
#include "ldapobject.h"
#include "kldap_export.h"

namespace KLDAP {

class LdapModelDNNode;

/**
 * @internal
 */
class LdapModelNode
{
  public:
    explicit LdapModelNode( LdapModelDNNode *parent = 0 );
    virtual ~LdapModelNode();

    enum NodeType {
      DN,
      Attr
    };

    virtual NodeType nodeType() const = 0;

    LdapModelDNNode *parent();
    int columnCount() const { return 2; }
    int row() const;

    void setPopulated( bool b ) { m_isPopulated = b; }
    bool isPopulated() const { return m_isPopulated; }

  private:
    LdapModelDNNode *m_parent;
    bool m_isPopulated;
};

/**
 * @internal
 */
class LdapModelDNNode : public LdapModelNode
{
  public:
    explicit LdapModelDNNode( LdapModelDNNode *parent = 0,
                              const LdapDN &dn = LdapDN() );
    ~LdapModelDNNode();

    LdapModelNode::NodeType nodeType() const
    { return LdapModelNode::DN; }

    void appendChild( LdapModelNode *pItem );
    LdapModelNode *child( int row );
    int childCount() const { return m_childItems.size(); }
    const QList<LdapModelNode*>& children() const
    { return m_childItems; }

    const LdapDN &dn() const { return m_dn; }

    /**
     * Creates child LdapModelAttrNode object to store \p object's attributes
     * and adds them as children of this node.
     *
     * \param The LdapObject to store in this node.
     */
    void setLdapObject( const LdapObject &object );

  private:
    QList<LdapModelNode*> m_childItems;
    LdapDN m_dn;
};

/**
 * @internal
 */
class LdapModelAttrNode : public LdapModelNode
{
  public:
    explicit LdapModelAttrNode( LdapModelDNNode *parent = 0,
                                const QString &attrName = QString(),
                                const QByteArray &attrData = QByteArray() );
    ~LdapModelAttrNode();

    LdapModelNode::NodeType nodeType() const
    { return LdapModelNode::Attr; }

    const QString &attributeName() { return m_attrName; }
    const QByteArray &attributeData() { return m_attrData; }

  private:
    QString m_attrName;
    QByteArray m_attrData;
};

}

#endif