scenariomodel.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5  *
6  * ArmarX is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * ArmarX is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * @package ArmarXCore::core
19  * @author Cedric Seehausen (usdnr at kit dot edu)
20  * @date 2016
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 
25 
26 #pragma once
27 
28 #include <memory>
29 
31 
32 #include "../gui/treemodel.h"
33 #include "scenarioitem.h"
34 
35 /**
36 * @class ScenarioModel
37 * @brief Model defining how a Scenario gets displayed in the TreeView.
38 */
39 class ScenarioModel : public TreeModel
40 {
41  Q_OBJECT
42 public:
43  /**
44  * Sets up the model.
45  */
46  ScenarioModel();
47 
48  /**
49  * Returns the data of the item at the given index based on the given role.
50  * @param index index of the item
51  * @param role role of the item
52  */
53  QVariant data(const QModelIndex& index, int role) const override;
54 
55  /**
56  * Returns the drop-Actions supported by this model.
57  * @return supported drop-actions
58  */
59  Qt::DropActions supportedDropActions() const override;
60 
61  /**
62  * Returns the item flags of the item at the given index.
63  * @param index item-index
64  * @return item flags
65  */
66  Qt::ItemFlags flags(const QModelIndex& index) const override;
67 
68  /**
69  *
70  * @param data
71  * @param action
72  * @param row
73  * @param column
74  * @param parent
75  */
76  bool dropMimeData(const QMimeData* data,
77  Qt::DropAction action,
78  int row,
79  int column,
80  const QModelIndex& parent) override;
81 
82  /**
83  * Updates this model.
84  */
85  void update();
86 
87  /**
88  *
89  */
90  QStringList mimeTypes() const override;
91 
92  /**
93  * Clears and resets this model.
94  */
95  void clear() override;
96 
98 
99  static ScenarioItem* FindScenario(const QAbstractItemModel* model, const QString& scenarioName);
100  static int FindScenarioIndex(const QAbstractItemModel* model, const QString& scenarioName);
101 
102 private:
103  void treeUpdate(ScenarioItem* item);
104 
105 signals:
106  void applicationsDrop(
107  QList<QPair<QString, ScenarioManager::Data_Structure::Application*>> applications,
108  int row,
109  const QModelIndex& parent);
110 };
111 
112 using ScenarioModelPtr = std::shared_ptr<ScenarioModel>;
ScenarioItem
TreeItem representing data contained in a Scenario or an Application.
Definition: scenarioitem.h:40
ScenarioModel::FindScenarioIndex
static int FindScenarioIndex(const QAbstractItemModel *model, const QString &scenarioName)
Definition: scenariomodel.cpp:276
TreeModel::index
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Definition: treemodel.cpp:99
ScenarioModel::dropMimeData
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
Definition: scenariomodel.cpp:165
ScenarioModel::supportedDropActions
Qt::DropActions supportedDropActions() const override
Returns the drop-Actions supported by this model.
Definition: scenariomodel.cpp:138
ScenarioModel
Model defining how a Scenario gets displayed in the TreeView.
Definition: scenariomodel.h:39
ScenarioModel::ScenarioModel
ScenarioModel()
Sets up the model.
Definition: scenariomodel.cpp:42
scenarioitem.h
ScenarioModel::data
QVariant data(const QModelIndex &index, int role) const override
Returns the data of the item at the given index based on the given role.
Definition: scenariomodel.cpp:49
ScenarioModel::clear
void clear() override
Clears and resets this model.
Definition: scenariomodel.cpp:129
TreeModel::parent
QModelIndex parent(const QModelIndex &index) const override
Definition: treemodel.cpp:121
ScenarioModel::getRootItem
ScenarioItem * getRootItem()
Definition: scenariomodel.cpp:253
ScenarioModel::update
void update()
Updates this model.
Definition: scenariomodel.cpp:220
ScenarioModel::mimeTypes
QStringList mimeTypes() const override
Definition: scenariomodel.cpp:157
TreeModel
Definition: treemodel.h:36
ApplicationInstance.h
ScenarioModelPtr
std::shared_ptr< ScenarioModel > ScenarioModelPtr
Definition: scenariomodel.h:112
ScenarioModel::FindScenario
static ScenarioItem * FindScenario(const QAbstractItemModel *model, const QString &scenarioName)
Definition: scenariomodel.cpp:259
ScenarioModel::flags
Qt::ItemFlags flags(const QModelIndex &index) const override
Returns the item flags of the item at the given index.
Definition: scenariomodel.cpp:144
ScenarioModel::applicationsDrop
void applicationsDrop(QList< QPair< QString, ScenarioManager::Data_Structure::Application * >> applications, int row, const QModelIndex &parent)