Falkon Develop
Cross-platform Qt-based web browser
adblocksubscription.h
Go to the documentation of this file.
1/* ============================================================
2* Falkon - Qt web browser
3* Copyright (C) 2010-2016 David Rosca <nowrep@gmail.com>
4*
5* This program is free software: you can redistribute it and/or modify
6* it under the terms of the GNU General Public License as published by
7* the Free Software Foundation, either version 3 of the License, or
8* (at your option) any later version.
9*
10* This program is distributed in the hope that it will be useful,
11* but WITHOUT ANY WARRANTY; without even the implied warranty of
12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13* GNU General Public License for more details.
14*
15* You should have received a copy of the GNU General Public License
16* along with this program. If not, see <http://www.gnu.org/licenses/>.
17* ============================================================ */
46#ifndef ADBLOCKSUBSCRIPTION_H
47#define ADBLOCKSUBSCRIPTION_H
48
49#include <QVector>
50#include <QUrl>
51
52#include "qzcommon.h"
53#include "adblockrule.h"
54#include "adblocksearchtree.h"
55
56class QUrl;
57class QNetworkReply;
58
59class FALKON_EXPORT AdBlockSubscription : public QObject
60{
61 Q_OBJECT
62public:
63 explicit AdBlockSubscription(const QString &title, QObject* parent = nullptr);
65
66 QString title() const;
67
68 QString filePath() const;
69 void setFilePath(const QString &path);
70
71 QUrl url() const;
72 void setUrl(const QUrl &url);
73
74 virtual void loadSubscription(const QStringList &disabledRules);
75 virtual void saveSubscription();
76
77 const AdBlockRule* rule(int offset) const;
78 QVector<AdBlockRule*> allRules() const;
79
80 const AdBlockRule* enableRule(int offset);
81 const AdBlockRule* disableRule(int offset);
82
83 virtual bool canEditRules() const;
84 virtual bool canBeRemoved() const;
85
86 virtual int addRule(AdBlockRule* rule);
87 virtual bool removeRule(int offset);
88 virtual const AdBlockRule* replaceRule(AdBlockRule* rule, int offset);
89
90public Q_SLOTS:
91 void updateSubscription();
92
93Q_SIGNALS:
96 void subscriptionError(const QString &message);
97
98protected Q_SLOTS:
99 void subscriptionDownloaded();
100
101protected:
102 virtual bool saveDownloadedData(const QByteArray &data);
103
104 QNetworkReply *m_reply;
105 QVector<AdBlockRule*> m_rules;
106
107private:
108 QString m_title;
109 QString m_filePath;
110
111 QUrl m_url;
112 bool m_updated;
113};
114
116{
117 Q_OBJECT
118public:
119 explicit AdBlockCustomList(QObject* parent = nullptr);
120
121 void loadSubscription(const QStringList &disabledRules) override;
122 void saveSubscription() override;
123
124 bool canEditRules() const override;
125 bool canBeRemoved() const override;
126
127 bool containsFilter(const QString &filter) const;
128 bool removeFilter(const QString &filter);
129
130 int addRule(AdBlockRule* rule) override;
131 bool removeRule(int offset) override;
132 const AdBlockRule* replaceRule(AdBlockRule* rule, int offset) override;
133};
134
135#endif // ADBLOCKSUBSCRIPTION_H
136
int addRule(AdBlockRule *rule) override
void loadSubscription(const QStringList &disabledRules) override
bool removeRule(int offset) override
bool removeFilter(const QString &filter)
bool canBeRemoved() const override
void saveSubscription() override
AdBlockCustomList(QObject *parent=nullptr)
const AdBlockRule * replaceRule(AdBlockRule *rule, int offset) override
bool containsFilter(const QString &filter) const
bool canEditRules() const override
const AdBlockRule * rule(int offset) const
void subscriptionError(const QString &message)
QVector< AdBlockRule * > m_rules
#define FALKON_EXPORT
Definition: qzcommon.h:28