void KexiDataSourcePage::slotFormDataSourceTextChanged(const QString & string) { Q_UNUSED(string); const bool enable = m_formDataSourceCombo->isSelectionValid(); if (!enable) { clearFormDataSourceSelection(m_formDataSourceCombo->selectedName().isEmpty()/*alsoClearComboBox*/); } updateSourceFieldWidgetsAvailability(); }
void KexiDataSourcePage::slotFormDataSourceTextChanged(const QString & string) { Q_UNUSED(string); const bool enable = m_formDataSourceCombo->isSelectionValid(); //!string.isEmpty() && m_formDataSourceCombo->selectedName() == string.toLatin1(); if (!enable) { clearFormDataSourceSelection(m_formDataSourceCombo->selectedName().isEmpty()/*alsoClearComboBox*/); } updateSourceFieldWidgetsAvailability(); /*#ifndef KEXI_NO_AUTOFIELD_WIDGET m_fieldListView->setEnabled(enable); // m_addField->setEnabled(enable); m_availableFieldsLabel->setEnabled(enable); #endif*/ }
void KexiDataSourcePage::slotFormDataSourceChanged() { if (!m_formDataSourceCombo->project()) return; const QString partClass(m_formDataSourceCombo->selectedPartClass()); bool dataSourceFound = false; QString name(m_formDataSourceCombo->selectedName()); const bool isPartAcceptable = partClass == QLatin1String("org.kexi-project.table") || partClass == QLatin1String("org.kexi-project.query"); if (isPartAcceptable && m_formDataSourceCombo->isSelectionValid()) { KexiDB::TableOrQuerySchema *tableOrQuery = new KexiDB::TableOrQuerySchema( m_formDataSourceCombo->project()->dbConnection(), name.toLatin1(), partClass == "org.kexi-project.table"); if (tableOrQuery->table() || tableOrQuery->query()) { #ifdef KEXI_NO_AUTOFIELD_WIDGET m_tableOrQuerySchema = tableOrQuery; #else m_fieldListView->setSchema(tableOrQuery); #endif dataSourceFound = true; m_widgetDataSourceCombo->setTableOrQuery(name, partClass == "org.kexi-project.table"); } else { delete tableOrQuery; } } if (!dataSourceFound) { m_widgetDataSourceCombo->setTableOrQuery(QString(), true); } //if (m_widgetDataSourceCombo->hasFocus()) // m_formDataSourceCombo->setFocus(); /*2.0: clear button is available in the combobox itself m_clearDSButton->setEnabled(dataSourceFound);*/ m_gotoButton->setEnabled(dataSourceFound); if (dataSourceFound) { slotFieldListViewSelectionChanged(); } else { #ifndef KEXI_NO_AUTOFIELD_WIDGET m_addField->setEnabled(false); #endif } updateSourceFieldWidgetsAvailability(); emit formDataSourceChanged(partClass, name); }
void KexiDataSourcePage::slotFormDataSourceChanged() { if (!m_formDataSourceCombo->project()) return; const QString pluginId(m_formDataSourceCombo->selectedPluginId()); bool dataSourceFound = false; QString name(m_formDataSourceCombo->selectedName()); const bool isIdAcceptable = pluginId == QLatin1String("org.kexi-project.table") || pluginId == QLatin1String("org.kexi-project.query"); if (isIdAcceptable && m_formDataSourceCombo->isSelectionValid()) { KDbTableOrQuerySchema *tableOrQuery = new KDbTableOrQuerySchema( m_formDataSourceCombo->project()->dbConnection(), name.toLatin1(), pluginId == "org.kexi-project.table"); if (tableOrQuery->table() || tableOrQuery->query()) { #ifdef KEXI_AUTOFIELD_FORM_WIDGET_SUPPORT m_fieldListView->setSchema(tableOrQuery); #else m_tableOrQuerySchema = tableOrQuery; #endif dataSourceFound = true; m_widgetDataSourceCombo->setTableOrQuery(name, pluginId == "org.kexi-project.table"); } else { delete tableOrQuery; } } if (!dataSourceFound) { m_widgetDataSourceCombo->setTableOrQuery(QString(), true); } m_gotoButton->setEnabled(dataSourceFound); if (dataSourceFound) { slotFieldListViewSelectionChanged(); } else { #ifdef KEXI_AUTOFIELD_FORM_WIDGET_SUPPORT m_addField->setEnabled(false); #endif } updateSourceFieldWidgetsAvailability(); emit formDataSourceChanged(pluginId, name); }
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 }
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 }