KLdap

ldapmodel.h
1/*
2 * SPDX-FileCopyrightText: 2024 Laurent Montel <montel@kde.org>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
7#pragma once
8#include "kldap_core_export.h"
9#include <KLDAPCore/LdapServer>
10#include <QAbstractListModel>
11namespace KLDAPCore
12{
13class KLDAP_CORE_EXPORT LdapModel : public QAbstractListModel
14{
15 Q_OBJECT
16public:
17 explicit LdapModel(QObject *parent = nullptr);
18 ~LdapModel() override;
19
20 enum LdapRoles {
21 Name,
22 Index,
23 Activities,
24 EnabledActivitiesRole,
25 Server,
26 LastColumn = Server,
27 };
28
29 struct ServerInfo {
30 bool enabled = false;
31 int index = 0;
33 };
34
35 [[nodiscard]] QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
36 [[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override;
37 [[nodiscard]] int columnCount(const QModelIndex &parent) const override;
38 bool setData(const QModelIndex &modelIndex, const QVariant &value, int role) override;
39
40 [[nodiscard]] QList<ServerInfo> ldapServerInfo() const;
41 void setLdapServerInfo(const QList<ServerInfo> &newLdapServerInfo);
42
43 [[nodiscard]] Qt::ItemFlags flags(const QModelIndex &index) const override;
44
45 void save();
46 void load();
47
48 void insertServer(const KLDAPCore::LdapServer &server);
49
50 void removeServer(int index);
51
52private:
53 KLDAP_CORE_NO_EXPORT void init();
54 QList<ServerInfo> mLdapServerInfo;
55};
56}
57Q_DECLARE_METATYPE(KLDAPCore::LdapModel::ServerInfo)
58Q_DECLARE_TYPEINFO(KLDAPCore::LdapModel::ServerInfo, Q_RELOCATABLE_TYPE);
A class that contains LDAP server connection settings.
Definition ldapserver.h:27
QAction * load(const QObject *recvr, const char *slot, QObject *parent)
const QList< QKeySequence > & save()
QCA_EXPORT void init()
DisplayRole
typedef ItemFlags
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:03:36 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.