kpimutils
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 */ 00030 #ifndef KPIMUTILS_LINKLOCATOR_H 00031 #define KPIMUTILS_LINKLOCATOR_H 00032 00033 #include "kpimutils_export.h" 00034 00035 #include <QtCore/QString> 00036 #include <QtCore/QMap> 00037 00038 namespace KPIMUtils { 00039 00050 class KPIMUTILS_EXPORT LinkLocator 00051 { 00052 public: 00060 explicit LinkLocator( const QString &text, int pos = 0 ); 00061 00065 ~LinkLocator(); 00066 00076 void setMaxUrlLen( int length ); 00077 00083 int maxUrlLen() const; 00084 00095 void setMaxAddressLen( int length ); 00096 00101 int maxAddressLen() const; 00102 00111 QString getUrl(); 00112 00123 QString getEmailAddress(); 00124 00145 static QString convertToHtml( const QString &plainText, int flags = 0, 00146 int maxUrlLen = 4096, int maxAddressLen = 255 ); 00147 00148 static const int PreserveSpaces = 0x01; 00149 static const int ReplaceSmileys = 0x02; 00150 static const int IgnoreUrls = 0x04; 00151 static const int HighlightText = 0x08; 00152 00158 static QString pngToDataUrl( const QString & iconPath ); 00159 00160 protected: 00164 QString mText; 00165 00169 int mPos; 00170 00171 bool atUrl() const; 00172 bool isEmptyUrl( const QString &url ) const; 00173 00178 QString highlightedText(); 00179 00180 private: 00181 private: 00182 //@cond PRIVATE 00183 class Private; 00184 Private *const d; 00185 //@endcond 00186 00187 }; 00188 00189 } 00190 00191 #endif