linklocator.h
00001 /* 00002 * linklocator.h 00003 * 00004 * Copyright (c) 2002 Dave Corrie <kde@davecorrie.com> 00005 * 00006 * This file is part of KMail. 00007 * 00008 * KMail is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation; either version 2 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * This program is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with this program; if not, write to the Free Software 00020 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00021 */ 00022 00023 #ifndef LINKLOCATOR_H_INCLUDED 00024 #define LINKLOCATOR_H_INCLUDED 00025 00026 #include <tqstring.h> 00027 #include <tqmap.h> 00028 00029 #include <tdepimmacros.h> 00030 00041 class KDE_EXPORT LinkLocator 00042 { 00043 public: 00052 LinkLocator(const TQString& text, int pos = 0); 00053 00064 void setMaxUrlLen(int length); 00065 00071 int maxUrlLen() const; 00072 00083 void setMaxAddressLen(int length); 00084 00091 int maxAddressLen() const; 00092 00101 TQString getUrl(); 00102 00114 TQString getEmailAddress(); 00115 00139 static TQString convertToHtml(const TQString& plainText, int flags = 0, 00140 int maxUrlLen = 4096, int maxAddressLen = 255); 00141 00142 static const int PreserveSpaces = 0x01; 00143 static const int ReplaceSmileys = 0x02; 00144 static const int IgnoreUrls = 0x04; 00145 static const int HighlightText = 0x08; 00146 00151 static TQString pngToDataUrl( const TQString & iconPath ); 00152 00153 protected: 00157 TQString mText; 00161 int mPos; 00162 00163 private: 00164 bool atUrl() const; 00165 bool isEmptyUrl(const TQString& url); 00166 00173 TQString getEmoticon(); 00178 TQString highlightedText(); 00179 00180 int mMaxUrlLen; 00181 int mMaxAddressLen; 00182 00183 // maps the smiley text to the corresponding emoticon name 00184 static TQMap<TQString, TQString> *s_smileyEmoticonNameMap; 00185 // cache for the HTML representation of a smiley 00186 static TQMap<TQString, TQString> *s_smileyEmoticonHTMLCache; 00187 }; 00188 00189 #endif // LINKLOCATOR_H_INCLUDED 00190