void HgWidgetOptionsView::updateData(QModelIndex startIn, QModelIndex endIn)
{
    Q_UNUSED(endIn);

    if (!mContentReady) return;

    QSettings settings(SETT_ORGANIZATION, SETT_APPLICATION);

    HbDataFormModelItem *item = mModel->itemFromIndex(startIn);
    if( !item ) return;
    
    if (item->data(HbDataFormModelItem::LabelRole).toString() == WIDGET_TYPE) {
        int index = item->contentWidgetData(QString("currentIndex")).toInt();
        HgTestWidgetType type = HgWidgetNone;
        switch (index) {
            case 0:
                type = HgWidgetGrid;
                break;
            case 1:
                type = HgWidgetCoverflow;
                break;
            case 2:
                type = HgWidgetTBone;
                break;
            default: break;
        }

        setCoverflowEnabled(index == 1 || index  == 2);
        settings.setValue(SETT_WIDGET_TYPE, type);
        emit widgetTypeChanged(type);
    }
    else if (item->data(HbDataFormModelItem::LabelRole).toString() == SCROLLBAR_VISIBILITY) {
        int index = item->contentWidgetData(QString("currentIndex")).toInt();
        HgWidget::ScrollBarPolicy visibility = HgWidget::ScrollBarAutoHide;
        switch (index) {
            case 0:
                visibility = HgWidget::ScrollBarAutoHide;
                break;
            case 1:
                visibility = HgWidget::ScrollBarAlwaysOn;
                break;
            case 2:
                visibility = HgWidget::ScrollBarAlwaysOff;
                break;
            default: break;
        }

        settings.setValue(SETT_SCROLLBAR_VISIBILITY, visibility);
        emit scrollBarVisibilityChanged(visibility);
    }
    else if (item->data(HbDataFormModelItem::LabelRole).toString() == INTERACTIVE_SCROLLBAR) {
        QVariant data = item->contentWidgetData(QString("text"));
        bool value = data.toString() == "yes";
        settings.setValue(SETT_SCROLLBAR_INTERACTIVITY, value);
        if (value) {
            item = mModel->itemFromIndex(mModel->index(ItemScrollBarVisibility, 0));
            if (item) {
                item->setContentWidgetData(QString("currentIndex"), 1); // Set scroll bar always on
            }
        }
        emit scrollBarInteractivityChanged(value);
    }
    else if (item->data(HbDataFormModelItem::LabelRole).toString() == MODEL_IMAGE_TYPE) {
        int index = item->contentWidgetData(QString("currentIndex")).toInt();
        HgTestImageType type = ImageTypeNone;
        switch (index) {
            case 0:
                type = ImageTypeQImage;
                break;
            case 1:
                type = ImageTypeHbIcon;
                break;
            case 2:
                type = ImageTypeQIcon;
                break;
            case 3:
                type = ImageTypeQPixmap;
                break;
            default: break;
        }

        settings.setValue(SETT_MODEL_IMAGE_TYPE, type);
        emit imageTypeChanged(type);
    }
    else if (item->data(HbDataFormModelItem::LabelRole).toString() == WIDGET_HEIGHT) {
        emit widgetHeightChanged(item->contentWidgetData(QString("text")).toInt());
        storeWidgetSize();
    }
    else if (item->data(HbDataFormModelItem::LabelRole).toString() == WIDGET_WIDTH) {
        emit widgetWidthChanged(item->contentWidgetData(QString("text")).toInt());
        storeWidgetSize();

    }
    else if (item->data(HbDataFormModelItem::LabelRole).toString() == LOW_RES_IMAGES) {
        QVariant data = item->contentWidgetData(QString("text"));
        bool value = data.toString() == "yes";
        settings.setValue(SETT_LOW_RES_IMAGES, value);
        emit lowResImageUseChanged(value);
    }
    else if (item->data(HbDataFormModelItem::LabelRole).toString() == TITLE_FONT) {
        int index = item->contentWidgetData(QString("currentIndex")).toInt();
        HbFontSpec::Role role = HbFontSpec::Undefined;
        switch (index) {
            case 0:
                role = HbFontSpec::Primary;
                break;
            case 1:
                role = HbFontSpec::Secondary;
                break;
            case 2:
                role = HbFontSpec::Title;
                break;
            case 3:
                role = HbFontSpec::PrimarySmall;
                break;
            case 4:
                role = HbFontSpec::Digital;
                break;
            default: break;
        }
        settings.setValue(SETT_TITLE_FONT, role);
        emit titleFontChanged(HbFontSpec(role));
    }
    else if (item->data(HbDataFormModelItem::LabelRole).toString() == DESCRIPTION_FONT) {
        int index = item->contentWidgetData(QString("currentIndex")).toInt();
        HbFontSpec::Role role = HbFontSpec::Undefined;
        switch (index) {
            case 0:
                role = HbFontSpec::Primary;
                break;
            case 1:
                role = HbFontSpec::Secondary;
                break;
            case 2:
                role = HbFontSpec::Title;
                break;
            case 3:
                role = HbFontSpec::PrimarySmall;
                break;
            case 4:
                role = HbFontSpec::Digital;
                break;
            default: break;
        }
        settings.setValue(SETT_DESCRIPTION_FONT, role);
        emit descriptionFontChanged(HbFontSpec(role));
    }
    else if (item->data(HbDataFormModelItem::LabelRole).toString() == REFLECTIONS_ENABLED) {
        QVariant data = item->contentWidgetData(QString("text"));
        bool value = data.toString() == "yes";
        settings.setValue(SETT_REFLECTIONS_ENABLED, value);
        emit reflectionsEnabledChanged(value);
    }
    else if (item->data(HbDataFormModelItem::LabelRole).toString() == EFFECT3D_ENABLED) {
        QVariant data = item->contentWidgetData(QString("text"));
        bool value = data.toString() == "yes";
        settings.setValue(SETT_EFFECT3D_ENABLED, value);
        emit effect3dEnabledChanged(value);
    }
    else if (item->data(HbDataFormModelItem::LabelRole).toString() == ITEM_SIZE_POLICY) {
        QVariant data = item->contentWidgetData(QString("text"));
        HgWidget::ItemSizePolicy value = (data.toString() == "Automatic" ? HgWidget::ItemSizeAutomatic : HgWidget::ItemSizeUserDefined);
        settings.setValue(SETT_ITEM_SIZE_POLICY, value);
        emit itemSizePolicyChanged(value);
    }
}
DataWidget::DataWidget(DataDescription *dataDescription,
                       WidgetWindowsManager *widgetWindowsManager,
                       MainWindow *mainWindow,
                       bool inside) :
