Modified UserInfo to use TextModifier class.
[situare] / src / ui / textmodifier.h
1 #ifndef TEXTMODIFIER_H
2 #define TEXTMODIFIER_H
3
4 #include <QObject>
5
6 class QFontMetrics;
7
8 class TextModifier : public QObject
9 {
10     Q_OBJECT
11 public:
12     TextModifier(QObject *parent = 0);
13
14     /**
15     * @brief Shortens text to fit.
16     *
17     * Text shortening is defined by text maximum width.
18     *
19     * @param fontMetrics font metrics to use
20     * @param text text to shorten
21     * @param textMaxWidth maximum width for text
22     */
23     static QString shortenText(const QFontMetrics fontMetrics, const QString &text,
24                                int textMaxWidth);
25
26     /**
27      * @brief Splits too long word.
28      *
29      * Splits long word to several by adding extra spaces
30      *
31      * @param fontMetrics font metrics to use
32      * @param word long word to be splitted
33      * @param textMaxWidth maximum width for word
34      * @returns splitted word
35      */
36     static QString splitWord(const QFontMetrics fontMetrics, const QString &word, int textMaxWidth);
37
38     /**
39      * @brief Splits long words from text.
40      *
41      * Splits long words to several by adding extra spaces
42      *
43      * @param fontMetrics font metrics to use
44      * @param text text to be splitted
45      * @param textMaxWidth maximum width for word
46      * @returns text with long words splitted
47      */
48     static QString splitLongWords(const QFontMetrics fontMetrics, const QString &text,
49                                   int textMaxWidth);
50 };
51
52 #endif // TEXTMODIFIER_H