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 apps/SchemaEditor/SchemaCustomModelInterface.cpp).
5
9#include "dbe/SchemaStyle.hpp"
10
11dbse::CustomModelInterface::CustomModelInterface ( QStringList Headers, QObject * parent )
12 : QAbstractTableModel ( parent ),
13 HeaderList ( Headers )
14{
15}
16
20
21int dbse::CustomModelInterface::rowCount ( const QModelIndex & parent ) const
22{
23 Q_UNUSED ( parent )
24 return Data.size();
25}
26
27int dbse::CustomModelInterface::columnCount ( const QModelIndex & parent ) const
28{
29 Q_UNUSED ( parent )
30 return HeaderList.size();
31}
32
33Qt::ItemFlags dbse::CustomModelInterface::flags ( const QModelIndex & index ) const
34{
35 Q_UNUSED ( index )
36 return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
37}
38
39QVariant dbse::CustomModelInterface::headerData ( int section, Qt::Orientation orientation,
40 int role ) const
41{
42 if ( role != Qt::DisplayRole )
43 {
44 return QVariant();
45 }
46
47 if ( orientation == Qt::Horizontal )
48 {
49 return HeaderList.at ( section );
50 }
51
52 return QVariant();
53}
54
55QVariant dbse::CustomModelInterface::data ( const QModelIndex & index, int role ) const
56{
57 if ( role == Qt::DisplayRole ) {
58 return Data.value ( index.row() ).value ( index.column() );
59 }
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 }
67 else if (role == Qt::BackgroundRole) {
68 auto row = Data.at(index.row());
69 auto flag = row.at(row.size()-1);
70 if (flag == "I") {
71 return SchemaStyle::get_color("background", "inherited");
72 }
73 }
74 return QVariant();
75}
76
77QStringList dbse::CustomModelInterface::getRowFromIndex ( QModelIndex & index )
78{
79 if ( !index.isValid() )
80 {
81 return QStringList();
82 }
83
84 return Data.at ( index.row() );
85}
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)