File indexing completed on 2024-05-19 05:00:54
0001 /* 0002 kcookiespolicies.h - Cookies configuration 0003 0004 Original Authors 0005 SPDX-FileCopyrightText: Waldo Bastian <bastian@kde.org> 0006 SPDX-FileCopyrightText: 1999 David Faure <faure@kde.org> 0007 0008 Re-written by: 0009 SPDX-FileCopyrightText: 2000 Dawit Alemayehu <adawit@kde.org> 0010 0011 SPDX-License-Identifier: GPL-2.0-or-later 0012 */ 0013 0014 #ifndef KCOOKIESPOLICIES_H 0015 #define KCOOKIESPOLICIES_H 0016 0017 #include <KCModule> 0018 #include <QMap> 0019 0020 #include "kcookiespolicyselectiondlg.h" 0021 #include "ui_kcookiespolicies.h" 0022 0023 class QTreeWidgetItem; 0024 0025 class KCookiesPolicies : public KCModule 0026 { 0027 Q_OBJECT 0028 0029 public: 0030 //TODO KF6: when dropping compatibility with KF5, remove QVariantList argument 0031 explicit KCookiesPolicies(QObject *parent, const KPluginMetaData &md={}, const QVariantList &args={}); 0032 ~KCookiesPolicies() override; 0033 0034 void load() override; 0035 void save() override; 0036 void defaults() override; 0037 0038 void setPolicy(const QString &domain); 0039 0040 #if QT_VERSION_MAJOR < 6 0041 void setNeedsSave(bool needs) { 0042 m_needsSave = needs; 0043 emit changed(needs); 0044 } 0045 bool needsSave() const {return m_needsSave;} 0046 #endif 0047 0048 protected Q_SLOTS: 0049 void cookiesEnabled(bool); 0050 void configChanged(); 0051 0052 void selectionChanged(); 0053 void updateButtons(); 0054 0055 void deleteAllPressed(); 0056 void deletePressed(); 0057 void changePressed(); 0058 void addPressed(); 0059 void changePressed(QTreeWidgetItem *, bool state = true); 0060 void addPressed(const QString &, bool state = true); 0061 0062 private: 0063 void updateDomainList(const QStringList &list); 0064 bool handleDuplicate(const QString &domain, KonqInterfaces::CookieJar::CookieAdvice advice); 0065 void splitDomainAdvice(const QString &configStr, QString &domain, KonqInterfaces::CookieJar::CookieAdvice &advice); 0066 0067 private: 0068 quint64 mSelectedItemsCount; 0069 Ui::KCookiePoliciesUI mUi; 0070 QMap<QString, KonqInterfaces::CookieJar::CookieAdvice> mDomainPolicyMap; 0071 #if QT_VERSION_MAJOR < 6 0072 bool m_needsSave = false; 0073 #endif 0074 }; 0075 0076 #endif // KCOOKIESPOLICIES_H