Skip to content

Commit

Permalink
Merge pull request LibrePCB#195 from LibrePCB/rename_item_to_gate
Browse files Browse the repository at this point in the history
Rename "item" to "gate" in components and schematics
  • Loading branch information
ubruhin authored Feb 11, 2018
2 parents 2412a24 + ed62d03 commit d2ea95e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dev/demo-workspace
Submodule demo-workspace updated 796 files
5 changes: 5 additions & 0 deletions libs/librepcb/library/cmp/componentsymbolvariant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ ComponentSymbolVariant::ComponentSymbolVariant(const SExpression& node) :
// Load all symbol variant items
mSymbolItems.loadFromDomElement(node);

// backward compatibility, remove this some time!
foreach (const SExpression& node, node.getChildren("item")) {
mSymbolItems.append(std::make_shared<ComponentSymbolVariantItem>(node)); // can throw
}

if (!checkAttributesValidity()) throw LogicError(__FILE__, __LINE__);
}

Expand Down
4 changes: 3 additions & 1 deletion libs/librepcb/library/cmp/componentsymbolvariantitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ namespace library {
* - UUID
* - Symbol UUID
* - Pin-signal-mapping
*
* @todo Rename class to "ComponentGate" (or similar) and rename related classes if needed
*/
class ComponentSymbolVariantItem final : public SerializableObject
{
Expand Down Expand Up @@ -112,7 +114,7 @@ class ComponentSymbolVariantItem final : public SerializableObject
* Class ComponentSymbolVariantItemList
****************************************************************************************/

struct ComponentSymbolVariantItemListNameProvider {static constexpr const char* tagname = "item";};
struct ComponentSymbolVariantItemListNameProvider {static constexpr const char* tagname = "gate";};
using ComponentSymbolVariantItemList = SerializableObjectList<ComponentSymbolVariantItem, ComponentSymbolVariantItemListNameProvider>;
using CmdComponentSymbolVariantItemInsert = CmdListElementInsert<ComponentSymbolVariantItem, ComponentSymbolVariantItemListNameProvider>;
using CmdComponentSymbolVariantItemRemove = CmdListElementRemove<ComponentSymbolVariantItem, ComponentSymbolVariantItemListNameProvider>;
Expand Down
10 changes: 8 additions & 2 deletions libs/librepcb/project/schematics/items/si_symbol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,13 @@ SI_Symbol::SI_Symbol(Schematic& schematic, const SExpression& node) :
}
mPosition = Point(node.getChildByPath("pos"));
mRotation = node.getValueByPath<Angle>("rot", true);
Uuid symbVarItemUuid = node.getValueByPath<Uuid>("lib_item", true);
Uuid symbVarItemUuid;
if (node.tryGetChildByPath("lib_gate")) {
symbVarItemUuid = node.getValueByPath<Uuid>("lib_gate", true);
} else {
// backward compatibility, remove this some time!
symbVarItemUuid = node.getValueByPath<Uuid>("lib_item", true);
}
init(symbVarItemUuid);
}

Expand Down Expand Up @@ -189,7 +195,7 @@ void SI_Symbol::serialize(SExpression& root) const

root.appendToken(mUuid);
root.appendTokenChild("component", mComponentInstance->getUuid(), true);
root.appendTokenChild("lib_item", mSymbVarItem->getUuid(), true);
root.appendTokenChild("lib_gate", mSymbVarItem->getUuid(), true);
root.appendChild(mPosition.serializeToDomElement("pos"), true);
root.appendTokenChild("rot", mRotation, false);
}
Expand Down

0 comments on commit d2ea95e

Please sign in to comment.