linklocator.h
Go to the documentation of this file.
00001 /* 00002 Copyright (c) 2002 Dave Corrie <kde@davecorrie.com> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 Boston, MA 02110-1301, USA. 00018 */ 00029 #ifndef KPIMUTILS_LINKLOCATOR_H 00030 #define KPIMUTILS_LINKLOCATOR_H 00031 00032 #include "kpimutils_export.h" 00033 00034 #include <QtCore/QString> 00035 00036 namespace KPIMUtils { 00037 00048 class KPIMUTILS_EXPORT LinkLocator 00049 { 00050 public: 00058 explicit LinkLocator( const QString &text, int pos = 0 ); 00059 00063 ~LinkLocator(); 00064 00074 void setMaxUrlLen( int length ); 00075 00081 int maxUrlLen() const; 00082 00093 void setMaxAddressLen( int length ); 00094 00099 int maxAddressLen() const; 00100 00109 QString getUrl(); 00110 00121 QString getEmailAddress(); 00122 00143 static QString convertToHtml( const QString &plainText, int flags = 0, 00144 int maxUrlLen = 4096, int maxAddressLen = 255 ); 00145 00146 static const int PreserveSpaces = 0x01; 00147 static const int ReplaceSmileys = 0x02; 00148 static const int IgnoreUrls = 0x04; 00149 static const int HighlightText = 0x08; 00150 00156 static QString pngToDataUrl( const QString & iconPath ); 00157 00158 protected: 00162 QString mText; 00163 00167 int mPos; 00168 00169 bool atUrl() const; 00170 bool isEmptyUrl( const QString &url ) const; 00171 00176 QString highlightedText(); 00177 00178 private: 00179 private: 00180 //@cond PRIVATE 00181 class Private; 00182 Private *const d; 00183 //@endcond 00184 00185 }; 00186 00187 } 00188 00189 #endif