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 Server,
25 LastColumn = Server,
26 };
27
28 struct ServerInfo {
29 bool enabled = false;
30 int index = 0;
32 };
33
34 [[nodiscard]] QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
35 [[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override;
36 [[nodiscard]] int columnCount(const QModelIndex &parent) const override;
37 [[nodiscard]] QVariant headerData(int section, Qt::Orientation orientation, int role) 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
47 void insertServer(const KLDAPCore::LdapServer &server);
48
49 void removeServer(int index);
50
51private:
52 KLDAP_CORE_NO_EXPORT void init();
53 QList<ServerInfo> mLdapServerInfo;
54};
55}
56Q_DECLARE_METATYPE(KLDAPCore::LdapModel::ServerInfo)
57Q_DECLARE_TYPEINFO(KLDAPCore::LdapModel::ServerInfo, Q_RELOCATABLE_TYPE);
A class that contains LDAP server connection settings.
Definition ldapserver.h:27
void init(KXmlGuiWindow *window, KGameDifficulty *difficulty=nullptr)
KGuiItem save()
DisplayRole
typedef ItemFlags
Orientation
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Oct 11 2024 12:14:23 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.