NodeDelegateModel.cpp 1018 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #include "NodeDelegateModel.hpp"
  2. #include "StyleCollection.hpp"
  3. namespace QtNodes {
  4. NodeDelegateModel::NodeDelegateModel()
  5. : _nodeStyle(StyleCollection::nodeStyle())
  6. {
  7. // Derived classes can initialize specific style here
  8. }
  9. QJsonObject NodeDelegateModel::save() const
  10. {
  11. QJsonObject modelJson;
  12. modelJson["model-name"] = name();
  13. return modelJson;
  14. }
  15. void NodeDelegateModel::load(QJsonObject const &)
  16. {
  17. //
  18. }
  19. ConnectionPolicy NodeDelegateModel::portConnectionPolicy(PortType portType, PortIndex) const
  20. {
  21. auto result = ConnectionPolicy::One;
  22. switch (portType) {
  23. case PortType::In:
  24. result = ConnectionPolicy::One;
  25. break;
  26. case PortType::Out:
  27. result = ConnectionPolicy::Many;
  28. break;
  29. case PortType::None:
  30. break;
  31. }
  32. return result;
  33. }
  34. NodeStyle const &NodeDelegateModel::nodeStyle() const
  35. {
  36. return _nodeStyle;
  37. }
  38. void NodeDelegateModel::setNodeStyle(NodeStyle const &style)
  39. {
  40. _nodeStyle = style;
  41. }
  42. } // namespace QtNodes