34 |
34 |
35 \param localeId identifier for locale |
35 \param localeId identifier for locale |
36 */ |
36 */ |
37 HbNumberGrpXmlReader::HbNumberGrpXmlReader( int localeId ) |
37 HbNumberGrpXmlReader::HbNumberGrpXmlReader( int localeId ) |
38 { |
38 { |
39 locale.setNum(localeId); |
39 locale.setNum(localeId); |
40 locale.insert(0, "C"); |
40 locale.insert(0, "C"); |
41 found = false; |
41 found = false; |
42 done = false; |
42 done = false; |
43 phase = 0; |
43 phase = 0; |
44 decimal = ""; |
44 decimal = ""; |
45 pattern = ""; |
45 pattern = ""; |
46 group = ""; |
46 group = ""; |
47 |
47 |
48 QFile xmlFile(NumberGroupingFile); |
48 QFile xmlFile(NumberGroupingFile); |
49 |
49 |
50 if ( xmlFile.exists() ) { |
50 if ( xmlFile.exists() ) { |
51 QXmlInputSource source(&xmlFile); |
51 QXmlInputSource source(&xmlFile); |
52 QXmlSimpleReader reader; |
52 QXmlSimpleReader reader; |
53 reader.setContentHandler(this); |
53 reader.setContentHandler(this); |
54 reader.parse(source) ; |
54 reader.parse(source) ; |
55 } |
55 } |
56 } |
56 } |
57 |
57 |
58 /*! |
58 /*! |
59 \return pattern for grouping |
59 \return pattern for grouping |
60 */ |
60 */ |
61 QString HbNumberGrpXmlReader::getPattern() |
61 QString HbNumberGrpXmlReader::getPattern() |
62 { |
62 { |
63 return pattern; |
63 return pattern; |
64 } |
64 } |
65 |
65 |
66 /*! |
66 /*! |
67 \return character(s) for group |
67 \return character(s) for group |
68 */ |
68 */ |
69 QString HbNumberGrpXmlReader::getGroup() |
69 QString HbNumberGrpXmlReader::getGroup() |
70 { |
70 { |
71 return group; |
71 return group; |
72 } |
72 } |
73 |
73 |
74 /*! |
74 /*! |
75 \return character(s) for decimal |
75 \return character(s) for decimal |
76 */ |
76 */ |
77 QString HbNumberGrpXmlReader::getDecimal() |
77 QString HbNumberGrpXmlReader::getDecimal() |
78 { |
78 { |
79 return decimal; |
79 return decimal; |
80 } |
80 } |
81 |
81 |
82 /*! |
82 /*! |
83 Destructor of class. |
83 Destructor of class. |
84 */ |
84 */ |
102 |
102 |
103 \param qName element which will be readed |
103 \param qName element which will be readed |
104 \return true |
104 \return true |
105 */ |
105 */ |
106 bool HbNumberGrpXmlReader::startElement( const QString &, |
106 bool HbNumberGrpXmlReader::startElement( const QString &, |
107 const QString &, |
107 const QString &, |
108 const QString &qName, |
108 const QString &qName, |
109 const QXmlAttributes & ) |
109 const QXmlAttributes & ) |
110 { |
110 { |
111 if ( done ) { |
111 if ( done ) { |
112 return true; |
112 return true; |
113 } |
113 } |
114 |
114 |
115 if ( found ) { |
115 if ( found ) { |
116 if ( qName == DecimalStr ) { |
116 if ( qName == DecimalStr ) { |
117 phase = 1; |
117 phase = 1; |
118 } else if ( qName == GroupStr ) { |
118 } else if ( qName == GroupStr ) { |
119 phase = 2; |
119 phase = 2; |
120 } else if ( qName == PatternStr ) { |
120 } else if ( qName == PatternStr ) { |
121 phase = 3; |
121 phase = 3; |
122 } |
122 } |
123 } else if ( locale == qName ) { |
123 } else if ( locale == qName ) { |
124 found = true; |
124 found = true; |
125 } |
125 } |
126 return true; |
126 return true; |
127 } |
127 } |
128 |
128 |
129 /*! |
129 /*! |
130 This function is needed by XML reader. |
130 This function is needed by XML reader. |
131 |
131 |
138 return true; |
138 return true; |
139 } |
139 } |
140 |
140 |
141 QString tmpText; |
141 QString tmpText; |
142 |
142 |
143 // This little trick is needed because of limitation in XML reader |
143 // This little trick is needed because of limitation in XML reader |
144 // XML reader doesn't read space character corretly |
144 // XML reader doesn't read space character corretly |
145 if ( text.at(0).toAscii() == 32 ) { // " " |
145 if ( text.at(0).toAscii() == 32 ) { // " " |
146 tmpText = ' '; |
146 tmpText = ' '; |
147 } else { |
147 } else { |
148 tmpText = text; |
148 tmpText = text; |
149 } |
149 } |
150 |
150 |
151 if ( found ) { |
151 if ( found ) { |
152 if ( phase == 1 ) { //handle Decimal |
152 if ( phase == 1 ) { //handle Decimal |
153 decimal = tmpText; |
153 decimal = tmpText; |
154 } else if ( phase == 2 ) { // handle group |
154 } else if ( phase == 2 ) { // handle group |
155 group = tmpText; |
155 group = tmpText; |
156 } else if ( phase == 3 ) { // handle pattern |
156 } else if ( phase == 3 ) { // handle pattern |
157 pattern = tmpText; |
157 pattern = tmpText; |
158 } else {} |
158 } else {} |
159 |
159 |
160 phase = 0; |
160 phase = 0; |
161 } |
161 } |
162 return true; |
162 return true; |
163 } |
163 } |
164 |
164 |
165 /*! |
165 /*! |
166 This function is needed by XML reader. |
166 This function is needed by XML reader. |
167 |
167 |