camerauis/cameraxui/cxui/src/cxuisettingradiobuttonlist.cpp
changeset 39 c5025ea871a1
parent 38 0f0b4c1d7744
child 37 64817133cd1d
--- a/camerauis/cameraxui/cxui/src/cxuisettingradiobuttonlist.cpp	Thu Jul 15 01:44:30 2010 +0300
+++ b/camerauis/cameraxui/cxui/src/cxuisettingradiobuttonlist.cpp	Thu Jul 15 01:46:05 2010 +0300
@@ -67,10 +67,35 @@
 
         setSettingId(data->mSettingId);
         setListBoxType(data->mListboxType);
+
+        initOriginalSelectedItem();
+        // ensure that currently selected item is visible
+        scrollTo(currentIndex());
     }
 
 }
 
+/*!
+ * Sets the original selection of list by value. Can be used to override value read from
+ * CxeSettings or used to remember previously selected value in case of setting that is
+ * not read from CxeSettings (e.g. selftimer)
+ */
+void CxuiSettingRadioButtonList::setOriginalSelectedItemByValue(const QVariant &value)
+{
+    CX_DEBUG_ENTER_FUNCTION();
+
+    int index = mSettingValues.indexOf(QVariant(value));
+    if (index >= 0) {
+        mOriginalIndex = index;
+        setSelected(index);
+        // ensure that currently selected item is visible
+        scrollTo(currentIndex());
+    } else {
+        CX_DEBUG(("Value %s not found", value.toString().toAscii().data()));
+    }
+    CX_DEBUG_EXIT_FUNCTION();
+}
+
 void CxuiSettingRadioButtonList::setItems(const QStringList &values)
 {
     mListModel->setItems(values);
@@ -102,19 +127,6 @@
     CX_DEBUG_EXIT_FUNCTION();
 }
 
-void CxuiSettingRadioButtonList::showEvent(QShowEvent *event)
-{
-    CX_DEBUG_ENTER_FUNCTION();
-
-    initOriginalSelectedItem();
-    // ensure that currently selected item is visible
-    scrollTo(currentIndex());
-    QGraphicsWidget::showEvent(event);
-
-    CX_DEBUG_EXIT_FUNCTION();
-}
-
-
 /*!
 *  Get the value currently active in settings.
 */