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