コード例 #1
0
void QtCheckBoxFactory::slotSetValue(bool value)
{
    QObject *object = this->sender();

    const QMap<QtBoolEdit *, QtProperty *>::ConstIterator ecend = m_editorToProperty.constEnd();
    for (QMap<QtBoolEdit *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend;  ++itEditor)
        if (itEditor.key() == object) {
            QtProperty *property = itEditor.value();
            QtBoolPropertyManager *manager = this->propertyManager(property);
            if (!manager)
                return;
            manager->setValue(property, value);
            return;
        }
}
コード例 #2
0
void SchematicSceneBuilder::setup_properties(
    Item* item,
    std::string name,
    double value,
    bool symbolic,
    std::map<std::string, std::string> props
  )
{
  QtProperty* properties = SchematicScene::itemProperties(item);

  QHash<QString, QtProperty*> subproperties;
  if(properties) {
    subproperties.insert("__NAME", properties);
    foreach(QtProperty* prop, properties->subProperties())
      subproperties.insert(prop->propertyName(), prop);
  }

  if(subproperties.contains("__NAME")) {
    QtStringPropertyManager* spm =
      qobject_cast<QtStringPropertyManager*>(
        subproperties.value("__NAME")->propertyManager());
      if(spm)
        spm->setValue(
            subproperties.value("__NAME"),
            QString::fromStdString(name)
          );
  }

  if(subproperties.contains("Value")) {
    QtStringPropertyManager* spm =
      qobject_cast<QtStringPropertyManager*>(
        subproperties.value("Value")->propertyManager());
      if(spm)
        spm->setValue(
            subproperties.value("Value"),
            QString::number(value)
          );
  }

  if(subproperties.contains("Symbolic")) {
    QtBoolPropertyManager* bpm =
      qobject_cast<QtBoolPropertyManager*>(
        subproperties.value("Symbolic")->propertyManager());
      if(bpm)
        bpm->setValue(
            subproperties.value("Symbolic"),
            symbolic
          );
  }

  if(subproperties.contains("lp:name")) {
    QtStringPropertyManager* spm =
      qobject_cast<QtStringPropertyManager*>(
        subproperties.value("lp:name")->propertyManager());
      if(spm)
        spm->setValue(
            subproperties.value("lp:name"),
            QString::fromStdString(props["lp:name"])
          );
  }

  if(subproperties.contains("lp:value")) {
    QtStringPropertyManager* spm =
      qobject_cast<QtStringPropertyManager*>(
        subproperties.value("lp:value")->propertyManager());
      if(spm)
        spm->setValue(
            subproperties.value("lp:value"),
            QString::number(
              QString::fromStdString(props["lp:value"]).toDouble())
          );
  }

  if(subproperties.contains("ls:name")) {
    QtStringPropertyManager* spm =
      qobject_cast<QtStringPropertyManager*>(
        subproperties.value("ls:name")->propertyManager());
      if(spm)
        spm->setValue(
            subproperties.value("ls:name"),
            QString::fromStdString(props["ls:name"])
          );
  }

  if(subproperties.contains("ls:value")) {
    QtStringPropertyManager* spm =
      qobject_cast<QtStringPropertyManager*>(
        subproperties.value("ls:value")->propertyManager());
      if(spm)
        spm->setValue(
            subproperties.value("ls:value"),
            QString::number(
              QString::fromStdString(props["ls:value"]).toDouble())
          );
  }
}