void KexiDBComboBox::setEditable(bool set) { if (d->isEditable == set) return; d->isEditable = set; d->paintedCombo->setEditable(set); if (set) createEditor(); else { delete subwidget(); setSubwidget(0); } update(); }
void KexiDBAutoField::init(const QString &text, WidgetType type, LabelPosition pos) { d->fieldTypeInternal = KexiDB::Field::InvalidType; d->layout = 0; setSubwidget(0); d->label = new QLabel(text, this); d->label->installEventFilter(this); d->autoCaption = true; d->focusPolicyChanged = false; d->widgetType = Auto; d->widgetType_property = (type == Auto ? Text : type); //to force "differ" to be true in setWidgetType() setLabelPosition(pos); setWidgetType(type); d->baseBrush = palette().base(); d->textBrush = palette().text(); }
void KexiDBAutoField::createEditor() { if (subwidget()) { delete(QWidget *)subwidget(); } QWidget *newSubwidget; //kDebug() << "widgetType:" << d->widgetType; switch (d->widgetType) { case Text: case Double: //! @todo setup validator case Integer: //! @todo setup validator case Date: case Time: case DateTime: { KexiDBLineEdit *le = new KexiDBLineEdit(this); newSubwidget = le; le->setFrame(false); break; } case MultiLineText: newSubwidget = new KexiDBTextEdit(this); break; case Boolean: newSubwidget = new KexiDBCheckBox(dataSource(), this); break; case Image: newSubwidget = new KexiDBImageBox(designMode(), this); break; case ComboBox: { KexiDBComboBox *cbox = new KexiDBComboBox(this); newSubwidget = cbox; cbox->setDesignMode(designMode()); break; } default: newSubwidget = 0; changeText(d->caption); break; } //kDebug() << newSubwidget; setSubwidget(newSubwidget); //this will also allow to declare subproperties, see KFormDesigner::WidgetWithSubpropertiesInterface if (newSubwidget) { newSubwidget->setObjectName( QString::fromLatin1("KexiDBAutoField_") + newSubwidget->metaObject()->className()); dynamic_cast<KexiDataItemInterface*>(newSubwidget)->setParentDataItemInterface(this); dynamic_cast<KexiFormDataItemInterface*>(newSubwidget) ->setColumnInfo(columnInfo()); //needed at least by KexiDBImageBox dynamic_cast<KexiFormDataItemInterface*>(newSubwidget) ->setVisibleColumnInfo(visibleColumnInfo()); //needed at least by KexiDBComboBox newSubwidget->setProperty("dataSource", dataSource()); //needed at least by KexiDBImageBox KFormDesigner::DesignTimeDynamicChildWidgetHandler::childWidgetAdded(this); newSubwidget->show(); d->label->setBuddy(newSubwidget); if (d->focusPolicyChanged) {//if focusPolicy is changed at top level, editor inherits it newSubwidget->setFocusPolicy(focusPolicy()); } else {//if focusPolicy is not changed at top level, inherit it from editor QWidget::setFocusPolicy(newSubwidget->focusPolicy()); } setFocusProxy(newSubwidget); //ok? if (parentWidget()) newSubwidget->setPalette(qApp->palette()); copyPropertiesToEditor(); } setLabelPosition(labelPosition()); }