Incidenceeditor

resourceitem.h
1/*
2 * SPDX-FileCopyrightText: 2014 Sandro Knauß <knauss@kolabsys.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
5 *
6 */
7
8#pragma once
9
10#include <KLDAPCore/LdapClient>
11
12#include <KLDAPCore/LdapObject>
13
14#include <QList>
15#include <QSharedPointer>
16#include <QStringList>
17#include <QVariant>
18
19namespace IncidenceEditorNG
20{
21class ResourceItem : public QObject
22{
24public:
25 /* Copied from https://doc.qt.io/qt-5/qtwidgets-itemviews-editabletreemodel-example.html:
26 * Editable Tree Model Example
27 */
28
29 /**
30 A shared pointer to an ResourceItem object.
31 */
33
34 ResourceItem(const KLDAPCore::LdapDN &dn,
35 const QStringList &attrs,
36 const KLDAPCore::LdapClient &ldapClient,
37 const ResourceItem::Ptr &parent = ResourceItem::Ptr());
38 ~ResourceItem() override;
39
40 [[nodiscard]] ResourceItem::Ptr child(int number);
41 [[nodiscard]] int childCount() const;
42 [[nodiscard]] int columnCount() const;
43 [[nodiscard]] QVariant data(int column) const;
44 [[nodiscard]] QVariant data(const QString &column) const;
45 [[nodiscard]] bool insertChild(int position, const ResourceItem::Ptr &item);
46 [[nodiscard]] ResourceItem::Ptr parent();
47 [[nodiscard]] bool removeChildren(int position, int count);
48 [[nodiscard]] int childNumber() const;
49
50private:
51 QList<ResourceItem::Ptr> childItems;
52 QList<QVariant> itemData;
53 ResourceItem::Ptr parentItem;
54
56 void searchFinished();
57
58public:
59 /* Returns the attributes of the requested ldapObject.
60 *
61 */
62 const QStringList &attributes() const;
63
64 /* Returns the ldapObject, that is used as data source.
65 *
66 */
67 const KLDAPCore::LdapObject &ldapObject() const;
68
69 /* Set the ldapObject, either directly via this function
70 * or use startSearch to request the ldapServer for the ldapObject
71 * with the dn specified via the constructor.
72 *
73 */
74 void setLdapObject(const KLDAPCore::LdapObject &);
75
76 /* The used ldapClient.
77 *
78 */
79 const KLDAPCore::LdapClient &ldapClient() const;
80
81 /* Start querying the ldapServer for a object that name is dn
82 *
83 */
84 void startSearch();
85
86private:
87 /* data source
88 *
89 */
90 KLDAPCore::LdapObject mLdapObject;
91
92 /* dn of the ldapObject
93 *
94 */
95 const KLDAPCore::LdapDN dn;
96
97 /* Attributes of the ldapObject to request and the header of the Item
98 *
99 */
100 QStringList mAttrs;
101
102 /* ldapClient to request
103 *
104 */
105 KLDAPCore::LdapClient mLdapClient;
106
107private:
108 /* Answer of the LdapServer for the given dn
109 *
110 */
111 void slotLDAPResult(const KLDAPCore::LdapClient &, const KLDAPCore::LdapObject &);
112};
113}
114
115//@cond PRIVATE
116Q_DECLARE_TYPEINFO(IncidenceEditorNG::ResourceItem::Ptr, Q_RELOCATABLE_TYPE);
117Q_DECLARE_METATYPE(IncidenceEditorNG::ResourceItem::Ptr)
118//@endcond
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 13 2024 11:52:53 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.