| 1 |
/**************************************************************************************** |
| 2 |
* Copyright (c) 2008 Nicos Gollan <gtdev@spearhead.de> * |
| 3 |
* Copyright (c) 2008 Téo Mrnjavac <teo@kde.org> * |
| 4 |
* * |
| 5 |
* This program is free software; you can redistribute it and/or modify it under * |
| 6 |
* the terms of the GNU General Public License as published by the Free Software * |
| 7 |
* Foundation; either version 2 of the License, or (at your option) any later * |
| 8 |
* version. * |
| 9 |
* * |
| 10 |
* This program is distributed in the hope that it will be useful, but WITHOUT ANY * |
| 11 |
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * |
| 12 |
* PARTICULAR PURPOSE. See the GNU General Public License for more details. * |
| 13 |
* * |
| 14 |
* You should have received a copy of the GNU General Public License along with * |
| 15 |
* this program. If not, see <http://www.gnu.org/licenses/>. * |
| 16 |
****************************************************************************************/ |
| 17 |
|
| 18 |
#ifndef CASECONVERTER_H |
| 19 |
#define CASECONVERTER_H |
| 20 |
|
| 21 |
#include <QString> |
| 22 |
|
| 23 |
namespace Amarok |
| 24 |
{ |
| 25 |
/** Case converter for tag formatting. |
| 26 |
* |
| 27 |
* Provides helper functions to achieve sane capitalization of tag |
| 28 |
* information. |
| 29 |
*/ |
| 30 |
class CaseConverter |
| 31 |
{ |
| 32 |
public: |
| 33 |
/** Convert to "title case". |
| 34 |
* |
| 35 |
* Title case tries to conform to the common capitalization of titles, |
| 36 |
* i.e. first letter of each word is capitalized, except for "small" |
| 37 |
* words like "in", "of", etc. |
| 38 |
* |
| 39 |
* This implementation will also leave alone words that already have |
| 40 |
* some kind of capitalization, assuming that those are properly |
| 41 |
* formatted. |
| 42 |
* |
| 43 |
* @param s A string to be converted |
| 44 |
* @return The converted string |
| 45 |
*/ |
| 46 |
static QString toTitleCase( const QString &s ); |
| 47 |
/** Convert to "capitalized case" |
| 48 |
* |
| 49 |
* Capitalizes the initial letter of each word. |
| 50 |
* |
| 51 |
* @param s A string to be converted |
| 52 |
* @return The converted string |
| 53 |
*/ |
| 54 |
static QString toCapitalizedCase( const QString &s ); |
| 55 |
private: |
| 56 |
/// regular expression for a word. |
| 57 |
static const QString s_MATCH_A_WORD; |
| 58 |
/** "small words" that ought not be capitalized. |
| 59 |
* |
| 60 |
* This is mostly English only. |
| 61 |
*/ |
| 62 |
static const QString s_LITTLE_WORDS; |
| 63 |
}; |
| 64 |
} |
| 65 |
|
| 66 |
#endif //CASECONVERTER_H |