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*/
40{
41 Q_OBJECT
42public:
43 /**
44 * Sets up the model.
45 */
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
102private:
103 void treeUpdate(ScenarioItem* item);
104
105signals:
107 QList<QPair<QString, ScenarioManager::Data_Structure::Application*>> applications,
108 int row,
109 const QModelIndex& parent);
110};
111
112using ScenarioModelPtr = std::shared_ptr<ScenarioModel>;
uint8_t data[1]
TreeItem representing data contained in a Scenario or an Application.
QStringList mimeTypes() const override
void applicationsDrop(QList< QPair< QString, ScenarioManager::Data_Structure::Application * > > applications, int row, const QModelIndex &parent)
static ScenarioItem * FindScenario(const QAbstractItemModel *model, const QString &scenarioName)
Qt::ItemFlags flags(const QModelIndex &index) const override
Returns the item flags of the item at the given index.
ScenarioItem * getRootItem()
static int FindScenarioIndex(const QAbstractItemModel *model, const QString &scenarioName)
void update()
Updates this model.
Qt::DropActions supportedDropActions() const override
Returns the drop-Actions supported by this model.
QVariant data(const QModelIndex &index, int role) const override
Returns the data of the item at the given index based on the given role.
void clear() override
Clears and resets this model.
ScenarioModel()
Sets up the model.
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
TreeModel(QObject *parent=0)
Definition treemodel.cpp:32
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Definition treemodel.cpp:99
QModelIndex parent(const QModelIndex &index) const override
std::shared_ptr< ScenarioModel > ScenarioModelPtr