void QtGroupBoxPropertyBrowserPrivate::updateItem(WidgetItem *item) { QtProperty *property = m_itemToIndex[item]->property(); if (item->groupBox) { QFont font = item->groupBox->font(); font.setUnderline(property->isModified()); item->groupBox->setFont(font); item->groupBox->setTitle(property->propertyName()); item->groupBox->setToolTip(property->toolTip()); item->groupBox->setStatusTip(property->statusTip()); item->groupBox->setWhatsThis(property->whatsThis()); item->groupBox->setEnabled(property->isEnabled()); } if (item->label) { QFont font = item->label->font(); font.setUnderline(property->isModified()); item->label->setFont(font); item->label->setText(property->propertyName()); item->label->setToolTip(property->toolTip()); item->label->setStatusTip(property->statusTip()); item->label->setWhatsThis(property->whatsThis()); item->label->setEnabled(property->isEnabled()); } if (item->widgetLabel) { QFont font = item->widgetLabel->font(); font.setUnderline(false); item->widgetLabel->setFont(font); item->widgetLabel->setText(property->valueText()); item->widgetLabel->setToolTip(property->valueText()); item->widgetLabel->setEnabled(property->isEnabled()); } if (item->widget) { QFont font = item->widget->font(); font.setUnderline(false); item->widget->setFont(font); item->widget->setEnabled(property->isEnabled()); item->widget->setToolTip(property->valueText()); } // item->setIcon(1, property->valueIcon()); }
void IqtFit::fixItem() { QtBrowserItem *item = m_ffTree->currentItem(); // Determine what the property is. QtProperty *prop = item->property(); QtProperty *fixedProp = m_stringManager->addProperty(prop->propertyName()); QtProperty *fprlbl = m_stringManager->addProperty("Fixed"); fixedProp->addSubProperty(fprlbl); m_stringManager->setValue(fixedProp, prop->valueText()); item->parent()->property()->addSubProperty(fixedProp); m_fixedProps[fixedProp] = prop; item->parent()->property()->removeSubProperty(prop); }
void SchematicSceneParser::parse_item( sapecng::abstract_builder& builder, Item* item ) { SchematicScene::SupportedItemType type = SchematicScene::itemType(item); std::map<std::string, std::string> props; storeItemData(props, type, item); QtProperty* properties = SchematicScene::itemProperties(item); QHash<QString, QString> subproperties; if(properties) { subproperties.insert("__NAME", properties->valueText()); foreach(QtProperty* prop, properties->subProperties()) subproperties.insert(prop->propertyName(), prop->valueText()); } switch(type) { case SchematicScene::GroundItemType: case SchematicScene::PortItemType: { // add as unknow Component* component = static_cast<Component*>(item); props["node"] = QString::number(component->nodes().front()).toStdString(); builder.add_unknow_component(props); break; } case SchematicScene::LabelItemType: { // add as unknow Label* label = static_cast<Label*>(item); props["text"] = label->text().toStdString(); builder.add_unknow_component(props); break; } case SchematicScene::WireItemType: { Wire* wire = static_cast<Wire*>(item); props["orientation"] = QString::number(wire->orientation()).toStdString(); props["to_x"] = QString::number(wire->toPoint().x()).toStdString(); props["to_y"] = QString::number(wire->toPoint().y()).toStdString(); props["conn"] = QString::number(wire->isJunctionsConnected()).toStdString(); builder.add_wire_component(props); break; } case SchematicScene::OutItemType: { if(!discard_) { Component* out = static_cast<Component*>(item); builder.add_out_component(out->nodes().front(), props); } break; } case SchematicScene::VoltmeterItemType: case SchematicScene::AmmeterItemType: { Component* component = static_cast<Component*>(item); QVector<int> nodes = component->nodes(); builder.add_dual_component( dualMap_[type], "", 1., true, nodes.at(1), nodes.at(0), props ); break; } case SchematicScene::CapacitorItemType: case SchematicScene::ConductanceItemType: case SchematicScene::InductorItemType: case SchematicScene::ResistorItemType: case SchematicScene::CurrentSourceItemType: case SchematicScene::VoltageSourceItemType: { Component* component = static_cast<Component*>(item); QVector<int> nodes = component->nodes(); storeLabel(props, component); builder.add_dual_component( dualMap_[type], subproperties.value("__NAME").toStdString(), subproperties.value("Value").toDouble(), QVariant(subproperties.value("Symbolic")).toBool(), nodes.at(1), nodes.at(0), props ); break; } case SchematicScene::CCCSItemType: case SchematicScene::CCVSItemType: case SchematicScene::VCCSItemType: case SchematicScene::VCVSItemType: { Component* component = static_cast<Component*>(item); QVector<int> nodes = component->nodes(); storeLabel(props, component); builder.add_quad_component( quadMap_[type], subproperties.value("__NAME").toStdString(), subproperties.value("Value").toDouble(), QVariant(subproperties.value("Symbolic")).toBool(), nodes.at(1), nodes.at(0), nodes.at(3), nodes.at(2), props ); break; } case SchematicScene::OpAmplItemType: { Component* component = static_cast<Component*>(item); QVector<int> nodes = component->nodes(); storeLabel(props, component); builder.add_quad_component( quadMap_[type], subproperties.value("__NAME").toStdString(), 1., false, SchematicScene::Ground, nodes.at(2), nodes.at(1), nodes.at(0), props ); break; } case SchematicScene::TransformerItemType: { Component* component = static_cast<Component*>(item); QVector<int> nodes = component->nodes(); storeLabel(props, component); builder.add_quad_component( quadMap_[type], subproperties.value("__NAME").toStdString(), subproperties.value("Value").toDouble(), QVariant(subproperties.value("Symbolic")).toBool(), nodes.at(3), nodes.at(2), nodes.at(1), nodes.at(0), props ); break; } case SchematicScene::MutualInductanceItemType: { Component* component = static_cast<Component*>(item); QVector<int> nodes = component->nodes(); storeLabel(props, component); props["lp:name"] = subproperties.value("lp:name").toStdString(); props["lp:value"] = subproperties.value("lp:value").toStdString(); props["ls:name"] = subproperties.value("ls:name").toStdString(); props["ls:value"] = subproperties.value("ls:value").toStdString(); builder.add_quad_component( quadMap_[type], subproperties.value("__NAME").toStdString(), subproperties.value("Value").toDouble(), QVariant(subproperties.value("Symbolic")).toBool(), nodes.at(3), nodes.at(2), nodes.at(1), nodes.at(0), props ); break; } case SchematicScene::UserDefItemType: { Component* component = static_cast<Component*>(item); storeLabel(props, component); builder.begin_userdef_component( subproperties.value("__NAME").toStdString(), props ); ++discard_; QPointer<qsapecng::SchematicScene> scene = item->data(101).value< QPointer<qsapecng::SchematicScene> >(); foreach(Item* item, scene->activeItems()) parse_item(builder, item); --discard_; builder.end_userdef_component( subproperties.value("__NAME").toStdString(), props ); // outer-to-inner port buffer resistors QVector<int> nodes = component->nodes(); QVector<int> ports = scene->ports(); if(nodes.size() == ports.size()) { for(int i = 0; i < nodes.size(); ++i) builder.add_dual_component( dualMap_[SchematicScene::ResistorItemType], "", .0, false, nodes.at(i), ports.at(i), boost::assign::map_list_of("discard", "1") ); } else { // something strange happens - port-to-ground short circuits foreach(int node, nodes) builder.add_dual_component( dualMap_[SchematicScene::ResistorItemType], "", .0, false, node, SchematicScene::Ground, boost::assign::map_list_of("discard", "1") ); } break; } default: break; } }