File indexing completed on 2024-06-16 04:59:07
0001 /* 0002 0003 SPDX-FileCopyrightText: 2004 Ingo Kloecker <kloecker@kde.org> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #pragma once 0009 0010 #include "search/searchpattern.h" 0011 0012 #include <QByteArray> 0013 #include <QList> 0014 0015 class QObject; 0016 class QString; 0017 class QStackedWidget; 0018 0019 namespace MailCommon 0020 { 0021 class RuleWidgetHandler; 0022 0023 /** 0024 * @short Singleton to manage the list of RuleWidgetHandlers 0025 */ 0026 class RuleWidgetHandlerManager 0027 { 0028 static RuleWidgetHandlerManager *self; 0029 0030 RuleWidgetHandlerManager(); 0031 0032 public: 0033 ~RuleWidgetHandlerManager(); 0034 0035 static RuleWidgetHandlerManager *instance() 0036 { 0037 if (!self) { 0038 self = new RuleWidgetHandlerManager(); 0039 } 0040 return self; 0041 } 0042 0043 void setIsAkonadiSearch(bool isBalooSearch); 0044 0045 void registerHandler(const RuleWidgetHandler *handler); 0046 void unregisterHandler(const RuleWidgetHandler *handler); 0047 0048 void createWidgets(QStackedWidget *functionStack, QStackedWidget *valueStack, const QObject *receiver) const; 0049 0050 MailCommon::SearchRule::Function function(const QByteArray &field, const QStackedWidget *functionStack) const; 0051 0052 QString value(const QByteArray &field, const QStackedWidget *functionStack, const QStackedWidget *valueStack) const; 0053 0054 QString prettyValue(const QByteArray &field, const QStackedWidget *functionStack, const QStackedWidget *valueStack) const; 0055 0056 void reset(QStackedWidget *functionStack, QStackedWidget *valueStack) const; 0057 0058 void setRule(QStackedWidget *functionStack, QStackedWidget *valueStack, const MailCommon::SearchRule::Ptr rule) const; 0059 0060 void update(const QByteArray &field, QStackedWidget *functionStack, QStackedWidget *valueStack) const; 0061 0062 private: 0063 using const_iterator = QList<const RuleWidgetHandler *>::const_iterator; 0064 using iterator = QList<const RuleWidgetHandler *>::iterator; 0065 0066 QList<const RuleWidgetHandler *> mHandlers; 0067 bool mIsBalooSearch = false; 0068 }; 0069 } // namespace MailCommon