|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Small helper utility to localize radio genres |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef RADIOGENRELOCALIZER_H |
|
19 #define RADIOGENRELOCALIZER_H |
|
20 |
|
21 #include "radio_global.h" |
|
22 |
|
23 // Constants |
|
24 |
|
25 namespace RadioGenreLocalizer |
|
26 { |
|
27 |
|
28 struct GenreMap |
|
29 { |
|
30 int mGenreCode; |
|
31 const char* mInCarousel; |
|
32 const char* mInStationsList; |
|
33 const char* mInHomeScreen; |
|
34 }; |
|
35 |
|
36 static QString genreToString( RadioRegion::Region region, int genre, GenreTarget::Target target ); |
|
37 } |
|
38 |
|
39 // Convenience macros to help in the construction of the localization tables |
|
40 #define BEGIN_GENRE_MAP(name) const RadioGenreLocalizer::GenreMap name[] = { |
|
41 #define EUROPEAN_GENRE(code, inCarousel, inStationsList, inHomescreen ) { GenreEurope::code, inCarousel, inStationsList, inHomescreen } |
|
42 #define AMERICAN_GENRE(code, inCarousel, inStationsList, inHomescreen ) { GenreAmerica::code, inCarousel, inStationsList, inHomescreen } |
|
43 #define END_GENRE_MAP(name) }; const int name ## Count = sizeof ( name ) / sizeof ( name[0] ); |
|
44 |
|
45 BEGIN_GENRE_MAP( EuropeanGenres ) |
|
46 // Genre code // Text in Carousel // Text in Stations list // Text in Homescreen widget |
|
47 EUROPEAN_GENRE( RdsNone, "", "", "" ), |
|
48 EUROPEAN_GENRE( RdsNews, "txt_rad_info_news", "txt_rad_dblist_l1_mhz_val_news", "txt_rad_info_news_hs" ), |
|
49 EUROPEAN_GENRE( RdsCurrentAffairs, "txt_rad_info_current_affairs", "txt_rad_dblist_l1_mhz_val_current_affairs", "txt_rad_info_current_affairs_hs" ), |
|
50 EUROPEAN_GENRE( RdsInformation, "txt_rad_info_information", "txt_rad_dblist_l1_mhz_val_information", "txt_rad_info_information_hs" ), |
|
51 EUROPEAN_GENRE( RdsSport, "txt_rad_info_sport", "txt_rad_dblist_l1_mhz_val_sport", "txt_rad_info_sport_hs" ), |
|
52 EUROPEAN_GENRE( RdsEducation, "txt_rad_info_education", "txt_rad_dblist_l1_mhz_val_education", "txt_rad_info_education_hs" ), |
|
53 EUROPEAN_GENRE( RdsDrama, "txt_rad_info_drama", "txt_rad_dblist_l1_mhz_val_drama", "txt_rad_info_drama_hs" ), |
|
54 EUROPEAN_GENRE( RdsCulture, "txt_rad_info_culture", "txt_rad_dblist_l1_mhz_val_culture", "txt_rad_info_culture_hs" ), |
|
55 EUROPEAN_GENRE( RdsScience, "txt_rad_info_science", "txt_rad_dblist_l1_mhz_val_science", "txt_rad_info_science_hs" ), |
|
56 EUROPEAN_GENRE( RdsVariedSpeech, "txt_rad_info_varied", "txt_rad_dblist_l1_mhz_val_varied", "txt_rad_info_varied_hs" ), |
|
57 EUROPEAN_GENRE( RdsPopMusic, "txt_rad_info_pop_music", "txt_rad_dblist_l1_mhz_val_pop_music", "txt_rad_info_pop_music_hs" ), |
|
58 EUROPEAN_GENRE( RdsRockMusic, "txt_rad_info_rock_music", "txt_rad_dblist_l1_mhz_val_rock_music", "txt_rad_info_rock_music_hs" ), |
|
59 EUROPEAN_GENRE( RdsEasyListening, "txt_rad_info_easy_listening", "txt_rad_dblist_l1_mhz_val_easy_listening", "txt_rad_info_easy_listening_hs" ), |
|
60 EUROPEAN_GENRE( RdsLightClassical, "txt_rad_info_light_classical", "txt_rad_dblist_l1_mhz_val_light_classical", "txt_rad_info_light_classical_hs" ), |
|
61 EUROPEAN_GENRE( RdsSeriousClassical, "txt_rad_info_serious_classical", "txt_rad_dblist_l1_mhz_val_serious_classical", "txt_rad_info_serious_classical_hs" ), |
|
62 EUROPEAN_GENRE( RdsOtherMusic, "txt_rad_info_other_music", "txt_rad_dblist_l1_mhz_val_other_music", "txt_rad_info_other_music_hs" ), |
|
63 EUROPEAN_GENRE( RdsWeather, "txt_rad_info_weather", "txt_rad_dblist_l1_mhz_val_weather", "txt_rad_info_weather_hs" ), |
|
64 EUROPEAN_GENRE( RdsFinance, "txt_rad_info_finance", "txt_rad_dblist_l1_mhz_val_finance", "txt_rad_info_finance_hs" ), |
|
65 EUROPEAN_GENRE( RdsChildrensProgrammes, "txt_rad_info_childrens_programmes", "txt_rad_dblist_l1_mhz_val_childrens_programmes", "txt_rad_info_childrens_programmes_hs" ), |
|
66 EUROPEAN_GENRE( RdsSocialAffairs, "txt_rad_info_social_affairs", "txt_rad_dblist_l1_mhz_val_social_affairs", "txt_rad_info_social_affairs_hs" ), |
|
67 EUROPEAN_GENRE( RdsReligion, "txt_rad_info_religion", "txt_rad_dblist_l1_mhz_val_religion", "txt_rad_info_religion_hs" ), |
|
68 EUROPEAN_GENRE( RdsPhoneIn, "txt_rad_info_phone_in", "txt_rad_dblist_l1_mhz_val_phone_in", "txt_rad_info_phone_in_hs" ), |
|
69 EUROPEAN_GENRE( RdsTravel, "txt_rad_info_travel", "txt_rad_dblist_l1_mhz_val_travel", "txt_rad_info_travel_hs" ), |
|
70 EUROPEAN_GENRE( RdsLeisure, "txt_rad_info_leisure", "txt_rad_dblist_l1_mhz_val_leisure", "txt_rad_info_leisure_hs" ), |
|
71 EUROPEAN_GENRE( RdsJazzMusic, "txt_rad_info_jazz_music", "txt_rad_dblist_l1_mhz_val_jazz_music", "txt_rad_info_jazz_music_hs" ), |
|
72 EUROPEAN_GENRE( RdsCountryMusic, "txt_rad_info_country_music", "txt_rad_dblist_l1_mhz_val_country_music", "txt_rad_info_country_music_hs" ), |
|
73 EUROPEAN_GENRE( RdsNationalMusic, "txt_rad_info_national_music", "txt_rad_dblist_l1_mhz_val_national_music", "txt_rad_info_national_music_hs" ), |
|
74 EUROPEAN_GENRE( RdsOldiesMusic, "txt_rad_info_oldies_music", "txt_rad_dblist_l1_mhz_val_oldies_music", "txt_rad_info_oldies_music_hs" ), |
|
75 EUROPEAN_GENRE( RdsFolkMusic, "txt_rad_info_folk_music", "txt_rad_dblist_l1_mhz_val_folk_music", "txt_rad_info_folk_music_hs" ), |
|
76 EUROPEAN_GENRE( RdsDocumentary, "txt_rad_info_documentary", "txt_rad_dblist_l1_mhz_val_documentary", "txt_rad_info_documentary_hs" ), |
|
77 EUROPEAN_GENRE( RdsAlarmTest, "txt_rad_info_alarm_test", "txt_rad_dblist_l1_mhz_val_alarm_test", "txt_rad_info_alarm_test_hs" ), |
|
78 EUROPEAN_GENRE( RdsAlarm, "txt_rad_info_alarm", "txt_rad_dblist_l1_mhz_val_alarm", "txt_rad_info_alarm_hs" ) |
|
79 END_GENRE_MAP( EuropeanGenres ) |
|
80 |
|
81 BEGIN_GENRE_MAP( AmericanGenres ) |
|
82 // Genre code // Text in Carousel // Text in Stations list // Text in Homescreen widget |
|
83 AMERICAN_GENRE( RbdsNone, "", "", "" ), |
|
84 AMERICAN_GENRE( RbdsNews, "txt_rad_info_news", "txt_rad_dblist_l1_mhz_val_news", "txt_rad_info_news_hs" ), |
|
85 AMERICAN_GENRE( RbdsInformation, "txt_rad_info_information", "txt_rad_dblist_l1_mhz_val_information", "txt_rad_info_information_hs" ), |
|
86 AMERICAN_GENRE( RbdsSports, "txt_rad_info_sport", "txt_rad_dblist_l1_mhz_val_sport", "txt_rad_info_sport_hs" ), |
|
87 AMERICAN_GENRE( RbdsTalk, "txt_rad_info_talk", "txt_rad_dblist_l1_mhz_val_talk", "txt_rad_info_talk_hs" ), |
|
88 AMERICAN_GENRE( RbdsRock, "txt_rad_info_rock_music", "txt_rad_dblist_l1_mhz_val_rock_music", "txt_rad_info_rock_music_hs" ), |
|
89 AMERICAN_GENRE( RbdsClassicRock, "txt_rad_info_classic_rock", "txt_rad_dblist_l1_mhz_val_classic_rock", "txt_rad_info_classic_rock_hs" ), |
|
90 AMERICAN_GENRE( RbdsAdultHits, "txt_rad_info_adult_hits", "txt_rad_dblist_l1_mhz_val_adult_hits", "txt_rad_info_adult_hits_hs" ), |
|
91 AMERICAN_GENRE( RbdsSoftRock, "txt_rad_info_soft_rock", "txt_rad_dblist_l1_mhz_val_soft_rock", "txt_rad_info_soft_rock_hs" ), |
|
92 AMERICAN_GENRE( RbdsTop40, "txt_rad_info_top_40", "txt_rad_dblist_l1_mhz_val_top_40", "txt_rad_info_top_40_hs" ), |
|
93 AMERICAN_GENRE( RbdsCountry, "txt_rad_info_country_music", "txt_rad_dblist_l1_mhz_val_country_music", "txt_rad_info_country_music_hs" ), |
|
94 AMERICAN_GENRE( RbdsOldies, "txt_rad_info_oldies_music", "txt_rad_dblist_l1_mhz_val_oldies_music", "txt_rad_info_oldies_music_hs" ), |
|
95 AMERICAN_GENRE( RbdsSoft, "txt_rad_info_soft", "txt_rad_dblist_l1_mhz_val_soft", "txt_rad_info_soft_hs" ), |
|
96 AMERICAN_GENRE( RbdsNostalgia, "txt_rad_info_nostalgia", "txt_rad_dblist_l1_mhz_val_nostalgia", "txt_rad_info_nostalgia_hs" ), |
|
97 AMERICAN_GENRE( RbdsJazz, "txt_rad_info_jazz_music", "txt_rad_dblist_l1_mhz_val_jazz_music", "txt_rad_info_jazz_music_hs" ), |
|
98 AMERICAN_GENRE( RbdsClassical, "txt_rad_info_classical", "txt_rad_dblist_l1_mhz_val_classical", "txt_rad_info_classical_hs" ), |
|
99 AMERICAN_GENRE( RbdsRhythmAndBlues, "txt_rad_info_rhythm_and_blues", "txt_rad_dblist_l1_mhz_val_rhythm_and_blues", "txt_rad_info_rhythm_and_blues_hs" ), |
|
100 AMERICAN_GENRE( RbdsSoftRhythmAndBlues, "txt_rad_info_soft_rhythm_and_blues", "txt_rad_dblist_l1_mhz_val_soft_rhythm_and_blues", "txt_rad_info_soft_rhythm_and_blues_hs" ), |
|
101 AMERICAN_GENRE( RbdsLanguage, "txt_rad_info_language", "txt_rad_dblist_l1_mhz_val_language", "txt_rad_info_language_hs" ), |
|
102 AMERICAN_GENRE( RbdsReligiousMusic, "txt_rad_info_religious_music", "txt_rad_dblist_l1_mhz_val_religious_music", "txt_rad_info_religious_music_hs" ), |
|
103 AMERICAN_GENRE( RbdsReligiousTalk, "txt_rad_info_religious_talk", "txt_rad_dblist_l1_mhz_val_religious_talk", "txt_rad_info_religious_talk_hs" ), |
|
104 AMERICAN_GENRE( RbdsPersonality, "txt_rad_info_personality", "txt_rad_dblist_l1_mhz_val_personality", "txt_rad_info_personality_hs" ), |
|
105 AMERICAN_GENRE( RbdsPublic, "txt_rad_info_public", "txt_rad_dblist_l1_mhz_val_public", "txt_rad_info_public_hs" ), |
|
106 AMERICAN_GENRE( RbdsCollege, "txt_rad_info_college", "txt_rad_dblist_l1_mhz_val_college", "txt_rad_info_college_hs" ), |
|
107 AMERICAN_GENRE( RbdsUnassigned1, "", "", "" ), |
|
108 AMERICAN_GENRE( RbdsUnassigned2, "", "", "" ), |
|
109 AMERICAN_GENRE( RbdsUnassigned3, "", "", "" ), |
|
110 AMERICAN_GENRE( RbdsUnassigned4, "", "", "" ), |
|
111 AMERICAN_GENRE( RbdsUnassigned5, "", "", "" ), |
|
112 AMERICAN_GENRE( RbdsWeather, "txt_rad_info_weather", "txt_rad_dblist_l1_mhz_val_weather", "txt_rad_info_weather_hs" ), |
|
113 AMERICAN_GENRE( RbdsEmergencyTest, "txt_rad_info_alarm_test", "txt_rad_dblist_l1_mhz_val_alarm_test", "txt_rad_info_alarm_test_hs" ), |
|
114 AMERICAN_GENRE( RbdsEmergency, "txt_rad_info_alarm", "txt_rad_dblist_l1_mhz_val_alarm", "txt_rad_info_alarm_hs" ), |
|
115 END_GENRE_MAP( AmericanGenres ) |
|
116 |
|
117 /*! |
|
118 * Function to find the localized text of the given frequency in the given region and target |
|
119 */ |
|
120 static QString RadioGenreLocalizer::genreToString( RadioRegion::Region region, int genre, GenreTarget::Target target ) |
|
121 { |
|
122 const RadioGenreLocalizer::GenreMap* genreArray = region == RadioRegion::America ? AmericanGenres : EuropeanGenres; |
|
123 const int genreCount = region == RadioRegion::America ? AmericanGenresCount : EuropeanGenresCount; |
|
124 |
|
125 for( int i = 0; i < genreCount; ++i ) { |
|
126 if ( genreArray[i].mGenreCode == genre ) { |
|
127 if ( target == GenreTarget::Carousel ) { |
|
128 return qtTrId( genreArray[i].mInCarousel ); |
|
129 } else if ( target == GenreTarget::StationsList ) { |
|
130 return qtTrId( genreArray[i].mInStationsList ); |
|
131 } else if ( target == GenreTarget::HomeScreen ) { |
|
132 return qtTrId( genreArray[i].mInHomeScreen ); |
|
133 } |
|
134 } |
|
135 } |
|
136 |
|
137 return ""; |
|
138 } |
|
139 |
|
140 #endif // RADIOGENRELOCALIZER_H |