File indexing completed on 2024-04-28 04:55:50

0001 /*
0002     This file is part of Choqok, the KDE micro-blogging client
0003 
0004     SPDX-FileCopyrightText: 2010-2012 Mehrdad Momeny <mehrdad.momeny@gmail.com>
0005 
0006     SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0007 */
0008 
0009 #ifndef FILTERMANAGER_H
0010 #define FILTERMANAGER_H
0011 
0012 #include <QPointer>
0013 #include <QQueue>
0014 
0015 #include "plugin.h"
0016 
0017 #include "filter.h"
0018 
0019 class QAction;
0020 namespace Choqok
0021 {
0022 namespace UI
0023 {
0024 class PostWidget;
0025 }
0026 }
0027 
0028 /**
0029 Filter Manager
0030 
0031 @author Mehrdad Momeny \<mehrdad.momeny@gmail.com\>
0032 */
0033 class FilterManager : public Choqok::Plugin
0034 {
0035     Q_OBJECT
0036 public:
0037     FilterManager(QObject *parent, const QList< QVariant > &args);
0038     ~FilterManager();
0039 
0040 protected Q_SLOTS:
0041     void slotAddNewPostWidget(Choqok::UI::PostWidget *newWidget);
0042     void startParsing();
0043     void slotConfigureFilters();
0044     void slotHidePost();
0045 
0046 private:
0047     enum ParserState { Stopped = 0, Running };
0048     ParserState state;
0049 
0050     Filter::FilterAction filterText(const QString &textToCheck, Filter *filter);
0051     void doFiltering(Choqok::UI::PostWidget *postToFilter, Filter::FilterAction action);
0052 
0053     void parse(Choqok::UI::PostWidget *postToParse);
0054     QQueue< QPointer<Choqok::UI::PostWidget> > postsQueue;
0055 
0056     bool parseSpecialRules(Choqok::UI::PostWidget *postToParse);
0057 
0058     QAction *hidePost;
0059 };
0060 
0061 #endif