48 static const char *ATTRIBUTE_LOCALIZATION_ID = "string"; |
48 static const char *ATTRIBUTE_LOCALIZATION_ID = "string"; |
49 static const char *ATTRIBUTE_LOCALIZATION_ID_LN_VALUE = "lnValue"; |
49 static const char *ATTRIBUTE_LOCALIZATION_ID_LN_VALUE = "lnValue"; |
50 |
50 |
51 static const char *ATTRIBUTE_SLIDER_MIN = "min"; |
51 static const char *ATTRIBUTE_SLIDER_MIN = "min"; |
52 static const char *ATTRIBUTE_SLIDER_MAX = "max"; |
52 static const char *ATTRIBUTE_SLIDER_MAX = "max"; |
53 static const char *ATTRIBUTE_SLIDER_STEP = "step"; |
53 static const char *ATTRIBUTE_SLIDER_MINOR_STEP = "minorStep"; |
|
54 static const char *ATTRIBUTE_SLIDER_MAJOR_STEP = "majorStep"; |
54 |
55 |
55 // possible values that can be used in xml for "ATTRIBUTE_LISTBOXTYPE" |
56 // possible values that can be used in xml for "ATTRIBUTE_LISTBOXTYPE" |
56 static const char *SINGLE_LINE_LISTBOX = "SingleLineListBox"; |
57 static const char *SINGLE_LINE_LISTBOX = "SingleLineListBox"; |
57 static const char *TWO_LINE_LISTBOX = "TwoLineListBox"; |
58 static const char *TWO_LINE_LISTBOX = "TwoLineListBox"; |
58 } |
59 } |
288 p->mSettingPairList.clear(); |
289 p->mSettingPairList.clear(); |
289 |
290 |
290 // Go through list of items |
291 // Go through list of items |
291 // XML something like this |
292 // XML something like this |
292 // <item value="0" string="qtn_whitebalance_auto" /> |
293 // <item value="0" string="qtn_whitebalance_auto" /> |
|
294 bool ok(false); |
|
295 int intValue(0); |
|
296 QVariant value; |
|
297 QString string; |
293 for (QDomNode n = element.firstChild(); !n.isNull(); n = n.nextSibling()) { |
298 for (QDomNode n = element.firstChild(); !n.isNull(); n = n.nextSibling()) { |
294 e = n.toElement(); |
299 e = n.toElement(); |
295 |
|
296 // get the string text id from the xml |
|
297 QString string = e.attribute(ATTRIBUTE_LOCALIZATION_ID); |
|
298 // get the equivalent engine value from xml |
|
299 QVariant value = e.attribute(ATTRIBUTE_VALUE); |
|
300 |
|
301 CX_DEBUG(("tag name <%s>", e.tagName().toAscii().constData())); |
300 CX_DEBUG(("tag name <%s>", e.tagName().toAscii().constData())); |
|
301 |
|
302 // Get the item equivalent engine value from xml. |
|
303 // We need to know later if it is a string or int type, hence the extra effort. |
|
304 // QVariant has auto-conversion even from string to int, so can't use QVariant::canConvert<T>(). |
|
305 string = e.attribute(ATTRIBUTE_VALUE); |
|
306 intValue = string.toInt(&ok); |
|
307 if (ok) { |
|
308 value.setValue(intValue); |
|
309 } else { |
|
310 value.setValue(string); |
|
311 } |
|
312 |
|
313 |
|
314 // get the string text id from the xml, and format based on type. |
|
315 string = e.attribute(ATTRIBUTE_LOCALIZATION_ID); |
302 if (e.tagName() == TAG_ITEM) { |
316 if (e.tagName() == TAG_ITEM) { |
303 // get the localizable string from the hbtrid |
317 // get the localizable string from the hbtrid |
304 string = hbTrId(string.toAscii().constData()); |
318 string = hbTrId(string.toAscii().constData()); |
305 } else if (e.tagName() == TAG_ITEM_VARIANT) { |
319 } else if (e.tagName() == TAG_ITEM_VARIANT) { |
306 QString lnValue = e.attribute(ATTRIBUTE_LOCALIZATION_ID_LN_VALUE); |
320 QString lnValue = e.attribute(ATTRIBUTE_LOCALIZATION_ID_LN_VALUE); |
307 // format the setting string |
321 // format the setting string |
308 string = hbTrId(string.toAscii().constData(), lnValue.toInt()); |
322 string = hbTrId(string.toAscii().constData(), lnValue.toInt()); |
309 } |
323 } |
310 |
|
311 CX_DEBUG(("attribute [%s] value[%s]", ATTRIBUTE_LOCALIZATION_ID, string.toAscii().constData())); |
324 CX_DEBUG(("attribute [%s] value[%s]", ATTRIBUTE_LOCALIZATION_ID, string.toAscii().constData())); |
312 |
325 |
313 if (!string.isNull()) { |
326 if (!string.isNull()) { |
314 CxUiSettings::SettingItem setting; |
327 CxUiSettings::SettingItem setting; |
315 setting.mItem = string; |
328 setting.mItem = string; |
362 |
375 |
363 // get the max text id from the xml |
376 // get the max text id from the xml |
364 QString maxString = e.attribute(ATTRIBUTE_SLIDER_MAX); |
377 QString maxString = e.attribute(ATTRIBUTE_SLIDER_MAX); |
365 |
378 |
366 // get the step text id from the xml |
379 // get the step text id from the xml |
367 QVariant stepString = e.attribute(ATTRIBUTE_SLIDER_STEP); |
380 QVariant stepString = e.attribute(ATTRIBUTE_SLIDER_MINOR_STEP); |
368 p->mStep = stepString.toReal(); |
381 p->mMinorStep = stepString.toReal(); |
|
382 stepString = e.attribute(ATTRIBUTE_SLIDER_MAJOR_STEP); |
|
383 p->mMajorStep = stepString.toReal(); |
369 |
384 |
370 // get the ln value from xml to generate strings for slider |
385 // get the ln value from xml to generate strings for slider |
371 QString lnValue = e.attribute(ATTRIBUTE_LOCALIZATION_ID_LN_VALUE); |
386 QString lnValue = e.attribute(ATTRIBUTE_LOCALIZATION_ID_LN_VALUE); |
372 |
387 |
373 // Don't create labels for slider if no strings are defined in settinsg xml |
388 // Don't create labels for slider if no strings are defined in settinsg xml |
|
389 // Create labels only for major ticks |
374 if (!minString.isEmpty() && !maxString.isEmpty()) { |
390 if (!minString.isEmpty() && !maxString.isEmpty()) { |
375 qreal step = p->mStep; |
391 qreal step = p->mMajorStep; |
376 qreal value = lnValue.toDouble(); |
392 qreal value = lnValue.toDouble(); |
377 // generating all negative valued strings for slider setting |
393 // generating all negative valued strings for slider setting |
378 while (value > 0) { |
394 while (value > 0) { |
379 // format the setting string |
395 // format the setting string |
380 QString str = hbTrId(minString.toAscii().constData()).arg(value,0,'f',1); |
396 QString str = hbTrId(minString.toAscii().constData()).arg(value,0,'f',1); |
381 p->mSettingStrings.append(str); |
397 p->mSettingStrings.append(str); |
382 value = value - step; |
398 value = value - step; |
383 } |
399 } |
384 |
400 |
385 // generating all non-negative valued strings for slider setting |
401 // generating all non-negative valued strings for slider setting |
386 step = p->mStep; |
402 step = p->mMajorStep; |
387 value = 0; |
403 value = 0; |
388 while(value <= lnValue.toInt()) { |
404 while(value <= lnValue.toInt()) { |
389 // format the setting string |
405 // format the setting string |
390 QString str = hbTrId(maxString.toAscii().constData()).arg(value,0,'f',1); |
406 QString str = hbTrId(maxString.toAscii().constData()).arg(value,0,'f',1); |
391 p->mSettingStrings.append(str); |
407 p->mSettingStrings.append(str); |