adblockblockableitemswidget.h 2.17 KB
Newer Older
Laurent Montel's avatar
Laurent Montel committed
1
/*
Laurent Montel's avatar
Laurent Montel committed
2
   Copyright (C) 2016-2020 Laurent Montel <montel@kde.org>
Laurent Montel's avatar
Laurent Montel committed
3

Laurent Montel's avatar
Laurent Montel committed
4
5
6
7
   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.
Laurent Montel's avatar
Laurent Montel committed
8

Laurent Montel's avatar
Laurent Montel committed
9
10
11
12
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   General Public License for more details.
Laurent Montel's avatar
Laurent Montel committed
13

Laurent Montel's avatar
Laurent Montel committed
14
15
16
17
   You should have received a copy of the GNU General Public License
   along with this program; see the file COPYING.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301, USA.
Laurent Montel's avatar
Laurent Montel committed
18
19
20
21
22
23
*/

#ifndef ADBLOCKBLOCKABLEITEMSWIDGET_H
#define ADBLOCKBLOCKABLEITEMSWIDGET_H

#include <QWidget>
Laurent Montel's avatar
Laurent Montel committed
24
#include "adblocklib_export.h"
Laurent Montel's avatar
Laurent Montel committed
25
namespace PimCommon {
Laurent Montel's avatar
Laurent Montel committed
26
27
class CustomTreeView;
}
Laurent Montel's avatar
Laurent Montel committed
28
namespace AdBlock {
Laurent Montel's avatar
Laurent Montel committed
29
struct AdBlockResult;
Laurent Montel's avatar
Laurent Montel committed
30
class ADBLOCKLIB_EXPORT AdBlockBlockableItemsWidget : public QWidget
Laurent Montel's avatar
Laurent Montel committed
31
32
33
{
    Q_OBJECT
public:
Laurent Montel's avatar
Laurent Montel committed
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
    enum TypeElement {
        None = 0,
        Image,
        Script,
        StyleSheet,
        Font,
        Frame,
        XmlRequest,
        Object,
        Media,
        Popup,

        MaxTypeElement
    };

Laurent Montel's avatar
Laurent Montel committed
49
    explicit AdBlockBlockableItemsWidget(QWidget *parent = nullptr);
Laurent Montel's avatar
Laurent Montel committed
50
51
    ~AdBlockBlockableItemsWidget();

Laurent Montel's avatar
Laurent Montel committed
52
    void setAdblockResult(const QVector<AdBlock::AdBlockResult> &result);
53
    void saveFilters();
Laurent Montel's avatar
Laurent Montel committed
54

Laurent Montel's avatar
Laurent Montel committed
55
56
    static QString elementType(AdBlockBlockableItemsWidget::TypeElement type);
    static QString elementTypeToI18n(AdBlockBlockableItemsWidget::TypeElement type);
57
58

private:
Laurent Montel's avatar
Laurent Montel committed
59
    void slotCustomContextMenuRequested(const QPoint &);
Laurent Montel's avatar
Laurent Montel committed
60
61
62
63
    void slotCopyFilterItem();
    void slotOpenItem();
    void slotBlockItem();
    void slotCopyItem();
Laurent Montel's avatar
Laurent Montel committed
64
    void slotRemoveFilter();
Laurent Montel's avatar
Laurent Montel committed
65
66
67
68
69
    enum BlockType {
        FilterValue = 0,
        Url,
        Type
    };
Laurent Montel's avatar
Laurent Montel committed
70
71
72
    enum TypeItem {
        Element = Qt::UserRole + 1
    };
Laurent Montel's avatar
Laurent Montel committed
73

Laurent Montel's avatar
Laurent Montel committed
74
75
76
    void writeConfig();
    void searchBlockableItems();
    void readConfig();
Laurent Montel's avatar
Laurent Montel committed
77
    PimCommon::CustomTreeView *mListItems = nullptr;
Laurent Montel's avatar
Laurent Montel committed
78
};
Laurent Montel's avatar
Laurent Montel committed
79
}
Laurent Montel's avatar
Laurent Montel committed
80
#endif // ADBLOCKBLOCKABLEITEMSWIDGET_H