kpimutils
spellingfilter.h
Go to the documentation of this file.
00001 /* 00002 * spellingfilter.h 00003 * 00004 * Copyright (c) 2002 Dave Corrie <kde@davecorrie.com> 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Library General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Library General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Library General Public License 00017 * along with this library; see the file COPYING.LIB. If not, write to 00018 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 * Boston, MA 02110-1301, USA. 00020 */ 00032 #ifndef KPIMUTILS_SPELLINGFILTER_H 00033 #define KPIMUTILS_SPELLINGFILTER_H 00034 00035 #include "kpimutils_export.h" 00036 #include "linklocator.h" 00037 00038 #include <QtCore/QString> 00039 #include <QtCore/QStringList> 00040 00041 namespace KPIMUtils { 00042 00043 class KPIMUTILS_EXPORT SpellingFilter 00044 { 00045 public: 00046 enum UrlFiltering { 00047 DontFilterUrls, 00048 FilterUrls 00049 }; 00050 enum EmailAddressFiltering { 00051 DontFilterEmailAddresses, 00052 FilterEmailAddresses 00053 }; 00054 00055 SpellingFilter( const QString &text, const QString "ePrefix, 00056 UrlFiltering filterUrls = FilterUrls, 00057 EmailAddressFiltering filterEmailAddresses = FilterEmailAddresses, 00058 const QStringList &filterStrings = QStringList() ); 00059 ~SpellingFilter(); 00060 00061 QString originalText() const; 00062 QString filteredText() const; 00063 00064 class TextCensor; 00065 00066 private: 00067 //@cond PRIVATE 00068 class Private; 00069 Private *const d; 00070 //@endcond 00071 }; 00072 00073 class SpellingFilter::TextCensor : public LinkLocator 00074 { 00075 public: 00076 TextCensor( const QString &s ); 00077 00078 void censorQuotations( const QString "ePrefix ); 00079 void censorUrls(); 00080 void censorEmailAddresses(); 00081 void censorString( const QString &s ); 00082 00083 QString censoredText() const; 00084 00085 private: 00086 bool atLineStart() const; 00087 void skipLine(); 00088 00089 bool atQuotation( const QString "ePrefix ) const; 00090 void skipQuotation( const QString "ePrefix ); 00091 void findQuotation( const QString "ePrefix ); 00092 00093 void findEmailAddress(); 00094 }; 00095 00096 } 00097 00098 #endif