MessageItemModel.hpp
1 #pragma once
2 #include <Process/State/MessageNode.hpp>
3 
4 #include <score/model/tree/TreeNodeItemModel.hpp>
5 #include <score/tools/Metadata.hpp>
6 
7 #include <QStringList>
8 #include <QVariant>
9 #include <qnamespace.h>
10 
11 #include <score_plugin_scenario_export.h>
12 
13 #include <verdigris>
14 
15 class QMimeData;
16 class QObject;
17 namespace score
18 {
19 class CommandStackFacade;
20 } // namespace score
21 namespace State
22 {
23 struct Message;
24 }
25 
26 namespace Scenario
27 {
28 class StateModel;
36 class SCORE_PLUGIN_SCENARIO_EXPORT MessageItemModel final
37  : public TreeNodeBasedItemModel<Process::MessageNode>
38 {
39  W_OBJECT(MessageItemModel)
40 
41 public:
43 
44  enum class Column : int
45  {
46  Name = 0,
47  Value,
48  Count
49  };
50 
51  MessageItemModel(const StateModel&, QObject* parent);
52  MessageItemModel& operator=(const MessageItemModel&);
53  MessageItemModel& operator=(const node_type&);
54  MessageItemModel& operator=(node_type&&);
55 
56  const Process::MessageNode& rootNode() const override { return m_rootNode; }
57 
58  Process::MessageNode& rootNode() override { return m_rootNode; }
59 
60  // AbstractItemModel interface
61  int columnCount(const QModelIndex& parent) const override;
62 
63  QVariant data(const QModelIndex& index, int role) const override;
64  bool setData(const QModelIndex& index, const QVariant& value, int role) override;
65 
66  QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
67  bool setHeaderData(
68  int section, Qt::Orientation orientation, const QVariant& value,
69  int role) override;
70 
71  QStringList mimeTypes() const override;
72  QMimeData* mimeData(const QModelIndexList& indexes) const override;
73  bool canDropMimeData(
74  const QMimeData* data, Qt::DropAction action, int row, int column,
75  const QModelIndex& parent) const override;
76  bool dropMimeData(
77  const QMimeData* data, Qt::DropAction action, int row, int column,
78  const QModelIndex& parent) override;
79 
80  Qt::DropActions supportedDragActions() const override;
81  Qt::DropActions supportedDropActions() const override;
82 
83  Qt::ItemFlags flags(const QModelIndex& index) const override;
84 
85  const StateModel& stateModel;
86 
87  using QAbstractItemModel::beginInsertRows;
88  using QAbstractItemModel::beginRemoveRows;
89  using QAbstractItemModel::beginResetModel;
90  using QAbstractItemModel::endInsertRows;
91  using QAbstractItemModel::endRemoveRows;
92  using QAbstractItemModel::endResetModel;
93 
94 public:
95  void userMessage(const State::Message& arg_1)
96  E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, userMessage, arg_1)
97 
98 private:
99  node_type m_rootNode;
100 };
101 
102 QVariant valueColumnData(const MessageItemModel::node_type& node, int role);
103 }
104 
105 DEFAULT_MODEL_METADATA(Scenario::MessageItemModel, "Message item model")
The MessageItemModel class.
Definition: MessageItemModel.hpp:38
Definition: StateModel.hpp:63
Definition: TreeNodeItemModel.hpp:38
Main plug-in of score.
Definition: score-plugin-dataflow/Dataflow/PortItem.hpp:14
Utilities for OSSIA data structures.
Definition: DeviceInterface.hpp:33
Base toolkit upon which the software is built.
Definition: Application.cpp:90
The Message struct.
Definition: Message.hpp:15