-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathldapobject.cpp
More file actions
122 lines (97 loc) · 2.38 KB
/
Copy pathldapobject.cpp
File metadata and controls
122 lines (97 loc) · 2.38 KB
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
#include "ldapobject.h"
#include "common.h"
#include <QStringList>
LdapObject::LdapObject(QString name, Connector &connector, LdapObject *parent, ObjectType objectType):
connector(connector), parentObject(parent), objectType(objectType), isFetched(false), adfsFileName(name)
{
qDebug() << "LdapObject::LdapObject: for adfsFileName" << name;
objectData.insert(NameAttr, StringUnicodeType, name);
}
LdapObject::~LdapObject()
{
qDeleteAll(childObjects);
}
void LdapObject::appendChild(LdapObject *object)
{
childObjects.append(object);
}
void LdapObject::appendAttribute(QString name, QString type, QString value)
{
objectData.insert(name, type, value);
}
LdapObject *LdapObject::child(int row)
{
return childObjects.value(row);
}
int LdapObject::childCount() const
{
return childObjects.count();
}
int LdapObject::columnCount() const
{
return objectData.count();
}
QVariant LdapObject::data(AttributeName attr) const
{
return objectData.value(attr);
}
QString LdapObject::name() const
{
return objectData.value(NameAttr).toString();
}
QString LdapObject::dn() const
{
return objectData.value(DNAttr).toString();
}
QString LdapObject::path(QString child) const
{
if (type() == ConnectionType)
return QString(QDir::separator());
QString path = adfsFileName;
if (!child.isNull())
path += QDir::separator() + child;
if (parentObject != nullptr && parentObject->type() != ConnectionType)
return parentObject->path(path);
return path;
}
LdapObject *LdapObject::parent() const
{
return parentObject;
}
int LdapObject::row() const
{
if (parentObject)
return parentObject->childObjects.indexOf(const_cast<LdapObject*>(this));
return 0;
}
ObjectType LdapObject::type() const
{
return objectType;
}
bool LdapObject::canFetch() const
{
bool canFetch = false;
foreach (const LdapObject *object, childObjects)
{
if (!object->isFetched) {
canFetch = true;
break;
}
}
return canFetch;
}
void LdapObject::fetch()
{
qDebug() << "LdapObject::fetch: fetch!!!";
foreach (LdapObject *object, childObjects)
{
if (!object->isFetched)
object->queryData();
}
}
void LdapObject::queryData()
{
connector.query(objectData, this);
connector.childs(childObjects, this);
isFetched = !connector.childs(childObjects, this);
}