libtdepim

linklocator.h
1/*
2 * linklocator.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 LINKLOCATOR_H_INCLUDED
24#define LINKLOCATOR_H_INCLUDED
25
26#include <tqstring.h>
27#include <tqmap.h>
28
29#include <tdemacros.h>
30
41class TDE_EXPORT LinkLocator
42{
43public:
52 LinkLocator(const TQString& text, int pos = 0);
53
64 void setMaxUrlLen(int length);
65
71 int maxUrlLen() const;
72
83 void setMaxAddressLen(int length);
84
91 int maxAddressLen() const;
92
101 TQString getUrl();
102
114 TQString getEmailAddress();
115
139 static TQString convertToHtml(const TQString& plainText, int flags = 0,
140 int maxUrlLen = 4096, int maxAddressLen = 255);
141
142 static const int PreserveSpaces = 0x01;
143 static const int ReplaceSmileys = 0x02;
144 static const int IgnoreUrls = 0x04;
145 static const int HighlightText = 0x08;
146
151 static TQString pngToDataUrl( const TQString & iconPath );
152
153protected:
157 TQString mText;
161 int mPos;
162
163private:
164 bool atUrl() const;
165 bool isEmptyUrl(const TQString& url);
166
173 TQString getEmoticon();
178 TQString highlightedText();
179
180 int mMaxUrlLen;
181 int mMaxAddressLen;
182
183 // maps the smiley text to the corresponding emoticon name
184 static TQMap<TQString, TQString> *s_smileyEmoticonNameMap;
185 // cache for the HTML representation of a smiley
186 static TQMap<TQString, TQString> *s_smileyEmoticonHTMLCache;
187};
188
189#endif // LINKLOCATOR_H_INCLUDED
190
LinkLocator assists in identifying sections of text that can usefully be converted in hyperlinks in h...
Definition: linklocator.h:42
int mPos
The current scan position.
Definition: linklocator.h:161
TQString mText
The plaintext string being scanned for URLs and email addresses.
Definition: linklocator.h:157