PortInspectorFactory.hpp
1 #pragma once
2 #include <Process/Dataflow/PortFactory.hpp>
3 #include <Process/Dataflow/PortListWidget.hpp>
4 
5 #include <Dataflow/PortItem.hpp>
6 #include <Inspector/InspectorLayout.hpp>
7 
8 #include <score/application/GUIApplicationContext.hpp>
9 #include <score/document/DocumentContext.hpp>
10 
11 namespace Dataflow
12 {
13 
14 class PortTooltip final : public QWidget
15 {
16 public:
18  const score::DocumentContext& ctx, const Process::Inlet& port, QWidget* parent)
19  : QWidget{parent}
20  {
21  auto lay = new Inspector::Layout{this};
22  lay->addRow(port.name(), (QWidget*)nullptr);
23 
24  auto& pf = ctx.app.interfaces<Process::PortFactoryList>();
25  auto fact = pf.get(port.concreteKey());
26  if(fact)
27  {
28  fact->setupInletInspector(port, ctx, this, *lay, this);
29  }
30  else
31  {
32  Process::PortWidgetSetup::setupAlone(port, ctx, *lay, this);
33  }
34  }
36  const score::DocumentContext& ctx, const Process::Outlet& port, QWidget* parent)
37  : QWidget{parent}
38  {
39  auto lay = new Inspector::Layout{this};
40  lay->addRow(port.name(), (QWidget*)nullptr);
41 
42  auto& pf = ctx.app.interfaces<Process::PortFactoryList>();
43  auto fact = pf.get(port.concreteKey());
44  if(fact)
45  {
46  fact->setupOutletInspector(port, ctx, this, *lay, this);
47  }
48  else
49  {
50  Process::PortWidgetSetup::setupAlone(port, ctx, *lay, this);
51  }
52  }
53 };
54 
55 class SCORE_PLUGIN_DATAFLOW_EXPORT InletInspectorFactory final
57 {
58  SCORE_CONCRETE("1e7166bb-278a-49ce-b6a9-d662b8cd8dd2")
59 public:
61  : InspectorWidgetFactory{}
62  {
63  }
64 
65  QWidget* make(
66  const InspectedObjects& sourceElements, const score::DocumentContext& doc,
67  QWidget* parent) const override
68  {
69  return new PortTooltip{
70  doc, safe_cast<const Process::Inlet&>(*sourceElements.first()), parent};
71  }
72 
73  bool matches(const InspectedObjects& objects) const override
74  {
75  return qobject_cast<const Process::Inlet*>(objects.first());
76  }
77 };
78 class SCORE_PLUGIN_DATAFLOW_EXPORT OutletInspectorFactory final
80 {
81  SCORE_CONCRETE("2479a7a1-8dbc-49d5-a146-3d29d5106cba")
82 public:
83 public:
85  : InspectorWidgetFactory{}
86  {
87  }
88 
89  QWidget* make(
90  const InspectedObjects& sourceElements, const score::DocumentContext& doc,
91  QWidget* parent) const override
92  {
93  return new PortTooltip{
94  doc, safe_cast<const Process::Outlet&>(*sourceElements.first()), parent};
95  }
96 
97  bool matches(const InspectedObjects& objects) const override
98  {
99  return qobject_cast<const Process::Outlet*>(objects.first());
100  }
101 };
102 }
Definition: PortInspectorFactory.hpp:57
QWidget * make(const InspectedObjects &sourceElements, const score::DocumentContext &doc, QWidget *parent) const override
makeWidget Makes a widget for the inspector from an object
Definition: PortInspectorFactory.hpp:65
Definition: PortInspectorFactory.hpp:80
QWidget * make(const InspectedObjects &sourceElements, const score::DocumentContext &doc, QWidget *parent) const override
makeWidget Makes a widget for the inspector from an object
Definition: PortInspectorFactory.hpp:89
Definition: PortInspectorFactory.hpp:15
The InspectorWidgetFactoryInterface class.
Definition: InspectorWidgetFactoryInterface.hpp:32
Definition: lib/score/widgets/Layout.hpp:29
Definition: Port.hpp:177
Definition: Port.hpp:273
Definition: PortFactory.hpp:74
FactoryType * get(const key_type &k) const noexcept
Get a particular factory from its ConcreteKey.
Definition: InterfaceList.hpp:123
Definition: ObjectMatches.hpp:6
const T & interfaces() const
Access to a specific interface list.
Definition: ApplicationContext.hpp:67
Definition: DocumentContext.hpp:18