File indexing completed on 2025-01-05 04:58:21
0001 /* 0002 SPDX-FileCopyrightText: 2015-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 0006 */ 0007 0008 #pragma once 0009 0010 #include "pimcommonakonadi_private_export.h" 0011 #include <KConfig> 0012 #include <QDBusAbstractAdaptor> 0013 #include <QWidget> 0014 0015 class QPushButton; 0016 class QAbstractItemModel; 0017 class QModelIndex; 0018 class QTreeWidget; 0019 0020 namespace KLDAPWidgets 0021 { 0022 class LdapClientSearch; 0023 } 0024 0025 namespace PimCommon 0026 { 0027 class CompletionOrderEditorAdaptor : public QDBusAbstractAdaptor 0028 { 0029 Q_OBJECT 0030 Q_CLASSINFO("D-Bus Interface", "org.kde.pim.CompletionOrder") 0031 public: 0032 explicit CompletionOrderEditorAdaptor(QObject *parent); 0033 Q_SIGNALS: 0034 void completionOrderChanged(); 0035 }; 0036 0037 class CompletionOrderWidget; 0038 0039 // Base class for items in the list 0040 class CompletionItem 0041 { 0042 public: 0043 virtual ~CompletionItem() = default; 0044 0045 virtual QString label() const = 0; 0046 virtual QIcon icon() const = 0; 0047 virtual int completionWeight() const = 0; 0048 virtual void setCompletionWeight(int weight) = 0; 0049 virtual void save(CompletionOrderWidget *) = 0; 0050 virtual bool hasEnableSupport() const = 0; 0051 virtual bool isEnabled() const = 0; 0052 virtual void setIsEnabled(bool b) = 0; 0053 }; 0054 0055 class PIMCOMMONAKONADI_TESTS_EXPORT CompletionOrderWidget : public QWidget 0056 { 0057 Q_OBJECT 0058 public: 0059 explicit CompletionOrderWidget(QWidget *parent = nullptr); 0060 ~CompletionOrderWidget() override; 0061 void save(); 0062 0063 KConfig *configFile(); 0064 void loadCompletionItems(); 0065 void setLdapClientSearch(KLDAPWidgets::LdapClientSearch *ldapSearch); 0066 0067 Q_SIGNALS: 0068 void completionOrderChanged(); 0069 0070 private: 0071 void rowsInserted(const QModelIndex &parent, int start, int end); 0072 void slotSelectionChanged(); 0073 void slotMoveUp(); 0074 void slotMoveDown(); 0075 void addRecentAddressItem(); 0076 void addCompletionItemForCollection(const QModelIndex &); 0077 void slotItemChanged(); 0078 0079 KConfig mConfig; 0080 QTreeWidget *mListView = nullptr; 0081 QPushButton *mUpButton = nullptr; 0082 QPushButton *mDownButton = nullptr; 0083 QAbstractItemModel *mCollectionModel = nullptr; 0084 KLDAPWidgets::LdapClientSearch *mLdapSearch = nullptr; 0085 0086 int mDefaultValue = 60; 0087 bool mDirty = false; 0088 }; 0089 }