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 "../gui/treemodel.h"
29 #include "scenarioitem.h"
31 #include <memory>
32 
33 /**
34 * @class ScenarioModel
35 * @brief Model defining how a Scenario gets displayed in the TreeView.
36 */
37 class ScenarioModel : public TreeModel
38 {
39  Q_OBJECT
40 public:
41  /**
42  * Sets up the model.
43  */
44  ScenarioModel();
45 
46  /**
47  * Returns the data of the item at the given index based on the given role.
48  * @param index index of the item
49  * @param role role of the item
50  */
51  QVariant data(const QModelIndex& index, int role) const override;
52 
53  /**
54  * Returns the drop-Actions supported by this model.
55  * @return supported drop-actions
56  */
57  Qt::DropActions supportedDropActions() const override;
58 
59  /**
60  * Returns the item flags of the item at the given index.
61  * @param index item-index
62  * @return item flags
63  */
64  Qt::ItemFlags flags(const QModelIndex& index) const override;
65 
66  /**
67  *
68  * @param data
69  * @param action
70  * @param row
71  * @param column
72  * @param parent
73  */
74  bool dropMimeData(const QMimeData* data, Qt::DropAction action,
75  int row, int column, const QModelIndex& parent) override;
76 
77  /**
78  * Updates this model.
79  */
80  void update();
81 
82  /**
83  *
84  */
85  QStringList mimeTypes() const override;
86 
87  /**
88  * Clears and resets this model.
89  */
90  void clear() override;
91 
93 
94  static ScenarioItem* FindScenario(const QAbstractItemModel* model, const QString& scenarioName);
95  static int FindScenarioIndex(const QAbstractItemModel* model, const QString& scenarioName);
96 
97 private:
98  void treeUpdate(ScenarioItem* item);
99 
100 signals:
101  void applicationsDrop(QList<QPair<QString, ScenarioManager::Data_Structure::Application*>> applications,
102  int row, const QModelIndex& parent);
103 };
104 
105 using ScenarioModelPtr = std::shared_ptr<ScenarioModel>;
106 
ScenarioItem
TreeItem representing data contained in a Scenario or an Application.
Definition: scenarioitem.h:38
ScenarioModel::FindScenarioIndex
static int FindScenarioIndex(const QAbstractItemModel *model, const QString &scenarioName)
Definition: scenariomodel.cpp:260
TreeModel::index
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Definition: treemodel.cpp:96
ScenarioModel::dropMimeData
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
Definition: scenariomodel.cpp:158
ScenarioModel::supportedDropActions
Qt::DropActions supportedDropActions() const override
Returns the drop-Actions supported by this model.
Definition: scenariomodel.cpp:134
ScenarioModel
Model defining how a Scenario gets displayed in the TreeView.
Definition: scenariomodel.h:37
ScenarioModel::ScenarioModel
ScenarioModel()
Sets up the model.
Definition: scenariomodel.cpp:41
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:46
ScenarioModel::clear
void clear() override
Clears and resets this model.
Definition: scenariomodel.cpp:125
TreeModel::parent
QModelIndex parent(const QModelIndex &index) const override
Definition: treemodel.cpp:118
ScenarioModel::getRootItem
ScenarioItem * getRootItem()
Definition: scenariomodel.cpp:239
ScenarioModel::update
void update()
Updates this model.
Definition: scenariomodel.cpp:208
ScenarioModel::mimeTypes
QStringList mimeTypes() const override
Definition: scenariomodel.cpp:151
TreeModel
Definition: treemodel.h:34
ApplicationInstance.h
ScenarioModelPtr
std::shared_ptr< ScenarioModel > ScenarioModelPtr
Definition: scenariomodel.h:105
ScenarioModel::FindScenario
static ScenarioItem * FindScenario(const QAbstractItemModel *model, const QString &scenarioName)
Definition: scenariomodel.cpp:244
ScenarioModel::flags
Qt::ItemFlags flags(const QModelIndex &index) const override
Returns the item flags of the item at the given index.
Definition: scenariomodel.cpp:139
ScenarioModel::applicationsDrop
void applicationsDrop(QList< QPair< QString, ScenarioManager::Data_Structure::Application * >> applications, int row, const QModelIndex &parent)