Added missing comments.
[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     TextModifier(QObject *parent = 0);
38
39     /**
40     * @brief Shortens text to fit.
41     *
42     * Text shortening is defined by text maximum width.
43     *
44     * @param fontMetrics font metrics to use
45     * @param text text to shorten
46     * @param textMaxWidth maximum width for text
47     */
48     static QString shortenText(const QFontMetrics fontMetrics, const QString &text,
49                                int textMaxWidth);
50
51     /**
52      * @brief Splits too long word.
53      *
54      * Splits long word to several by adding extra spaces
55      *
56      * @param fontMetrics font metrics to use
57      * @param word long word to be splitted
58      * @param textMaxWidth maximum width for word
59      * @returns splitted word
60      */
61     static QString splitWord(const QFontMetrics fontMetrics, const QString &word, int textMaxWidth);
62
63     /**
64      * @brief Splits long words from text.
65      *
66      * Splits long words to several by adding extra spaces
67      *
68      * @param fontMetrics font metrics to use
69      * @param text text to be splitted
70      * @param textMaxWidth maximum width for word
71      * @returns text with long words splitted
72      */
73     static QString splitLongWords(const QFontMetrics fontMetrics, const QString &text,
74                                   int textMaxWidth);
75 };
76
77 #endif // TEXTMODIFIER_H