ProcessInspectorWidgetDelegateFactory.hpp
1 #pragma once
2 #include <Inspector/InspectorWidgetFactoryInterface.hpp>
3 
4 #include <score/plugins/Interface.hpp>
5 #include <score/tools/SafeCast.hpp>
6 
7 #include <score_lib_process_export.h>
8 class QBoxLayout;
9 namespace Process
10 {
11 class ProcessModel;
12 class InspectorWidgetDelegate;
13 }
14 namespace score
15 {
16 struct DocumentContext;
17 }
18 
19 namespace Process
20 {
21 class SCORE_LIB_PROCESS_EXPORT InspectorWidgetDelegateFactory
23 {
24 public:
26  virtual QWidget* makeProcess(
28  QWidget* parent) const
29  = 0;
30  virtual bool matchesProcess(const Process::ProcessModel&) const = 0;
31 
32  virtual void addButtons(
34  QBoxLayout* layout, QWidget* parent) const;
35 
36  bool matchesProcess(
37  const Process::ProcessModel& proc, const score::DocumentContext& doc,
38  QWidget* parent) const;
39 
40  QWidget* make(
41  const InspectedObjects& objects, const score::DocumentContext& doc,
42  QWidget* parent) const final override;
43  bool matches(const InspectedObjects& objects) const final override;
44 
45 protected:
46  QWidget* wrap(
47  const Process::ProcessModel& process, const score::DocumentContext& doc,
48  QWidget* widg, QWidget* parent) const;
49 };
50 
51 template <typename Process_T, typename Widget_T>
53 {
54 private:
55  QWidget* makeProcess(
56  const Process::ProcessModel& process, const score::DocumentContext& doc,
57  QWidget* parent) const override
58  {
59  auto w = new Widget_T{safe_cast<const Process_T&>(process), doc, nullptr};
60 
61  return wrap(process, doc, w, parent);
62  }
63 
64  bool matchesProcess(const Process::ProcessModel& process) const override
65  {
66  return dynamic_cast<const Process_T*>(&process);
67  }
68 };
69 
70 }
The InspectorWidgetFactoryInterface class.
Definition: InspectorWidgetFactoryInterface.hpp:32
Definition: ProcessInspectorWidgetDelegateFactory.hpp:53
Definition: ProcessInspectorWidgetDelegateFactory.hpp:23
The Process class.
Definition: score-lib-process/Process/Process.hpp:61
Base classes and tools to implement processes and layers.
Definition: JSONVisitor.hpp:1324
Base toolkit upon which the software is built.
Definition: Application.cpp:90
Definition: ObjectMatches.hpp:6
Definition: DocumentContext.hpp:18