Fixed FacebookLoginBrowser::destroyed() signal handling
[situare] / src / ui / textmodifier.h
1 /*
2    Situare - A location system for Facebook
3    Copyright (C) 2010  Ixonos Plc. Authors:
4
5        Katri Kaikkonen - katri.kaikkonen@ixonos.com
6        Jussi Laitinen - jussi.laitinen@ixonos.com
7
8    Situare is free software; you can redistribute it and/or
9    modify it under the terms of the GNU General Public License
10    version 2 as published by the Free Software Foundation.
11
12    Situare is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with Situare; if not, write to the Free Software
19    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
20    USA.
21 */
22
23 #ifndef TEXTMODIFIER_H
24 #define TEXTMODIFIER_H
25
26 #include <QObject>
27
28 class QFontMetrics;
29
30 /**
31 * @brief Contains helper methods to modify text.
32 */
33 class TextModifier : public QObject
34 {
35     Q_OBJECT
36 public:
37     /**
38     * @brief Shortens text to fit.
39     *
40     * Text shortening is defined by text maximum width.
41     *
42     * @param fontMetrics font metrics to use
43     * @param text text to shorten
44     * @param textMaxWidth maximum width for text
45     */
46     static QString shortenText(const QFontMetrics fontMetrics, const QString &text,
47                                int textMaxWidth);
48
49     /**
50      * @brief Splits too long word.
51      *
52      * Splits long word to several by adding extra spaces
53      *
54      * @param fontMetrics font metrics to use
55      * @param word long word to be splitted
56      * @param textMaxWidth maximum width for word
57      * @returns splitted word
58      */
59     static QString splitWord(const QFontMetrics fontMetrics, const QString &word, int textMaxWidth);
60
61     /**
62      * @brief Splits long words from text.
63      *
64      * Splits long words to several by adding extra spaces
65      *
66      * @param fontMetrics font metrics to use
67      * @param text text to be splitted
68      * @param textMaxWidth maximum width for word
69      * @returns text with long words splitted
70      */
71     static QString splitLongWords(const QFontMetrics fontMetrics, const QString &text,
72                                   int textMaxWidth);
73 };
74
75 #endif // TEXTMODIFIER_H