File indexing completed on 2024-04-21 04:47:49
0001 /**************************************************************************************** 0002 * Copyright (c) 2008 Nicos Gollan <gtdev@spearhead.de> * 0003 * Copyright (c) 2008 Téo Mrnjavac <teo@kde.org> * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify it under * 0006 * the terms of the GNU General Public License as published by the Free Software * 0007 * Foundation; either version 2 of the License, or (at your option) any later * 0008 * version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 0011 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 0012 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 0013 * * 0014 * You should have received a copy of the GNU General Public License along with * 0015 * this program. If not, see <http://www.gnu.org/licenses/>. * 0016 ****************************************************************************************/ 0017 0018 #ifndef CASECONVERTER_H 0019 #define CASECONVERTER_H 0020 0021 #include <QString> 0022 0023 namespace Amarok 0024 { 0025 /** Case converter for tag formatting. 0026 * 0027 * Provides helper functions to achieve sane capitalization of tag 0028 * information. 0029 */ 0030 class CaseConverter 0031 { 0032 public: 0033 /** Convert to "title case". 0034 * 0035 * Title case tries to conform to the common capitalization of titles, 0036 * i.e. first letter of each word is capitalized, except for "small" 0037 * words like "in", "of", etc. 0038 * 0039 * This implementation will also leave alone words that already have 0040 * some kind of capitalization, assuming that those are properly 0041 * formatted. 0042 * 0043 * @param s A string to be converted 0044 * @return The converted string 0045 */ 0046 static QString toTitleCase( const QString &s ); 0047 /** Convert to "capitalized case" 0048 * 0049 * Capitalizes the initial letter of each word. 0050 * 0051 * @param s A string to be converted 0052 * @return The converted string 0053 */ 0054 static QString toCapitalizedCase( const QString &s ); 0055 private: 0056 /// regular expression for a word. 0057 static const QString s_MATCH_A_WORD; 0058 /** "small words" that ought not be capitalized. 0059 * 0060 * This is mostly English only. 0061 */ 0062 static const QString s_LITTLE_WORDS; 0063 }; 0064 } 0065 0066 #endif //CASECONVERTER_H