summaryrefslogtreecommitdiffstats
path: root/knode/knarticlefilter.h
blob: b01cdf6a3ab881089e3b997fd972310637ab7fe4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
    knarticlefilter.h

    KNode, the KDE newsreader
    Copyright (c) 1999-2001 the KNode authors.
    See file AUTHORS for details

    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.
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software Foundation,
    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, US
*/

#ifndef KNARTICLEFILTER_H
#define KNARTICLEFILTER_H

#include "knstatusfilter.h"
#include "knrangefilter.h"
#include "knstringfilter.h"

class KNRemoteArticle;
class KNLocalArticle;
class KNGroup;
class KNFolder;


class KNArticleFilter {

  friend class KNFilterManager;
  friend class KNFilterDialog;
  friend class KNSearchDialog;

  public:
    KNArticleFilter(int id=-1);
    KNArticleFilter(const KNArticleFilter& org);   // constructs a copy of org
    ~KNArticleFilter();

    bool loadInfo();
    void load();
    void save();

    void doFilter(KNGroup *g);
    void doFilter(KNFolder *f);
    int count()const                     { return c_ount; }
    int id()const                        { return i_d; }
    int applyOn()                   { return static_cast<int>(apon); }
    const TQString& name()           { return n_ame; }
    TQString translatedName();        // *tries* to translate the name
    bool isEnabled()const                { return e_nabled; }
    bool loaded()const                   { return l_oaded; }
    bool isSearchFilter()const           { return s_earchFilter; }

    void setId(int i)               { i_d=i; }
    void setApplyOn(int i)          { apon=(ApOn)i; }
    void setLoaded(bool l)          { l_oaded=l; }
    void setName(const TQString &s)  { n_ame=s; }
    void setTranslatedName(const TQString &s);     // *tries* to retranslate the name to english
    void setEnabled(bool l)         { e_nabled=l; }
    void setSearchFilter(bool b)    { s_earchFilter = b; }

  protected:

    enum ApOn { articles=0 , threads=1 };
    bool applyFilter(KNRemoteArticle *a);
    bool applyFilter(KNLocalArticle *a);

    TQString n_ame;
    int i_d, c_ount;
    bool l_oaded, e_nabled, translateName, s_earchFilter;
    ApOn apon;

    KNStatusFilter status;
    KNRangeFilter score, age, lines;
    KNStringFilter subject, from, messageId, references;
};

#endif