AbstractWidgetWindow(widgetWindowsManager, mainWindow, inside)
{
    _dataDescription = dataDescription;
    _internalWidget = 0;
    // For the plot widget
    _curve = 0;
    _curveData = 0;

    _dataWidgetNames = _mainWindow->dataWidgetNames();
    _dataWidgetPossibilities = _mainWindow->dataWidgetPossibilities() ->value(
            _dataDescription->type).values();

    // Init context menu actions
    QActionGroup *actionGroup = new QActionGroup(this);
    for (int i = 0; i < _dataWidgetPossibilities.count(); i++)
    {
        QAction *action = new QAction(
                _dataWidgetNames ->value(_dataWidgetPossibilities.at(i)),
                actionGroup);
        action->setCheckable(true);
        if (_dataWidgetPossibilities.at(i) == _dataDescription->widget)
        {
            action->setChecked(true);
        }
        QObject::connect(action, SIGNAL(triggered()), this,
                         SLOT(widgetTypeChanged()));
        actionGroup->addAction(action);
    }
    addActions(actionGroup->actions());

    // Set attributes
    setContextMenuPolicy(Qt::ActionsContextMenu);

    // Init GUI
    setWindowTitle(_dataDescription->descriptionString);
    setWindowIcon(QIcon(":/images/widget.png"));
    // Set layout
    QVBoxLayout *globalLayout = new QVBoxLayout();
    setLayout(globalLayout);
    QHBoxLayout *topLayout = new QHBoxLayout();
    topLayout->addWidget(_inOutButton);
    QString labelText = _dataDescription->descriptionString;
    if (_dataDescription->descriptionString.size() > 14)
    {
        labelText.truncate(12);
        labelText.append("...");
    }
    QLabel *dataTitle = new QLabel(labelText);
    dataTitle->setToolTip(_dataDescription->descriptionString);
    topLayout->addWidget(dataTitle, 0, Qt::AlignHCenter);
    dataTitle->setFixedHeight(dataTitle->sizeHint().height());
    globalLayout->addLayout(topLayout);

    // Create internal widget
    createInternalWidget();

    setParent(0); // Needed if it is a flying window
    // Will be updated anyway if it goes into the MDI area
    // However the object HAS to be constructed with the main window as parent
    // so it can connect to its slots.

    // Setup automatic cleanup
    QObject::connect(this, SIGNAL(destroyed()), _mainWindow,
                     SLOT(removeDestroyedDataWidgets()));

    qDebug() << "DataWidget : initializing [desc"
            << _dataDescription->descriptionString << "; id"
            << _dataDescription->id << "; type" << _dataDescription->type
            << "; min" << _dataDescription->valMin << "; max"
            << _dataDescription->valMax << "; widget"
            << _dataDescription->widget << "]";
}