DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
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
10#include "dbe/SchemaStyle.hpp"
11
12dbse::CustomModelInterface::CustomModelInterface(QStringList Headers, QObject* parent)
13 : QAbstractTableModel(parent)
14 , HeaderList(Headers)
15{
16}
17
19
20int
21dbse::CustomModelInterface::rowCount(const QModelIndex& parent) const
22{
23 Q_UNUSED(parent)
24 return Data.size();
25}
26
27int
28dbse::CustomModelInterface::columnCount(const QModelIndex& parent) const
29{
30 Q_UNUSED(parent)
31 return HeaderList.size();
32}
33
34Qt::ItemFlags
35dbse::CustomModelInterface::flags(const QModelIndex& index) const
36{
37 Q_UNUSED(index)
38 return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
39}
40
41QVariant
42dbse::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
55QVariant
56dbse::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
76QStringList
78{
79 if (!index.isValid()) {
80 return QStringList();
81 }
82
83 return Data.at(index.row());
84}
QVariant data(const QModelIndex &index, int role) const
int rowCount(const QModelIndex &parent) const
QVariant headerData(int section, Qt::Orientation orientation, int role) const
QStringList getRowFromIndex(QModelIndex &index)
Qt::ItemFlags flags(const QModelIndex &index) const
CustomModelInterface(QStringList Headers, QObject *parent=nullptr)
Including Schema Editor.
int columnCount(const QModelIndex &parent) const
static QColor get_color(const QString &item, const QString &group)