DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
dbe
apps
SchemaEditor
SchemaCustomModelInterface.cpp
Go to the documentation of this file.
1
// DUNE DAQ modification notice:
2
// This file has been modified from the original ATLAS dbe source for the DUNE DAQ project.
3
// Fork baseline commit: dbe-02-12-17 (2022-05-12).
4
// Renamed since fork: yes (from src/SchemaEditor/SchemaCustomModelInterface.cpp to
5
// apps/SchemaEditor/SchemaCustomModelInterface.cpp).
6
8
#include "
dbe/SchemaCustomModelInterface.hpp
"
9
#include "
dbe/SchemaKernelWrapper.hpp
"
10
#include "
dbe/SchemaStyle.hpp
"
11
12
dbse::CustomModelInterface::CustomModelInterface
(QStringList Headers, QObject* parent)
13
: QAbstractTableModel(parent)
14
,
HeaderList
(Headers)
15
{
16
}
17
18
dbse::CustomModelInterface::~CustomModelInterface
() {}
19
20
int
21
dbse::CustomModelInterface::rowCount
(
const
QModelIndex& parent)
const
22
{
23
Q_UNUSED(parent)
24
return
Data
.size();
25
}
26
27
int
28
dbse::CustomModelInterface::columnCount
(
const
QModelIndex& parent)
const
29
{
30
Q_UNUSED(parent)
31
return
HeaderList
.size();
32
}
33
34
Qt::ItemFlags
35
dbse::CustomModelInterface::flags
(
const
QModelIndex& index)
const
36
{
37
Q_UNUSED(index)
38
return
Qt::ItemIsEnabled | Qt::ItemIsSelectable;
39
}
40
41
QVariant
42
dbse::CustomModelInterface::headerData
(
int
section, Qt::Orientation orientation,
int
role)
const
43
{
44
if
(role != Qt::DisplayRole) {
45
return
QVariant();
46
}
47
48
if
(orientation == Qt::Horizontal) {
49
return
HeaderList
.at(section);
50
}
51
52
return
QVariant();
53
}
54
55
QVariant
56
dbse::CustomModelInterface::data
(
const
QModelIndex& index,
int
role)
const
57
{
58
if
(role == Qt::DisplayRole) {
59
return
Data
.value(index.row()).value(index.column());
60
}
else
if
(role == Qt::ForegroundRole) {
61
auto
row =
Data
.at(index.row());
62
auto
flag = row.at(row.size() - 1);
63
if
(flag ==
"I"
) {
64
return
SchemaStyle::get_color
(
"foreground"
,
"inherited"
);
65
}
66
}
else
if
(role == Qt::BackgroundRole) {
67
auto
row =
Data
.at(index.row());
68
auto
flag = row.at(row.size() - 1);
69
if
(flag ==
"I"
) {
70
return
SchemaStyle::get_color
(
"background"
,
"inherited"
);
71
}
72
}
73
return
QVariant();
74
}
75
76
QStringList
77
dbse::CustomModelInterface::getRowFromIndex
(QModelIndex& index)
78
{
79
if
(!index.isValid()) {
80
return
QStringList();
81
}
82
83
return
Data
.at(index.row());
84
}
SchemaCustomModelInterface.hpp
SchemaKernelWrapper.hpp
SchemaStyle.hpp
dbse::CustomModelInterface::HeaderList
QStringList HeaderList
Definition
SchemaCustomModelInterface.hpp:30
dbse::CustomModelInterface::data
QVariant data(const QModelIndex &index, int role) const
Definition
SchemaCustomModelInterface.cpp:56
dbse::CustomModelInterface::rowCount
int rowCount(const QModelIndex &parent) const
Definition
SchemaCustomModelInterface.cpp:21
dbse::CustomModelInterface::headerData
QVariant headerData(int section, Qt::Orientation orientation, int role) const
Definition
SchemaCustomModelInterface.cpp:42
dbse::CustomModelInterface::getRowFromIndex
QStringList getRowFromIndex(QModelIndex &index)
Definition
SchemaCustomModelInterface.cpp:77
dbse::CustomModelInterface::~CustomModelInterface
~CustomModelInterface()
Definition
SchemaCustomModelInterface.cpp:18
dbse::CustomModelInterface::flags
Qt::ItemFlags flags(const QModelIndex &index) const
Definition
SchemaCustomModelInterface.cpp:35
dbse::CustomModelInterface::CustomModelInterface
CustomModelInterface(QStringList Headers, QObject *parent=nullptr)
Including Schema Editor.
Definition
SchemaCustomModelInterface.cpp:12
dbse::CustomModelInterface::columnCount
int columnCount(const QModelIndex &parent) const
Definition
SchemaCustomModelInterface.cpp:28
dbse::CustomModelInterface::Data
QList< QStringList > Data
Definition
SchemaCustomModelInterface.hpp:31
dbse::SchemaStyle::get_color
static QColor get_color(const QString &item, const QString &group)
Definition
SchemaStyle.cpp:105
Generated on
for DUNE-DAQ by
1.18.0