File indexing completed on 2025-01-05 04:58:22

0001 /*
0002  * This file is part of libkldap.
0003  *
0004  * SPDX-FileCopyrightText: 2002 Klarälvdalens Datakonsult AB
0005  * SPDX-FileContributor: Steffen Hansen <hansen@kde.org>
0006  *
0007  * SPDX-License-Identifier: LGPL-2.0-or-later
0008  */
0009 #pragma once
0010 
0011 #include "pimcommonakonadi_export.h"
0012 
0013 #include <KContacts/Addressee>
0014 #include <QDialog>
0015 
0016 class QCloseEvent;
0017 
0018 namespace KLDAPWidgets
0019 {
0020 class LdapClient;
0021 }
0022 namespace KLDAPCore
0023 {
0024 class LdapObject;
0025 }
0026 namespace PimCommon
0027 {
0028 /**
0029  * @short A dialog to search contacts in a LDAP directory.
0030  *
0031  * This dialog allows the user to search for contacts inside
0032  * a LDAP directory.
0033  *
0034  * @author Steffen Hansen <hansen@kde.org>
0035  * @since 4.5
0036  */
0037 class PIMCOMMONAKONADI_EXPORT LdapSearchDialog : public QDialog
0038 {
0039     Q_OBJECT
0040 
0041 public:
0042     enum FilterType {
0043         Name = 0,
0044         Email,
0045         HomeNumber,
0046         WorkNumber,
0047     };
0048 
0049     /**
0050      * Creates a new ldap search dialog.
0051      *
0052      * @param parent The parent widget.
0053      */
0054     explicit LdapSearchDialog(QWidget *parent = nullptr);
0055 
0056     /**
0057      * Destroys the ldap search dialog.
0058      */
0059     ~LdapSearchDialog() override;
0060 
0061     /**
0062      * Sets the @p text in the search line edit.
0063      */
0064     void setSearchText(const QString &text);
0065 
0066     /**
0067      * Returns a list of contacts that have been selected
0068      * in the LDAP search.
0069      */
0070     KContacts::Addressee::List selectedContacts() const;
0071 
0072 Q_SIGNALS:
0073     /**
0074      * This signal is emitted whenever the user clicked the
0075      * 'Add Selected' button.
0076      */
0077     void contactsAdded();
0078 
0079 protected Q_SLOTS:
0080     void slotUser1();
0081     void slotUser2();
0082     void slotCustomContextMenuRequested(const QPoint &);
0083     void slotCancelClicked();
0084 
0085 protected:
0086     void closeEvent(QCloseEvent *) override;
0087 
0088 private:
0089     //@cond PRIVATE
0090     class LdapSearchDialogPrivate;
0091     std::unique_ptr<LdapSearchDialogPrivate> const d;
0092 
0093     Q_PRIVATE_SLOT(d, void slotAddResult(const KLDAPWidgets::LdapClient &, const KLDAPCore::LdapObject &))
0094     Q_PRIVATE_SLOT(d, void slotStartSearch())
0095     Q_PRIVATE_SLOT(d, void slotStopSearch())
0096     Q_PRIVATE_SLOT(d, void slotSearchDone())
0097     //@endcond
0098 };
0099 }
0100 Q_DECLARE_METATYPE(PimCommon::LdapSearchDialog::FilterType)