libtdepim

spellingfilter.h
1 /*
2  * spellingfilter.h
3  *
4  * Copyright (c) 2002 Dave Corrie <kde@davecorrie.com>
5  *
6  * This file is part of KMail.
7  *
8  * KMail is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 #ifndef SPELLINGFILTER_H_INCLUDED
24 #define SPELLINGFILTER_H_INCLUDED
25 
26 #include <tqstring.h>
27 #include <tqstringlist.h>
28 #include "linklocator.h"
29 
30 #include <kdemacros.h>
31 
32 class TDE_EXPORT SpellingFilter
33 {
34 public:
35  enum UrlFiltering { DontFilterUrls, FilterUrls };
36  enum EmailAddressFiltering { DontFilterEmailAddresses, FilterEmailAddresses };
37 
38  SpellingFilter(const TQString& text, const TQString& quotePrefix,
39  UrlFiltering filterUrls = FilterUrls,
40  EmailAddressFiltering filterEmailAddresses = FilterEmailAddresses,
41  const TQStringList& filterStrings = TQStringList());
42 
43  TQString originalText() const;
44  TQString filteredText() const;
45 
46  class TextCensor;
47 
48 private:
49  const TQString mOriginal;
50  TQString mFiltered;
51 };
52 
53 class SpellingFilter::TextCensor : public LinkLocator
54 {
55 public:
56  TextCensor(const TQString& s);
57 
58  void censorQuotations(const TQString& quotePrefix);
59  void censorUrls();
60  void censorEmailAddresses();
61  void censorString(const TQString& s);
62 
63  TQString censoredText() const;
64 
65 private:
66  bool atLineStart() const;
67  void skipLine();
68 
69  bool atQuotation(const TQString& quotePrefix) const;
70  void skipQuotation(const TQString& quotePrefix);
71  void findQuotation(const TQString& quotePrefix);
72 
73  void findEmailAddress();
74 };
75 
76 #endif // SPELLINGFILTER_H_INCLUDED
77 
LinkLocator assists in identifying sections of text that can usefully be converted in hyperlinks in h...
Definition: linklocator.h:42