--- a/ipsservices/nmipssettings/src/nmipssettingscustomitem.cpp Fri Apr 16 14:51:52 2010 +0300
+++ b/ipsservices/nmipssettings/src/nmipssettingscustomitem.cpp Mon May 03 12:23:15 2010 +0300
@@ -16,6 +16,10 @@
*/
#include <QVariant>
+#include <hbdatetimeedit.h>
+#include <hbabstractitemview.h>
+#include <hbdataformmodel.h>
+#include <hbdataformmodelitem.h>
#include "nmipssettingscustomitem.h"
#include "nmipssettingslabeledcombobox.h"
@@ -23,7 +27,6 @@
/*!
\class NmIpsSettingsCustomItem
\brief The class implements a custom HbDataFormViewItem.
-
*/
// ======== MEMBER FUNCTIONS ========
@@ -58,7 +61,43 @@
bool NmIpsSettingsCustomItem::canSetModelIndex(const QModelIndex &index) const
{
int type(index.data(HbDataFormModelItem::ItemTypeRole).toInt());
- return type==LabeledComboBox;
+ return type==LabeledComboBox || type==TimeEditor;
+}
+
+/*!
+ Sets the custom widget's properties from the model item.
+*/
+void NmIpsSettingsCustomItem::restore()
+{
+ HbDataFormModelItem::DataItemType itemType = static_cast<HbDataFormModelItem::DataItemType>(
+ modelIndex().data(HbDataFormModelItem::ItemTypeRole).toInt());
+
+ if (itemType==LabeledComboBox || itemType==TimeEditor) {
+
+ HbDataFormModel* model = static_cast<HbDataFormModel*>
+ (static_cast<HbAbstractViewItem*>(this)->itemView()->model());
+ HbDataFormModelItem* modelItem = model->itemFromIndex(modelIndex());
+ QHash<QString ,QVariant> properties =
+ modelItem->data(HbDataFormModelItem::PropertyRole).toHash();
+
+ if (itemType==TimeEditor) {
+ // Set time editor properties. Simply copy all set properties to the widget.
+ QStringList propertyNames = properties.keys();
+
+ for (int index=0 ; index < propertyNames.count() ; index++) {
+ QString propName = propertyNames.at(index);
+ dataItemContentWidget()->setProperty(propName.toAscii().data(),
+ properties.value(propName));
+ }
+ } else {
+ // Set combobox properties in specific order. currentIndex must be set last so that
+ // both the labelTexts and comboItems have been set before. Also, labelTexts must be
+ // set before comboItems.
+ setWidgetProperty("labelTexts", properties);
+ setWidgetProperty("comboItems", properties);
+ setWidgetProperty("currentIndex", properties);
+ }
+ }
}
/*!
@@ -71,9 +110,34 @@
HbWidget *widget = 0;
- if (type == LabeledComboBox) {
- widget = new NmIpsSettingsLabeledComboBox();
+ switch (type) {
+ case LabeledComboBox: {
+ widget = new NmIpsSettingsLabeledComboBox();
+ break;
+ }
+ case TimeEditor: {
+ HbDateTimeEdit *edit = new HbDateTimeEdit();
+ widget = edit;
+ break;
+ }
+ default: {
+ break;
+ }
}
return widget;
}
+
+/*!
+ Sets \a property to the content widget if found from \a properties.
+ \param property Name of the property to set.
+ \param properties Available properties.
+*/
+void NmIpsSettingsCustomItem::setWidgetProperty(const QString &property,
+ const QHash<QString, QVariant> &properties)
+{
+ if (properties.contains(property)) {
+ dataItemContentWidget()->setProperty(property.toAscii().data(), properties.value(property));
+ }
+}
+