openscenariomodel.cpp
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#include "openscenariomodel.h"
25
26#include <initializer_list>
27
29{
30 rootItem = new OpenScenarioItem({"Scenarios", "Package", "Open"});
31}
32
33QVariant
34OpenScenarioModel::data(const QModelIndex& index, int role) const
35{
36 if (!index.isValid())
37 {
38 return QVariant();
39 }
40
41 // if (role == Qt::BackgroundRole){
42 // if(index.column() == 1) {
43 // if(!index.data().toString().compare("Running")){
44 // return QColor(Qt::green);
45 // } else if(!index.data().toString().compare("Stopped")) {
46 // return QColor(Qt::red);
47 // } else if(!index.data().toString().compare("Waiting")) {
48 // return QColor(Qt::darkYellow);
49 // } else {
50 // return QColor(Qt::lightGray); //only for safety reasons
51 // }
52 // }
53 // } else if (role == Qt::DisplayRole) {
54 // if(index.column() == 2) {
55
56 // }
57 // } else if (role != Qt::DisplayRole){
58 // return QVariant();
59 // }
60 if (role == OPENSCENARIOITEMSOURCE)
61 {
62 return QVariant::fromValue(reinterpret_cast<OpenScenarioItem*>(index.internalPointer()));
63 }
64 if (role != Qt::DisplayRole)
65 {
66 return QVariant();
67 }
68
69 OpenScenarioItem* item = static_cast<OpenScenarioItem*>(index.internalPointer());
70
71 return item->data(index.column());
72}
73
74void
76{
77 delete rootItem;
78 rootItem = new OpenScenarioItem({"Scenarios", "Package", "Open"});
79 reset();
80}
81
82void
84{
85 QModelIndex topLeft = index(0, 0);
86 QModelIndex bottomRight = index(rowCount() - 1, columnCount() - 1);
87
88 emit dataChanged(topLeft, bottomRight);
89}
90
93{
94 return static_cast<OpenScenarioItem*>(rootItem);
95}
uint8_t index
Item in the TreeItemView.
OpenScenarioModel()
Constructor that sets up the root of this model.
void update()
Updates this model.
OpenScenarioItem * getRootItem()
QVariant data(const QModelIndex &index, int role) const override
Returns the data of the item at the given index of the given role.
void clear() override
Deletes the current root and replaces it with a new one, as if this model was newly constructed.
virtual QVariant data(int column) const
Definition treeitem.cpp:69
TreeItem * rootItem
Definition treemodel.h:69
int rowCount(const QModelIndex &parent=QModelIndex()) const override
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Definition treemodel.cpp:99
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Definition treemodel.cpp:45
@ OPENSCENARIOITEMSOURCE
Definition treeitem.h:43