QVariant ItemHandlerSpinboxRange::GetObjectValue (QObject *object) const { RangeWidget *widget = qobject_cast<RangeWidget*> (object); if (!widget) { qWarning () << Q_FUNC_INFO << "not a RangeWidget" << object; return QVariant (); } return widget->GetRange (); }
void ItemHandlerSpinboxRange::SetValue (QWidget *widget, const QVariant& value) const { RangeWidget *rw = qobject_cast<RangeWidget*> (widget); if (!rw) { qWarning () << Q_FUNC_INFO << "not a RangeWidget" << widget; return; } rw->SetRange (value); }
void ItemHandlerSpinboxRange::Handle (const QDomElement& item, QWidget *pwidget) { QGridLayout *lay = qobject_cast<QGridLayout*> (pwidget->layout ()); QLabel *label = new QLabel (XSD_->GetLabel (item)); label->setWordWrap (false); RangeWidget *widget = new RangeWidget (); XSD_->SetTooltip (widget, item); widget->setObjectName (item.attribute ("property")); widget->SetMinimum (item.attribute ("minimum").toInt ()); widget->SetMaximum (item.attribute ("maximum").toInt ()); const QVariant& value = XSD_->GetValue (item); widget->SetRange (value); connect (widget, SIGNAL (changed ()), this, SLOT (updatePreferences ())); widget->setProperty ("ItemHandler", QVariant::fromValue<QObject*> (this)); widget->setProperty ("SearchTerms", label->text ()); int row = lay->rowCount (); lay->addWidget (label, row, 0, Qt::AlignRight); lay->addWidget (widget, row, 1); }
void ItemHandlerSpinboxRange::Handle (const QDomElement& item, QWidget *pwidget) { QFormLayout *lay = qobject_cast<QFormLayout*> (pwidget->layout ()); QLabel *label = new QLabel (XSD_->GetLabel (item)); label->setWordWrap (false); RangeWidget *widget = new RangeWidget (); widget->setObjectName (item.attribute ("property")); widget->SetMinimum (item.attribute ("minimum").toInt ()); widget->SetMaximum (item.attribute ("maximum").toInt ()); QVariant value = XSD_->GetValue (item); widget->SetRange (value); connect (widget, SIGNAL (changed ()), this, SLOT (updatePreferences ())); widget->setProperty ("ItemHandler", QVariant::fromValue<QObject*> (this)); lay->addRow (label, widget); }