void KexiDataSourcePage::assignPropertySet(KoProperty::Set* propertySet)
{
    QString objectName;
    if (propertySet)
        objectName = propertySet->propertyValue("objectName").toString();
    if (!objectName.isEmpty() && objectName == m_currentObjectName)
        return; //the same object
    m_currentObjectName = objectName;

#if KexiDataSourcePage_FADE //TODO
    KFadeWidgetEffect *animation = 0;
    if (isVisible())
        animation = new KFadeWidgetEffect(this);
#endif
    QString objectClassName;
    if (propertySet) {
        objectClassName = propertySet->propertyValue("this:className").toString();
    }
    updateInfoLabelForPropertySet(propertySet);

    const bool isForm = objectClassName == "KexiDBForm";
// kDebug() << "objectClassName=" << objectClassName;
// {
    /*  //this is top level form's surface: data source means table or query
        QCString dataSourcePartClass, dataSource;
        if (buffer->hasProperty("dataSourcePartClass"))
          dataSourcePartClass = (*buffer)["dataSourcePartClass"].value().toCString();
        if (buffer->hasProperty("dataSource"))
          dataSource = (*buffer)["dataSource"].value().toCString();
        m_formDataSourceCombo->setDataSource(dataSourcePartClass, dataSource);*/
// }
// else {

    const bool multipleSelection = objectClassName == "special:multiple";
    const bool hasDataSourceProperty = propertySet
                                       && propertySet->contains("dataSource") && !multipleSelection;

    if (!isForm) {
        //this is a widget
        QString dataSource;
        if (hasDataSourceProperty) {
            if (propertySet) {
                dataSource = (*propertySet)["dataSource"].value().toString();
            }
            m_noDataSourceAvailableLabel->hide();
            m_widgetDataSourceCombo->setFieldOrExpression(dataSource);
            m_widgetDataSourceCombo->setEnabled(true);
/*2.0: clear button is available in the combobox itself
            m_clearWidgetDSButton->setEnabled(!m_widgetDataSourceCombo->currentText().isEmpty());*/
            m_widgetDSLabel->show();
/*2.0: clear button is available in the combobox itself
            m_clearWidgetDSButton->show();*/
            m_widgetDataSourceCombo->show();
            m_widgetDataSourceComboSpacer->show();
//   m_dataSourceSeparator->hide();
            updateSourceFieldWidgetsAvailability();
        }
    }

    if (isForm) {
        m_noDataSourceAvailableLabel->hide();
//  m_dataSourceSeparator->hide();
    }
    else if (!hasDataSourceProperty) {
        if (multipleSelection) {
            m_noDataSourceAvailableLabel->setText(m_noDataSourceAvailableMultiText);
        }
        else {
            m_noDataSourceAvailableLabel->setText(m_noDataSourceAvailableSingleText);
        }
        m_noDataSourceAvailableLabel->show();
//  m_dataSourceSeparator->show();
        //make 'No data source could be assigned' label's height the same as the 'source field' combo+label
//2.0        m_noDataSourceAvailableLabel->setMinimumHeight(m_widgetDSLabel->height()
//2.0                + m_widgetDataSourceCombo->height()/*-m_dataSourceSeparator->height()*/);
        m_widgetDataSourceCombo->setEditText(QString());
    }

    if (isForm || !hasDataSourceProperty) {
        //no source field can be set
        m_widgetDSLabel->hide();
/*2.0: clear button is available in the combobox itself
        m_clearWidgetDSButton->hide();*/
        m_widgetDataSourceCombo->hide();
        m_widgetDataSourceComboSpacer->hide();
    }
#if KexiDataSourcePage_FADE //TODO
    if (animation)
        animation->start(100);
#endif
}
Beispiel #2
0
void KexiDataSourcePage::assignPropertySet(KoProperty::Set* propertySet)
{
    QString objectName;
    if (propertySet)
        objectName = propertySet->propertyValue("objectName").toString();
    if (!objectName.isEmpty() && objectName == m_currentObjectName)
        return; //the same object
    m_currentObjectName = objectName;

//! @todo
#if KexiDataSourcePage_FADE
    KFadeWidgetEffect *animation = 0;
    if (isVisible())
        animation = new KFadeWidgetEffect(this);
#endif
    QString objectClassName;
    if (propertySet) {
        objectClassName = propertySet->propertyValue("this:className").toString();
    }
    updateInfoLabelForPropertySet(propertySet);

    const bool isForm = objectClassName == "KexiDBForm";
    const bool multipleSelection = objectClassName == "special:multiple";
    const bool hasDataSourceProperty = propertySet
                                       && propertySet->contains("dataSource") && !multipleSelection;

    if (!isForm) {
        //this is a widget
        QString dataSource;
        if (hasDataSourceProperty) {
            if (propertySet) {
                dataSource = (*propertySet)["dataSource"].value().toString();
            }
            m_noDataSourceAvailableLabel->hide();
            m_widgetDataSourceCombo->setFieldOrExpression(dataSource);
            m_widgetDataSourceCombo->setEnabled(true);
            m_widgetDSLabel->show();
            m_widgetDataSourceCombo->show();
            m_widgetDataSourceComboSpacer->show();
            updateSourceFieldWidgetsAvailability();
        }
    }

    if (isForm) {
        m_noDataSourceAvailableLabel->hide();
    }
    else if (!hasDataSourceProperty) {
        if (multipleSelection) {
            m_noDataSourceAvailableLabel->setText(m_noDataSourceAvailableMultiText);
        }
        else {
            m_noDataSourceAvailableLabel->setText(m_noDataSourceAvailableSingleText);
        }
        m_noDataSourceAvailableLabel->show();
        m_widgetDataSourceCombo->setEditText(QString());
    }

    if (isForm || !hasDataSourceProperty) {
        //no source field can be set
        m_widgetDSLabel->hide();
        m_widgetDataSourceCombo->hide();
        m_widgetDataSourceComboSpacer->hide();
    }
//! @todo
#if KexiDataSourcePage_FADE
    if (animation)
        animation->start(100);
#endif
}