settingsmodel.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
25
26
#include "
settingsmodel.h
"
27
28
SettingsModel::SettingsModel
()
29
{
30
rootItem
=
new
SettingsItem
(QList<QVariant>({
"Packages"
,
"Paths"
,
"Remove"
}));
31
}
32
33
QVariant
SettingsModel::data
(
const
QModelIndex&
index
,
int
role)
const
34
{
35
if
(!
index
.isValid())
36
{
37
return
QVariant();
38
}
39
40
// if (role == Qt::BackgroundRole){
41
// if(index.column() == 1) {
42
// if(!index.data().toString().compare("Running")){
43
// return QColor(Qt::green);
44
// } else if(!index.data().toString().compare("Stopped")) {
45
// return QColor(Qt::red);
46
// } else if(!index.data().toString().compare("Waiting")) {
47
// return QColor(Qt::darkYellow);
48
// } else {
49
// return QColor(Qt::lightGray); //only for safety reasons
50
// }
51
// }
52
// } else if (role == Qt::DisplayRole) {
53
// if(index.column() == 2) {
54
55
// }
56
// } else if (role != Qt::DisplayRole){
57
// return QVariant();
58
// }
59
if
(role ==
SETTINGSITEMSOURCE
)
60
{
61
return
QVariant::fromValue(
reinterpret_cast<
SettingsItem
*
>
(
index
.internalPointer()));
62
}
63
if
(role != Qt::DisplayRole)
64
{
65
return
QVariant();
66
}
67
68
SettingsItem
* item =
static_cast<
SettingsItem
*
>
(
index
.internalPointer());
69
70
return
item->
data
(
index
.column());
71
}
72
73
74
void
SettingsModel::clear
()
75
{
76
delete
rootItem
;
77
rootItem
=
new
SettingsItem
(QList<QVariant>({
"Packages"
,
"Paths"
,
"Remove"
}));
78
}
79
80
void
SettingsModel::update
()
81
{
82
QModelIndex topLeft =
index
(0, 0);
83
QModelIndex bottomRight =
index
(
rowCount
() - 1,
columnCount
() - 1);
84
85
emit dataChanged(topLeft, bottomRight);
86
}
87
88
89
SettingsItem
*
SettingsModel::getRootItem
()
90
{
91
return
static_cast<
SettingsItem
*
>
(
rootItem
);
92
}
TreeModel::index
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Definition:
treemodel.cpp:96
SettingsModel::clear
void clear() override
Definition:
settingsmodel.cpp:74
SettingsModel::data
QVariant data(const QModelIndex &index, int role) const override
Definition:
settingsmodel.cpp:33
index
uint8_t index
Definition:
EtherCATFrame.h:59
SettingsModel::getRootItem
SettingsItem * getRootItem()
Definition:
settingsmodel.cpp:89
TreeItem::data
virtual QVariant data(int column) const
Definition:
treeitem.cpp:64
settingsmodel.h
SettingsModel::update
void update()
Definition:
settingsmodel.cpp:80
SETTINGSITEMSOURCE
@ SETTINGSITEMSOURCE
Definition:
treeitem.h:38
SettingsModel::SettingsModel
SettingsModel()
Definition:
settingsmodel.cpp:28
TreeModel::rootItem
TreeItem * rootItem
Definition:
treemodel.h:70
SettingsItem
Definition:
settingsitem.h:31
TreeModel::columnCount
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Definition:
treemodel.cpp:45
TreeModel::rowCount
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Definition:
treemodel.cpp:136
ArmarXGui
gui-plugins
ScenarioManager
gui
settingsmodel.cpp
Generated on Sat Sep 7 2024 09:13:47 for armarx_documentation by
1.8.17